// 测量设备
import type { Route } from '@/global'

const Layout = () => import('@/layouts/index.vue')

const routes: Route.recordRaw[] = [
  {
    path: '/device',
    component: Layout,
    redirect: '/device/bench',
    name: 'DBench',
    meta: {
      title: '工作台',
      icon: 'ep:key',
      auth: '/device/bench',
    },
    children: [
      {
        path: '/device/bench',
        name: 'DeviceBench',
        component: () => import('@/views/device/bench/deviceBench.vue'),
        meta: {
          title: '工作台',
          auth: '/device/bench',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/device',
        },
      },
    ],
  },
  {
    path: '/standingBook',
    component: Layout,
    redirect: '/standingBook/measureDevice',
    name: 'standingBook',
    meta: {
      title: '设备台账',
      icon: 'ep:key',
      auth: '/device/standingBook',
    },
    children: [
      {
        path: 'measureDevice',
        name: 'measureDevice',
        component: () => import('@/views/device/standingBook/measureDevice.vue'),
        meta: {
          title: '测量设备',
          icon: 'ep:key',
          auth: '/device/measureDevice',
        },
      },
      {
        path: 'adjustDevice',
        name: 'adjustDevice',
        component: () => import('@/views/device/standingBook/adjustDevice.vue'),
        meta: {
          title: '校准/检定设备',
          icon: 'ep:key',
          auth: '/device/adjustDevice',
        },
      },
      {
        path: 'standardMatchDevice',
        name: 'standardMatchDevice',
        component: () => import('@/views/device/standingBook/standardMatchDevice.vue'),
        meta: {
          title: '标准配套设备',
          icon: 'ep:key',
          auth: '/device/standardMatchDevice',
        },
      },
      {
        path: 'measureTool',
        name: 'measureTool',
        component: () => import('@/views/device/standingBook/measureTool.vue'),
        meta: {
          title: '测量工装',
          icon: 'ep:key',
          auth: '/device/measureTool',
        },
      },
      {
        path: ':type/:id?',
        name: 'standingBookDetail',
        component: () => import('@/views/device/standingBook/components/templateAdd.vue'),
        meta: {
          title: '测量设备',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/standingBook/measureDevice',
        },
        // 独享守卫，根据form的路由动态修改meta中的activeMenu
        beforeEnter: (to, from, next) => {
          const type = from.path.split('/')[from.path.split('/').length - 1]
          console.log(type)
          switch (type) {
            case 'measureDevice':
              to.meta.activeMenu = '/standingBook/measureDevice'
              to.meta.title = '测量设备'
              break
            case 'standardMatchDevice':
              to.meta.activeMenu = '/standingBook/standardMatchDevice'
              to.meta.title = '校准检定设备'
              break
            case 'adjustDevice':
              to.meta.activeMenu = '/standingBook/adjustDevice'
              to.meta.title = '标准配套设备'
              break
            case 'measureTool':
              to.meta.activeMenu = '/standingBook/measureTool'
              to.meta.title = '测量工装'
              break
            case 'fixedAssets':
              to.meta.activeMenu = '/standingBook/fixedAssets'
              to.meta.title = '固定资产'
              break
          }
          next()
        },
      },
      {
        path: 'fixedAssets',
        name: 'fixedAssets',
        component: () => import('@/views/device/standingBook/fixedAssets.vue'),
        meta: {
          title: '固定资产',
          icon: 'ep:key',
          auth: '/device/fixedAssets',
        },
      },
      // {
      //   path: 'fixAssets/:type/:id?',
      //   name: 'fixedAssetsDetailType',
      //   component: () => import('@/views/device/standingBook/components/fixedAssetsAdd.vue'),
      //   meta: {
      //     title: '固定资产',
      //     icon: 'ep:key',
      //     sidebar: false,
      //     breadcrumb: true,
      //     activeMenu: '/standingBook/fixedAssets',
      //   },
      // },
    ],
  },
  {
    path: '/standard',
    component: Layout,
    redirect: '/standard/list',
    name: 'Standard',
    meta: {
      title: '标准装置',
      icon: 'ep:key',
      auth: '/standardEquipment',
    },
    children: [
      {
        path: 'list',
        name: 'standardList',
        component: () => import('@/views/device/standardEquipment/standardList.vue'),
        meta: {
          title: '标准装置列表',
          icon: 'ep:key',
          auth: '/standard/list',
        },
      },
      {
        path: ':type/:id?',
        name: 'fixedAssetsDetail',
        component: () => import('@/views/device/standardEquipment/components/standardListAdd.vue'),
        meta: {
          title: '标准装置列表',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/standard/list',
        },
      },
      {
        path: 'expirationRemind',
        name: 'expirationRemind',
        component: () => import('@/views/device/standardEquipment/expirationRemind.vue'),
        meta: {
          title: '到期提醒',
          icon: 'ep:key',
          auth: '/standard/expirationRemind',
        },
      },
      // {
      //   path: 'expirationRemind/:type/:id?',
      //   name: 'fixedAssetsDetail',
      //   component: () => import('@/views/device/standardEquipment/components/standardListAdd.vue'),
      //   meta: {
      //     title: '到期提醒',
      //     icon: 'ep:key',
      //     sidebar: false,
      //     breadcrumb: true,
      //     activeMenu: '/standard/expirationRemind',
      //   },
      // },
      {
        path: 'changeApply',
        name: 'changeApply',
        component: () => import('@/views/device/standardEquipment/changeApply.vue'),
        meta: {
          title: '更换申请',
          icon: 'ep:key',
          auth: '/standard/changeApply',
        },
      },
      {
        path: 'pauseApply',
        name: 'pauseApply',
        component: () => import('@/views/device/standardEquipment/pauseApply.vue'),
        meta: {
          title: '暂停申请',
          icon: 'ep:key',
          auth: '/standard/pauseApply',
        },
      },
      {
        path: 'cancelApply',
        name: 'cancelApply',
        component: () => import('@/views/device/standardEquipment/cancelApply.vue'),
        meta: {
          title: '撤销申请',
          icon: 'ep:key',
          auth: '/standard/cancelApply',
        },
      },
      {
        path: 'resumeApply',
        name: 'resumeApply',
        component: () => import('@/views/device/standardEquipment/resumeApply.vue'),
        meta: {
          title: '恢复申请',
          icon: 'ep:key',
          auth: '/standard/resumeApply',
        },
      },
      {
        path: 'checkApply',
        name: 'checkApply',
        component: () => import('@/views/device/standardEquipment/checkApply.vue'),
        meta: {
          title: '复查申请',
          icon: 'ep:key',
          auth: '/standard/checkApply',
        },
      },
      {
        path: ':type/:id?',
        name: 'standardListAdd',
        component: () => import('@/views/device/standardEquipment/components/listApply/listPageAdd.vue'),
        meta: {
          title: '更换申请申请',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/standard/changeApply',
        },
        beforeEnter: (to, from, next) => {
          const type = from.path.split('/')[from.path.split('/').length - 1]
          console.log(type)
          switch (type) {
            case 'changeApply':
              to.meta.activeMenu = '/standard/changeApply'
              to.meta.title = '更换申请'
              break
            case 'pauseApply':
              to.meta.activeMenu = '/standard/pauseApply'
              to.meta.title = '暂停申请'
              break
            case 'cancelApply':
              to.meta.activeMenu = '/standard/cancelApply'
              to.meta.title = '撤销申请'
              break
            case 'resumeApply':
              to.meta.activeMenu = '/standard/resumeApply'
              to.meta.title = '恢复申请'
              break
            case 'checkApply':
              to.meta.activeMenu = '/standard/checkApply'
              to.meta.title = '复查申请'
              break
          }
          next()
        },
      },
    ],
  },
  {
    path: '/stateManage',
    component: Layout,
    redirect: '/stateManage/unusedApply',
    name: 'stateManage',
    meta: {
      title: '状态管理',
      icon: 'ep:key',
      auth: '/device/stateManage',
    },
    children: [
      {
        path: 'unusedApply',
        name: 'unusedApply',
        component: () => import('@/views/device/stateManage/unusedApply.vue'),
        meta: {
          title: '设备闲置申请',
          icon: 'ep:key',
          auth: '/device/unusedApply',
        },
      },
      {
        path: 'sealupApply',
        name: 'sealupApply',
        component: () => import('@/views/device/stateManage/sealupApply.vue'),
        meta: {
          title: '设备封存申请',
          icon: 'ep:key',
          auth: '/device/sealupApply',
        },
      },
      {
        path: 'openApply',
        name: 'openApply',
        component: () => import('@/views/device/stateManage/openApply.vue'),
        meta: {
          title: '设备启封申请',
          icon: 'ep:key',
          auth: '/device/openApply',
        },
      },
      {
        path: 'scrapApply',
        name: 'scrapApply',
        component: () => import('@/views/device/stateManage/scrapApply.vue'),
        meta: {
          title: '设备报废申请',
          icon: 'ep:key',
          auth: '/device/scrapApply',
        },
      },
      {
        path: 'handleApply',
        name: 'handleApply',
        component: () => import('@/views/device/stateManage/handleApply.vue'),
        meta: {
          title: '设备处置申请',
          icon: 'ep:key',
          auth: '/device/handleApply',
        },
      },
      {
        path: ':type/:id?',
        name: 'stateManageDetail',
        component: () => import('@/views/device/stateManage/components/templateAdd.vue'),
        meta: {
          title: '设备闲置申请',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/stateManage/unusedApply',
        },
        beforeEnter: (to, from, next) => {
          const type = from.path.split('/')[from.path.split('/').length - 1]
          console.log(type)
          switch (type) {
            case 'unusedApply':
              to.meta.activeMenu = '/stateManage/unusedApply'
              to.meta.title = '设备闲置申请'
              break
            case 'sealupApply':
              to.meta.activeMenu = '/stateManage/sealupApply'
              to.meta.title = '设备封存申请'
              break
            case 'openApply':
              to.meta.activeMenu = '/stateManage/openApply'
              to.meta.title = '设备启封申请'
              break
            case 'scrapApply':
              to.meta.activeMenu = '/stateManage/scrapApply'
              to.meta.title = '设备报废申请'
              break
            case 'handleApply':
              to.meta.activeMenu = '/stateManage/handleApply'
              to.meta.title = '设备处置申请'
              break
            case 'borrowapply':
              to.meta.activeMenu = '/borrow/borrowapply'
              to.meta.title = '设备借用申请'
              break
            case 'borrowhandle':
              to.meta.activeMenu = '/borrow/borrowhandle'
              to.meta.title = '设备借用处理'
              break
          }
          next()
        },
      },
    ],
  },
  {
    path: '/maintenance',
    component: Layout,
    redirect: '/maintenance/maintenanceList',
    name: 'MaintenanceManage',
    meta: {
      title: '设备维护',
      icon: 'ep:key',
      auth: '/device/maintenance',
    },
    children: [
      {
        path: 'maintenanceList',
        name: 'maintenanceList',
        component: () => import('@/views/device/deviceMaintenance/maintenanceList.vue'),
        meta: {
          title: '设备维护列表',
          icon: 'ep:key',
          auth: '/device/maintenanceList',
        },
      },
      {
        path: 'maintenanceCheckList',
        name: 'maintenanceCheckList',
        component: () => import('@/views/device/deviceMaintenance/maintenanceCheckList.vue'),
        meta: {
          title: '设备检修保养验收单',
          icon: 'ep:key',
          auth: '/device/maintenance/checkList',
        },
      },
      {
        path: 'manageCheckList',
        name: 'manageCheckList',
        component: () => import('@/views/device/deviceMaintenance/manageCheckList.vue'),
        meta: {
          title: '设备管理点检查表',
          icon: 'ep:key',
          auth: '/device/manage/checkList',
        },
      },
      {
        path: 'manageCheckList/:type/:id?',
        name: 'manageAdd',
        component: () => import('@/views/device/deviceMaintenance/components/manageAdd.vue'),
        meta: {
          title: '设备管理点检查表',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/maintenance/manageCheckList',
        },
      },
      {
        path: ':type/:id?',
        name: 'maintenanceAdd',
        component: () => import('@/views/device/deviceMaintenance/components/listApply/listPageAdd.vue'),
        meta: {
          title: '设备维护列表',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/maintenance/maintenanceList',
        },
        beforeEnter: (to, from, next) => {
          const type = from.path.split('/')[from.path.split('/').length - 1]
          console.log(type)
          switch (type) {
            case 'maintenanceList':
              to.meta.activeMenu = '/maintenance/maintenanceList'
              to.meta.title = '设备维护列表'
              break
            case 'maintenanceCheckList':
              to.meta.activeMenu = '/maintenance/maintenanceCheckList'
              to.meta.title = '设备检修保养验收单'
              break
            case 'manageCheckList':
              to.meta.activeMenu = '/maintenance/manageCheckList'
              to.meta.title = '设备管理点检查表'
              break
          }
          next()
        },
      },
    ],
  },
  {
    path: '/receive',
    component: Layout,
    redirect: '/device/receive/applyList',
    name: 'Receive',
    meta: {
      title: '设备领用',
      icon: 'ep:key',
      auth: '/device/receive',
    },
    children: [
      {
        path: 'applyList',
        name: 'ApplyList',
        component: () => import('@/views/device/receive/applyList.vue'),
        meta: {
          title: '设备领用申请',
          icon: 'ep:key',
          auth: '/device/receive/applyList',
        },
      },
      {
        path: ':type',
        name: 'ApplyListDetail',
        component: () => import('@/views/device/receive/createOrCheck.vue'),
        meta: {
          title: '设备领用申请',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/receive/applyList',
        },
      },
      {
        path: 'solveList',
        name: 'SolveList',
        component: () => import('@/views/device/receive/solveList.vue'),
        meta: {
          title: '设备领用处理',
          icon: 'ep:key',
          auth: '/device/receive/solveList',
        },
      },
      {
        path: 'solveDetail',
        name: 'SolveListDetail',
        component: () => import('@/views/device/receive/solveComponent/detail.vue'),
        meta: {
          title: '设备领用处理',
          icon: 'ep:key',
          sidebar: false,
          breadcrumb: true,
          activeMenu: '/receive/solveList',
        },
      },
    ],
  },
  {
    path: '/borrow',
    component: Layout,
    redirect: '/device/borrow/borrowapply',
    name: 'Borrow',
    meta: {
      title: '设备领用',
      icon: 'ep:key',
      auth: '/device/borrow',
    },
    children: [
      {
        path: 'borrowapply',
        name: 'borroWapply',
        component: () => import('@/views/device/borrow/borrwoApply.vue'),
        meta: {
          title: '设备借用申请',
          icon: 'ep:key',
          auth: '/device/borrow/borrowapply',
        },
      },
      {
        path: 'borrowhandle',
        name: 'borrowHandle',
        component: () => import('@/views/device/borrow/borrowHandle.vue'),
        meta: {
          title: '设备借用处理',
          icon: 'ep:key',
          auth: '/device/borrow/borrowhandle',
        },
      },
    ],
  },

]

export default routes
