Commit 588f3de1 by 冒粤蓉

fix

1 parent 8beb4d2b
...@@ -214,6 +214,22 @@ export default { ...@@ -214,6 +214,22 @@ export default {
}) })
} }
const sortMenu = (param) => {
if (param instanceof Array) {
const arr1 = param.sort((a, b) => a.order - b.order)
arr1.forEach(item => {
if (item.children && item.children.length > 1) {
sortMenu(item)
} else {
item.children.sort((a, b) => a.order - b.order)
}
})
} else if (param instanceof Object) {
param.children.sort((a, b) => a.order - b.order)
}
return param
}
// 获取菜单树接口 // 获取菜单树接口
const getServerTree = async (isInit) => { const getServerTree = async (isInit) => {
const menuService = new MenuService(); const menuService = new MenuService();
...@@ -223,7 +239,7 @@ export default { ...@@ -223,7 +239,7 @@ export default {
const resData = res.data; const resData = res.data;
let curBreadcrumb = localStorage.getItem('breadcrumb'); let curBreadcrumb = localStorage.getItem('breadcrumb');
// const getNewTree = getMenuTree(res.data, menuTreeLocalList) // const getNewTree = getMenuTree(res.data, menuTreeLocalList)
state.menuList = resData; state.menuList = sortMenu(resData);
// 初始化操作 // 初始化操作
let showEmpty = false; let showEmpty = false;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!