diff --git a/pages/dropship-palletization/dropship-palletization.vue b/pages/dropship-palletization/dropship-palletization.vue index 12c35cb..2db950f 100644 --- a/pages/dropship-palletization/dropship-palletization.vue +++ b/pages/dropship-palletization/dropship-palletization.vue @@ -116,7 +116,7 @@ assignableCurrentPallet() { return this.currentPallet?.status === 'OPEN' ? this.currentPallet : null } }, onLoad(options) { this.taskId = String(options.taskId || ''); this.warehouseId = String(options.warehouseId || ''); this.initialPalletNo = String(options.palletNo || '') }, - onShow() { if (!requireSession()) return; this.user = session.currentUser; const draft = restoreDropshipPalletizingDraft(this.draftIdentity()); this.selectedPalletNo = this.initialPalletNo || draft?.activePalletNo || ''; this.initialPalletNo = ''; this.startScanner(); this.loadTask() }, + onShow() { if (!requireSession()) return; this.user = session.currentUser; const draft = restoreDropshipPalletizingDraft(this.draftIdentity()); this.selectedPalletNo = this.initialPalletNo || draft?.activePalletNo || ''; this.initialPalletNo = ''; this.startScanner(); this.loadTask({ restorePallet: true }) }, onHide() { this.stopScanner() }, onUnload() { this.stopScanner() }, beforeUnmount() { this.stopScanner() }, onBackPress() { if (!this.unsealOpen) return false; this.closeUnseal(); return true }, methods: { @@ -124,10 +124,10 @@ stopScanner() { if (this._stopScanner) this._stopScanner(); this._stopScanner = null }, handleScan(value) { if (this.loading || this.submitting) return; if (!this.palletSetupReady) { this.error = this.palletSetupMessage; return } const plan = planDropshipScan(createDropshipScanState({ online: isOnline() }), value, { unboundCartons: this.task?.unboundCartons }); if ([DROPSHIP_SCAN_INTENT.BLOCKED, DROPSHIP_SCAN_INTENT.INVALID].includes(plan.intent)) { this.error = plan.message; return } const code = plan.palletNo || plan.boxCode; if (plan.palletNo) { this.palletCode = code; this.selectPallet(code) } else { this.boxCode = code; this.resolveCarton() } }, resetMessages() { this.error = ''; this.notice = '' }, - async loadTask() { + async loadTask({ restorePallet = false } = {}) { if (!this.taskId || !this.warehouseId) { this.error = '缺少合托任务或仓库信息,请返回任务列表'; return } this.loading = true; this.resetMessages() - try { this.task = await getDropshipPalletizationTask(this.taskId, this.warehouseId); await this.refreshPallet(); if (this.task.taskStatus === 'COMPLETED') clearDropshipPalletizingDraft(this.draftIdentity()) } + try { this.task = await getDropshipPalletizationTask(this.taskId, this.warehouseId); await this.refreshPallet({ restorePallet }); if (this.task.taskStatus === 'COMPLETED') clearDropshipPalletizingDraft(this.draftIdentity()) } catch (error) { this.error = formatApiError(error, '一件代发入库任务加载失败') } finally { this.loading = false } }, @@ -175,7 +175,18 @@ if (Number(this.task?.unboundCartons || 0) > 0) await this.runMutation(() => bindDropshipPendingCartons(this.taskId, this.warehouseId, code, this.task.version), `待归托箱已绑定至 ${code}`) else this.notice = `已选择仓库开放托盘 ${code},可连续扫描不同客户的箱码` }, - async refreshPallet() { if (!this.selectedPalletNo) { this.workspace = null; return }; this.workspace = null; this.workspace = await resolveDropshipWorkspacePallet(this.warehouseId, this.selectedPalletNo) }, + // 页面恢复只延续开放托盘;主动扫码和刚封托后的回查仍保留真实封托结果。 + async refreshPallet({ restorePallet = false } = {}) { + this.workspace = null + if (!this.selectedPalletNo) return + const workspace = await resolveDropshipWorkspacePallet(this.warehouseId, this.selectedPalletNo) + if (restorePallet && workspace.pallet.status !== 'OPEN') { + this.selectedPalletNo = ''; this.selectedPalletId = ''; this.palletCode = '' + clearDropshipPalletizingDraft(this.draftIdentity()) + return + } + this.workspace = workspace + }, memberForCarton(carton) { return this.palletMembers.find((member) => String(member.inboundId) === String(carton.inboundId)) }, async activateScanTask() { const targetId = String(this.scanTask?.taskId || this.taskId) diff --git a/pages/dropship-tasks/dropship-tasks.vue b/pages/dropship-tasks/dropship-tasks.vue index 6c0731c..4337ae3 100644 --- a/pages/dropship-tasks/dropship-tasks.vue +++ b/pages/dropship-tasks/dropship-tasks.vue @@ -33,7 +33,7 @@