¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <TableLayout :permissions="['system:permission:query']"> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <el-tabs v-model="currentTab" v-loading="isWorking.search"> |
| | | <el-tab-pane :name="'module'+module.id" :label="module.name" v-for="module in tableData.list" :key="module.id"> |
| | | <ul class="toolbar" v-permissions="['system:permission:create', 'system:permission:delete']"> |
| | | <li><el-button type="primary" @click="$refs.operaPermissionWindow.open('æ°å»ºç³»ç»æé', module)" icon="el-icon-plus" v-permissions="['system:permission:create']">æ°å»º</el-button></li> |
| | | <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['system:permission:delete']">å é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | :data="module.children" |
| | | :ref="'module' + module.id" |
| | | row-key="id" |
| | | stripe |
| | | default-expand-all |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" fixed="left" width="55"></el-table-column> |
| | | <el-table-column prop="name" label="æéåç§°" fixed="left" min-width="200px"></el-table-column> |
| | | <el-table-column prop="code" label="æéç¼ç " min-width="200px"></el-table-column> |
| | | <el-table-column prop="remark" label="æé夿³¨" min-width="120px"></el-table-column> |
| | | <el-table-column prop="createUser" label="å建人" min-width="100px"> |
| | | <template slot-scope="{row}">{{row.createUserInfo == null ? '' : row.createUserInfo.username}}</template> |
| | | </el-table-column> |
| | | <el-table-column prop="createTime" label="å建æ¶é´" min-width="140px"></el-table-column> |
| | | <el-table-column prop="updateUser" label="æ´æ°äºº" min-width="100px"> |
| | | <template slot-scope="{row}">{{row.updateUserInfo == null ? '' : row.updateUserInfo.username}}</template> |
| | | </el-table-column> |
| | | <el-table-column prop="updateTime" label="æ´æ°æ¶é´" min-width="140px"></el-table-column> |
| | | <el-table-column |
| | | v-if="containPermissions(['system:permission:update', 'system:permission:delete'])" |
| | | label="æä½" |
| | | min-width="150" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <!-- 模åç¼è¾&å é¤ --> |
| | | <template v-if="row.type === 'module'"> |
| | | <el-button type="text" @click="$refs.operaModuleWindow.open('ç¼è¾æ¨¡å', row)" icon="el-icon-edit" v-permissions="['system:permission:update']">ç¼è¾</el-button> |
| | | <el-button type="text" @click="$refs.operaPermissionWindow.open('æ°å»ºç³»ç»æé', row)" icon="el-icon-edit" v-permissions="['system:permission:update']">æ·»å æé</el-button> |
| | | <el-button v-if="!row.fixed" type="text" @click="deletePermission(row)" icon="el-icon-delete" v-permissions="['system:permission:delete']">å é¤</el-button> |
| | | </template> |
| | | <!-- æéç¼è¾&å é¤ --> |
| | | <template v-else> |
| | | <el-button v-if="!row.fixed" type="text" @click="$refs.operaPermissionWindow.open('ç¼è¾ç³»ç»æé', row)" icon="el-icon-edit" v-permissions="['system:permission:update']">ç¼è¾</el-button> |
| | | <el-button v-if="!row.fixed" type="text" @click="deletePermission(row)" icon="el-icon-delete" v-permissions="['system:permission:delete']">å é¤</el-button> |
| | | </template> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaPermissionWindow ref="operaPermissionWindow" @success="search"/> |
| | | <!-- ç¼è¾æé模å --> |
| | | <OperaModuleWindow ref="operaModuleWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import OperaPermissionWindow from '@/components/system/permission/OperaPermissionWindow' |
| | | import OperaModuleWindow from '@/components/system/permission/OperaModuleWindow' |
| | | |
| | | export default { |
| | | name: 'SystemPermission', |
| | | extends: BaseTable, |
| | | components: { OperaModuleWindow, OperaPermissionWindow, TableLayout }, |
| | | data () { |
| | | return { |
| | | // å½åéä¸ç模å |
| | | currentTab: null |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * è¦ç页ç åæ´å¤ç |
| | | */ |
| | | handlePageChange () { |
| | | this.isWorking.search = true |
| | | this.api.fetchTree() |
| | | .then(data => { |
| | | this.tableData.list = data |
| | | this.currentTab = 'module' + this.tableData.list[0].id |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking.search = false |
| | | }) |
| | | }, |
| | | /** |
| | | * è¦çå é¤å¤ç |
| | | */ |
| | | deletePermission (row, childConfirm = true) { |
| | | this.__checkApi() |
| | | let message = `确认å é¤${this.module}ã${row[this.configData['field.main']]}ãå?` |
| | | if (childConfirm && row.children != null && row.children.length > 0) { |
| | | message = `确认å é¤${this.module}ã${row[this.configData['field.main']]}ãåå
¶å${this.module}å?` |
| | | } |
| | | this.$dialog.deleteConfirm(message) |
| | | .then(() => { |
| | | this.isWorking.delete = true |
| | | this.api.deletePermission({ |
| | | id: row.type === 'module' ? null : row.id, // 模åä¸ä¼ ID |
| | | modulePrefix: row.type === 'module' ? row.modulePath : null // æéä¸ä¼ 模å |
| | | }) |
| | | .then(() => { |
| | | this.$tip.apiSuccess('å 餿å') |
| | | this.__afterDelete() |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking.delete = false |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | }, |
| | | /** |
| | | * è¦çæ¹éå é¤å¤ç |
| | | */ |
| | | deleteByIdInBatch (childConfirm = true) { |
| | | this.__checkApi() |
| | | if (this.tableData.selectedRows.length === 0) { |
| | | this.$tip.warning('请è³å°éæ©ä¸æ¡æ°æ®') |
| | | return |
| | | } |
| | | let message = `确认å é¤å·²éä¸ç ${this.tableData.selectedRows.length} æ¡${this.module}è®°å½å?` |
| | | if (childConfirm) { |
| | | const containChildrenRows = [] |
| | | for (const row of this.tableData.selectedRows) { |
| | | if (row.children != null && row.children.length > 0) { |
| | | containChildrenRows.push(row[this.configData['field.main']]) |
| | | } |
| | | } |
| | | if (containChildrenRows.length > 0) { |
| | | message = `æ¬æ¬¡å°å é¤${this.module}ã${containChildrenRows.join('ã')}ãåå
¶å${this.module}è®°å½ï¼ç¡®è®¤å é¤åï¼` |
| | | } |
| | | } |
| | | this.$dialog.deleteConfirm(message) |
| | | .then(() => { |
| | | this.isWorking.delete = true |
| | | this.api.deletePermissionInBatch(this.tableData.selectedRows.map(row => { |
| | | return { |
| | | id: row.type === 'module' ? null : row.id, // 模åä¸ä¼ ID |
| | | modulePrefix: row.type === 'module' ? row.modulePath : null // æéä¸ä¼ 模å |
| | | } |
| | | })) |
| | | .then(() => { |
| | | this.$tip.apiSuccess('å 餿å') |
| | | this.__afterDelete(this.tableData.selectedRows.length) |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking.delete = false |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: 'æé', |
| | | api: '/system/permission' |
| | | }) |
| | | this.search() |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | /deep/ .table-content { |
| | | margin-top: 0; |
| | | .table-wrap { |
| | | padding-bottom: 16px; |
| | | } |
| | | } |
| | | /deep/ .el-tabs__nav-prev, /deep/ .el-tabs__nav-next { |
| | | line-height: 40px; |
| | | } |
| | | </style> |