首页业务处理

This commit is contained in:
13405411873 2024-10-24 00:17:42 +08:00
parent d2ae3d87f6
commit e05d5e9270

View File

@ -37,8 +37,9 @@ const permission = {
// 将 menus 菜单,转换为 route 路由数组
const sdata = JSON.parse(JSON.stringify(menus)) // 【重要】用于菜单中的数据
const rdata = JSON.parse(JSON.stringify(menus)) // 用于最后添加到 Router 中的数据
const sidebarRoutes = filterAsyncRouter(sdata)
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
const sss = JSON.parse(JSON.stringify(menus))
const sidebarRoutes = filterAsyncRouter(sdata,sss)
const rewriteRoutes = filterAsyncRouter(rdata,sss, false, true)
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
commit('SET_ROUTES', rewriteRoutes)
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) {
// 将 ruoyi 后端原有耦合前端的逻辑,迁移到此处
// 处理 meta 属性
route.meta = {
title:dealMenuText(index) +' '+ route.name,
icon: route.icon,
title:dealMenuText(index,route,sdata) +' '+ route.name,
noCache: !route.keepAlive,
}
route.hidden = !route.visible
@ -89,23 +89,56 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
route.children = filterChildren(route.children)
}
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
} else {
delete route['children']
delete route['alwaysShow'] // 如果没有子菜单,就不需要考虑 alwaysShow 字段
}
console.log(route,989898)
return true
})
}
function dealMenuText(num){
let tempData =['(一)','(二)','(三)','(四)','(五)','(六)','(七)','(八)','(九)','(十)'
,'(十一)','(十二)','(十三)','(十四)','(十五)','(十六)','(十七)','(十八)','(十九)','(二十)','(二十一)','(二十二)','(二十三)']
function dealMenuText(num,data,list){
if (data.parentId==0){
let tempData =['一','二','三','四','五','六','七','八','九','十'
,'十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一','二十二','二十三']
if (num>tempData.length){
return "";
}
return tempData[num]
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 ""
}
}
}
function filterChildren(childrenMap, lastRouter = false) {
let children = [];