首页业务处理
This commit is contained in:
parent
d2ae3d87f6
commit
e05d5e9270
@ -37,8 +37,9 @@ const permission = {
|
|||||||
// 将 menus 菜单,转换为 route 路由数组
|
// 将 menus 菜单,转换为 route 路由数组
|
||||||
const sdata = JSON.parse(JSON.stringify(menus)) // 【重要】用于菜单中的数据
|
const sdata = JSON.parse(JSON.stringify(menus)) // 【重要】用于菜单中的数据
|
||||||
const rdata = JSON.parse(JSON.stringify(menus)) // 用于最后添加到 Router 中的数据
|
const rdata = JSON.parse(JSON.stringify(menus)) // 用于最后添加到 Router 中的数据
|
||||||
const sidebarRoutes = filterAsyncRouter(sdata)
|
const sss = JSON.parse(JSON.stringify(menus))
|
||||||
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
const sidebarRoutes = filterAsyncRouter(sdata,sss)
|
||||||
|
const rewriteRoutes = filterAsyncRouter(rdata,sss, false, true)
|
||||||
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
|
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
|
||||||
commit('SET_ROUTES', rewriteRoutes)
|
commit('SET_ROUTES', rewriteRoutes)
|
||||||
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
|
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
|
||||||
@ -51,13 +52,12 @@ const permission = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 遍历后台传来的路由字符串,转换为组件对象
|
// 遍历后台传来的路由字符串,转换为组件对象
|
||||||
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
function filterAsyncRouter(asyncRouterMap,sdata, lastRouter = false, type = false) {
|
||||||
return asyncRouterMap.filter(function(route,index) {
|
return asyncRouterMap.filter(function(route,index) {
|
||||||
// 将 ruoyi 后端原有耦合前端的逻辑,迁移到此处
|
// 将 ruoyi 后端原有耦合前端的逻辑,迁移到此处
|
||||||
// 处理 meta 属性
|
// 处理 meta 属性
|
||||||
route.meta = {
|
route.meta = {
|
||||||
title:dealMenuText(index) +' '+ route.name,
|
title:dealMenuText(index,route,sdata) +' '+ route.name,
|
||||||
icon: route.icon,
|
|
||||||
noCache: !route.keepAlive,
|
noCache: !route.keepAlive,
|
||||||
}
|
}
|
||||||
route.hidden = !route.visible
|
route.hidden = !route.visible
|
||||||
@ -89,23 +89,56 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
|||||||
route.children = filterChildren(route.children)
|
route.children = filterChildren(route.children)
|
||||||
}
|
}
|
||||||
if (route.children != null && route.children && route.children.length) {
|
if (route.children != null && route.children && route.children.length) {
|
||||||
route.children = filterAsyncRouter(route.children, route, type)
|
route.children = filterAsyncRouter(route.children,sdata, route, type)
|
||||||
route.alwaysShow = route.alwaysShow !== undefined ? route.alwaysShow : true
|
route.alwaysShow = route.alwaysShow !== undefined ? route.alwaysShow : true
|
||||||
} else {
|
} else {
|
||||||
delete route['children']
|
delete route['children']
|
||||||
delete route['alwaysShow'] // 如果没有子菜单,就不需要考虑 alwaysShow 字段
|
delete route['alwaysShow'] // 如果没有子菜单,就不需要考虑 alwaysShow 字段
|
||||||
}
|
}
|
||||||
console.log(route,989898)
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function dealMenuText(num){
|
function dealMenuText(num,data,list){
|
||||||
let tempData =['(一)','(二)','(三)','(四)','(五)','(六)','(七)','(八)','(九)','(十)'
|
if (data.parentId==0){
|
||||||
,'(十一)','(十二)','(十三)','(十四)','(十五)','(十六)','(十七)','(十八)','(十九)','(二十)','(二十一)','(二十二)','(二十三)']
|
let tempData =['一','二','三','四','五','六','七','八','九','十'
|
||||||
if (num>tempData.length){
|
,'十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一','二十二','二十三']
|
||||||
return "";
|
if (num>tempData.length){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return tempData[num] +'、'
|
||||||
|
}else {
|
||||||
|
let level =1;
|
||||||
|
let parData ={};
|
||||||
|
for (const item of list) {
|
||||||
|
if ( data.parentId == item.id){
|
||||||
|
parData = item
|
||||||
|
level++
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const item of list) {
|
||||||
|
if ( parData.parentId == 0){
|
||||||
|
parData = item
|
||||||
|
level++
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (level==2){
|
||||||
|
let tempData2 =['(一)','(二)','(三)','(四)','(五)','(六)','(七)','(八)','(九)','(十)'
|
||||||
|
,'(十一)','(十二)','(十三)','(十四)','(十五)','(十六)','(十七)','(十八)','(十九)','(二十)','(二十一)','(二十二)','(二十三)']
|
||||||
|
if (num>tempData2.length){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return tempData2[num]
|
||||||
|
}else if (level == 3){
|
||||||
|
return (num+1)+'.'
|
||||||
|
}else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return tempData[num]
|
|
||||||
}
|
}
|
||||||
function filterChildren(childrenMap, lastRouter = false) {
|
function filterChildren(childrenMap, lastRouter = false) {
|
||||||
let children = [];
|
let children = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user