227 lines
5.8 KiB
JavaScript
227 lines
5.8 KiB
JavaScript
import { lazy } from "react";
|
|
|
|
export const allRoutes = [
|
|
{
|
|
path: "/home",
|
|
component: lazy(() => import("@/pages/home")),
|
|
name: "首页",
|
|
hidden: true,
|
|
key: "home",
|
|
},
|
|
{
|
|
path: "dashboard",
|
|
component: lazy(() => import("@/pages/Dashboard")),
|
|
name: "仪表盘",
|
|
icon: "dashboard",
|
|
key: "dashboard",
|
|
},
|
|
{
|
|
path: "resource",
|
|
component: lazy(() => import("@/pages/resource")),
|
|
name: "资源管理",
|
|
icon: "appstore",
|
|
key: "resource",
|
|
children: [
|
|
{
|
|
path: "team",
|
|
component: lazy(() => import("@/pages/resource/team")),
|
|
name: "团队管理",
|
|
icon: "team",
|
|
key: "resource/team",
|
|
},
|
|
{
|
|
path: "role",
|
|
component: lazy(() => import("@/pages/resource/role")),
|
|
name: "角色管理",
|
|
icon: "setting",
|
|
key: "resource/role",
|
|
},
|
|
{
|
|
path: "menu",
|
|
component: lazy(() => import("@/pages/resource/menu")),
|
|
name: "菜单管理",
|
|
icon: "menu",
|
|
key: "resource/menu",
|
|
},
|
|
{
|
|
path: "bucket",
|
|
component: lazy(() => import("@/pages/resource/bucket")),
|
|
name: "对象存储",
|
|
icon: "shop",
|
|
key: "resource/bucket",
|
|
},
|
|
{
|
|
path: "task/edit/:id?",
|
|
component: lazy(() => import("@/pages/resource/resourceTask/edit")),
|
|
name: "新增/编辑任务",
|
|
hidden: true,
|
|
key: "resource/task/edit",
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: "company",
|
|
component: lazy(() => import("@/pages/company")),
|
|
name: "公司管理",
|
|
icon: "bank",
|
|
key: "company",
|
|
children: [
|
|
{
|
|
path: "quotation",
|
|
component: lazy(() => import("@/pages/company/quotation")),
|
|
name: "报价单",
|
|
icon: "file",
|
|
key: "company/quotation",
|
|
},
|
|
{
|
|
path: "quotaInfo/:id?",
|
|
component: lazy(() => import("@/pages/company/quotation/detail")),
|
|
name: "报价单详情",
|
|
icon: "file",
|
|
hidden: true,
|
|
key: "company/quotaInfo",
|
|
},
|
|
{
|
|
<<<<<<< HEAD
|
|
path: "quotaInfo/preview/:id?", // 添加可选的 id 参数
|
|
=======
|
|
path: "quotaInfo/preview/:id?",
|
|
>>>>>>> 8dccf8e554eefcfa832eca45be35be4dddad3cb8
|
|
hidden: true,
|
|
component: lazy(() => import("@/pages/company/quotation/view")),
|
|
name: "报价单预览",
|
|
icon: "file",
|
|
<<<<<<< HEAD
|
|
key:'company/quotaInfo/preview'
|
|
},
|
|
=======
|
|
key: "company/quotaInfo/preview",
|
|
},
|
|
|
|
>>>>>>> 8dccf8e554eefcfa832eca45be35be4dddad3cb8
|
|
{
|
|
path: "project",
|
|
component: lazy(() => import("@/pages/company/project")),
|
|
name: "专案管理",
|
|
icon: "appstore",
|
|
key: "company/project",
|
|
},
|
|
{
|
|
path: "task",
|
|
component: lazy(() => import("@/pages/company/task")),
|
|
name: "任务管理",
|
|
icon: "appstore",
|
|
key: "company/task",
|
|
},
|
|
{
|
|
path: "taskInfo/:id?",
|
|
component: lazy(() => import("@/pages/company/task/detail")),
|
|
name: "任务管理详情",
|
|
icon: "appstore",
|
|
hidden: true,
|
|
key: "company/taskInfo",
|
|
},
|
|
{
|
|
path: "serviceTemplate",
|
|
component: lazy(() => import("@/pages/company/service")),
|
|
name: "服务管理",
|
|
icon: "appstore",
|
|
key: "company/serviceTemplate",
|
|
},
|
|
{
|
|
path: "serviceTemplateInfo/:id?",
|
|
hidden: true,
|
|
component: lazy(() => import("@/pages/company/service/detail")),
|
|
name: "服务模版详情",
|
|
icon: "container",
|
|
key: "company/serviceTemplateInfo",
|
|
<<<<<<< HEAD
|
|
|
|
=======
|
|
>>>>>>> 8dccf8e554eefcfa832eca45be35be4dddad3cb8
|
|
},
|
|
{
|
|
path: "supplier",
|
|
component: lazy(() => import("@/pages/company/supplier")),
|
|
name: "供应商管理",
|
|
icon: "branches",
|
|
key: "company/supplier",
|
|
},
|
|
{
|
|
path: "supplierInfo/:id?",
|
|
component: lazy(() => import("@/pages/company/supplier/detail")),
|
|
name: "供应商详情",
|
|
icon: "branches",
|
|
hidden: true,
|
|
key: "company/supplierInfo",
|
|
},
|
|
{
|
|
path: "projectInfo/:id?",
|
|
component: lazy(() => import("@/pages/company/project/detail")),
|
|
name: "专案管理详情",
|
|
icon: "appstore",
|
|
hidden: true,
|
|
key: "company/projectInfo",
|
|
},
|
|
{
|
|
path: "projectView/:id?",
|
|
component: lazy(() => import("@/pages/company/project/info")),
|
|
name: "专案详情",
|
|
icon: "appstore",
|
|
hidden: true,
|
|
key: "company/projectView",
|
|
},
|
|
{
|
|
path: "templateItemManage",
|
|
component: lazy(() => import("@/pages/company/service/itemsManange")),
|
|
name: "资源类型",
|
|
icon: "container",
|
|
<<<<<<< HEAD
|
|
key:'company/templateItemManage'
|
|
=======
|
|
key: "company/templateItem",
|
|
>>>>>>> 8dccf8e554eefcfa832eca45be35be4dddad3cb8
|
|
},
|
|
]
|
|
}
|
|
];
|
|
|
|
export const getRouteByKey = (key) => {
|
|
const keys = key.split('/').filter(Boolean);
|
|
let current = allRoutes;
|
|
let result = null;
|
|
|
|
keys.forEach(k => {
|
|
const found = current.find(r => r.path.split('/')[0] === k);
|
|
if (found) {
|
|
result = found;
|
|
current = found.children || [];
|
|
}
|
|
});
|
|
|
|
return result;
|
|
};
|
|
|
|
export const flattenRoutes = (routes, parentPath = '') => {
|
|
return routes.reduce((acc, route) => {
|
|
const path = parentPath ? `${parentPath}/${route.path}` : route.path;
|
|
acc.push({ ...route, path });
|
|
|
|
if (route.children) {
|
|
acc.push(...flattenRoutes(route.children, path));
|
|
}
|
|
|
|
return acc;
|
|
}, []);
|
|
};
|
|
|
|
// 获取所有可选的路由选项(用于菜单管理)
|
|
export const getAllRouteOptions = () => {
|
|
return flattenRoutes(allRoutes)
|
|
.filter(route => !route.hidden)
|
|
.map(route => ({
|
|
label: route.name,
|
|
value: route.key,
|
|
isLeaf: !route.children
|
|
}));
|
|
}; |