From 1b404335e530349f0ba67b7b97a59e6d4433835a Mon Sep 17 00:00:00 2001 From: "kelvin.yau" Date: Fri, 12 Dec 2025 16:18:02 +0800 Subject: [PATCH] separate IQC and EPQC stock in modal --- src/app/api/jo/actions.ts | 29 +++++++++++++ src/components/PoDetail/PoInputGrid.tsx | 1 + .../ProductionProcessList.tsx | 1 + src/components/Qc/QcStockInModal.tsx | 43 ++++++++++++------- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/src/app/api/jo/actions.ts b/src/app/api/jo/actions.ts index 67e1a29..4b782d1 100644 --- a/src/app/api/jo/actions.ts +++ b/src/app/api/jo/actions.ts @@ -137,6 +137,35 @@ export interface PrintPickRecordResponse{ message?: string } + +export interface PrintFGStockInLabelRequest { + stockInLineId: number; + printerId: number; + printQty?: number; +} + +export const printFGStockInLabel = cache(async(data: PrintFGStockInLabelRequest) => { + const params = new URLSearchParams(); + if (data.stockInLineId) { + params.append('stockInLineId', data.stockInLineId.toString()); + } + params.append('printerId', data.printerId.toString()); + if (data.printQty !== undefined && data.printQty !== null) { + params.append('printQty', data.printQty.toString()); + } + + return serverFetchWithNoContent( + `${BASE_API_URL}/jo/print-FGPickRecordLabel?${params.toString()}`, + { + method: "GET", + next: { + tags: ["printFGStockInLabel"], + }, + } + ); +}); + + export const recordSecondScanIssue = cache(async ( pickOrderId: number, itemId: number, diff --git a/src/components/PoDetail/PoInputGrid.tsx b/src/components/PoDetail/PoInputGrid.tsx index e40595d..777de0b 100644 --- a/src/components/PoDetail/PoInputGrid.tsx +++ b/src/components/PoDetail/PoInputGrid.tsx @@ -955,6 +955,7 @@ const closeNewModal = useCallback(() => { // itemDetail={modalInfo} inputDetail={modalInfo} printerCombo={printerCombo} + printSource="stockIn" /> {/* ) diff --git a/src/components/ProductionProcess/ProductionProcessList.tsx b/src/components/ProductionProcess/ProductionProcessList.tsx index 11eb382..8679fb1 100644 --- a/src/components/ProductionProcess/ProductionProcessList.tsx +++ b/src/components/ProductionProcess/ProductionProcessList.tsx @@ -248,6 +248,7 @@ const ProductProcessList: React.FC = ({ onSelectProcess onClose={closeNewModal} inputDetail={modalInfo} printerCombo={printerCombo} + printSource="productionProcess" /> {processes.length > 0 && ( { printerCombo: PrinterCombo[]; onClose: () => void; skipQc?: Boolean; + printSource?: "stockIn" | "productionProcess"; } interface Props extends CommonProps { // itemDetail: StockInLine & { qcResult?: PurchaseQcResult[] } & { escResult?: EscalationResult[] }; @@ -76,6 +77,7 @@ const QcStockInModal: React.FC = ({ warehouse, printerCombo, skipQc = false, + printSource = "stockIn", }) => { const { t, @@ -496,27 +498,36 @@ const QcStockInModal: React.FC = ({ alert("列印數量不正確!"); return; } - // console.log(pafRowSelectionModel) - const printList = formProps.watch("putAwayLines")?.filter((line) => ((pafRowSelectionModel ?? []).some((model) => model === line.id))) ?? [] - // const printQty = printList.reduce((acc, cur) => acc + cur.printQty, 0) - // console.log(printQty) - const data: PrintQrCodeForSilRequest = { + // Conditionally call different APIs based on source + let response; + if (printSource === "productionProcess") { + // Use FG Stock In Label print API for production process + const data: PrintFGStockInLabelRequest = { stockInLineId: stockInLineInfo?.id ?? 0, printerId: selectedPrinter.id, printQty: printQty } - const response = await printQrCodeForSil(data); - if (response) { - console.log(response) - } - if (typeof window !== 'undefined' && selectedPrinter) { - sessionStorage.setItem(printerStorageKey, String(selectedPrinter.id)); + response = await printFGStockInLabel(data); + } else { + // Use stock-in print API (default) + const data: PrintQrCodeForSilRequest = { + stockInLineId: stockInLineInfo?.id ?? 0, + printerId: selectedPrinter.id, + printQty: printQty } - } finally { - setIsPrinting(() => false) + response = await printQrCodeForSil(data); + } + + if (response) { + console.log(response) + } + if (typeof window !== 'undefined' && selectedPrinter) { + sessionStorage.setItem(printerStorageKey, String(selectedPrinter.id)); } - // }, [pafRowSelectionModel, printQty, selectedPrinter]); - }, [stockInLineInfo?.id, pafRowSelectionModel, printQty, selectedPrinter]); + } finally { + setIsPrinting(() => false) + } +}, [stockInLineInfo?.id, pafRowSelectionModel, printQty, selectedPrinter, printSource]); // const checkQcIsPassed = useCallback((qcItems: PurchaseQcResult[]) => { // const isPassed = qcItems.every((qc) => qc.qcPassed);