import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '@/views/layout/Layout'

import data_dict from './modules/data_dict'
import device from './modules/device'
import dialysis from './modules/dialysis'
import patient from './modules/patient'
import qcd from './modules/qcd'
import role from './modules/role'
import stock from './modules/stock'
import weight_sign from './modules/weight_sign'
import workforce from './modules/workforce'
import service from './modules/service'
import org from './modules/org'
import systems from './modules/systems'
import data_upload from './modules/data_upload'
import integration from './modules/integration'
import medicalScheduling from './modules/medical_scheduling'
import slow from './modules/slow'
import scrm from './modules/scrm'
import shop from './modules/shop'
import selfPreparedMedicine from './modules/selfPreparedMedicine'
import drugs from './modules/drugs'
import outpatientRegistration from './modules/outpatientRegistration'
import outpatientDoctorStation from './modules/outpatientDoctorStation'
import outpatientCharges from './modules/outpatientCharges'
import outpatientPharmacy from './modules/outpatientPharmacy'
import kuyiShopping from './modules/kuyiShopping'
import createPatient from './modules/createPatient'
import dialysisRecord from './modules/dialysisRecord'
import otherManagement from './modules/otherManagement'
import roleManage from './modules/roleManage'
import dataDictionary from './modules/dataDictionary'
import specialDictionary from './modules/specialDictionary'
import dataTemplate from './modules/dataTemplate'
import dataPrescription from './modules/dataPrescription'
import dataDruguse from './modules/dataDruguse'
import dataShowconfig from './modules/dataShowconfig'
import dataPrint from './modules/dataPrint'
import bedManagement from './modules/bedManagement'
import dictionaryManagement from './modules/dictionaryManagement'
import templateManagement from './modules/templateManagement'

Vue.use(Router)

/** note: submenu only apppear when children.length>=1
 *   detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
 * 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

 // 详见 xt_permission.xt_filterAsyncRouter 函数的逻辑
 is_menu: false               加载路由时验证用的(即该路由是否要在侧边栏展示，需要展示的即需要)，为 false 时表示该路由不需要进行权限验证

 *                                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 redirct 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,
    noCache: true                if true ,the page will no be cached(default is false)

    // 详见 xt_permission.xt_filterAsyncRouter 函数的逻辑
    is_menu: false               加载路由时验证用的，为 false 时表示该路由不需要进行权限验证
    hidden: false                加载路由时验证用的，is_menu 为true时才有作用，为 true 时表示该路由需要进行权限验证
  }
 **/
var _constant_router_map = [{
  path: '/token/verify',
  component: () => import('@/xt_pages/index/verify_token'),
  hidden: true
},
{
  path: '/404',
  component: () => import('@/views/errorPage/404'),
  hidden: true
},
{
  path: '/401',
  component: () => import('@/views/errorPage/401'),
  hidden: true
},
{
  path: '',
  component: Layout,
  redirect: '/home',
  name:'home',
  children: [{
    path: '/home',
    component: () => import('@/xt_pages/home/index'),
    name: 'home',
    meta: {
      title: 'home',
      icon: 'dashboard',
      noCache: true
    }
  }]
},
{
  path: '/kuyiShopping',
  component: Layout,
  name:'kuyiShopping',
  redirct: '/kuyiShopping/index',
  children: [{
    path: '/kuyiShopping/index',
    component: () => import('@/xt_pages/kuyiShopping/index'),
    name: 'kuyiShopping',
    meta: {
      title: 'kuyiShopping',
      icon: 'kuyiShopping',
      noCache: true
    }
  }]
},
service
  // patient,
  // workforce,
  // weight_sign,
  // dialysis,
  // stock,
  // qcd,
  // data_dict,
  // device,
  // role,
  // org
]

var _asy_router_map = [
  patient,
  createPatient,
  workforce,
  medicalScheduling,
  weight_sign,
  dialysisRecord,
  dialysis,
  stock,
  drugs,
  selfPreparedMedicine,
  otherManagement,
  qcd,
  device,
  org,
  data_upload,
  slow,
  scrm,
  shop,
  
  systems,
  roleManage,
  bedManagement,
  dictionaryManagement,
  templateManagement,
  // dataDictionary,
  // specialDictionary,
  dataTemplate,
  dataPrescription,
  dataDruguse,
  dataShowconfig,
  dataPrint,
  outpatientRegistration,
  outpatientDoctorStation,
  outpatientCharges,
  outpatientPharmacy,
  // kuyiShopping,
  integration,
]

var is_asy_router = process.env.NODE_ENV === 'production' // true; 设置为 true 强制进行路由验证
if (!is_asy_router) {
  _constant_router_map = _constant_router_map.concat(_asy_router_map)
  _asy_router_map = []
} else {

}

export const xt_constantRouterMap = _constant_router_map
export const xt_asyncRouterMap = _asy_router_map

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: xt_constantRouterMap
})

