feat(index): 继续完成路由相关操作

duizhaopin_ui
duan 3 years ago
parent 40f04d1984
commit 4b810dfc66

@ -6,7 +6,7 @@
<el-badge :value="39"> <el-badge :value="39">
<img style="height: 23px" src="@/assets/0-常用/预警管理-白.png" alt=""> <img style="height: 23px" src="@/assets/0-常用/预警管理-白.png" alt="">
</el-badge> </el-badge>
<el-select v-model="value" size="small" placeholder="请选择"> <el-select v-model="$store.state.user.classification" size="small" placeholder="请选择" @change="selectChange">
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.value" :key="item.value"
@ -49,17 +49,23 @@ export default {
}, },
options: [ options: [
{ {
value: '选项1', value: 'reagent',
label: '试剂管理' label: '试剂管理'
},
{
value: 'user',
label: '用户管理'
} }
], ]
value: '选项1'
} }
}, },
methods: { methods: {
toggleSideBar() { toggleSideBar() {
this.$store.dispatch('app/toggleSideBar') this.$store.dispatch('app/toggleSideBar')
}, },
selectChange(val) {
this.$router.push('/' + val)
},
async logout() { async logout() {
await this.$store.dispatch('user/logout') await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`) this.$router.push(`/login?redirect=${this.$route.fullPath}`)

@ -1,5 +1,5 @@
<template> <template>
<div v-if="!item.hidden"> <div v-if="!item.hidden && item.meta && item.meta.classification === $store.state.user.classification">
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
@ -30,6 +30,7 @@ import { isExternal } from '@/utils/validate'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
import FixiOSBug from './FixiOSBug' import FixiOSBug from './FixiOSBug'
import { mapGetters } from 'vuex'
export default { export default {
name: 'SidebarItem', name: 'SidebarItem',

@ -41,9 +41,6 @@ export default {
'permission_routes', 'permission_routes',
'sidebar' 'sidebar'
]), ]),
// routes() {
// return this.$router.options.routes
// },
activeMenu() { activeMenu() {
const route = this.$route const route = this.$route
const { meta, path } = route const { meta, path } = route

@ -1,4 +1,4 @@
import router, { asyncRoutes } from './router' import router, { asyncRoutes, resetRouter } from './router'
import store from './store' import store from './store'
// import { Message } from 'element-ui' // import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar import NProgress from 'nprogress' // progress bar
@ -26,9 +26,22 @@ router.beforeEach(async(to, from, next) => {
NProgress.done() NProgress.done()
} else { } else {
if (to.name) { 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() next()
} else { } 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) store.commit('permission/SET_ROUTES', asyncRoutes)
resetRouter()
router.addRoutes(asyncRoutes) router.addRoutes(asyncRoutes)
next({ ...to, replace: true }) next({ ...to, replace: true })
} }

@ -49,6 +49,7 @@ export const constantRoutes = [
}, },
{ {
path: '/404', path: '/404',
name: '404',
component: () => import('@/views/404'), component: () => import('@/views/404'),
hidden: true hidden: true
} }
@ -60,7 +61,6 @@ export const asyncRoutes = [
// 404 page must be placed at the end !!! // 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true } { path: '*', redirect: '/404', hidden: true }
] ]
const createRouter = () => new Router({ const createRouter = () => new Router({
// mode: 'history', // require service support // mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),

@ -4,17 +4,18 @@ const reagentRouter = [
{ {
path: '/reagent', path: '/reagent',
hidden: true, hidden: true,
redirect: '/reagent/mainoverview/index' redirect: '/reagent/mainoverview/index',
meta: { classification: 'reagent' }
}, },
{ {
path: '/reagent/mainoverview', path: '/reagent/mainoverview',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'MainOverview', name: 'MainOverview',
meta: { title: '主预览', icon: '主概览', class: 'reagent' }, meta: { title: '主预览', icon: '主概览', classification: 'reagent' },
component: () => import('@/views/reagent/mainoverview/index') component: () => import('@/views/reagent/mainoverview/index')
} }
] ]
@ -22,180 +23,180 @@ const reagentRouter = [
{ {
path: '/reagent/report', path: '/reagent/report',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Report', name: 'Report',
component: () => import('@/views/reagent/report/index'), component: () => import('@/views/reagent/report/index'),
meta: { title: '报告统计', icon: '报表统计', class: 'reagent' } meta: { title: '报告统计', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'storeinfo', path: 'storeinfo',
name: 'StoreInfo', name: 'StoreInfo',
component: () => import('@/views/reagent/report/storeinfo/index'), component: () => import('@/views/reagent/report/storeinfo/index'),
hidden: true, hidden: true,
meta: { title: '库存信息总览', icon: '报表统计', class: 'reagent' } meta: { title: '库存信息总览', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'reagentinfo', path: 'reagentinfo',
name: 'ReagentInfo', name: 'ReagentInfo',
component: () => import('@/views/reagent/report/reagentinfo/index'), component: () => import('@/views/reagent/report/reagentinfo/index'),
hidden: true, hidden: true,
meta: { title: '试剂信息详情', icon: '报表统计', class: 'reagent' } meta: { title: '试剂信息详情', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'warehousinginfo', path: 'warehousinginfo',
name: 'WarehousingInfo', name: 'WarehousingInfo',
component: () => import('@/views/reagent/report/warehousinginfo/index'), component: () => import('@/views/reagent/report/warehousinginfo/index'),
hidden: true, hidden: true,
meta: { title: '入库信息查询', icon: '报表统计', class: 'reagent' } meta: { title: '入库信息查询', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'inventoryconsuminfo', path: 'inventoryconsuminfo',
name: 'InventoryConsumInfo', name: 'InventoryConsumInfo',
component: () => import('@/views/reagent/report/inventoryconsum/index'), component: () => import('@/views/reagent/report/inventoryconsum/index'),
hidden: true, hidden: true,
meta: { title: '库存消耗', icon: '报表统计', class: 'reagent' } meta: { title: '库存消耗', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'reagentconsuminfo', path: 'reagentconsuminfo',
name: 'ReagentConsumInfo', name: 'ReagentConsumInfo',
component: () => import('@/views/reagent/report/reagentconsum/index'), component: () => import('@/views/reagent/report/reagentconsum/index'),
hidden: true, hidden: true,
meta: { title: '试剂消耗', icon: '报表统计', class: 'reagent' } meta: { title: '试剂消耗', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'userconsuminfo', path: 'userconsuminfo',
name: 'UserConsumInfo', name: 'UserConsumInfo',
component: () => import('@/views/reagent/report/userconsum/index'), component: () => import('@/views/reagent/report/userconsum/index'),
hidden: true, hidden: true,
meta: { title: '人员用量消耗', icon: '报表统计', class: 'reagent' } meta: { title: '人员用量消耗', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'usefrequencyinfo', path: 'usefrequencyinfo',
name: 'UseFrequencyInfo', name: 'UseFrequencyInfo',
component: () => import('@/views/reagent/report/usefrequency/index'), component: () => import('@/views/reagent/report/usefrequency/index'),
hidden: true, hidden: true,
meta: { title: '使用频率', icon: '报表统计', class: 'reagent' } meta: { title: '使用频率', icon: '报表统计', classification: 'reagent' }
}, },
{ {
path: 'recordinfo/:t', path: 'recordinfo/:t',
name: 'RecordInfo', name: 'RecordInfo',
component: () => import('@/views/reagent/report/record/index'), component: () => import('@/views/reagent/report/record/index'),
hidden: true, hidden: true,
meta: { title: '记录', icon: '报表统计', class: 'reagent' } meta: { title: '记录', icon: '报表统计', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/warehousing', path: '/reagent/warehousing',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Warehousing', name: 'Warehousing',
component: () => import('@/views/reagent/warehousing/index'), component: () => import('@/views/reagent/warehousing/index'),
meta: { title: '试剂入库', icon: '试剂入库', class: 'reagent' } meta: { title: '试剂入库', icon: '试剂入库', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/receiving', path: '/reagent/receiving',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Receiving', name: 'Receiving',
component: () => import('@/views/reagent/receivingandreturn/index'), component: () => import('@/views/reagent/receivingandreturn/index'),
meta: { title: '试剂领用', icon: '试剂领用', class: 'reagent' } meta: { title: '试剂领用', icon: '试剂领用', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/sendback', path: '/reagent/sendback',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'SendBack', name: 'SendBack',
component: () => import('@/views/reagent/receivingandreturn/index'), component: () => import('@/views/reagent/receivingandreturn/index'),
meta: { title: '试剂归还', icon: '试剂归还', class: 'reagent' } meta: { title: '试剂归还', icon: '试剂归还', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/weighing', path: '/reagent/weighing',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'weighing', name: 'weighing',
component: () => import('@/views/reagent/weighing/index'), component: () => import('@/views/reagent/weighing/index'),
meta: { title: '试剂称重', icon: '试剂称重', class: 'reagent' } meta: { title: '试剂称重', icon: '试剂称重', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/inventory', path: '/reagent/inventory',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Inventory', name: 'Inventory',
component: () => import('@/views/reagent/inventory/index'), component: () => import('@/views/reagent/inventory/index'),
meta: { title: '试剂盘点', icon: '库存盘点', class: 'reagent' } meta: { title: '试剂盘点', icon: '库存盘点', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/database', path: '/reagent/database',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Database', name: 'Database',
component: () => import('@/views/reagent/database/index'), component: () => import('@/views/reagent/database/index'),
meta: { title: '化学品数据库', icon: '化学品数据库', class: 'reagent' } meta: { title: '化学品数据库', icon: '化学品数据库', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/management', path: '/reagent/management',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Management', name: 'Management',
component: () => import('@/views/reagent/management/index'), component: () => import('@/views/reagent/management/index'),
meta: { title: '试剂管理', icon: '试剂管理', class: 'reagent' } meta: { title: '试剂管理', icon: '试剂管理', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/reagent/buy', path: '/reagent/buy',
component: Layout, component: Layout,
meta: { class: 'reagent' }, meta: { classification: 'reagent' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'Buy', name: 'Buy',
component: () => import('@/views/reagent/buy/index'), component: () => import('@/views/reagent/buy/index'),
meta: { title: '请购', icon: '请购', class: 'reagent' } meta: { title: '请购', icon: '请购', classification: 'reagent' }
} }
] ]
}, },
{ {
path: '/gotohome', path: '/gotohome',
redirect: '/home', redirect: '/home',
meta: { title: '返回主页', icon: 'el-icon-arrow-left', class: 'reagent' } meta: { title: '返回主页', icon: 'el-icon-arrow-left', classification: 'reagent' }
} }
] ]

@ -7,33 +7,38 @@ const userRouter = [
path: '/user', path: '/user',
redirect: '/user/info/index', redirect: '/user/info/index',
hidden: true, hidden: true,
meta: { class: 'user' } meta: { classification: 'user' }
}, },
{ {
path: '/user/info', path: '/user/info',
component: Layout, component: Layout,
meta: { class: 'user' }, meta: { classification: 'user' },
children: [ children: [
{ {
path: 'index', path: 'index',
component: () => import('@/views/user/index'), component: () => import('@/views/user/index'),
name: 'UserInfo', name: 'UserInfo',
meta: { title: '用户信息', icon: 'lock', class: 'user' } meta: { title: '用户信息', icon: 'lock', classification: 'user' }
} }
] ]
}, },
{ {
path: '/user/role', path: '/user/role',
component: Layout, component: Layout,
meta: { class: 'user' }, meta: { classification: 'user' },
children: [ children: [
{ {
path: 'index', path: 'index',
component: () => import('@/views/user/role/index'), component: () => import('@/views/user/role/index'),
name: 'Role', 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' }
} }
] ]

@ -4,6 +4,7 @@ const getters = {
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
name: state => state.user.name, 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 export default getters

@ -6,7 +6,8 @@ const getDefaultState = () => {
return { return {
token: getToken(), token: getToken(),
name: '', name: '',
avatar: '' avatar: '',
classification: ''
} }
} }
@ -18,13 +19,16 @@ const mutations = {
}, },
SET_TOKEN: (state, token) => { SET_TOKEN: (state, token) => {
state.token = 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 = { const actions = {

@ -11,7 +11,7 @@
<div key="2" class="home-pic-item"><img src="@/assets/2-主界面/标准品管理.png" alt=""></div> <div key="2" class="home-pic-item"><img src="@/assets/2-主界面/标准品管理.png" alt=""></div>
<div key="3" class="home-pic-item"><img src="@/assets/2-主界面/耗材管理.png" alt=""></div> <div key="3" class="home-pic-item"><img src="@/assets/2-主界面/耗材管理.png" alt=""></div>
<div key="4" class="home-pic-item"><img src="@/assets/2-主界面/仪器管理.png" alt=""></div> <div key="4" class="home-pic-item"><img src="@/assets/2-主界面/仪器管理.png" alt=""></div>
<div key="5" class="home-pic-item"><img src="@/assets/2-主界面/用户管理.png" alt=""></div> <div key="5" class="home-pic-item" @click="picClick('/user')"><img src="@/assets/2-主界面/用户管理.png" alt=""></div>
</div> </div>
<div class="home-menu"> <div class="home-menu">
<div v-for="item in 9" :key="item" class="home-menu-item"> <div v-for="item in 9" :key="item" class="home-menu-item">

@ -224,8 +224,6 @@ import Scanner from '@/components/Scannner/index'
import { show_tmp, select_drug, bind_tmp_enter_warehouse, add_tmp, del_tmp } from '@/api/reagent/warehousing' import { show_tmp, select_drug, bind_tmp_enter_warehouse, add_tmp, del_tmp } from '@/api/reagent/warehousing'
import stringify from '@/utils/stringify' import stringify from '@/utils/stringify'
import { getClients } from '@/views/reagent/mixin/getClients' import { getClients } from '@/views/reagent/mixin/getClients'
import { MessageBox } from 'element-ui'
import store from '@/store'
export default { export default {
name: 'Warehousing', name: 'Warehousing',

Loading…
Cancel
Save