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

//解决重复点击导航栏报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [{
		path: '/index',
		name: 'index',
		component: () => import( /* webpackChunkName: "index" */ '@/index'),
		redirect: "home",
		children: [{
				path: '/home',
				name: 'home',
				icon: 'icon-gongzuotai1',
				component: () => import('@/views/job/home'),
				meta: {
					role: ['creator', 'masterAdministrator', 'childAdministrator', 'deptManager', 'employee'],
					jurisdiction: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,17,18]
				},
				label: '工作台'
			},
			{
				path: '/assessManagement',
				name: 'assessManagement',
				icon: 'icon-kaoqin_kaoqinyuebaobiao',
				component: () => import('@/views/assessManagement/assessManagement'),
				meta: {
					role: ['masterAdministrator', 'childAdministrator', 'deptManager'],
					jurisdiction: [7, 8, 9, 10, 11,,17,18]
				},
				label: '考核管理'
			},
			{
				path: '/myPerformance',
				name: 'myPerformance',
				icon: 'icon-biaoqian_wode',
				component: () => import('@/views/myPerformance/myPerformance'),
				meta: {
					role: ['creator', 'masterAdministrator', 'childAdministrator', 'deptManager', 'employee'],
					jurisdiction: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,17,18]
				},
				label: '我的绩效'
			},
			{
				path: '/statement',
				name: 'statement',
				icon: 'icon-baobiao1',
				component: () => import('@/views/statement/statement'),
				meta: {
					role: ['masterAdministrator', 'childAdministrator', 'deptManager'],
					jurisdiction: [16]
				},
				label: '绩效报表'
			},
			{
				path: '/set',
				name: 'set',
				icon: 'icon-shezhi',
				component: () => import('@/views/set/set'),
				meta: {
					role: ['creator', 'masterAdministrator', 'childAdministrator'],
					jurisdiction: [12, 13, 14, 15]
				},
				label: '考核设置'
			},
			{
				path: '/userSet',
				name: 'userSet',
				icon: 'icon-shezhirenyuan',
				component: () => import('@/views/userSet/userSet'),
				meta: {
					role: ['creator', 'masterAdministrator', 'childAdministrator'],
					jurisdiction: [12, 13, 14, 15]
				},
				label: '人员权限'
			},
			{
				path: '/CNC_center',
				name: 'CNC_center',
				icon: 'icon-tongji',
				component: () => import( /* webpackChunkName: "CNC_center" */ '@/views/CNC/CNC_center'),
				meta: {
					role: ['creator', 'masterAdministrator', 'childAdministrator', 'deptManager', 'employee'],
					jurisdiction: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,17,18]
				},
				label: '数据中台'
			},
			// 以下是不需要展示在导航栏的页面，不设置meta字段
			{
				path: '/sponsorAssess',
				name: 'sponsorAssess',
				component: () => import('@/views/assessManagement/sponsor/sponsorAssess'),
				label: '发起考核'
			},
			{
				path: '/assessDetails',
				name: 'assessDetails',
				component: () => import('@/views/assessManagement/assessDetails'),
				label: '绩效列表详情'
			},
			{
				path: '/staffAssDet',
				name: 'staffAssDet',
				component: () => import('@/views/assessManagement/staffAssDet'),
				label: '员工绩效详情'
			},
			{
				path: '/addIndexSet',
				name: 'addIndexSet',
				component: () => import('@/views/set/addIndexSet'),
				label: '添加指标'
			},
			{
				path: '/backlog',
				name: 'backlog',
				component: () => import('@/views/myPerformance/backlog'),
				label: '待办事项'
			},
			{
				path: '/unread',
				name: 'unread',
				component: () => import('@/views/myPerformance/unread'),
				label: '未读消息'
			},
			{
				path: '/adjustment',
				name: 'adjustment',
				component: () => import('@/views/myPerformance/adjustment'),
				label: '调整目标'
			},
			{
				path: '/adjustment2',
				name: 'adjustment2',
				component: () => import('@/views/myPerformance/adjustment2'),
				label: '调整目标2'
			},
			{
				path: '/resultSet',
				name: 'resultSet',
				component: () => import('@/views/myPerformance/resultSet'),
				label: '结果值录入'
			},
			{
				path: '/formulate',
				name: 'formulate',
				component: () => import('@/views/myPerformance/formulate'),
				label: '目标制定'
			},
			{
				path: '/addPersonnel',
				name: 'addPersonnel',
				component: () => import('@/views/assessManagement/addPersonnel'),
				label: '添加人员'
			},
			{
				path: '/evaluate',
				name: 'evaluate',
				component: () => import('@/views/evaluate/evaluate'),
				label: '考核表编辑添加'
			},
			{
				path: '/preview',
				name: 'preview',
				component: () => import('@/views/preview/preview'),
				label: '预览'
			},
			{
				path: '/previewTow',
				name: 'previewTow',
				component: () => import('@/views/preview/previewTow'),
				label: '预览考核表'
			},
			{
				path: '/classDtail',
				name: 'classDtail',
				component: () => import('@/views/assessManagement/classDtail'),
				label: '等级分布'
			},
			{
				path: '/participation',
				name: 'participation',
				component: () => import('@/views/assessManagement/participation'),
				label: '参与人员'
			},
			{
				path: '/updateTarget',
				name: 'updateTarget',
				component: () => import('@/views/assessManagement/updateTarget'),
				label: '批量修改目标值'
			},
			{
				path: '/score',
				name: 'score',
				component: () => import('@/views/job/score'),
				label: '我评分的'
			},
			{
				path: '/management',
				name: 'management',
				component: () => import('@/views/job/management'),
				label: '我管理记录的'
			},
		]
	},
	{
		path: '/',
		name: '初始化',
		component: () => import( /* webpackChunkName: "init" */ '@/init'),
	},
	{
		path: '/noAccess',
		name: '无权限',
		component: () => import( /* webpackChunkName: "noAccess" */ '@/noAccess'),
	},
	{
		path: '/hint',
		name: '提示页',
		component: () => import( /* webpackChunkName: "hint" */ '@/hint'),
	},
]

const router = new VueRouter({
	// mode: 'history',
	base: process.env.BASE_URL,
	routes
})

export default router
