feat(can): 다국적 통화 표기 지원
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user