2026-01-07 13:06:49 +08:00
|
|
|
|
import { BreadcrumbItemType } from "@/Components/shared/BreadcrumbNav";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 麵包屑定義對應表
|
|
|
|
|
|
* 根據側邊欄層級結構定義基礎麵包屑
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const BREADCRUMB_MAP: Record<string, BreadcrumbItemType[]> = {
|
2026-01-13 13:37:51 +08:00
|
|
|
|
dashboard: [],
|
2026-01-07 13:06:49 +08:00
|
|
|
|
products: [
|
|
|
|
|
|
{ label: "商品與庫存管理" },
|
2026-01-07 13:12:07 +08:00
|
|
|
|
{ label: "商品資料管理", href: "/products", isPage: true }
|
2026-01-07 13:06:49 +08:00
|
|
|
|
],
|
|
|
|
|
|
warehouses: [
|
|
|
|
|
|
{ label: "商品與庫存管理" },
|
2026-01-07 13:12:07 +08:00
|
|
|
|
{ label: "倉庫管理", href: "/warehouses", isPage: true }
|
2026-01-07 13:06:49 +08:00
|
|
|
|
],
|
|
|
|
|
|
vendors: [
|
2026-01-27 13:27:28 +08:00
|
|
|
|
{ label: "供應鏈管理", href: '#' },
|
2026-01-07 13:12:07 +08:00
|
|
|
|
{ label: "廠商資料管理", href: "/vendors", isPage: true }
|
2026-01-07 13:06:49 +08:00
|
|
|
|
],
|
|
|
|
|
|
purchaseOrders: [
|
2026-01-27 13:27:28 +08:00
|
|
|
|
{ label: "供應鏈管理", href: '#' },
|
|
|
|
|
|
{ label: "採購單管理", href: "/purchase-orders", isPage: true }
|
2026-01-07 13:06:49 +08:00
|
|
|
|
],
|
2026-01-21 17:19:36 +08:00
|
|
|
|
productionOrders: [
|
|
|
|
|
|
{ label: "生產管理" },
|
|
|
|
|
|
{ label: "生產工單", href: "/production-orders", isPage: true }
|
|
|
|
|
|
],
|
|
|
|
|
|
productionOrdersCreate: [
|
|
|
|
|
|
{ label: "生產管理" },
|
|
|
|
|
|
{ label: "生產工單", href: "/production-orders" },
|
|
|
|
|
|
{ label: "建立生產單", isPage: true }
|
|
|
|
|
|
],
|
|
|
|
|
|
productionOrdersShow: [
|
|
|
|
|
|
{ label: "生產管理" },
|
|
|
|
|
|
{ label: "生產工單", href: "/production-orders" },
|
|
|
|
|
|
{ label: "詳情", isPage: true }
|
|
|
|
|
|
],
|
2026-01-26 14:59:24 +08:00
|
|
|
|
recipes: [
|
|
|
|
|
|
{ label: "生產管理" },
|
|
|
|
|
|
{ label: "配方管理", href: "/recipes", isPage: true }
|
|
|
|
|
|
],
|
2026-01-07 13:06:49 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 組合麵包屑工具
|
|
|
|
|
|
* @param base 基礎路徑名稱 (key of BREADCRUMB_MAP)
|
|
|
|
|
|
* @param extra 額外的路徑項目 (例如編輯、詳情頁)
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getBreadcrumbs(base: keyof typeof BREADCRUMB_MAP, extra?: BreadcrumbItemType[]): BreadcrumbItemType[] {
|
|
|
|
|
|
const baseItems = JSON.parse(JSON.stringify(BREADCRUMB_MAP[base] || []));
|
|
|
|
|
|
|
|
|
|
|
|
if (extra && extra.length > 0) {
|
|
|
|
|
|
// 如果有額外路徑,基礎路徑的最後一項不應標記為 isPage
|
|
|
|
|
|
if (baseItems.length > 0) {
|
|
|
|
|
|
baseItems[baseItems.length - 1].isPage = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return [...baseItems, ...extra];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return baseItems;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 取得「新增」操作的麵包屑
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getCreateBreadcrumbs(base: keyof typeof BREADCRUMB_MAP): BreadcrumbItemType[] {
|
|
|
|
|
|
return getBreadcrumbs(base, [{ label: "新增", isPage: true }]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 取得「編輯」操作的麵包屑
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getEditBreadcrumbs(base: keyof typeof BREADCRUMB_MAP): BreadcrumbItemType[] {
|
|
|
|
|
|
return getBreadcrumbs(base, [{ label: "編輯", isPage: true }]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 取得「詳情」操作的麵包屑
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getShowBreadcrumbs(base: keyof typeof BREADCRUMB_MAP, suffix: string = "詳情"): BreadcrumbItemType[] {
|
|
|
|
|
|
return getBreadcrumbs(base, [{ label: suffix, isPage: true }]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 取得「庫存管理」子頁面的麵包屑
|
|
|
|
|
|
* 層級:倉庫管理 > 庫存詳情 (倉庫名) > [功能]
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getInventoryBreadcrumbs(warehouseId: string | number, warehouseName: string, subPageLabel?: string): BreadcrumbItemType[] {
|
|
|
|
|
|
const baseItems: BreadcrumbItemType[] = [
|
|
|
|
|
|
...JSON.parse(JSON.stringify(BREADCRUMB_MAP.warehouses || []))
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
// 修改「倉庫管理」不作為最後一頁
|
|
|
|
|
|
if (baseItems.length > 0) {
|
|
|
|
|
|
baseItems[baseItems.length - 1].isPage = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const inventoryDetailItem: BreadcrumbItemType = {
|
|
|
|
|
|
label: `庫存管理 (${warehouseName})`,
|
|
|
|
|
|
href: `/warehouses/${warehouseId}/inventory`,
|
|
|
|
|
|
isPage: !subPageLabel
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const finalItems = [...baseItems, inventoryDetailItem];
|
|
|
|
|
|
|
|
|
|
|
|
if (subPageLabel) {
|
|
|
|
|
|
finalItems.push({ label: subPageLabel, isPage: true });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return finalItems;
|
|
|
|
|
|
}
|