角色管理菜单

This commit is contained in:
2023-06-14 10:59:24 +08:00
parent 9b9de383eb
commit cf3637aa2b

View File

@@ -35,7 +35,7 @@
<div class="tree_wrapper">
<div class="tree_header">
<span>角色名称</span>
<button class="button button--primary grid_button button1" :class="{'button--info': pkId === ''}" :disabled="disabled" @click="toSave">保存</button>
<button class="button button--primary grid_button button1" :class="{'button--info': pkId === '' || $refs.tree.getCheckedKeys().length === 0}" :disabled="disabled" @click="toSave">保存</button>
</div>
<div class="tree_body_container">
<el-tree
@@ -43,6 +43,7 @@
show-checkbox
default-expand-all
node-key="menuId"
:default-checked-keys=checkedKeys
ref="tree"
highlight-current
:props="defaultProps">
@@ -101,6 +102,7 @@ export default {
children: 'children',
label: 'title'
},
checkedKeys: [],
pkObj: {},
pkId: '',
unclick: false,
@@ -245,6 +247,12 @@ export default {
let res = await sysRoleMenu(this.pkId, arr)
if (res.code === '1') {
this.toast(res.desc)
this.pkId = ''
this.checkedKeys = []
this.tree.map(e => {
this.$refs.tree.setChecked(e, false, true)
})
this._sysRoleQuery()
} else {
this.toast(res.desc)
}
@@ -258,6 +266,9 @@ export default {
return
}
let arr = this.$refs.tree.getCheckedKeys()
if (arr.length === 0) {
return
}
let arr1 = []
arr.map(el => {
arr1.push({menuId: el})
@@ -266,6 +277,18 @@ export default {
},
toCheck (e) {
this.pkId = this.pkId === e.roleId ? '' : e.roleId
this.checkedKeys = this.pkId === e.roleId ? e.menus : []
this.tree.map(e => {
this.$refs.tree.setChecked(e, false, true)
})
if (this.pkId === e.roleId) {
this.checkedKeys = e.menus
console.log(99)
} else {
this.checkedKeys = []
console.log(100)
}
console.log(this.checkedKeys)
}
}
}