|
@@ -48,7 +48,7 @@ const routes = [
|
|
|
]
|
|
|
/* 后台管理系统Layout */
|
|
|
import administrator_layout from '@/views/backStageManage/layout/Layout.vue'
|
|
|
-export const backStageManageRouterItem = [
|
|
|
+export let backStageManageRouterItem = [
|
|
|
{
|
|
|
path: '/administrator',
|
|
|
component: administrator_layout,
|
|
@@ -59,10 +59,12 @@ export const backStageManageRouterItem = [
|
|
|
path: 'home',
|
|
|
name: 'Administrator_home',
|
|
|
component: () => import('@/views/backStageManage/home/index.vue'),
|
|
|
- meta: { title: '首页', icon: 'home' }
|
|
|
+ meta: { title: '首页', icon: 'home' },
|
|
|
},
|
|
|
]
|
|
|
},
|
|
|
+]
|
|
|
+export const defaultBackStageManageRouterItem = [
|
|
|
{
|
|
|
path: '/administrator',
|
|
|
name: 'Administrator_organization',
|
|
@@ -75,18 +77,21 @@ export const backStageManageRouterItem = [
|
|
|
name: 'Administrator_tenant',
|
|
|
component: () => import('@/views/backStageManage/organization/tenant/index.vue'),
|
|
|
meta: {title: '企业管理',icon: '企业'},
|
|
|
+ sign:'administrator/tenant'
|
|
|
},
|
|
|
{
|
|
|
path: 'personnel',
|
|
|
name: 'Administrator_personnel',
|
|
|
component: () => import('@/views/backStageManage/organization/personnel/index.vue'),
|
|
|
meta: {title: '人员清单',icon: '人员'},
|
|
|
+ sign:'administrator/personnel'
|
|
|
},
|
|
|
{
|
|
|
path: 'department',
|
|
|
name: 'Administrator_department',
|
|
|
component: () => import('@/views/backStageManage/organization/department/index.vue'),
|
|
|
meta: {title: '部门管理',icon: '部门'},
|
|
|
+ sign:'administrator/department'
|
|
|
},
|
|
|
{
|
|
|
path: 'addDepartment',
|
|
@@ -107,6 +112,7 @@ export const backStageManageRouterItem = [
|
|
|
name: 'Administrator_position',
|
|
|
component: () => import('@/views/backStageManage/organization/position/index.vue'),
|
|
|
meta: {title: '职位管理',icon: '职位'},
|
|
|
+ sign:'administrator/position'
|
|
|
},
|
|
|
{
|
|
|
path: 'addPosition',
|
|
@@ -149,7 +155,8 @@ export const backStageManageRouterItem = [
|
|
|
path: 'vision',
|
|
|
name: 'Administrator_vision',
|
|
|
component: () => import('@/views/backStageManage/application/vision/index.vue'),
|
|
|
- meta: { title: '应用版本管理', icon: '版本' }
|
|
|
+ meta: { title: '应用版本管理', icon: '版本' },
|
|
|
+ sign:'administrator/vision'
|
|
|
},
|
|
|
{
|
|
|
path: 'addVersion',
|
|
@@ -163,7 +170,7 @@ export const backStageManageRouterItem = [
|
|
|
name: 'Administrator_editVersion',
|
|
|
component: () => import('@/views/backStageManage/application/vision/editVersion.vue'),
|
|
|
meta: {title: '编辑应用版本', icon: 'editVision',keepAlive:true},
|
|
|
- hidden:true
|
|
|
+ hidden:true,
|
|
|
},
|
|
|
{
|
|
|
path: 'versionDetail',
|
|
@@ -176,7 +183,8 @@ export const backStageManageRouterItem = [
|
|
|
path: 'vipType',
|
|
|
name: 'Administrator_vipType',
|
|
|
component: () => import('@/views/backStageManage/application/vipType/index.vue'),
|
|
|
- meta: {title: '应用会员类型', icon: '会员类型'}
|
|
|
+ meta: {title: '应用会员类型', icon: '会员类型'},
|
|
|
+ sign:'administrator/vipType'
|
|
|
},
|
|
|
{
|
|
|
path: 'addVipType',
|
|
@@ -213,6 +221,7 @@ export const backStageManageRouterItem = [
|
|
|
name: 'Administrator_paymentCode',
|
|
|
component: () => import('@/views/backStageManage/paymentCode/paymentCode/index.vue'),
|
|
|
meta: {title: '付费码管理', icon: '付费'},
|
|
|
+ sign:'administrator/paymentCode'
|
|
|
},
|
|
|
{
|
|
|
path: 'addPaymentCode',
|
|
@@ -249,6 +258,7 @@ export const backStageManageRouterItem = [
|
|
|
name: 'Administrator_examine',
|
|
|
component: () => import('@/views/backStageManage/examine/examine/index.vue'),
|
|
|
meta: {title: '账号审核', icon: '审核'},
|
|
|
+ sign:'administrator/examine'
|
|
|
},
|
|
|
]
|
|
|
},
|
|
@@ -309,16 +319,67 @@ router.beforeEach((to, from, next) => {
|
|
|
next({ name: 'Administrator_login' })
|
|
|
break;
|
|
|
default:
|
|
|
- if (to.meta.title) {
|
|
|
- document.title = to.meta.title;
|
|
|
+ if(Store.getters.permission === null){
|
|
|
+ Store.dispatch('getPersonPermission').then(response=>{
|
|
|
+ var permission = response.data
|
|
|
+ // if(permission.length>0){}
|
|
|
+ setRoutePermission(permission).then(() => { // 生成可访问的路由表
|
|
|
+ router.addRoutes(Store.state.permission.addRouters); // 动态添加可访问路由表
|
|
|
+ next({ ...to, replace: true })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ next()
|
|
|
}
|
|
|
- next()
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+function setRoutePermission(data){
|
|
|
+ return new Promise((resolve, reject)=>{
|
|
|
+ if(Store.getters.userinfo?.roleType == 1){
|
|
|
+ Store.commit('SET_ROUTERS', defaultBackStageManageRouterItem);
|
|
|
+ resolve();
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var addRouters = []
|
|
|
+ for(var i = 0;i<defaultBackStageManageRouterItem.length;i++){
|
|
|
+ var item = defaultBackStageManageRouterItem[i]
|
|
|
+ if(item.sign){
|
|
|
+ var index = data.indexOf(item.sign)
|
|
|
+ if(index == -1){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var childrenRouter = []
|
|
|
+ if(item.children && item.children.length){
|
|
|
+ childrenRouter = item.children.filter(child=>{
|
|
|
+ return !child.sign || data.indexOf(child.sign) != -1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ item.children = childrenRouter
|
|
|
+ if(item.children.length>0){
|
|
|
+ var child = item.children.find(i=>{
|
|
|
+ return !i.hidden
|
|
|
+ })
|
|
|
+ if(child){
|
|
|
+ item.redirect = item.path + '/' +child.path
|
|
|
+ }else{
|
|
|
+ item.children = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(item.sign || item.children.length>0){
|
|
|
+ addRouters.push(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Store.commit('SET_ROUTERS', addRouters);
|
|
|
+ resolve();
|
|
|
+ })
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
function routeExists(array, path, parentPath) {
|
|
|
for (var i = 0; i < array.length; i++) {
|
|
|
var item = array[i]
|