1
This commit is contained in:
@@ -19,18 +19,18 @@
|
|||||||
<el-input-number v-model="form.qty" :min="1" :max="99" controls-position="right" style="width: 100%;" />
|
<el-input-number v-model="form.qty" :min="1" :max="99" controls-position="right" style="width: 100%;" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-divider content-position="left">选填:已下单时一并写入录单表</el-divider>
|
<el-divider content-position="left">落库必填(与中控录单一致)</el-divider>
|
||||||
<el-form-item label="下单人">
|
<el-form-item label="下单人">
|
||||||
<el-input v-model="form.buyer" placeholder="选填" clearable />
|
<el-input v-model="form.buyer" placeholder="落库必填" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="下单付款(元)">
|
<el-form-item label="下单付款(元)">
|
||||||
<el-input v-model="form.paymentText" placeholder="选填,如 2999.00" clearable />
|
<el-input v-model="form.paymentText" placeholder="落库必填,如 2999.00" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="后返金额(元)">
|
<el-form-item label="后返金额(元)">
|
||||||
<el-input v-model="form.rebateText" placeholder="选填" clearable />
|
<el-input v-model="form.rebateText" placeholder="不写则按 0.00 落库" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="物流链接">
|
<el-form-item label="物流链接">
|
||||||
<el-input v-model="form.logisticsLink" type="textarea" :rows="2" placeholder="选填" clearable />
|
<el-input v-model="form.logisticsLink" type="textarea" :rows="2" placeholder="落库必填" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<div class="btn-row">
|
<div class="btn-row">
|
||||||
@@ -129,15 +129,50 @@ export default {
|
|||||||
}
|
}
|
||||||
if (rebate) {
|
if (rebate) {
|
||||||
t = t.replace(/(后返金额(注意核对):)\n\n/, `$1\n${rebate}\n\n`)
|
t = t.replace(/(后返金额(注意核对):)\n\n/, `$1\n${rebate}\n\n`)
|
||||||
|
} else {
|
||||||
|
t = t.replace(/(后返金额(注意核对):)\n\n/, `$1\n0.00\n\n`)
|
||||||
}
|
}
|
||||||
if (logistics) {
|
if (logistics) {
|
||||||
t = t.replace(/(物流链接(需填):)\n\n/, `$1\n${logistics}\n\n`)
|
t = t.replace(/(物流链接(需填):)\n\n/, `$1\n${logistics}\n\n`)
|
||||||
}
|
}
|
||||||
return t
|
return t
|
||||||
},
|
},
|
||||||
|
/** 中控「单」录单:表单正文已含「单:」开头,直接作为 command 即可落库 */
|
||||||
|
formBodyLooksPersistable(text) {
|
||||||
|
const t = (text || '').trim()
|
||||||
|
return t.startsWith('单')
|
||||||
|
},
|
||||||
|
canPersistOrderFields() {
|
||||||
|
const buyer = (this.form.buyer || '').trim()
|
||||||
|
const pay = (this.form.paymentText || '').trim()
|
||||||
|
const logistics = (this.form.logisticsLink || '').trim()
|
||||||
|
return !!(buyer && pay && logistics)
|
||||||
|
},
|
||||||
|
formatInstructionData(data) {
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
return data.length ? data.join('\n\n') : ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
},
|
||||||
|
isPersistFailureText(text) {
|
||||||
|
const s = String(text || '')
|
||||||
|
return s.includes('[炸弹]') || s.includes('录单警告')
|
||||||
|
},
|
||||||
|
applyPersistResult(mergedBody, persistMsg) {
|
||||||
|
const msg = persistMsg || ''
|
||||||
|
this.resultText = (mergedBody || '') + '\n\n--- 落库回执 ---\n' + msg
|
||||||
|
if (this.isPersistFailureText(msg)) {
|
||||||
|
this.$modal.msgError('落库未成功,请查看回执')
|
||||||
|
} else {
|
||||||
|
this.$modal.msgSuccess('已生成表单并落库')
|
||||||
|
}
|
||||||
|
},
|
||||||
extractFirstResponse(data) {
|
extractFirstResponse(data) {
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
return data.length ? data.join('\n\n\n') : ''
|
return data.length ? String(data[0]) : ''
|
||||||
}
|
}
|
||||||
if (typeof data === 'string') {
|
if (typeof data === 'string') {
|
||||||
return data
|
return data
|
||||||
@@ -178,32 +213,48 @@ export default {
|
|||||||
}
|
}
|
||||||
this.verifyDialogVisible = true
|
this.verifyDialogVisible = true
|
||||||
},
|
},
|
||||||
generate() {
|
async generate() {
|
||||||
const cmd = this.buildCommand()
|
const cmd = this.buildCommand()
|
||||||
if (!cmd) return
|
if (!cmd) return
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.resultText = ''
|
this.resultText = ''
|
||||||
executeInstruction({ command: cmd }).then(res => {
|
try {
|
||||||
this.loading = false
|
const res = await executeInstruction({ command: cmd })
|
||||||
if (res && (res.code === 200 || res.msg === '操作成功')) {
|
if (!(res && (res.code === 200 || res.msg === '操作成功'))) {
|
||||||
|
this.$modal.msgError((res && res.msg) || '生成表单失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
const list = Array.isArray(res.data) ? res.data : (res.data ? [String(res.data)] : [])
|
const list = Array.isArray(res.data) ? res.data : (res.data ? [String(res.data)] : [])
|
||||||
if (this.checkDuplicateError(list)) {
|
if (this.checkDuplicateError(list)) {
|
||||||
this.resultListFromLast = list
|
this.resultListFromLast = list
|
||||||
this.showVerifyDialog(cmd)
|
this.showVerifyDialog(cmd)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const merged = this.injectOptional(this.extractFirstResponse(res.data))
|
const rawForm = this.extractFirstResponse(res.data)
|
||||||
|
const merged = this.injectOptional(rawForm)
|
||||||
|
if (!this.formBodyLooksPersistable(merged)) {
|
||||||
this.resultText = merged
|
this.resultText = merged
|
||||||
this.$modal.msgSuccess('已录单')
|
this.$modal.msgError('生成结果不是可落库表单,请重试或联系管理员')
|
||||||
} else {
|
return
|
||||||
this.$modal.msgError((res && res.msg) || '录单失败')
|
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
if (!this.canPersistOrderFields()) {
|
||||||
this.loading = false
|
this.resultText = merged
|
||||||
|
this.$modal.msgWarning('已生成录单文案。落库需填写:下单人、下单付款、物流链接(后返可不填,将按 0.00)')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const res2 = await executeInstruction({ command: merged })
|
||||||
|
if (!(res2 && (res2.code === 200 || res2.msg === '操作成功'))) {
|
||||||
|
this.$modal.msgError((res2 && res2.msg) || '落库失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.applyPersistResult(merged, this.formatInstructionData(res2.data))
|
||||||
|
} catch (e) {
|
||||||
this.$modal.msgError('请求失败')
|
this.$modal.msgError('请求失败')
|
||||||
})
|
} finally {
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleVerify() {
|
async handleVerify() {
|
||||||
if (!this.verifyInput || this.verifyInput.length !== 4) {
|
if (!this.verifyInput || this.verifyInput.length !== 4) {
|
||||||
this.$modal.msgError('请输入四位验证码')
|
this.$modal.msgError('请输入四位验证码')
|
||||||
return
|
return
|
||||||
@@ -214,20 +265,37 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.verifyLoading = true
|
this.verifyLoading = true
|
||||||
executeInstructionWithForce({ command: this.pendingCommand }).then(res => {
|
try {
|
||||||
this.verifyLoading = false
|
const res = await executeInstructionWithForce({ command: this.pendingCommand })
|
||||||
this.verifyDialogVisible = false
|
if (!(res && (res.code === 200 || res.msg === '操作成功'))) {
|
||||||
if (res && (res.code === 200 || res.msg === '操作成功')) {
|
|
||||||
const merged = this.injectOptional(this.extractFirstResponse(res.data))
|
|
||||||
this.resultText = merged
|
|
||||||
this.$modal.msgSuccess('已强制录单')
|
|
||||||
} else {
|
|
||||||
this.$modal.msgError((res && res.msg) || '执行失败')
|
this.$modal.msgError((res && res.msg) || '执行失败')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
const merged = this.injectOptional(this.extractFirstResponse(res.data))
|
||||||
this.verifyLoading = false
|
if (!this.formBodyLooksPersistable(merged)) {
|
||||||
|
this.resultText = merged
|
||||||
|
this.verifyDialogVisible = false
|
||||||
|
this.$modal.msgError('生成结果不是可落库表单')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.canPersistOrderFields()) {
|
||||||
|
this.resultText = merged
|
||||||
|
this.verifyDialogVisible = false
|
||||||
|
this.$modal.msgWarning('已强制生成表单。落库仍需填写:下单人、下单付款、物流链接')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const res2 = await executeInstruction({ command: merged })
|
||||||
|
this.verifyDialogVisible = false
|
||||||
|
if (!(res2 && (res2.code === 200 || res2.msg === '操作成功'))) {
|
||||||
|
this.$modal.msgError((res2 && res2.msg) || '落库失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.applyPersistResult(merged, this.formatInstructionData(res2.data))
|
||||||
|
} catch (e) {
|
||||||
this.$modal.msgError('请求失败')
|
this.$modal.msgError('请求失败')
|
||||||
})
|
} finally {
|
||||||
|
this.verifyLoading = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.form = {
|
this.form = {
|
||||||
|
|||||||
Reference in New Issue
Block a user