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: '初始页',
		component: () => import('@/index'),
		redirect: "home",
		children: [
			{
				path: '/home',
				name: '首页',
				component: () => import('@/home'),
				meta: {
					icon: 'icon-shezhi_zuzhijiagou',
					groupCode:'home'
				}
			},
			{
				path: '/award_punish',
				name: '我奖扣的',
				component: () => import('@/views/abPoint/award_punish.vue'),
				meta: {
					icon: 'icon-shezhi_zuzhijiagou',
					groupCode:'abPoint'
				}
			},
			{
				path: '/apply_list',
				name: '我申请的',
				component: () => import('@/views/abPoint/apply_list.vue'),
				meta: {
					icon: 'icon-shezhi_zuzhijiagou',
					groupCode:'abPoint'
				}
			},			
			{
				path: '/framework',
				name: '组织架构',
				component: () => import('@/views/set/framework.vue'),
				meta: {
					icon: 'icon-shezhi_zuzhijiagou',
					groupCode:'set'
				}
			},
			{
				path: '/jurisdiction',
				name: '角色权限',
				component: () => import('@/views/set/jurisdiction.vue'),
				meta: {
					icon: 'icon-shezhi_jiaose',
					groupCode:'set'
				}
			},
			{
				path: '/rule',
				name: '积分规则',
				component: () => import('@/views/set/rule.vue'),
				meta: {
					icon: 'icon-shezhi_jifenguize',
					groupCode:'set',
					groupName:"设置"
				}
			},
			{
				path: '/initialPoint',
				name: '初始分',
				component: () => import('@/views/set/initialPoint.vue'),
				meta: {
					icon: 'icon-shezhi_jichushezhi',
					groupCode:'set',
				}
			},
			{
				path: '/check',
				name: '考勤积分',
				component: () => import('@/views/set/check.vue'),
				meta: {
					icon: 'icon-kaoqin_kaoqinyuebaobiao',
					groupCode:'set'
				}
			},
			{
				path: '/voluntarilyPoint',
				name: '自动积分',
				component: () => import('@/views/set/voluntarilyPoint.vue'),
				meta: {
					icon: 'icon-shezhi_zidongjifen',
					groupCode:'set'
				}
			},
			{
				path: '/integral_event',
				name: '积分事件',
				component: () => import('@/views/ranking/integral_event.vue'),
				meta: {
					icon: 'icon-shezhi_jifenguize',
					groupCode:'ranking',
					groupName:"统计"
				}
			},
			{
				path: '/dept_rank',
				name: '部门排名',
				component: () => import('@/views/ranking/dept_rank.vue'),
				meta: {
					icon: 'icon-shezhi_zuzhijiagou',
					groupCode:'ranking'
				}
			},
			{
				path: '/total_rank',
				name: '累计B分排名',
				component: () => import('@/views/ranking/total_rank.vue'),
				meta: {
					icon: 'icon-shezhi_jiaose',
					groupCode:'ranking'
				}
			},
			{
				path: '/custom_rank',
				name: '自定义分组B分排名',
				component: () => import('@/views/ranking/custom_rank.vue'),
				meta: {
					icon: 'icon-shezhi_jichushezhi',
					groupCode:'ranking'
				}
			},
			{
				path: '/manager_statistics',
				name: '管理者奖扣',
				component: () => import('@/views/ranking/manager_statistics.vue'),
				meta: {
					icon: 'icon-shezhi_jichushezhi',
					groupCode:'ranking'
				}
			},
			
			{
				path: '/department_statistics',
				name: '部门统计',
				component: () => import('@/views/ranking/department_statistics.vue'),
				meta: {
					icon: 'icon-shezhi_jichushezhi',
					groupCode:'ranking'
				}
			},
			{
				path: '/individual_statistics',
				name: '个人统计',
				component: () => import('@/views/ranking/individual_statistics.vue'),
				meta: {
					icon: 'icon-shezhi_jichushezhi',
					groupCode:'ranking'
				}
			}
		]
	},
	{
		path: '/',
		name: '初始化',
		component: () => import('@/init'),
	},
	{
		path: '/noAccess',
		name: '无权限',
		component: () => import('@/noAccess'),
	},
	{
		path: '/deptRankSwiper',
		name: '轮播',
		component: () => import('@/views/ranking/deptRankSwiper.vue'),
	},
]

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

export default router
