This commit is contained in:
2026-08-27 14:53:44 +08:00
parent a493a7faeb
commit c06b808354
3 changed files with 62 additions and 7 deletions
+27 -5
View File
@@ -347,7 +347,7 @@
import { ITEM_STATUS, classifyScan, createItemStates, getPickSummary, submitStates } from '@/utils/picking-state.js'
import { SKIP_REASONS, INCOMPLETE_REASONS } from '@/data/demo-data.js'
import { session, requireSession } from '@/stores/session.js'
import { clearPickingDraft, getPickingSession, restorePickingSession, savePickingSession } from '@/stores/picking.js'
import { clearLoadingCompletionAttempt, clearPickingDraft, getPickingSession, restoreLoadingCompletionAttempt, restorePickingSession, saveLoadingCompletionAttempt, savePickingSession } from '@/stores/picking.js'
import { navigateBackOr } from '@/utils/navigation.js'
import { startScanBroadcast } from '@/utils/scan-broadcast.js'
import { playErrorSound, playSuccessSound } from '@/utils/audio-feedback.js'
@@ -356,6 +356,7 @@
import { isOnline } from '@/utils/network.js'
import { stableOperationId } from '@/utils/idempotency.js'
import { stableTaskOperationIdentity } from '@/utils/task-identity.js'
import { COMPLETION_PHASE, resolveCompletionPhase, shouldReconcileCompletion } from '@/utils/loading-completion-state.js'
import ScanTargetInput from '@/components/ScanTargetInput.vue'
import PopupHeader from '@/components/PopupHeader.vue'
@@ -365,7 +366,11 @@
const workflowStatus = task?.workflowStatus
const taskStatus = task?.taskStatus ?? task?.status
return workflowStatus === 'AWAITING_REVIEW'
|| workflowStatus === 'PROCESSING'
|| workflowStatus === 'COMPLETION_FAILED'
|| workflowStatus === 'COMPLETED'
|| taskStatus === 'COMPLETING'
|| taskStatus === 'COMPLETION_FAILED'
|| taskStatus === 'COMPLETED'
}
@@ -1390,29 +1395,46 @@
if (!this.evidenceComplete) { this.showToast('五类有效照片和封签号均为必填', 'warning'); return }
const contextId = this.evidenceContextId
const identity = { ...this.evidenceIdentity }
const expectedTaskVersion = Number(this.pickingVersion)
const savedAttempt = restoreLoadingCompletionAttempt(this.draftIdentity())
const expectedTaskVersion = savedAttempt?.expectedTaskVersion ?? Number(this.pickingVersion)
const operationIdentity = stableTaskOperationIdentity(this.draftIdentity())
const operationId = stableOperationId('complete', operationIdentity, {
const operationId = savedAttempt?.operationId || stableOperationId('complete', operationIdentity, {
taskId: this.remoteTaskId,
expectedTaskVersion,
loadingPlanId: identity.loadingPlanId,
containerBookingId: identity.containerBookingId
})
const completionAttempt = { operationId, expectedTaskVersion, remark: savedAttempt?.remark || 'PDA确认装柜完成' }
saveLoadingCompletionAttempt(this.draftIdentity(), completionAttempt)
this.submitting = true
try {
const completedTask = await completeContainerPickingTask(this.remoteTaskId, {
expectedTaskVersion,
operationId,
remark: 'PDA确认装柜完成'
remark: completionAttempt.remark
})
if (!this.isEvidenceContextActive(contextId, identity)) return
if (completedTask) {
this.remotePick = normalizePickingTask({ ...this.remotePick, ...completedTask })
this.pickingVersion = this.remotePick.pickingVersion ?? this.remotePick.version ?? this.pickingVersion
}
this.showToast('已确认装柜完成', 'success')
const phase = resolveCompletionPhase({ taskStatus: completedTask?.taskStatus, commandStatus: completedTask?.commandStatus })
if (phase === COMPLETION_PHASE.PROCESSING) {
this.showToast('完成命令已受理,后台处理中', 'success')
this.persistSession()
navigateBackOr('/pages/tasks/tasks')
return
}
if (phase === COMPLETION_PHASE.COMPLETED) clearLoadingCompletionAttempt(this.draftIdentity())
this.showToast('装柜已完成', 'success')
} catch (error) {
if (!this.isEvidenceContextActive(contextId, identity)) return
if (shouldReconcileCompletion(error)) {
this.remoteError = '提交结果待确认,请返回任务列表刷新'
this.showToast('提交结果待确认', 'warning')
navigateBackOr('/pages/tasks/tasks')
return
}
if (this.isTaskConflict(error)) {
await this.refreshAfterTaskConflict(error.message || '订舱、装柜关联或证据状态已变化,请刷新后重试')
return