From a293a7559bb6eb525374d320518a67a089d82306 Mon Sep 17 00:00:00 2001 From: kelvinsuen Date: Wed, 8 Oct 2025 16:43:56 +0800 Subject: [PATCH] rename qc data interface --- src/app/api/stockIn/actions.ts | 8 ++++---- src/components/PoDetail/PoInputGrid.tsx | 4 ++-- src/components/PoDetail/PutAwayForm.tsx | 2 +- src/components/PoDetail/QcComponent.tsx | 17 +++++++++-------- src/components/PoDetail/QcStockInModal.tsx | 2 +- src/components/PoDetail/StockInForm.tsx | 2 -- src/components/StockIn/FgStockInForm.tsx | 2 -- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/app/api/stockIn/actions.ts b/src/app/api/stockIn/actions.ts index e94ce20..db43102 100644 --- a/src/app/api/stockIn/actions.ts +++ b/src/app/api/stockIn/actions.ts @@ -39,7 +39,7 @@ export interface StockInLineEntry { dnNo?: string; } -export interface PurchaseQcResult{ +export interface QcResult{ id?: number; qcItemId: number; qcPassed?: boolean; @@ -66,7 +66,7 @@ export interface StockInInput { expiryDate: string; uom: Uom; } -export interface PurchaseQCInput { +export interface QCInput { status: string; acceptQty: number; passingQty: number; @@ -75,7 +75,7 @@ export interface PurchaseQCInput { totalWeight?: number; qcAccept: boolean; qcDecision?: number; - qcResult: PurchaseQcResult[]; + qcResult: QcResult[]; } export interface EscalationInput { status: string; @@ -102,7 +102,7 @@ export interface PutAwayInput { } export type ModalFormInput = Partial< - PurchaseQCInput & StockInInput & PutAwayInput + QCInput & StockInInput & PutAwayInput > & { escalationLog? : Partial }; diff --git a/src/components/PoDetail/PoInputGrid.tsx b/src/components/PoDetail/PoInputGrid.tsx index 200ee94..4918f4e 100644 --- a/src/components/PoDetail/PoInputGrid.tsx +++ b/src/components/PoDetail/PoInputGrid.tsx @@ -35,7 +35,7 @@ import ShoppingCartIcon from "@mui/icons-material/ShoppingCart"; import PlayArrowIcon from "@mui/icons-material/PlayArrow"; import { PurchaseOrderLine } from "@/app/api/po"; import { StockInLine } from "@/app/api/stockIn"; -import { createStockInLine, PurchaseQcResult } from "@/app/api/stockIn/actions"; +import { createStockInLine, QcResult } from "@/app/api/stockIn/actions"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { returnWeightUnit, @@ -140,7 +140,7 @@ function PoInputGrid({ setEntries(stockInLine); }, [stockInLine]) const [modalInfo, setModalInfo] = useState< - StockInLine & { qcResult?: PurchaseQcResult[] } & { escalationResult?: EscalationResult[] } + StockInLine & { qcResult?: QcResult[] } & { escalationResult?: EscalationResult[] } >(); const pathname = usePathname() const router = useRouter(); diff --git a/src/components/PoDetail/PutAwayForm.tsx b/src/components/PoDetail/PutAwayForm.tsx index 64c2441..bdc8c4c 100644 --- a/src/components/PoDetail/PutAwayForm.tsx +++ b/src/components/PoDetail/PutAwayForm.tsx @@ -1,6 +1,6 @@ "use client"; -import { PurchaseQcResult, PutAwayInput, PutAwayLine } from "@/app/api/stockIn/actions"; +import { PutAwayInput, PutAwayLine } from "@/app/api/stockIn/actions"; import { Autocomplete, Box, diff --git a/src/components/PoDetail/QcComponent.tsx b/src/components/PoDetail/QcComponent.tsx index 915ecc3..1a804d9 100644 --- a/src/components/PoDetail/QcComponent.tsx +++ b/src/components/PoDetail/QcComponent.tsx @@ -1,6 +1,6 @@ "use client"; -import { PurchaseQcResult, PurchaseQCInput } from "@/app/api/stockIn/actions"; +import { QcResult, QCInput } from "@/app/api/stockIn/actions"; import { Box, Card, @@ -90,7 +90,7 @@ const QcComponent: React.FC = ({ itemDetail, disabled = false }) => { resetField, setError, clearErrors, - } = useFormContext(); + } = useFormContext(); const [tabIndex, setTabIndex] = useState(0); const [rowSelectionModel, setRowSelectionModel] = useState(); @@ -103,8 +103,9 @@ const QcComponent: React.FC = ({ itemDetail, disabled = false }) => { const value = watch('qcResult'); //console.log("%c QC update!", "color:green", value); return Array.isArray(value) ? [...value] : []; }, [watch('qcResult')]); - const [qcHistory, setQcHistory] = useState([]); - const [qcResult, setQcResult] = useState([]); + const [qcHistory, setQcHistory] = useState([]); + const [qcResult, setQcResult] = useState([]); + const [newQcData, setNewQcData] = useState([]); const detailMode = useMemo(() => { const isDetailMode = itemDetail.status == "escalated" || isNaN(itemDetail.jobOrderId); @@ -140,7 +141,7 @@ const QcComponent: React.FC = ({ itemDetail, disabled = false }) => { } // W I P // - const validateFieldFail = (field : FieldPath, condition: boolean, message: string) : boolean => { + const validateFieldFail = (field : FieldPath, condition: boolean, message: string) : boolean => { // console.log("Checking if " + message) if (condition) { setError(field, { message: message}); return false; } else { clearErrors(field); return true; } @@ -224,7 +225,7 @@ const QcComponent: React.FC = ({ itemDetail, disabled = false }) => { return ; } - const qcDisabled = (row : PurchaseQcResult) => { + const qcDisabled = (row : QcResult) => { return disabled || isExist(row.escalationLogId); }; @@ -418,7 +419,7 @@ const QcComponent: React.FC = ({ itemDetail, disabled = false }) => { // const [openCollapse, setOpenCollapse] = useState(false) const [isCollapsed, setIsCollapsed] = useState(true); - const onFailedOpenCollapse = useCallback((qcItems: PurchaseQcResult[]) => { + const onFailedOpenCollapse = useCallback((qcItems: QcResult[]) => { const isFailed = qcItems.some((qc) => !qc.qcPassed) // console.log(isFailed) if (isFailed) { @@ -487,7 +488,7 @@ const QcComponent: React.FC = ({ itemDetail, disabled = false }) => { }, [itemDetail]) const dummyQcHeader = useMemo(() => { - const d = itemDetail;console.log("I am checking now", d); + const d = itemDetail; if (d.itemId == 23239 || d.itemNo == "PP2277" || d.itemName == "烚意粉") { return dummyQcHeader_E2; } else { diff --git a/src/components/PoDetail/QcStockInModal.tsx b/src/components/PoDetail/QcStockInModal.tsx index ec83d2c..95c1f8e 100644 --- a/src/components/PoDetail/QcStockInModal.tsx +++ b/src/components/PoDetail/QcStockInModal.tsx @@ -36,7 +36,7 @@ import { isEmpty } from "lodash"; import { EscalationCombo } from "@/app/api/user"; import { truncateSync } from "fs"; import { ModalFormInput, StockInLineInput, StockInLine } from "@/app/api/stockIn"; -import { PurchaseQcResult, StockInLineEntry, updateStockInLine, printQrCodeForSil, PrintQrCodeForSilRequest } from "@/app/api/stockIn/actions"; +import { StockInLineEntry, updateStockInLine, printQrCodeForSil, PrintQrCodeForSilRequest } from "@/app/api/stockIn/actions"; import { fetchStockInLineInfo } from "@/app/api/stockIn/actions"; import { fetchQcResult } from "@/app/api/qc/actions"; import { fetchEscalationLogsByStockInLines } from "@/app/api/escalation/actions"; diff --git a/src/components/PoDetail/StockInForm.tsx b/src/components/PoDetail/StockInForm.tsx index 0dad7e6..0829e6c 100644 --- a/src/components/PoDetail/StockInForm.tsx +++ b/src/components/PoDetail/StockInForm.tsx @@ -1,8 +1,6 @@ "use client"; import { - PurchaseQcResult, - PurchaseQCInput, StockInInput, } from "@/app/api/stockIn/actions"; import { diff --git a/src/components/StockIn/FgStockInForm.tsx b/src/components/StockIn/FgStockInForm.tsx index a76ca9b..c6ff5b6 100644 --- a/src/components/StockIn/FgStockInForm.tsx +++ b/src/components/StockIn/FgStockInForm.tsx @@ -1,8 +1,6 @@ "use client"; import { - PurchaseQcResult, - PurchaseQCInput, StockInInput, } from "@/app/api/stockIn/actions"; import {