import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
const layout = () => import("@/layout/index.vue");

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "主页",
    redirect: "/home"
  },
  {
    path: "/login",
    name: "登录",
    component: () => import("@/views/login/index.vue")
  },
  {
    path: "/InformationFilling",
    name: "InformationFilling",
    redirect: "/InformationFilling/outWarehouseInfo",
    component: layout,
    children: [
      {
        path: "outWarehouseInfoDetail",
        name: "出库信息填报详情",
        component: () => import("@/views/InformationFilling/outWarehouseInfo/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "enterWarehouseInfoDetail",
        name: "入库信息填报详情",
        component: () => import("@/views/InformationFilling/enterWarehouseInfo/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "outIssueDetail",
        name: "出库信息下发详情",
        component: () => import("@/views/InformationFilling/outIssue/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  },
  {
    path: "/InformationAudit",
    name: "InformationAudit",
    redirect: "/InformationAudit/outWarehouseAudit",
    component: layout,
    children: [
      {
        path: "outWarehouseAuditDetail",
        name: "出库信息审核详情",
        component: () => import("@/views/InformationAudit/outWarehouseAudit/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "enterWarehouseAuditDetail",
        name: "入库信息审核详情",
        component: () => import("@/views/InformationAudit/enterWarehouseAudit/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  },
  {
    path: "/transportationMng",
    name: "transportationMng",
    redirect: "/transportationMng/driverMng",
    component: layout,
    children: [
      {
        path: "driverMngDetail",
        name: "司机管理详情",
        component: () => import("@/views/transportationMng/driverMng/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "vehicleMngDetail",
        name: "车辆管理详情",
        component: () => import("@/views/transportationMng/vehicleMng/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  },
  {
    path: "/Powermanagement",
    name: "Powermanagement",
    redirect: "/Powermanagement/vehicles",
    component: layout,
    children: [
      {
        path: "vehiclesDetail",
        name: "调运车辆动力管理详情",
        component: () => import("@/views/Powermanagement/vehicles/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "PositioningDetail",
        name: "在途定位车辆管理详情",
        component: () => import("@/views/Powermanagement/Positioning/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  },
  {
    path: "/dataStatistics",
    name: "dataStatistics",
    redirect: "/dataStatistics/components",
    component: layout,
    children: [
      {
        path: "DataStatisticsDetail",
        name: "维护保养统计明细详情",
        component: () => import("@/views/dataStatistics/components/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "WarningDetail",
        name: "维护保养统计明细详情",
        component: () => import("@/views/dataStatistics/warning/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  },
  {
    path: "/upkeep",
    name: "upkeep",
    redirect: "/upkeep/report",
    component: layout,
    children: [
      {
        path: "ReportDetail",
        name: "维护保养详情",
        component: () => import("@/views/upkeep/report/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "AuditingDetail",
        name: "维护保养审核详情",
        component: () => import("@/views/upkeep/Auditing/detail.vue"),
        props(route) {
          return route.query;
        }
      },
      {
        path: "StatisticsDetail",
        name: "维护保养仓库统计表详情",
        component: () => import("@/views/upkeep/statistics/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  },
  {
    path: "/equipmentFailure",
    name: "equipmentFailure",
    redirect: "/equipmentFailure/faultMng",
    component: layout,
    children: [
      {
        path: "faultMngDetail",
        name: "设备类物资故障详情",
        component: () => import("@/views/equipmentFailure/faultMng/detail.vue"),
        props(route) {
          return route.query;
        }
      }
    ]
  }
];

const baseRoutes: Array<RouteRecordRaw> = [
  {
    path: "/shuju",
    name: "数据可视化",
    component: () => import("@/views/DataVisualization/home/index.vue")
  },
  {
    path: "/DataVisualization/detailPage",
    name: "detailPage",
    component: () => import("@/views/DataVisualization/detailPage/index.vue")
  },
  {
    path: "/home",
    name: "home",
    redirect: "/home/index",
    component: layout,
    meta: {
      isKeepAlive: true
    },
    children: [
      {
        path: "index",
        name: "首页",
        component: () => import("@/views/home/index.vue")
      }
    ]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: [...baseRoutes, ...routes]
});
// avueRouter.install(router, store);
// router.$avueRouter.formatRoutes(store.state.user.menu, true);

export default router;
