From 809f8b1279bf84f28bccabc4f95a8eba6c22a24d Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期二, 29 八月 2023 10:30:04 +0800
Subject: [PATCH] 放行委托新增
---
.env.staging | 2
.env.production | 2
src/router/index.js | 133 +++++++++++++++++++++++---------------------
3 files changed, 72 insertions(+), 65 deletions(-)
diff --git a/.env.production b/.env.production
index d5166db..dd72fa5 100644
--- a/.env.production
+++ b/.env.production
@@ -3,5 +3,5 @@
# base api
# VUE_APP_BASE_API = '/prod-api'
-VUE_APP_BASE_API = 'http://192.168.110.167:1234/'
+VUE_APP_BASE_API = 'http://localhost:1234/'
diff --git a/.env.staging b/.env.staging
index 65e5ce8..92fbe73 100644
--- a/.env.staging
+++ b/.env.staging
@@ -5,6 +5,6 @@
# base api
# VUE_APP_BASE_API = '/stage-api'
-VUE_APP_BASE_API = 'http://192.168.110.167:1234/'
+VUE_APP_BASE_API = 'http://localhost:1234/'
diff --git a/src/router/index.js b/src/router/index.js
index 3f4bca3..458100d 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -516,10 +516,10 @@
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;
};
@@ -527,82 +527,89 @@
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!='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) => {
+ 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') {
@@ -611,8 +618,8 @@
// 涓嶆槸鐧诲綍椤甸潰
// 2. 鍒ゆ柇 鏄惁鐧诲綍杩�
let token = sessionStorage.getItem('user')
- if(token!=null&&token!=undefined){
- await resetRouter()
+ if (token != null && token != undefined) {
+ resetRouter()
}
token ? next() : next('/login')
}
--
Gitblit v1.9.3