Commit b965e9a1 by caoyanzhi

调整菜单配置交互

parent 41a0e6f1
...@@ -147,7 +147,7 @@ export default { ...@@ -147,7 +147,7 @@ export default {
if (allMenuIds.some(item => item == el.menuId)) { if (allMenuIds.some(item => item == el.menuId)) {
let allSubId = []; let allSubId = [];
if (Array.isArray(el.children)) { if (Array.isArray(el.children)) {
allSubId = el.children.map(item => item.menuId); allSubId = getAllSubMenuIds(el.children);
} }
// 如果el的allSubId都在allMenuIds中,则认为el需要被勾选,需要把el.menuId放入result中 // 如果el的allSubId都在allMenuIds中,则认为el需要被勾选,需要把el.menuId放入result中
if (allSubId.length == 0 || allSubId.every(el => allMenuIds.some(item => item == el))) { if (allSubId.length == 0 || allSubId.every(el => allMenuIds.some(item => item == el))) {
...@@ -160,6 +160,16 @@ export default { ...@@ -160,6 +160,16 @@ export default {
}) })
return result; return result;
} }
function getAllSubMenuIds(menuList) {
let result = [];
menuList.forEach(el => {
result.push(el.menuId);
if (Array.isArray(el.children)) {
result = result.concat(getAllSubMenuIds(el.children));
}
})
return result;
}
}, },
// 将平铺的数据转为树形结构 // 将平铺的数据转为树形结构
flatDataToTree(data) { flatDataToTree(data) {
......
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