fix: 结算行付款金额联动回填申请付款金额并校验合计一致

结算信息行改动付款比例或付款金额时,自动把行金额合计回填到上方申请付款金额并重算比例;
保存/提交前校验行金额合计与申请付款金额一致,避免推送金蝶金额与预付建档分摊不一致。
回显加载走默认不同步,避免改写历史单据。
This commit is contained in:
刘泉佳
2026-10-29 02:19:23 +08:00
parent ea6ec13ea4
commit 698f808f0b
+32 -5
View File
@@ -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();