feat(can): 다국적 통화 표기 지원
This commit is contained in:
@@ -39,17 +39,16 @@
|
|||||||
class="elevation-1"
|
class="elevation-1"
|
||||||
hide-default-footer
|
hide-default-footer
|
||||||
>
|
>
|
||||||
<template v-slot:item.price="{ item }">
|
<template v-slot:item.priceStr="{ item }">
|
||||||
<span v-if="item.currency === 'KRW'">₩ {{ item.price.toLocaleString('en-US') }}</span>
|
{{ formatMoney(item.price, item.currency) }}
|
||||||
<span v-else>$ {{ item.price.toLocaleString('en-US') }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:item.can="{ item }">
|
<template v-slot:item.can="{ item }">
|
||||||
{{ item.can.toLocaleString('en-US') }} 캔
|
{{ formatNumber(item.can) }} 캔
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:item.rewardCan="{ item }">
|
<template v-slot:item.rewardCan="{ item }">
|
||||||
{{ item.rewardCan.toLocaleString('en-US') }} 캔
|
{{ formatNumber(item.rewardCan) }} 캔
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:item.management="{ item }">
|
<template v-slot:item.management="{ item }">
|
||||||
@@ -142,7 +141,7 @@ export default {
|
|||||||
text: '가격(VAT포함)',
|
text: '가격(VAT포함)',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
value: 'price',
|
value: 'priceStr',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '충전캔',
|
text: '충전캔',
|
||||||
@@ -189,6 +188,22 @@ export default {
|
|||||||
this.selected_can = null
|
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() {
|
async getCans() {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user