diff --git a/pages/picking/picking.vue b/pages/picking/picking.vue index b959307..ca6a61d 100644 --- a/pages/picking/picking.vue +++ b/pages/picking/picking.vue @@ -117,7 +117,7 @@ - + 装柜证据空仓、半仓、满仓、锁仓及带锁码照 {{ remoteSyncState.label }} @@ -147,6 +147,10 @@ + + 拣货已完成,装柜状态尚未同步,请刷新重试 + + @@ -371,7 +375,7 @@ selectedIncompleteReason: '', completionSummary: { picked: 0, partial: 0, skipped: 0, autoSkipped: 0 }, evidenceSlots: EVIDENCE_SLOTS, - evidenceFiles: {}, evidenceQueueItems: [], evidenceQueue: null, evidenceContextId: 0, sealNo: '', loadingVersion: null, pickingVersion: null, remotePick: null, + evidenceFiles: {}, evidenceQueueItems: [], evidenceQueue: null, evidenceContextId: 0, evidenceIdentity: null, sealNo: '', loadingVersion: null, pickingVersion: null, remotePick: null, remoteTaskId: null, assignmentVersion: null, submitId: '', taskRequestId: 0, remoteError: '', remoteLoading: false, submitting: false, @@ -410,6 +414,12 @@ return Boolean(this.completedBoxes[this.currentBoxIndex]) || isPickingCompleteTask(this.remotePick) }, + loadingStageReady() { + return this.pickingCompleted + && this.evidenceIdentity + && this.evidenceIdentity.inboundId + && Number.isFinite(Number(this.loadingVersion)) + }, partialTargetItem() { return this.currentBox.items.find((item) => item.id === this.partialTargetId) || null }, @@ -514,18 +524,36 @@ }) } catch (_) { /* console may be unavailable on a device */ } }, - isEvidenceContextActive(contextId, inboundId) { + captureEvidenceIdentity() { + return { + taskId: this.remoteTaskId || this.currentBox.taskId || null, + inboundId: this.currentBox.inboundId || null, + loadingPlanId: this.currentBox.loadingPlanId || null, + containerBookingId: this.currentBox.containerBookingId || null + } + }, + isSameEvidenceIdentity(left, right) { + return ['taskId', 'inboundId', 'loadingPlanId', 'containerBookingId'].every((key) => String(left?.[key] ?? '') === String(right?.[key] ?? '')) + }, + isEvidenceContextActive(contextId, identity) { return contextId === this.evidenceContextId - && String(this.currentBox.inboundId ?? '') === String(inboundId ?? '') + && this.isSameEvidenceIdentity(this.evidenceIdentity, identity) }, requireEvidenceStage() { - if (this.pickingCompleted) return true - this.showToast('请先提交拣货完成', 'warning') - return false + if (!this.pickingCompleted) { + this.showToast('请先提交拣货完成', 'warning') + return false + } + if (!this.loadingStageReady) { + this.showToast(VERSION_SYNC_MESSAGE, 'warning') + return false + } + return true }, resetEvidenceState() { const contextId = this.evidenceContextId + 1 this.evidenceContextId = contextId + this.evidenceIdentity = null this.evidenceFiles = {} this.evidenceQueueItems = [] this.sealNo = '' @@ -728,12 +756,18 @@ async syncRemoteTask() { if (!isRemoteReady(this.currentBox.inboundId || this.currentBox.boxNo)) return const requestId = ++this.taskRequestId - this.debugSubmit('refresh.start', { requestId, inboundId: this.currentBox.inboundId || null, cabinetNo: this.currentBox.cabinetNo || null }) + const selector = { taskId: this.remoteTaskId || this.currentBox.taskId, cabinetNo: this.currentBox.cabinetNo, loadingPlanId: this.currentBox.loadingPlanId } + this.currentBox.inboundId = null + this.currentBox.loadingPlanId = null + this.currentBox.containerBookingId = null + this.loadingVersion = null + this.resetEvidenceState() + this.debugSubmit('refresh.start', { requestId, cabinetNo: this.currentBox.cabinetNo || null, selector }) this.remoteLoading = true this.remoteError = '' try { const warehouseId = this.currentBox.warehouseId || session.currentUser?.warehouseId || session.currentUser?.warehouse - const task = await getContainerPickingTask({ taskId: this.remoteTaskId || this.currentBox.taskId, cabinetNo: this.currentBox.cabinetNo, loadingPlanId: this.currentBox.loadingPlanId }, warehouseId) + const task = await getContainerPickingTask(selector, warehouseId) if (requestId !== this.taskRequestId) return if (!task) throw new Error('未找到当前柜次的拣货任务') const remoteItems = task.items || task.pickItems || task.details || task.lines @@ -758,8 +792,9 @@ })) const firstItem = this.currentBox.items[0] this.currentBox.orderNo = firstItem.orderNo || firstItem.inboundCode || this.currentBox.orderNo - this.currentBox.inboundId = firstItem.inboundId || this.currentBox.inboundId - this.currentBox.tenantId = firstItem.tenantId || this.currentBox.tenantId + if (!firstItem.inboundId) throw new Error('服务端任务明细缺少 inboundId,无法进入装柜取证') + this.currentBox.inboundId = firstItem.inboundId + this.currentBox.tenantId = firstItem.tenantId || null const serverStates = createItemStates(this.currentBox.items) const serverPartialQuantities = {} this.currentBox.items.forEach((item) => {