import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'
export const constantRouterMap = [
  {
    path: '/l',
    name: 'l',
    component: () => import('@/views/l'),
    hidden: true
  },
  {
    path: '/invite_new_company',
    name: 'invite_new_company',
    component: () => import('@/views/login/invite_new_company'),
    hidden: false
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index3'),
    hidden: true,
    meta: { pushindex : true},
  },
  {
    path: '/loginTransfer',
    name: 'loginTransfer',
    component: () => import('@/views/login/loginTransfer'),
    hidden: true,
  },
  // {
  //   path: '/login',
  //   name: 'login',
  //   component: () => import('@/views/login/index'),
  //   hidden: true
  // },
  {
    path: '/autoLogin',
    name: 'autoLogin',
    component: () => import('@/views/login/autoLogin'),
    hidden: true
  },
  {
    path: '/reg',
    name: 'reg',
    component: () => import('@/views/login/reg'),
    hidden: true
  },
  {
    path: '/create_company',
    name: 'create_company',
    component: () => import('@/views/login/create_company'),
    hidden: true
  },
  {
    path: '/forgetPwd',
    name: 'forgetPwd',
    component: () => import('@/views/login/forgetPwd'),
    hidden: true
  },
  {
    path: '/deptRankSwiper',
    name: 'deptRankSwiper',
    component: () => import('@/views/login/deptRankSwiper'),
    hidden: true
  },
  {
    path: '/resetPwd',
    name: 'resetPwd',
    component: () => import('@/views/login/resetPwd'),
    hidden: true
  },
  {
    path: '/android',
    name: 'android',
    component: () => import('@/views/login/android_and_ios'),
    hidden: true
  },
  {
    path: '/authredirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/loginbytoken/:token',
    component: () => import('@/views/login/loginbytoken'),
    hidden: true
  },
	{
		path: '/noAccess',
		name: '无权限',
		component: () => import(/* webpackChunkName: "noAccess" */'@/views/noAccess'),
    hidden: true
	},
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
// 这些是要进行过滤的路由，在permission.js里面过滤
export const asyncRouterMap = [

  {
    path: '/',
    component: Layout,
    redirect: '/index',
    hidden: true, // 不在侧边栏线上
    meta: { title: '首页', icon: 'department', noCache: true},
    children: [
      {
        path: '/index',
        name: 'index',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'workCenter', noCache: true }
      }
    ]
  },

  {
    path: '/award_punish',
    component: Layout,
    redirect: '/award_punish',
    meta: { title: '工作台', icon: 'department', show: false, noCache: true},
    children: [
      {
        path: '/workbench',
        name: 'workbench',
        component: () => import('@/views/workbench/workbench'),
        meta: { title: 'A/B分', icon: 'abf', show: true, noCache: true },
        alwaysShow: true, // 一直显示根路由
        children: [
          {
            path: '/award_punish',
            name: 'award_punish',
            component: () => import('@/views/workbench/grade/award_punish'),
            meta: { title: '我奖扣的', noCache: true , jurisdiction:['employee']}
          },
          {
            path: '/apply_list',
            name: 'apply_list',
            component: () => import('@/views/workbench/grade/apply_list'),
            meta: { title: '我的申请', noCache: true  , jurisdiction:['creator']}
          },
        ]
      },
      {
        path: '/performance',
        name: 'performance',
        component: () => import('@/views/workbench/workbench'),
        meta: { title: '绩效分', icon: 'jxf', show: true, noCache: true , jurisdiction:['creator','point_manager','admin','dept_manager','employee'] },
        alwaysShow: true, // 一直显示根路由
        children: [
          {
            path: '/team_performance',
            name: 'team_performance',
            component: () => import('@/views/workbench/performance/team_performance'),
            meta: { title: '团队绩效', noCache: true , jurisdiction:['employee']}
          },
          {
            path: '/my_performance',
            name: 'my_performance',
            component: () => import('@/views/workbench/performance/my_performance'),
            meta: { title: '我的绩效', noCache: true  , jurisdiction:['creator']}
          },
          {
            path: '/performance_review',
            name: 'performance_review',
            component: () => import('@/views/workbench/performance/performance_review'),
            meta: { title: '绩效评审', noCache: true , jurisdiction:['employee']}
          },
          {
            path: '/examine_unit',
            name: 'examine_unit',
            component: () => import('@/views/workbench/performance/examine_unit'),
            hidden: true, // 不在侧边栏线上
            meta: { title: '绩效评审详情', noCache: true }
          },
          {
            path: '/participation_detail',
            name: 'participation_detail',
            component: () => import('@/views/workbench/performance/participation_detail'),
            hidden: true, // 不在侧边栏线上
            meta: { title: '绩效评审(我参与)详情', noCache: true }
          },
          {
            path: '/team_detail',
            name: 'team_detail',
            component: () => import('@/views/workbench/performance/team_detail'),
            hidden: true, // 不在侧边栏线上
            meta: { title: '团队绩效详情', noCache: true }
          },
          {
            path: '/add_team_performance',
            name: 'add_team_performance',
            component: () => import('@/views/workbench/performance/add_team_performance'),
            hidden: true, // 不在侧边栏线上
            meta: { title: '创建团队月绩效', noCache: true }
          }
        ]
      },
      {
        path: '/task',
        name: 'task',
        component: () => import('@/views/workbench/workbench'),
        meta: { title: '任务', icon: 'rw', show: true, noCache: true },
        alwaysShow: true, // 一直显示根路由
        children: [
          {
            path: '/my_issue',
            name: 'my_issue',
            component: () => import('@/views/workbench/task/my_issue'),
            meta: { title: '我发布的', noCache: true , jurisdiction:['employee']}
          },
          {
            path: '/get_task',
            name: 'get_task',
            component: () => import('@/views/workbench/task/get_task'),
            meta: { title: '领任务', noCache: true }
          },
          {
            path: '/my_task',
            name: 'my_task',
            component: () => import('@/views/workbench/task/my_task'),
            meta: { title: '我的任务', noCache: true  , jurisdiction:['creator']}
          }
        ]
      },
      {
        path: '/approval_list',
        name: 'approval_list',
        component: () => import('@/views/workbench/approval_list'),
        meta: { title: '审批', icon: 'set_basics_icon', noCache: true , jurisdiction:['employee']}
      },
    ]
  },

  {
    path: '/attendancenew',
    component: Layout,
    redirect: '/attendance_classnew',
    meta: { title: '考勤', icon: 'attendance_classnew_icon', show: false, noCache: true  , jurisdiction:['creator','point_manager','admin','dept_manager','employee'] },
    children: [
      {
        path: '/attendance_classnew',
        name: 'att_schedule',
        component: () => import('@/views/attendance/attendance_classnew'),
        meta: { title: '班次管理', icon: 'attendance_classnew_icon', noCache: true },
        hidden: false
      },
      {
        path: '/attendance_overtime_rulenew',
        name: 'att_ot_rule',
        component: () => import('@/views/attendance/attendance_overtime_rulenew'),
        meta: { title: '加班规则', icon: 'attendance_overtime_rulenew_icon', noCache: true }
      },
      {
        path: '/attendance_groupnew',
        name: 'att_group',
        component: () => import('@/views/attendance/attendance_groupnew'),
        meta: { title: '考勤组', icon: 'attendance_groupnew_icon', noCache: true }
      },
      {
        path: '/attendance_machinenew',
        name: 'att_machine',
        component: () => import('@/views/attendance/attendance_machinenew'),
        meta: { title: '考勤机', icon: 'attendance_machinenew_icon', noCache: true }
      },
      // {
      //   path: '/attendance_data',
      //   name: 'attendance_data',
      //   component: () => import('@/views/integral/AttendanceManage'),
      //   meta: { title: '考勤统计', icon: 'data', noCache: true }
      // },
      {
        path: '/attendance_datanew',
        name: 'att_sign_daily',
        component: () => import('@/views/attendance/attendance_datanew'),
        meta: { title: '日打卡明细', icon: 'attendance_datanew_icon', noCache: true }
      },
      {
        path: '/attendance_statisticnew',
        name: 'att_report_monthly',
        component: () => import('@/views/attendance/attendance_statisticnew'),
        meta: { title: '考勤月报表', icon: 'attendance_statisticnew_icon', noCache: true }
      },
      {
        path: '/attendance_reviewnew',
        name: 'att_review',
        component: () => import('@/views/attendance/attendance_reviewnew'),
        meta: { title: '考勤审批', icon: 'attendance_reviewnew_icon', noCache: true }
      },
      // {
      //   path: '/attendance_setting',
      //   name: 'attendance_setting',
      //   component: () => import('@/views/attendance/attendance_setting'),
      //   meta: { title: '考勤设置', icon: 'sys', noCache: true }
      // }
      // {
      //   path: '/attendance_settingnew',
      //   name: 'attendance_settingnew',
      //   component: () => import('@/views/attendance/attendance_settingnew'),
      //   meta: { title: '考勤设置', icon: 'sys', noCache: true }
      // },
      {
        path: '/attendance_hioldaynew',
        name: 'att_holiday',
        component: () => import('@/views/attendance/attendance_hiolday'),
        meta: { title: '假期管理', icon: 'attendance_hioldaynew_icon', noCache: true }
      },
      {
        path: '/attendance_rating',
        name: 'attendance_rating',
        component: () => import('@/views/attendance/attendance_rating'),
        meta: { title: '考勤分排名', icon: 'attendance_rating_icon', noCache: true }
      },
      {
        path: '/attendance_integral_event',
        name: 'attendance_integral_event',
        component: () => import('@/views/attendance/attendance_integral_event'),
        meta: { title: '考勤积分事件', icon: 'integral_event_icon', noCache: true }
      }
    ]
  },

  {
    path: '/integral',
    component: Layout,
    redirect: '/dept_rank',
    // hidden: true, // 不在侧边栏线上
    meta: { title: '统计', icon: 'department', show: false, noCache: true },
    children: [
      {
        path: '/workbench',
        name: 'ranking',
        component: () => import('@/views/workbench/workbench'),
        meta: { title: '排名', icon: 'Statistical_rankings', show: true, noCache: true },
        alwaysShow: true, // 一直显示根路由
        children: [
          {
            path: '/dept_rank',
            name: 'dept_rank',
            component: () => import('@/views/statistics_new/dept_rank'),
            meta: { title: '阶段排名', noCache: true }
          },
          {
            path: '/total_rank',
            name: 'total_rank',
            component: () => import('@/views/statistics_new/total_rank'),
            meta: { title: '累计B分排名', noCache: true }
          },
          {
            path: '/custom_rank',
            name: 'custom_rank',
            component: () => import('@/views/statistics_new/custom_rank'),
            meta: { title: '自定义B分排名', noCache: true }
          }
        ]
      },
      {
        path: '/integral_statistics',
        name: 'integral_statistics',
        component: () => import('@/views/statistics_new/integral_statistics'),
        meta: { title: '积分统计', icon: 'integral_statistics_icon', noCache: true , jurisdiction:['employee'] ,}
        // hidden: true
      },
      {
        path: '/manager_statistics',
        name: 'manager_statistics',
        component: () => import('@/views/statistics_new/manager_statistics'),
        meta: { title: '管理者奖扣', icon: 'manager_statistics_icon', noCache: true , jurisdiction:['employee'] ,}
      },
      {
        path: '/integral_event',
        name: 'integral_event',
        component: () => import('@/views/statistics_new/integral_event'),
        meta: { title: '积分事件', icon: 'integral_event_icon', noCache: true }
      },
      {
        path: '/balanceA',
        name: 'balanceA',
        component: () => import('@/views/statistics_new/balanceA'),
        meta: { title: 'A分余额', icon: 'A_points', noCache: true  , jurisdiction:['dept_manager','employee'] ,}
      },
      {
        path: '/department_statistics',
        name: 'department_statistics',
        component: () => import('@/views/statistics_new/department_statistics'),
        meta: { title: '部门统计', icon: 'department_statistics', noCache: true , jurisdiction:['employee']}
      },
      {
        path: '/individual_statistics',
        name: 'individual_statistics',
        component: () => import('@/views/statistics_new/individual_statistics'),
        meta: { title: '个人统计', icon: 'individual_statistics', noCache: true }
      },
      {
        path: '/lotteryTicket_statistics',
        name: 'lotteryTicket_statistics',
        component: () => import('@/views/statistics_new/lotteryTicket_statistics'),
        meta: { title: '奖票统计', icon: 'Lottery_ticket_statistics', noCache: true , jurisdiction:['employee']}
      },
    ]
  },

  {
    path: '/employee',
    component: Layout,
    redirect: '/employee_table',
    // hidden: true, // 不在侧边栏线上
    meta: { title: '设置', icon: 'department', show: false, noCache: true  , jurisdiction:['dept_manager','employee'] },
    children: [
      {
        path: '/employee_table',
        name: 'employee_table',
        component: () => import('@/views/integral/EmployeeTable'),
        // component: () => import('@/views/integral/framework'),
        meta: { title: '组织架构', icon: 'employee_table_icon', noCache: true }
      },
      {
        path: '/new_employee',
        name: 'new_employee',
        component: () => import('@/views/setting/new_employee'),
        hidden: true,
        meta: { title: '新成员列表', icon: 'employee_table_icon', noCache: true },
      },
      {
        path: '/set_role',
        name: 'set_role',
        component: () => import('@/views/setting/set_role'),
        meta: { title: '角色权限', icon: 'set_role_icon', noCache: true }
      },
      {
        path: '/set_basics',
        name: 'set_basics',
        component: () => import('@/views/setting/set_basics'),
        meta: { title: '基础设置', icon: 'set_basics_icon', noCache: true }
      },
      {
        path: '/fixed_integral',
        name: 'fixed_integral',
        component: () => import('@/views/setting/fixed_integral'),
        meta: { title: '自动积分', icon: 'fixed_integral_icon', noCache: true }
      },
      {
        path: '/company_info',
        name: 'company_info',
        component: () => import('@/views/setting/company_info'),
        meta: { title: '企业信息', icon: 'company_info_icon', noCache: true }
      },
      {
        path: '/rule_manage',
        name: 'integral_rule',

        component: () => import('@/views/integral/rule/rule_category'),
        meta: { title: '积分规则', icon: 'rule_manage_icon', noCache: true }
      },
      // {
      //   path: '/approver_set',
      //   name: 'approver_set',
      //   component: () => import('@/views/setting/approver_set'),
      //   meta: { title: '审批人设置', icon: 'employee_table_icon', noCache: true }
      // },
    ]
  }

]

// Router.afterEach((to, from) => {
//   wxAuth(to);
// });