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

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'
import { systemRouters } from './modules/system'
import { cooRouters } from './modules/coo'
import { bmsRouters } from './modules/bms'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/
/**
 * 静态路由
 */
export const constantRouterMap = [
  {// 重定向
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  // 登录页面
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  // 404错误页面
  { path: '/404', component: () => import('@/views/errorPage/404'), hidden: true },
  // 401 错误页面
  { path: '/401', component: () => import('@/views/errorPage/401'), hidden: true },
  // 主页
  {
    path: '/',
    component: Layout,
    redirect: '/work',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  }
]
// 实例化vue的时候直挂载constantRouter
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

// 异步挂载路由
// 动态需要根据权限加载的路由表
export const asyncRouterMap = [
  // {
  //   path: 'coorBusiness',
  //   component: Layout,
  //   name: 'CoorBusniess',
  //   alwaysShow: true,
  //   meta: {
  //     title: '协调业务管理',
  //     permission: ['/coorBusiness']
  //   },
  //   children: [
  //     {
  //       path: '/work',
  //       component: () => import('@/views/coorBusiness/work/index'),
  //       name: 'Work',
  //       meta: { title: '待办任务', icon: '', permission: '/work' }
  //     },
  //     {
  //       path: '/toRegister',
  //       component: () => import('@/views/coorBusiness/toRegister/index'),
  //       name: 'ToRegister',
  //       meta: { title: '待立案', icon: '', permission: '/toRegister' }
  //     },
  //     {
  //       path: '/preRegister',
  //       component: () => import('@/views/coorBusiness/preRegister/index'),
  //       name: 'PreRegister',
  //       meta: { title: '预立案', icon: '', permission: '/preRegister' }
  //     },
  //     {
  //       path: '/toDistribute',
  //       component: () => import('@/views/coorBusiness/toDistribute/index'),
  //       name: 'ToDistribute',
  //       meta: { title: '待派发', icon: '', permission: '/toDistribute' }
  //     },
  //     {
  //       path: '/preDistribute',
  //       component: () => import('@/views/coorBusiness/preDistribute/index'),
  //       name: 'PreDistribute',
  //       meta: { title: '预派发', icon: '', permission: '/preDistribute' }
  //     },
  //     {
  //       path: '/toAdjustInstruction',
  //       component: () => import('@/views/coorBusiness/toAdjustInstruction/index'),
  //       name: 'ToAdjustInstruction',
  //       meta: { title: '调整批示', icon: '', permission: '/toInstruction' }
  //     },
  //     {
  //       path: '/toHandle',
  //       component: () => import('@/views/coorBusiness/toHandle/index'),
  //       name: 'ToHandle',
  //       meta: { title: '待处理', icon: '', permission: '/toHandle' }
  //     },
  //     {
  //       path: '/toAdjust',
  //       component: () => import('@/views/coorBusiness/toAdjust/index'),
  //       name: 'ToAdjust',
  //       meta: { title: '待调整', icon: '', permission: '/toAdjust' }
  //     },
  //     {
  //       path: '/toFinish',
  //       component: () => import('@/views/coorBusiness/toFinish/index'),
  //       name: 'ToFinish',
  //       meta: { title: '待结案', icon: '', permission: '/toFinish' }
  //     },
  //     {
  //       path: '/handleAudit',
  //       component: () => import('@/views/coorBusiness/handleAudit/index'),
  //       name: 'HandleAudit',
  //       meta: { title: '处理审核', icon: '', permission: '/handleAudit' }
  //     },
  //     {
  //       path: '/toDeptAdjustInstruction',
  //       component: () => import('@/views/coorBusiness/toDeptAdjustInstruction/index'),
  //       name: 'ToDeptAdjustInstruction',
  //       meta: { title: '部门调整批示', icon: '', permission: '/toDeptAdjustInstruction' }
  //     },
  //     {
  //       path: '/delayed',
  //       component: () => import('@/views/coorBusiness/delayed/index'),
  //       name: 'Delayed',
  //       meta: { title: '延期待处理', icon: '', permission: '/delayed' }
  //     },
  //     {
  //       path: '/postponed',
  //       component: () => import('@/views/coorBusiness/postponed/index'),
  //       name: 'Postponed',
  //       meta: { title: '缓办待处理', icon: '', permission: '/postponed' }
  //     },
  //     {
  //       path: '/toCheck',
  //       component: () => import('@/views/coorBusiness/toCheck/index'),
  //       name: 'ToCheck',
  //       meta: { title: '待核查', icon: '', permission: '/toCheck' }
  //     },
  //     {
  //       path: '/authorizationAudit',
  //       component: () => import('@/views/coorBusiness/authorizationAudit/index'),
  //       name: 'AuthorizationAudit',
  //       meta: { title: '授权审核', icon: '', permission: '/authorizationAudit' }
  //     },
  //     {
  //       path: '/secIsPostpone',
  //       component: () => import('@/views/coorBusiness/secIsPostpone/index'),
  //       name: 'SecIsPostpone',
  //       meta: { title: '二级缓办待处理', icon: '', permission: '/secIsPostpone' }
  //     },
  //     {
  //       path: '/deptAuthAudit',
  //       component: () => import('@/views/coorBusiness/deptAuthAudit/index'),
  //       name: 'DeptAuthAudit',
  //       meta: { title: '部门授权审核', icon: '', permission: '/toDeptAuthAudit' }
  //     },
  //     {
  //       path: '/secIsDelay',
  //       component: () => import('@/views/coorBusiness/secIsDelay/index'),
  //       name: 'SecIsDelay',
  //       meta: { title: '二级延期待处理', icon: '', permission: '/secIsDelay' }
  //     },
  //     {
  //       path: '/completed',
  //       component: () => import('@/views/coorBusiness/completed/index'),
  //       name: 'Completed',
  //       meta: { title: '已办案卷', icon: '', permission: '/completed' }
  //     }
  //   ]
  // },
  // {
  //   path: 'system',
  //   component: Layout,
  //   redirect: '/resource',
  //   name: 'System',
  //   alwaysShow: true,
  //   meta: {
  //     title: '系统管理',
  //     icon: 'icon-config', // 图标
  //     permission: ['/system']// 权限名称
  //   },
  //   children: [
  //     {
  //       path: '/resource',
  //       name: 'Resource',
  //       component: () => import('@/views/system/resource/listResource'),
  //       meta: { title: '资源管理', icon: 'function', permission: ['/resource'] }
  //     },
  //     {
  //       path: '/dept',
  //       name: 'Dept',
  //       component: () => import('@/views/system/dept/listDept'),
  //       meta: { title: '组织管理', icon: 'tree', permission: ['/dept'] }
  //     },
  //     {
  //       path: '/role',
  //       component: () => import('@/views/system/role/listRole'), // Parent router-view
  //       name: 'Role',
  //       meta: { title: '角色管理', permission: ['/role'] }
  //     },
  //     {
  //       path: '/user',
  //       component: () => import('@/views/system/user/listUser'), // Parent router-view
  //       name: 'User',
  //       meta: { title: '用户管理', permission: ['/mgr'] }
  //     },
  //     {
  //       path: '/log',
  //       component: () => import('@/views/system/log/listLog'), // Parent router-view
  //       name: 'Log',
  //       meta: { title: '日志管理', permission: ['/log'] }
  //     },
  //     {
  //       path: '/loginLog',
  //       component: () => import('@/views/system/log/loginLog'), // Parent router-view
  //       name: 'LoginLog',
  //       meta: { title: '登录日志', permission: ['/loginLog'] }
  //     }
  //   ]
  // },
  ...cooRouters,
  ...bmsRouters,
  systemRouters,
  { path: '*', redirect: '/404', hidden: true }
]
