✨ 结算单新增时自动查询BFI汇率
- currency.js: 新增getBfiExchangeRate接口调用 - pre-settlement-editor.vue: - 选择合同后同步结算币种并自动查询当天BFI汇率 - 汇率日期变更时自动查询BFI汇率并回填结算汇率 - 新增时自动设置当天日期并查询汇率 - formal-settlement-editor.vue: - 选择合同后同步结算币种并自动查询当天BFI汇率 - 汇率日期变更时自动查询BFI汇率并回填结算汇率 - 新增时自动查询当天BFI汇率
This commit is contained in:
@@ -58,3 +58,14 @@ export const changeStatus = (id, status) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getBfiExchangeRate = (currencyCode, effectdate) => {
|
||||||
|
return request({
|
||||||
|
url: '/blade-transport/bfi/exchange-rate',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
currencyCode,
|
||||||
|
effectdate,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
|
@change="fetchBfiExchangeRate"
|
||||||
/>
|
/>
|
||||||
<el-select
|
<el-select
|
||||||
v-else-if="field.type === 'project' && editable"
|
v-else-if="field.type === 'project' && editable"
|
||||||
@@ -947,6 +948,7 @@ import {
|
|||||||
getDetailFees as getPreSettlementDetailFees,
|
getDetailFees as getPreSettlementDetailFees,
|
||||||
} from '@/api/settlement/preSettlement';
|
} from '@/api/settlement/preSettlement';
|
||||||
import { calculateAdjustedFee, getFeeDetail } from '@/api/settlement/receivable-payable-detail';
|
import { calculateAdjustedFee, getFeeDetail } from '@/api/settlement/receivable-payable-detail';
|
||||||
|
import { getBfiExchangeRate } from '@/api/base/currency';
|
||||||
import {
|
import {
|
||||||
createFormalSettlementForm,
|
createFormalSettlementForm,
|
||||||
formalSettlementFormFields,
|
formalSettlementFormFields,
|
||||||
@@ -1250,6 +1252,7 @@ export default {
|
|||||||
if (this.initialData) await this.applyInitialData();
|
if (this.initialData) await this.applyInitialData();
|
||||||
Object.assign(this.form, newRecordAudit);
|
Object.assign(this.form, newRecordAudit);
|
||||||
await this.refreshFormalSettlementNo();
|
await this.refreshFormalSettlementNo();
|
||||||
|
await this.fetchBfiExchangeRate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -1482,6 +1485,7 @@ export default {
|
|||||||
(settlementType === 'receivable' ? contract.partyA : contract.partyB),
|
(settlementType === 'receivable' ? contract.partyA : contract.partyB),
|
||||||
settlementType,
|
settlementType,
|
||||||
settlementTypeName: settlementType === 'receivable' ? '应收' : '应付',
|
settlementTypeName: settlementType === 'receivable' ? '应收' : '应付',
|
||||||
|
currency: contract.settlementCurrency || 'RMB',
|
||||||
});
|
});
|
||||||
this.sources = [];
|
this.sources = [];
|
||||||
this.details = [];
|
this.details = [];
|
||||||
@@ -1489,6 +1493,23 @@ export default {
|
|||||||
this.form.sourcePreSettlementIds = [];
|
this.form.sourcePreSettlementIds = [];
|
||||||
this.form.sourceDetailIds = [];
|
this.form.sourceDetailIds = [];
|
||||||
if (refreshSettlementNo) this.refreshFormalSettlementNo();
|
if (refreshSettlementNo) this.refreshFormalSettlementNo();
|
||||||
|
if (this.form.currency !== 'RMB') this.fetchBfiExchangeRate();
|
||||||
|
},
|
||||||
|
async fetchBfiExchangeRate() {
|
||||||
|
const currency = this.form.currency;
|
||||||
|
if (!currency || currency === 'RMB') return;
|
||||||
|
if (!this.form.exchangeRateDate) return;
|
||||||
|
try {
|
||||||
|
const { data } = await getBfiExchangeRate(currency, this.form.exchangeRateDate);
|
||||||
|
const rateData = data?.data;
|
||||||
|
if (rateData?.excval != null) {
|
||||||
|
this.form.exchangeRate = Number(rateData.excval);
|
||||||
|
} else {
|
||||||
|
this.$message.warning(`未查询到 ${currency} 的BFI汇率数据`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.$message.warning('查询BFI汇率失败,请手动输入结算汇率');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
openCandidateDialog() {
|
openCandidateDialog() {
|
||||||
this.candidate.visible = true;
|
this.candidate.visible = true;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
:disabled="!editable || form.currency === 'RMB'"
|
:disabled="!editable || form.currency === 'RMB'"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@change="recalculateLocalAmount"
|
@change="handleExchangeRateDateChange"
|
||||||
/>
|
/>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-else-if="field.type === 'number'"
|
v-else-if="field.type === 'number'"
|
||||||
@@ -934,6 +934,7 @@ import {
|
|||||||
submit,
|
submit,
|
||||||
} from '@/api/settlement/preSettlement';
|
} from '@/api/settlement/preSettlement';
|
||||||
import { calculateAdjustedFee, getFeeDetail } from '@/api/settlement/receivable-payable-detail';
|
import { calculateAdjustedFee, getFeeDetail } from '@/api/settlement/receivable-payable-detail';
|
||||||
|
import { getBfiExchangeRate } from '@/api/base/currency';
|
||||||
import { getDictionary } from '@/api/system/dictbiz';
|
import { getDictionary } from '@/api/system/dictbiz';
|
||||||
import {
|
import {
|
||||||
emptyPreSettlementForm,
|
emptyPreSettlementForm,
|
||||||
@@ -1242,7 +1243,11 @@ export default {
|
|||||||
await this.loadFeeCategoryOptions();
|
await this.loadFeeCategoryOptions();
|
||||||
await this.loadTransportTypeOptions();
|
await this.loadTransportTypeOptions();
|
||||||
if (this.recordId) await this.loadDetail();
|
if (this.recordId) await this.loadDetail();
|
||||||
else if (this.initialData) await this.applyInitialData();
|
else if (this.initialData) {
|
||||||
|
await this.applyInitialData();
|
||||||
|
this.form.exchangeRateDate = this.$dayjs().format('YYYY-MM-DD');
|
||||||
|
await this.fetchBfiExchangeRate();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async applyInitialData() {
|
async applyInitialData() {
|
||||||
const rows = Array.isArray(this.initialData?.rows) ? this.initialData.rows : [];
|
const rows = Array.isArray(this.initialData?.rows) ? this.initialData.rows : [];
|
||||||
@@ -1527,7 +1532,12 @@ export default {
|
|||||||
this.form.settlementType = contract.settlementType || 'payable';
|
this.form.settlementType = contract.settlementType || 'payable';
|
||||||
this.form.payerName = contract.partyA;
|
this.form.payerName = contract.partyA;
|
||||||
this.form.payeeName = contract.partyB;
|
this.form.payeeName = contract.partyB;
|
||||||
|
this.form.currency = contract.settlementCurrency || 'RMB';
|
||||||
this.summaryFees = [];
|
this.summaryFees = [];
|
||||||
|
if (this.form.currency !== 'RMB') {
|
||||||
|
this.form.exchangeRateDate = this.$dayjs().format('YYYY-MM-DD');
|
||||||
|
this.fetchBfiExchangeRate();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async saveDraft(shouldSubmit) {
|
async saveDraft(shouldSubmit) {
|
||||||
await this.$refs.formRef?.validate();
|
await this.$refs.formRef?.validate();
|
||||||
@@ -1794,6 +1804,26 @@ export default {
|
|||||||
.toFixed(2)
|
.toFixed(2)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
handleExchangeRateDateChange() {
|
||||||
|
this.fetchBfiExchangeRate();
|
||||||
|
this.recalculateLocalAmount();
|
||||||
|
},
|
||||||
|
async fetchBfiExchangeRate() {
|
||||||
|
if (!this.form.currency || this.form.currency === 'RMB') 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.form.exchangeRate = Number(rateData.excval);
|
||||||
|
this.recalculateLocalAmount();
|
||||||
|
} else {
|
||||||
|
this.$message.warning(`未查询到 ${this.form.currency} 的BFI汇率数据`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.$message.warning('查询BFI汇率失败,请手动输入结算汇率');
|
||||||
|
}
|
||||||
|
},
|
||||||
recalculateLocalAmount() {
|
recalculateLocalAmount() {
|
||||||
const rate = this.form.currency === 'RMB' ? 1 : Number(this.form.exchangeRate || 0);
|
const rate = this.form.currency === 'RMB' ? 1 : Number(this.form.exchangeRate || 0);
|
||||||
this.form.localSettlementAmount = (Number(this.form.settlementAmount || 0) * rate).toFixed(2);
|
this.form.localSettlementAmount = (Number(this.form.settlementAmount || 0) * rate).toFixed(2);
|
||||||
|
|||||||
Reference in New Issue
Block a user