315 lines
9.2 KiB
JavaScript
315 lines
9.2 KiB
JavaScript
import React from "react";
|
|
import {
|
|
DashboardOutlined,
|
|
FileProtectOutlined,
|
|
TeamOutlined,
|
|
BankOutlined,
|
|
UserSwitchOutlined,
|
|
IdcardOutlined,
|
|
SafetyCertificateOutlined,
|
|
ToolOutlined,
|
|
UserOutlined,
|
|
BarChartOutlined,
|
|
PieChartOutlined,
|
|
ExperimentOutlined,
|
|
ShopOutlined,
|
|
ApartmentOutlined,
|
|
SwapOutlined,
|
|
LogoutOutlined,
|
|
FileTextOutlined,
|
|
KeyOutlined,
|
|
} from "@ant-design/icons";
|
|
|
|
const menuItems = [
|
|
{
|
|
key: "/certificate/container/Supervision",
|
|
label: "监管端",
|
|
icon: <DashboardOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/Supervision/test2",
|
|
label: "Test2 测试",
|
|
icon: <ExperimentOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/BasicInfo",
|
|
label: "基础信息管理",
|
|
icon: <FileTextOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/Supervision/BasicInfo/OrgAccount",
|
|
label: "机构账号管理",
|
|
icon: <KeyOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/BasicInfo/RegisteredOrg/List",
|
|
label: "已备案机构管理",
|
|
icon: <FileProtectOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/BasicInfo/EvaluatorInfo",
|
|
label: "评价师信息管理",
|
|
icon: <UserOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/BasicInfo/EnterprisePortrait",
|
|
label: "企业画像管理",
|
|
icon: <BarChartOutlined />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/EnterpriseLicense",
|
|
label: "企业证照",
|
|
icon: <FileProtectOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/Supervision/EnterpriseLicense/EnterpriseLicense",
|
|
label: "企业证照管理",
|
|
icon: <IdcardOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/EnterpriseLicense/BranchStatistics/List",
|
|
label: "分公司统计",
|
|
icon: <BarChartOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/EnterpriseLicense/StakeholderStatistics/List",
|
|
label: "干系人统计",
|
|
icon: <PieChartOutlined />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense",
|
|
label: "人员证照",
|
|
icon: <TeamOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense/PersonInCharge/List",
|
|
label: "负责人",
|
|
icon: <UserOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense/SecurityAdmini/List",
|
|
label: "安全管理员",
|
|
icon: <SafetyCertificateOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense/SpecialDevice/List",
|
|
label: "特种设备",
|
|
icon: <ToolOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense/SpecialPersonnel/List",
|
|
label: "特种作业人员",
|
|
icon: <IdcardOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense/BranchCompanyStat/List",
|
|
label: "分公司人员统计",
|
|
icon: <BarChartOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Supervision/PersonnelLicense/StakeholderStat/List",
|
|
label: "干系人人员统计",
|
|
icon: <PieChartOutlined />,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: "/certificate/container/BranchCompany",
|
|
label: "分公司端",
|
|
icon: <BankOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/BranchCompany/EnterpriseLicense/EnterpriseLicense",
|
|
label: "企业证照管理",
|
|
icon: <IdcardOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/BranchCompany/EnterpriseLicense/PersonnelLicense",
|
|
label: "人员证照",
|
|
icon: <TeamOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/BranchCompany/EnterpriseLicense/PersonnelLicense/PersonInCharge/List",
|
|
label: "负责人",
|
|
icon: <UserOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/BranchCompany/EnterpriseLicense/PersonnelLicense/SecurityAdmini/List",
|
|
label: "安全管理员",
|
|
icon: <SafetyCertificateOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/BranchCompany/EnterpriseLicense/PersonnelLicense/SpecialDevice/List",
|
|
label: "特种设备",
|
|
icon: <ToolOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/BranchCompany/EnterpriseLicense/PersonnelLicense/SpecialPersonnel/List",
|
|
label: "特种作业人员",
|
|
icon: <IdcardOutlined />,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: "/certificate/container/Stakeholder",
|
|
label: "干系人端",
|
|
icon: <UserSwitchOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/Stakeholder/EnterpriseLicense/EnterpriseLicense",
|
|
label: "企业证照管理",
|
|
icon: <IdcardOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Stakeholder/EnterpriseLicense/PersonnelLicense",
|
|
label: "人员证照",
|
|
icon: <TeamOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/Stakeholder/EnterpriseLicense/PersonnelLicense/PersonInCharge/List",
|
|
label: "负责人",
|
|
icon: <UserOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Stakeholder/EnterpriseLicense/PersonnelLicense/SecurityAdmini/List",
|
|
label: "安全管理员",
|
|
icon: <SafetyCertificateOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Stakeholder/EnterpriseLicense/PersonnelLicense/SpecialDevice/List",
|
|
label: "特种设备",
|
|
icon: <ToolOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/Stakeholder/EnterpriseLicense/PersonnelLicense/SpecialPersonnel/List",
|
|
label: "特种作业人员",
|
|
icon: <IdcardOutlined />,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo",
|
|
label: "企业信息管理",
|
|
icon: <ShopOutlined />,
|
|
children: [
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/OrgInfo",
|
|
label: "机构信息管理",
|
|
icon: <BankOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/QualificationCert",
|
|
label: "资质信息管理",
|
|
icon: <SafetyCertificateOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/PersonnelChange",
|
|
label: "人员变更管理",
|
|
icon: <SwapOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/PersonnelInfo/List",
|
|
label: "人员信息管理",
|
|
icon: <TeamOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/DepartmentPosition",
|
|
label: "部门岗位管理",
|
|
icon: <ApartmentOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/ResignationApply",
|
|
label: "人员离职申请",
|
|
icon: <LogoutOutlined />,
|
|
},
|
|
{
|
|
key: "/certificate/container/EnterpriseInfo/EquipInfo",
|
|
label: "装备信息管理",
|
|
icon: <ToolOutlined />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
key: "/certificate/container/Test",
|
|
label: "测试页面",
|
|
icon: <ExperimentOutlined />,
|
|
},
|
|
];
|
|
|
|
export default menuItems;
|
|
|
|
/** 扁平化菜单 */
|
|
export function flattenMenu(items) {
|
|
const result = [];
|
|
function walk(list) {
|
|
for (const item of list) {
|
|
result.push(item);
|
|
if (item.children) walk(item.children);
|
|
}
|
|
}
|
|
walk(items);
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 根据路径查找面包屑路径
|
|
* 返回从根到叶子节点的菜单项数组
|
|
*/
|
|
export function findMenuPath(path) {
|
|
function search(items, ancestors) {
|
|
for (const item of items) {
|
|
const current = [...ancestors, item];
|
|
if (item.key === path) {
|
|
return current;
|
|
}
|
|
if (item.children) {
|
|
const found = search(item.children, current);
|
|
if (found) return found;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
return search(menuItems, []) || [];
|
|
}
|
|
|
|
/**
|
|
* 根据路径获取页面标签名
|
|
*/
|
|
export function getPageLabel(path) {
|
|
const flat = flattenMenu(menuItems);
|
|
const item = flat.find((m) => m.key === path);
|
|
return item?.label || path.split("/").filter(Boolean).pop() || "未命名页面";
|
|
}
|
|
|
|
/**
|
|
* 根据路径获取默认展开的菜单项
|
|
*/
|
|
export function getOpenKeys(path) {
|
|
const breadcrumb = findMenuPath(path);
|
|
return breadcrumb.slice(0, -1).map((i) => i.key);
|
|
}
|
|
|
|
/**
|
|
* 根据路径获取选中的菜单项
|
|
*/
|
|
export function getSelectedKeys(path) {
|
|
const allPaths = flattenMenu(menuItems).map((m) => m.key);
|
|
let match = "";
|
|
for (const p of allPaths) {
|
|
if (path.startsWith(p) && p.length > match.length) {
|
|
match = p;
|
|
}
|
|
}
|
|
return match ? [match] : [];
|
|
}
|