From eaa9477faaa6fb0bc46dca384f4eb49973b4ae51 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Mon, 23 Feb 2026 17:20:31 +0800 Subject: [PATCH] update jobmatch --- .../Jodetail/JobPickExecutionForm.tsx | 40 ++++++++------ .../Jodetail/JobPickExecutionsecondscan.tsx | 55 +++++-------------- src/components/Jodetail/JobmatchForm.tsx | 2 +- src/i18n/zh/common.json | 24 +++++++- src/i18n/zh/jo.json | 9 +++ src/i18n/zh/pickOrder.json | 1 + 6 files changed, 70 insertions(+), 61 deletions(-) diff --git a/src/components/Jodetail/JobPickExecutionForm.tsx b/src/components/Jodetail/JobPickExecutionForm.tsx index 6d6a054..42916c3 100644 --- a/src/components/Jodetail/JobPickExecutionForm.tsx +++ b/src/components/Jodetail/JobPickExecutionForm.tsx @@ -91,7 +91,9 @@ const PickExecutionForm: React.FC = ({ const [handlers, setHandlers] = useState>([]); const [verifiedQty, setVerifiedQty] = useState(0); const { data: session } = useSession() as { data: SessionWithTokens | null }; - + const missSet = formData.missQty != null; +const badItemSet = formData.badItemQty != null; +const badPackageSet = (formData as any).badPackageQty != null; const calculateRemainingAvailableQty = useCallback((lot: LotPickData) => { return lot.availableQty || 0; }, []); @@ -162,9 +164,9 @@ useEffect(() => { storeLocation: selectedLot.location, requiredQty: selectedLot.requiredQty, actualPickQty: initialVerifiedQty, - missQty: 0, - badItemQty: 0, - badPackageQty: 0, // Bad Package Qty (frontend only) + missQty: undefined, + badItemQty: undefined, + badPackageQty: undefined, issueRemark: "", pickerName: "", handledBy: undefined, @@ -195,10 +197,10 @@ useEffect(() => { const newErrors: FormErrors = {}; const ap = Number(verifiedQty) || 0; const miss = Number(formData.missQty) || 0; - const badItem = Number(formData.badItemQty) || 0; - const badPackage = Number((formData as any).badPackageQty) || 0; - const totalBad = badItem + badPackage; - const total = ap + miss + totalBad; + const badItem = Number(formData.badItemQty) ?? 0; + const badPackage = Number((formData as any).badPackageQty) ?? 0; + const totalBadQty = badItem + badPackage; + const total = ap + miss + totalBadQty; const availableQty = selectedLot?.availableQty || 0; // 1. Check actualPickQty cannot be negative @@ -231,7 +233,7 @@ useEffect(() => { } // 5. At least one field must have a value - if (ap === 0 && miss === 0 && totalBad === 0) { + if (ap === 0 && miss === 0 && totalBadQty === 0) { newErrors.actualPickQty = t("Enter pick qty or issue qty"); } @@ -288,11 +290,12 @@ useEffect(() => { const submissionData: PickExecutionIssueData = { ...(formData as PickExecutionIssueData), actualPickQty: verifiedQty, - lotId: formData.lotId || selectedLot?.lotId || 0, - lotNo: formData.lotNo || selectedLot?.lotNo || '', - pickOrderCode: formData.pickOrderCode || selectedPickOrderLine?.pickOrderCode || '', - pickerName: session?.user?.name || '', - badItemQty: totalBadQty, + lotId: formData.lotId ?? selectedLot?.lotId ?? 0, + lotNo: formData.lotNo ?? selectedLot?.lotNo ?? '', + pickOrderCode: formData.pickOrderCode ?? selectedPickOrderLine?.pickOrderCode ?? '', + pickerName: session?.user?.name ?? '', + missQty: formData.missQty ?? 0, // 这里:null/undefined → 0 + badItemQty: totalBadQty, // totalBadQty 下面用 ?? 0 算 badReason, }; @@ -397,7 +400,8 @@ useEffect(() => { pattern: "[0-9]*", min: 0, }} - value={formData.missQty || 0} + disabled={badItemSet || badPackageSet} + value={formData.missQty || ""} onChange={(e) => { handleInputChange( "missQty", @@ -421,7 +425,7 @@ useEffect(() => { pattern: "[0-9]*", min: 0, }} - value={formData.badItemQty || 0} + value={formData.badItemQty || ""} onChange={(e) => { const newBadItemQty = e.target.value === "" ? undefined @@ -429,6 +433,7 @@ useEffect(() => { handleInputChange('badItemQty', newBadItemQty); }} error={!!errors.badItemQty} + disabled={missSet || badPackageSet} helperText={errors.badItemQty} variant="outlined" /> @@ -444,7 +449,7 @@ useEffect(() => { pattern: "[0-9]*", min: 0, }} - value={(formData as any).badPackageQty || 0} + value={(formData as any).badPackageQty || ""} onChange={(e) => { handleInputChange( "badPackageQty", @@ -453,6 +458,7 @@ useEffect(() => { : Math.max(0, Number(e.target.value) || 0) ); }} + disabled={missSet || badItemSet} error={!!errors.badItemQty} variant="outlined" /> diff --git a/src/components/Jodetail/JobPickExecutionsecondscan.tsx b/src/components/Jodetail/JobPickExecutionsecondscan.tsx index 823f79c..21163e1 100644 --- a/src/components/Jodetail/JobPickExecutionsecondscan.tsx +++ b/src/components/Jodetail/JobPickExecutionsecondscan.tsx @@ -868,7 +868,8 @@ const JobPickExecution: React.FC = ({ filterArgs, onBack }) => { qty: submitQty, isMissing: false, isBad: false, - reason: undefined + reason: undefined, + userId: currentUserId ?? 0 } ); @@ -881,7 +882,7 @@ const JobPickExecution: React.FC = ({ filterArgs, onBack }) => { } catch (error) { console.error("Error submitting second scan quantity:", error); } - }, [fetchJobOrderData]); + }, [fetchJobOrderData, currentUserId]); const handlePickExecutionForm = useCallback((lot: any) => { console.log("=== Pick Execution Form ==="); @@ -1263,55 +1264,24 @@ const JobPickExecution: React.FC = ({ filterArgs, onBack }) => { return requiredQty.toLocaleString()+'('+lot.uomShortDesc+')'; })()} - {/* - - {lot.matchStatus?.toLowerCase() === 'scanned' || - lot.matchStatus?.toLowerCase() === 'completed' ? ( - - - - ) : ( - - {t(" ")} - - )} - - */} +