From c4d43542f41c2312c24acbcab12eb48b6d325dc8 Mon Sep 17 00:00:00 2001 From: liuyihe <2513762445@qq.com> Date: Fri, 9 Oct 2026 20:39:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/fulfillment.js | 1 + src/pages/outbound/outbound.vue | 2 +- src/pages/return-receipt/return-receipt.vue | 6 +++--- tests/fulfillment-workflows.test.mjs | 8 ++++++++ tests/return-receipt-page.test.mjs | 17 +++++++++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/api/fulfillment.js b/src/api/fulfillment.js index eb2eeba..a8b4f03 100644 --- a/src/api/fulfillment.js +++ b/src/api/fulfillment.js @@ -138,6 +138,7 @@ export function outboundPickPayload(item, position, packages, scannedCode = '') outboundPalletItemId: item.outboundPalletItemId, inventoryPositionId: position.inventoryPositionId || null, packages: Number(packages), + ...(item.returnSkuQuantity != null ? { productQuantity: Number(item.returnSkuQuantity) } : {}), cartonMarks: skuScan ? [] : position.cartonMark ? [position.cartonMark] : [], ...(skuScan ? { skuCode: item.skuCode } : {}) } diff --git a/src/pages/outbound/outbound.vue b/src/pages/outbound/outbound.vue index 7b120ea..1deda49 100644 --- a/src/pages/outbound/outbound.vue +++ b/src/pages/outbound/outbound.vue @@ -38,7 +38,7 @@ 任务详情尚无可拣货明细请刷新;若持续为空,请联系平台确认出库货物是否已下发。 - 本次拣货:{{ lineBusinessCode(selectedPosition) }}拣货箱数最多 {{ selectedRemaining }} 箱 + 本次拣货:{{ lineBusinessCode(selectedPosition) }}本来源计划出库 {{ selectedItem.returnSkuQuantity }} 件,请清点这些件数后确认;余数保留原箱。拣货箱数最多 {{ selectedRemaining }} 箱 完成出库任务尚有 {{ remainingPackages }} 箱未拣,不能完成出库。出库任务已完成,不可重复提交。全部计划货物已扫描核平,服务端将再次校验库存门禁。 diff --git a/src/pages/return-receipt/return-receipt.vue b/src/pages/return-receipt/return-receipt.vue index 2ba4ebf..282835e 100644 --- a/src/pages/return-receipt/return-receipt.vue +++ b/src/pages/return-receipt/return-receipt.vue @@ -21,7 +21,7 @@ 本次实物单元 - 包裹码/快递单号 + 包裹码/快递单号(选填) @@ -47,6 +45,8 @@ export default { data() { return { rebindSelection: null, active: 'source', sourceCode: '', targetCode: '', source: null, target: null, marks: [], busy: false, error: '', message: '', newPallet: null, sourceRows: [], selectedSource: null, quantity: '', selectedDestination: '' } }, mounted() { this.loadSources() }, computed: { + requiredSplitPackages() { return (this.task.items || []).filter(item => ['CARTON_LABEL', 'CARTON_AND_SKU'].includes(item.operationType)).reduce((sum, item) => sum + Number(item.expectedPackages || 0), 0) }, + splitPackages() { const bound = new Set(this.currentBindings.map(binding => binding.mark)); return (this.task.items || []).filter(item => ['CARTON_LABEL', 'CARTON_AND_SKU'].includes(item.operationType) && bound.has(item.cartonMark)).reduce((sum, item) => sum + Number(item.expectedPackages || 0), 0) }, currentBindings() { const latest = new Map() for (const entry of this.task.history || []) { @@ -60,7 +60,6 @@ export default { } return [...latest.values()] }, - bindingHistory() { return (this.task.history || []).filter(entry => entry.action === 'PALLET_BIND').flatMap(entry => { try { const data = JSON.parse(entry.detail); return Array.isArray(data.cartonMarks) && Array.isArray(data.targetPallets) ? [data] : [] } catch { return [] } }) }, destinations() { return [...new Set((this.isReturnBulk ? this.sourceItems() : this.completedItems()).map(item => item.destinationFbaWarehouseCode).filter(Boolean))] }, eligibleItems() { return (this.isReturnBulk ? this.sourceItems() : this.completedItems()).filter(item => item.destinationFbaWarehouseCode === this.selectedDestination) }, isReturnBulk() { return this.task.operationType === 'RETURN_BULK_SKU_LABEL' }, @@ -99,7 +98,7 @@ export default { if (!binding || !targetCode || this.busy) return if (targetCode === binding.pallet.toUpperCase()) { this.showBindingMessage('无需改绑', '该箱唛已经绑定此托盘,不会重复扣库存。'); return } this.busy = true; this.$emit('busy', true) - const confirmed = await new Promise(resolve => uni.showModal({ title: '确认改绑', content: `将 ${binding.mark} 从 ${binding.pallet} 移至 ${targetCode}?旧托盘扣箱,新托盘加箱。`, confirmText: '确认改绑', cancelText: '取消', success: result => resolve(result.confirm), fail: () => resolve(false) })) + const confirmed = await new Promise(resolve => uni.showModal({ title: '确认改绑', content: `将 ${binding.mark} 从 ${binding.pallet} 移至 ${targetCode}?旧托盘扣箱,新托盘加箱。`, confirmText: '是', cancelText: '否', success: result => resolve(result.confirm), fail: () => resolve(false) })) this.busy = false; this.$emit('busy', false) if (!confirmed) return await this.run(async () => { @@ -111,17 +110,17 @@ export default { releaseWarehouseKey('relabel', key.signature) this.rebindSelection = null; this.targetCode = ''; this.target = null this.$emit('saved') - this.showBindingMessage('绑定成功', `${binding.mark} 已从 ${binding.pallet} 移至 ${target.palletCode}`) + this.showBindingMessage('绑定成功', `托盘 ${target.palletCode} 已绑定`) }) if (this.error) this.showBindingMessage('改绑失败', this.error) }, sourceItems() { return (this.task.items || []).filter(item => this.selectedSource?.cartonMarks.includes(item.cartonMark)) }, - completedItems() { return this.sourceItems().filter(item => this.isReturnBulk ? Number(item.expectedPackages) > 0 && Number(item.relabelledPackages) >= Number(item.expectedPackages) : Number(item.relabelledPackages) >= 1) }, + completedItems() { const bound = new Set(this.currentBindings.map(binding => binding.mark)); return this.sourceItems().filter(item => this.isReturnBulk ? Number(item.expectedPackages) > 0 && Number(item.relabelledPackages) >= Number(item.expectedPackages) : Number(item.relabelledPackages) >= 1 && !bound.has(item.cartonMark)) }, async loadSources() { await this.run(async () => { this.sourceRows = await findRelabelSources(this.task.relabelNo); this.selectedSource = null; this.source = null; this.marks = []; this.quantity = '' }) }, async selectSource(row) { if (this.busy) return this.rebindSelection = null; this.selectedSource = row; this.source = null; this.sourceCode = ''; this.quantity = ''; this.marks = [] - this.selectedDestination = this.sourceItems()[0]?.destinationFbaWarehouseCode || '' + this.selectedDestination = (this.isReturnBulk ? this.sourceItems() : this.completedItems())[0]?.destinationFbaWarehouseCode || '' if (this.isReturnBulk) { const items = this.eligibleItems this.marks = items.map(item => item.cartonMark) @@ -144,23 +143,45 @@ export default { fillBatch() { const count = Number(this.quantity); const packages = this.eligibleItems.reduce((sum, item) => sum + Number(item.expectedPackages || 0), 0); const invalid = !Number.isSafeInteger(count) || count <= 0 || count > this.selectedSource.movablePackages || (this.isReturnBulk ? count !== packages : count > this.eligibleItems.length); if (invalid) { this.error = this.isReturnBulk ? '拆出件数必须等于本批已完成贴标件数,且不能超过来源托盘可拆数量' : '拆出数量必须为正整数,且不超过来源托盘可拆箱数和已完成换标箱数'; return } this.marks = (this.isReturnBulk ? this.eligibleItems : this.eligibleItems.slice(0, count)).map(item => item.cartonMark); this.error = '' }, toggleMark(mark) { if (this.busy) return; this.marks = this.marks.includes(mark) ? this.marks.filter(value => value !== mark) : [...this.marks, mark] }, activate(value) { this.active = value; this.$emit('activate') }, - handleScan(value) { if (this.busy) return; this[this.active + 'Code'] = value; return this.active === 'target' ? this.confirmTargetAndBind() : this.resolve(this.active) }, + handleScan(value) { if (this.busy) return; this[this.active + 'Code'] = value; return this.active === 'target' ? this.confirmTargetAndBind() : this.confirmSourceScan() }, + async confirmBindingChoice(content) { + this.busy = true; this.$emit('busy', true) + try { return await new Promise(resolve => uni.showModal({ title: '是否绑定', content, confirmText: '是', cancelText: '否', success: result => resolve(!!result.confirm), fail: () => resolve(false) })) } + finally { this.busy = false; this.$emit('busy', false) } + }, + async confirmSourceScan() { + if (this.busy || !this.sourceCode.trim()) return + const matched = this.operableSourceRows.find(row => this.samePallet(row, { palletCode: this.sourceCode })) + this.source = null + if (!matched) { this.error = '该托盘不在本单可操作的来源托盘列表中'; this.showBindingMessage('来源托盘不匹配', this.error); return } + await this.resolve('source') + if (this.error || !this.source) return + const source = this.source; this.source = null + if (await this.confirmBindingChoice(`是否绑定来源托盘 ${source.palletCode}?`)) this.source = source + }, showBindingMessage(title, content) { uni.showModal({ title, content, showCancel: false, confirmText: '知道了' }) }, async confirmTargetAndBind() { if (this.busy) return if (this.rebindSelection) return this.submitRebind() + if (!this.isReturnBulk && this.selectedSource && this.samePallet(this.source, this.selectedSource)) { + this.selectedDestination = this.completedItems()[0]?.destinationFbaWarehouseCode || '' + this.marks = [] + this.fillBatch() + if (this.error) { this.showBindingMessage('尚未绑定', this.error); return } + } this.message = '' let reason = '' if (!this.selectedSource) reason = '请先选择实际拆出货物的来源托盘。' else if (!this.samePallet(this.source, this.selectedSource)) reason = this.isReturnBulk ? '来源托盘识别失败,请重新选择。' : '请先扫描并确认实际来源托盘;选择来源列表不等于扫描确认。' else if (this.isReturnBulk && this.completedItems().length !== this.eligibleItems.length) reason = '请先完成本托盘的 SKU 贴标登记,再绑定新托盘;整托无需填写拆箱数量。' else if (!Number.isSafeInteger(Number(this.quantity)) || Number(this.quantity) <= 0 || Number(this.quantity) > this.selectedSource.movablePackages) reason = this.isReturnBulk ? '本托盘可操作件数不足,请刷新来源托盘。' : '请填写有效的拆出箱数,不能超过来源托盘可拆数量。' - else if (!this.selectedDestination || !this.bindingSelectionValid()) reason = this.isReturnBulk ? `本托盘拆箱数量必须等于贴标预报分配数量 ${this.plannedPackages} 件。` : '请选择本批目的仓和对应箱唛,勾选箱数必须等于拆出箱数。' + else if (!this.selectedDestination || !this.bindingSelectionValid()) reason = this.isReturnBulk ? `本托盘拆箱数量必须等于贴标预报分配数量 ${this.plannedPackages} 件。` : '本次拆出箱数必须对应已完成换标且尚未拆出的同目的仓箱唛。' else if (!this.targetCode.trim()) reason = '请扫描或输入目标托盘号。' if (reason) { this.error = reason; this.showBindingMessage('尚未绑定', reason); return } await this.resolve('target') if (this.error) { this.showBindingMessage('绑定失败', this.error); return } if (!this.readyToBind) { this.error = '来源和目标托盘不能相同,请核对后重新确认。'; this.showBindingMessage('尚未绑定', this.error); return } + if (!await this.confirmBindingChoice(`是否绑定目标托盘 ${this.target.palletCode}(${this.quantity} ${this.isReturnBulk ? '件' : '箱'})?`)) { this.target = null; return } await this.bind() }, destination(mark) { return this.task.items.find(item => item.cartonMark === mark)?.destinationFbaWarehouseCode || '目的仓待维护' }, @@ -198,7 +219,7 @@ export default { const payload = { relabelNo: this.task.relabelNo, source: expectation(this.source), target: expectation(this.target), cartonMarks: [...this.marks], actualSource: { positionId: this.selectedSource.positionId, expectedPositionVersion: this.selectedSource.positionVersion, packages: Number(this.quantity) }, reason: 'PDA 按原入仓单箱数拆托并按新目的仓合托' } const key = warehouseIdempotencyKey('relabel', 'bind-pallet', payload) let saved = false - await this.run(async () => { await bindRelabelPallet({ ...payload, idempotencyKey: key.value }); saved = true; releaseWarehouseKey('relabel', key.signature); const createdKey = warehouseIdempotencyKey('relabel', 'new-pallet', { relabelNo: this.task.relabelNo }); releaseWarehouseKey('relabel', createdKey.signature); this.message = `${this.marks.length} 箱已从 ${this.source.palletCode} 合入 ${this.target.palletCode},仍归属 ${this.selectedSource.inboundCode}`; this.marks = []; this.source = null; this.target = null; this.newPallet = null; this.sourceCode = ''; this.targetCode = ''; this.$emit('saved'); this.activate('source') }) + await this.run(async () => { await bindRelabelPallet({ ...payload, idempotencyKey: key.value }); saved = true; releaseWarehouseKey('relabel', key.signature); const createdKey = warehouseIdempotencyKey('relabel', 'new-pallet', { relabelNo: this.task.relabelNo }); releaseWarehouseKey('relabel', createdKey.signature); this.message = `托盘 ${this.target.palletCode} 已绑定`; this.marks = []; this.source = null; this.target = null; this.newPallet = null; this.sourceCode = ''; this.targetCode = ''; this.$emit('saved'); this.activate('source') }) if (saved) { this.showBindingMessage('绑定成功', this.message); await this.loadSources() } else if (this.error) this.showBindingMessage('绑定失败', this.error) }, @@ -219,8 +240,16 @@ export default { .heading{display:block;font-size:18px;font-weight:700} .refresh-button{flex:none;margin:0;padding:6px 14px;font-size:13px;line-height:1.5} .hint{display:block;font-size:13px;color:#52647c;margin:10px 0;white-space:normal} -.source-row{padding:12px;margin:10px 0;border:1px solid #d7e1ef;border-radius:8px} +.source-row{display:flex;align-items:center;gap:8px;padding:8px;margin:8px 0;border:1px solid #d7e1ef;border-radius:8px;white-space:nowrap} +.source-identifiers{flex:1;min-width:0} +.source-identifier{display:flex;align-items:baseline;gap:5px;max-width:100%;min-width:0} +.source-caption{flex-shrink:0;color:#718095;font-size:10px} +.source-code{min-width:0;color:#243951;font-size:11px;line-height:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.source-quantity{flex-shrink:0;color:#52647c;font-size:9px;line-height:16px} +.split-quantity-row{display:flex;align-items:center;gap:8px;margin:10px 0;color:#52647c;font-size:12px}.split-quantity-row input{box-sizing:border-box;width:72px;height:34px;padding:6px 8px;text-align:center;font-size:13px} +.split-progress{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:10px 0;color:#52647c;font-size:12px;line-height:20px}.split-progress strong{color:#1f5fca;font-weight:700}.split-progress .create-pallet-button{margin:0 0 0 auto;padding:0 10px;border-radius:6px;background:#22c55e;color:#fff;font-size:10px;font-weight:700;line-height:28px}.split-progress .create-pallet-button[disabled]{background:#bbf7d0;color:#6b987b}.split-progress .create-pallet-button::after{border:none} .source-row.selected{border-color:#2674d9;background:#eff6ff} +.binding-row{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;min-width:0;padding:8px 9px;font-size:11px;line-height:20px;text-align:left;white-space:nowrap}.binding-mark{max-width:25%;overflow:hidden;text-overflow:ellipsis}.binding-arrow,.binding-action{flex-shrink:0}.binding-pallet{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}.binding-action{color:#1f5fca;font-size:10px} .line{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:8px 0}.line text{flex:1;overflow-wrap:anywhere} input{padding:12px;background:#f3f6fa;border-radius:6px}button{font-size:13px;margin:8px 0} .error{display:block;color:#bc3030;font-size:13px} diff --git a/src/pages/relabel/relabel.vue b/src/pages/relabel/relabel.vue index 8c6f3bd..63837c6 100644 --- a/src/pages/relabel/relabel.vue +++ b/src/pages/relabel/relabel.vue @@ -2,27 +2,27 @@ - {{ title }}{{ stageSubtitle }} - 当前任务{{ stage === 'review' ? '换标复核详情' : '换标执行详情' }} + {{ title }}{{ stageSubtitle }} + 换标类型:{{ relabelTypeName(current.operationType) }} {{ current.relabelNo }}客户订单:{{ current.customerOrderNo || '—' }}标签截止:{{ formatTime(current.labelDeadline) }}{{ statusLabel(current.taskStatus || current.applicationStatus) }} - {{ current.expectedPackages }}应处理{{ current.relabelledPackages }}已换标{{ current.skippedPackages }}跳过{{ current.exceptionPackages }}异常 + FBA 目的仓:{{ destination }}待维护应处理 {{ current.expectedPackages }}已换标 {{ current.relabelledPackages }}跳过 {{ current.skippedPackages }}异常 {{ current.exceptionPackages }} 标签文件暂无标签文件{{ file.scope === 'CARTON_TOTAL' ? '总箱唛' : file.scope === 'SKU_TOTAL' ? '总 SKU 标签' : '明细标签' }}:{{ file.fileName }}