parent
198b5516e8
commit
c915903832
@ -0,0 +1,202 @@
|
|||||||
|
import Layout from '@/layout'
|
||||||
|
|
||||||
|
const reagentRouter = [
|
||||||
|
{
|
||||||
|
path: '/reagent',
|
||||||
|
hidden: true,
|
||||||
|
redirect: '/reagent/mainoverview/index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/mainoverview',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'MainOverview',
|
||||||
|
meta: { title: '主预览', icon: '主概览', class: 'reagent' },
|
||||||
|
component: () => import('@/views/reagent/mainoverview/index')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/report',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Report',
|
||||||
|
component: () => import('@/views/reagent/report/index'),
|
||||||
|
meta: { title: '报告统计', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'storeinfo',
|
||||||
|
name: 'StoreInfo',
|
||||||
|
component: () => import('@/views/reagent/report/storeinfo/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '库存信息总览', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'reagentinfo',
|
||||||
|
name: 'ReagentInfo',
|
||||||
|
component: () => import('@/views/reagent/report/reagentinfo/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '试剂信息详情', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'warehousinginfo',
|
||||||
|
name: 'WarehousingInfo',
|
||||||
|
component: () => import('@/views/reagent/report/warehousinginfo/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '入库信息查询', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'inventoryconsuminfo',
|
||||||
|
name: 'InventoryConsumInfo',
|
||||||
|
component: () => import('@/views/reagent/report/inventoryconsum/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '库存消耗', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'reagentconsuminfo',
|
||||||
|
name: 'ReagentConsumInfo',
|
||||||
|
component: () => import('@/views/reagent/report/reagentconsum/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '试剂消耗', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'userconsuminfo',
|
||||||
|
name: 'UserConsumInfo',
|
||||||
|
component: () => import('@/views/reagent/report/userconsum/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '人员用量消耗', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'usefrequencyinfo',
|
||||||
|
name: 'UseFrequencyInfo',
|
||||||
|
component: () => import('@/views/reagent/report/usefrequency/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '使用频率', icon: '报表统计', class: 'reagent' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'recordinfo/:t',
|
||||||
|
name: 'RecordInfo',
|
||||||
|
component: () => import('@/views/reagent/report/record/index'),
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '记录', icon: '报表统计', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/warehousing',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Warehousing',
|
||||||
|
component: () => import('@/views/reagent/warehousing/index'),
|
||||||
|
meta: { title: '试剂入库', icon: '试剂入库', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/receiving',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Receiving',
|
||||||
|
component: () => import('@/views/reagent/receivingandreturn/index'),
|
||||||
|
meta: { title: '试剂领用', icon: '试剂领用', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/sendback',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'SendBack',
|
||||||
|
component: () => import('@/views/reagent/receivingandreturn/index'),
|
||||||
|
meta: { title: '试剂归还', icon: '试剂归还', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/weighing',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'weighing',
|
||||||
|
component: () => import('@/views/reagent/weighing/index'),
|
||||||
|
meta: { title: '试剂称重', icon: '试剂称重', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/inventory',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Inventory',
|
||||||
|
component: () => import('@/views/reagent/inventory/index'),
|
||||||
|
meta: { title: '试剂盘点', icon: '库存盘点', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/database',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Database',
|
||||||
|
component: () => import('@/views/reagent/database/index'),
|
||||||
|
meta: { title: '化学品数据库', icon: '化学品数据库', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/management',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Management',
|
||||||
|
component: () => import('@/views/reagent/management/index'),
|
||||||
|
meta: { title: '试剂管理', icon: '试剂管理', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/reagent/buy',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'reagent' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Buy',
|
||||||
|
component: () => import('@/views/reagent/buy/index'),
|
||||||
|
meta: { title: '请购', icon: '请购', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/gotohome',
|
||||||
|
redirect: '/home',
|
||||||
|
meta: { title: '返回主页', icon: 'el-icon-arrow-left', class: 'reagent' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export default reagentRouter
|
@ -0,0 +1,40 @@
|
|||||||
|
// import Layout from '@/layout'
|
||||||
|
|
||||||
|
import Layout from '@/layout'
|
||||||
|
|
||||||
|
const userRouter = [
|
||||||
|
{
|
||||||
|
path: '/user',
|
||||||
|
redirect: '/user/info/index',
|
||||||
|
hidden: true,
|
||||||
|
meta: { class: 'user' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/user/info',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'user' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
component: () => import('@/views/user/index'),
|
||||||
|
name: 'UserInfo',
|
||||||
|
meta: { title: '用户信息', icon: 'lock', class: 'user' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/user/role',
|
||||||
|
component: Layout,
|
||||||
|
meta: { class: 'user' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
component: () => import('@/views/user/role/index'),
|
||||||
|
name: 'Role',
|
||||||
|
meta: { title: '角色信息', icon: 'lock', class: 'user' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export default userRouter
|
@ -0,0 +1,69 @@
|
|||||||
|
import { asyncRoutes, constantRoutes } from '@/router'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use meta.role to determine if the current user has permission
|
||||||
|
* @param roles
|
||||||
|
* @param route
|
||||||
|
*/
|
||||||
|
function hasPermission(roles, route) {
|
||||||
|
if (route.meta && route.meta.roles) {
|
||||||
|
return roles.some(role => route.meta.roles.includes(role))
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter asynchronous routing tables by recursion
|
||||||
|
* @param routes asyncRoutes
|
||||||
|
* @param roles
|
||||||
|
*/
|
||||||
|
export function filterAsyncRoutes(routes, roles) {
|
||||||
|
const res = []
|
||||||
|
|
||||||
|
routes.forEach(route => {
|
||||||
|
const tmp = { ...route }
|
||||||
|
if (hasPermission(roles, tmp)) {
|
||||||
|
if (tmp.children) {
|
||||||
|
tmp.children = filterAsyncRoutes(tmp.children, roles)
|
||||||
|
}
|
||||||
|
res.push(tmp)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
routes: [],
|
||||||
|
addRoutes: []
|
||||||
|
}
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
SET_ROUTES: (state, routes) => {
|
||||||
|
state.addRoutes = routes
|
||||||
|
state.routes = constantRoutes.concat(routes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
generateRoutes({ commit }, roles) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let accessedRoutes
|
||||||
|
if (roles.includes('admin')) {
|
||||||
|
accessedRoutes = asyncRoutes || []
|
||||||
|
} else {
|
||||||
|
accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
|
||||||
|
}
|
||||||
|
commit('SET_ROUTES', accessedRoutes)
|
||||||
|
resolve(accessedRoutes)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<h1>用户根目录</h1>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'User'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<h1>角色信息</h1>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'Role'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
Loading…
Reference in new issue