From be8420e1739780f8af29070c66b147a6eb91fe2e Mon Sep 17 00:00:00 2001 From: liuyihe <2513762445@qq.com> Date: Sun, 20 Sep 2026 21:50:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=B9=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RelabelPalletWork.vue | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/components/RelabelPalletWork.vue b/src/components/RelabelPalletWork.vue index 8000408..b058689 100644 --- a/src/components/RelabelPalletWork.vue +++ b/src/components/RelabelPalletWork.vue @@ -71,7 +71,13 @@ export default { methods: { samePallet(left, right) { if (!left || !right) return false - const code = value => String(value?.palletCode || '').trim().toUpperCase() + // 扫码枪可能在托盘号前后附带 CR/LF、零宽字符或全角空格; + // 这些字符不属于托盘号,不能让同一托盘被误判为不同托盘。 + const code = value => String(value?.palletCode || '') + .replace(/[\u0000-\u001f\u007f\u200b-\u200d\u2060\ufeff]/g, '') + .replace(/[\u3000]/g, ' ') + .trim() + .toUpperCase() const leftCode = code(left); const rightCode = code(right) const sameCode = !!leftCode && leftCode === rightCode if (sameCode) return true @@ -158,7 +164,32 @@ export default { }, destination(mark) { return this.task.items.find(item => item.cartonMark === mark)?.destinationFbaWarehouseCode || '目的仓待维护' }, async run(work) { if (this.busy) return; this.busy = true; this.$emit('busy', true); this.error = ''; try { await work() } catch (error) { this.error = error?.message || '托盘作业失败,请重新核对'; if (['409', 'A0409'].includes(String(error?.code))) { this.source = null; this.target = null; this.selectedSource = null; this.marks = []; this.error += ';请刷新来源托盘并重新扫码'; } } finally { this.busy = false; this.$emit('busy', false) } }, - async resolve(kind) { const code = this[kind + 'Code'].trim(); if (!code) return; this[kind] = null; await this.run(async () => { const value = await resolvePallet(code); if (kind === 'source' && !this.samePallet(value, this.selectedSource)) throw new Error('请扫描所选原入仓单的实际来源托盘'); if (this[kind + 'Code'].trim() === code) this[kind] = value }) }, + async resolve(kind) { + const raw = String(this[kind + 'Code'] || '') + const code = raw.replace(/[\u0000-\u001f\u007f\u200b-\u200d\u2060\ufeff]/g, '').replace(/[\u3000]/g, ' ').trim() + if (!code) return + this[kind + 'Code'] = code + this[kind] = null + // 来源托盘以扫码结果为准:当页面当前选中的是另一张来源卡片时, + // 自动切换到扫码命中的来源,避免“已扫正确托盘但仍提示不匹配”。 + if (kind === 'source') { + const normalized = value => String(value || '') + .replace(/[\u0000-\u001f\u007f\u200b-\u200d\u2060\ufeff]/g, '') + .replace(/[\u3000]/g, ' ').trim().toUpperCase() + const matched = this.sourceRows.find(row => normalized(row.palletCode) === normalized(code)) + if (matched && this.selectedSource?.positionId !== matched.positionId) { + this.selectedSource = matched + this.selectedDestination = this.sourceItems()[0]?.destinationFbaWarehouseCode || '' + this.quantity = '' + this.marks = [] + } + } + await this.run(async () => { + const value = await resolvePallet(code) + if (kind === 'source' && !this.samePallet(value, this.selectedSource)) throw new Error('请扫描所选原入仓单的实际来源托盘') + if (this[kind + 'Code'] === code) this[kind] = value + }) + }, async createPallet() { const payload = { relabelNo: this.task.relabelNo }; const key = warehouseIdempotencyKey('relabel', 'new-pallet', payload); await this.run(async () => { this.newPallet = await createRelabelPallet({ ...payload, idempotencyKey: key.value }); this.target = null; this.targetCode = this.newPallet.palletCode || ''; this.activate('target') }) }, async bind() { if (!this.readyToBind) { this.error = '请核对来源托盘、拆出箱数、本批箱唛和目标托盘'; return } -- 2.54.0