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

duizhaopin_ui
duan 3 years ago
parent 40f04d1984
commit 4b810dfc66

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

@ -1,5 +1,5 @@
<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">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<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 AppLink from './Link'
import FixiOSBug from './FixiOSBug'
import { mapGetters } from 'vuex'
export default {
name: 'SidebarItem',

@ -41,9 +41,6 @@ export default {
'permission_routes',
'sidebar'
]),
// routes() {
// return this.$router.options.routes
// },
activeMenu() {
const route = this.$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 { 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 })
}

@ -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 }),

@ -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' }
}
]

@ -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' }
}
]

@ -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

@ -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 = {

@ -11,7 +11,7 @@
<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="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 class="home-menu">
<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 stringify from '@/utils/stringify'
import { getClients } from '@/views/reagent/mixin/getClients'
import { MessageBox } from 'element-ui'
import store from '@/store'
export default {
name: 'Warehousing',

Loading…
Cancel
Save