feat: 實作即時庫存查詢功能、儀表板庫存導盤,及優化手動入庫批號與儲位連動與選單顯示

This commit is contained in:
2026-02-10 10:47:31 +08:00
parent 6980eac1a4
commit a6393e03d8
12 changed files with 1401 additions and 198 deletions

View File

@@ -43,6 +43,7 @@ interface Batch {
expiryDate: string | null;
quantity: number;
isDeleted?: boolean;
location?: string;
}
interface Props {
@@ -322,7 +323,8 @@ export default function AddInventoryPage({ warehouse, products }: Props) {
inventoryId: item.inventoryId,
originCountry: item.originCountry,
expiryDate: item.expiryDate,
unit_cost: item.unit_cost
unit_cost: item.unit_cost,
location: item.location,
};
})
}, {
@@ -575,17 +577,25 @@ export default function AddInventoryPage({ warehouse, products }: Props) {
batchMode: 'existing',
inventoryId: value,
originCountry: selectedBatch?.originCountry,
expiryDate: selectedBatch?.expiryDate || undefined
expiryDate: selectedBatch?.expiryDate || undefined,
location: selectedBatch?.location || item.location,
});
}
}}
options={[
{ label: "📦 不使用批號 (自動累加)", value: "no_batch" },
{ label: "+ 建立新批號", value: "new_batch" },
...(batchesCache[item.productId]?.batches || []).map(b => ({
label: `${b.batchNumber === 'NO-BATCH' ? '(無批號紀錄)' : b.batchNumber} - 庫存: ${b.quantity}`,
value: b.inventoryId
}))
...(batchesCache[item.productId]?.batches || []).map(b => {
const isNoBatch = b.batchNumber === 'NO-BATCH';
const showLocation = isNoBatch || warehouse.type === 'vending';
const locationInfo = (showLocation && b.location) ? ` [${b.location}]` : '';
const batchLabel = isNoBatch ? '(無批號紀錄)' : b.batchNumber;
return {
label: `${batchLabel}${locationInfo} - 庫存: ${b.quantity}`,
value: b.inventoryId
};
})
]}
placeholder="選擇或新增批號"
className="border-gray-300"