mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 16:07:33 +08:00
support changing default account/transaction category filter in statistics page
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<f7-page>
|
||||
<f7-navbar>
|
||||
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
||||
<f7-nav-title :title="$t('Filter Accounts')"></f7-nav-title>
|
||||
<f7-nav-title :title="$t(title)"></f7-nav-title>
|
||||
<f7-nav-right>
|
||||
<f7-link icon-f7="ellipsis" @click="showMoreActionSheet = true"></f7-link>
|
||||
<f7-link :text="$t('Save')" @click="save"></f7-link>
|
||||
@@ -104,11 +104,19 @@ export default {
|
||||
data: function () {
|
||||
return {
|
||||
loading: true,
|
||||
modifyDefault: false,
|
||||
filterAccountIds: {},
|
||||
showMoreActionSheet: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
if (this.modifyDefault) {
|
||||
return 'Default Account Filter';
|
||||
} else {
|
||||
return 'Filter Accounts';
|
||||
}
|
||||
},
|
||||
allAccountCategories() {
|
||||
return this.$constants.account.allCategories;
|
||||
},
|
||||
@@ -118,8 +126,11 @@ export default {
|
||||
},
|
||||
created() {
|
||||
const self = this;
|
||||
const query = self.$f7route.query;
|
||||
const router = self.$f7router;
|
||||
|
||||
self.modifyDefault = !!query.modifyDefault;
|
||||
|
||||
self.$store.dispatch('loadAllAccounts', {
|
||||
force: false
|
||||
}).then(() => {
|
||||
@@ -136,7 +147,11 @@ export default {
|
||||
allAccountIds[account.id] = false;
|
||||
}
|
||||
|
||||
self.filterAccountIds = self.$utilities.copyObjectTo(self.$store.state.transactionStatisticsFilter.filterAccountIds, allAccountIds)
|
||||
if (self.modifyDefault) {
|
||||
self.filterAccountIds = self.$utilities.copyObjectTo(self.$settings.getStatisticsDefaultAccountFilter(), allAccountIds);
|
||||
} else {
|
||||
self.filterAccountIds = self.$utilities.copyObjectTo(self.$store.state.transactionStatisticsFilter.filterAccountIds, allAccountIds);
|
||||
}
|
||||
}).catch(error => {
|
||||
self.logining = false;
|
||||
|
||||
@@ -163,9 +178,13 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
self.$store.dispatch('updateTransactionStatisticsFilter', {
|
||||
filterAccountIds: filteredAccountIds
|
||||
});
|
||||
if (self.modifyDefault) {
|
||||
self.$settings.setStatisticsDefaultAccountFilter(filteredAccountIds);
|
||||
} else {
|
||||
self.$store.dispatch('updateTransactionStatisticsFilter', {
|
||||
filterAccountIds: filteredAccountIds
|
||||
});
|
||||
}
|
||||
|
||||
router.back();
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<f7-page>
|
||||
<f7-navbar>
|
||||
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
||||
<f7-nav-title :title="$t('Filter Transaction Categories')"></f7-nav-title>
|
||||
<f7-nav-title :title="$t(title)"></f7-nav-title>
|
||||
<f7-nav-right>
|
||||
<f7-link icon-f7="ellipsis" @click="showMoreActionSheet = true"></f7-link>
|
||||
<f7-link :text="$t('Save')" @click="save"></f7-link>
|
||||
@@ -109,19 +109,30 @@ export default {
|
||||
data: function () {
|
||||
return {
|
||||
loading: true,
|
||||
modifyDefault: false,
|
||||
filterCategoryIds: {},
|
||||
showMoreActionSheet: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
if (this.modifyDefault) {
|
||||
return 'Default Transaction Category Filter';
|
||||
} else {
|
||||
return 'Filter Transaction Categories';
|
||||
}
|
||||
},
|
||||
allTransactionCategories: function () {
|
||||
return this.$store.state.allTransactionCategories;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const self = this;
|
||||
const query = self.$f7route.query;
|
||||
const router = self.$f7router;
|
||||
|
||||
self.modifyDefault = !!query.modifyDefault;
|
||||
|
||||
self.$store.dispatch('loadAllCategories', {
|
||||
force: false
|
||||
}).then(() => {
|
||||
@@ -138,7 +149,11 @@ export default {
|
||||
allCategoryIds[category.id] = false;
|
||||
}
|
||||
|
||||
self.filterCategoryIds = self.$utilities.copyObjectTo(self.$store.state.transactionStatisticsFilter.filterCategoryIds, allCategoryIds)
|
||||
if (self.modifyDefault) {
|
||||
self.filterCategoryIds = self.$utilities.copyObjectTo(self.$settings.getStatisticsDefaultTransactionCategoryFilter(), allCategoryIds);
|
||||
} else {
|
||||
self.filterCategoryIds = self.$utilities.copyObjectTo(self.$store.state.transactionStatisticsFilter.filterCategoryIds, allCategoryIds);
|
||||
}
|
||||
}).catch(error => {
|
||||
self.logining = false;
|
||||
|
||||
@@ -165,9 +180,13 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
self.$store.dispatch('updateTransactionStatisticsFilter', {
|
||||
filterCategoryIds: filteredCategoryIds
|
||||
});
|
||||
if (self.modifyDefault) {
|
||||
self.$settings.setStatisticsDefaultTransactionCategoryFilter(filteredCategoryIds);
|
||||
} else {
|
||||
self.$store.dispatch('updateTransactionStatisticsFilter', {
|
||||
filterCategoryIds: filteredCategoryIds
|
||||
});
|
||||
}
|
||||
|
||||
router.back();
|
||||
},
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
</select>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item :title="$t('Default Account Filter')" link="/statistic/filter/account?modifyDefault=1"></f7-list-item>
|
||||
|
||||
<f7-list-item :title="$t('Default Transaction Category Filter')" link="/statistic/filter/category?modifyDefault=1"></f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
:title="$t('Sort By')"
|
||||
smart-select :smart-select-params="{ openIn: 'sheet', closeOnSelect: true, sheetCloseLinkText: $t('Done'), scrollToSelectedItem: true }">
|
||||
|
||||
@@ -401,6 +401,8 @@ export default {
|
||||
endTime: dateRange ? dateRange.maxTime : undefined,
|
||||
chartType: defaultChartType,
|
||||
chartDataType: defaultChartDataType,
|
||||
filterAccountIds: self.$settings.getStatisticsDefaultAccountFilter() || {},
|
||||
filterCategoryIds: self.$settings.getStatisticsDefaultTransactionCategoryFilter() || {},
|
||||
});
|
||||
|
||||
Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user