feat(can): 다국적 통화 표기 지원

This commit is contained in:
Yu Sung
2025-10-02 17:50:39 +09:00
parent 379e5b67f3
commit b5dbccf515

View File

@@ -39,17 +39,16 @@
class="elevation-1"
hide-default-footer
>
<template v-slot:item.price="{ item }">
<span v-if="item.currency === 'KRW'"> {{ item.price.toLocaleString('en-US') }}</span>
<span v-else>$ {{ item.price.toLocaleString('en-US') }}</span>
<template v-slot:item.priceStr="{ item }">
{{ formatMoney(item.price, item.currency) }}
</template>
<template v-slot:item.can="{ item }">
{{ item.can.toLocaleString('en-US') }}
{{ formatNumber(item.can) }}
</template>
<template v-slot:item.rewardCan="{ item }">
{{ item.rewardCan.toLocaleString('en-US') }}
{{ formatNumber(item.rewardCan) }}
</template>
<template v-slot:item.management="{ item }">
@@ -142,7 +141,7 @@ export default {
text: '가격(VAT포함)',
align: 'center',
sortable: false,
value: 'price',
value: 'priceStr',
},
{
text: '충전캔',
@@ -189,6 +188,22 @@ export default {
this.selected_can = null
},
formatMoney(priceStr, currencyCode, locale = navigator.language) {
const price = Number(priceStr);
const formatted = new Intl.NumberFormat(locale, {
style: 'currency',
currency: currencyCode
}).format(price);
return formatted.replace(/([^\d\s])(\d)/, '$1 $2');
},
formatNumber(num) {
return new Intl.NumberFormat(navigator.language, {
style: 'decimal'
}).format(num);
},
async getCans() {
this.isLoading = true
try {