|
|
@@ -30,19 +30,22 @@ export function sortMenu(menus: TreeRoleMenuData[]) {
|
|
|
// 是一级菜单找是否在临时区域有保存的二级菜单
|
|
|
const tempList = tempAreaMap.get(id);
|
|
|
|
|
|
- result.push({...tempValue, children: tempList ? [...tempList] : []});
|
|
|
+ tempList && (tempValue.children = [...tempList]);
|
|
|
+
|
|
|
+ result.push(tempValue);
|
|
|
} else {
|
|
|
// 二级菜单判断是否有对应的一级菜单 如果有加到父组件的children里
|
|
|
// 如果没有放在临时Map中
|
|
|
const idx = result.findIndex(val => val.key === pId);
|
|
|
|
|
|
if (idx >= 0) {
|
|
|
- result[idx].children!.push(tempValue);
|
|
|
+ result[idx].children
|
|
|
+ ? result[idx].children!.push(tempValue)
|
|
|
+ : (result[idx].children = [tempValue]);
|
|
|
} else {
|
|
|
- if (tempAreaMap.has(pId))
|
|
|
- tempAreaMap.get(pId)!.push(tempValue);
|
|
|
- else
|
|
|
- tempAreaMap.set(pId, [tempValue]);
|
|
|
+ tempAreaMap.has(pId)
|
|
|
+ ? tempAreaMap.get(pId)!.push(tempValue)
|
|
|
+ : tempAreaMap.set(pId, [tempValue]);
|
|
|
}
|
|
|
}
|
|
|
});
|