菜单配置

This commit is contained in:
BianLzhaoMin 2025-12-17 13:37:05 +08:00
parent a9855f5d72
commit ada7408941
15 changed files with 230 additions and 97 deletions

View File

@ -8,15 +8,13 @@ import InnerLink from '@/layout/components/InnerLink'
// 匹配views里面所有的.vue文件
const modules = import.meta.glob('./../../views/**/*.vue')
const usePermissionStore = defineStore(
'permission',
{
const usePermissionStore = defineStore('permission', {
state: () => ({
routes: [],
addRoutes: [],
defaultRoutes: [],
topbarRouters: [],
sidebarRouters: []
sidebarRouters: [],
}),
actions: {
setRoutes(routes) {
@ -33,9 +31,9 @@ const usePermissionStore = defineStore(
this.sidebarRouters = routes
},
generateRoutes(roles) {
return new Promise(resolve => {
return new Promise((resolve) => {
// 向后端请求路由数据
getRouters().then(res => {
getRouters().then((res) => {
const sdata = JSON.parse(JSON.stringify(res.data))
const rdata = JSON.parse(JSON.stringify(res.data))
const defaultData = JSON.parse(JSON.stringify(res.data))
@ -43,7 +41,9 @@ const usePermissionStore = defineStore(
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
const defaultRoutes = filterAsyncRouter(defaultData)
const asyncRoutes = filterDynamicRoutes(dynamicRoutes)
asyncRoutes.forEach(route => { router.addRoute(route) })
asyncRoutes.forEach((route) => {
router.addRoute(route)
})
this.setRoutes(rewriteRoutes)
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
this.setDefaultRoutes(sidebarRoutes)
@ -51,13 +51,13 @@ const usePermissionStore = defineStore(
resolve(rewriteRoutes)
})
})
}
}
})
},
},
})
// 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
return asyncRouterMap.filter(route => {
return asyncRouterMap.filter((route) => {
if (type && route.children) {
route.children = filterChildren(route.children)
}
@ -85,7 +85,7 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
function filterChildren(childrenMap, lastRouter = false) {
var children = []
childrenMap.forEach(el => {
childrenMap.forEach((el) => {
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
if (el.children && el.children.length && el.component === 'ParentView') {
children = children.concat(filterChildren(el.children, el))
@ -99,7 +99,7 @@ function filterChildren(childrenMap, lastRouter = false) {
// 动态路由遍历,验证是否具备权限
export function filterDynamicRoutes(routes) {
const res = []
routes.forEach(route => {
routes.forEach((route) => {
if (route.permissions) {
if (auth.hasPermiOr(route.permissions)) {
res.push(route)

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>业务类型管理</h1>
</div>
</template>
<script setup name="BusinessType"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>运检站管理</h1>
</div>
</template>
<script setup name="InspectionStation"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>人员分类管理</h1>
</div>
</template>
<script setup name="PersonCategory"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>人员性质管理</h1>
</div>
</template>
<script setup name="PersonNature"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>计划类别管理</h1>
</div>
</template>
<script setup name="PlanCategory"></script>
<style></style>

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>计划专业管理</h1>
</div>
</template>
<script setup name="PlanProfessional"></script>
<style></style>

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>岗位管理</h1>
</div>
</template>
<script setup name="Position"></script>
<style></style>

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>项目部管理</h1>
</div>
</template>
<script setup name="ProjectDept"></script>
<style></style>

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>工作量类别管理</h1>
</div>
</template>
<script setup name="WorkloadCategory"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>月报管理</h1>
</div>
</template>
<script setup name="monthlyReport"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>人员管理123</h1>
</div>
</template>
<script setup name="Person"></script>
<style></style>

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>日计划填报管理</h1>
</div>
</template>
<script setup name="DailyPlan"></script>
<style></style>

View File

@ -0,0 +1,9 @@
<template>
<div>
<h1>月计划填报管理</h1>
</div>
</template>
<script setup name="MonthlyPlan"></script>
<style></style>

View File

@ -0,0 +1,10 @@
<template>
<div>
<h1>计划管理</h1>
</div>
</template>
<script setup name="Plan"></script>
<style></style>