|
|
@ -1,19 +1,19 @@ |
|
|
|
import Vue from 'vue'; |
|
|
|
import Vue from 'vue'; |
|
|
|
import Router from 'vue-router'; |
|
|
|
import Router from 'vue-router'; |
|
|
|
import axios from 'axios' |
|
|
|
import axios from 'axios' |
|
|
|
import {getPermission} from '../utils/api' |
|
|
|
import { getPermission } from '../utils/api' |
|
|
|
|
|
|
|
|
|
|
|
//解决编程式路由往同一地址跳转时会报错的情况
|
|
|
|
//解决编程式路由往同一地址跳转时会报错的情况
|
|
|
|
const originalPush = Router.prototype.push; |
|
|
|
const originalPush = Router.prototype.push; |
|
|
|
const originalReplace = Router.prototype.replace; |
|
|
|
const originalReplace = Router.prototype.replace; |
|
|
|
//push
|
|
|
|
//push
|
|
|
|
Router.prototype.push = function push(location, onResolve, onReject) { |
|
|
|
Router.prototype.push = function push (location, onResolve, onReject) { |
|
|
|
if (onResolve || onReject) |
|
|
|
if (onResolve || onReject) |
|
|
|
return originalPush.call(this, location, onResolve, onReject); |
|
|
|
return originalPush.call(this, location, onResolve, onReject); |
|
|
|
return originalPush.call(this, location).catch(err => err); |
|
|
|
return originalPush.call(this, location).catch(err => err); |
|
|
|
}; |
|
|
|
}; |
|
|
|
//replace
|
|
|
|
//replace
|
|
|
|
Router.prototype.replace = function push(location, onResolve, onReject) { |
|
|
|
Router.prototype.replace = function push (location, onResolve, onReject) { |
|
|
|
if (onResolve || onReject) |
|
|
|
if (onResolve || onReject) |
|
|
|
return originalReplace.call(this, location, onResolve, onReject); |
|
|
|
return originalReplace.call(this, location, onResolve, onReject); |
|
|
|
return originalReplace.call(this, location).catch(err => err); |
|
|
|
return originalReplace.call(this, location).catch(err => err); |
|
|
@ -74,14 +74,14 @@ const noticeDesign = () => import('../components/common/noticeDesign.vue') |
|
|
|
// 404页面,随便写了个
|
|
|
|
// 404页面,随便写了个
|
|
|
|
const notFind = () => import('../components/page/404.vue') |
|
|
|
const notFind = () => import('../components/page/404.vue') |
|
|
|
// 重载路由,用于权限更新后的重载
|
|
|
|
// 重载路由,用于权限更新后的重载
|
|
|
|
import {resetRouter} from './resetRouter' |
|
|
|
import { resetRouter } from './resetRouter' |
|
|
|
|
|
|
|
|
|
|
|
Vue.use(Router); |
|
|
|
Vue.use(Router); |
|
|
|
|
|
|
|
|
|
|
|
export const constantRouterMap = [ // 默认路由,不需要权限
|
|
|
|
export const constantRouterMap = [ // 默认路由,不需要权限
|
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/', |
|
|
|
path: '/', |
|
|
|
redirect: '/beforeLogin', |
|
|
|
redirect: '/login', |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/beforeLogin', |
|
|
|
path: '/beforeLogin', |
|
|
@ -100,15 +100,15 @@ export const constantRouterMap = [ // 默认路由,不需要权限 |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
let router = new Router({ |
|
|
|
let router = new Router({ |
|
|
|
mode: 'hash', |
|
|
|
mode: 'hash', |
|
|
|
base: process.env.BASE_URL, |
|
|
|
base: process.env.BASE_URL, |
|
|
|
routes: [] |
|
|
|
routes: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
export default router |
|
|
|
export default router |
|
|
|
router.addRoutes(constantRouterMap) |
|
|
|
router.addRoutes(constantRouterMap) |
|
|
|
function createdRouter(item,val) {// 处理成路由接受对象的方法
|
|
|
|
function createdRouter (item, val) {// 处理成路由接受对象的方法
|
|
|
|
if(item.menuOrNot===1){ |
|
|
|
if (item.menuOrNot === 1) { |
|
|
|
let len,com,obj |
|
|
|
let len, com, obj |
|
|
|
// 匹配路由名称对应的component
|
|
|
|
// 匹配路由名称对应的component
|
|
|
|
switch (item.name) { |
|
|
|
switch (item.name) { |
|
|
|
case '待办事项': com = Dashboard |
|
|
|
case '待办事项': com = Dashboard |
|
|
@ -137,22 +137,22 @@ function createdRouter(item,val) {// 处理成路由接受对象的方法 |
|
|
|
break; |
|
|
|
break; |
|
|
|
case '保后业务管理系统': com = afterLoan |
|
|
|
case '保后业务管理系统': com = afterLoan |
|
|
|
break; |
|
|
|
break; |
|
|
|
default:console.log('未匹配到文件地址'); |
|
|
|
default: console.log('未匹配到文件地址'); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
// 每个路由对应的数据形式
|
|
|
|
// 每个路由对应的数据形式
|
|
|
|
obj = { |
|
|
|
obj = { |
|
|
|
path:item.menuUrl, |
|
|
|
path: item.menuUrl, |
|
|
|
component:com, |
|
|
|
component: com, |
|
|
|
meta:{title:item.name,btn:[]}, |
|
|
|
meta: { title: item.name, btn: [] }, |
|
|
|
children:[] |
|
|
|
children: [] |
|
|
|
} |
|
|
|
} |
|
|
|
// 判断是否为主路由文件,进行递归匹配
|
|
|
|
// 判断是否为主路由文件,进行递归匹配
|
|
|
|
if(item.children&&item.children.length!==0){ |
|
|
|
if (item.children && item.children.length !== 0) { |
|
|
|
len = item.children.length |
|
|
|
len = item.children.length |
|
|
|
for(let i=0;i<len;i++){ |
|
|
|
for (let i = 0; i < len; i++) { |
|
|
|
obj.meta.btn.push(item.children[i].name)// 权限判断,把非主路由name作为鉴权信息
|
|
|
|
obj.meta.btn.push(item.children[i].name)// 权限判断,把非主路由name作为鉴权信息
|
|
|
|
if(item.children[i].menuOrNot!==0){ |
|
|
|
if (item.children[i].menuOrNot !== 0) { |
|
|
|
// 是页面的话,生成新的obj,赛进父级
|
|
|
|
// 是页面的话,生成新的obj,赛进父级
|
|
|
|
obj.children.push(createdRouter(item.children[i])) |
|
|
|
obj.children.push(createdRouter(item.children[i])) |
|
|
|
} |
|
|
|
} |
|
|
@ -172,70 +172,70 @@ function createdRouter(item,val) {// 处理成路由接受对象的方法 |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if(item.name === '后台管理'){ |
|
|
|
if (item.name === '后台管理') { |
|
|
|
if(item.children&&item.children.length){ |
|
|
|
if (item.children && item.children.length) { |
|
|
|
for(let i=0;i<item.children.length;i++){ |
|
|
|
for (let i = 0; i < item.children.length; i++) { |
|
|
|
if(item.children[i].name==='客户资源后台管理系统'){ |
|
|
|
if (item.children[i].name === '客户资源后台管理系统') { |
|
|
|
obj.children.push( |
|
|
|
obj.children.push( |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/addcustomer', |
|
|
|
path: '/addcustomer', |
|
|
|
component: AddCustomer, |
|
|
|
component: AddCustomer, |
|
|
|
meta: { title: '担保业务后台管理系统', btn:[]} |
|
|
|
meta: { title: '担保业务后台管理系统', btn: [] } |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
// 判断后台管理系统,添加十个表单设计页面
|
|
|
|
// 判断后台管理系统,添加十个表单设计页面
|
|
|
|
if(item.children[i].name==='担保业务后台管理系统'){ |
|
|
|
if (item.children[i].name === '担保业务后台管理系统') { |
|
|
|
obj.children.push( |
|
|
|
obj.children.push( |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/applyDesign', |
|
|
|
path: '/applyDesign', |
|
|
|
component: applyDesign, |
|
|
|
component: applyDesign, |
|
|
|
meta: { title: '业务申请表单设计', btn:[]} |
|
|
|
meta: { title: '业务申请表单设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/guaranteeDesign', |
|
|
|
path: '/guaranteeDesign', |
|
|
|
component: guaranteeDesign, |
|
|
|
component: guaranteeDesign, |
|
|
|
meta: { title: '担保部调查', btn:[]} |
|
|
|
meta: { title: '担保部调查', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/assetDesign', |
|
|
|
path: '/assetDesign', |
|
|
|
component: assetDesign, |
|
|
|
component: assetDesign, |
|
|
|
meta: { title: '资产部调查表单设计', btn:[]} |
|
|
|
meta: { title: '资产部调查表单设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/messageDesign', |
|
|
|
path: '/messageDesign', |
|
|
|
component: messageDesign, |
|
|
|
component: messageDesign, |
|
|
|
meta: { title: '信息部调查表单设计', btn:[]} |
|
|
|
meta: { title: '信息部调查表单设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/complianceDesign', |
|
|
|
path: '/complianceDesign', |
|
|
|
component: complianceDesign, |
|
|
|
component: complianceDesign, |
|
|
|
meta: { title: '合规调查表单设计', btn:[]} |
|
|
|
meta: { title: '合规调查表单设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/workDesign', |
|
|
|
path: '/workDesign', |
|
|
|
component: workDesign, |
|
|
|
component: workDesign, |
|
|
|
meta: { title: '工作会表单设计', btn:[]} |
|
|
|
meta: { title: '工作会表单设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/loansDepartDesign', |
|
|
|
path: '/loansDepartDesign', |
|
|
|
component: loansDepartDesign, |
|
|
|
component: loansDepartDesign, |
|
|
|
meta: { title: '贷审会表单设计', btn:[]} |
|
|
|
meta: { title: '贷审会表单设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/letterDesign', |
|
|
|
path: '/letterDesign', |
|
|
|
component: letterDesign, |
|
|
|
component: letterDesign, |
|
|
|
meta: { title: '担保函流程设计', btn:[]} |
|
|
|
meta: { title: '担保函流程设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/paymentDesign', |
|
|
|
path: '/paymentDesign', |
|
|
|
component: paymentDesign, |
|
|
|
component: paymentDesign, |
|
|
|
meta: { title: '财务部确认流程设计', btn:[]} |
|
|
|
meta: { title: '财务部确认流程设计', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path:'/noticeDesign', |
|
|
|
path: '/noticeDesign', |
|
|
|
component: noticeDesign, |
|
|
|
component: noticeDesign, |
|
|
|
meta: { title: '放款通知流程设计', btn:[]} |
|
|
|
meta: { title: '放款通知流程设计', btn: [] } |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -244,17 +244,17 @@ function createdRouter(item,val) {// 处理成路由接受对象的方法 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return obj |
|
|
|
return obj |
|
|
|
}else return |
|
|
|
} else return |
|
|
|
} |
|
|
|
} |
|
|
|
router.beforeEach(function(to,from,next){ |
|
|
|
router.beforeEach(function (to, from, next) { |
|
|
|
if(to.path == '/login'){ |
|
|
|
if (to.path == '/login') { |
|
|
|
sessionStorage.removeItem('token') |
|
|
|
sessionStorage.removeItem('token') |
|
|
|
} |
|
|
|
} |
|
|
|
if(sessionStorage.getItem('token')){ |
|
|
|
if (sessionStorage.getItem('token')) { |
|
|
|
if(!sessionStorage.getItem('success')){// 记录路由是否处理过
|
|
|
|
if (!sessionStorage.getItem('success')) {// 记录路由是否处理过
|
|
|
|
getPermission().then(res=>{ |
|
|
|
getPermission().then(res => { |
|
|
|
if(res.success){ |
|
|
|
if (res.success) { |
|
|
|
sessionStorage.setItem('getRouter','true') |
|
|
|
sessionStorage.setItem('getRouter', 'true') |
|
|
|
let permissions = { |
|
|
|
let permissions = { |
|
|
|
path: '/', |
|
|
|
path: '/', |
|
|
|
component: Home, |
|
|
|
component: Home, |
|
|
@ -263,22 +263,22 @@ router.beforeEach(function(to,from,next){ |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/homePage', |
|
|
|
path: '/homePage', |
|
|
|
component: HomePage, |
|
|
|
component: HomePage, |
|
|
|
meta: { title: '首页' ,btn:[]} |
|
|
|
meta: { title: '首页', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/workbench', |
|
|
|
path: '/workbench', |
|
|
|
component: () => import('../components/page/Workbench.vue'), |
|
|
|
component: () => import('../components/page/Workbench.vue'), |
|
|
|
meta: { title: '工作台' ,btn:[]}, |
|
|
|
meta: { title: '工作台', btn: [] }, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/workbench-manpower', |
|
|
|
path: '/workbench-manpower', |
|
|
|
component: WorkbenchManpower, |
|
|
|
component: WorkbenchManpower, |
|
|
|
meta: { title: '人力资源管理',btn:[] }
|
|
|
|
meta: { title: '人力资源管理', btn: [] } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/workbench-client-message', |
|
|
|
path: '/workbench-client-message', |
|
|
|
component: WorkbenchClientmessage, |
|
|
|
component: WorkbenchClientmessage, |
|
|
|
meta: { title: '工作台客户信息', btn:[]} |
|
|
|
meta: { title: '工作台客户信息', btn: [] } |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
}, |
|
|
|
}, |
|
|
@ -289,12 +289,12 @@ router.beforeEach(function(to,from,next){ |
|
|
|
// console.log(res.data,'路由处理,工作台和非工作台路由匹配')
|
|
|
|
// console.log(res.data,'路由处理,工作台和非工作台路由匹配')
|
|
|
|
|
|
|
|
|
|
|
|
// 此处为主路由页面的操作,通过对应的 createdRouter 函数进行路由数据处理,文件地址分配
|
|
|
|
// 此处为主路由页面的操作,通过对应的 createdRouter 函数进行路由数据处理,文件地址分配
|
|
|
|
for(let i=0;i<len;i++){ |
|
|
|
for (let i = 0; i < len; i++) { |
|
|
|
//匹配非工作台的路由
|
|
|
|
//匹配非工作台的路由
|
|
|
|
if(res.data[i].name!=='客户资源管理系统'&&res.data[i].name!=='担保业务管理系统'&&res.data[i].name!=='保后业务管理系统'){ |
|
|
|
if (res.data[i].name !== '客户资源管理系统' && res.data[i].name !== '担保业务管理系统' && res.data[i].name !== '保后业务管理系统') { |
|
|
|
permissions.children.push(createdRouter(res.data[i])) |
|
|
|
permissions.children.push(createdRouter(res.data[i])) |
|
|
|
homeMenu.push(res.data[i].name) |
|
|
|
homeMenu.push(res.data[i].name) |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
permissions.children[1].meta.btn.push(res.data[i].name) |
|
|
|
permissions.children[1].meta.btn.push(res.data[i].name) |
|
|
|
permissions.children[1].children.push(createdRouter(res.data[i])) |
|
|
|
permissions.children[1].children.push(createdRouter(res.data[i])) |
|
|
|
} |
|
|
|
} |
|
|
@ -309,17 +309,17 @@ router.beforeEach(function(to,from,next){ |
|
|
|
{ |
|
|
|
{ |
|
|
|
path: '/404', |
|
|
|
path: '/404', |
|
|
|
component: notFind, |
|
|
|
component: notFind, |
|
|
|
meta: { title: '找不到页面', btn:[]} |
|
|
|
meta: { title: '找不到页面', btn: [] } |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
router.addRoutes([permissions]) |
|
|
|
router.addRoutes([permissions]) |
|
|
|
router.addRoutes(errPage) |
|
|
|
router.addRoutes(errPage) |
|
|
|
sessionStorage.setItem('routerData',JSON.stringify([permissions])) |
|
|
|
sessionStorage.setItem('routerData', JSON.stringify([permissions])) |
|
|
|
// 处理过路由否
|
|
|
|
// 处理过路由否
|
|
|
|
sessionStorage.setItem('success',true) |
|
|
|
sessionStorage.setItem('success', true) |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(err=>{ |
|
|
|
}).catch(err => { |
|
|
|
console.log(err,'路由处理出错') |
|
|
|
console.log(err, '路由处理出错') |
|
|
|
let errPage = { |
|
|
|
let errPage = { |
|
|
|
path: '*', |
|
|
|
path: '*', |
|
|
|
redirect: '/login' |
|
|
|
redirect: '/login' |
|
|
@ -327,10 +327,11 @@ router.beforeEach(function(to,from,next){ |
|
|
|
router.addRoutes([errPage]) |
|
|
|
router.addRoutes([errPage]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
if (to.path !== '/login'&&to.path !=="/beforeLogin"&&to.path !=='/bind-phone') { |
|
|
|
if (to.path !== '/login' && to.path !== "/beforeLogin" && to.path !== '/bind-phone') { |
|
|
|
next({ path: '/login', |
|
|
|
next({ |
|
|
|
query:{redirect:to.path} |
|
|
|
path: '/login', |
|
|
|
|
|
|
|
query: { redirect: to.path } |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|