|
@@ -1334,6 +1334,7 @@ export default {
|
|
|
isAsc,
|
|
|
primaryKey,
|
|
|
});
|
|
|
+ console.log(this.menus);
|
|
|
this.formData.routePath = this.getParentMenuId(
|
|
|
res.data.menuId,
|
|
|
this.menus,
|
|
@@ -1355,16 +1356,27 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 获取父级menuId
|
|
|
- getParentMenuId(menuId, menus, parentItem) {
|
|
|
- if (!menus.length) return undefined;
|
|
|
+ getParentMenuId(menuId, menus) {
|
|
|
let res;
|
|
|
- for (var i = 0; i < menus.length; i++) {
|
|
|
+ for (let i = 0; i < menus.length; i++) {
|
|
|
+ // console.log(menus[i]);
|
|
|
let item = menus[i];
|
|
|
+ console.log(item.menuId, menuId);
|
|
|
if (item.menuId == menuId) {
|
|
|
- res = parentItem?.menuId;
|
|
|
- }
|
|
|
- if (item.children?.length) {
|
|
|
- res = this.getParentMenuId(menuId, item.children, item);
|
|
|
+ res = item.parentId;
|
|
|
+ break;
|
|
|
+ } else if (item.children?.length) {
|
|
|
+ if (
|
|
|
+ this.getParentMenuId(
|
|
|
+ menuId,
|
|
|
+ JSON.parse(JSON.stringify(item.children))
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ res = this.getParentMenuId(
|
|
|
+ menuId,
|
|
|
+ JSON.parse(JSON.stringify(item.children))
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return res;
|