|
|
|
@@ -40,7 +40,7 @@ import { StockInLineEntry, updateStockInLine, printQrCodeForSil, PrintQrCodeForS |
|
|
|
import { fetchStockInLineInfo } from "@/app/api/stockIn/actions"; |
|
|
|
import FgStockInForm from "../StockIn/FgStockInForm"; |
|
|
|
import LoadingComponent from "../General/LoadingComponent"; |
|
|
|
|
|
|
|
import { printFGStockInLabel, PrintFGStockInLabelRequest } from "@/app/api/jo/actions"; |
|
|
|
|
|
|
|
const style = { |
|
|
|
position: "absolute", |
|
|
|
@@ -63,6 +63,7 @@ interface CommonProps extends Omit<ModalProps, "children"> { |
|
|
|
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<Props> = ({ |
|
|
|
warehouse, |
|
|
|
printerCombo, |
|
|
|
skipQc = false, |
|
|
|
printSource = "stockIn", |
|
|
|
}) => { |
|
|
|
const { |
|
|
|
t, |
|
|
|
@@ -496,27 +498,36 @@ const QcStockInModal: React.FC<Props> = ({ |
|
|
|
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); |
|
|
|
|