/** * 查看採購單詳情頁面 */ import { ArrowLeft } from "lucide-react"; import { Button } from "./ui/button"; import { Badge } from "./ui/badge"; import { STATUS_CONFIG, PAYMENT_METHODS, INVOICE_TYPES } from "../constants/purchase-order"; import { StatusProgressBar } from "./purchase-order/StatusProgressBar"; import { Breadcrumb } from "./shared/Breadcrumb"; import { StatusBadge } from "./shared/StatusBadge"; import { CopyButton } from "./shared/CopyButton"; import type { PurchaseOrder } from "../types/purchase-order"; import { formatCurrency } from "../utils/purchase-order"; interface ViewPurchaseOrderPageProps { order: PurchaseOrder; onBack: () => void; } export default function ViewPurchaseOrderPage({ order, onBack, }: ViewPurchaseOrderPageProps) { return (
{/* Header */}

查看採購單

{/* 狀態流程條 */} {order.status !== "draft" && order.status !== "rejected" && (
)}
{/* 審核資訊卡片(如果有審核資訊) */} {order.reviewInfo && (

{order.status === "rejected" ? "退回資訊" : "審核資訊"}

{order.reviewInfo.reviewedBy}
{order.reviewInfo.reviewedAt}
{order.reviewInfo.rejectionReason && (

{order.reviewInfo.rejectionReason}

)}
)} {/* 付款資訊卡片(如果有付款資訊) */} {order.paymentInfo && (

付款資訊

{PAYMENT_METHODS[order.paymentInfo.paymentMethod]}
{order.paymentInfo.paymentDate}
${order.paymentInfo.actualAmount.toLocaleString()}
{order.paymentInfo.paidBy}
{order.paymentInfo.paidAt}
{/* 發票資訊(如果有) */} {order.paymentInfo.hasInvoice && order.paymentInfo.invoice && (

發票資訊

{order.paymentInfo.invoice.invoiceNumber}
{INVOICE_TYPES[order.paymentInfo.invoice.invoiceType]}
${order.paymentInfo.invoice.invoiceAmount.toLocaleString()}
{order.paymentInfo.invoice.invoiceDate}
{order.paymentInfo.invoice.invoiceType === "triplicate" && ( <>
{order.paymentInfo.invoice.companyName}
{order.paymentInfo.invoice.taxId}
)}
)}
)} {/* 基本資訊卡片 */}

基本資訊

{/* 採購單編號 */}
{order.poNumber}
{/* 廠商 */}
{order.supplierName}
{/* 申請單位 */}
{order.requesterName}
{/* 申請人 */}
{order.createdBy}
{/* 建立日期 */}
{order.createdAt}
{/* 預計到貨日 */}
{order.expectedDate}
{/* 備註(如果有) */} {order.notes && (

{order.notes}

)}
{/* 採購項目卡片 */}

採購項目

{order.items.map((item, index) => ( ))}
品項名稱 數量 單位 單價 小計
{item.productName} {item.productId}
{item.quantity} {item.unit}
{formatCurrency(item.unitPrice)} {item.previousPrice && item.previousPrice !== item.unitPrice && ( {formatCurrency(item.previousPrice)} )}
{formatCurrency(item.subtotal)}
總金額 {formatCurrency(order.totalAmount)}
); }