|
|
|
|
import Vue from "vue";
|
|
|
|
|
import Router from "vue-router";
|
|
|
|
|
// 问卷
|
|
|
|
|
import NoTopLayout from "@/components/layouts/NoTopLayout.vue";
|
|
|
|
|
import DwSurveyAttr from "@/views/dw-survey/dw-collect/DwSurveyAttr";
|
|
|
|
|
import DwAnswerUrl from "@/views/dw-survey/dw-collect/DwAnswerUrl";
|
|
|
|
|
import DwSiteComp from "@/views/dw-survey/dw-collect/DwSiteComp";
|
|
|
|
|
import DwSiteShare from "@/views/dw-survey/dw-collect/DwSiteShare";
|
|
|
|
|
import DwAnswerWeixin from "@/views/dw-survey/dw-collect/DwAnswerWeixin";
|
|
|
|
|
import DwSurveyCharts from "@/views/dw-survey/dw-data/DwSurveyCharts";
|
|
|
|
|
import DwSurveyAnswer from "@/views/dw-survey/dw-data/DwSurveyAnswer";
|
|
|
|
|
import DwSurveyAnswerInfo from "@/views/dw-survey/dw-data/DwSurveyAnswerInfo";
|
|
|
|
|
|
|
|
|
|
Vue.use(Router);
|
|
|
|
|
/* Layout */
|
|
|
|
|
import Layout from "@/layout";
|
|
|
|
|
import api from "@/api/Myapi/login";
|
|
|
|
|
// 公共路由
|
|
|
|
|
//因为本项目分为三个,管理后台,要根据字段区分
|
|
|
|
|
let Login_index = localStorage.getItem("Login_index");
|
|
|
|
|
// 获取main 中存的路由信息,monitor专属信息
|
|
|
|
|
let monitor_Router = JSON.parse(
|
|
|
|
|
localStorage.getItem("DongtrouterList_router")
|
|
|
|
|
)?.find((res) => {
|
|
|
|
|
return res.menuUrl == "monitor";
|
|
|
|
|
});
|
|
|
|
|
let convenient_Router = JSON.parse(
|
|
|
|
|
localStorage.getItem("DongtrouterList_router")
|
|
|
|
|
)?.find((res) => {
|
|
|
|
|
return res.menuUrl == "convenient";
|
|
|
|
|
});
|
|
|
|
|
export const constantRoutes = [
|
|
|
|
|
// 调查问卷
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/c/attr/:id",
|
|
|
|
|
name: "DwSurveyAttr",
|
|
|
|
|
component: DwSurveyAttr,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/c/url/:id",
|
|
|
|
|
name: "DwAnswerUrl",
|
|
|
|
|
component: DwAnswerUrl,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/c/comp/:id",
|
|
|
|
|
name: "DwSiteComp",
|
|
|
|
|
component: DwSiteComp,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/c/share/:id",
|
|
|
|
|
name: "DwSiteShare",
|
|
|
|
|
component: DwSiteShare,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/c/weixin/:id",
|
|
|
|
|
name: "DwAnswerWeixin",
|
|
|
|
|
component: DwAnswerWeixin,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/d/chart/:id",
|
|
|
|
|
name: "DwSurveyCharts",
|
|
|
|
|
component: DwSurveyCharts,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/d/data/:id",
|
|
|
|
|
name: "DwSurveyAnswer",
|
|
|
|
|
component: DwSurveyAnswer,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/no-top",
|
|
|
|
|
name: "NoTopLayout",
|
|
|
|
|
component: NoTopLayout,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: "/no-top/dw-survey/d/data/:id/:answerId",
|
|
|
|
|
name: "DwSurveyAnswerInfo",
|
|
|
|
|
component: DwSurveyAnswerInfo,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw-survey/d/data/:id/:answerId",
|
|
|
|
|
name: "DwSurveyAnswerInfo",
|
|
|
|
|
component: DwSurveyAnswerInfo,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/dw/survey/back",
|
|
|
|
|
name: "DwSurveyBack",
|
|
|
|
|
component: (resolve) => require(["@/views/dw-survey/DwBack"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/redirect",
|
|
|
|
|
component: Layout,
|
|
|
|
|
hidden: true,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: "/redirect/:path(.*)",
|
|
|
|
|
component: () => import("@/views/redirect"),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/login",
|
|
|
|
|
name: "login",
|
|
|
|
|
component: () => import("@/views/login"),
|
|
|
|
|
hidden: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/register",
|
|
|
|
|
component: () => import("@/views/register"),
|
|
|
|
|
hidden: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/404",
|
|
|
|
|
component: () => import("@/views/error/404"),
|
|
|
|
|
hidden: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: "/401",
|
|
|
|
|
component: () => import("@/views/error/401"),
|
|
|
|
|
hidden: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
// path: "",
|
|
|
|
|
// component: Layout,
|
|
|
|
|
// redirect: "index",
|
|
|
|
|
// children: [
|
|
|
|
|
// {
|
|
|
|
|
// path: "index",
|
|
|
|
|
// component: () => import("@/views/index"),
|
|
|
|
|
// name: "Index",
|
|
|
|
|
// meta: { title: "首页", icon: "dashboard", affix: true },
|
|
|
|
|
// },
|
|
|
|
|
// ],
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
path: "/",
|
|
|
|
|
// component: Layout,
|
|
|
|
|
redirect: {
|
|
|
|
|
name:
|
|
|
|
|
Login_index == "1" ? "monitor" : Login_index == "2" ? "convenient" : "",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
path: "/user",
|
|
|
|
|
component: Layout,
|
|
|
|
|
hidden: true,
|
|
|
|
|
redirect: "noredirect",
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: "profile",
|
|
|
|
|
component: () => import("@/views/system/user/profile/index"),
|
|
|
|
|
name: "Profile",
|
|
|
|
|
meta: { title: "个人中心", icon: "user" },
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
//自定义默认首页
|
|
|
|
|
// {
|
|
|
|
|
// path: "",
|
|
|
|
|
// redirect: "/home",
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
// !监管端
|
|
|
|
|
{
|
|
|
|
|
path: "/monitor",
|
|
|
|
|
name: "monitor",
|
|
|
|
|
// 设置默认路由,因为 monitor 一级路由仅是管理框架,包含了头部侧边栏,contenr 内容区域需要二级路由支撑。所以要根据main更新的路由表进行配置
|
|
|
|
|
redirect: {
|
|
|
|
|
name: monitor_Router?.childMenuList[0].menuUrl.split("/")[2] || "",
|
|
|
|
|
},
|
|
|
|
|
component: (resolve) => require(["@/pages/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
// 填报任务
|
|
|
|
|
path: "FillingTask",
|
|
|
|
|
name: "FillingTask",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/FillingTask/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "填报任务管理",
|
|
|
|
|
routerIndex: "0-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// 药品召回
|
|
|
|
|
{
|
|
|
|
|
path: "FilingRecall",
|
|
|
|
|
name: "FilingRecall",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/FilingRecall/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "药品召回管理",
|
|
|
|
|
routerIndex: "1-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 医疗
|
|
|
|
|
path: "FilingMachinery",
|
|
|
|
|
name: "FilingMachinery",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/FilingMachinery/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "医疗器械召回管理",
|
|
|
|
|
routerIndex: "1-2",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 药品企业年报
|
|
|
|
|
path: "FilingLecture",
|
|
|
|
|
name: "FilingLecture",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/FilingLecture/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "企业年报管理",
|
|
|
|
|
routerIndex: "2-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 药品企业统计
|
|
|
|
|
path: "FilingTongji",
|
|
|
|
|
name: "FilingTongji",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/FilingTongji/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "年报数据统计",
|
|
|
|
|
routerIndex: "2-2",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 通知管理
|
|
|
|
|
path: "Tongzhigonggao",
|
|
|
|
|
name: "Tongzhigonggao",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/Tongzhigonggao/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "通知公告",
|
|
|
|
|
routerIndex: "3-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 操作指南
|
|
|
|
|
path: "FilingCaozuo",
|
|
|
|
|
name: "FilingCaozuo",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/FilingCaozuo/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "操作指南",
|
|
|
|
|
routerIndex: "4-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 政策管理
|
|
|
|
|
path: "PolicyManagement",
|
|
|
|
|
name: "PolicyManagement",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/pages/PolicyManagement/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "政策管理",
|
|
|
|
|
routerIndex: "5-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// !便民服务端
|
|
|
|
|
{
|
|
|
|
|
path: "/convenient",
|
|
|
|
|
name: "convenient",
|
|
|
|
|
redirect: {
|
|
|
|
|
name: convenient_Router?.childMenuList[0].menuUrl.split("/")[2] || "",
|
|
|
|
|
},
|
|
|
|
|
component: (resolve) => require(["@/viewsBM/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
// 填报任务
|
|
|
|
|
path: "MedData",
|
|
|
|
|
name: "MedData",
|
|
|
|
|
component: (resolve) =>
|
|
|
|
|
require(["@/viewsBM/MedData/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "药品知识",
|
|
|
|
|
routerIndex: "0-1",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// 填报任务
|
|
|
|
|
path: "test",
|
|
|
|
|
name: "test",
|
|
|
|
|
component: (resolve) => require(["@/viewsBM/test/index.vue"], resolve),
|
|
|
|
|
hidden: true,
|
|
|
|
|
meta: {
|
|
|
|
|
name: "测试页面",
|
|
|
|
|
routerIndex: "0-2",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
// 防止连续点击多次路由报错
|
|
|
|
|
let routerPush = Router.prototype.push;
|
|
|
|
|
let routerReplace = Router.prototype.replace;
|
|
|
|
|
// push
|
|
|
|
|
Router.prototype.push = function push(location) {
|
|
|
|
|
return routerPush.call(this, location).catch((err) => err);
|
|
|
|
|
};
|
|
|
|
|
// replace
|
|
|
|
|
Router.prototype.replace = function push(location) {
|
|
|
|
|
return routerReplace.call(this, location).catch((err) => err);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const router = new Router({
|
|
|
|
|
// mode: "history", // 去掉url中的#
|
|
|
|
|
scrollBehavior: () => ({ y: 0 }),
|
|
|
|
|
routes: [],
|
|
|
|
|
// routes: constantRoutes,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
async function getConstantRoutes() {
|
|
|
|
|
// 这里调接口的原因是,如果获取 localStorage 的数据,会导致更新不及时,await不等待等问题
|
|
|
|
|
|
|
|
|
|
// 调取接口,获取 monitor 的路由信息
|
|
|
|
|
// ! getuserinfo 对外
|
|
|
|
|
// ! frimUserInfo 对内
|
|
|
|
|
// let response = await api.frimUserInfo({
|
|
|
|
|
// token: localStorage.getItem("MSSM-LIAONING__TOKEN"),
|
|
|
|
|
// });
|
|
|
|
|
// response = response.data;
|
|
|
|
|
|
|
|
|
|
let response = await api.getuserinfo();
|
|
|
|
|
|
|
|
|
|
if (response.result.userDto.username == "admin") {
|
|
|
|
|
return constantRoutes;
|
|
|
|
|
} else {
|
|
|
|
|
let RouterList = response?.result.menuTree;
|
|
|
|
|
console.log(RouterList);
|
|
|
|
|
let DongtrouterList = RouterList.find((res) => {
|
|
|
|
|
return res.menuUrl == "monitor";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let convenient = RouterList.find((res) => {
|
|
|
|
|
return res.menuUrl == "convenient";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// // 公共企业监管端数据
|
|
|
|
|
localStorage.setItem("monitor_list", JSON.stringify(DongtrouterList));
|
|
|
|
|
localStorage.setItem("convenient_list", JSON.stringify(convenient));
|
|
|
|
|
|
|
|
|
|
// 对原静态路由表下的 monitor 一级路由的 children 进行筛选过滤--目的解决在url地址栏输入地址可直接跳过去的问题
|
|
|
|
|
// 其实在路由拦截也可以直接拦截到--但是这样标准点吧
|
|
|
|
|
constantRoutes.find((item) => item.name == "monitor").children =
|
|
|
|
|
constantRoutes
|
|
|
|
|
.find((item) => item.name == "monitor")
|
|
|
|
|
.children.filter((item) => {
|
|
|
|
|
const subMenus = DongtrouterList.childMenuList.filter((subItem) => {
|
|
|
|
|
return subItem.menuName == item.meta.name;
|
|
|
|
|
});
|
|
|
|
|
return subMenus.length > 0;
|
|
|
|
|
});
|
|
|
|
|
// constantRoutes.find((item) => item.name == "convenient").children =
|
|
|
|
|
// constantRoutes
|
|
|
|
|
// .find((item) => item.name == "convenient")
|
|
|
|
|
// .children.filter((item) => {
|
|
|
|
|
// const subMenus = convenient.childMenuList.filter((subItem) => {
|
|
|
|
|
// return subItem.menuName == item.meta.name;
|
|
|
|
|
// });
|
|
|
|
|
// return subMenus.length > 0;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
return constantRoutes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(async function initializeRouter() {
|
|
|
|
|
const constantRoutes = await getConstantRoutes(); // 使用 async/await 等待异步请求结束,并获取返回结果
|
|
|
|
|
router.addRoutes(constantRoutes); // 将路由配置添加到路由对象中
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
export default router;
|