更新
This commit is contained in:
1 parent
4ab63e77ed
commit
eb9b7beff5
16 files changed
+1031
-91
No files matched your search
@@ -123,6 +123,89 @@ function mergeFixedCmsMenu(menus) {
|
||||
: [fixedCmsMenu, ...menus];
|
||||
}
|
||||
|
||||
const ERP_ROOT = "/apps/erp";
|
||||
const ERP_WORKBENCH_DIR = "/apps/erp/workbench";
|
||||
const ERP_DASHBOARD_PAGE = "/apps/erp/dashboard";
|
||||
const ERP_APPROVAL_PAGE = "/apps/erp/workbench/approval";
|
||||
|
||||
/**
|
||||
* 进销存「工作台」统一为目录,目录内固定挂「工作台 / 审批列表」两个页面。
|
||||
*
|
||||
* 菜单由数据库下发,erp_menus.sql 未重跑时工作台仍是模块根下的一个叶子页面,
|
||||
* 这里在导航模型里就地补齐目录结构,保证前端展示与 SQL 的目标结构一致;
|
||||
* 数据库已是正确的目录结构时只做幂等补充,不会重复插入。
|
||||
*/
|
||||
function normalizeErpWorkbench(menus) {
|
||||
return (menus || []).map((menu) => {
|
||||
if (menu.path !== ERP_ROOT) {
|
||||
return menu.children?.length
|
||||
? { ...menu, children: normalizeErpWorkbench(menu.children) }
|
||||
: menu;
|
||||
}
|
||||
|
||||
const children = [...(menu.children || [])];
|
||||
const dir = children.find((m) => m.path === ERP_WORKBENCH_DIR && m.children?.length);
|
||||
const dashboard = children.find((m) => m.path === ERP_DASHBOARD_PAGE);
|
||||
const pages = dir ? [...(dir.children || [])] : [];
|
||||
|
||||
// 不能用 isWorkbenchMenu 判断:审批列表路径里也带 workbench,会被误判成工作台页
|
||||
const hasDashboard = pages.some(
|
||||
(m) => m.path === ERP_DASHBOARD_PAGE || String(m.title || "") === "工作台"
|
||||
);
|
||||
if (!hasDashboard) {
|
||||
pages.push(
|
||||
dashboard
|
||||
? { ...dashboard, title: "工作台", sort: 1, order: 1 }
|
||||
: {
|
||||
id: -3001,
|
||||
path: ERP_DASHBOARD_PAGE,
|
||||
title: "工作台",
|
||||
icon: "DataBoard",
|
||||
component_path: "/apps/erp/dashboard/index.vue",
|
||||
type: 2,
|
||||
sort: 1,
|
||||
order: 1,
|
||||
children: [],
|
||||
}
|
||||
);
|
||||
}
|
||||
if (!pages.some((m) => m.path === ERP_APPROVAL_PAGE)) {
|
||||
pages.push({
|
||||
id: -3002,
|
||||
path: ERP_APPROVAL_PAGE,
|
||||
title: "审批列表",
|
||||
icon: "Tickets",
|
||||
component_path: "/apps/erp/workbench/approvalList.vue",
|
||||
type: 2,
|
||||
sort: 2,
|
||||
order: 2,
|
||||
children: [],
|
||||
});
|
||||
}
|
||||
|
||||
const workbenchDir = dir
|
||||
? { ...dir, type: 1, component_path: "", children: pages }
|
||||
: {
|
||||
id: -300,
|
||||
pid: menu.id,
|
||||
path: ERP_WORKBENCH_DIR,
|
||||
title: "工作台",
|
||||
icon: "DataBoard",
|
||||
component_path: "",
|
||||
type: 1,
|
||||
sort: 1,
|
||||
order: 1,
|
||||
children: pages,
|
||||
};
|
||||
|
||||
// 原工作台叶子(或空的工作台目录)已被收进新目录,避免同一功能出现两份
|
||||
const rest = children.filter(
|
||||
(m) => m.path !== ERP_WORKBENCH_DIR && m.path !== ERP_DASHBOARD_PAGE
|
||||
);
|
||||
return { ...menu, children: [workbenchDir, ...rest] };
|
||||
});
|
||||
}
|
||||
|
||||
function sortMenusRecursively(menus) {
|
||||
(menus || []).forEach((menu) => {
|
||||
if (menu.children && menu.children.length > 0) {
|
||||
@@ -260,7 +343,9 @@ export function useAdminNavigation() {
|
||||
const menuStore = useMenuStore();
|
||||
|
||||
const list = computed(() =>
|
||||
sortMenusRecursively(processMenus(mergeFixedCmsMenu(menuStore.menus || []))),
|
||||
sortMenusRecursively(
|
||||
processMenus(normalizeErpWorkbench(mergeFixedCmsMenu(menuStore.menus || [])))
|
||||
),
|
||||
);
|
||||
|
||||
const currentModule = computed(() => {
|
||||
|
||||
Reference in new issue
Block a user