账单bug修复,以及加入转单号功能
This commit is contained in:
+42
-16
@@ -924,7 +924,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- ====== 余额核销账单弹窗 ====== -->
|
||||
<el-dialog title="余额核销账单" v-model="woDialog.visible" width="560px" append-to-body>
|
||||
<el-dialog title="余额核销账单" v-model="woDialog.visible" width="560px" append-to-body v-loading="woDialog.accountLoading">
|
||||
<el-descriptions :column="1" border size="small" v-if="woDialog.bill">
|
||||
<el-descriptions-item label="账单号">{{ woDialog.bill.billNo }}</el-descriptions-item>
|
||||
<el-descriptions-item label="账单名称">{{ woDialog.bill.billName || '-' }}</el-descriptions-item>
|
||||
@@ -937,13 +937,12 @@
|
||||
</el-descriptions>
|
||||
<el-form :model="woDialog.form" label-width="110px" class="wo-form">
|
||||
<el-form-item label="本次核销金额" required>
|
||||
<el-input-number
|
||||
<el-input
|
||||
v-model="woDialog.form.writeoffAmount"
|
||||
:precision="2"
|
||||
:step="100"
|
||||
:min="0.01"
|
||||
controls-position="right"
|
||||
inputmode="decimal"
|
||||
clearable
|
||||
style="width: 220px;"
|
||||
placeholder="请输入核销金额"
|
||||
/>
|
||||
<span class="wo-form-unit">CNY</span>
|
||||
</el-form-item>
|
||||
@@ -1851,7 +1850,8 @@ function loadBillWriteoffData() {
|
||||
|
||||
/* ---- 核销弹窗 ---- */
|
||||
const woSubmitLoading = ref(false)
|
||||
const woDialog = reactive({ visible: false, bill: null, form: {} })
|
||||
const woDialog = reactive({ visible: false, bill: null, form: {}, accountLoading: false })
|
||||
let writeoffAccountRequestSerial = 0
|
||||
/** 核销后余额预览(不为负则可提交) */
|
||||
const woAfterBalance = computed(() => {
|
||||
const balance = Number(currentAccount.value.balance) || 0
|
||||
@@ -1859,27 +1859,53 @@ const woAfterBalance = computed(() => {
|
||||
return formatMoney(balance - amount)
|
||||
})
|
||||
|
||||
function openWriteoffDialog(row) {
|
||||
// 先刷新账户余额,避免用过期余额核销
|
||||
listAccount(route.query.customerId).then(res => {
|
||||
accountList.value = res.data || []
|
||||
})
|
||||
async function openWriteoffDialog(row) {
|
||||
const customerId = Number(route.query.customerId)
|
||||
if (!customerId) {
|
||||
proxy.$modal.msgError('缺少客户ID,无法发起核销')
|
||||
return
|
||||
}
|
||||
|
||||
woDialog.bill = row
|
||||
const balance = Number(currentAccount.value.balance) || 0
|
||||
const unwritten = Number(row.unwrittenAmount) || 0
|
||||
woDialog.form = {
|
||||
arBillId: row.arBillId,
|
||||
customerId: Number(route.query.customerId),
|
||||
writeoffAmount: Math.min(unwritten, balance > 0 ? balance : unwritten),
|
||||
customerId,
|
||||
// 余额接口返回前先显示 0,避免使用旧余额或在余额为 0 时错误带出整笔未核销金额。
|
||||
writeoffAmount: 0,
|
||||
writeoffDate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
|
||||
remark: ''
|
||||
}
|
||||
woDialog.visible = true
|
||||
|
||||
// 必须等待余额刷新完成后再计算默认金额,避免异步请求尚未返回就读取旧余额。
|
||||
const requestSerial = ++writeoffAccountRequestSerial
|
||||
woDialog.accountLoading = true
|
||||
try {
|
||||
const res = await listAccount(customerId)
|
||||
if (requestSerial !== writeoffAccountRequestSerial) return
|
||||
accountList.value = res.data || []
|
||||
const balance = Math.max(0, Number(currentAccount.value.balance) || 0)
|
||||
woDialog.form.writeoffAmount = Math.min(unwritten, balance)
|
||||
} catch (e) {
|
||||
if (requestSerial !== writeoffAccountRequestSerial) return
|
||||
woDialog.form.writeoffAmount = 0
|
||||
proxy.$modal.msgError('账户余额刷新失败,请稍后重试')
|
||||
} finally {
|
||||
if (requestSerial === writeoffAccountRequestSerial) woDialog.accountLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
function submitWriteoff() {
|
||||
if (woDialog.accountLoading) {
|
||||
proxy.$modal.msgWarning('正在刷新账户余额,请稍候')
|
||||
return
|
||||
}
|
||||
const bill = woDialog.bill
|
||||
const amount = Number(woDialog.form.writeoffAmount)
|
||||
const rawAmount = typeof woDialog.form.writeoffAmount === 'string'
|
||||
? woDialog.form.writeoffAmount.trim()
|
||||
: woDialog.form.writeoffAmount
|
||||
const amount = Number(rawAmount)
|
||||
if (!(amount > 0)) {
|
||||
proxy.$modal.msgError('核销金额必须大于0')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user