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

import routerBefore from '@/config/routerBefore.js'

// 主要
import main from '@/components/main.vue'
// 系统配置管理
const functionMain = () => import( '../components/functionMain.vue')
const organizManage = () => import( '../components/organizManage.vue')
const transportReserveFu = () => import( '../components/transportReserveFu.vue') 
const rolesManage = () => import( '../components/rolesManage.vue')
const authManage = () => import( '../components/authManage.vue')
const usersManage = () => import( '../components/usersManage.vue')
const userAuth = () => import( '../components/userAuth.vue')
const dataPermission = () => import( '../components/dataPermission.vue')
const dataPermissionAdd = () => import( '../components/dataPermissionAdd.vue')
const dataDictionary = () => import( '../components/dataDictionary.vue')
const backup = () => import( '../components/backup.vue')
// 租户管理
const tenantManage = () => import( '../components/tenantManage.vue')
// 公告管理
const noticeUser = () => import( '../components/noticeUser.vue')
// 用户审计
const userBehaviorManage = () => import( '../components/userBehaviorManage.vue')
// 密码策略
const pwdValidSetting = () => import( '../components/pwdValidSetting.vue')
// 职级管理
const dutyManage = () => import( '../components/dutyManage.vue')
Vue.use(Router)

const constantRouterMap = [
  {
    path: '/',
    name: 'main',
    meta: {title: '首页', code: 'xtpzgl'},
    component: main,
    redirect: {name: 'usersManage'},
    children: [
      {path: 'organizManage', name: 'organizManage', meta: {code: 'xtpzgl-jggl'}, component: organizManage},
      {path: 'usersManage', name: 'usersManage', meta: {code: 'xtpzgl-yhgl'}, component: usersManage},
      {path: 'transportReserveFu', name: 'transportReserveFu', meta: {code: 'xtpzgl-yhgl'}, component: transportReserveFu},
      {path: 'functionMain', name: 'functionMain', meta: {code: 'xtpzgl-cdgl'}, component: functionMain},
      {path: 'dataPermission', name: 'dataPermission', meta: {code: 'xtpzgl-sjqxpz'}, component: dataPermission},
      {path: 'dataPermission/dataPermissionAdd', name: 'dataPermissionAdd', meta: {code: 'xtpzgl-sjqxpz-add'}, component: dataPermissionAdd},
      {path: 'rolesManage', name: 'rolesManage', meta: {code: 'xtpzgl-jsgl'}, component: rolesManage},
      {path: 'authManage', name: 'authManage', meta: {code: 'xtpzgl-augl'}, component: authManage},
      {path: 'userAuth', name: 'userAuth', meta: {code: 'xtpzgl-yhsq'}, component: userAuth},
      // 备份数据
      {path: 'backup', name: 'backup', component: backup},
      {path: 'dataDictionary', name: 'dataDictionary', component: dataDictionary},
      {path: 'tenantManage', name: 'tenantManage', component: tenantManage},
      {path: 'noticeUser', name: 'noticeUser', component: noticeUser},
      {path: 'userBehaviorManage', name: 'userBehaviorManage', component: userBehaviorManage},
      {path: 'pwdValidSetting', name: 'pwdValidSetting', component: pwdValidSetting},
      {path: 'dutyManage', name: 'dutyManage', component: dutyManage}
    ]
  }
];

const router = new Router({
  routes: constantRouterMap
})
//  before
routerBefore(router, constantRouterMap);

export default router;
//  constantRouterMap
export const routes = constantRouterMap;
