汇率管理

This commit is contained in:
luojiaquan
2026-09-14 17:12:16 +08:00
parent c89c1340b0
commit aec5be9643
13 changed files with 1550 additions and 1 deletions
@@ -24,6 +24,12 @@
<el-card shadow="hover" class="balance-card">
<div class="balance-label">账户余额</div>
<div class="balance-value primary">{{ formatMoney(currentAccount.balance) }}</div>
<div v-if="currentCurrency !== 'CNY'" class="balance-base">
≈ CNY {{ baseAmountText }}
<el-tooltip :content="baseRateText" placement="bottom">
<el-icon class="balance-base-icon"><InfoFilled /></el-icon>
</el-tooltip>
</div>
</el-card>
</el-col>
<el-col :xs="12" :sm="8" :md="4">
@@ -368,6 +374,7 @@ import axios from 'axios'
import { saveAs } from 'file-saver'
import { getCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
import { listAccount, listReceipt, getReceipt, addReceipt, confirmReceipt, cancelReceipt, listFlow } from "@/api/customersuppliermanagement/customermoney/customermoney.js"
import { convertToBase } from "@/api/data/exchangeRate"
import { getToken } from "@/utils/auth"
import { useRoute } from 'vue-router'
@@ -466,9 +473,42 @@ function loadAccounts() {
const exists = accountList.value.some(a => a.currency === currentCurrency.value)
if (!exists) currentCurrency.value = accountList.value[0].currency
}
loadBaseAmounts()
})
}
/* 外币账户按即期汇率折算本位币(CNY) */
const baseAmountMap = ref({})
const baseRateMap = ref({})
function loadBaseAmounts() {
baseAmountMap.value = {}
baseRateMap.value = {}
accountList.value
.filter(a => a.currency && a.currency !== 'CNY' && Number(a.balance) !== 0)
.forEach(a => {
convertToBase({ amount: a.balance, currency: a.currency, rateType: '0' })
.then(res => {
baseAmountMap.value[a.currency] = res.data.result
baseRateMap.value[a.currency] = res.data.rate
})
.catch(() => {
// 未维护汇率时不阻塞页面,折算行不显示
})
})
}
const baseAmountText = computed(() => {
const v = baseAmountMap.value[currentCurrency.value]
return v === undefined || v === null ? '-' : formatMoney(v)
})
const baseRateText = computed(() => {
const r = baseRateMap.value[currentCurrency.value]
return r === undefined || r === null
? '未维护对CNY汇率'
: `按即期汇率折算:1 ${currentCurrency.value} = ${r} CNY`
})
function goBack() {
router.push({ path: '/customersuppliermanagement/customerinfo' })
}
@@ -815,6 +855,19 @@ watch(() => route.query.customerId, (newId, oldId) => {
.balance-value.success { color: var(--el-color-success); }
.balance-value.warning { color: var(--el-color-warning); }
.balance-value.danger { color: var(--el-color-danger); }
.balance-base {
margin-top: 6px;
font-size: 12px;
color: var(--el-text-color-secondary);
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
}
.balance-base-icon {
cursor: help;
font-size: 13px;
}
.search-form {
margin-bottom: -4px;
}