From 09917026c023560025e242e1964f9ff1913108e0 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Fri, 3 Apr 2026 20:44:52 +0800 Subject: [PATCH] update --- .../FinishedGoodSearch/GoodPickExecutiondetail.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/FinishedGoodSearch/GoodPickExecutiondetail.tsx b/src/components/FinishedGoodSearch/GoodPickExecutiondetail.tsx index 9675972..264e956 100644 --- a/src/components/FinishedGoodSearch/GoodPickExecutiondetail.tsx +++ b/src/components/FinishedGoodSearch/GoodPickExecutiondetail.tsx @@ -923,7 +923,9 @@ const fetchAllCombinedLotData = useCallback(async (userId?: number, pickOrderIdO pickOrderLinesForDisplay.forEach((line: any) => { // 用来记录这一行已经通过 lots 出现过的 lotId const lotIdSet = new Set(); - + /** 已由有批次建議分配的量(加總後與 pick_order_line.requiredQty 的差額 = 無批次列應顯示的數) */ + let lotsAllocatedSumForLine = 0; + // ✅ lots:按 lotId 去重并合并 requiredQty if (line.lots && line.lots.length > 0) { const lotMap = new Map(); @@ -940,6 +942,7 @@ const fetchAllCombinedLotData = useCallback(async (userId?: number, pickOrderIdO }); lotMap.forEach((lot: any) => { + lotsAllocatedSumForLine += Number(lot.requiredQty) || 0; if (lot.id != null) { lotIdSet.add(lot.id); } @@ -1029,7 +1032,13 @@ const fetchAllCombinedLotData = useCallback(async (userId?: number, pickOrderIdO location: stockout.location || null, stockUnit: line.item.uomDesc, availableQty: stockout.availableQty || 0, - requiredQty: line.requiredQty, + // 無批次列對應 suggested_pick_lot 的缺口量(如 11),勿用整行 POL 需求(100)以免顯示成 89 / 100 + requiredQty: stockout.noLot + ? Math.max( + 0, + (Number(line.requiredQty) || 0) - lotsAllocatedSumForLine + ) + : Number(line.requiredQty) || 0, actualPickQty: stockout.qty || 0, inQty: 0, outQty: 0,