From c24815eaabf08ee9a233921e415568d40cf22acf Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 11 三月 2024 10:51:45 +0800
Subject: [PATCH] 部门管理员路由管理
---
src/views/login/index.vue | 1
src/layout/components/Sidebar/index.vue | 8 +
src/router.js | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/store/modules/router.js | 3
4 files changed, 230 insertions(+), 4 deletions(-)
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index 59f1f9d..104421d 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -12,7 +12,7 @@
:collapse-transition="false"
mode="vertical"
>
- <sidebar-item v-for="route in routes" :key="route.path" :item="route" :base-path="route.path" />
+ <sidebar-item v-for="route in routerList" :key="route.path" :item="route" :base-path="route.path" />
</el-menu>
</el-scrollbar>
</div>
@@ -23,9 +23,15 @@
import Logo from './Logo'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
+import { deptAdminRoutes } from '@/router'
export default {
components: { SidebarItem, Logo },
+ data () {
+ return {
+ routerList: sessionStorage.getItem('deptAdmin') === '1' ? deptAdminRoutes : this.routes
+ }
+ },
computed: {
...mapGetters([
'sidebar',
diff --git a/src/router.js b/src/router.js
index e94fab1..5013f6c 100644
--- a/src/router.js
+++ b/src/router.js
@@ -356,11 +356,229 @@
}
]
+const deptAdminRoutes = [
+ {
+ path: '/redirect',
+ component: Layout,
+ hidden: true,
+ children: [
+ {
+ path: '/redirect/:path*',
+ component: () => import('@/views/redirect/index')
+ }
+ ]
+ },
+ {
+ path: '/login',
+ name: 'Login',
+ hidden: true,
+ component: () => import('@/views/login/index'),
+ meta: { title: '鐧诲綍' }
+ },
+ {
+ path: '/',
+ component: Layout,
+ redirect: '/dashboard',
+ children: [
+ {
+ path: 'dashboard',
+ component: () => import('@/views/dashboard/index'),
+ name: 'Dashboard',
+ meta: { title: '涓婚〉', icon: 'home', affix: true }
+ }
+ ]
+ },
+ {
+ path: '/exam',
+ component: Layout,
+ name: 'ExamPage',
+ meta: {
+ title: '鍗烽绠$悊',
+ icon: 'exam'
+ },
+ children: [
+ {
+ path: 'paper/list',
+ component: () => import('@/views/exam/paper/list'),
+ name: 'ExamPaperPageList',
+ meta: { title: '璇曞嵎鍒楄〃', noCache: true }
+ },
+ {
+ path: 'paper/edit',
+ component: () => import('@/views/exam/paper/edit'),
+ name: 'ExamPaperEdit',
+ meta: { title: '璇曞嵎缂栬緫', noCache: true, activeMenu: '/exam/paper/list' },
+ hidden: true
+ },
+ {
+ path: 'question/list',
+ component: () => import('@/views/exam/question/list'),
+ name: 'ExamQuestionPageList',
+ meta: { title: '棰樼洰鍒楄〃', noCache: true }
+ },
+ {
+ path: 'question/edit/singleChoice',
+ component: () => import('@/views/exam/question/edit/single-choice'),
+ name: 'singleChoicePage',
+ meta: { title: '鍗曢�夐缂栬緫', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
+ },
+ {
+ path: 'simulation/list',
+ component: () => import('@/views/exam/simulation/list'),
+ name: 'personalSimulationList',
+ meta: { title: '妯℃嫙鍒楄〃', noCache: true }
+ },
+ {
+ path: 'personalSimulation/list',
+ component: () => import('@/views/exam/personalSimulation/list'),
+ name: 'personalSimulation',
+ meta: { title: '涓汉妯℃嫙', noCache: true }
+ },
+ {
+ path: 'personalRandomTemplate/list',
+ component: () => import('@/views/exam/personalRandomTemplate/list'),
+ name: 'personalSimulation',
+ meta: { title: '闅忔満璇曞嵎', noCache: true }
+ },
+ {
+ path: 'personalRandomTemplate/edit',
+ component: () => import('@/views/exam/personalRandomTemplate/edit'),
+ name: 'personalSimulationEdit',
+ meta: { title: '闅忔満璇曞嵎', noCache: true, activeMenu: '/exam/personalRandomTemplate/list' },
+ hidden: true
+ },
+ {
+ path: 'personalSimulation/edit',
+ component: () => import('@/views/exam/personalSimulation/edit'),
+ name: 'personalSimulationEdit',
+ meta: { title: '璇曞嵎缂栬緫', noCache: true, activeMenu: '/exam/personalSimulation/list' },
+ hidden: true
+ },
+ {
+ path: 'personalSimulation/list/mathList',
+ component: () => import('@/views/exam/mathList/list.vue'),
+ name: 'multiplemathList',
+ meta: { title: '妯℃嫙鍒楄〃璇︽儏', noCache: true, activeMenu: '/exam/mathList/list' },
+ hidden: true
+ },
+ {
+ path: 'question/edit/multipleChoice',
+ component: () => import('@/views/exam/question/edit/multiple-choice'),
+ name: 'multipleChoicePage',
+ meta: { title: '澶氶�夐缂栬緫', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
+ },
+ {
+ path: 'question/edit/trueFalse',
+ component: () => import('@/views/exam/question/edit/true-false'),
+ name: 'trueFalsePage',
+ meta: { title: '鍒ゆ柇棰樼紪杈�', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
+ },
+ {
+ path: 'question/edit/gapFilling',
+ component: () => import('@/views/exam/question/edit/gap-filling'),
+ name: 'gapFillingPage',
+ meta: { title: '濉┖棰樼紪杈�', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
+ },
+ {
+ path: 'question/edit/shortAnswer',
+ component: () => import('@/views/exam/question/edit/short-answer'),
+ name: 'shortAnswerPage',
+ meta: { title: '绠�绛旈缂栬緫', noCache: true, activeMenu: '/exam/question/list' },
+ hidden: true
+ }
+ ]
+ },
+ {
+ path: '/task',
+ component: Layout,
+ name: 'TaskPage',
+ meta: {
+ title: '浠诲姟绠$悊',
+ icon: 'task'
+ },
+ alwaysShow: true,
+ children: [
+ {
+ path: 'list',
+ component: () => import('@/views/task/list'),
+ name: 'TaskListPage',
+ meta: { title: '浠诲姟鍒楄〃', noCache: true }
+ },
+ {
+ path: 'edit',
+ component: () => import('@/views/task/edit'),
+ name: 'TaskEditPage',
+ meta: { title: '浠诲姟鍒涘缓', noCache: true }
+ }
+ ]
+ },
+ {
+ path: '/answer',
+ component: Layout,
+ name: 'AnswerPage',
+ meta: {
+ title: '鎴愮哗绠$悊',
+ icon: 'answer'
+ },
+ alwaysShow: true,
+ children: [
+ {
+ path: 'list',
+ component: () => import('@/views/answer/list'),
+ name: 'AnswerPageList',
+ meta: { title: '绛斿嵎鍒楄〃', noCache: true }
+ },
+ {
+ path: 'sheetStatistics',
+ component: () => import('@/views/answer/sheetStatistics.vue'),
+ name: 'AnswerPageList',
+ meta: { title: '绛斿嵎缁熻', noCache: true }
+ },
+ {
+ path: 'achievementStatistics',
+ component: () => import('@/views/answer/achievementStatistics.vue'),
+ name: 'AnswerPageList',
+ meta: { title: '鎴愮哗缁熻', noCache: true }
+ },
+ {
+ path: 'achievementStatistics/gradeDetails',
+ component: () => import('@/views/exam/gradeDetails/list.vue'),
+ name: 'AnswerPageList',
+ meta: { title: '鎴愮哗缁熻璇︽儏', noCache: true, activeMenu: '/exam/gradeDetails/list' },
+ hidden: true
+ }
+ ]
+ },
+ {
+ path: '/profile',
+ component: Layout,
+ hidden: true,
+ children: [
+ {
+ path: 'index',
+ component: () => import('@/views/profile/index'),
+ name: 'Profile',
+ meta: { title: '涓汉绠�浠�', icon: 'user', noCache: true }
+ }
+ ]
+ },
+ { path: '*',
+ hidden: true,
+ component: () => import('@/views/error-page/404'),
+ meta: { title: '404', noCache: true }
+ }
+]
+
const router = new Router({
- routes: constantRoutes
+ routes: sessionStorage.getItem('deptAdmin') === '1' ? deptAdminRoutes : constantRoutes
})
export {
constantRoutes,
- router
+ router,
+ deptAdminRoutes
}
diff --git a/src/store/modules/router.js b/src/store/modules/router.js
index 747a715..0ec6320 100644
--- a/src/store/modules/router.js
+++ b/src/store/modules/router.js
@@ -1,4 +1,4 @@
-import { constantRoutes } from '@/router'
+import { constantRoutes, deptAdminRouter } from '@/router'
let state = {
routes: constantRoutes
@@ -11,6 +11,7 @@
}
const actions = {
+ changeRoute() {}
}
export default {
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 37ef440..84d58a8 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -165,6 +165,7 @@
console.log(result)
_this.seachPageDepartMentList()
_this.setUserName(_this.loginForm.userName)
+ sessionStorage.setItem('deptAdmin', result.response.deptAdmin)
_this.$router.push({ path: '/' })
} else {
_this.loading = false
--
Gitblit v1.8.0