角色管理菜单
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
<div class="tree_wrapper">
|
<div class="tree_wrapper">
|
||||||
<div class="tree_header">
|
<div class="tree_header">
|
||||||
<span>角色名称</span>
|
<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>
|
||||||
<div class="tree_body_container">
|
<div class="tree_body_container">
|
||||||
<el-tree
|
<el-tree
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
show-checkbox
|
show-checkbox
|
||||||
default-expand-all
|
default-expand-all
|
||||||
node-key="menuId"
|
node-key="menuId"
|
||||||
|
:default-checked-keys=checkedKeys
|
||||||
ref="tree"
|
ref="tree"
|
||||||
highlight-current
|
highlight-current
|
||||||
:props="defaultProps">
|
:props="defaultProps">
|
||||||
@@ -101,6 +102,7 @@ export default {
|
|||||||
children: 'children',
|
children: 'children',
|
||||||
label: 'title'
|
label: 'title'
|
||||||
},
|
},
|
||||||
|
checkedKeys: [],
|
||||||
pkObj: {},
|
pkObj: {},
|
||||||
pkId: '',
|
pkId: '',
|
||||||
unclick: false,
|
unclick: false,
|
||||||
@@ -245,6 +247,12 @@ export default {
|
|||||||
let res = await sysRoleMenu(this.pkId, arr)
|
let res = await sysRoleMenu(this.pkId, arr)
|
||||||
if (res.code === '1') {
|
if (res.code === '1') {
|
||||||
this.toast(res.desc)
|
this.toast(res.desc)
|
||||||
|
this.pkId = ''
|
||||||
|
this.checkedKeys = []
|
||||||
|
this.tree.map(e => {
|
||||||
|
this.$refs.tree.setChecked(e, false, true)
|
||||||
|
})
|
||||||
|
this._sysRoleQuery()
|
||||||
} else {
|
} else {
|
||||||
this.toast(res.desc)
|
this.toast(res.desc)
|
||||||
}
|
}
|
||||||
@@ -258,6 +266,9 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let arr = this.$refs.tree.getCheckedKeys()
|
let arr = this.$refs.tree.getCheckedKeys()
|
||||||
|
if (arr.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let arr1 = []
|
let arr1 = []
|
||||||
arr.map(el => {
|
arr.map(el => {
|
||||||
arr1.push({menuId: el})
|
arr1.push({menuId: el})
|
||||||
@@ -266,6 +277,18 @@ export default {
|
|||||||
},
|
},
|
||||||
toCheck (e) {
|
toCheck (e) {
|
||||||
this.pkId = this.pkId === e.roleId ? '' : e.roleId
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user