This commit is contained in:
van
2026-10-08 16:34:02 +08:00
parent d2305882d2
commit e294f4f343
@@ -100,11 +100,15 @@
<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 @input="onPaymentInput" />
</el-form-item> </el-form-item>
<el-form-item label="后返金额(元)"> <el-form-item label="后返金额(元)">
<el-input v-model="form.rebateText" placeholder="不写则按 0.00 落库" clearable /> <el-input v-model="form.rebateText" placeholder="与成本价至少填一项,填 0 也可以" clearable @input="onRebateInput" />
</el-form-item> </el-form-item>
<el-form-item label="成本价(元)">
<el-input v-model="form.costText" placeholder="与后返至少填一项;成本价 = 下单付款 − 后返金额" clearable @input="onCostInput" />
</el-form-item>
<p class="model-shop-hint">后改的那一项为准,另一项按付款金额重算。两个都空不能录单。</p>
<el-form-item label="订单号(京东)"> <el-form-item label="订单号(京东)">
<el-input v-model="form.orderIdText" placeholder="落库必填;无京东单号可填 1(仅填物流单号时允许重复)" clearable /> <el-input v-model="form.orderIdText" placeholder="落库必填;无京东单号可填 1(仅填物流单号时允许重复)" clearable />
</el-form-item> </el-form-item>
@@ -262,10 +266,13 @@ export default {
buyer: '', buyer: '',
paymentText: '', paymentText: '',
rebateText: '', rebateText: '',
costText: '',
orderIdText: '', orderIdText: '',
logisticsLink: '', logisticsLink: '',
waybillNo: '' waybillNo: ''
}, },
/** rebate:以后返为准算成本;cost:以成本为准算后返 */
moneySource: 'rebate',
loading: false, loading: false,
resultText: '', resultText: '',
resultListFromLast: [], resultListFromLast: [],
@@ -381,6 +388,68 @@ export default {
if (!Number.isFinite(n)) return '' if (!Number.isFinite(n)) return ''
return n.toFixed(2) return n.toFixed(2)
}, },
/** 空返回 null,非法返回 NaN */
parseMoneyField(text) {
const s = String(text || '').trim().replace(/,/g, '').replace(/,/g, '')
if (!s) return null
const n = Number(s)
return Number.isFinite(n) ? n : NaN
},
onPaymentInput() {
if (this.moneySource === 'cost') this.recalcRebate()
else this.recalcCost()
},
onRebateInput() {
this.moneySource = 'rebate'
this.recalcCost()
},
onCostInput() {
this.moneySource = 'cost'
this.recalcRebate()
},
recalcCost() {
const pay = this.parseMoneyField(this.form.paymentText)
const rebate = this.parseMoneyField(this.form.rebateText)
if (pay == null || rebate == null || Number.isNaN(pay) || Number.isNaN(rebate)) return
this.form.costText = (pay - rebate).toFixed(2)
},
recalcRebate() {
const pay = this.parseMoneyField(this.form.paymentText)
const cost = this.parseMoneyField(this.form.costText)
if (pay == null || cost == null || Number.isNaN(pay) || Number.isNaN(cost)) return
this.form.rebateText = (pay - cost).toFixed(2)
},
ensureMoneyPair() {
const pay = this.parseMoneyField(this.form.paymentText)
const rebate = this.parseMoneyField(this.form.rebateText)
const cost = this.parseMoneyField(this.form.costText)
if (Number.isNaN(pay) || Number.isNaN(rebate) || Number.isNaN(cost)) {
this.$modal.msgError('金额格式不正确')
return false
}
if (rebate == null && cost == null) {
this.$modal.msgError('请填写成本价或后返金额,至少填一项(填 0 也可以)')
return false
}
if (pay == null) {
this.$modal.msgError('请填写下单付款,才能算出成本价或后返金额')
return false
}
if (this.moneySource === 'cost' && cost != null) {
this.form.costText = cost.toFixed(2)
this.form.rebateText = (pay - cost).toFixed(2)
} else if (rebate != null) {
this.moneySource = 'rebate'
this.form.rebateText = rebate.toFixed(2)
this.form.costText = (pay - rebate).toFixed(2)
} else {
this.moneySource = 'cost'
this.form.costText = cost.toFixed(2)
this.form.rebateText = (pay - cost).toFixed(2)
}
this.form.paymentText = pay.toFixed(2)
return true
},
modelOptionLabel(row) { modelOptionLabel(row) {
if (!row || !row.modelNumber) return '' if (!row || !row.modelNumber) return ''
const p = this.formatMoneyText(row.lastPaymentAmount) const p = this.formatMoneyText(row.lastPaymentAmount)
@@ -499,6 +568,9 @@ export default {
const rebateRaw = hit.lastRebateAmount const rebateRaw = hit.lastRebateAmount
this.form.paymentText = payRaw != null && payRaw !== '' ? this.formatMoneyText(payRaw) : '' this.form.paymentText = payRaw != null && payRaw !== '' ? this.formatMoneyText(payRaw) : ''
this.form.rebateText = rebateRaw != null && rebateRaw !== '' ? this.formatMoneyText(rebateRaw) : '' this.form.rebateText = rebateRaw != null && rebateRaw !== '' ? this.formatMoneyText(rebateRaw) : ''
this.form.costText = ''
this.moneySource = 'rebate'
this.recalcCost()
}, },
buildCommand() { buildCommand() {
const mark = this.buildDistributionMark() const mark = this.buildDistributionMark()
@@ -552,8 +624,10 @@ 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`) const cost = (this.form.costText || '').trim()
if (cost) {
t = t.replace(/(成本价(注意核对):)\n\n/, `$1\n${cost}\n\n`)
} }
if (orderId) { if (orderId) {
t = t.replace(/(订单号(需填):)\n\n/, `$1\n${orderId}\n\n`) t = t.replace(/(订单号(需填):)\n\n/, `$1\n${orderId}\n\n`)
@@ -646,6 +720,7 @@ export default {
async generate() { async generate() {
const cmd = this.buildCommand() const cmd = this.buildCommand()
if (!cmd) return if (!cmd) return
if (!this.ensureMoneyPair()) return
this.loading = true this.loading = true
this.resultText = '' this.resultText = ''
try { try {
@@ -669,7 +744,7 @@ export default {
} }
if (!this.canPersistOrderFields()) { if (!this.canPersistOrderFields()) {
this.resultText = merged this.resultText = merged
this.$modal.msgWarning('已生成录单文案。落库需填写:下单人、下单付款、订单号,以及物流链接或物流单号(后返可不填,将按 0.00)') this.$modal.msgWarning('已生成录单文案。落库需填写:下单人、下单付款、订单号,以及物流链接或物流单号')
return return
} }
const res2 = await executeInstruction({ command: merged }) const res2 = await executeInstruction({ command: merged })
@@ -701,6 +776,10 @@ export default {
this.$modal.msgError((res && res.msg) || '执行失败') this.$modal.msgError((res && res.msg) || '执行失败')
return return
} }
if (!this.ensureMoneyPair()) {
this.verifyDialogVisible = false
return
}
const merged = this.injectOptional(this.extractFirstResponse(res.data)) const merged = this.injectOptional(this.extractFirstResponse(res.data))
if (!this.formBodyLooksPersistable(merged)) { if (!this.formBodyLooksPersistable(merged)) {
this.resultText = merged this.resultText = merged
@@ -739,10 +818,12 @@ export default {
buyer: '', buyer: '',
paymentText: '', paymentText: '',
rebateText: '', rebateText: '',
costText: '',
orderIdText: '', orderIdText: '',
logisticsLink: '', logisticsLink: '',
waybillNo: '' waybillNo: ''
} }
this.moneySource = 'rebate'
this.resultText = '' this.resultText = ''
}, },
openHistory() { openHistory() {
@@ -804,7 +885,7 @@ export default {
model: field('型号:', ['下单人(需填):', '下单付款(注意核对):']), model: field('型号:', ['下单人(需填):', '下单付款(注意核对):']),
buyer: field('下单人(需填):', ['下单付款(注意核对):']), buyer: field('下单人(需填):', ['下单付款(注意核对):']),
payment: field('下单付款(注意核对):', ['后返金额(注意核对):']), payment: field('下单付款(注意核对):', ['后返金额(注意核对):']),
rebate: field('后返金额(注意核对):', ['订单号(需填):']), rebate: field('后返金额(注意核对):', ['成本价(注意核对):', '订单号(需填):']),
orderId: field('订单号(需填):', ['物流链接(需填):']), orderId: field('订单号(需填):', ['物流链接(需填):']),
logistics: field('物流链接(需填):', ['物流单号(无链接时填):', '备注(下单号码有变动', '—————————', '京粉实际价格']), logistics: field('物流链接(需填):', ['物流单号(无链接时填):', '备注(下单号码有变动', '—————————', '京粉实际价格']),
waybill: field('物流单号(无链接时填):', ['备注(下单号码有变动', '—————————', '京粉实际价格']) waybill: field('物流单号(无链接时填):', ['备注(下单号码有变动', '—————————', '京粉实际价格'])
@@ -1056,6 +1137,9 @@ export default {
this.form.buyer = String(row.buyer || '').trim() this.form.buyer = String(row.buyer || '').trim()
this.form.paymentText = this.formatHistoryMoney(row.paymentAmount) this.form.paymentText = this.formatHistoryMoney(row.paymentAmount)
this.form.rebateText = this.formatHistoryMoney(row.rebateAmount) this.form.rebateText = this.formatHistoryMoney(row.rebateAmount)
this.form.costText = ''
this.moneySource = 'rebate'
this.recalcCost()
this.form.orderIdText = String(row.orderId || '').trim() this.form.orderIdText = String(row.orderId || '').trim()
this.form.logisticsLink = String(row.logisticsLink || '').trim() this.form.logisticsLink = String(row.logisticsLink || '').trim()
this.form.waybillNo = String(row.waybillNo || '').trim() this.form.waybillNo = String(row.waybillNo || '').trim()