✨ 结算汇率反算、开票合计填报、配载承运商交集与车辆组织悬停
外币结算按本位币/汇率反算;开票改填合计金额并反算不含税单价;配载展示承运商合同并按乙方交集限选;评分加减分封顶15分;车辆所有组织/使用部门悬停显示完整路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1388,16 +1388,12 @@ export default {
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
summaryTotal(value) {
|
||||
this.form.settlementAmount = Number(value || 0).toFixed(2);
|
||||
this.form.localSettlementAmount = (
|
||||
Number(value || 0) * Number(this.form.exchangeRate || 1)
|
||||
).toFixed(2);
|
||||
summaryTotal() {
|
||||
this.syncSettlementAmountsFromSummary();
|
||||
},
|
||||
'form.exchangeRate'(value) {
|
||||
this.form.localSettlementAmount = (
|
||||
Number(this.summaryTotal || 0) * Number(value || 1)
|
||||
).toFixed(2);
|
||||
'form.exchangeRate'() {
|
||||
if (this._skipExchangeRateRebuild) return;
|
||||
this.buildSummaryFeesFromDetails();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
@@ -1683,8 +1679,9 @@ export default {
|
||||
current.settlementAmount = current.originalAmount;
|
||||
summaryMap.set(key, current);
|
||||
});
|
||||
// 先保留预结算手工费用行,再按明细本位币 + 结算汇率重算系统归集行
|
||||
this.summaryFees = [...summaryMap.values()];
|
||||
if (!this.summaryFees.length) await this.refreshSummaryFees();
|
||||
await this.refreshSummaryFees();
|
||||
},
|
||||
async loadAllContracts() {
|
||||
const response = await getContractOptions('');
|
||||
@@ -1786,13 +1783,19 @@ export default {
|
||||
},
|
||||
async fetchBfiExchangeRate() {
|
||||
const currency = this.form.currency;
|
||||
if (!currency || currency === 'RMB') return;
|
||||
if (!currency || currency === 'RMB') {
|
||||
this.buildSummaryFeesFromDetails();
|
||||
return;
|
||||
}
|
||||
if (!this.form.exchangeRateDate) return;
|
||||
try {
|
||||
const { data } = await getBfiExchangeRate(currency, this.form.exchangeRateDate);
|
||||
const rateData = data?.data;
|
||||
if (rateData?.excval != null) {
|
||||
this._skipExchangeRateRebuild = true;
|
||||
this.form.exchangeRate = Number(rateData.excval);
|
||||
this._skipExchangeRateRebuild = false;
|
||||
this.buildSummaryFeesFromDetails();
|
||||
} else {
|
||||
this.$message.warning(`未查询到 ${currency} 的BFI汇率数据`);
|
||||
}
|
||||
@@ -1800,6 +1803,37 @@ export default {
|
||||
this.$message.warning('查询BFI汇率失败,请手动输入结算汇率');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 明细金额按本位币理解;外币结算时结算合计原金额/结算金额 = 本位币金额 / 结算汇率。
|
||||
*/
|
||||
convertLocalToSettlementAmount(localAmount) {
|
||||
const amount = Number(localAmount || 0);
|
||||
if (!Number.isFinite(amount)) return 0;
|
||||
if (this.isLocalCurrencySettlement) {
|
||||
return Number(amount.toFixed(2));
|
||||
}
|
||||
const rate = Number(this.form.exchangeRate || 0);
|
||||
if (rate <= 0) return 0;
|
||||
return Number((amount / rate).toFixed(2));
|
||||
},
|
||||
/**
|
||||
* 结算金额取结算合计原币汇总值;本位币合计 = 结算金额 × 结算汇率。
|
||||
*/
|
||||
syncSettlementAmountsFromSummary() {
|
||||
const settlementTotal = this.summaryFees.reduce(
|
||||
(total, row) => total + Number(row.settlementAmount || 0),
|
||||
0
|
||||
);
|
||||
this.form.settlementAmount = Number(settlementTotal || 0).toFixed(2);
|
||||
if (this.isLocalCurrencySettlement) {
|
||||
this.form.localSettlementAmount = this.form.settlementAmount;
|
||||
this.form.exchangeRate = 1;
|
||||
return;
|
||||
}
|
||||
const rate = Number(this.form.exchangeRate || 0);
|
||||
this.form.localSettlementAmount =
|
||||
rate > 0 ? (Number(this.form.settlementAmount || 0) * rate).toFixed(2) : '0.00';
|
||||
},
|
||||
openCandidateDialog() {
|
||||
this.candidate.visible = true;
|
||||
this.candidate.page.current = 1;
|
||||
@@ -2021,8 +2055,9 @@ export default {
|
||||
.map(row => [`${row.feeType}\u0000${row.feeItem}`, row])
|
||||
);
|
||||
const append = (feeItem, originalValue, settlementValue, fallbackFeeType = '') => {
|
||||
const originalAmount = Number(originalValue || 0);
|
||||
const settlementAmount = Number(settlementValue || 0);
|
||||
// 明细费用按本位币归集,外币结算时再按汇率换算成结算原币金额
|
||||
const originalAmount = this.convertLocalToSettlementAmount(originalValue);
|
||||
const settlementAmount = this.convertLocalToSettlementAmount(settlementValue);
|
||||
if (!feeItem || !Number.isFinite(originalAmount) || !Number.isFinite(settlementAmount)) {
|
||||
return;
|
||||
}
|
||||
@@ -2060,6 +2095,7 @@ export default {
|
||||
});
|
||||
const manualRows = this.summaryFees.filter(row => Number(row.manualFlag) === 1);
|
||||
this.summaryFees = [...generatedMap.values(), ...manualRows];
|
||||
this.syncSettlementAmountsFromSummary();
|
||||
},
|
||||
// 每条明细对应的费用行:[调整前基准行, 调整后当前行],缺少费用快照时退化为明细自身的汇总行。
|
||||
resolveDetailFeePairs(detail) {
|
||||
|
||||
@@ -1332,9 +1332,12 @@ export default {
|
||||
if (value) this.initialize();
|
||||
},
|
||||
},
|
||||
summaryTotal(value) {
|
||||
this.form.settlementAmount = Number(value || 0).toFixed(2);
|
||||
this.recalculateLocalAmount();
|
||||
summaryTotal() {
|
||||
this.syncSettlementAmountsFromSummary();
|
||||
},
|
||||
'form.exchangeRate'() {
|
||||
if (this._skipExchangeRateRebuild) return;
|
||||
this.buildSummaryFeesFromDetails();
|
||||
},
|
||||
filteredDetails: {
|
||||
handler(list) {
|
||||
@@ -1890,8 +1893,9 @@ export default {
|
||||
.map(row => [`${row.feeType}\u0000${row.feeItem}`, row])
|
||||
);
|
||||
const appendSummary = (feeItem, originalValue, settlementValue, fallbackFeeType = '') => {
|
||||
const originalAmount = Number(originalValue || 0);
|
||||
const settlementAmount = Number(settlementValue || 0);
|
||||
// 明细费用按本位币归集,外币结算时再按汇率换算成结算原币金额
|
||||
const originalAmount = this.convertLocalToSettlementAmount(originalValue);
|
||||
const settlementAmount = this.convertLocalToSettlementAmount(settlementValue);
|
||||
if (!feeItem || !Number.isFinite(originalAmount) || !Number.isFinite(settlementAmount)) {
|
||||
return;
|
||||
}
|
||||
@@ -1946,7 +1950,7 @@ export default {
|
||||
});
|
||||
nextFeeMap.forEach(row => orderedFees.push(row));
|
||||
this.summaryFees = orderedFees;
|
||||
this.recalculateLocalAmount();
|
||||
this.syncSettlementAmountsFromSummary();
|
||||
},
|
||||
// 每条明细对应的费用行:[调整前基准行, 调整后当前行],缺少来源费用快照时退化为明细自身的汇总行。
|
||||
resolveDetailFeePairs(detail) {
|
||||
@@ -2034,17 +2038,21 @@ export default {
|
||||
},
|
||||
handleExchangeRateDateChange() {
|
||||
this.fetchBfiExchangeRate();
|
||||
this.recalculateLocalAmount();
|
||||
},
|
||||
async fetchBfiExchangeRate() {
|
||||
if (!this.form.currency || this.form.currency === 'RMB') return;
|
||||
if (!this.form.currency || this.form.currency === 'RMB') {
|
||||
this.buildSummaryFeesFromDetails();
|
||||
return;
|
||||
}
|
||||
if (!this.form.exchangeRateDate) return;
|
||||
try {
|
||||
const { data } = await getBfiExchangeRate(this.form.currency, this.form.exchangeRateDate);
|
||||
const rateData = data?.data;
|
||||
if (rateData?.excval != null) {
|
||||
this._skipExchangeRateRebuild = true;
|
||||
this.form.exchangeRate = Number(rateData.excval);
|
||||
this.recalculateLocalAmount();
|
||||
this._skipExchangeRateRebuild = false;
|
||||
this.buildSummaryFeesFromDetails();
|
||||
} else {
|
||||
this.$message.warning(`未查询到 ${this.form.currency} 的BFI汇率数据`);
|
||||
}
|
||||
@@ -2052,9 +2060,39 @@ export default {
|
||||
this.$message.warning('查询BFI汇率失败,请手动输入结算汇率');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 明细金额按本位币理解;外币结算时结算合计原金额/结算金额 = 本位币金额 / 结算汇率。
|
||||
*/
|
||||
convertLocalToSettlementAmount(localAmount) {
|
||||
const amount = Number(localAmount || 0);
|
||||
if (!Number.isFinite(amount)) return 0;
|
||||
if (this.isLocalCurrencySettlement) {
|
||||
return Number(amount.toFixed(2));
|
||||
}
|
||||
const rate = Number(this.form.exchangeRate || 0);
|
||||
if (rate <= 0) return 0;
|
||||
return Number((amount / rate).toFixed(2));
|
||||
},
|
||||
/**
|
||||
* 结算金额取结算合计原币汇总值;本位币合计 = 结算金额 × 结算汇率。
|
||||
*/
|
||||
syncSettlementAmountsFromSummary() {
|
||||
const settlementTotal = this.summaryFees.reduce(
|
||||
(total, row) => total + Number(row.settlementAmount || 0),
|
||||
0
|
||||
);
|
||||
this.form.settlementAmount = Number(settlementTotal || 0).toFixed(2);
|
||||
if (this.isLocalCurrencySettlement) {
|
||||
this.form.localSettlementAmount = this.form.settlementAmount;
|
||||
this.form.exchangeRate = 1;
|
||||
return;
|
||||
}
|
||||
const rate = Number(this.form.exchangeRate || 0);
|
||||
this.form.localSettlementAmount =
|
||||
rate > 0 ? (Number(this.form.settlementAmount || 0) * rate).toFixed(2) : '0.00';
|
||||
},
|
||||
recalculateLocalAmount() {
|
||||
const rate = this.form.currency === 'RMB' ? 1 : Number(this.form.exchangeRate || 0);
|
||||
this.form.localSettlementAmount = (Number(this.form.settlementAmount || 0) * rate).toFixed(2);
|
||||
this.buildSummaryFeesFromDetails();
|
||||
},
|
||||
openCandidateDialog() {
|
||||
if (!this.form.contractId) {
|
||||
|
||||
Reference in New Issue
Block a user