/** * 狀態流程條組件 */ import { Check } from "lucide-react"; import type { PurchaseOrderStatus } from "@/types/purchase-order"; interface StatusProgressBarProps { currentStatus: PurchaseOrderStatus; } // 流程步驟定義 const FLOW_STEPS: { key: PurchaseOrderStatus; label: string }[] = [ { key: "draft", label: "草稿" }, { key: "pending", label: "簽核中" }, { key: "approved", label: "已核准" }, { key: "partial", label: "部分收貨" }, { key: "completed", label: "全數收貨" }, { key: "closed", label: "已結案" }, ]; export function StatusProgressBar({ currentStatus }: StatusProgressBarProps) { // 對於 cancelled 狀態,進度條通常不顯示或顯示特殊樣式,這裡我們顯示到最後一個有效狀態 const effectiveStatus = currentStatus === "cancelled" ? "pending" : currentStatus; // 找到當前狀態在流程中的位置 const currentIndex = FLOW_STEPS.findIndex((step) => step.key === effectiveStatus); return (

採購單處理進度

{/* 進度條背景 */}
{/* 進度條進度 */} {currentIndex >= 0 && (
)} {/* 步驟標記 */}
{FLOW_STEPS.map((step, index) => { const isCompleted = index < currentIndex; const isCurrent = index === currentIndex; // 如果當前是 cancelled,且我們正在渲染 pending 步驟,可以加點提示 const isRejectedAtThisStep = currentStatus === "cancelled" && step.key === "pending"; return (
{/* 圓點 */}
{isCompleted && !isRejectedAtThisStep ? ( ) : ( {index + 1} )}
{/* 標籤 */}

{isRejectedAtThisStep ? "已作廢" : step.label}

); })}
); }