角色管理
This commit is contained in:
@@ -112,7 +112,7 @@
|
||||
check-strictly
|
||||
accordion
|
||||
show-checkbox
|
||||
node-key="menu_id"
|
||||
node-key="menuId"
|
||||
@check="menuChange"
|
||||
/>
|
||||
</el-card>
|
||||
@@ -164,7 +164,7 @@ export default {
|
||||
methods: {
|
||||
getMenuDatas(node, resolve) {
|
||||
setTimeout(() => {
|
||||
getMenusTree(node.data.menu_id ? node.data.menu_id : 0).then(res => {
|
||||
getMenusTree(node.data.menuId ? node.data.menuId : 0).then(res => {
|
||||
resolve(res)
|
||||
})
|
||||
}, 100)
|
||||
@@ -184,7 +184,7 @@ export default {
|
||||
// 初始化默认选中的key
|
||||
_this.menuIds = []
|
||||
_this.menus.forEach(function(data) {
|
||||
_this.menuIds.push(data.menu_id)
|
||||
_this.menuIds.push(data.menuId)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -203,20 +203,20 @@ export default {
|
||||
// 清空菜单的选中
|
||||
this.$refs.menu.setCheckedKeys([])
|
||||
// 保存当前的角色id
|
||||
this.currentId = val.role_id
|
||||
this.currentId = val.roleId
|
||||
// 初始化默认选中的key
|
||||
this.menuIds = []
|
||||
val.menus.forEach(function(data) {
|
||||
_this.menuIds.push(data.menu_id)
|
||||
_this.menuIds.push(data.menuId)
|
||||
})
|
||||
this.showButton = true
|
||||
}
|
||||
},
|
||||
menuChange(menu) {
|
||||
// 获取该节点的所有子节点,id 包含自身
|
||||
getChild(menu.menu_id).then(childIds => {
|
||||
getChild(menu.menuId).then(childIds => {
|
||||
// 判断是否在 menuIds 中,如果存在则删除,否则添加
|
||||
if (this.menuIds.indexOf(menu.menu_id) !== -1) {
|
||||
if (this.menuIds.indexOf(menu.menuId) !== -1) {
|
||||
for (let i = 0; i < childIds.length; i++) {
|
||||
const index = this.menuIds.indexOf(childIds[i])
|
||||
if (index !== -1) {
|
||||
@@ -237,10 +237,10 @@ export default {
|
||||
// 保存菜单
|
||||
saveMenu() {
|
||||
this.menuLoading = true
|
||||
const role = { role_id: this.currentId, menus: [] }
|
||||
const role = { roleId: this.currentId, menus: [] }
|
||||
// 得到已选中的 key 值
|
||||
this.menuIds.forEach(function(menu_id) {
|
||||
const menu = { menu_id: menu_id }
|
||||
this.menuIds.forEach(function(menuId) {
|
||||
const menu = { menuId: menuId }
|
||||
role.menus.push(menu)
|
||||
})
|
||||
crudRoles.editMenu(role).then(() => {
|
||||
@@ -257,7 +257,7 @@ export default {
|
||||
// 无刷新更新 表格数据
|
||||
crudRoles.get(this.currentId).then(res => {
|
||||
for (let i = 0; i < this.crud.data.length; i++) {
|
||||
if (res.menu_id === this.crud.data[i].menu_id) {
|
||||
if (res.menuId === this.crud.data[i].menuId) {
|
||||
this.crud.data[i] = res
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user