diff --git a/web/src/view/superAdmin/authority/authority.vue b/web/src/view/superAdmin/authority/authority.vue index 56cfde31..09053280 100644 --- a/web/src/view/superAdmin/authority/authority.vue +++ b/web/src/view/superAdmin/authority/authority.vue @@ -27,20 +27,14 @@ - - - + + @@ -218,60 +212,58 @@ export default { } }) }, - getAuthorityList(AuthorityData){ - AuthorityData.map(item=>{ - this.AuthorityOption.push({ - authorityId:item.authorityId, - authorityName:item.authorityName - }) - if(item.children){ - this.getAuthorityList(item.children) - } - }) + setOptions(){ + this.AuthorityOption = [{ + authorityId:"0", + authorityName:"根角色" + }] + this.setAuthorityOptions(this.tableData,this.AuthorityOption,false) }, - findAuthoritySelf(authority,authData,outData){ - authData.some(item=>{ - if(item.authorityId == authority.authorityId){ - outData.push(item) - return true + setAuthorityOptions(AuthorityData,optionsData,disabled){ + AuthorityData&&AuthorityData.map(item=>{ + if(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) } - this.findAuthoritySelf(authority,item.children,outData) - }) - }, - findAllChild(authority,array){ - authority&&authority.map(item=>{ - array.push(item.authorityId) - this.findAllChild(item.children,array) }) }, - canSelect(authority){ - const array = [] - const arrayIds = [] - this.findAuthoritySelf({authorityId:this.form.authorityId},this.tableData,array) - this.findAllChild(array,arrayIds) - return arrayIds.indexOf(authority.authorityId)>-1 - }, // 增加角色 addAuthority(parentId) { - this. dialogTitle = "新增角色" + this.dialogTitle = "新增角色" this.dialogType = "add" this.form.parentId = parentId + this.setOptions() this.dialogFormVisible = true + }, - // 增加角色 + // 编辑角色 editAuthority(row) { - this. dialogTitle = "编辑角色" + this.setOptions() + this.dialogTitle = "编辑角色" this.dialogType = "edit" for(let key in this.form){ this.form[key] = row[key] } + this.setOptions() this.dialogFormVisible = true } }, async created() { this.pageSize = 999 await this.getTableData() - this.getAuthorityList(this.tableData) } } diff --git a/web/src/view/superAdmin/menu/menu.vue b/web/src/view/superAdmin/menu/menu.vue index 7c742f0e..76fd5881 100644 --- a/web/src/view/superAdmin/menu/menu.vue +++ b/web/src/view/superAdmin/menu/menu.vue @@ -47,21 +47,14 @@ - - - - + + @@ -143,6 +136,34 @@ export default { } }, methods: { + setOptions(){ + this.menuOption = [{ + ID:"0", + title:"根目录" + }] + this.setMenuOptions(this.tableData,this.menuOption,false) + }, + setMenuOptions(menuData,optionsData,disabled){ + menuData&&menuData.map(item=>{ + if(item.children.length){ + const option = { + title:item.meta.title, + ID:String(item.ID), + disabled:disabled||item.ID == this.form.ID, + children:[] + } + this.setMenuOptions(item.children,option.children,disabled||item.ID == this.form.ID) + optionsData.push(option) + }else{ + const option = { + title:item.meta.title, + ID:String(item.ID), + disabled:disabled||item.ID == this.form.ID, + } + optionsData.push(option) + } + }) + }, handleClose(done) { this.initForm() done() @@ -239,6 +260,7 @@ export default { this.dialogTitle = "新增菜单" this.form.parentId = String(id) this.isEdit = false + this.setOptions() this.dialogFormVisible = true }, // 修改菜单方法 @@ -246,41 +268,9 @@ export default { this.dialogTitle = "编辑菜单" const res = await getBaseMenuById({ id }) this.form = res.data.menu - this.dialogFormVisible = true this.isEdit = true - }, - getMenuList(MenuData){ - MenuData.map(item=>{ - this.menuOption.push({ - ID:String(item.ID), - title:item.meta.title - }) - if(item.children){ - this.getMenuList(item.children) - } - }) - }, - findAuthoritySelf(mune,muneData,outData){ - muneData&&muneData.some(item=>{ - if(item.ID == mune.ID){ - outData.push(item) - return true - } - this.findAuthoritySelf(mune,item.children,outData) - }) - }, - findAllChild(menu,array){ - menu&&menu.map(item=>{ - array.push(String(item.ID)) - this.findAllChild(item.children,array) - }) - }, - canSelect(authority){ - const array = [] - const arrayIds = [] - this.findAuthoritySelf({ID:this.form.ID},this.tableData,array) - this.findAllChild(array,arrayIds) - return arrayIds.indexOf(authority.ID)>-1 + this.setOptions() + this.dialogFormVisible = true }, }, async created() { diff --git a/web/src/view/superAdmin/user/user.vue b/web/src/view/superAdmin/user/user.vue index 7d5be00a..b1ede5ba 100644 --- a/web/src/view/superAdmin/user/user.vue +++ b/web/src/view/superAdmin/user/user.vue @@ -16,18 +16,14 @@ @@ -82,14 +78,14 @@ - - - + +