| @@ -2714,15 +2714,20 @@ const handleSubmitAllScanned = useCallback(async () => { | |||
| console.log(`⏰ Start time: ${new Date().toISOString()}`); | |||
| const scannedLots = combinedLotData.filter(lot => { | |||
| // 如果是 noLot 情况,检查状态是否为 pending 或 partially_complete | |||
| const status = lot.stockOutLineStatus; | |||
| // ✅ noLot 情况:允许 checked / pending / partially_completed / PARTIALLY_COMPLETE | |||
| if (lot.noLot === true) { | |||
| return lot.stockOutLineStatus === 'checked' || | |||
| lot.stockOutLineStatus === 'pending' || | |||
| lot.stockOutLineStatus === 'partially_completed' || | |||
| lot.stockOutLineStatus === 'PARTIALLY_COMPLETE'; | |||
| } | |||
| // 正常情况:只包含 checked 状态 | |||
| return lot.stockOutLineStatus === 'checked'; | |||
| return status === 'checked' || | |||
| status === 'pending' || | |||
| status === 'partially_completed' || | |||
| status === 'PARTIALLY_COMPLETE'; | |||
| } | |||
| // ✅ 正常 lot:也放宽为允许 checked / pending / partially_completed / PARTIALLY_COMPLETE | |||
| // 这样即使用户先改数(状态变为 pending / partially_completed),仍然可以批量提交 | |||
| return status === 'checked' || | |||
| status === 'pending' || | |||
| status === 'partially_completed' || | |||
| status === 'PARTIALLY_COMPLETE'; | |||
| }); | |||
| if (scannedLots.length === 0) { | |||
| @@ -2813,16 +2818,18 @@ const handleSubmitAllScanned = useCallback(async () => { | |||
| // Calculate scanned items count (should match handleSubmitAllScanned filter logic) | |||
| const scannedItemsCount = useMemo(() => { | |||
| const filtered = combinedLotData.filter(lot => { | |||
| // ✅ FIXED: 使用与 handleSubmitAllScanned 相同的过滤逻辑 | |||
| const status = lot.stockOutLineStatus; | |||
| // ✅ 与 handleSubmitAllScanned 完全保持一致 | |||
| if (lot.noLot === true) { | |||
| // ✅ 只包含可以提交的状态(与 handleSubmitAllScanned 保持一致) | |||
| return lot.stockOutLineStatus === 'checked' || | |||
| lot.stockOutLineStatus === 'pending' || | |||
| lot.stockOutLineStatus === 'partially_completed' || | |||
| lot.stockOutLineStatus === 'PARTIALLY_COMPLETE'; | |||
| return status === 'checked' || | |||
| status === 'pending' || | |||
| status === 'partially_completed' || | |||
| status === 'PARTIALLY_COMPLETE'; | |||
| } | |||
| // 正常情况:只包含 checked 状态 | |||
| return lot.stockOutLineStatus === 'checked'; | |||
| return status === 'checked' || | |||
| status === 'pending' || | |||
| status === 'partially_completed' || | |||
| status === 'PARTIALLY_COMPLETE'; | |||
| }); | |||
| // 添加调试日志 | |||
| @@ -2840,14 +2847,11 @@ const handleSubmitAllScanned = useCallback(async () => { | |||
| // ADD THIS: Auto-stop scan when no data available | |||
| useEffect(() => { | |||
| return () => { | |||
| if (isManualScanning) { | |||
| console.log("🧹 Pick execution component unmounting, stopping QR scanner..."); | |||
| stopScan(); | |||
| resetScan(); | |||
| } | |||
| }; | |||
| }, [isManualScanning, stopScan, resetScan]); | |||
| if (isManualScanning && combinedLotData.length === 0) { | |||
| console.log("⏹️ No data available, auto-stopping QR scan..."); | |||
| handleStopScan(); | |||
| } | |||
| }, [combinedLotData.length, isManualScanning, handleStopScan]); | |||
| // Cleanup effect | |||
| useEffect(() => { | |||
| @@ -2981,8 +2985,7 @@ const handleSubmitAllScanned = useCallback(async () => { | |||
| color="success" | |||
| onClick={handleSubmitAllScanned} | |||
| disabled={ | |||
| // scannedItemsCount === 0 | |||
| !allItemsReady | |||
| scannedItemsCount === 0 | |||
| || isSubmittingAll} | |||
| sx={{ minWidth: '160px' }} | |||
| > | |||