1
This commit is contained in:
@@ -69,13 +69,30 @@
|
|||||||
<div class="btn-row">
|
<div class="btn-row">
|
||||||
<el-button type="primary" size="medium" :loading="loading" @click="generate">录单</el-button>
|
<el-button type="primary" size="medium" :loading="loading" @click="generate">录单</el-button>
|
||||||
<el-button size="medium" @click="resetForm">重置表单</el-button>
|
<el-button size="medium" @click="resetForm">重置表单</el-button>
|
||||||
<el-button v-if="resultText" size="medium" @click="copyResult">复制录单</el-button>
|
<el-button v-if="resultText" size="medium" @click="copyResult">
|
||||||
|
{{ resultPieces.length > 1 ? '复制全部(连在一起)' : '复制结果' }}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<template v-if="resultText">
|
<template v-if="resultText">
|
||||||
<el-divider content-position="left">录单结果</el-divider>
|
<el-divider content-position="left">录单结果</el-divider>
|
||||||
<el-input v-model="resultText" type="textarea" :rows="isMobile ? 16 : 20" readonly class="result-area" />
|
<p v-if="resultPieces.length > 1" class="result-pieces-hint">按条复制,每条对应一条聊天消息。</p>
|
||||||
|
<div class="result-pieces">
|
||||||
|
<div v-for="(p, i) in resultPieces" :key="i" class="result-piece">
|
||||||
|
<div class="result-piece-head">
|
||||||
|
<span class="result-piece-title">{{ p.title }}</span>
|
||||||
|
<el-button type="primary" plain size="mini" @click="copyPieceText(p.text)">复制本条</el-button>
|
||||||
|
</div>
|
||||||
|
<el-input
|
||||||
|
:value="p.text"
|
||||||
|
type="textarea"
|
||||||
|
:autosize="{ minRows: resultPieceMinRows(p.text), maxRows: isMobile ? 22 : 28 }"
|
||||||
|
readonly
|
||||||
|
class="result-area"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
@@ -144,9 +161,61 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
dialogWidth() {
|
dialogWidth() {
|
||||||
return this.isMobile ? '92%' : '480px'
|
return this.isMobile ? '92%' : '480px'
|
||||||
|
},
|
||||||
|
resultPieces() {
|
||||||
|
return this.splitResultTextIntoMessages(this.resultText)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
buildDistributionMark() {
|
||||||
let s = (this.form.markSuffix || '').trim()
|
let s = (this.form.markSuffix || '').trim()
|
||||||
if (s.startsWith('-')) {
|
if (s.startsWith('-')) {
|
||||||
@@ -453,13 +522,13 @@ export default {
|
|||||||
if (!t) return
|
if (!t) return
|
||||||
if (navigator.clipboard) {
|
if (navigator.clipboard) {
|
||||||
navigator.clipboard.writeText(t).then(() => {
|
navigator.clipboard.writeText(t).then(() => {
|
||||||
this.$modal.msgSuccess('已复制')
|
this.$modal.msgSuccess('已复制全部')
|
||||||
}).catch(() => this.fallbackCopy(t))
|
}).catch(() => this.fallbackCopy(t, '已复制全部'))
|
||||||
} else {
|
} else {
|
||||||
this.fallbackCopy(t)
|
this.fallbackCopy(t, '已复制全部')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fallbackCopy(text) {
|
fallbackCopy(text, successMsg) {
|
||||||
const ta = document.createElement('textarea')
|
const ta = document.createElement('textarea')
|
||||||
ta.value = text
|
ta.value = text
|
||||||
document.body.appendChild(ta)
|
document.body.appendChild(ta)
|
||||||
@@ -467,7 +536,7 @@ export default {
|
|||||||
ta.select()
|
ta.select()
|
||||||
try {
|
try {
|
||||||
document.execCommand('copy')
|
document.execCommand('copy')
|
||||||
this.$modal.msgSuccess('已复制')
|
this.$modal.msgSuccess(successMsg || '已复制')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$modal.msgError('复制失败')
|
this.$modal.msgError('复制失败')
|
||||||
}
|
}
|
||||||
@@ -536,6 +605,32 @@ export default {
|
|||||||
font-size: 13px;
|
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 {
|
.verify-body .verify-code {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 26px;
|
font-size: 26px;
|
||||||
|
|||||||
Reference in New Issue
Block a user