import { useUserStore } from "@/store/modules/user";

const Layout = () => import("@/layout/index.vue");
export default {
  path: "/",
  name: "/",
  component: Layout,
  redirect: "/process",
  children: [
    {
      path: "process",
      component: () => import("@/views/process/main.vue"),
      name: "ProcessMain",
      meta: {
        title: "process",
      },
    },
    {
      path: "pro-steps",
      component: () => import("@/views/pro-steps/index.vue"),
      name: "ProSteps",
      meta: {
        title: "",
        keepAlive: true,
        back: true,
      },
      children: [
        {
          path: "dianjian",
          component: () => import("@/views/pro-steps/components/dianjian.vue"),
          name: "Dianjian",
          meta: {
            back: true,
          },
        },
        {
          path: "duomeiticaiji",
          component: () =>
            import("@/views/pro-steps/components/duomeiticaiji.vue"),
          name: "Duomeiticaiji",
          meta: {
            back: true,
          },
        },

        {
          path: "esop",
          component: () => import("@/views/pro-steps/components/ESOP.vue"),
          name: "Esop",
          meta: {
            back: true,
          },
        },
        {
          path: "jingu",
          component: () => import("@/views/pro-steps/components/jingu.vue"),
          name: "Jingu",
          meta: {
            back: true,
          },
        },
        {
          path: "excel",
          component: () => import("@/views/pro-steps/components/excel.vue"),
          name: "Excel",
          meta: {
            back: true,
          },
        },
        {
          path: "mingpaibangding",
          component: () =>
            import("@/views/pro-steps/components/mingpaibangding.vue"),
          name: "Mingpaibangding",
          meta: {
            back: true,
          },
        },
        {
          path: "jiluxiang",
          component: () => import("@/views/pro-steps/components/jiluxiang.vue"),
          name: "Jiluxiang",
          meta: {
            back: true,
            keepAlive: true,
          },
        },
        {
          path: "shebeijilu",
          component: () =>
            import("@/views/pro-steps/components/shebeijilu.vue"),
          name: "Shebeijilu",
          meta: {
            back: true,
          },
        },
        {
          path: "tiaoshipipei",
          component: () =>
            import("@/views/pro-steps/components/tiaoshipipei.vue"),
          name: "Tiaoshipipei",
          meta: {
            back: true,
          },
        },
        {
          path: "wuliaocaiji",
          component: () =>
            import("@/views/pro-steps/components/wuliaocaiji.vue"),
          name: "Wuliaocaiji",
          meta: {
            back: true,
            keepAlive: true,
          },
        },
        {
          path: "ceshishuju",
          component: () =>
            import("@/views/pro-steps/components/ceshishuju.vue"),
          name: "Ceshishuju",
          meta: {
            back: true,
            keepAlive: true,
          },
        },
        {
          path: "screwdriver",
          component: () =>
            import("@/views/pro-steps/components/screwdriver.vue"),
          name: "Screwdriver",
          meta: {
            back: true,
            keepAlive: true,
          },
        },
        {
          path: "gongxuwenjian",
          component: () =>
            import("@/views/pro-steps/components/gongxuwenjian.vue"),
          name: "Gongxuwenjian",
          meta: {
            back: true,
            keepAlive: true,
          },
        },
      ],
    },
    {
      path: "call-materiel",
      component: () => import("@/views/pro-operation/call-materiel/index.vue"),
      name: "call-materiel",
      meta: {
        title: "叫料",
        back: true,
      },
    },
    {
      path: "drawing",
      component: () => import("@/views/pro-operation/drawing/index.vue"),
      name: "drawing-list",
      meta: {
        title: "图纸资料",
        back: true,
      },
    },
    {
      path: "appoint",
      component: () => import("@/views/pro-operation/appoint-out/index.vue"),
      name: "appoint-out",
      meta: {
        title: "委外",
        back: true,
      },
    },
    {
      path: "printing-plate",
      component: () => import("@/views/pro-operation/printing-plate/index.vue"),
      name: "printing-plate",
      meta: {
        title: "印刷板",
        back: true,
      },
    },
    {
      path: "material-flow",
      component: () => import("@/views/material-flow/index.vue"),
      name: "material-flow",
      meta: {
        title: "物料流转",
        back: true,
      },
    },
    {
      path: "station-up-material",
      component: () =>
        import("@/views/pro-operation/station-up-material/index.vue"),
      name: "station-up-material",
      meta: {
        title: "工位上料",
        back: true,
      },
    },
    {
      path: "traceability/:id?",
      component: () => import("@/views/traceability/index.vue"),
      name: "traceability",
      meta: {
        title: "生产履历",
        back: true,
      },
    },
    {
      path: "checkOut",
      component: () => import("@/views/pro-operation/check-out/index.vue"),
      name: "checkOut",
      meta: {
        title: "检验",
        back: true,
      },
    },
    {
      path: "rework",
      component: () => import("@/views/pro-operation/rework/index.vue"),
      name: "rework",
      meta: {
        title: "返工",
        back: true,
      },
    },
    {
      path: "remove",
      component: () => import("@/views/pro-operation/remove/index.vue"),
      name: "remove",
      meta: {
        title: "剔除",
        back: true,
      },
    },
    {
      path: "pdmfile",
      component: () => import("@/views/pro-operation/pdm-file/index.vue"),
      name: "pdmfile",
      meta: {
        title: "产品文档",
        back: true,
      },
    },
  ],
  beforeEnter: (to, from, next) => {
    const store = useUserStore();
    if (store.user.stationType == "5") {
      next({ path: "/prepare" });
    } else {
      next();
    }
  },
};
