fix incorrect style when switch pages but some error occurs

This commit is contained in:
MaysWind
2021-03-05 01:27:32 +08:00
parent c74077fb13
commit b0cff71b24
16 changed files with 150 additions and 87 deletions
+10 -7
View File
@@ -1,5 +1,5 @@
<template>
<f7-page ptr @ptr:refresh="reload">
<f7-page ptr @ptr:refresh="reload" @page:afterin="onPageAfterIn">
<f7-navbar :title="$t('Transaction Categories')" :back-link="$t('Back')"></f7-navbar>
<f7-card class="skeleton-text" v-if="loading">
@@ -29,12 +29,12 @@
export default {
data() {
return {
loading: true
loading: true,
loadingError: null
};
},
created() {
const self = this;
const router = self.$f7router;
self.loading = true;
@@ -43,15 +43,18 @@ export default {
}).then(() => {
self.loading = false;
}).catch(error => {
self.logining = false;
if (!error.processed) {
if (error.processed) {
self.loading = false;
} else {
self.loadingError = error;
self.$toast(error.message || error);
router.back();
}
});
},
methods: {
onPageAfterIn() {
this.$routeBackOnError('loadingError');
},
reload(done) {
const self = this;
+11 -8
View File
@@ -1,5 +1,5 @@
<template>
<f7-page>
<f7-page @page:afterin="onPageAfterIn">
<f7-navbar>
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
<f7-nav-title :title="$t(title)"></f7-nav-title>
@@ -87,6 +87,7 @@ export default {
return {
editCategoryId: null,
loading: false,
loadingError: null,
category: {
type: parseInt(query.type),
name: '',
@@ -140,11 +141,10 @@ export default {
created() {
const self = this;
const query = self.$f7route.query;
const router = self.$f7router;
if (!query.id && !query.parentId) {
self.$toast('Parameter Invalid');
router.back();
self.loadingError = 'Parameter Invalid';
return;
}
@@ -166,11 +166,11 @@ export default {
self.loading = false;
}).catch(error => {
self.loading = false;
if (!error.processed) {
if (error.processed) {
self.loading = false;
} else {
self.loadingError = error;
self.$toast(error.message || error);
router.back();
}
});
} else if (query.parentId) {
@@ -180,7 +180,7 @@ export default {
categoryType !== this.$constants.category.allCategoryTypes.Expense &&
categoryType !== this.$constants.category.allCategoryTypes.Transfer) {
self.$toast('Parameter Invalid');
router.back();
self.loadingError = 'Parameter Invalid';
return;
}
@@ -191,6 +191,9 @@ export default {
this.autoChangeCommentTextareaSize();
},
methods: {
onPageAfterIn() {
this.$routeBackOnError('loadingError');
},
save() {
const self = this;
const router = self.$f7router;
+8 -6
View File
@@ -97,6 +97,7 @@ export default {
categoryType: 0,
categoryId: '',
loading: true,
loadingError: null,
showHidden: false,
sortable: false,
categoryToDelete: null,
@@ -166,7 +167,6 @@ export default {
created() {
const self = this;
const query = self.$f7route.query;
const router = self.$f7router;
self.categoryType = parseInt(query.type);
@@ -174,7 +174,7 @@ export default {
self.categoryType !== this.$constants.category.allCategoryTypes.Expense &&
self.categoryType !== this.$constants.category.allCategoryTypes.Transfer) {
self.$toast('Parameter Invalid');
router.back();
self.loadingError = 'Parameter Invalid';
return;
}
@@ -193,11 +193,11 @@ export default {
}).then(() => {
self.loading = false;
}).catch(error => {
self.logining = false;
if (!error.processed) {
if (error.processed) {
self.loading = false;
} else {
self.loadingError = error;
self.$toast(error.message || error);
router.back();
}
});
},
@@ -206,6 +206,8 @@ export default {
if (this.$store.state.transactionCategoryListStateInvalid && !this.loading) {
this.reload(null);
}
this.$routeBackOnError('loadingError');
},
reload(done) {
if (this.sortable) {
+6 -3
View File
@@ -1,5 +1,5 @@
<template>
<f7-page>
<f7-page @page:afterin="onPageAfterIn">
<f7-navbar>
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
<f7-nav-title :title="$t('Default Categories')"></f7-nav-title>
@@ -67,6 +67,7 @@ export default {
const self = this;
return {
loadingError: null,
currentLocale: self.$i18n.locale,
categoryType: 0,
allCategories: [],
@@ -83,7 +84,6 @@ export default {
created() {
const self = this;
const query = self.$f7route.query;
const router = self.$f7router;
self.categoryType = parseInt(query.type);
@@ -92,7 +92,7 @@ export default {
self.categoryType !== this.$constants.category.allCategoryTypes.Expense &&
self.categoryType !== this.$constants.category.allCategoryTypes.Transfer) {
self.$toast('Parameter Invalid');
router.back();
self.loadingError = 'Parameter Invalid';
return;
}
@@ -111,6 +111,9 @@ export default {
}
},
methods: {
onPageAfterIn() {
this.$routeBackOnError('loadingError');
},
getDefaultCategories(categoryType) {
switch (categoryType) {
case this.$constants.category.allCategoryTypes.Income: