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;
        }
      }
    ]
  }
];

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;
