From 7b0a012ae53ea23df4dbc5d69f7936fc96b0b75b Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Mon, 8 Jun 2020 12:52:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=AE=A1=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=A7=92=E8=89=B2bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/superAdmin/authority/authority.vue | 217 ++++++++++-------- 1 file changed, 123 insertions(+), 94 deletions(-) diff --git a/web/src/view/superAdmin/authority/authority.vue b/web/src/view/superAdmin/authority/authority.vue index 58b2233d..66b2bd4f 100644 --- a/web/src/view/superAdmin/authority/authority.vue +++ b/web/src/view/superAdmin/authority/authority.vue @@ -16,29 +16,48 @@ - + - - - + + - + @@ -51,15 +70,15 @@ - + - + - + - + @@ -74,7 +93,7 @@ import { deleteAuthority, createAuthority, updateAuthority, - copyAuthority + copyAuthority } from '@/api/authority' import Menus from '@/view/superAdmin/authority/components/menus' @@ -87,16 +106,18 @@ export default { mixins: [infoList], data() { return { - AuthorityOption:[{ - authorityId:"0", - authorityName:"根角色" - }], + AuthorityOption: [ + { + authorityId: '0', + authorityName: '根角色' + } + ], listApi: getAuthorityList, drawer: false, - dialogType:"add", + dialogType: 'add', activeRow: {}, activeUserId: 0, - dialogTitle:"新增角色", + dialogTitle: '新增角色', dialogFormVisible: false, apiDialogFlag: false, copyForm: {}, @@ -124,10 +145,10 @@ export default { Datas }, methods: { - autoEnter(activeName, oldActiveName){ - const paneArr = ["menus","apis","datas"] - if(oldActiveName){ - if(this.$refs[paneArr[oldActiveName]].needConfirm){ + autoEnter(activeName, oldActiveName) { + const paneArr = ['menus', 'apis', 'datas'] + if (oldActiveName) { + if (this.$refs[paneArr[oldActiveName]].needConfirm) { this.$refs[paneArr[oldActiveName]].enterAndNext() this.$refs[paneArr[oldActiveName]].needConfirm = false } @@ -136,13 +157,13 @@ export default { // 拷贝角色 copyAuthority(row) { this.setOptions() - this.dialogTitle = "拷贝角色" - this.dialogType = "copy" - for(let k in this.form) { + this.dialogTitle = '拷贝角色' + this.dialogType = 'copy' + for (let k in this.form) { this.form[k] = row[k] } this.copyForm = row - this.dialogFormVisible = true; + this.dialogFormVisible = true }, opdendrawer(row) { this.drawer = true @@ -174,8 +195,10 @@ export default { }, // 初始化表单 initForm() { - this.$refs.authorityForm.resetFields() - this.form = { + if (this.$refs.authorityForm) { + this.$refs.authorityForm.resetFields() + } + this.form = { authorityId: '', authorityName: '', parentId: '0' @@ -212,7 +235,7 @@ export default { this.closeDialog() } } - break; + break case 'edit': { const res = await updateAuthority(this.form) @@ -225,82 +248,88 @@ export default { this.closeDialog() } } - break; - case 'copy': { - const data = { - "authority": { - "authorityId": "string", - "authorityName": "string", - "datauthorityId": [], - "parentId": "string", - }, - "oldAuthorityId": 0 - } - data.authority.authorityId = this.form.authorityId - data.authority.authorityName = this.form.authorityName - data.authority.parentId = this.form.parentId - data.authority.dataAuthorityId = this. copyForm.dataAuthorityId - data.oldAuthorityId = this.copyForm.authorityId - const res = await copyAuthority(data) - if(res.code == 0) { - this.$message({ - type: 'success', - message: '复制成功!' - }) - this.getTableData() - } + break + case 'copy': { + const data = { + authority: { + authorityId: 'string', + authorityName: 'string', + datauthorityId: [], + parentId: 'string' + }, + oldAuthorityId: 0 + } + data.authority.authorityId = this.form.authorityId + data.authority.authorityName = this.form.authorityName + data.authority.parentId = this.form.parentId + data.authority.dataAuthorityId = this.copyForm.dataAuthorityId + data.oldAuthorityId = this.copyForm.authorityId + const res = await copyAuthority(data) + if (res.code == 0) { + this.$message({ + type: 'success', + message: '复制成功!' + }) + this.getTableData() } + } } - + this.initForm() this.dialogFormVisible = false } }) }, - setOptions(){ - this.AuthorityOption = [{ - authorityId:"0", - authorityName:"根角色" - }] - this.setAuthorityOptions(this.tableData,this.AuthorityOption,false) - }, - setAuthorityOptions(AuthorityData,optionsData,disabled){ - AuthorityData&&AuthorityData.map(item=>{ - if(item.children&&item.children.length){ - const option = { - authorityId:item.authorityId, - authorityName:item.authorityName, - disabled:disabled||item.authorityId == this.form.authorityId, - children:[] + setOptions() { + this.AuthorityOption = [ + { + authorityId: '0', + authorityName: '根角色' } - this.setAuthorityOptions(item.children,option.children,disabled||item.authorityId == this.form.authorityId) - optionsData.push(option) - }else{ - const option = { - authorityId:item.authorityId, - authorityName:item.authorityName, - disabled:disabled||item.authorityId == this.form.authorityId, + ] + this.setAuthorityOptions(this.tableData, this.AuthorityOption, false) + }, + setAuthorityOptions(AuthorityData, optionsData, disabled) { + AuthorityData && + AuthorityData.map(item => { + if (item.children && item.children.length) { + const option = { + authorityId: item.authorityId, + authorityName: item.authorityName, + disabled: disabled || item.authorityId == this.form.authorityId, + children: [] + } + this.setAuthorityOptions( + item.children, + option.children, + disabled || item.authorityId == this.form.authorityId + ) + optionsData.push(option) + } else { + const option = { + authorityId: item.authorityId, + authorityName: item.authorityName, + disabled: disabled || item.authorityId == this.form.authorityId + } + optionsData.push(option) } - optionsData.push(option) - } - }) + }) }, // 增加角色 addAuthority(parentId) { this.initForm() - this.dialogTitle = "新增角色" - this.dialogType = "add" + this.dialogTitle = '新增角色' + this.dialogType = 'add' this.form.parentId = parentId this.setOptions() this.dialogFormVisible = true - }, // 编辑角色 editAuthority(row) { this.setOptions() - this.dialogTitle = "编辑角色" - this.dialogType = "edit" - for(let key in this.form){ + this.dialogTitle = '编辑角色' + this.dialogType = 'edit' + for (let key in this.form) { this.form[key] = row[key] } this.setOptions()