337 lines
8.0 KiB
JavaScript
337 lines
8.0 KiB
JavaScript
import { currentRole } from "@/api/system/role";
|
|
import Vue from "vue";
|
|
import Router from "vue-router";
|
|
|
|
Vue.use(Router);
|
|
|
|
/* Layout */
|
|
import Layout from "@/layout";
|
|
|
|
// 公共路由
|
|
export const constantRoutes = [
|
|
{
|
|
path: "/redirect",
|
|
component: Layout,
|
|
hidden: true,
|
|
children: [
|
|
{
|
|
path: "/redirect/:path(.*)",
|
|
component: () => import("@/views/redirect"),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/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 },
|
|
beforeEnter: (to, from, next) => {
|
|
currentRole().then((res) => {
|
|
const role = res.data[0].roleKey;
|
|
if (role === "temp") {
|
|
next("/temp");
|
|
} else {
|
|
next();
|
|
}
|
|
});
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/temp",
|
|
component: () => import("@/views/temp"),
|
|
name: "Temp",
|
|
hidden: true,
|
|
meta: { title: "临时页面", icon: "dashboard" },
|
|
beforeEnter: (to, from, next) => {
|
|
currentRole().then((res) => {
|
|
const role = res.data[0].roleKey;
|
|
if (role === "temp") {
|
|
next();
|
|
} else {
|
|
next("/index");
|
|
}
|
|
});
|
|
},
|
|
},
|
|
{
|
|
path: "/tool",
|
|
component: Layout,
|
|
hidden: true,
|
|
children: [
|
|
{
|
|
path: "build/index",
|
|
component: () => import("@/views/tool/build/index"),
|
|
name: "FormBuild",
|
|
meta: { title: "表单设计", icon: "" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
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: "/people",
|
|
component: Layout,
|
|
hidden: true,
|
|
children: [
|
|
{
|
|
path: "updateOnboarding/:onboardingId(\\d+)",
|
|
component: () => import("@/views/oa/onboarding/update"),
|
|
name: "updateOnboarding",
|
|
meta: { title: "更新入职数据", activeMenu: "/people/onboarding" },
|
|
},
|
|
{
|
|
path: "addOffboarding",
|
|
component: () => import("@/views/oa/offboarding/add"),
|
|
name: "addOffboarding",
|
|
meta: { title: "新增离职申请", activeMenu: "/people/offboarding" },
|
|
},
|
|
{
|
|
path: "updateOffboarding/:offboardingId(\\d+)",
|
|
component: () => import("@/views/oa/offboarding/update"),
|
|
name: "updateOffboarding",
|
|
meta: { title: "新增离职申请", activeMenu: "/people/offboarding" },
|
|
},
|
|
],
|
|
},
|
|
|
|
{
|
|
path: "/customer",
|
|
component: Layout,
|
|
hidden: true,
|
|
children: [
|
|
{
|
|
path: "detail/:customerId(\\d+)",
|
|
component: () => import("@/views/oa/customer/customer/detail"),
|
|
name: "detail",
|
|
meta: { title: "客户详情", activeMenu: "/customer" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/money",
|
|
component: Layout,
|
|
hidden: true,
|
|
children: [
|
|
{
|
|
path: "addMoney",
|
|
component: () => import("@/views/oa/apply/money/add"),
|
|
name: "addMoney",
|
|
meta: { title: "新增拨款申请", activeMenu: "/money" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/claim",
|
|
component: Layout,
|
|
hidden: true,
|
|
children: [
|
|
{
|
|
path: "addTripClaim",
|
|
component: () => import("@/views/oa/claim/add"),
|
|
name: "addTripClaim",
|
|
meta: { title: "新增差旅报销", activeMenu: "/claim/oaClaim" },
|
|
},
|
|
{
|
|
path: "detail/:claimId(\\d+)",
|
|
component: () => import("@/views/oa/claim/detail"),
|
|
name: "detail",
|
|
meta: { title: "报销单审批", activeMenu: "/claim/oaClaim" },
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
export const dynamicRoutes = [
|
|
|
|
{
|
|
path: "/system/user-auth",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["system:user:edit"],
|
|
children: [
|
|
{
|
|
path: "role/:userId(\\d+)",
|
|
component: () => import("@/views/system/user/authRole"),
|
|
name: "AuthRole",
|
|
meta: { title: "分配角色", activeMenu: "/system/user" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/system/role-auth",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["system:role:edit"],
|
|
children: [
|
|
{
|
|
path: "user/:roleId(\\d+)",
|
|
component: () => import("@/views/system/role/authUser"),
|
|
name: "AuthUser",
|
|
meta: { title: "分配用户", activeMenu: "/system/role" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/system/dict-data",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["system:dict:list"],
|
|
children: [
|
|
{
|
|
path: "index/:dictId(\\d+)",
|
|
component: () => import("@/views/system/dict/data"),
|
|
name: "Data",
|
|
meta: { title: "字典数据", activeMenu: "/system/dict" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/oa/warehouse-data",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["oa:oaWarehouse:list"],
|
|
children: [
|
|
{
|
|
path: "index/:warehouseId(\\d+)",
|
|
component: () => import("@/views/oa/oaWarehouse/data"),
|
|
name: "Data",
|
|
meta: { title: "出库数据", activeMenu: "/oa/oaWarehouse" },
|
|
},
|
|
{
|
|
path: "addTask",
|
|
component: () => import("@/views/oa/oaWarehouse/addTask"),
|
|
name: "addTask",
|
|
meta: { title: "采购计划", activeMenu: "/oa/oaWarehouse" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/remind",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["oa:remind:list"],
|
|
children: [
|
|
{
|
|
path: "/index",
|
|
component: () => import("@/views/oa/remind/index"),
|
|
name: "remind",
|
|
meta: { title: "事件管理", activeMenu: "/oa/remind" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/proContract",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["oa:project:list"],
|
|
children: [
|
|
{
|
|
path: "/index",
|
|
component: () => import("@/views/oa/proContract/index"),
|
|
name: "oaContract",
|
|
meta: { title: "项目合同管理", activeMenu: "/oa/proContract" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/system/oss-config",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["system:oss:list"],
|
|
children: [
|
|
{
|
|
path: "index",
|
|
component: () => import("@/views/system/oss/config"),
|
|
name: "OssConfig",
|
|
meta: { title: "配置管理", activeMenu: "/system/oss" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/tool/gen-edit",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["tool:gen:edit"],
|
|
children: [
|
|
{
|
|
path: "index/:tableId(\\d+)",
|
|
component: () => import("@/views/tool/gen/editTable"),
|
|
name: "GenEdit",
|
|
meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/project/closure",
|
|
component: Layout,
|
|
hidden: true,
|
|
permissions: ["workflow:process:query"],
|
|
children: [
|
|
{
|
|
path: "detail/:projectId(\\d+)",
|
|
component: () => import("@/views/oa/closure/index"),
|
|
name: "closure",
|
|
meta: { title: "项目结项", activeMenu: "/project/project" },
|
|
},
|
|
],
|
|
},
|
|
|
|
];
|
|
|
|
let routerPush = Router.prototype.push;
|
|
let routerReplace = Router.prototype.replace;
|
|
Router.prototype.push = function push(location) {
|
|
return routerPush.call(this, location).catch((err) => err);
|
|
};
|
|
Router.prototype.replace = function replace(location) {
|
|
return routerReplace.call(this, location).catch((err) => err);
|
|
};
|
|
|
|
const router = new Router({
|
|
base: process.env.VUE_APP_CONTEXT_PATH,
|
|
mode: "history",
|
|
scrollBehavior: () => ({ y: 0 }),
|
|
routes: constantRoutes,
|
|
});
|
|
|
|
export default router; |