diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index 3c510ca..15afc87 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -6,7 +6,7 @@
-
+
-
+
@@ -30,6 +30,7 @@ import { isExternal } from '@/utils/validate'
import Item from './Item'
import AppLink from './Link'
import FixiOSBug from './FixiOSBug'
+import { mapGetters } from 'vuex'
export default {
name: 'SidebarItem',
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index 224e2ff..3a61c8a 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -41,9 +41,6 @@ export default {
'permission_routes',
'sidebar'
]),
- // routes() {
- // return this.$router.options.routes
- // },
activeMenu() {
const route = this.$route
const { meta, path } = route
diff --git a/src/permission.js b/src/permission.js
index 6725915..560643e 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -1,4 +1,4 @@
-import router, { asyncRoutes } from './router'
+import router, { asyncRoutes, resetRouter } from './router'
import store from './store'
// import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
@@ -26,9 +26,22 @@ router.beforeEach(async(to, from, next) => {
NProgress.done()
} else {
if (to.name) {
+ if (to.path.indexOf('reagent') !== -1) {
+ store.commit('user/SET_CLASS', 'reagent')
+ }
+ if (to.path.indexOf('user') !== -1) {
+ store.commit('user/SET_CLASS', 'user')
+ }
next()
} else {
+ if (to.path.indexOf('reagent') !== -1) {
+ store.commit('user/SET_CLASS', 'reagent')
+ }
+ if (to.path.indexOf('user') !== -1) {
+ store.commit('user/SET_CLASS', 'user')
+ }
store.commit('permission/SET_ROUTES', asyncRoutes)
+ resetRouter()
router.addRoutes(asyncRoutes)
next({ ...to, replace: true })
}
diff --git a/src/router/index.js b/src/router/index.js
index b4db9a9..ca70731 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -49,6 +49,7 @@ export const constantRoutes = [
},
{
path: '/404',
+ name: '404',
component: () => import('@/views/404'),
hidden: true
}
@@ -60,7 +61,6 @@ export const asyncRoutes = [
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]
-
const createRouter = () => new Router({
// mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }),
diff --git a/src/router/modules/reagent.js b/src/router/modules/reagent.js
index 3b43d6b..0b39a2e 100644
--- a/src/router/modules/reagent.js
+++ b/src/router/modules/reagent.js
@@ -4,17 +4,18 @@ const reagentRouter = [
{
path: '/reagent',
hidden: true,
- redirect: '/reagent/mainoverview/index'
+ redirect: '/reagent/mainoverview/index',
+ meta: { classification: 'reagent' }
},
{
path: '/reagent/mainoverview',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'MainOverview',
- meta: { title: '主预览', icon: '主概览', class: 'reagent' },
+ meta: { title: '主预览', icon: '主概览', classification: 'reagent' },
component: () => import('@/views/reagent/mainoverview/index')
}
]
@@ -22,180 +23,180 @@ const reagentRouter = [
{
path: '/reagent/report',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Report',
component: () => import('@/views/reagent/report/index'),
- meta: { title: '报告统计', icon: '报表统计', class: 'reagent' }
+ meta: { title: '报告统计', icon: '报表统计', classification: 'reagent' }
},
{
path: 'storeinfo',
name: 'StoreInfo',
component: () => import('@/views/reagent/report/storeinfo/index'),
hidden: true,
- meta: { title: '库存信息总览', icon: '报表统计', class: 'reagent' }
+ meta: { title: '库存信息总览', icon: '报表统计', classification: 'reagent' }
},
{
path: 'reagentinfo',
name: 'ReagentInfo',
component: () => import('@/views/reagent/report/reagentinfo/index'),
hidden: true,
- meta: { title: '试剂信息详情', icon: '报表统计', class: 'reagent' }
+ meta: { title: '试剂信息详情', icon: '报表统计', classification: 'reagent' }
},
{
path: 'warehousinginfo',
name: 'WarehousingInfo',
component: () => import('@/views/reagent/report/warehousinginfo/index'),
hidden: true,
- meta: { title: '入库信息查询', icon: '报表统计', class: 'reagent' }
+ meta: { title: '入库信息查询', icon: '报表统计', classification: 'reagent' }
},
{
path: 'inventoryconsuminfo',
name: 'InventoryConsumInfo',
component: () => import('@/views/reagent/report/inventoryconsum/index'),
hidden: true,
- meta: { title: '库存消耗', icon: '报表统计', class: 'reagent' }
+ meta: { title: '库存消耗', icon: '报表统计', classification: 'reagent' }
},
{
path: 'reagentconsuminfo',
name: 'ReagentConsumInfo',
component: () => import('@/views/reagent/report/reagentconsum/index'),
hidden: true,
- meta: { title: '试剂消耗', icon: '报表统计', class: 'reagent' }
+ meta: { title: '试剂消耗', icon: '报表统计', classification: 'reagent' }
},
{
path: 'userconsuminfo',
name: 'UserConsumInfo',
component: () => import('@/views/reagent/report/userconsum/index'),
hidden: true,
- meta: { title: '人员用量消耗', icon: '报表统计', class: 'reagent' }
+ meta: { title: '人员用量消耗', icon: '报表统计', classification: 'reagent' }
},
{
path: 'usefrequencyinfo',
name: 'UseFrequencyInfo',
component: () => import('@/views/reagent/report/usefrequency/index'),
hidden: true,
- meta: { title: '使用频率', icon: '报表统计', class: 'reagent' }
+ meta: { title: '使用频率', icon: '报表统计', classification: 'reagent' }
},
{
path: 'recordinfo/:t',
name: 'RecordInfo',
component: () => import('@/views/reagent/report/record/index'),
hidden: true,
- meta: { title: '记录', icon: '报表统计', class: 'reagent' }
+ meta: { title: '记录', icon: '报表统计', classification: 'reagent' }
}
]
},
{
path: '/reagent/warehousing',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Warehousing',
component: () => import('@/views/reagent/warehousing/index'),
- meta: { title: '试剂入库', icon: '试剂入库', class: 'reagent' }
+ meta: { title: '试剂入库', icon: '试剂入库', classification: 'reagent' }
}
]
},
{
path: '/reagent/receiving',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Receiving',
component: () => import('@/views/reagent/receivingandreturn/index'),
- meta: { title: '试剂领用', icon: '试剂领用', class: 'reagent' }
+ meta: { title: '试剂领用', icon: '试剂领用', classification: 'reagent' }
}
]
},
{
path: '/reagent/sendback',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'SendBack',
component: () => import('@/views/reagent/receivingandreturn/index'),
- meta: { title: '试剂归还', icon: '试剂归还', class: 'reagent' }
+ meta: { title: '试剂归还', icon: '试剂归还', classification: 'reagent' }
}
]
},
{
path: '/reagent/weighing',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'weighing',
component: () => import('@/views/reagent/weighing/index'),
- meta: { title: '试剂称重', icon: '试剂称重', class: 'reagent' }
+ meta: { title: '试剂称重', icon: '试剂称重', classification: 'reagent' }
}
]
},
{
path: '/reagent/inventory',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Inventory',
component: () => import('@/views/reagent/inventory/index'),
- meta: { title: '试剂盘点', icon: '库存盘点', class: 'reagent' }
+ meta: { title: '试剂盘点', icon: '库存盘点', classification: 'reagent' }
}
]
},
{
path: '/reagent/database',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Database',
component: () => import('@/views/reagent/database/index'),
- meta: { title: '化学品数据库', icon: '化学品数据库', class: 'reagent' }
+ meta: { title: '化学品数据库', icon: '化学品数据库', classification: 'reagent' }
}
]
},
{
path: '/reagent/management',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Management',
component: () => import('@/views/reagent/management/index'),
- meta: { title: '试剂管理', icon: '试剂管理', class: 'reagent' }
+ meta: { title: '试剂管理', icon: '试剂管理', classification: 'reagent' }
}
]
},
{
path: '/reagent/buy',
component: Layout,
- meta: { class: 'reagent' },
+ meta: { classification: 'reagent' },
children: [
{
path: 'index',
name: 'Buy',
component: () => import('@/views/reagent/buy/index'),
- meta: { title: '请购', icon: '请购', class: 'reagent' }
+ meta: { title: '请购', icon: '请购', classification: 'reagent' }
}
]
},
{
path: '/gotohome',
redirect: '/home',
- meta: { title: '返回主页', icon: 'el-icon-arrow-left', class: 'reagent' }
+ meta: { title: '返回主页', icon: 'el-icon-arrow-left', classification: 'reagent' }
}
]
diff --git a/src/router/modules/user.js b/src/router/modules/user.js
index 0dddf3e..12e6dad 100644
--- a/src/router/modules/user.js
+++ b/src/router/modules/user.js
@@ -7,33 +7,38 @@ const userRouter = [
path: '/user',
redirect: '/user/info/index',
hidden: true,
- meta: { class: 'user' }
+ meta: { classification: 'user' }
},
{
path: '/user/info',
component: Layout,
- meta: { class: 'user' },
+ meta: { classification: 'user' },
children: [
{
path: 'index',
component: () => import('@/views/user/index'),
name: 'UserInfo',
- meta: { title: '用户信息', icon: 'lock', class: 'user' }
+ meta: { title: '用户信息', icon: 'lock', classification: 'user' }
}
]
},
{
path: '/user/role',
component: Layout,
- meta: { class: 'user' },
+ meta: { classification: 'user' },
children: [
{
path: 'index',
component: () => import('@/views/user/role/index'),
name: 'Role',
- meta: { title: '角色信息', icon: 'lock', class: 'user' }
+ meta: { title: '角色信息', icon: 'lock', classification: 'user' }
}
]
+ },
+ {
+ path: '/gotohome',
+ redirect: '/home',
+ meta: { title: '返回主页', icon: 'el-icon-arrow-left', classification: 'user' }
}
]
diff --git a/src/store/getters.js b/src/store/getters.js
index d75c2ad..bc2d7cf 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -4,6 +4,7 @@ const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
- permission_routes: state => state.permission.routes
+ permission_routes: state => state.permission.routes,
+ classification: state => state.user.classification
}
export default getters
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 4d20d97..7024378 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -6,7 +6,8 @@ const getDefaultState = () => {
return {
token: getToken(),
name: '',
- avatar: ''
+ avatar: '',
+ classification: ''
}
}
@@ -18,13 +19,16 @@ const mutations = {
},
SET_TOKEN: (state, token) => {
state.token = token
+ },
+ SET_NAME: (state, name) => {
+ state.name = name
+ },
+ SET_AVATAR: (state, avatar) => {
+ state.avatar = avatar
+ },
+ SET_CLASS: (state, name) => {
+ state.classification = name
}
- // SET_NAME: (state, name) => {
- // state.name = name
- // },
- // SET_AVATAR: (state, avatar) => {
- // state.avatar = avatar
- // }
}
const actions = {
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 74fb43d..99df898 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -11,7 +11,7 @@
-
+