code refactor

This commit is contained in:
MaysWind
2023-08-13 22:58:52 +08:00
parent 3d086992dc
commit 399936e3ab
+6 -10
View File
@@ -23,9 +23,8 @@
@click="showAccountCategorySheet = true" @click="showAccountCategorySheet = true"
> >
<list-item-selection-sheet value-type="item" <list-item-selection-sheet value-type="item"
key-field="id" value-field="id" title-field="name" key-field="id" value-field="id" title-field="displayName"
icon-field="defaultAccountIconId" icon-type="account" icon-field="defaultAccountIconId" icon-type="account"
:title-i18n="true"
:items="allAccountCategories" :items="allAccountCategories"
v-model:show="showAccountCategorySheet" v-model:show="showAccountCategorySheet"
v-model="account.category"> v-model="account.category">
@@ -41,9 +40,8 @@
@click="showAccountTypeSheet = true" @click="showAccountTypeSheet = true"
> >
<list-item-selection-sheet value-type="item" <list-item-selection-sheet value-type="item"
key-field="id" value-field="id" title-field="name" key-field="id" value-field="id" title-field="displayName"
:items="allAccountTypesArray" :items="allAccountTypesArray"
:title-i18n="true"
v-model:show="showAccountTypeSheet" v-model:show="showAccountTypeSheet"
v-model="account.type"> v-model="account.type">
</list-item-selection-sheet> </list-item-selection-sheet>
@@ -481,10 +479,10 @@ export default {
return accountConstants.allAccountTypes; return accountConstants.allAccountTypes;
}, },
allAccountCategories() { allAccountCategories() {
return accountConstants.allCategories; return this.$locale.getAllAccountCategories();
}, },
allAccountTypesArray() { allAccountTypesArray() {
return accountConstants.allAccountTypesArray; return this.$locale.getAllAccountTypes();
}, },
allAccountIcons() { allAccountIcons() {
return iconConstants.allAccountIcons; return iconConstants.allAccountIcons;
@@ -642,12 +640,10 @@ export default {
return this.$locale.getCurrencyName(currencyCode); return this.$locale.getCurrencyName(currencyCode);
}, },
getAccountTypeName(accountType) { getAccountTypeName(accountType) {
const typeName = getNameByKeyValue(this.allAccountTypesArray, accountType, 'id', 'name'); return getNameByKeyValue(this.allAccountTypesArray, accountType, 'id', 'displayName');
return this.$t(typeName);
}, },
getAccountCategoryName(accountCategory) { getAccountCategoryName(accountCategory) {
const categoryName = getNameByKeyValue(this.allAccountCategories, accountCategory, 'id', 'name'); return getNameByKeyValue(this.allAccountCategories, accountCategory, 'id', 'displayName');
return this.$t(categoryName);
}, },
getAccountBalance(account) { getAccountBalance(account) {
return this.getDisplayCurrency(account.balance, account.currency); return this.getDisplayCurrency(account.balance, account.currency);