Commit 8fa1b415 by 无尘

fix: 修改管理员角色菜单

parent 2b2549dd
......@@ -195,42 +195,24 @@ export default {
// 同时更新roleData中menuIds的数据
onCheckedChange(checkedId) {
let menuIds = [];
let flatMenu = [];
let allMenuIds = [];
for(let key in checkedId) {
menuIds = menuIds.concat(checkedId[key]);
}
this.tabList = this.tabList.map(el => {
if (el.appType == this.activeType) {
el.checkedId = checkedId;
flatMenu = el.flatMenu;
}
return el;
})
// 根据任意层级的子节点向上查找全部的父节点,存入allMenuIds中,然后过滤掉重复的menuId
menuIds.map(el => {
allMenuIds = allMenuIds.concat(getParentIds(el, flatMenu));
})
allMenuIds = allMenuIds.filter((el, index) => index == allMenuIds.findIndex(item => item == el));
// 根据选择的菜单,设置对应选择的 ids
if (this.roleData.menuIds.some(el => el.appType == this.activeType)) {
this.roleData.menuIds.forEach(el => {
if (el.appType == this.activeType) {
el.menuIds = allMenuIds;
el.menuIds = menuIds;
}
})
} else {
this.roleData.menuIds.push({ appType: this.activeType, menuIds: allMenuIds });
}
function getParentIds(menuId, menuList) {
let result = [ menuId ];
menuList.some(el => {
if (el.menuId == menuId && el.parentId > 0) {
result = result.concat(getParentIds(el.parentId, menuList));
}
return el.menuId == menuId;
})
return result;
this.roleData.menuIds.push({ appType: this.activeType, menuIds: menuIds });
}
},
// 新建、编辑角色的保存
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment