朱思禹提交:修改检测菜单是否存在的方法

init
Administrator 4 years ago
parent 3691805e0c
commit 81621d9997

@ -387,65 +387,33 @@ const dealMenuFromInterface=(_list,pName="")=>{
/* /*
*判断某个菜单是否存在 *判断某个菜单是否存在
* parentId: ""获取一级菜单或其子菜单是否存在["","","",]获取多级菜单或其子菜单是否存在 *jurisdictionAry 目标菜单路径 id 从第一级开始
* 数组的值的先后顺序一定是按照菜单的由父到子的顺序
* */ * */
OfficeMenuConfig.menuIsExist=(parentId,childId=null)=>{ OfficeMenuConfig.menuIsExist=(jurisdictionAry = [])=>{
let i = 0; let isExist = true;
if (Array.isArray(parentId)){ if (jurisdictionAry && this.TypesCheck.isArray(jurisdictionAry) && jurisdictionAry.length > 0){
let len = parentId.length; let ary = secondMenuList;
let menu = _.cloneDeep(secondMenuList); for (let i = 0; i < jurisdictionAry.length; i++){
let count = 0; let menuString = jurisdictionAry[i];
/********找到最里层的菜单********/ if (ary.some((item)=>{return item.id === menuString})){
while(count < len){ let menu = ary.filter((item)=>{return item.id === menuString})[0]
let parId = parentId[count]; if (i < jurisdictionAry.length - 1){
for (i = 0; i < menu.length; i ++){ if (menu.children && menu.children.length > 0){
if (menu[i].id === parId){ ary = menu.children;
menu = _.cloneDeep(menu[i].children);
break;
}
}
if (menu === undefined || menu === null || menu.length === 0 || menu[0].parentId !== parId){//当某个父级菜单不存在时直接返回false
return false;
}
count += 1;
}
/********查找结束***************/
if (childId === null){
return true;
}else{ }else{
if (menu && menu.length > 0){ isExist = false;
for (i = 0; i < menu.length; i++){ break
if (menu[i].id === childId){
return true;
}
} }
} }
}
}else{
for (i = 0; i < secondMenuList.length; i++){
if (secondMenuList[i].id === parentId){
if(childId === null){
return true;
}else{ }else{
let children = secondMenuList[i].children; isExist = false;
if (children !== null && children !== undefined){
for (let j = 0; j < children.length; j++){
if (children[j].id === childId){
return true;
}
}
}
}
break; break;
} }
} }
}else{
isExist = false;
} }
return isExist;
return false;
}; };
/* /*

Loading…
Cancel
Save