From 59b4a8873526af51853ded5c692d9c8a075050c0 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Sun, 1 Mar 2026 21:56:50 +0800 Subject: [PATCH] update bag --- .../ProductionProcess/BagConsumptionForm.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/ProductionProcess/BagConsumptionForm.tsx b/src/components/ProductionProcess/BagConsumptionForm.tsx index afee258..2de6881 100644 --- a/src/components/ProductionProcess/BagConsumptionForm.tsx +++ b/src/components/ProductionProcess/BagConsumptionForm.tsx @@ -140,7 +140,17 @@ const BagConsumptionForm: React.FC = ({ alert(t("Please select at least one bag")); return; } - + for (const row of validRows) { + const selectedBag = bagList.find((b) => b.id === row.bagLotLineId); + const available = selectedBag?.balanceQty ?? 0; + const requested = row.consumedQty + row.scrapQty; + if (requested > available) { + alert( + `${selectedBag?.bagName ?? "Bag"}: ${t("Insufficient balance")}. ${t("Available")}: ${available}, ${t("Requested")}: ${requested}` + ); + return; + } + } // 提交每个 bag consumption const promises = validRows.map((row) => { const selectedBag = bagList.find((b) => b.id === row.bagLotLineId);