This commit is contained in:
MaysWind
2020-12-20 17:56:55 +08:00
parent 4e0ef42278
commit 23a17d5f67
3 changed files with 31 additions and 29 deletions
+17 -17
View File
@@ -12,7 +12,7 @@
<f7-card v-for="categoryInfo in allCategories" :key="categoryInfo.type">
<f7-card-header>
<small :style="{ opacity: 0.6 }">
<span>{{ categoryInfo.type | categoryTypeName | t }}</span>
<span>{{ categoryInfo.type | categoryTypeName($constants.category.allCategoryTypes) | t }}</span>
</small>
</f7-card-header>
<f7-card-content class="no-safe-areas" :padding="false">
@@ -68,7 +68,7 @@ export default {
return {
currentLocale: self.$i18n.locale,
categoryType: '',
categoryType: 0,
allCategories: [],
submitting: false,
showMoreActionSheet: false,
@@ -85,22 +85,22 @@ export default {
const query = self.$f7route.query;
const router = self.$f7router;
if (query.type !== '0' &&
query.type !== this.$constants.category.allCategoryTypes.Income &&
query.type !== this.$constants.category.allCategoryTypes.Expense &&
query.type !== this.$constants.category.allCategoryTypes.Transfer) {
self.categoryType = parseInt(query.type);
if (self.categoryType !== 0 &&
self.categoryType !== this.$constants.category.allCategoryTypes.Income &&
self.categoryType !== this.$constants.category.allCategoryTypes.Expense &&
self.categoryType !== this.$constants.category.allCategoryTypes.Transfer) {
self.$toast('Parameter Invalid');
router.back();
return;
}
self.categoryType = query.type;
if (query.type === '0') {
if (self.categoryType === 0) {
for (let i = 1; i <= 3; i++) {
self.allCategories.push({
type: i.toString(),
categories: self.$utilities.copyArrayTo(self.getDefaultCategories(i.toString()), [])
type: i,
categories: self.$utilities.copyArrayTo(self.getDefaultCategories(i), [])
});
}
} else {
@@ -139,7 +139,7 @@ export default {
const category = categoryInfo.categories[j];
const submitCategory = {
name: self.$t('category.' + category.name, self.currentLocale),
type: parseInt(categoryInfo.type),
type: categoryInfo.type,
icon: category.categoryIconId,
color: category.color,
subCategories: []
@@ -149,7 +149,7 @@ export default {
const subCategory = category.subCategories[k];
submitCategory.subCategories.push({
name: self.$t('category.' + subCategory.name, self.currentLocale),
type: parseInt(categoryInfo.type),
type: categoryInfo.type,
icon: subCategory.categoryIconId,
color: subCategory.color
});
@@ -188,13 +188,13 @@ export default {
}
},
filters: {
categoryTypeName(categoryType) {
categoryTypeName(categoryType, allCategoryTypes) {
switch (categoryType) {
case this.$constants.category.allCategoryTypes.Income:
case allCategoryTypes.Income:
return 'Income Categories';
case this.$constants.category.allCategoryTypes.Expense:
case allCategoryTypes.Expense:
return 'Expense Categories';
case this.$constants.category.allCategoryTypes.Transfer:
case allCategoryTypes.Transfer:
return 'Transfer Categories';
default:
return 'Transaction Categories';
+8 -6
View File
@@ -81,7 +81,7 @@ export default {
editCategoryId: null,
loading: false,
category: {
type: query.type,
type: parseInt(query.type),
name: '',
parentId: query.parentId,
icon: self.$constants.icons.defaultCategoryIconId,
@@ -158,7 +158,7 @@ export default {
const category = data.result;
self.category.id = category.id;
self.category.type = category.type.toString();
self.category.type = category.type;
self.category.parentId = category.type.parentId;
self.category.name = category.name;
self.category.icon = category.icon;
@@ -179,9 +179,11 @@ export default {
}
});
} else if (query.parentId) {
if (query.type !== this.$constants.category.allCategoryTypes.Income &&
query.type !== this.$constants.category.allCategoryTypes.Expense &&
query.type !== this.$constants.category.allCategoryTypes.Transfer) {
const categoryType = parseInt(query.type);
if (categoryType !== this.$constants.category.allCategoryTypes.Income &&
categoryType !== this.$constants.category.allCategoryTypes.Expense &&
categoryType !== this.$constants.category.allCategoryTypes.Transfer) {
self.$toast('Parameter Invalid');
router.back();
return;
@@ -206,7 +208,7 @@ export default {
self.$showLoading(() => self.submitting);
const submitCategory = {
type: parseInt(self.category.type),
type: self.category.type,
name: self.category.name,
parentId: self.category.parentId,
icon: self.category.icon,
+6 -6
View File
@@ -88,7 +88,7 @@ export default {
return {
categories: [],
hasSubCategories: false,
categoryType: '',
categoryType: 0,
categoryId: '',
loading: true,
showHidden: false,
@@ -145,16 +145,16 @@ export default {
const query = self.$f7route.query;
const router = self.$f7router;
if (query.type !== this.$constants.category.allCategoryTypes.Income &&
query.type !== this.$constants.category.allCategoryTypes.Expense &&
query.type !== this.$constants.category.allCategoryTypes.Transfer) {
self.categoryType = parseInt(query.type);
if (self.categoryType !== this.$constants.category.allCategoryTypes.Income &&
self.categoryType !== this.$constants.category.allCategoryTypes.Expense &&
self.categoryType !== this.$constants.category.allCategoryTypes.Transfer) {
self.$toast('Parameter Invalid');
router.back();
return;
}
self.categoryType = query.type;
if (query.id && query.id !== '0') {
self.categoryId = query.id;
self.hasSubCategories = false;