修改菜单查询逻辑

This commit is contained in:
liaozetao
2023-11-23 10:35:43 +08:00
parent ef3a28e686
commit 9ee10ef721

View File

@@ -131,17 +131,12 @@ export default {
},
methods: {
getMenu() {
// let parentMenus = getStore({ name: 'parent_menus' });
// let childMenus = getStore({ name: 'child_menus' });
// if (parentMenus && childMenus && parentMenus.length > 0 && childMenus.length > 0) {
// this.parentMenus = parentMenus;
// this.childMenus = childMenus;
// } else {
store.dispatch('getMenu').then(res => {
this.parentMenus = res.parents;
this.childMenus = res.childs;
});
// }
this.parentMenus = getStore({ name: 'parent_menus' });
this.childMenus = getStore({ name: 'child_menus' });
store.dispatch('getMenu').then(res => {
this.parentMenus = res.parents;
this.childMenus = res.childs;
});
},
getChilds(parentId) {
return this.childMenus.filter(v => v.parentid == parentId);
@@ -171,9 +166,7 @@ export default {
parentIds.push(v.id);
});
}
console.log(parentIds);
this.parentMenus = store.getters.parentMenus.filter(v1 => parentIds.filter(v2 => v1.id == v2).length > 0);
this.childMenus = store.getters.childMenus.filter(v1 => parentIds.filter(v2 => v1.parentid == v2).length > 0);
}
}
},