import Vue from 'vue'
|
import Router from 'vue-router'
|
import AppLayout from '@/layout/AppLayout.vue'
|
|
Vue.use(Router)
|
|
const routes = [
|
{ path: '/', redirect: '/dashboard' },
|
{ path: '/login', component: () => import('@/views/Login.vue') },
|
{
|
path: '/',
|
component: AppLayout,
|
children: [
|
{ path: 'dashboard', component: () => import('@/views/Dashboard.vue') },
|
{ path: 'fault/report', component: () => import('@/views/fault/FaultReport.vue') },
|
{ path: 'fault/review', component: () => import('@/views/fault/XcbReview.vue') },
|
{ path: 'fault/approval/cmb', component: () => import('@/views/fault/SimpleApproval.vue'), meta: { stage: 'CMB' } },
|
{ path: 'fault/approval/jcc-assistant', component: () => import('@/views/fault/SimpleApproval.vue'), meta: { stage: 'JCC_ASSISTANT' } },
|
{ path: 'fault/approval/jcc-director', component: () => import('@/views/fault/SimpleApproval.vue'), meta: { stage: 'JCC_DIRECTOR' } },
|
{ path: 'fault/dispatch', component: () => import('@/views/fault/DispatchPage.vue') },
|
{ path: 'fault/completion', component: () => import('@/views/completion/CompletionList.vue') },
|
{ path: 'completion/report', component: () => import('@/views/completion/CompletionReport.vue') },
|
{ path: 'acceptance/application', component: () => import('@/views/acceptance/AcceptanceList.vue'), meta: { stage: 'APPLICATION' } },
|
{ path: 'acceptance/inspector', component: () => import('@/views/acceptance/AcceptanceList.vue'), meta: { stage: 'INSPECTOR' } },
|
{ path: 'acceptance/leader', component: () => import('@/views/acceptance/AcceptanceList.vue'), meta: { stage: 'LEADER' } },
|
{ path: 'acceptance/print', component: () => import('@/views/acceptance/AcceptanceList.vue'), meta: { stage: 'PRINT' } },
|
{ path: 'acceptance/rating', component: () => import('@/views/acceptance/AcceptanceList.vue'), meta: { stage: 'RATING' } },
|
{ path: 'reports/:type', component: () => import('@/views/report/ReportPage.vue') },
|
{ path: 'system/contractors', component: () => import('@/views/system/ContractorManage.vue') },
|
{ path: 'system/product-tree', component: () => import('@/views/system/TreeManage.vue'), meta: { treeType: 'product' } },
|
{ path: 'system/base-equipment', component: () => import('@/views/system/TreeManage.vue'), meta: { treeType: 'base' } },
|
{ path: 'system/engineering-majors', component: () => import('@/views/system/EngineeringMajorManage.vue') },
|
{ path: 'system/team-majors', component: () => import('@/views/system/TeamMajorManage.vue') },
|
{ path: 'system/roles', component: () => import('@/views/system/RoleManage.vue') },
|
{ path: 'system/menus', component: () => import('@/views/system/MenuManage.vue') },
|
{ path: 'system/menu-permissions', component: () => import('@/views/system/MenuPermission.vue') },
|
{ path: 'system/three-member', component: () => import('@/views/system/ThreeMember.vue') }
|
]
|
}
|
]
|
|
const router = new Router({ mode: 'hash', routes })
|
|
router.beforeEach((to, from, next) => {
|
const token = sessionStorage.getItem('token')
|
if (to.path === '/login') return next(token ? '/dashboard' : undefined)
|
if (!token) return next('/login')
|
next()
|
})
|
|
export default router
|