import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/components/Layout/index.vue'
import Demo from '@/components/Demo.vue'
import Config from '@/pages/config'
import agencyName from '@/utils/agencyName'
import theaterName from '@/utils/theaterName'
import sellName from '@/utils/sellName'
import saleTicketName from '@/utils/saleTicketName'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/',
    component: Layout,
    redirect: '/login',
    hidden: true
  },
  {
    path: '/posTool',
    component: require('@/pages/posTool/index.vue').default,
    hidden: true
  },
  {
    path: '/demo',
    component: Demo,
    hidden: true
  },
  {
    path: '/config',
    name: 'config',
    component: Config,
    hidden: true
  },
  {
    path: '/login',
    name: 'login',
    component: require('@/pages/login').default,
    hidden: true
  },
  {
    path: '/index',
    component: Layout,
    name: 'Dashboard',
    hidden: true,
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        // redirect: '/ticketSale/retail',
        component: require('@/pages/dashboard').default,
        meta: { title: '首页' }
      }
    ]
  }
  // ,
  // {
  //   path: '/demo',
  //   component: Layout,
  //   hidden: true,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'demo',
  //       component: require('@/pages/demo').default,
  //       meta: {title: 'demo'}
  //     }
  //   ]
  // }
]

export default new Router({
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})

// permissionName 与后台获取的权限菜单列表相对应
let routerMap = [
  {
    path: '/ticketSale',
    component: Layout,
    name: '售票管理',
    meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '预约管理' : `${saleTicketName()}管理`, icon: 'ticketSale' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'retail',
        name: 'retail',
        component: require('@/pages/sellManage/retail').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '散客预约' : `散客${sellName()}`, permissionName: 'ticket_sale:scatter' }
      },
      // {
      //   path: 'quickSell',
      //   name: 'quickSell',
      //   component: require('@/pages/sellManage/quickSell').default,
      //   meta: { title: '散客证件售票', permissionName: 'ticket_sale:identify' }
      // },
      {
        path: 'group',
        name: 'group',
        component: require('@/pages/sellManage/group').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '团体预约' : `团体${sellName()}`, permissionName: 'ticket_sale:group' }
      },
      {
        path: 'preOrderGroup',
        name: 'preOrderGroup',
        component: require('@/pages/sellManage/preOrderGroup').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '团体预订预约' : '团体预订售票', permissionName: 'ticket_sale:group_preorder' }
      },
      {
        path: 'preOrderGroupReservation',
        name: 'preOrderGroupReservation',
        component: require('@/pages/sellManage/preOrderGroupReservation').default,
        meta: { title: '团队预约出票', permissionName: 'ticket_sale:team_book_sale' }
      },
      {
        path: 'discountSales',
        name: 'discountSales',
        component: require('@/pages/sellManage/discountSales').default,
        meta: { title: '优惠折扣票', permissionName: 'ticket_sale:group_discount' }
      },
      {
        path: 'batchSale',
        name: 'batchSale',
        component: require('@/pages/sellManage/batchSale/index.vue').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '场次预约' : '场次售票', permissionName: 'ticket_sale:batch' }
      },
      // {
      //   path: 'theaterSale',
      //   name: 'theaterSale',
      //   component: require('@/pages/sellManage/theaterSale').default,
      //   meta: { title: `${theaterName()}售票`, permissionName: 'ticket_sale:theater_sale' }
      // },
      {
        path: 'theaterSaleMazu',
        name: 'theaterSaleMazu',
        component: require('@/pages/sellManage/theaterSaleMazu').default,
        meta: { title: `${theaterName()}售票`, permissionName: 'ticket_sale:theater_sale' }
      },
      {
        path: 'PreOrderList',
        name: 'PreOrderList',
        component: require('@/pages/sellManage/preOrderList').default,
        meta: { title: '预订单列表', permissionName: 'ticket_sale:pre_order' }
      },
      {
        path: 'preOrder',
        name: 'preOrder',
        component: require('@/pages/sellManage/preOrder').default,
        meta: { title: '预订售票', permissionName: 'ticket_sale:pre_order' }
      },
      {
        path: 'printTicket',
        name: 'printTicket',
        component: require('@/pages/sellManage/printTicket').default,
        meta: { title: '补打门票', permissionName: 'ticket_sale:print' }
      },
      {
        path: 'printOnlineTicket',
        name: 'printOnlineTicket',
        component: require('@/pages/sellManage/printOnlineTicket').default,
        meta: { title: '网络取票', permissionName: 'ticket_sale:onlinequery' }
      },
      {
        path: 'returnTickets',
        name: 'returnTickets',
        component: require('@/pages/sellManage/returnTickets').default,
        meta: { title: '退票处理', permissionName: 'ticket_sale:refund' }
      },
      {
        path: 'reschedule',
        name: 'reschedule',
        component: require('@/pages/sellManage/reschedule').default,
        meta: { title: '门票改签', permissionName: 'ticket_sale:change' }
      },
      {
        path: 'checkTickets',
        name: 'checkTickets',
        component: require('@/pages/sellManage/checkTickets').default,
        meta: { title: '人工检票', permissionName: 'ticket_sale:check' }
      },
      {
        path: 'ticketsOperate',
        name: 'ticketsOperate',
        component: require('@/pages/sellManage/ticketsOperate/index').default,
        meta: { title: '门票处理', permissionName: 'ticket_sale:ticket_handle' }
      },
      {
        path: 'sellerShift',
        name: 'sellerShift',
        component: require('@/pages/sellManage/sellerShift').default,
        meta: { title: '售票员交班', permissionName: 'ticket_sale:handover' }
      },
      {
        path: 'myHandOverLog',
        name: 'myHandOverLog',
        component: require('@/pages/sellManage/myHandOverLog').default,
        meta: { title: '交班记录', permissionName: 'ticket_sale:handover_record' }
      },
      {
        path: 'paymentHandIn',
        name: 'paymentHandIn',
        component: require('@/pages/sellManage/paymentHandIn').default,
        meta: { title: '缴款记录', permissionName: 'ticket_sale:cash_handin_log' }
      }
    ]
  },
  {
    path: '/reservation',
    component: Layout,
    name: '预约管理',
    meta: { title: '预约管理', icon: 'form' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'reservationPreOrder',
        name: 'reservationPreOrder',
        component: require('@/pages/reservation/preOrder').default,
        meta: { title: '团队预约', permissionName: 'ticket_book_manager:team_book' }
      },
      {
        path: 'reservationPreOrderList',
        name: 'reservationPreOrderList',
        component: require('@/pages/reservation/preOrderList').default,
        meta: { title: '预订单列表', permissionName: 'ticket_book_manager:team_book_record' }
      },
      {
        path: 'reservationManagerStatistics',
        name: 'reservationManagerStatistics',
        component: require('@/pages/reservation/managerStatistics').default,
        meta: { title: '讲解员记录及统计', permissionName: 'ticket_book_manager:explain_manager_stat' }
      }
    ]
  },
  {
    path: '/checkSetting',
    component: Layout,
    name: '检票管理',
    meta: { title: '检票管理', icon: 'checkTicket' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'channelGroup',
        name: 'channelGroup',
        component: require('@/pages/checkerManage/channelGroup').default,
        meta: { title: '通道组管理', permissionName: 'ticket_check:channel_group' }
      },
      {
        path: 'channelManage',
        name: 'channelManage',
        component: require('@/pages/checkerManage/channelManage').default,
        meta: { title: '通道管理', permissionName: 'ticket_check:channel' }
      },
      {
        path: 'deviceManage',
        name: 'deviceManage',
        component: require('@/pages/checkerManage/deviceManage').default,
        meta: { title: '检票设备', permissionName: 'ticket_check:checker' }
      },
      {
        path: 'secondDevice',
        name: 'secondDevice',
        component: require('@/pages/checkerManage/secondDevice').default,
        meta: { title: '登记机设备', permissionName: 'ticket_check:register' }
      },
      {
        path: 'terminalConfig',
        name: 'terminalConfig',
        component: require('@/pages/checkerManage/terminalConfig').default,
        meta: { title: '设备配置/更新', permissionName: 'ticket_check:checker_config' }
      },
      {
        path: 'checkRecord',
        name: 'checkRecord',
        component: require('@/pages/checkerManage/checkRecord').default,
        meta: { title: '检票记录', permissionName: 'ticket_check:checker_traffic' }
      },
      {
        path: 'channelRecord',
        name: 'channelRecord',
        component: require('@/pages/checkerManage/channelRecord').default,
        meta: { title: '通道记录', permissionName: 'ticket_check:channel_traffic' }
      }
    ]
  },
  {
    path: '/ticketSetting',
    component: Layout,
    name: '票务管理',
    meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '预约检票管理' : '票务管理', icon: 'ticketSetting' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'ticket',
        name: 'ticket',
        component: require('@/pages/ticketSetting/ticket').default,
        meta: { title: '票种管理', permissionName: 'ticket_type_scenic:ticket_type' }
      },
      {
        path: 'ticketTag',
        name: 'ticketTag',
        component: require('@/pages/ticketSetting/ticketTag').default,
        meta: { title: '票种标签管理', permissionName: 'ticket_type_scenic:ticket_type_tag_manager' }
      },
      {
        path: 'ticketPricePlan',
        name: 'ticketPricePlan',
        component: require('@/pages/ticketSetting/ticketPricePlan').default,
        meta: { title: '票种价格方案管理', permissionName: 'ticket_type_scenic:ticket_price_plan' }
      },
      {
        path: 'ticketInventory',
        name: 'ticketInventory',
        component: require('@/pages/ticketSetting/ticketInventory').default,
        meta: { title: '票仓管理', permissionName: 'ticket_type_scenic:ticket_master_warehouse_query', hidden: process.env.VUE_APP_PROJECT === 'czg' }
      },
      {
        path: 'sellerInventory',
        name: 'sellerInventory',
        component: require('@/pages/ticketSetting/sellerInventory').default,
        meta: { title: '售票员票仓', permissionName: 'ticket_type_scenic:ticket_warehouse_sale' }
      },
      {
        path: 'ticketStorage',
        name: 'ticketStorage',
        component: require('@/pages/ticketSetting/ticketStorage').default,
        meta: { title: '预印门票管理', permissionName: 'ticket_type_scenic:ticket_stock' }
      },
      {
        path: 'scenic',
        name: 'scenic',
        component: require('@/pages/ticketSetting/scenic').default,
        meta: { title: '景点管理', permissionName: 'ticket_type_scenic:scenic' }
      },
      {
        path: 'ticketSpot',
        name: 'ticketSpot',
        component: require('@/pages/ticketSetting/ticketSpot').default,
        meta: { title: '售票点管理', permissionName: 'ticket_type_scenic:sale_spot' }
      },
      {
        path: 'addPaymentHandIn',
        name: 'addPaymentHandIn',
        component: require('@/pages/ticketSetting/addPaymentHandIn').default,
        meta: { title: '新增缴款', permissionName: 'ticket_type_scenic:cash_handin' }
      },
      {
        path: 'paymentHandInAll',
        name: 'paymentHandInAll',
        component: require('@/pages/ticketSetting/paymentHandIn').default,
        meta: { title: '缴款记录汇总', permissionName: 'ticket_type_scenic:cash_handin_total' }
      },
      {
        path: 'batchConfig',
        name: 'batchConfig',
        component: require('@/pages/ticketSetting/batchConfig/index.vue').default,
        meta: { title: '场次管理', permissionName: 'ticket_type_scenic:batch_config', hidden: process.env.VUE_APP_PROJECT === 'mazu' }
      },
      {
        path: 'scheduleConfig',
        name: 'scheduleConfig',
        component: require('@/pages/ticketSetting/scheduleConfig/index.vue').default,
        meta: { title: '班次管理', permissionName: 'ticket_type_scenic:schedule' }
      },
      {
        path: 'batch',
        name: 'batch',
        component: require('@/pages/ticketSetting/batch/index.vue').default,
        meta: { title: '卖场管理', permissionName: 'ticket_type_scenic:batch', hidden: process.env.VUE_APP_PROJECT === 'mazu' }
      },
      {
        path: 'performConfig',
        name: 'performConfig',
        component: require('@/pages/ticketSetting/performConfig/index.vue').default,
        meta: { title: '节目管理', permissionName: 'ticket_type_scenic:batch_config', hidden: process.env.VUE_APP_PROJECT === 'czg' }
      },
      {
        path: 'seatConfig',
        name: 'seatConfig',
        component: require('@/pages/ticketSetting/seatConfig/index.vue').default,
        meta: { title: '座位表管理', permissionName: 'ticket_type_scenic:batch_config', hidden: process.env.VUE_APP_PROJECT === 'czg' }
      },

      {
        path: 'batchConfig_theatre',
        name: 'batchConfig_theatre',
        component: require('@/pages/ticketSetting/batchConfig_theatre/index.vue').default,
        meta: { title: `场次管理-${theaterName()}`, permissionName: 'ticket_type_scenic:batch_config', hidden: process.env.VUE_APP_PROJECT === 'czg' }
      },
      {
        path: 'performBatch',
        name: 'performBatch',
        component: require('@/pages/ticketSetting/performBatch/index.vue').default,
        meta: { title: `${theaterName()}排片`, permissionName: 'ticket_type_scenic:batch', hidden: process.env.VUE_APP_PROJECT === 'czg' }
      },
      {
        path: 'invoice',
        name: 'invoice',
        component: require('@/pages/ticketSetting/invoice/index.vue').default,
        meta: { title: '发票管理', permissionName: 'ticket_type_scenic:invoice' }
      },
      {
        path: 'queue',
        name: 'queue',
        component: require('@/pages/ticketSetting/queue/index.vue').default,
        meta: { title: '队列管理', permissionName: 'ticket_type_scenic:queue_manager' }
      },
      {
        path: 'queueLog',
        name: 'queueLog',
        component: require('@/pages/ticketSetting/queueLog/index.vue').default,
        meta: { title: '队列记录', permissionName: 'ticket_type_scenic:queue_manager' }
      },
      {
        path: 'subProject',
        name: 'subProject',
        component: require('@/pages/ticketSetting/subProject/index.vue').default,
        meta: { title: '子项目管理', permissionName: 'ticket_type_scenic:sub_project_manager' }
      }
    ]
  },
  {
    path: '/agency',
    component: Layout,
    name: '旅行社管理',
    meta: { title: `${agencyName()}管理`, icon: 'travel' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'agencySetting',
        name: 'agencySetting',
        component: require('@/pages/agency/agencySetting').default,
        meta: { title: `${agencyName()}列表`, permissionName: 'travel_agency:travel_agency' }
      },
      {
        path: 'agencyTradeLog',
        name: 'agencyTradeLog',
        component: require('@/pages/agency/agencyTradeLog').default,
        meta: { title: '余额消费记录', permissionName: 'travel_agency:prepay_log' }
      },
      {
        path: 'agencyPreOrder',
        name: 'agencyPreOrder',
        component: require('@/pages/agency/preOrder').default,
        meta: { title: `${agencyName()}预定`, permissionName: 'travel_agency:travel_agency_preorder' }
      },
      {
        path: 'agencyPreOrderList',
        name: 'agencyPreOrderList',
        component: require('@/pages/agency/preOrderList').default,
        meta: { title: '预订单记录', permissionName: 'travel_agency:travel_agency_preorder_npm' }
      },
      {
        path: 'agencypreOrderManage',
        name: 'agencypreOrderManage',
        component: require('@/pages/agency/preOrderManage').default,
        meta: { title: '预订单管理', permissionName: 'travel_agency:travel_agency_preorder_manage' }
      },
      {
        path: 'agencyStatistic',
        name: 'agencyStatistic',
        component: require('@/pages/agency/agencyStatistic').default,
        meta: { title: `${agencyName()}售票统计`, permissionName: 'travel_agency:sale_stats' }
      },
      {
        path: 'agencyPreOrderStatistic',
        name: 'agencyPreOrderStatistic',
        component: require('@/pages/agency/agencyPreOrderStatistic').default,
        meta: { title: `${agencyName()}预付款统计`, permissionName: 'querystats:fetch_agency' }
      },
      {
        path: 'guideQuery',
        name: 'guideQuery',
        component: require('@/pages/agency/guideQuery').default,
        meta: { title: '导游管理', permissionName: 'travel_agency:guide' }
      },
      {
        path: 'guideStatistic',
        name: 'guideStatistic',
        component: require('@/pages/agency/guideStatistic').default,
        meta: { title: '导游售票统计', permissionName: 'travel_agency:guide_sale_stats' }
      }
    ]
  },
  {
    path: '/membership',
    component: Layout,
    name: '会员管理',
    meta: { title: '会员管理', icon: 'member' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'memberType',
        name: 'memberType',
        component: require('@/pages/member/memberType').default,
        meta: { title: '会员类型', permissionName: 'member:member_type' }
      },
      {
        path: 'memberPreSales',
        name: 'memberPreSales',
        component: require('@/pages/member/memberPreSales').default,
        meta: { title: '会员预售管理', permissionName: 'member:member_presale' }
      },
      {
        path: 'memberSales',
        name: 'memberSales',
        component: require('@/pages/member/memberSales').default,
        meta: { title: '会员办理', permissionName: 'member:member_add' }
      },
      {
        path: 'memberUpgrade',
        name: 'memberUpgrade',
        component: require('@/pages/member/memberUpgrade').default,
        meta: { title: '会员升级设置', permissionName: 'member:member_upgrade' }
      },
      // {
      //   path: 'iccardCheckout',
      //   name: 'iccardCheckout',
      //   component: require('@/pages/member/iccardCheckout').default,
      //   meta: { title: '会员出库', permissionName: 'member:member_preadd' }
      // },
      // {
      //   path: 'iccardCheckoutLog',
      //   name: 'iccardCheckoutLog',
      //   component: require('@/pages/member/iccardCheckoutLog').default,
      //   meta: { title: '会员出库记录', permissionName: 'member:member_preadd' }
      // },
      // {
      //   path: 'iccardStorage',
      //   name: 'iccardStorage',
      //   component: require('@/pages/member/iccardStorage').default,
      //   meta: { title: '会员入库', permissionName: 'member:member_preadd' }
      // },
      // {
      //   path: 'storageQuery',
      //   name: 'storageQuery',
      //   component: require('@/pages/member/storageQuery').default,
      //   meta: { title: '入库记录', permissionName: 'member:member_preadd_record' }
      // },
      // {
      //   path: 'storageStatistics',
      //   name: 'storageStatistics',
      //   component: require('@/pages/member/storageStatistics').default,
      //   meta: { title: '入库统计', permissionName: 'member:member_preadd_stats' }
      // },
      // {
      //   path: 'memberActive',
      //   name: 'memberActive',
      //   component: require('@/pages/member/memberActive').default,
      //   meta: { title: '会员激活', permissionName: 'member:member_active' }
      // },
      // {
      //   path: 'iccardActiveLog',
      //   name: 'iccardActiveLog',
      //   component: require('@/pages/member/iccardActiveLog').default,
      //   meta: { title: '会员激活记录', permissionName: 'member:member_active' }
      // },
      {
        path: 'memberList',
        name: 'memberList',
        component: require('@/pages/member/memberList').default,
        meta: { title: '会员客户管理', permissionName: 'member:member_query' }
      },
      {
        path: 'memberRecharge',
        name: 'memberRecharge',
        component: require('@/pages/member/memberRecharge').default,
        meta: { title: '会员充值退卡', permissionName: 'member:member_charge' }
      },
      {
        path: 'memberCheckLog',
        name: 'memberCheckLog',
        component: require('@/pages/member/memberCheckLog').default,
        meta: { title: '会员检票记录', permissionName: 'member:member_check_record' }
      },
      {
        path: 'memberCheckStatistics',
        name: 'memberCheckStatistics',
        component: require('@/pages/member/memberCheckStatistics').default,
        meta: { title: '会员检票统计', permissionName: 'member:member_check_statistics' }
      },
      {
        path: 'memberTradeLog',
        name: 'memberTradeLog',
        component: require('@/pages/member/memberTradeLog').default,
        meta: { title: '会员交易记录', permissionName: 'member:member_charge_statistics' }
      },
      {
        path: 'memberTradeStatistics',
        name: 'memberTradeStatistics',
        component: require('@/pages/member/memberTradeStatistics').default,
        meta: { title: '会员交易统计', permissionName: 'member:member_charge_record' }
      },
      {
        path: 'memberCheckTimesLogs',
        name: 'memberCheckTimesLogs',
        component: require('@/pages/member/memberCheckTimesLogs').default,
        meta: { title: '会员检票修改记录', permissionName: 'member:update_check_times' }
      }
    ]
  },
  {
    path: '/queryReport',
    component: Layout,
    name: '查询报表',
    meta: { title: '查询报表', icon: 'queryform' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'salesQuery',
        name: 'salesQuery',
        component: require('@/pages/queryReport/salesQuery').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '预约记录' : '售票记录', permissionName: 'querystats:sale_query' }
      },
      {
        path: 'ticketSaleByBatch',
        name: 'ticketSaleByBatch',
        component: require('@/pages/queryReport/TicketSaleByBatch').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '场次预约统计' : '场次售票统计', permissionName: 'querystats:batch_stats' }
      },
      {
        path: 'salesStatistic',
        name: 'salesStatistic',
        component: require('@/pages/queryReport/salesStatistic').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '预约统计' : '售票统计', permissionName: 'querystats:sale_stats' }
      },
      {
        path: 'orderStatistic',
        name: 'orderStatistic',
        component: require('@/pages/queryReport/OrderStatistics').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '自定义预约统计' : '自定义售票统计', permissionName: 'querystats:sale_stats' }
      },
      {
        path: 'batchorderStatistic',
        name: 'batchorderStatistic',
        component: require('@/pages/queryReport/BatchOrderStatistics').default,
        meta: { title: '日历票报表', permissionName: 'querystats:sale_stats', hidden: process.env.VUE_APP_PROJECT !== 'mazu' }
      },
      {
        path: 'reserveOrderStatistics',
        name: 'reserveOrderStatistics',
        component: require('@/pages/queryReport/ReserveOrderStatistics').default,
        meta: { title: '早鸟票报表', permissionName: 'querystats:sale_stats', hidden: process.env.VUE_APP_PROJECT !== 'mazu' }
      },
      {
        path: 'OrderScenicSaleStatistics',
        name: 'OrderScenicSaleStatistics',
        component: require('@/pages/queryReport/OrderScenicSaleStatistics').default,
        meta: { title: '景点售票统计', permissionName: 'querystats:scenic_sale_stats' }
      },
      {
        path: 'dailyOrderStatistics',
        name: 'dailyOrderStatistics',
        component: require('@/pages/queryReport/dailyOrderStatistics').default,
        meta: { title: '营业日报表', permissionName: 'querystats:sale_stats' }
      },
      {
        path: 'printOlQuery',
        name: 'printOlQuery',
        component: require('@/pages/queryReport/printOlQuery').default,
        meta: { title: '取票记录', permissionName: 'querystats:fetch_query' }
      },
      {
        path: 'printOlStatistics',
        name: 'printOlStatistics',
        component: require('@/pages/queryReport/printOlStatistics').default,
        meta: { title: '取票统计', permissionName: 'querystats:fetch_stats' }
      },
      {
        path: 'checkQuery',
        name: 'checkQuery',
        component: require('@/pages/queryReport/checkQuery').default,
        meta: { title: '检票记录', permissionName: 'querystats:check_query' }
      },
      {
        path: 'checkStatistic',
        name: 'checkStatistic',
        component: require('@/pages/queryReport/checkStatistic').default,
        meta: { title: '检票统计', permissionName: 'querystats:check_stats' }
      },
      {
        path: 'salesDaily',
        name: 'salesDaily',
        component: require('@/pages/queryReport/salesDaily').default,
        meta: { title: process.env.VUE_APP_PROJECT === 'czg' ? '预约检票日报' : '销售日报', permissionName: 'querystats:daily_sale' }
      },

      {
        path: 'freeQuery',
        name: 'freeQuery',
        component: require('@/pages/queryReport/freeQuery').default,
        meta: { title: '免票记录', permissionName: 'querystats:sale_query' }
      },
      {
        path: 'freeStatistic',
        name: 'freeStatistic',
        component: require('@/pages/queryReport/freeStatistic').default,
        meta: { title: '免票统计', permissionName: 'querystats:sale_stats' }
      },
      {
        path: 'comparedAnalysis',
        name: 'comparedAnalysis',
        component: require('@/pages/queryReport/comparedAnalysis').default,
        meta: { title: '门票同比分析表', permissionName: 'querystats:compared_analysis' }
      },
      {
        path: 'printQuery',
        name: 'printQuery',
        component: require('@/pages/queryReport/printQuery').default,
        meta: { title: '补打记录', permissionName: 'querystats:secondprint_query' }
      },
      {
        path: 'rescheduleQuery',
        name: 'rescheduleQuery',
        component: require('@/pages/queryReport/rescheduleQuery').default,
        meta: { title: '改签记录', permissionName: 'querystats:change_query' }
      },
      {
        path: 'rescheduleStatistics',
        name: 'rescheduleStatistics',
        component: require('@/pages/queryReport/rescheduleStatistics').default,
        meta: { title: '改签统计', permissionName: 'querystats:change_stats' }
      },
      {
        path: 'refundQuery',
        name: 'refundQuery',
        component: require('@/pages/queryReport/refundQuery').default,
        meta: { title: '退票记录', permissionName: 'querystats:refund_query' }
      },
      {
        path: 'refundStatistics',
        name: 'refundStatistics',
        component: require('@/pages/queryReport/refundStatistics').default,
        meta: { title: '退票统计', permissionName: 'querystats:refund_stats' }
      },
      {
        path: 'secondQuery',
        name: 'secondQuery',
        component: require('@/pages/queryReport/secondQuery').default,
        meta: { title: '二次入园记录', permissionName: 'querystats:reentry_query' }
      },
      {
        path: 'handOverLog',
        name: 'handOverLog',
        component: require('@/pages/queryReport/handOverLog').default,
        meta: { title: '交班记录汇总', permissionName: 'querystats:handover_stats' }
      },
      {
        path: 'TicketIncomeStatistics',
        name: 'TicketIncomeStatistics',
        component: require('@/pages/queryReport/TicketIncomeStatistics.vue').default,
        meta: { title: '票种收入统计', permissionName: 'querystats:sale_stats' }
      },
      {
        path: 'handOverStatistics',
        name: 'handOverStatistics',
        component: require('@/pages/queryReport/handOverStatistics/index.vue').default,
        meta: { title: '窗口销售明细', permissionName: 'querystats:sale_detail' }
      },
      {
        path: 'orderTotalStatistics',
        name: 'orderTotalStatistics',
        component: require('@/pages/queryReport/orderTotalStatistics').default,
        meta: { title: '售票累计统计', permissionName: 'querystats:sale_grand_total' }
      },
      {
        path: 'memberVisitsStatistics',
        name: 'memberVisitsStatistics',
        component: require('@/pages/queryReport/memberVisitsStatistics').default,
        meta: { title: '会员来园次数分析', permissionName: 'member:member_visits_statistics' }
      },
      {
        path: 'ticketInStockStatistics',
        name: 'ticketInStockStatistics',
        component: require('@/pages/queryReport/ticketInStockStatistics').default,
        meta: { title: '预印门票管理统计', permissionName: 'querystats:ticket_in_stock_detail' }
      },
      {
        path: 'invoiceRecord',
        name: 'invoiceRecord',
        component: require('@/pages/queryReport/invoiceRecord').default,
        meta: { title: '开票记录', permissionName: 'querystats:invoice_record' }
      },
      {
        path: 'reportExport',
        name: 'reportExport',
        component: require('@/pages/queryReport/reportExport').default,
        meta: { title: '导出报表', permissionName: 'querystats:reports_list' }
      }
    ]
  },
  {
    path: '/mergeReport',
    component: Layout,
    name: '汇总数据',
    meta: { title: '汇总数据', icon: 'visitorSetting' },
    alwaysShow: true,
    children: [
      {
        name: 'report',
        path: 'report',
        component: require('@/pages/queryReport/mergeReport').default,
        meta: { title: '汇总数据', hidden: process.env.VUE_APP_PROJECT !== 'mazu', permissionName: 'querystats:sale_stats' }
      }
    ]
  },
  {
    path: '/visitor',
    component: Layout,
    name: '客户列表',
    meta: { title: '客户管理', icon: 'visitorSetting' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'visitorManage',
        name: 'visitorManage',
        component: () => import('@/pages/visitor/visitorManage'),
        meta: { title: '客户列表', permissionName: 'customer:customer' }
      },
      {
        path: 'vistorStaticstics',
        name: 'vistorStaticstics',
        component: () => import('@/pages/visitor/vistorStaticstics'),
        meta: { title: '客户画像', permissionName: 'customer:customer_stats' }
      }
    ]
  },
  {
    path: '/systemSetting',
    component: Layout,
    name: '系统管理',
    meta: { title: '系统管理', icon: 'systemSetting' },
    redirect: 'noredirect',
    alwaysShow: true,
    children: [
      {
        path: 'payChannel',
        name: 'payChannel',
        component: require('@/pages/systemSetting/payChannel').default,
        meta: { title: '支付渠道设置', permissionName: 'system_setting:global_setting' }
      },
      {
        path: 'commonSetting',
        name: 'commonSetting',
        component: require('@/pages/systemSetting/commonSetting').default,
        meta: { title: '参数配置', permissionName: 'system_setting:global_setting' }
      },
      {
        path: 'account',
        name: 'account',
        component: require('@/pages/systemSetting/account').default,
        meta: { title: '账号管理', permissionName: 'system_setting:users' }
      },
      {
        path: 'role',
        name: 'role',
        component: require('@/pages/systemSetting/role').default,
        meta: { title: '角色管理', permissionName: 'system_setting:roles' }
      },
      {
        path: 'printManage',
        name: 'printManage',
        component: require('@/pages/systemSetting/printManage').default,
        meta: { title: '打印模板配置', permissionName: 'system_setting:print_model' }
      },
      {
        path: 'smallTicket',
        name: 'smallTicket',
        component: require('@/pages/systemSetting/smallTicket').default,
        meta: { title: '小票打印配置', permissionName: 'system_setting:print_model' }
      },
      {
        path: 'operationLog',
        name: 'operationLog',
        component: require('@/pages/systemSetting/operationLog').default,
        meta: { title: '操作日志', permissionName: 'system_setting:web_log' }
      },
      {
        path: 'loginLog',
        name: 'loginLog',
        component: require('@/pages/systemSetting/loginLog').default,
        meta: { title: '登录日志', permissionName: 'system_setting:login_log' }
      }
    ]
  },
  {
    path: '/error',
    component: Layout,
    redirect: 'noredirect',
    name: 'errorPages',
    hidden: true,
    meta: {
      title: 'errorPages',
      icon: '404'
    },
    children: [
      { path: '401', component: require('@/pages/401').default, name: 'page401', meta: { title: 'page401', noCache: true } },
      { path: '404', component: require('@/pages/404').default, name: 'page404', meta: { title: 'page404', noCache: true } }
    ]
  },
  {
    path: '*',
    redirect: '/error/404',
    hidden: true
  }
]

// 印象妈祖客户端定制化去掉一些不用的菜单入口
// 优化票务管理页面，部分未使用功能按钮优化或隐藏，（如场次管理、场次管理剧院等重复按钮）
// const appName = process.env.VUE_APP_PROJECT_NAME // '印象妈祖票务系统'
// if (appName.indexOf('妈祖') > 0) {
//   const titlesToDelete = ['场次管理', '场次管理-'] // 添加要删除的标题 []
//   console.log('印象妈祖客户端定制化删除部分菜单', titlesToDelete)
//   routerMap.forEach(route => {
//     if (route.children) {
//       route.children = route.children.filter(child => {
//         return !titlesToDelete.some(title => child.meta.title.includes(title))
//       })
//     }
//   })
// }

// 动态将子权限附加到父级
export const asyncRouterMap = routerMap
  .map(item => {
    if (item.children) {
      !item.meta && (item.meta = {})

      item.meta.permissionName = item.children.map(i => {
        if (i.meta && i.meta.permissionName) {
          return i.meta.permissionName
        } else {
          return 'all' // 所有人可见
        }
      })
    }

    return item
  })
