mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
code refactor
This commit is contained in:
@@ -115,6 +115,7 @@
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useAccountsStore } from '@/stores/account.js';
|
||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
|
||||
@@ -140,7 +141,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useAccountsStore, useStatisticsStore),
|
||||
...mapStores(useSettingsStore, useAccountsStore, useStatisticsStore),
|
||||
title() {
|
||||
if (this.modifyDefault) {
|
||||
return 'Default Account Filter';
|
||||
@@ -188,7 +189,7 @@ export default {
|
||||
}
|
||||
|
||||
if (self.modifyDefault) {
|
||||
self.filterAccountIds = copyObjectTo(self.$settings.getStatisticsDefaultAccountFilter(), allAccountIds);
|
||||
self.filterAccountIds = copyObjectTo(self.settingsStore.appSettings.statistics.defaultAccountFilter, allAccountIds);
|
||||
} else {
|
||||
self.filterAccountIds = copyObjectTo(self.statisticsStore.transactionStatisticsFilter.filterAccountIds, allAccountIds);
|
||||
}
|
||||
@@ -222,7 +223,7 @@ export default {
|
||||
}
|
||||
|
||||
if (self.modifyDefault) {
|
||||
self.$settings.setStatisticsDefaultAccountFilter(filteredAccountIds);
|
||||
self.settingsStore.setStatisticsDefaultAccountFilter(filteredAccountIds);
|
||||
} else {
|
||||
self.statisticsStore.updateTransactionStatisticsFilter({
|
||||
filterAccountIds: filteredAccountIds
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
|
||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
|
||||
@@ -149,7 +150,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useTransactionCategoriesStore, useStatisticsStore),
|
||||
...mapStores(useSettingsStore, useTransactionCategoriesStore, useStatisticsStore),
|
||||
|
||||
title() {
|
||||
if (this.modifyDefault) {
|
||||
@@ -221,7 +222,7 @@ export default {
|
||||
}
|
||||
|
||||
if (self.modifyDefault) {
|
||||
self.filterCategoryIds = copyObjectTo(self.$settings.getStatisticsDefaultTransactionCategoryFilter(), allCategoryIds);
|
||||
self.filterCategoryIds = copyObjectTo(self.settingsStore.appSettings.statistics.defaultTransactionCategoryFilter, allCategoryIds);
|
||||
} else {
|
||||
self.filterCategoryIds = copyObjectTo(self.statisticsStore.transactionStatisticsFilter.filterCategoryIds, allCategoryIds);
|
||||
}
|
||||
@@ -255,7 +256,7 @@ export default {
|
||||
}
|
||||
|
||||
if (self.modifyDefault) {
|
||||
self.$settings.setStatisticsDefaultTransactionCategoryFilter(filteredCategoryIds);
|
||||
self.settingsStore.setStatisticsDefaultTransactionCategoryFilter(filteredCategoryIds);
|
||||
} else {
|
||||
self.statisticsStore.updateTransactionStatisticsFilter({
|
||||
filterCategoryIds: filteredCategoryIds
|
||||
|
||||
@@ -50,11 +50,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
|
||||
import datetimeConstants from '@/consts/datetime.js';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapStores(useSettingsStore),
|
||||
allChartTypes() {
|
||||
return statisticsConstants.allChartTypes;
|
||||
},
|
||||
@@ -83,34 +87,34 @@ export default {
|
||||
},
|
||||
defaultChartType: {
|
||||
get: function () {
|
||||
return this.$settings.getStatisticsDefaultChartType();
|
||||
return this.settingsStore.appSettings.statistics.defaultChartType;
|
||||
},
|
||||
set: function (value) {
|
||||
this.$settings.setStatisticsDefaultChartType(value);
|
||||
this.settingsStore.setStatisticsDefaultChartType(value);
|
||||
}
|
||||
},
|
||||
defaultChartDataType: {
|
||||
get: function () {
|
||||
return this.$settings.getStatisticsDefaultChartDataType();
|
||||
return this.settingsStore.appSettings.statistics.defaultChartDataType;
|
||||
},
|
||||
set: function (value) {
|
||||
this.$settings.setStatisticsDefaultChartDataType(value);
|
||||
this.settingsStore.setStatisticsDefaultChartDataType(value);
|
||||
}
|
||||
},
|
||||
defaultDateRange: {
|
||||
get: function () {
|
||||
return this.$settings.getStatisticsDefaultDateRange();
|
||||
return this.settingsStore.appSettings.statistics.defaultDataRangeType;
|
||||
},
|
||||
set: function (value) {
|
||||
this.$settings.setStatisticsDefaultDateRange(value);
|
||||
this.settingsStore.setStatisticsDefaultDateRange(value);
|
||||
}
|
||||
},
|
||||
defaultSortingType: {
|
||||
get: function () {
|
||||
return this.$settings.getStatisticsSortingType();
|
||||
return this.settingsStore.appSettings.statistics.defaultSortingType;
|
||||
},
|
||||
set: function (value) {
|
||||
this.$settings.setStatisticsSortingType(value);
|
||||
this.settingsStore.setStatisticsSortingType(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +251,7 @@
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
import { useAccountsStore } from '@/stores/account.js';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
|
||||
@@ -273,12 +274,9 @@ export default {
|
||||
'f7router'
|
||||
],
|
||||
data() {
|
||||
const self = this;
|
||||
|
||||
return {
|
||||
loading: true,
|
||||
loadingError: null,
|
||||
showAccountBalance: self.$settings.isShowAccountBalance(),
|
||||
showChartDataTypePopover: false,
|
||||
showSortingTypePopover: false,
|
||||
showDatePopover: false,
|
||||
@@ -287,7 +285,7 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useUserStore, useAccountsStore, useTransactionCategoriesStore, useStatisticsStore),
|
||||
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useStatisticsStore),
|
||||
defaultCurrency() {
|
||||
return this.userStore.currentUserDefaultCurrency;
|
||||
},
|
||||
@@ -323,6 +321,9 @@ export default {
|
||||
allDateRanges() {
|
||||
return datetimeConstants.allDateRanges;
|
||||
},
|
||||
showAccountBalance() {
|
||||
return this.settingsStore.appSettings.showAccountBalance;
|
||||
},
|
||||
totalAmountName() {
|
||||
if (this.query.chartDataType === this.allChartDataTypes.IncomeByAccount.type
|
||||
|| this.query.chartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type
|
||||
@@ -431,25 +432,25 @@ export default {
|
||||
created() {
|
||||
const self = this;
|
||||
|
||||
let defaultChartType = self.$settings.getStatisticsDefaultChartType();
|
||||
let defaultChartType = self.settingsStore.appSettings.statistics.defaultChartType;
|
||||
|
||||
if (defaultChartType !== self.allChartTypes.Pie && defaultChartType !== self.allChartTypes.Bar) {
|
||||
defaultChartType = statisticsConstants.defaultChartType;
|
||||
}
|
||||
|
||||
let defaultChartDataType = self.$settings.getStatisticsDefaultChartDataType();
|
||||
let defaultChartDataType = self.settingsStore.appSettings.statistics.defaultChartDataType;
|
||||
|
||||
if (defaultChartDataType < self.allChartDataTypes.ExpenseByAccount.type || defaultChartDataType > self.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
defaultChartDataType = statisticsConstants.defaultChartDataType;
|
||||
}
|
||||
|
||||
let defaultDateRange = self.$settings.getStatisticsDefaultDateRange();
|
||||
let defaultDateRange = self.settingsStore.appSettings.statistics.defaultDataRangeType;
|
||||
|
||||
if (defaultDateRange < self.allDateRanges.All.type || defaultDateRange >= self.allDateRanges.Custom.type) {
|
||||
defaultDateRange = statisticsConstants.defaultDataRangeType;
|
||||
}
|
||||
|
||||
let defaultSortType = self.$settings.getStatisticsSortingType();
|
||||
let defaultSortType = self.settingsStore.appSettings.statistics.defaultSortingType;
|
||||
|
||||
if (defaultSortType < self.allSortingTypes.Amount.type || defaultSortType > self.allSortingTypes.Name.type) {
|
||||
defaultSortType = statisticsConstants.defaultSortingType;
|
||||
@@ -463,8 +464,8 @@ export default {
|
||||
endTime: dateRange ? dateRange.maxTime : undefined,
|
||||
chartType: defaultChartType,
|
||||
chartDataType: defaultChartDataType,
|
||||
filterAccountIds: self.$settings.getStatisticsDefaultAccountFilter() || {},
|
||||
filterCategoryIds: self.$settings.getStatisticsDefaultTransactionCategoryFilter() || {},
|
||||
filterAccountIds: self.settingsStore.appSettings.statistics.defaultAccountFilter || {},
|
||||
filterCategoryIds: self.settingsStore.appSettings.statistics.defaultTransactionCategoryFilter || {},
|
||||
sortingType: defaultSortType,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user