diff --git a/src/app/api/jo/actions.ts b/src/app/api/jo/actions.ts index 805b1cf..358d9b5 100644 --- a/src/app/api/jo/actions.ts +++ b/src/app/api/jo/actions.ts @@ -208,6 +208,7 @@ export interface ProductProcessWithLinesResponse { bomId?: number; jobOrderId?: number; jobOrderCode: string; + jobOrderStatus: string; isDark: string; isDense: number; isFloat: string; @@ -230,6 +231,13 @@ export interface UpdateProductProcessLineQtyRequest { byproductUom: string; defectQty: number; defectUom: string; + defect2Qty: number; + defect2Uom: string; + defect3Qty: number; + defect3Uom: string; + defectDescription: string; + defectDescription2: string; + defectDescription3: string; scrapQty: number; scrapUom: string; } @@ -239,6 +247,13 @@ export interface UpdateProductProcessLineQtyResponse { outputFromProcessUom: string; defectQty: number; defectUom: string; + defect2Qty: number; + defect2Uom: string; + defect3Qty: number; + defect3Uom: string; + defectDescription: string; + defectDescription2: string; + defectDescription3: string; scrapQty: number; scrapUom: string; byproductName: string; @@ -344,6 +359,13 @@ export interface JobOrderProcessLineDetailResponse { outputFromProcessUom: string; defectQty: number; defectUom: string; + defectDescription: string; + defectQty2: number; + defectUom2: string; + defectDescription2: string; + defectQty3: number; + defectUom3: string; + defectDescription3: string; scrapQty: number; scrapUom: string; byproductId: number; diff --git a/src/components/PoDetail/PoDetail.tsx b/src/components/PoDetail/PoDetail.tsx index 62159a7..e2a55fd 100644 --- a/src/components/PoDetail/PoDetail.tsx +++ b/src/components/PoDetail/PoDetail.tsx @@ -260,14 +260,15 @@ const PoDetail: React.FC = ({ po, warehouse, printerCombo }) => { }, [selectedIdsParam]); - const fetchPoDetail = useCallback(async (poId: string) => { + const fetchPoDetail = useCallback(async (poId: string, preserveDnNo: boolean = false) => { try { const result = await fetchPoInClient(parseInt(poId)); if (result) { console.log("%c Fetched PO:", "color:orange", result); setPurchaseOrder(result); + const currentDnNo = preserveDnNo ? dnFormProps.getValues("dnNo") : ""; dnFormProps.reset({ - dnNo: "", + dnNo: currentDnNo, receiptDate: dayjsToDateString(dayjs()), }); setRows(result.pol || []); @@ -416,6 +417,7 @@ const PoDetail: React.FC = ({ po, warehouse, printerCombo }) => { () => { setTimeout(async () => { // post stock in line + const currentDnNo = dnFormProps.watch("dnNo"); const oldId = row.id; const acceptedQty = Number(polInputList[rowIndex].dnQty); if (isNaN(acceptedQty) || acceptedQty <= 0) { alert("來貨數量必須大於0!"); return; } // Temp check, need update @@ -436,7 +438,8 @@ const PoDetail: React.FC = ({ po, warehouse, printerCombo }) => { // if (secondReceiveQty === 0) return const res = await createStockInLine(postData); if (res) { - fetchPoDetail(selectedPoId.toString()); + fetchPoDetail(selectedPoId.toString(), true); + //dnFormProps.setValue("dnNo", currentDnNo); } console.log(res); }, 200); diff --git a/src/components/ProductionProcess/ProductionProcessJobOrderDetail.tsx b/src/components/ProductionProcess/ProductionProcessJobOrderDetail.tsx index 2c6dd6c..2f8f045 100644 --- a/src/components/ProductionProcess/ProductionProcessJobOrderDetail.tsx +++ b/src/components/ProductionProcess/ProductionProcessJobOrderDetail.tsx @@ -28,6 +28,7 @@ import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutli import DoDisturbAltRoundedIcon from '@mui/icons-material/DoDisturbAltRounded'; import { fetchInventories } from "@/app/api/inventory/actions"; import { InventoryResult } from "@/app/api/inventory"; +import { releaseJo, startJo } from "@/app/api/jo/actions"; import JobPickExecutionsecondscan from "../Jodetail/JobPickExecutionsecondscan"; interface JobOrderLine { id: number; @@ -127,9 +128,13 @@ const stockCounts = useMemo(() => { }, [jobOrderLines, inventoryData]); const status = processData?.status?.toLowerCase?.() ?? ""; -const handleRelease = useCallback(() => { +const handleRelease = useCallback(async ( jobOrderId: number) => { // TODO: 替换为实际的 release 调用 console.log("Release clicked for jobOrderId:", jobOrderId); + const response = await releaseJo({ id: jobOrderId }) + if (response) { + setProcessData(response.entity); + } }, [jobOrderId]); const handleTabChange = useCallback>( (_e, newValue) => { @@ -372,8 +377,8 @@ const handleRelease = useCallback(() => { diff --git a/src/components/ProductionProcess/ProductionProcessStepExecution.tsx b/src/components/ProductionProcess/ProductionProcessStepExecution.tsx index c8d8fb3..445ffcd 100644 --- a/src/components/ProductionProcess/ProductionProcessStepExecution.tsx +++ b/src/components/ProductionProcess/ProductionProcessStepExecution.tsx @@ -53,7 +53,14 @@ const ProductionProcessStepExecution: React.FC>(new Set()); @@ -135,6 +142,13 @@ const ProductionProcessStepExecution: React.FC - {t("Type")} - {t("Quantity")} - {t("Unit")} + {t("Type")} + {t("Quantity")} + {t("Unit")} + {t("Description")} @@ -306,8 +328,41 @@ const ProductionProcessStepExecution: React.FC {lineDetail.defectUom || "-"} + + {lineDetail.defectDescription || "-"} + + + + + + {t("Defect")}{t("(3)")} + + + {lineDetail.defectQty3} + + + {lineDetail.defectUom3 || "-"} + + + {lineDetail.defectDescription3 || "-"} + + + + + + {t("Defect")}{t("(2)")} + + + {lineDetail.defectQty2} + + + {lineDetail.defectUom2 || "-"} + + + {lineDetail.defectDescription2 || "-"} + + - {/* Scrap */} @@ -506,7 +561,7 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectUom: e.target.value + defectDescription: e.target.value })} /> @@ -521,10 +576,10 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectQty: parseInt(e.target.value) || 0 + defect2Qty: parseInt(e.target.value) || 0 })} /> @@ -532,10 +587,10 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectUom: e.target.value + defect2Uom: e.target.value })} /> @@ -546,7 +601,7 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectUom: e.target.value + defectDescription2: e.target.value })} /> @@ -561,10 +616,10 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectQty: parseInt(e.target.value) || 0 + defect3Qty: parseInt(e.target.value) || 0 })} /> @@ -572,10 +627,10 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectUom: e.target.value + defect3Uom: e.target.value })} /> @@ -586,7 +641,7 @@ const ProductionProcessStepExecution: React.FC setOutputData({ ...outputData, - defectUom: e.target.value + defectDescription3: e.target.value })} />