support displaying data in percentage format

This commit is contained in:
MaysWind
2026-04-15 22:21:42 +08:00
parent 50472d437a
commit c64c60c6a0
4 changed files with 38 additions and 3 deletions
+7 -1
View File
@@ -34,6 +34,7 @@ const props = defineProps<{
translateName?: boolean;
valueTypeName: string;
amountValue?: boolean;
percentValue?: boolean;
defaultCurrency?: string;
}>();
@@ -43,7 +44,8 @@ const {
tt,
getCurrentLanguageTextDirection,
formatAmountToLocalizedNumeralsWithCurrency,
formatNumberToLocalizedNumerals
formatNumberToLocalizedNumerals,
formatPercentToLocalizedNumerals
} = useI18n();
const textDirection = computed<TextDirection>(() => getCurrentLanguageTextDirection());
@@ -249,6 +251,10 @@ function getItemName(name: string): string {
}
function getDisplayValue(value: number): string {
if (props.percentValue) {
return formatPercentToLocalizedNumerals(value, 2, '<0.01');
}
if (props.amountValue) {
return formatAmountToLocalizedNumeralsWithCurrency(value, props.defaultCurrency);
}