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

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '*',
    component: (resolve) => require(['@/views/error/404.vue'], resolve)
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '/BCCdashboard',
    component: (resolve) => require(['@/views/monitor/elec/index'], resolve),
    hidden: true
  },
  {
    path: '/pptyulan',
    name:'pptyulan',
    component: (resolve) => require(['@/views/yulan/index'], resolve),
    hidden: true
  },
  {
    path: '/elecDashboard',
    component: (resolve) => require(['@/views/monitor/elec/elecindex'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: '首页',
        meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'profile',
        component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
        name: 'Profile',
        meta: { title: '个人中心', icon: 'user' }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'message',
        component: (resolve) => require(['@/views/system/message/index'], resolve),
        name: 'Profile',
        meta: { title: '系统消息', icon: '' }
      }
    ]
  },
  {
    path: '/dict',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'type/data/:dictId(\\d+)',
        component: (resolve) => require(['@/views/system/dict/data'], resolve),
        name: 'Data',
        meta: { title: '字典数据', icon: '' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    alwaysShow: true,
    children: [
      {
        path: 'rcaudit',
        component: (resolve) => require(['@/views/ehs/rcaudit/index'], resolve),
        name: 'Rcaudit',
        meta: { title: 'RC审计助手',
          keepAlive: true,
          scrollTop: 0,
        }
      }
    ]
  },
  {
    path: '/job',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'log',
        component: (resolve) => require(['@/views/monitor/job/log'], resolve),
        name: 'JobLog',
        meta: { title: '调度日志' }
      }
    ]
  },
  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
        name: 'GenEdit',
        meta: { title: '修改生成配置' }
      }
    ]
  },
  {
    path: '/training/spec',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'successorPlan/:staffId(\\d+)',
        component: (resolve) => require(['@/views/training/spec/successor/successorPlan'], resolve),
        name: 'SuccessorPlan',
        meta: { title: '培训计划清单' }
      },
      {
        path: 'monthdata/:staffId(\\d+)',
        component: (resolve) => require(['@/views/training/spec/successor/monthdata'], resolve),
        name: 'monthdata',
        meta: { title: '月度数据' }
      },
      {
        path: 'seasondata/:staffId(\\d+)',
        component: (resolve) => require(['@/views/training/spec/successor/seasondata'], resolve),
        name: 'seasondata',
        meta: { title: '季度数据' }
      }
    ]
  },
  {
    path: '/training/spec',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'planItem/:yearId(\\d+)',
        component: (resolve) => require(['@/views/training/spec/plan/index'], resolve),
        name: 'PlanItem',
        meta: { title: '培训计划明细' }
      }
    ]
  },
  {
    path: '/production',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'accident',
        component: (resolve) => require(['@/views/production/accident/index'], resolve),
        name: 'Accident',
        meta: { title: '隐患排查' }
      }
    ]
  },
  {
    path: '/document',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'publicdocmenu',
        component: (resolve) => require(['@/views/document/publicdocmenu/index'], resolve),
        name: 'PublicDocMenu',
        meta: { title: '公共文档目录管理' }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'alarmprincipal/:tableId(\\d+)',
        component: (resolve) => require(['@/views/system/principal/index'], resolve),
        name: 'AlarmPrincipal',
        meta: { title: '预警管理负责人配置' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'rcauditmenu',
        component: (resolve) => require(['@/views/ehs/rcauditmenu/index'], resolve),
        name: 'RcauditMenu',
        meta: { title: 'RC审计助手目录管理' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'environapproval',
        component: (resolve) => require(['@/views/ehs/environapproval/index'], resolve),
        name: 'Environapproval',
        meta: { title: '环保批文清单' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'fireapproval',
        component: (resolve) => require(['@/views/ehs/fireapproval/index'], resolve),
        name: 'Fireapproval',
        meta: { title: '消防批文清单' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'safetyapproval',
        component: (resolve) => require(['@/views/ehs/safetyapproval/index'], resolve),
        name: 'Safetyapproval',
        meta: { title: '安全批文清单' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'msds',
        component: (resolve) => require(['@/views/ehs/msds/index'], resolve),
        name: 'Msds',
        meta: { title: 'MSDS管理' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'fireextinguisher',
        component: (resolve) => require(['@/views/ehs/fireextinguisher/index'], resolve),
        name: 'Fireextinguisher',
        meta: { title: '灭火器' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'eyewasher',
        component: (resolve) => require(['@/views/ehs/eyewasher/index'], resolve),
        name: 'Eyewasher',
        meta: { title: '洗眼器' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'firehose',
        component: (resolve) => require(['@/views/ehs/firehose/index'], resolve),
        name: 'Firehose',
        meta: { title: '消防水带箱' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'firehydrant',
        component: (resolve) => require(['@/views/ehs/firehydrant/index'], resolve),
        name: 'Firehydrant',
        meta: { title: '消防栓' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'highpresfire',
        component: (resolve) => require(['@/views/ehs/highpresfire/index'], resolve),
        name: 'Highpresfire',
        meta: { title: '高压消防炮' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'autosprinkler',
        component: (resolve) => require(['@/views/ehs/autosprinkler/index'], resolve),
        name: 'Autosprinkler',
        meta: { title: '自动喷淋系统' }
      }
    ]
  },
  {
    path: '/ehs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'firestandpipe',
        component: (resolve) => require(['@/views/ehs/firestandpipe/index'], resolve),
        name: 'Firestandpipe',
        meta: { title: '消防竖管' }
      }
    ]
  },
  {
    path: '/document',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'plantproglist',
        component: (resolve) => require(['@/views/document/plantproglist/index'], resolve),
        name: 'Plantproglist',
        meta: { title: '装置程序清单' }
      }
    ]
  },
  {
    path: '/affair',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'ppe',
        component: (resolve) => require(['@/views/affair/ppe/index'], resolve),
        name: 'Ppe',
        meta: { title: 'PPE发放登记' }
      }
    ]
  },
  {
    path: '/training',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'workcertificate',
        component: (resolve) => require(['@/views/training/workcertificate/index'], resolve),
        name: 'Workcertificate',
        meta: { title: '作业证书一览表' }
      }
    ]
  },
  {
    path: '/training',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'worklicense',
        component: (resolve) => require(['@/views/training/worklicense/index'], resolve),
        name: 'Worklicense',
        meta: { title: '上岗证一览表' }
      }
    ]
  },
  {
    path: '/reliability',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'safetyvavle',
        component: (resolve) => require(['@/views/reliability/safetyvavle/index'], resolve),
        name: 'Safetyvavle',
        meta: { title: '安全阀清单' }
      }
    ]
  },
  {
    path: '/reliability',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'pipe',
        component: (resolve) => require(['@/views/cui/pipe/index'], resolve),
        name: 'Pipe',
        meta: { title: '管线清单' }
      }
    ]
  },
  {
    path: '/list',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'list',
        component: (resolve) => require(['@/views/reliability/list/index'], resolve),
        name: 'List',
        meta: { title: '故障管理跟踪' }
      }
    ]
  },
  {
    path: '/safetyapproval',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: (resolve) => require(['@/views/ehs/safetyapprcont/index'], resolve),
        name: 'Safetyapprcont',
        meta: { title: '主要内容' }
      }
    ]
  },
  {
    path: '/environapproval',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: (resolve) => require(['@/views/ehs/environapprcont/index'], resolve),
        name: 'Environapprcont',
        meta: { title: '主要内容' }
      }
    ]
  },
  {
    path: '/hismeeting',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: (resolve) => require(['@/views/plant/weekmeeting/index'], resolve),
        name: 'hismeeting',
        meta: { title: '主要内容' }
      }
    ]
  },

  {
    path: '/notice',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'details',
        component: (resolve) => require(['@/views/system/notice/index.vue'], resolve),
        name: 'details',
        meta: { title: '通知公告' }
      }
    ]
  },
]

export default new Router({
  base: '/cpms/',
  mode: 'hash', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
