Browse Source

separate IQC and EPQC stock in modal

master
kelvin.yau 3 days ago
parent
commit
1b404335e5
4 changed files with 58 additions and 16 deletions
  1. +29
    -0
      src/app/api/jo/actions.ts
  2. +1
    -0
      src/components/PoDetail/PoInputGrid.tsx
  3. +1
    -0
      src/components/ProductionProcess/ProductionProcessList.tsx
  4. +27
    -16
      src/components/Qc/QcStockInModal.tsx

+ 29
- 0
src/app/api/jo/actions.ts View File

@@ -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,


+ 1
- 0
src/components/PoDetail/PoInputGrid.tsx View File

@@ -955,6 +955,7 @@ const closeNewModal = useCallback(() => {
// itemDetail={modalInfo}
inputDetail={modalInfo}
printerCombo={printerCombo}
printSource="stockIn"
/>
</>
{/* )


+ 1
- 0
src/components/ProductionProcess/ProductionProcessList.tsx View File

@@ -248,6 +248,7 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({ onSelectProcess
onClose={closeNewModal}
inputDetail={modalInfo}
printerCombo={printerCombo}
printSource="productionProcess"
/>
{processes.length > 0 && (
<TablePagination


+ 27
- 16
src/components/Qc/QcStockInModal.tsx View File

@@ -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);


Loading…
Cancel
Save