mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
code refactor
This commit is contained in:
@@ -63,6 +63,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
|
||||
import { isString, appendThousandsSeparator } from '@/lib/common.js';
|
||||
import { numericCurrencyToString, stringCurrencyToNumeric } from '@/lib/currency.js';
|
||||
|
||||
@@ -87,9 +90,13 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useSettingsStore),
|
||||
isEnableThousandsSeparator() {
|
||||
return this.settingsStore.appSettings.thousandsSeparator;
|
||||
},
|
||||
currentDisplay() {
|
||||
const previousValue = appendThousandsSeparator(this.previousValue);
|
||||
const currentValue = appendThousandsSeparator(this.currentValue);
|
||||
const previousValue = appendThousandsSeparator(this.previousValue, this.isEnableThousandsSeparator);
|
||||
const currentValue = appendThousandsSeparator(this.currentValue, this.isEnableThousandsSeparator);
|
||||
|
||||
if (this.currentSymbol) {
|
||||
return `${previousValue} ${this.currentSymbol} ${currentValue}`;
|
||||
@@ -118,7 +125,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getStringValue(value) {
|
||||
let str = numericCurrencyToString(value);
|
||||
let str = numericCurrencyToString(value, this.isEnableThousandsSeparator);
|
||||
|
||||
if (str.indexOf(',')) {
|
||||
str = str.replaceAll(/,/g, '');
|
||||
|
||||
@@ -77,6 +77,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { formatPercent } from '@/lib/common.js';
|
||||
|
||||
@@ -124,6 +127,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useSettingsStore),
|
||||
validItems: function () {
|
||||
let totalValidValue = 0;
|
||||
|
||||
@@ -154,7 +158,7 @@ export default {
|
||||
};
|
||||
|
||||
finalItem.displayPercent = formatPercent(finalItem.percent, 2, '<0.01');
|
||||
finalItem.displayValue = this.$locale.getDisplayCurrency(finalItem.value, (finalItem.currency || this.defaultCurrency));
|
||||
finalItem.displayValue = this.getDisplayCurrency(finalItem.value, (finalItem.currency || this.defaultCurrency));
|
||||
|
||||
validItems.push(finalItem);
|
||||
}
|
||||
@@ -281,6 +285,12 @@ export default {
|
||||
|
||||
const allPreviousLength = allPreviousPercent * this.circumference;
|
||||
return this.circumference - allPreviousLength + offset;
|
||||
},
|
||||
getDisplayCurrency(value, currencyCode) {
|
||||
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||
enableThousandsSeparator: this.settingsStore.appSettings.thousandsSeparator
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user