菜单配置
This commit is contained in:
parent
a9855f5d72
commit
ada7408941
|
|
@ -8,15 +8,13 @@ import InnerLink from '@/layout/components/InnerLink'
|
||||||
// 匹配views里面所有的.vue文件
|
// 匹配views里面所有的.vue文件
|
||||||
const modules = import.meta.glob('./../../views/**/*.vue')
|
const modules = import.meta.glob('./../../views/**/*.vue')
|
||||||
|
|
||||||
const usePermissionStore = defineStore(
|
const usePermissionStore = defineStore('permission', {
|
||||||
'permission',
|
|
||||||
{
|
|
||||||
state: () => ({
|
state: () => ({
|
||||||
routes: [],
|
routes: [],
|
||||||
addRoutes: [],
|
addRoutes: [],
|
||||||
defaultRoutes: [],
|
defaultRoutes: [],
|
||||||
topbarRouters: [],
|
topbarRouters: [],
|
||||||
sidebarRouters: []
|
sidebarRouters: [],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setRoutes(routes) {
|
setRoutes(routes) {
|
||||||
|
|
@ -33,9 +31,9 @@ const usePermissionStore = defineStore(
|
||||||
this.sidebarRouters = routes
|
this.sidebarRouters = routes
|
||||||
},
|
},
|
||||||
generateRoutes(roles) {
|
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 sdata = JSON.parse(JSON.stringify(res.data))
|
||||||
const rdata = JSON.parse(JSON.stringify(res.data))
|
const rdata = JSON.parse(JSON.stringify(res.data))
|
||||||
const defaultData = 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 rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
||||||
const defaultRoutes = filterAsyncRouter(defaultData)
|
const defaultRoutes = filterAsyncRouter(defaultData)
|
||||||
const asyncRoutes = filterDynamicRoutes(dynamicRoutes)
|
const asyncRoutes = filterDynamicRoutes(dynamicRoutes)
|
||||||
asyncRoutes.forEach(route => { router.addRoute(route) })
|
asyncRoutes.forEach((route) => {
|
||||||
|
router.addRoute(route)
|
||||||
|
})
|
||||||
this.setRoutes(rewriteRoutes)
|
this.setRoutes(rewriteRoutes)
|
||||||
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
|
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
|
||||||
this.setDefaultRoutes(sidebarRoutes)
|
this.setDefaultRoutes(sidebarRoutes)
|
||||||
|
|
@ -51,13 +51,13 @@ const usePermissionStore = defineStore(
|
||||||
resolve(rewriteRoutes)
|
resolve(rewriteRoutes)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// 遍历后台传来的路由字符串,转换为组件对象
|
// 遍历后台传来的路由字符串,转换为组件对象
|
||||||
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
||||||
return asyncRouterMap.filter(route => {
|
return asyncRouterMap.filter((route) => {
|
||||||
if (type && route.children) {
|
if (type && route.children) {
|
||||||
route.children = filterChildren(route.children)
|
route.children = filterChildren(route.children)
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +85,7 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
||||||
|
|
||||||
function filterChildren(childrenMap, lastRouter = false) {
|
function filterChildren(childrenMap, lastRouter = false) {
|
||||||
var children = []
|
var children = []
|
||||||
childrenMap.forEach(el => {
|
childrenMap.forEach((el) => {
|
||||||
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
|
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
|
||||||
if (el.children && el.children.length && el.component === 'ParentView') {
|
if (el.children && el.children.length && el.component === 'ParentView') {
|
||||||
children = children.concat(filterChildren(el.children, el))
|
children = children.concat(filterChildren(el.children, el))
|
||||||
|
|
@ -99,7 +99,7 @@ function filterChildren(childrenMap, lastRouter = false) {
|
||||||
// 动态路由遍历,验证是否具备权限
|
// 动态路由遍历,验证是否具备权限
|
||||||
export function filterDynamicRoutes(routes) {
|
export function filterDynamicRoutes(routes) {
|
||||||
const res = []
|
const res = []
|
||||||
routes.forEach(route => {
|
routes.forEach((route) => {
|
||||||
if (route.permissions) {
|
if (route.permissions) {
|
||||||
if (auth.hasPermiOr(route.permissions)) {
|
if (auth.hasPermiOr(route.permissions)) {
|
||||||
res.push(route)
|
res.push(route)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>业务类型管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="BusinessType"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>运检站管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="InspectionStation"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>人员分类管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="PersonCategory"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>人员性质管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="PersonNature"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>计划类别管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="PlanCategory"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>计划专业管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="PlanProfessional"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>岗位管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="Position"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>项目部管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="ProjectDept"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>工作量类别管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="WorkloadCategory"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>月报管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="monthlyReport"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>人员管理123</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="Person"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>日计划填报管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="DailyPlan"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>月计划填报管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="MonthlyPlan"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>计划管理</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="Plan"></script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
|
|
||||||
Loading…
Reference in New Issue