汇率管理修改

This commit is contained in:
luojiaquan
2026-09-18 11:06:13 +08:00
parent e08a36de91
commit e2bb90ba75
8 changed files with 181 additions and 16 deletions
@@ -43,7 +43,7 @@
<el-col :xs="12" :sm="8" :md="4">
<el-card shadow="hover" class="balance-card">
<div class="balance-label">
总额度
信用额度
<el-button link type="primary" size="small" @click="openAdjustDialog('CREDIT')"
v-hasPermi="['customer:credit:adjust']">调整</el-button>
</div>
@@ -127,15 +127,27 @@
<span>{{ scope.row.currency }} {{ formatMoney(scope.row.amount) }}</span>
</template>
</el-table-column>
<el-table-column label="汇率" align="center" width="110">
<el-table-column label="汇率" align="center" width="100">
<template #default="scope">{{ formatRate(scope.row.exchangeRate) }}</template>
</el-table-column>
<el-table-column label="汇率来源" align="center" width="110">
<template #default="scope">
<el-tooltip v-if="scope.row.rateSourceDesc" :content="scope.row.rateSourceDesc" placement="top">
<el-tag :type="receiptRateSourceTag(scope.row.rateSource)" size="small">
{{ receiptRateSourceLabel(scope.row.rateSource) }}
</el-tag>
</el-tooltip>
<el-tag v-else :type="receiptRateSourceTag(scope.row.rateSource)" size="small">
{{ receiptRateSourceLabel(scope.row.rateSource) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="本位币金额(CNY)" align="center" width="140">
<template #default="scope">
<span class="money-in">{{ formatMoney(scope.row.baseAmount) }}</span>
</template>
</el-table-column>
<el-table-column label="待核销(CNY)" align="center" prop="unallocatedAmount" width="110" />
<!-- <el-table-column label="待核销(CNY)" align="center" prop="unallocatedAmount" width="110" />-->
<el-table-column label="收款方式" align="center" prop="payMethod" width="110">
<template #default="scope">{{ formatOption(payMethodOptions, scope.row.payMethod) }}</template>
</el-table-column>
@@ -596,7 +608,14 @@
style="width: 100%;"
@input="handleRateInput"
/>
<div class="rate-tip">1 {{ receiptDialog.form.currency || 'CNY' }} = {{ formatRate(receiptDialog.form.exchangeRate) }} CNY<span v-if="receiptDialog.form.currency !== 'CNY'">,默认取汇率表,可手工修改</span></div>
<div class="rate-tip">
1 {{ receiptDialog.form.currency || 'CNY' }} = {{ formatRate(receiptDialog.form.exchangeRate) }} CNY
<el-tag v-if="receiptDialog.form.currency === 'CNY'" size="small" type="info" effect="plain" style="margin-left: 6px;">系统默认</el-tag>
<el-tag v-else-if="rateEdited" size="small" type="warning" effect="dark" style="margin-left: 6px;">手工修改</el-tag>
<el-tag v-else-if="receiptDialog.form.exchangeRate" size="small" type="success" effect="plain" style="margin-left: 6px;">汇率表{{ rateSourceInfo.source ? '·' + rateSourceInfo.source : '' }}</el-tag>
<span v-else style="color: var(--el-color-warning);"> 汇率表未配置,请手工录入</span>
<span v-if="receiptDialog.form.currency !== 'CNY'">,默认取汇率表,可手工修改</span>
</div>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -678,6 +697,14 @@
<span class="money-in">{{ viewDialog.data.currency }} {{ formatMoney(viewDialog.data.amount) }}</span>
</el-descriptions-item>
<el-descriptions-item label="对CNY汇率">{{ formatRate(viewDialog.data.exchangeRate) }}</el-descriptions-item>
<el-descriptions-item label="汇率来源">
<el-tag :type="receiptRateSourceTag(viewDialog.data.rateSource)" size="small">
{{ receiptRateSourceLabel(viewDialog.data.rateSource) }}
</el-tag>
<span v-if="viewDialog.data.rateSourceDesc" style="margin-left: 8px; color: var(--el-text-color-secondary);">
{{ viewDialog.data.rateSourceDesc }}
</span>
</el-descriptions-item>
<el-descriptions-item label="本位币金额">
<span class="money-in">CNY {{ formatMoney(viewDialog.data.baseAmount) }}</span>
</el-descriptions-item>
@@ -1006,6 +1033,14 @@ function creditChangeTag(v) {
function isCreditUsageFlow(changeType) {
return changeType === 'OCCUPY' || changeType === 'RELEASE'
}
/** 收款汇率来源文案:RATE_TABLE汇率表 / MANUAL手工修改 / SYSTEM系统默认(本币) */
function receiptRateSourceLabel(v) {
return { RATE_TABLE: '汇率表', MANUAL: '手工修改', SYSTEM: '系统默认' }[v] || '系统默认'
}
/** 收款汇率来源标签颜色 */
function receiptRateSourceTag(v) {
return { RATE_TABLE: 'success', MANUAL: 'warning', SYSTEM: 'info' }[v] || 'info'
}
function formatMoney(val) {
const num = Number(val)
return isNaN(num) ? '0.00' : num.toFixed(2)
@@ -1277,6 +1312,7 @@ const receiptRules = {
function resetReceiptForm() {
rateEdited.value = false
rateSourceInfo.value = { source: '', ratePath: '' }
receiptDialog.form = {
customerId: route.query.customerId || null,
receivedAt: proxy.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
@@ -1299,12 +1335,15 @@ function handleAddReceipt() {
/** 汇率是否被手工修改过(修改后切换币种/日期不再自动覆盖) */
const rateEdited = ref(false)
/** 汇率表返回的来源信息(source: 中国银行等;ratePath: DIRECT/REVERSE/CROSS),仅用于表单实时展示 */
const rateSourceInfo = ref({ source: '', ratePath: '' })
/** 按收款日期从汇率表取该币种对CNY即期汇率 */
function fetchDefaultRate() {
const cur = receiptDialog.form.currency
if (!cur || cur === 'CNY') {
receiptDialog.form.exchangeRate = 1
rateSourceInfo.value = { source: '', ratePath: 'SAME' }
return
}
const bizDate = receiptDialog.form.receivedAt
@@ -1312,11 +1351,15 @@ function fetchDefaultRate() {
: proxy.parseTime(new Date(), '{y}-{m}-{d}')
convertToBase({ amount: 1, currency: cur, rateType: '0', bizDate })
.then(res => {
if (!rateEdited.value) receiptDialog.form.exchangeRate = Number(res.data.rate)
if (!rateEdited.value) {
receiptDialog.form.exchangeRate = Number(res.data.rate)
rateSourceInfo.value = { source: res.data.source || '', ratePath: res.data.ratePath || 'DIRECT' }
}
})
.catch(() => {
if (!rateEdited.value) {
receiptDialog.form.exchangeRate = undefined
rateSourceInfo.value = { source: '', ratePath: '' }
proxy.$modal.msgWarning(`汇率表中未维护 ${cur} 对 CNY 的汇率,请手工录入汇率`)
}
})
@@ -1325,6 +1368,7 @@ function fetchDefaultRate() {
/** 切换币种:重置手工标记并重新取默认汇率 */
function handleCurrencyChange() {
rateEdited.value = false
rateSourceInfo.value = { source: '', ratePath: '' }
fetchDefaultRate()
}
@@ -214,10 +214,11 @@ const open = ref(false)
const calcResult = ref(null)
const rateTypeOptions = [
{ value: '0', label: '即期汇率' },
{ value: '1', label: '月初汇率' },
{ value: '2', label: '月末汇率' },
{ value: '3', label: '固定汇率' }
{ value: '0', label: '即期汇率' }
// ,
// { value: '1', label: '月初汇率' },
// { value: '2', label: '月末汇率' },
// { value: '3', label: '固定汇率' }
]
/** 常用币种兜底 + 从国家资料(币种)去重加载 */