import Vue from 'vue'
import VueRouter from 'vue-router'

/** 导入element-UI信息提示组件 */
import {
	Message
} from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css'
Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}


/** 按需导入后台系统功能组件 */
const routes = [{
		path: '',
		redirect: '/login'
	},
	{
		path: '/login',
		component: () => import('../components/login')
	},
	{
		path: '/admin',
		component: () => import('../components/admin'),
		children: [{
				path: '/admin/routineMonitor',
				name:'routineMonitor',
				component: () => import('../components/admin/routineMonitor')
			},
			{
				path: '/admin/checkMonitor',
				name:'checkMonitor',
				component: () => import('../components/admin/checkMonitor')
			},
			{
				path: '/admin/specialMonitor',
				name:'specialMonitor',
				component: () => import('../components/admin/specialMonitor')
			},
			{
				path: '/admin/addTask',
				name:'addTask',
				component: () => import('../components/admin/addTask')
			},
			
			{
				path: '/admin/recheckMonitor',
				name:'recheckMonitor',
				component: () => import('../components/admin/recheckMonitor')
			},
			{
				path: '/admin/addSpecialTask',
				name:'addSpecialTask',
				component: () => import('../components/admin/addSpecialTask')
			},
			{
				path: '/admin/addTaskJcObject',
					name:'addTaskJcObject',
					component: () => import('../components/admin/addTaskJcObject')
			},{
				path: '/admin/userAccount',
					name:'userAccount',
					component: () => import('../components/admin/userAccount')
			},{
				path: '/admin/putAccount',
					name:'putAccount',
					component: () => import('../components/admin/putAccount')
			},{
				path: '/admin/getOrganization',
					name:'getOrganization',
					component: () => import('../components/admin/getOrganization')
			},{
				path: '/admin/getMonitor',
					name:'getMonitor',
					component: () => import('../components/admin/getMonitor')
			},{
				path: '/admin/setTaskJg',
				name:'setTaskJg',
				component: () => import('../components/admin/setTaskJg')
			},{
				path: '/admin/readSampleList',
				name:'readSampleList',
				component: () => import('../components/admin/readSampleList')
			},{
				path: '/admin/getJcds',
				name:'getJcds',
				component: () => import('../components/admin/getJcds')
			},{
				path: '/admin/readCheckList',
				name:'readCheckList',
				component: () => import('../components/admin/readCheckList')
			},{
				path: '/admin/reTask',
				name:'reTask',
				component: () => import('../components/admin/reTask')
			},{
				path: '/admin/editInformation',
				name:'editInformation',
				component: () => import('../components/admin/editInformation')
			},{
				path: '/admin/readSample',
				name:'readSample',
				component: () => import('../components/admin/readSample')
			},{
				path: '/admin/readCheck',
				name:'readCheck',
				component: () => import('../components/admin/readCheck')
			},{
				path: '/admin/nextStep',
				name:'nextStep',
				component: () => import('../components/admin/nextStep')
			},{
				path: '/admin/addTaskZx',
				name:'addTaskZx',
				component: () => import('../components/admin/addTaskZx')
			},{
				path: '/admin/addTaskObjectZx',
				name:'addTaskObjectZx',
				component: () => import('../components/admin/addTaskObjectZx')
			},{
				path: '/admin/addTaskJd',
				name:'addTaskJd',
				component: () => import('../components/admin/addTaskJd')
			},{
				path: '/admin/addTaskObjectJd',
				name:'addTaskObjectJd',
				component: () => import('../components/admin/addTaskObjectJd')
			},{
				path: '/admin/conSole',
				name:'conSole',
				component: () => import('../components/admin/conSole')
			},{
				path: '/admin/conSoleChild',
				name:'conSoleChild',
				component: () => import('../components/admin/conSoleChild')
			},{
				path: '/admin/systemIntro',
				name:'systemIntro',
				component: () => import('../components/admin/systemIntro')
			},{
				path: '/admin/dataEchart',
				name:'dataEchart',
				component: () => import('../components/admin/dataEchart')
			},
			
		]
	},
	{
		path: '/jc',
		component: () => import('../components/jc'),
		children: [{
				path: '/jc/routineMonitor',
				component: () => import('../components/jc/routineMonitor')
			},
			{
				path: '/jc/routineMonitorqt',
				component: () => import('../components/jc/routineMonitorqt'),
				// children:[]
			},
			{
				path: '/jc/taskdetail',
				name:'taskdetail',
				component: () => import('../components/jc/taskdetail')
			},
			{
				path: '/jc/jcobj',
				name:'jcobj',
				component: () => import('../components/jc/jcobj')
			},
			{
				path: '/jc/modelSet',
				name:'modelSet',
				component: () => import('../components/jc/modelSet')
			},
			{
				path: '/jc/inputSample',
				name:'inputSample',
				component: () => import('../components/jc/inputSample')
			},
			{
				path: '/jc/sampleDetail',
				name:'sampleDetail',
				component: () => import('../components/jc/sampleDetail')
			},
			{
				path: '/jc/inputCheck',
				name:'inputCheck',
				component: () => import('../components/jc/inputCheck')
			},
			{
				path: '/jc/specialMonitorqt',
				name:'specialMonitorqt',
				component: () => import('../components/jc/specialMonitorqt')
			},
			{
				path: '/jc/specialMonitorcd',
				name:'specialMonitorcd',
				component: () => import('../components/jc/specialMonitorcd')
			},
			
			{
				path: '/jc/setTaskcd',
				name:'setTaskcd',
				component: () => import('../components/jc/setTaskcd'),
			},
			{
					path: '/jc/setTask',
					name:'setTask',
					component: () => import('../components/jc/setTask')
			},
			{
					path: '/jc/sampleReport',
					name:'sampleReport',
					component: () => import('../components/jc/sampleReport')
			},{
				path: '/jc/fillSampleReport',
				name:'fillSampleReport',
				component: () => import('../components/jc/fillSampleReport')
		},{
			path: '/jc/returnTaskcd',
			name:'returnTaskcd',
			component: () => import('../components/jc/returnTaskcd')
		},{
			path: '/jc/subjectInformation',
			name:'subjectInformation',
			component: () => import('../components/jc/subjectInformation')
		},{
			path: '/jc/setReturnTask',
			name:'setReturnTask',
			component: () => import('../components/jc/setReturnTask')
		},{
			path: '/jc/setReturnTasks',
			name:'setReturnTasks',
			component: () => import('../components/jc/setReturnTasks')
		},{
			path: '/jc/workbench',
			name:'workbench',
			component: () => import('../components/jc/workbench')
		},{
			path: '/jc/systemIntroduce',
			name:'systemIntroduce',
			component: () => import('../components/jc/systemIntroduce')
		},{
			path: '/jc/tasksChart',
			name:'tasksChart',
			component: () => import('../components/jc/tasksChart')
		},{
			path: '/jc/mutiChart',
			name:'mutiChart',
			component: () => import('../components/jc/mutiChart')
		},{
			path: '/jc/dataStatistics',
			name:'dataStatistics',
			component: () => import('../components/jc/dataStatistics')
		}
		]
	},{
		path: '/pdf',
		component: () => import('../components/pdf'),
	}
]

const router = new VueRouter({
	routes
})

// 挂载路由导航守卫
router.beforeEach((to, from, next) => {
	// to:将要访问的路径  from:从哪里过来的   next:放行函数-> next()   next('跳转路径')
	/** 登录,初始化页面不需要拒绝 */
	if (to.path == '/login') {
		return next()
	}

	/** 其他页面需要登录 */
	// const token = window.sessionStorage.getItem('token')
	// console.log(token)
	// if (token == undefined || token == '') {
	//   Message({
	//     message: '用户未登录，请重新登录',
	//     type: 'warning',
	//     showClose: true,
	//     center: true
	//   })
	//   return next('/login')
	// }
	next()
})

export default router
