Browse Source

fix:数据展示问题

zhangyong/milestone-20250913-现金管理
lihui 1 month ago
parent
commit
23ecea5a49
  1. 37
      src/components/workspace/CashManagement.vue

37
src/components/workspace/CashManagement.vue

@ -41,11 +41,10 @@
<span class="market-name">{{ market.name }}</span>
<span class="market-value">{{ market.value.toLocaleString() }} 新币</span>
</div>
<div v-else>
<div v-for="item in cashData.markets" :key="item.name" class="market-item">
<div v-else v-for="item in cashData.markets" :key="item.name" class="market-item">
<span class="market-name">代收{{ item.name }}</span>
<span class="market-value">{{ item.value.toLocaleString() }} </span>
</div>
</div>
</div>
@ -135,29 +134,35 @@ const fetchCashData = async () => {
} else {
// 1.
const currencyMap = {
usd: '美元',
hkd: '港币',
// usd: '',
sgd: '新币',
myr: '马币',
thb: '泰铢',
hkd: '港币',
cad: '加币',
thb: '泰铢',
vdn: '越南盾',
krw: '韩元'
}
};
// 2. market totalSGD
const currencyKeys = Object.keys(res[0]).filter(
key => key !== 'market' && key !== 'totalSGD'
)
// res使currencyMapkey
const currencyKeys = res.length > 0
? Object.keys(res[0]).filter(key => key !== 'market' && key !== 'totalSGD')
: Object.keys(currencyMap);
// 3.
// 3. res0
markets.value = currencyKeys.map(currency => {
const total = res.reduce((sum, item) => sum + (Number(item[currency]) || 0), 0)
// keycurrencyMap
const lowerCurrency = currency.toLowerCase();
// res0
const total = res.length > 0
? res.reduce((sum, item) => sum + (Number(item[currency]) || 0), 0)
: 0;
return {
name: currencyMap[currency.toLowerCase()] || currency.toUpperCase(),
// 使res
name: currencyMap[lowerCurrency] || currency.toUpperCase(),
value: total
}
})
};
});
}

Loading…
Cancel
Save