| | |
| | | name: 'BasicDataMessage', |
| | | component: () => import('@/views/basicData/index'), |
| | | meta: { title: '基础数据', icon: 'el-icon-s-tools' } |
| | | } |
| | | }, |
| | | { |
| | | path: 'myBusiness', |
| | | name: 'MyBusiness', |
| | | component: () => import('@/views/personal/myBusiness/index'), |
| | | meta: { title: '我的企业', icon: 'tree', show: false } |
| | | } |
| | | ] |
| | | }, |
| | | { path: '*', redirect: '/404', hidden: true } |
| | |
| | | let result = []; |
| | | let obj = {}; |
| | | for (let i = 0; i < tempArr.length; i++) { |
| | | if (!obj[tempArr[i].path]) { |
| | | result.push(tempArr[i]); |
| | | obj[tempArr[i].path] = true; |
| | | }; |
| | | if (!obj[tempArr[i].path]) { |
| | | result.push(tempArr[i]); |
| | | obj[tempArr[i].path] = true; |
| | | }; |
| | | }; |
| | | return result; |
| | | }; |
| | |
| | | |
| | | function createRouter(Routees) { |
| | | if (JSON.parse(sessionStorage.getItem("user")) != undefined && JSON.parse(sessionStorage.getItem("user")) != null) { |
| | | let sessionLayerId=JSON.parse(sessionStorage.getItem("user")).sessionLayerId |
| | | if(sessionLayerId!='c3284d0f94606de1fd2af172aba15bf3'){ |
| | | let role = JSON.parse(sessionStorage.getItem("user")).role |
| | | let menuFather = baseRouter |
| | | const dataMenuFather = fn3(menuFather) |
| | | role.roleMenuList.forEach((r) => { |
| | | dataMenuFather.push(Routees.filter(item => { |
| | | return item.path === r.menuUrl |
| | | })[0]) |
| | | }) |
| | | let eqChildren = []; |
| | | role.roleMenuList.forEach((r) => { |
| | | let sessionLayerId = JSON.parse(sessionStorage.getItem("user")).sessionLayerId |
| | | if (sessionLayerId != 'f5c8bcb7d5a0fd27e2323280f7e98cad') { |
| | | let role = JSON.parse(sessionStorage.getItem("user")).role |
| | | let menuFather = baseRouter |
| | | const dataMenuFather = fn3(menuFather) |
| | | role.roleMenuList.forEach((r) => { |
| | | dataMenuFather.push(Routees.filter(item => { |
| | | return item.path === r.menuUrl |
| | | })[0]) |
| | | }) |
| | | let eqChildren = []; |
| | | role.roleMenuList.forEach((r) => { |
| | | dataMenuFather.forEach(m => { |
| | | if (r.menuUrl === m.path) { |
| | | r.children.forEach(rc => { |
| | | m.children.forEach(mc => { |
| | | if (mc.meta != undefined) { |
| | | eqChildren.push({ "path": mc.path, "meta": JSON.parse(JSON.stringify(mc.meta)) }) |
| | | delete mc["meta"] |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | let once = [] |
| | | role.roleMenuList.forEach((r) => { |
| | | r.children.forEach(rc => { |
| | | eqChildren.forEach(eq => { |
| | | if (eq != undefined) { |
| | | if (eq.path == rc.menuUrl.split("/")[1]) { |
| | | once.push(eq) |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | dataMenuFather.forEach(m => { |
| | | if (r.menuUrl === m.path) { |
| | | r.children.forEach(rc => { |
| | | m.children.forEach(mc => { |
| | | if (mc.meta != undefined) { |
| | | eqChildren.push({ "path": mc.path, "meta": JSON.parse(JSON.stringify(mc.meta)) }) |
| | | delete mc["meta"] |
| | | let i = 0 |
| | | if (m.children != undefined) { |
| | | m.children.forEach(mc => { |
| | | once.forEach(eq => { |
| | | if (eq != undefined) { |
| | | if (mc.path == eq.path) { |
| | | if (i === 0) { |
| | | m.redirect = m.path + "/" + eq.path |
| | | } |
| | | i++; |
| | | mc.meta = eq.meta |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | let once = [] |
| | | role.roleMenuList.forEach((r) => { |
| | | r.children.forEach(rc => { |
| | | eqChildren.forEach(eq => { |
| | | if (eq != undefined) { |
| | | if (eq.path == rc.menuUrl.split("/")[1]) { |
| | | once.push(eq) |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | dataMenuFather.forEach(m => { |
| | | let i = 0 |
| | | if (m.children != undefined) { |
| | | m.children.forEach(mc => { |
| | | once.forEach(eq => { |
| | | if (eq != undefined) { |
| | | if (mc.path == eq.path) { |
| | | if (i === 0) { |
| | | m.redirect = m.path + "/" + eq.path |
| | | } |
| | | i++; |
| | | mc.meta = eq.meta |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | dataMenuFather.push({path: '*', redirect: '/404', hidden: true}) |
| | | dataMenuFather.push() |
| | | Routees = dataMenuFather |
| | | } |
| | | dataMenuFather.push({ path: '*', redirect: '/404', hidden: true }) |
| | | dataMenuFather.push() |
| | | Routees = dataMenuFather |
| | | } |
| | | } else { |
| | | Routees = baseRouter |
| | | } |
| | | return new Router({ |
| | | // mode: 'history', // require service support |
| | | mode: 'history', // require service support |
| | | scrollBehavior: () => ({ y: 0 }), |
| | | routes: Routees |
| | | }) |
| | | } |
| | | let router = createRouter(getRoutes()) |
| | | let router = createRouter(getRoutes()) |
| | | |
| | | // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 |
| | | export async function resetRouter() { |
| | | let newRouter = createRouter(getRoutes()) |
| | | router.matcher = newRouter.matcher |
| | | router.matcher = newRouter.matcher |
| | | } |
| | | router.beforeEach(async (to, from, next) => { |
| | | router.beforeEach((to, from, next) => { |
| | | /** |
| | | * 委托新增 放行 |
| | | */ |
| | | if (to.path.indexOf("/addCommision/") === 0) { |
| | | next() |
| | | return |
| | | } |
| | | // 1. 判断是不是登录页面 |
| | | // 是登录页面 |
| | | if (to.path === '/login') { |
| | |
| | | // 不是登录页面 |
| | | // 2. 判断 是否登录过 |
| | | let token = sessionStorage.getItem('user') |
| | | if(token!=null&&token!=undefined){ |
| | | await resetRouter() |
| | | if (token != null && token != undefined) { |
| | | resetRouter() |
| | | } |
| | | token ? next() : next('/login') |
| | | } |