export interface Transaction { id: string; type: string; quantity: number; balanceAfter: number; reason: string | null; userName: string; actualTime: string; batchNumber?: string; // 商品層級查詢時顯示批號 slot?: string; // 貨道資訊 } interface TransactionTableProps { transactions: Transaction[]; showBatchNumber?: boolean; // 是否顯示批號欄位 } export default function TransactionTable({ transactions, showBatchNumber = false }: TransactionTableProps) { if (transactions.length === 0) { return (
| # | 時間 | {shouldShowBatchNumber &&批號 | }類型 | 變動數量 | 結餘 | {shouldShowSlot &&貨道 | }經手人 | 原因/備註 |
|---|---|---|---|---|---|---|---|---|
| {index + 1} | {tx.actualTime} | {shouldShowBatchNumber && ({tx.batchNumber || '-'} | )}0 ? 'bg-green-100 text-green-800' : tx.quantity < 0 ? 'bg-red-100 text-red-800' : 'bg-gray-100 text-gray-800' }`}> {tx.type} | 0 ? 'text-green-600' : tx.quantity < 0 ? 'text-red-600' : '' }`}> {tx.quantity > 0 ? '+' : ''}{tx.quantity} | {tx.balanceAfter} | {shouldShowSlot && ({tx.slot || '-'} | )}{tx.userName} | {tx.reason || '-'} |