This commit is contained in:
zhenghao
2022-02-17 16:37:11 +08:00
parent d2aca24d06
commit a7ed6454af
14 changed files with 10323 additions and 8814 deletions

View File

@@ -26,11 +26,11 @@ export const result = [{
children: null,
},
{
name: "goods",
name: "goods1",
level: 2,
type: 0,
title: "商品列表",
path: "goods",
path: "goods12",
component: "goods/goods-seller/goods",
children: null,
},
@@ -388,6 +388,42 @@ export const result = [{
component: "sys/user-manage/userManage",
children: []
},
{
name: "clerk",
level: 1,
type: 0,
title: "店员设置",
path: "",
component: "Main",
children: [
{
name: "clerkManage",
level: 2,
type: 0,
title: "店员管理",
path: "clerkManage",
component: "shop/system/clerk/clerkManage",
children: null
},{
name: "storeDepartmentManage",
level: 2,
type: 0,
title: "部门管理",
path: "storeDepartmentManage",
component: "shop/system/department/storeDepartmentManage",
children: null
},
{
name: "storeRole",
level: 2,
type: 0,
title: "角色权限",
path: "storeRole",
component: "shop/system/role/storeRoleManage",
children: null
}
]
},
{
name: "ship",
level: 1,
@@ -396,14 +432,14 @@ export const result = [{
path: "",
component: "Main",
children: [{
name: "shipTemplate",
level: 2,
type: 0,
title: "配送模板",
path: "shipTemplate",
component: "shop/ship/shipTemplate",
children: null
},
name: "shipTemplate",
level: 2,
type: 0,
title: "配送模板",
path: "shipTemplate",
component: "shop/ship/shipTemplate",
children: null
},
{
name: "logistics",
level: 2,

View File

@@ -1,3 +1,4 @@
import { getCurrentPermissionList } from "@/api/index";
import lazyLoading from './lazyLoading.js';
import Cookies from "js-cookie";
import { result } from './routerJson.js';
@@ -328,30 +329,43 @@ util.initRouter = function (vm) { // 初始化路由
if (!vm.$store.state.app.added) {
// 加载菜单
let menuData = result;
// 格式化数据,设置 空children 为 null
for(let i =0;i<menuData.length;i++){
let t = menuData[i].children
for(let k = 0;k<t.length;k++){
let tt = t[k].children;
for(let z = 0;z<tt.length;z++){
tt[z].children = null
// 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选
tt[z].firstRouterName = menuData[i].name
}
getCurrentPermissionList().then(res => {
if (!res.success) return false;
let menuData = result;
// 格式化数据,设置 空children 为 null
for (let i = 0; i < menuData.length; i++) {
let t = menuData[i].children;
for (let k = 0; k < t.length; k++) {
let tt = t[k].children;
for (let z = 0; z < tt.length; z++) {
tt[z].children = null;
// 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选
tt[z].firstRouterName = menuData[i].name;
}
}
}
util.initAllMenuData(constRoutes, menuData);
util.initRouterNode(otherRoutes, otherRouter);
// 添加所有主界面路由
vm.$store.commit('updateAppRouter', constRoutes.filter(item => item.children.length > 0));
// 添加全局路由
vm.$store.commit('updateDefaultRouter', otherRoutes);
// 添加菜单路由
util.initMenuData(vm, menuData);
// 缓存数据 修改加载标识
window.localStorage.setItem('menuData', JSON.stringify(menuData));
vm.$store.commit('setAdded', true);
}
if (!menuData) {
return;
}
util.initAllMenuData(constRoutes, menuData);
util.initRouterNode(otherRoutes, otherRouter);
// 添加所有主界面路由
vm.$store.commit(
"updateAppRouter",
constRoutes.filter(item => item.children.length > 0)
);
// 添加全局路由
vm.$store.commit("updateDefaultRouter", otherRoutes);
// 添加菜单路由
util.initMenuData(vm, menuData);
// 缓存数据 修改加载标识
window.localStorage.setItem("menuData", JSON.stringify(menuData));
vm.$store.commit("setAdded", true);
});
} else {
// 读取缓存数据
let data = window.localStorage.getItem('menuData');