diff --git a/src/views/payment/payment-application-form.vue b/src/views/payment/payment-application-form.vue index 21e0711..cb0eca1 100644 --- a/src/views/payment/payment-application-form.vue +++ b/src/views/payment/payment-application-form.vue @@ -3125,18 +3125,21 @@ export default { if (!target) return; target.paymentRatio = value; this.syncRowPayment(target, 'ratio'); - this.syncHeaderSettlementTotalsFromRows(); + this.syncHeaderSettlementTotalsFromRows(true); }, handleRowAppliedAmountChange(row, value) { const target = this.findReferenceRow(row); if (!target) return; target.appliedAmount = value; this.syncRowPayment(target, 'amount'); - this.syncHeaderSettlementTotalsFromRows(); + this.syncHeaderSettlementTotalsFromRows(true); }, - /** 多结算单时仅同步结算金额/可付款金额合计,申请付款金额与比例由上方独立维护 */ - syncHeaderSettlementTotalsFromRows() { - if (this.referenceRows.length <= 1) return; + /** + * 结算信息行合计回填付款基本信息。 + * @param {boolean} syncApplied 行内编辑时同步申请付款金额与比例;回显加载时保持原值,避免改写历史单据 + */ + syncHeaderSettlementTotalsFromRows(syncApplied = false) { + if (!this.referenceRows.length) return; const settlementAmount = this.referenceRows.reduce( (total, item) => total + Number(item.settlementAmount || 0), 0 @@ -3145,9 +3148,21 @@ export default { (total, item) => total + Number(item.payableAmount || 0), 0 ); + const appliedAmount = this.referenceRows.reduce( + (total, item) => total + Number(item.appliedAmount || 0), + 0 + ); this.amountSyncing = true; this.form.settlementAmount = Number(settlementAmount.toFixed(2)); this.form.payableAmount = Number(payableAmount.toFixed(2)); + if (syncApplied) { + this.form.appliedAmount = Number(appliedAmount.toFixed(2)); + if (this.paymentAmountBase) { + this.form.paymentRatio = Number( + ((appliedAmount / this.paymentAmountBase) * 100).toFixed(2) + ); + } + } this.$nextTick(() => { this.amountSyncing = false; this.$refs.formRef?.validateField?.(['settlementAmount', 'appliedAmount']); @@ -3321,6 +3336,18 @@ export default { ElMessage.warning(`${exceededRow.settlementNo || '结算单'}付款金额不能超过可付款金额`); return false; } + const rowAppliedTotal = this.referenceRows.reduce( + (total, item) => total + Number(item.appliedAmount || 0), + 0 + ); + // 金蝶按付款基本信息申请金额推单,行合计不等时预付建档分摊会与金蝶金额不一致 + if (Math.abs(rowAppliedTotal - appliedAmount) > 0.005) { + this.clearMessages(); + ElMessage.warning( + `结算行付款金额合计${rowAppliedTotal.toFixed(2)}与申请付款金额${appliedAmount.toFixed(2)}不一致,请调整` + ); + return false; + } } if (this.form.paymentType === 'project_advance' && !this.form.projectId) { this.clearMessages();