diff --git a/src/app/api/jo/actions.ts b/src/app/api/jo/actions.ts index fc13546..76a38d8 100644 --- a/src/app/api/jo/actions.ts +++ b/src/app/api/jo/actions.ts @@ -145,12 +145,21 @@ export const recordSecondScanIssue = cache(async ( }, ); }); -export const updateSecondQrScanStatus = cache(async (pickOrderId: number, itemId: number) => { +export const updateSecondQrScanStatus = cache(async (pickOrderId: number, itemId: number, userId: number, qty: number) => { return serverFetchJson( - `${BASE_API_URL}/jo/second-scan-qr/${pickOrderId}/${itemId}`, + `${BASE_API_URL}/jo/update-match-status`, { method: "POST", - next: { tags: ["jo-second-scan"] }, + body: JSON.stringify({ + pickOrderId, + itemId, + userId, + qty + }), + headers: { + 'Content-Type': 'application/json', + }, + next: { tags: ["update-match-status"] }, }, ); }); diff --git a/src/components/Jodetail/JobPickExecutionsecondscan.tsx b/src/components/Jodetail/JobPickExecutionsecondscan.tsx index 2c46ad8..6c288ff 100644 --- a/src/components/Jodetail/JobPickExecutionsecondscan.tsx +++ b/src/components/Jodetail/JobPickExecutionsecondscan.tsx @@ -73,7 +73,8 @@ const QrCodeModal: React.FC<{ const [processedQrCodes, setProcessedQrCodes] = useState>(new Set()); const [scannedQrResult, setScannedQrResult] = useState(''); - + const { data: session } = useSession() as { data: SessionWithTokens | null }; + const currentUserId = session?.id ? parseInt(session.id) : // Process scanned QR codes useEffect(() => { if (qrValues.length > 0 && lot && !isProcessingQr && !qrScanSuccess) { @@ -660,7 +661,9 @@ const JobPickExecution: React.FC = ({ filterArgs }) => { // ✅ Use the new second scan API const result = await updateSecondQrScanStatus( matchingLot.pickOrderId, - matchingLot.itemId + matchingLot.itemId, + currentUserId || 0, + matchingLot.requiredQty || 1 // ✅ 传递实际的 required quantity ); if (result.code === "SUCCESS") { @@ -1261,7 +1264,7 @@ const paginatedData = useMemo(() => { ) : ( - {t("Pending")} + {t(" ")} )} @@ -1280,9 +1283,8 @@ const paginatedData = useMemo(() => { handleSubmitPickQtyWithQty(lot, submitQty); }} disabled={ - // ✅ 修复:使用 matchStatus 而不是 secondQrScanStatus - lot.matchStatus === 'pending' || // 未扫描 - lot.matchStatus === 'completed' || // 已完成 + // ✅ 修复:只有扫描过但未完成的才能提交 + lot.matchStatus !== 'scanned' || // 只有 scanned 状态才能提交 lot.lotAvailability === 'expired' || lot.lotAvailability === 'status_unavailable' || lot.lotAvailability === 'rejected' @@ -1302,9 +1304,8 @@ const paginatedData = useMemo(() => { size="small" onClick={() => handlePickExecutionForm(lot)} disabled={ - // ✅ 修复:使用 matchStatus 而不是 secondQrScanStatus - lot.matchStatus === 'pending' || // 未扫描 - lot.matchStatus === 'completed' || // 已完成 + // ✅ 修复:只有扫描过但未完成的才能报告问题 + lot.matchStatus !== 'scanned' || // 只有 scanned 状态才能报告问题 lot.lotAvailability === 'expired' || lot.lotAvailability === 'status_unavailable' || lot.lotAvailability === 'rejected'