Browse Source

update

master
CANCERYS\kw093 2 months ago
parent
commit
7c53716473
2 changed files with 22 additions and 12 deletions
  1. +12
    -3
      src/app/api/jo/actions.ts
  2. +10
    -9
      src/components/Jodetail/JobPickExecutionsecondscan.tsx

+ 12
- 3
src/app/api/jo/actions.ts View File

@@ -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<any>( return serverFetchJson<any>(
`${BASE_API_URL}/jo/second-scan-qr/${pickOrderId}/${itemId}`,
`${BASE_API_URL}/jo/update-match-status`,
{ {
method: "POST", method: "POST",
next: { tags: ["jo-second-scan"] },
body: JSON.stringify({
pickOrderId,
itemId,
userId,
qty
}),
headers: {
'Content-Type': 'application/json',
},
next: { tags: ["update-match-status"] },
}, },
); );
}); });


+ 10
- 9
src/components/Jodetail/JobPickExecutionsecondscan.tsx View File

@@ -73,7 +73,8 @@ const QrCodeModal: React.FC<{
const [processedQrCodes, setProcessedQrCodes] = useState<Set<string>>(new Set()); const [processedQrCodes, setProcessedQrCodes] = useState<Set<string>>(new Set());
const [scannedQrResult, setScannedQrResult] = useState<string>(''); const [scannedQrResult, setScannedQrResult] = useState<string>('');
const { data: session } = useSession() as { data: SessionWithTokens | null };
const currentUserId = session?.id ? parseInt(session.id) :
// Process scanned QR codes // Process scanned QR codes
useEffect(() => { useEffect(() => {
if (qrValues.length > 0 && lot && !isProcessingQr && !qrScanSuccess) { if (qrValues.length > 0 && lot && !isProcessingQr && !qrScanSuccess) {
@@ -660,7 +661,9 @@ const JobPickExecution: React.FC<Props> = ({ filterArgs }) => {
// ✅ Use the new second scan API // ✅ Use the new second scan API
const result = await updateSecondQrScanStatus( const result = await updateSecondQrScanStatus(
matchingLot.pickOrderId, matchingLot.pickOrderId,
matchingLot.itemId
matchingLot.itemId,
currentUserId || 0,
matchingLot.requiredQty || 1 // ✅ 传递实际的 required quantity
); );
if (result.code === "SUCCESS") { if (result.code === "SUCCESS") {
@@ -1261,7 +1264,7 @@ const paginatedData = useMemo(() => {
</Box> </Box>
) : ( ) : (
<Typography variant="body2" color="text.secondary"> <Typography variant="body2" color="text.secondary">
{t("Pending")}
{t(" ")}
</Typography> </Typography>
)} )}
</TableCell> </TableCell>
@@ -1280,9 +1283,8 @@ const paginatedData = useMemo(() => {
handleSubmitPickQtyWithQty(lot, submitQty); handleSubmitPickQtyWithQty(lot, submitQty);
}} }}
disabled={ disabled={
// ✅ 修复:使用 matchStatus 而不是 secondQrScanStatus
lot.matchStatus === 'pending' || // 未扫描
lot.matchStatus === 'completed' || // 已完成
// ✅ 修复:只有扫描过但未完成的才能提交
lot.matchStatus !== 'scanned' || // 只有 scanned 状态才能提交
lot.lotAvailability === 'expired' || lot.lotAvailability === 'expired' ||
lot.lotAvailability === 'status_unavailable' || lot.lotAvailability === 'status_unavailable' ||
lot.lotAvailability === 'rejected' lot.lotAvailability === 'rejected'
@@ -1302,9 +1304,8 @@ const paginatedData = useMemo(() => {
size="small" size="small"
onClick={() => handlePickExecutionForm(lot)} onClick={() => handlePickExecutionForm(lot)}
disabled={ disabled={
// ✅ 修复:使用 matchStatus 而不是 secondQrScanStatus
lot.matchStatus === 'pending' || // 未扫描
lot.matchStatus === 'completed' || // 已完成
// ✅ 修复:只有扫描过但未完成的才能报告问题
lot.matchStatus !== 'scanned' || // 只有 scanned 状态才能报告问题
lot.lotAvailability === 'expired' || lot.lotAvailability === 'expired' ||
lot.lotAvailability === 'status_unavailable' || lot.lotAvailability === 'status_unavailable' ||
lot.lotAvailability === 'rejected' lot.lotAvailability === 'rejected'


Loading…
Cancel
Save