本期扣款金额自动填充

master
lynn 1 year ago
parent 9694459ac8
commit 64d9df58a4

@ -466,7 +466,9 @@ export default {
zoomedDialogVisible: false, // 控制放大表格弹窗的显示 zoomedDialogVisible: false, // 控制放大表格弹窗的显示
hasPostPaymentForm: false, // 是否有事后支付表格 hasPostPaymentForm: false, // 是否有事后支付表格
contract_category: {}, contract_category: {},
templateContextData: null // 合同模板关联数据 templateContextData: null, // 合同模板关联数据
total: 0,
otherTotal: 0
} }
}, },
computed: { computed: {
@ -482,7 +484,9 @@ export default {
this.getBudgets() this.getBudgets()
this.currentStep = 1 // 重置到第一步 this.currentStep = 1 // 重置到第一步
this.paymentRegistrationForm = this.getDefaultPaymentRegistrationForm() // 每次弹窗打开时重置表单 this.paymentRegistrationForm = this.getDefaultPaymentRegistrationForm() // 每次弹窗打开时重置表单
// 重置校验状态,避免立刻弹出必填项提示 this.forms = null // <---清空表单HTML内容
this.contract = {} // <--- 新增:重置合同对象
this.contractTemplate = null // <--- 新增:重置模板
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.paymentRegistration && this.$refs.paymentRegistration.$refs.elForm) { if (this.$refs.paymentRegistration && this.$refs.paymentRegistration.$refs.elForm) {
this.$refs.paymentRegistration.$refs.elForm.resetFields() this.$refs.paymentRegistration.$refs.elForm.resetFields()
@ -605,6 +609,7 @@ export default {
if (this.contract_category && this.contract_category.default_remark !== undefined) { if (this.contract_category && this.contract_category.default_remark !== undefined) {
this.paymentRegistrationForm.remark = this.contract_category.default_remark this.paymentRegistrationForm.remark = this.contract_category.default_remark
} }
// 动态生成rules // 动态生成rules
this.paymentRegistrationRules = { this.paymentRegistrationRules = {
applyMoney: [ applyMoney: [
@ -669,7 +674,7 @@ export default {
this.hasPostPaymentForm = true this.hasPostPaymentForm = true
this.currentStep = 1 this.currentStep = 1
this.contractTemplate = this.contract.contract_template.template this.contractTemplate = this.contract.contract_template.template
this.forms = this.contract.forms this.forms = this.contractTemplate
if (!this.contract.contract_template.contract_template_fields) { if (!this.contract.contract_template.contract_template_fields) {
this.contract.contract_template.contract_template_fields = this.contract.other_data || [] this.contract.contract_template.contract_template_fields = this.contract.other_data || []
} }
@ -910,6 +915,27 @@ export default {
}, },
nextStep() { nextStep() {
try { try {
// 自动填充表格中的填写的支付金额.
let applyMoney = 0
if (this.total > 0) {
applyMoney = this.total
} else if (this.otherTotal > 0) {
applyMoney = this.otherTotal
}
// 从动态表单中获取当前付款金额
const mainTable = this.$refs.mainTable
if (mainTable) {
const currentPaymentInput = mainTable.querySelector('input[data-field="currentDuePayment"]')
if (currentPaymentInput) {
const inputValue = currentPaymentInput.value
if (inputValue && Number(inputValue) > 0) {
applyMoney = Number(inputValue)
}
}
}
this.paymentRegistrationForm.applyMoney = applyMoney
// 如果有事后支付表格,下一步不做表单校验,直接切换 currentStep=2 // 如果有事后支付表格,下一步不做表单校验,直接切换 currentStep=2
if (this.hasPostPaymentForm) { if (this.hasPostPaymentForm) {
// 保存事后支付表格HTML数据,参考 openZoomedTable 逻辑 // 保存事后支付表格HTML数据,参考 openZoomedTable 逻辑
@ -983,6 +1009,7 @@ export default {
// 使用setTimeout确保DOM完全加载 // 使用setTimeout确保DOM完全加载
setTimeout(() => { setTimeout(() => {
const sdateAmountInputs = dom.querySelectorAll('input[data-field^="sdate"]') const sdateAmountInputs = dom.querySelectorAll('input[data-field^="sdate"]')
// 移除旧的监听器 // 移除旧的监听器
sdateAmountInputs.forEach(input => { sdateAmountInputs.forEach(input => {
@ -1275,26 +1302,20 @@ export default {
fenInput.value = fenTotal===0?'':fenTotal fenInput.value = fenTotal===0?'':fenTotal
} }
let otherTotal = wanTotal * 10000 + qianTotal * 1000 + baiTotal * 100 + shiTotal * 10 + yuanTotal + jiaoTotal * 0.1 + fenTotal * 0.01 this.otherTotal = wanTotal * 10000 + qianTotal * 1000 + baiTotal * 100 + shiTotal * 10 + yuanTotal + jiaoTotal * 0.1 + fenTotal * 0.01
let total = 0 this.total = 0
// 只计算以 amount 开头的输入框 // 只计算以 amount 开头的输入框
const amountInputs = dom.querySelectorAll('input[data-field^="amount"]') const amountInputs = dom.querySelectorAll('input[data-field^="amount"]')
console.log('计算总金额,找到输入框数量:', amountInputs.length, dom)
amountInputs.forEach(input => { amountInputs.forEach(input => {
const value = parseFloat(input.value) || 0 const value = parseFloat(input.value) || 0
console.log('输入框值:', input.getAttribute('data-field'), value) this.total += value
total += value
}) })
console.log('计算得到的总金额:', total)
// 更新总金额输入框 // 更新总金额输入框
const totalInput = dom.querySelector('input[data-field="total"]') const totalInput = dom.querySelector('input[data-field="total"]')
if (totalInput) { if (totalInput) {
totalInput.value = total.toFixed(2) totalInput.value = this.total.toFixed(2)
console.log('更新总金额输入框:', totalInput.value)
// 监听 total 输入框的变化 // 监听 total 输入框的变化
totalInput.removeEventListener('input', (e) => this.updateUpperCaseFromTotal(e, dom)) totalInput.removeEventListener('input', (e) => this.updateUpperCaseFromTotal(e, dom))
@ -1309,14 +1330,13 @@ export default {
// 更新大写金额 // 更新大写金额
const upperCaseInput = dom.querySelector('input[data-field="upperCaseAmount"]') const upperCaseInput = dom.querySelector('input[data-field="upperCaseAmount"]')
if (upperCaseInput) { if (upperCaseInput) {
if (total !== 0) { if (this.total !== 0) {
upperCaseInput.value = numberToChinese(total) upperCaseInput.value = numberToChinese(this.total)
} }
if (otherTotal !== 0) { if (this.otherTotal !== 0) {
upperCaseInput.value = numberToChinese(otherTotal) upperCaseInput.value = numberToChinese(this.otherTotal)
} }
console.log('更新大写金额:', upperCaseInput.value)
} }
}, },
@ -1329,7 +1349,6 @@ export default {
if (totalInput && upperCaseInput) { if (totalInput && upperCaseInput) {
const total = parseFloat(totalInput.value) || 0 const total = parseFloat(totalInput.value) || 0
upperCaseInput.value = numberToChinese(total) upperCaseInput.value = numberToChinese(total)
console.log('从总金额更新大写金额:', total, upperCaseInput.value)
} }
let wanTotal = 0 let wanTotal = 0

@ -3395,7 +3395,6 @@ export default {
// 获取最新的合同详情 // 获取最新的合同详情
const res = await detailContract({ id: row.id }) const res = await detailContract({ id: row.id })
if (res) { if (res) {
console.log('detail', res)
this.$refs['paymentRegistration'].getContract(row) this.$refs['paymentRegistration'].getContract(row)
this.$refs['paymentRegistration'].isShowPaymentRegistration = true this.$refs['paymentRegistration'].isShowPaymentRegistration = true
} else { } else {

Loading…
Cancel
Save