董国庆
2025-05-20 06b2be3bbb48e0275fbd25624c1cce54a7cac2b1
culture/src/router/index.js
@@ -1,14 +1,14 @@
import Vue from "vue";
import VueRouter from "vue-router";
import Layouts from "../layouts";
import Parent from "../layouts/components/AppContent"
import Parent from "../layouts/components/AppContent";
import store from "../store";
Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
  return originalPush.call(this, location).catch((err) => err);
};
/**
 *  path: "/login",   ------页面地址
@@ -79,8 +79,8 @@
                    hide: true,
                },
                component: () => import("../views/projectList/detailProject"),
            }
        ]
      },
    ],
    },
    {
        path: "/system",
@@ -139,7 +139,7 @@
                },
                component: () => import("../views/system/operation-log"),
            },
        ]
    ],
    },
    {
        path: "/strain",
@@ -162,7 +162,8 @@
                            title: "原始细胞库",
                            keepAlive: true,
                        },
                        component: () => import("../views/strain-library/strain-library-manage"),
            component: () =>
              import("../views/strain-library/strain-library-manage"),
                    },
                    {
                        path: "strain-library-manage/add",
@@ -170,19 +171,23 @@
                        meta: {
                            title: "新增原始细胞库",
                            keepAlive: true,
                            hide: true
              hide: true,
                        },
                        component: () => import("../views/strain-library/strain-library-manage/add.vue"),
            component: () =>
              import("../views/strain-library/strain-library-manage/add.vue"),
                    },
                    {
                        path: "strain-library-manage/record",
                        name: "StrainRecord",
                        meta: {
                            title: "出入库记录",
                            keepAlive: true,
                            hide: true
              hide: true,
                        },
                        component: () => import("../views/strain-library/strain-library-manage/record.vue"),
            component: () =>
              import(
                "../views/strain-library/strain-library-manage/record.vue"
              ),
                    },
                    {
                        path: "main-cell-library",
@@ -191,7 +196,8 @@
                            title: "主细胞库",
                            keepAlive: true,
                        },
                        component: () => import("../views/strain-library/main-cell-library"),
            component: () =>
              import("../views/strain-library/main-cell-library"),
                    },
                    {
                        path: "main-cell-library/add",
@@ -199,9 +205,10 @@
                        meta: {
                            title: "新增主细胞",
                            keepAlive: true,
                            hide: true
              hide: true,
                        },
                        component: () => import("../views/strain-library/main-cell-library/add.vue"),
            component: () =>
              import("../views/strain-library/main-cell-library/add.vue"),
                    },
                    {
                        path: "production-cell-library",
@@ -210,7 +217,8 @@
                            title: "生产细胞库",
                            keepAlive: true,
                        },
                        component: () => import("../views/strain-library/production-cell-library"),
            component: () =>
              import("../views/strain-library/production-cell-library"),
                    },
                    {
                        path: "production-cell-library/add",
@@ -218,35 +226,36 @@
                        meta: {
                            title: "新增生产细胞",
                            keepAlive: true,
                            hide: true
              hide: true,
                        },
                        component: () => import("../views/strain-library/production-cell-library/add.vue"),
                    }
                ]
            component: () =>
              import("../views/strain-library/production-cell-library/add.vue"),
          },
        ],
            },
            {
                path: 'pedigree-vhart',
                name: 'PedigreeChart',
        path: "pedigree-vhart",
        name: "PedigreeChart",
                meta: {
                    title: "菌种传代生产谱系图",
                },
                component: () => import("../views/pedigree-chart"),
            },
            {
                path: 'add-pedigree',
                name: 'AddPedigree',
        path: "add-pedigree",
        name: "AddPedigree",
                meta: {
                    title: "新增母代菌种传代生产谱系图",
                    hide: true
          hide: true,
                },
                component: () => import("../views/pedigree-chart/add"),
            },
            {
                path: 'add-progenitor',
                name: 'AddProgenitor',
        path: "add-progenitor",
        name: "AddProgenitor",
                meta: {
                    title: "新增祖代菌种传代生产谱系图",
                    hide: true
          hide: true,
                },
                component: () => import("../views/pedigree-chart/addProgenitor"),
            },
@@ -260,16 +269,16 @@
            //     component: () => import("../views/strain-library/strain-flow-chart"),
            // },
            {
                path: 'breeding-record',
                name: 'BreedingRecord',
        path: "breeding-record",
        name: "BreedingRecord",
                meta: {
                    title: "菌种选育保藏记录",
                },
                component: () => import("../views/strain-library/breeding-record"),
            },
            {
                path: 'add-breeding-record',
                name: 'AddBreedingRecord',
        path: "add-breeding-record",
        name: "AddBreedingRecord",
                meta: {
                    title: "新增菌种选育保藏记录",
                    hide: true,
@@ -277,62 +286,75 @@
                component: () => import("../views/strain-library/breeding-record/add"),
            },
            {
                path: 'validation',
        path: "validation",
                meta: {
                    title: "菌种验证数据资料",
                },
                component: Parent,
                children: [
                    {
                        path: 'primitive-cell',
                        name: 'PrimitiveCell',
            path: "primitive-cell",
            name: "PrimitiveCell",
                        meta: {
                            title: '原始细胞库资料',
              title: "原始细胞库资料",
                        },
                        component: () => import("../views/strain-library/validation/primitive-cell/index.vue")
            component: () =>
              import(
                "../views/strain-library/validation/primitive-cell/index.vue"
              ),
                    },
                    {
                        path: 'add-primitive-cell',
                        name: 'AddPrimitiveCell',
            path: "add-primitive-cell",
            name: "AddPrimitiveCell",
                        meta: {
                            title: '新增原始细胞库资料',
                            hide: true
              title: "新增原始细胞库资料",
              hide: true,
                        },
                        component: () => import("../views/strain-library/validation/primitive-cell/add.vue")
            component: () =>
              import(
                "../views/strain-library/validation/primitive-cell/add.vue"
              ),
                    },
                    {
                        path: 'confirm-detail',
                        name: 'ConfirmDetail',
            path: "confirm-detail",
            name: "ConfirmDetail",
                        meta: {
                            title: '确认原始细胞库资料',
                            hide: true
              title: "确认原始细胞库资料",
              hide: true,
                        },
                        component: () => import("../views/strain-library/validation/primitive-cell/confirm-detail.vue")
            component: () =>
              import(
                "../views/strain-library/validation/primitive-cell/confirm-detail.vue"
              ),
                    },
                    {
                        path: 'chief-cell',
                        name: 'ChiefCell',
            path: "chief-cell",
            name: "ChiefCell",
                        meta: {
                            title: '主细胞库资料'
              title: "主细胞库资料",
                        },
                        component: () => import("../views/strain-library/validation/chief-cell")
                    }
                ]
            component: () =>
              import("../views/strain-library/validation/chief-cell"),
            },
        ]
    }, {
        ],
      },
    ],
  },
  {
        path: "/strainReportLibrary",
        component: Layouts,
        meta: {
            title: "菌种报告库",
        },
        children: [{
    children: [
      {
            path: "reportLibraryOne",
            meta: {
                title: "报告库一",
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOne/index.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOne/index.vue"),
        },
        {
            path: "add",
@@ -341,7 +363,8 @@
                hide: true,
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOne/add.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOne/add.vue"),
        },
        {
            path: "reportLibraryTwo",
@@ -349,7 +372,8 @@
                title: "报告库二",
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOneTWO/index.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOneTWO/index.vue"),
        },
        {
            path: "addTwo",
@@ -358,7 +382,8 @@
                hide: true,
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOneTWO/add.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOneTWO/add.vue"),
        },
        {
            path: "reportLibraryThree",
@@ -366,7 +391,10 @@
                title: "报告库三",
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOneThree/index.vue"),
        component: () =>
          import(
            "../views/strainReportLibrary/reportLibraryOneThree/index.vue"
          ),
        },
        {
            path: "addThree",
@@ -375,7 +403,8 @@
                hide: true,
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOneThree/add.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOneThree/add.vue"),
        },
        {
            path: "reportLibraryFour",
@@ -383,7 +412,8 @@
                title: "报告库四",
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOneFour/index.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOneFour/index.vue"),
        },
        {
            path: "addFour",
@@ -392,9 +422,9 @@
                hide: true,
                keepAlive: true,
            },
            component: () => import("../views/strainReportLibrary/reportLibraryOneFour/add.vue"),
        component: () =>
          import("../views/strainReportLibrary/reportLibraryOneFour/add.vue"),
        },
        ],
    },
    {
@@ -403,23 +433,26 @@
        meta: {
            title: "菌种报告评定",
        },
        children: [{
    children: [
      {
            path: "projectTeamIntegral",
            meta: {
                title: "菌种项目组评定表",
            },
            component: () => import("../views/deliveryAssessment/projectTeamIntegral"),
        component: () =>
          import("../views/deliveryAssessment/projectTeamIntegral"),
        },
        {
            path: "projectTeamIntegral-detail",
            meta: {
                title: "评定详情",
                hide: true
          hide: true,
            },
            component: () => import("../views/deliveryAssessment/projectTeamIntegral/detail.vue"),
        component: () =>
          import("../views/deliveryAssessment/projectTeamIntegral/detail.vue"),
        },
        ]
    }
    ],
  },
];
const router = new VueRouter({
@@ -431,13 +464,13 @@
// 前置路由拦截器
router.beforeEach((to, from, next) => {
    // 设置当前页签名称
    document.title = to.meta.title || '实验室流程';
  document.title = to.meta.title || "实验室流程";
    // 登录验证
    // 排除登录页的校验
    if (to.path === "/login") {
        if (sessionStorage.getItem('token')) {
            next('/projectList');  // 已登录状态访问登录页时重定向到系统首页
    if (sessionStorage.getItem("token")) {
      next("/projectList"); // 已登录状态访问登录页时重定向到系统首页
            return;
        }
        next();
@@ -445,23 +478,26 @@
    }
    // 登录状态校验
    const isAuthenticated = sessionStorage.getItem('token');
  const isAuthenticated = sessionStorage.getItem("token");
    if (!isAuthenticated) {
        next('/login');  // 未登录用户重定向到登录页
    next("/login"); // 未登录用户重定向到登录页
        return;
    }
    // 判断是否拥有要跳转菜单权限
    let menus = store.state.menus
    if (to.meta.hasOwnProperty('privilege') && !menus.includes(to.meta.privilege)) {
        return
  let menus = store.state.menus;
  if (
    to.meta.hasOwnProperty("privilege") &&
    !menus.includes(to.meta.privilege)
  ) {
    return;
    }
    // 设置标签列表
    if (!to.meta.hide || !to.meta.oneself) {
        let tagList = JSON.parse(sessionStorage.getItem('tagList') || '[]')
    let tagList = JSON.parse(sessionStorage.getItem("tagList") || "[]");
        // 判断是否存在
        let isExist = tagList.some(item => item.path === to.path)
    let isExist = tagList.some((item) => item.path === to.path);
        if (!isExist) {
            // 只保存必要的信息
            const tagInfo = {
@@ -469,26 +505,28 @@
                name: to.name,
                meta: to.meta,
                query: to.query,
            }
            tagList.push(tagInfo)
            sessionStorage.setItem('tagList', JSON.stringify(tagList))
            store.commit('SET_TAGLIST', tagList)
      };
      tagList.push(tagInfo);
      sessionStorage.setItem("tagList", JSON.stringify(tagList));
      store.commit("SET_TAGLIST", tagList);
        }
    }
    // 判断是否需要缓存
    if (to.meta.keepAlive) {
        let keepAliveList = JSON.parse(sessionStorage.getItem('keepAliveList') || '[]')
    let keepAliveList = JSON.parse(
      sessionStorage.getItem("keepAliveList") || "[]"
    );
        // 判断是否已经缓存
        let isExist = keepAliveList.includes(to.name)
    let isExist = keepAliveList.includes(to.name);
        if (!isExist) {
            keepAliveList.push(to.name)
            sessionStorage.setItem('keepAliveList', JSON.stringify(keepAliveList))
            store.commit('SET_KEEPALIVELIST', keepAliveList)
      keepAliveList.push(to.name);
      sessionStorage.setItem("keepAliveList", JSON.stringify(keepAliveList));
      store.commit("SET_KEEPALIVELIST", keepAliveList);
        }
    }
    next()
  next();
});
export default router;