修改查询逻辑
This commit is contained in:
@@ -130,17 +130,12 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getMenu() {
|
getMenu() {
|
||||||
let parentMenus = getStore({ name: 'parent_menus' });
|
this.parentMenus = getStore({ name: 'parent_menus' });
|
||||||
let childMenus = getStore({ name: 'child_menus' });
|
this.childMenus = getStore({ name: 'child_menus' });
|
||||||
if (parentMenus && childMenus && parentMenus.length > 0 && childMenus.length > 0) {
|
store.dispatch('getMenu').then(res => {
|
||||||
this.parentMenus = parentMenus;
|
this.parentMenus = res.parents;
|
||||||
this.childMenus = childMenus;
|
this.childMenus = res.childs;
|
||||||
} else {
|
});
|
||||||
store.dispatch('getMenu').then(res => {
|
|
||||||
this.parentMenus = res.parents;
|
|
||||||
this.childMenus = res.childs;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
getChilds(parentId) {
|
getChilds(parentId) {
|
||||||
return this.childMenus.filter(v => v.parentid == parentId);
|
return this.childMenus.filter(v => v.parentid == parentId);
|
||||||
@@ -170,9 +165,7 @@ export default {
|
|||||||
parentIds.push(v.id);
|
parentIds.push(v.id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(parentIds);
|
|
||||||
this.parentMenus = store.getters.parentMenus.filter(v1 => parentIds.filter(v2 => v1.id == v2).length > 0);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user