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'

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

// 迭代项目的时候路由全部在后面加，参考init.vue文件
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/init', component: () => import('@/views/init'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/init',
    name: 'init',
    hidden: true,
  },
  {
    path: '/index',
    component: Layout,
    redirect: '/index/index',
    name: 'index',
    meta: { title: '首页', head: '程序概况', icon: 'example', show: 'yes'},
    children: [
      {
        path: 'index',
        component: () => import('@/views/index/index'),
        name: 'Index',
      },
    ]
  },
  {
    path: '/basicInfo',
    component: Layout,
    name: 'basicInfo',
    redirect: 'noredirect',
    meta: { title: '基本信息', icon: 'example' },
    children: [
      {
        path: '/basicInfo/driverList',
        component: () => import('@/views/basicInfo/driverList'),
        meta: { title: '司机列表' },
        name: 'driverList',
      },
      {
        path: '/basicInfo/dispatcherList',
        component: () => import('@/views/basicInfo/dispatcherList'),
        meta: { title: '调度员列表' },
        name: 'dispatcherList',
      },
      {
        path: '/basicInfo/supplierList',
        component: () => import('@/views/basicInfo/supplierList'),
        meta: { title: '供应商列表' },
        name: 'supplierList',
      },
      {
        path: '/basicInfo/clientNameList',
        component: () => import('@/views/basicInfo/clientNameList'),
        meta: { title: '客户名称' },
        name: 'clientNameList',
      },
      {
        path: '/basicInfo/clientList',
        component: () => import('@/views/basicInfo/clientList'),
        meta: { title: '客户列表' },
        name: 'clientList',
      },
      {
        path: '/basicInfo/siteList',
        component: () => import('@/views/basicInfo/siteList'),
        meta: { title: '工地列表' },
        name: 'siteList',
      },
      {
        path: '/basicInfo/transferList',
        component: () => import('@/views/basicInfo/transferList'),
        meta: { title: '中转站列表' },
        name: 'transferList',
      },
      {
        path: '/basicInfo/headList',
        component: () => import('@/views/basicInfo/headList'),
        meta: { title: '车辆负责人列表' },
        name: 'headList',
      },
      {
        path: '/basicInfo/speciesList',
        component: () => import('@/views/basicInfo/speciesList'),
        meta: { title: '品种列表' },
        name: 'speciesList',
      },
      // 司机新增/编辑
      {
        path: '/basicInfo/driCreate',
        name: 'driCreate',
        component: () => import('@/views/basicInfo/driverDetail'),
        meta: { title: '新增司机', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/driEdit/:id?',
        component: () => import('@/views/basicInfo/driverDetail'),
        meta: { title: '编辑司机', noCache: true },
        name: 'driEdit',
        hidden: true
      },
      // 调度员新增/编辑
      {
        path: '/basicInfo/disCreate',
        name: 'disCreate',
        component: () => import('@/views/basicInfo/dispatcherDetail'),
        meta: { title: '新增调度员', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/disEdit/:id?',
        component: () => import('@/views/basicInfo/dispatcherDetail'),
        meta: { title: '编辑调度员', noCache: true },
        name: 'disEdit',
        hidden: true
      },
      // 供应商新增/编辑
      {
        path: '/basicInfo/supCreate',
        name: 'supCreate',
        component: () => import('@/views/basicInfo/supplierDetail'),
        meta: { title: '新增供应商', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/supEdit/:id?',
        component: () => import('@/views/basicInfo/supplierDetail'),
        meta: { title: '编辑供应商', noCache: true },
        name: 'supEdit',
        hidden: true
      },
      // 客户新增/编辑
      {
        path: '/basicInfo/cliCreate',
        name: 'cliCreate',
        component: () => import('@/views/basicInfo/clientDetail'),
        meta: { title: '新增客户', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/cliEdit/:id?',
        component: () => import('@/views/basicInfo/clientDetail'),
        meta: { title: '编辑客户', noCache: true },
        name: 'cliEdit',
        hidden: true
      },
      // 工地新增/编辑
      {
        path: '/basicInfo/siteCreate',
        name: 'siteCreate',
        component: () => import('@/views/basicInfo/siteDetail'),
        meta: { title: '新增工地', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/siteEdit/:id?',
        component: () => import('@/views/basicInfo/siteDetail'),
        meta: { title: '编辑工地', noCache: true },
        name: 'siteEdit',
        hidden: true
      },
      // 中转站新增/编辑
      {
        path: '/basicInfo/transferCreate',
        name: 'transferCreate',
        component: () => import('@/views/basicInfo/transferDetail'),
        meta: { title: '新增中转站', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/transferEdit/:id?',
        component: () => import('@/views/basicInfo/transferDetail'),
        meta: { title: '编辑中转站', noCache: true },
        name: 'transferEdit',
        hidden: true
      },
      // 车辆负责人新增/编辑
      {
        path: '/basicInfo/headCreate',
        name: 'headCreate',
        component: () => import('@/views/basicInfo/headDetail'),
        meta: { title: '新增车辆负责人', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/headEdit/:id?',
        component: () => import('@/views/basicInfo/headDetail'),
        meta: { title: '编辑车辆负责人', noCache: true },
        name: 'headEdit',
        hidden: true
      },
      // 品种新增/编辑
      {
        path: '/basicInfo/speciesCreate',
        name: 'speciesCreate',
        component: () => import('@/views/basicInfo/speciesDetail'),
        meta: { title: '新增品种', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/speciesEdit/:id?',
        component: () => import('@/views/basicInfo/speciesDetail'),
        meta: { title: '编辑品种', noCache: true },
        name: 'speciesEdit',
        hidden: true
      },
      // 客户名称新增/编辑
      {
        path: '/basicInfo/cliNameCreate',
        name: 'cliNameCreate',
        component: () => import('@/views/basicInfo/clientNameDetail'),
        meta: { title: '新增客户名称', icon: 'edit' },
        hidden: true
      },
      {
        path: '/basicInfo/cliNameEdit/:id?',
        component: () => import('@/views/basicInfo/clientNameDetail'),
        meta: { title: '编辑客户名称', noCache: true },
        name: 'cliNameEdit',
        hidden: true
      },
    ]
  },
  {
    path: '/distributionManagement',
    component: Layout,
    name: 'distributionManagement',
    redirect: 'noredirect',
    meta: { title: '配送管理', icon: 'example' },
    children: [
      {
        path: '/distributionManagement/distributionList',
        component: () => import('@/views/distributionManagement/distributionList'),
        meta: { title: '配送列表' },
        name: 'distributionList',
      },
      {
        path: '/distributionManagement/deliveryDetail',
        component: () => import('@/views/distributionManagement/deliveryDetail'),
        meta: { title: '配送明细' },
        name: 'deliveryDetail',
      },
      {
        path: '/distributionManagement/deliveryEdit/:id?',
        component: () => import('@/views/distributionManagement/deliveryEdit'),
        meta: { title: '编辑配送明细' },
        name: 'deliveryEdit',
        hidden: true
      },
      {
        path: '/distributionManagement/disCost',
        component: () => import('@/views/distributionManagement/disCost'),
        meta: { title: '运费单价' },
        name: 'disCost',
      },
      // 新增配送订单
      {
        path: '/distributionManagement/disCreate',
        name: 'disCreate',
        component: () => import('@/views/distributionManagement/disDetail'),
        meta: { title: '新增配送订单', icon: 'edit' },
        hidden: true
      },
      // 新增运费单价
      {
        path: '/distributionManagement/disCostCreate',
        name: 'disCostCreate',
        component: () => import('@/views/distributionManagement/disCostDetail'),
        meta: { title: '新增运费单价', icon: 'edit' },
        hidden: true
      },
      // 编辑
      {
        path: '/distributionManagement/disCostEdit/:id?',
        component: () => import('@/views/distributionManagement/disCostDetail'),
        meta: { title: '编辑运费单价', noCache: true },
        name: 'disCostEdit',
        hidden: true
      },
    ]
  },
  {
    path: '/exchangeManagement',
    component: Layout,
    name: 'exchangeManagement',
    redirect: 'noredirect',
    meta: { title: '往来管理', icon: 'example'},
    children: [
      {
        path: '/exchangeManagement/collectionAndPayment',
        component: () => import('@/views/exchangeManagement/collectionAndPayment'),
        meta: { title: '收付款列表' },
        name: 'collectionAndPayment',
      },
      {
        path: '/exchangeManagement/supplier',
        component: () => import('@/views/exchangeManagement/supplier'),
        meta: { title: '供应商' },
        name: 'supplier',
      },
    ]
  },
  {
    path: '/cashingManagement',
    component: Layout,
    name: 'cashingManagement',
    redirect: 'noredirect',
    meta: { title: '出纳管理', icon: 'example'},
    children: [
      {
        path: '/cashingManagement/dayBook',
        component: () => import('@/views/cashingManagement/dayBook'),
        meta: { title: '日记账' },
        name: 'dayBook',
      },
      {
        path: '/cashingManagement/dayBookCreate',
        component: () => import('@/views/cashingManagement/dayBookCreate'),
        meta: { title: '日记账新增' },
        name: 'dayBookCreate',
        hidden: true
      },
      {
        path: '/cashingManagement/invoiceManagement',
        component: () => import('@/views/cashingManagement/invoiceManagement'),
        meta: { title: '发票管理' },
        name: 'cashingManagement',
      },
    ]
  },
  {
    path: '/financialManagement',
    component: Layout,
    name: 'financialManagement',
    redirect: 'noredirect',
    meta: {
      title: '财务管理',
      icon: 'example'
    },
    children: [
      {
        path: '/financialManagement/driver',
        component: () => import('@/views/financialManagement/driver/index'), // Parent router-view
        name: 'driver',
        redirect: 'noredirect',
        meta: { title: '司机', icon: 'xitong' },
        children: [
          {
            path: '/financialManagement/driver/driverReim',
            component: () => import('@/views/financialManagement/driver/driverReim'),
            name: 'driverReim',
            meta: { title: '司机帐款' }
          },
          {
            path: '/financialManagement/driver/shipDetails',
            component: () => import('@/views/financialManagement/driver/shipDetails'),
            name: 'shipDetails',
            meta: { title: '运费明细' },
          },
          {
            path: '/financialManagement/driver/shipProfits',
            component: () => import('@/views/financialManagement/driver/shipProfits'),
            name: 'shipProfits',
            meta: { title: '运费利润' },
          },
          // 运费明细
          {
            path: '/financialManagement/driver/shiDetails/:id?',
            name: 'shiDetails',
            component: () => import('@/views/financialManagement/driver/shipDetails/detail'),
            meta: { title: '运费明细', icon: 'edit' },
            hidden: true
          },
        ]
      },
      {
        path: '/financialManagement/client',
        component: () => import('@/views/financialManagement/client/index'),
        name: 'client',
        redirect: 'noredirect',
        meta: { title: '客户', icon: 'xitong' },
        children: [
          {
            path: '/financialManagement/client/reOrder',
            component: () => import('@/views/financialManagement/client/reOrder'),
            name: 'reOrder',
            meta: { title: '应收订单管理' },
          },
          {
            path: '/financialManagement/client/payDetail',
            component: () => import('@/views/financialManagement/client/payDetail'),
            name: 'payDetail',
            meta: { title: '收款明细' }
          },
          {
            path: '/financialManagement/client/refundDetail',
            component: () => import('@/views/financialManagement/client/refundDetail'),
            name: 'refundDetail',
            meta: { title: '退款明细' }
          },
          {
            path: '/financialManagement/client/custAccount',
            component: () => import('@/views/financialManagement/client/custAccount'),
            name: 'custAccount',
            meta: { title: '客户账款' }
          },
          {
            path: '/financialManagement/client/ticManagement',
            component: () => import('@/views/financialManagement/client/ticManagement'),
            name: 'ticManagement',
            meta: { title: '销项票管理' }
          },
          // 新增销项票
          {
            path: '/financialManagement/client/create',
            name: 'create',
            component: () => import('@/views/financialManagement/client/ticManagement/create'),
            meta: { title: '新增销项票', icon: 'edit' },
            hidden: true
          },
           // 编辑销项票
          {
            path: '/financialManagement/client/editTic/:id?',
            name: 'editTic',
            component: () => import('@/views/financialManagement/client/ticManagement/create'),
            meta: { title: '编辑销项票', icon: 'edit' },
            hidden: true
          },
          // 新增收款明细
          {
            path: '/financialManagement/client/payNew',
            name: 'create',
            component: () => import('@/views/financialManagement/client/payDetail/payNew'),
            meta: { title: '新增收款明细', icon: 'edit' },
            hidden: true
          },
          // 编辑收款明细
          {
            path: '/financialManagement/client/payNew/:id?',
            name: 'create',
            component: () => import('@/views/financialManagement/client/payDetail/payNew'),
            meta: { title: '编辑收款明细', icon: 'edit' },
            hidden: true
          },
          // 编辑退款明细
          {
            path: '/financialManagement/client/refundEdit/:id?',
            name: 'refundEdit',
            component: () => import('@/views/financialManagement/client/refundDetail/refundEdit'),
            meta: { title: '编辑退款明细', icon: 'edit' },
            hidden: true
          }
        ]
      },
      {
        path: '/financialManagement/supplier',
        component: () => import('@/views/financialManagement/supplier/index'),
        name: 'supplier',
        redirect: 'noredirect',
        meta: { title: '供应商', icon: 'xitong' },
        children: [
          {
            path: '/financialManagement/supplier/supplierOrder',
            component: () => import('@/views/financialManagement/supplier/supplierOrder'),
            name: 'supplierOrder',
            meta: { title: '应付订单管理' },
          },
          {
            path: '/financialManagement/supplier/payList',
            component: () => import('@/views/financialManagement/supplier/payList'),
            name: 'payList',
            meta: { title: '付款明细' }
          },
          // 编辑付款明细
          {
            path: '/financialManagement/supplier/payEdit/:id?',
            name: 'payEdit',
            component: () => import('@/views/financialManagement/supplier/payList/payEdit'),
            meta: { title: '编辑付款明细', icon: 'edit' },
            hidden: true
          },
          {
            path: '/financialManagement/supplier/draftDetail',
            component: () => import('@/views/financialManagement/supplier/draftDetail'),
            name: 'draftDetail',
            meta: { title: '汇票记账明细' }
          },
          // 汇票记账明细
          {
            path: '/financialManagement/supplier/draftEdit/:id?',
            name: 'draftEdit',
            component: () => import('@/views/financialManagement/supplier/draftDetail/draftEdit'),
            meta: { title: '编辑汇票记账明细', icon: 'edit' },
            hidden: true
          },
          {
            path: '/financialManagement/supplier/cashAccount',
            component: () => import('@/views/financialManagement/supplier/cashAccount'),
            name: 'cashAccount',
            meta: { title: '现金记账明细' }
          },
          {
            path: '/financialManagement/supplier/supplierAccount',
            component: () => import('@/views/financialManagement/supplier/supplierAccount'),
            name: 'supplierAccount',
            meta: { title: '供应商账款' }
          },
          // 编辑供应商账款
          {
            path: '/financialManagement/supplier/cashEdit/:id?',
            name: 'cashEdit',
            component: () => import('@/views/financialManagement/supplier/cashAccount/cashEdit'),
            meta: { title: '编辑供应商账款', icon: 'edit' },
            hidden: true
          },
          {
            path: '/financialManagement/supplier/supplierTicket',
            component: () => import('@/views/financialManagement/supplier/supplierTicket'),
            name: 'supplierTicket',
            meta: { title: '进项票管理' }
          },
          // 新增进项票
          {
            path: '/financialManagement/supplier/create',
            name: 'create',
            component: () => import('@/views/financialManagement/supplier/supplierTicket/create'),
            meta: { title: '新增进项票', icon: 'edit' },
            hidden: true
          },
          // 编辑进项票
          {
            path: '/financialManagement/supplier/ticketEdit/:id?',
            name: 'ticketEdit',
            component: () => import('@/views/financialManagement/supplier/supplierTicket/create'),
            meta: { title: '编辑进项票', icon: 'edit' },
            hidden: true
          }
        ]
      },
    ]
  },
  {
    path: '/purchaseManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'purchaseManagement',
    meta: { title: '采购管理', icon: 'example' },
    children: [
      {
        path: '/purchaseManagement/purchaseSet',
        component: () => import('@/views/purchaseManagement/purchaseSet'),
        meta: { title: '采购单' },
        name: 'purchaseSet',
      },
      {
        path: '/purchaseManagement/purchaseDetail',
        component: () => import('@/views/purchaseManagement/purchaseDetail'),
        meta: { title: '采购单明细' },
        name: 'purchaseDetail',
      },
      {
        path: '/purchaseManagement/billList',
        component: () => import('@/views/purchaseManagement/billList'),
        meta: { title: '付款单' },
        name: 'billList',
      },
    ]
  },
  {
    path: '/operManagement',
    component: Layout,
    name: 'operManagement',
    redirect: 'noredirect',
    meta: { title: '运营管理', icon: 'example'},
    children: [
      {
        path: '/operManagement/operManagement',
        component: () => import('@/views/operManagement/index'),
        meta: { title: '意见列表' },
        name: 'operManagement',
      },
    ]
  },
  {
    path: '/systemManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'systemManagement',
    meta: { title: '系统管理', icon: 'example' },
    children: [
      {
        path: '/systemManagement/systemSet',
        component: () => import('@/views/systemManagement/systemSet'),
        meta: { title: '系统设置' },
        name: 'systemSet',
      },
      {
        path: '/systemManagement/accountList',
        component: () => import('@/views/systemManagement/accountList'),
        meta: { title: '账号列表' },
        name: 'accountList',
      },
      {
        path: '/systemManagement/comList',
        component: () => import('@/views/systemManagement/comList'),
        meta: { title: '企业列表' },
        name: 'comList',
      },
      {
        path: '/systemManagement/accountCreate',
        component: () => import('@/views/systemManagement/accountDetail'),
        meta: { title: '新增账号', noCache: true },
        name: 'accountCreate',
        hidden: true
      },
      {
        path: '/systemManagement/accountEdit/:id?',
        component: () => import('@/views/systemManagement/accountDetail'),
        meta: { title: '编辑账号', noCache: true },
        name: 'accountEdit',
        hidden: true
      },
      {
        path: '/systemManagement/create',
        name: 'CreateArticle',
        component: () => import('@/views/systemManagement/detail'),
        meta: { title: '新增企业', icon: 'edit' },
        hidden: true
      },
      {
        path: '/systemManagement/edit/:id?',
        component: () => import('@/views/systemManagement/detail'),
        meta: { title: '编辑企业', noCache: true },
        name: 'EditArticle',
        hidden: true
      },

    ]
  },
  { path: '*', redirect: '/404', hidden: true },
]

export default new Router({
  mode: 'history', //后端支持可开
  base: 'front',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
