From fd99e616b46b3eaff7caaf079b62170ad8ce8768 Mon Sep 17 00:00:00 2001 From: van Date: Thu, 30 Apr 2026 19:37:23 +0800 Subject: [PATCH] 1 --- .../jd-instruction/fadan-quick-record.vue | 109 ++++++++++++++++-- 1 file changed, 102 insertions(+), 7 deletions(-) diff --git a/src/views/system/jd-instruction/fadan-quick-record.vue b/src/views/system/jd-instruction/fadan-quick-record.vue index 3901817..6dbcf7e 100644 --- a/src/views/system/jd-instruction/fadan-quick-record.vue +++ b/src/views/system/jd-instruction/fadan-quick-record.vue @@ -69,13 +69,30 @@
录单 重置表单 - 复制录单 + + {{ resultPieces.length > 1 ? '复制全部(连在一起)' : '复制结果' }} +
@@ -144,9 +161,61 @@ export default { computed: { dialogWidth() { return this.isMobile ? '92%' : '480px' + }, + resultPieces() { + return this.splitResultTextIntoMessages(this.resultText) } }, methods: { + /** + * 按「落库回执 / 发货摘要」拆成多条,便于逐条复制发送 + */ + splitResultTextIntoMessages(full) { + const raw = String(full || '').replace(/\r\n/g, '\n').trim() + if (!raw) return [] + const sepReceipt = /\n-{3,}\s*落库回执\s*-{3,}\s*\n/ + const m = sepReceipt.exec(raw) + if (!m) { + return [{ title: '录单结果', text: raw }] + } + const formBody = raw.slice(0, m.index).trim() + const receiptRest = raw.slice(m.index + m[0].length).trim() + const shipNeedle = '\n「发货摘要」' + const idxShip = receiptRest.indexOf(shipNeedle) + const out = [] + out.push({ title: '第 1 条 · 录单表单', text: formBody }) + if (idxShip >= 0) { + const beforeShip = receiptRest.slice(0, idxShip).trim() + const fromShip = receiptRest.slice(idxShip + 1).trim() + out.push({ + title: '第 2 条 · 落库回执', + text: `--- 落库回执 ---\n${beforeShip}`.trim() + }) + out.push({ title: '第 3 条 · 发货摘要', text: fromShip }) + } else { + out.push({ + title: '第 2 条 · 落库回执', + text: `--- 落库回执 ---\n${receiptRest}`.trim() + }) + } + return out + }, + resultPieceMinRows(text) { + const n = String(text || '').split('\n').length + const cap = this.isMobile ? 8 : 6 + return Math.min(Math.max(n + 1, cap), this.isMobile ? 18 : 14) + }, + copyPieceText(text) { + const t = (text || '').trim() + if (!t) return + if (navigator.clipboard) { + navigator.clipboard.writeText(t).then(() => { + this.$modal.msgSuccess('已复制本条') + }).catch(() => this.fallbackCopy(t, '已复制本条')) + } else { + this.fallbackCopy(t, '已复制本条') + } + }, buildDistributionMark() { let s = (this.form.markSuffix || '').trim() if (s.startsWith('-')) { @@ -453,13 +522,13 @@ export default { if (!t) return if (navigator.clipboard) { navigator.clipboard.writeText(t).then(() => { - this.$modal.msgSuccess('已复制') - }).catch(() => this.fallbackCopy(t)) + this.$modal.msgSuccess('已复制全部') + }).catch(() => this.fallbackCopy(t, '已复制全部')) } else { - this.fallbackCopy(t) + this.fallbackCopy(t, '已复制全部') } }, - fallbackCopy(text) { + fallbackCopy(text, successMsg) { const ta = document.createElement('textarea') ta.value = text document.body.appendChild(ta) @@ -467,7 +536,7 @@ export default { ta.select() try { document.execCommand('copy') - this.$modal.msgSuccess('已复制') + this.$modal.msgSuccess(successMsg || '已复制') } catch (e) { this.$modal.msgError('复制失败') } @@ -536,6 +605,32 @@ export default { font-size: 13px; } +.result-pieces-hint { + margin: 0 0 10px; + font-size: 13px; + color: #909399; +} + +.result-pieces { + display: flex; + flex-direction: column; + gap: 16px; +} + +.result-piece-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 10px; + margin-bottom: 6px; +} + +.result-piece-title { + font-weight: 600; + color: #303133; + font-size: 14px; +} + .verify-body .verify-code { text-align: center; font-size: 26px;