code refactor

This commit is contained in:
MaysWind
2023-07-09 20:43:08 +08:00
parent 522ed94c32
commit dc127ea6a3
4 changed files with 28 additions and 17 deletions
+2 -14
View File
@@ -81,21 +81,9 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js'; import { useSettingsStore } from '@/stores/setting.js';
import colorConstants from '@/consts/color.js'; import colorConstants from '@/consts/color.js';
import statisticsConstants from '@/consts/statistics.js';
import { formatPercent } from '@/lib/common.js'; import { formatPercent } from '@/lib/common.js';
const defaultColors = [
'cc4a66',
'e3564a',
'fc892c',
'ffc349',
'4dd291',
'24ceb3',
'2ab4d0',
'065786',
'713670',
'8e1d51'
];
export default { export default {
props: [ props: [
'skeleton', 'skeleton',
@@ -153,7 +141,7 @@ export default {
percent: (item[this.percentField] > 0 || item[this.percentField] === 0 || item[this.percentField] === '0') ? item[this.percentField] : (item[this.valueField] / totalValidValue * 100), percent: (item[this.percentField] > 0 || item[this.percentField] === 0 || item[this.percentField] === '0') ? item[this.percentField] : (item[this.valueField] / totalValidValue * 100),
actualPercent: item[this.valueField] / totalValidValue, actualPercent: item[this.valueField] / totalValidValue,
currency: item[this.currencyField], currency: item[this.currencyField],
color: item[this.colorField] ? item[this.colorField] : defaultColors[validItems.length % defaultColors.length], color: item[this.colorField] ? item[this.colorField] : statisticsConstants.defaultChartColors[validItems.length % statisticsConstants.defaultChartColors.length],
sourceItem: item sourceItem: item
}; };
+20 -3
View File
@@ -47,20 +47,36 @@ const defaultChartDataType = allChartDataTypes.ExpenseByPrimaryCategory.type;
const allSortingTypes = { const allSortingTypes = {
Amount: { Amount: {
type: 0, type: 0,
name: 'Amount' name: 'Amount',
fullName: 'Sort by Amount'
}, },
DisplayOrder: { DisplayOrder: {
type: 1, type: 1,
name: 'Display Order' name: 'Display Order',
fullName: 'Sort by Display Order'
}, },
Name: { Name: {
type: 2, type: 2,
name: 'Name' name: 'Name',
fullName: 'Sort by Name'
} }
}; };
const defaultSortingType = allSortingTypes.Amount.type; const defaultSortingType = allSortingTypes.Amount.type;
const defaultChartColors = [
'cc4a66',
'e3564a',
'fc892c',
'ffc349',
'4dd291',
'24ceb3',
'2ab4d0',
'065786',
'713670',
'8e1d51'
];
export default { export default {
allChartTypes: allChartTypes, allChartTypes: allChartTypes,
defaultChartType: defaultChartType, defaultChartType: defaultChartType,
@@ -69,4 +85,5 @@ export default {
defaultDataRangeType: datetime.allDateRanges.ThisMonth.type, defaultDataRangeType: datetime.allDateRanges.ThisMonth.type,
allSortingTypes: allSortingTypes, allSortingTypes: allSortingTypes,
defaultSortingType: defaultSortingType, defaultSortingType: defaultSortingType,
defaultChartColors: defaultChartColors,
}; };
+3
View File
@@ -975,6 +975,9 @@ export default {
'Amount': 'Amount', 'Amount': 'Amount',
'Display Order': 'Display Order', 'Display Order': 'Display Order',
'Name': 'Name', 'Name': 'Name',
'Sort by Amount': 'Sort by Amount',
'Sort by Display Order': 'Sort by Display Order',
'Sort by Name': 'Sort by Name',
'Filter Accounts': 'Filter Accounts', 'Filter Accounts': 'Filter Accounts',
'Filter Transaction Categories': 'Filter Transaction Categories', 'Filter Transaction Categories': 'Filter Transaction Categories',
'User Settings': 'User Settings', 'User Settings': 'User Settings',
+3
View File
@@ -975,6 +975,9 @@ export default {
'Amount': '金额', 'Amount': '金额',
'Display Order': '显示顺序', 'Display Order': '显示顺序',
'Name': '名称', 'Name': '名称',
'Sort by Amount': '按金额排序',
'Sort by Display Order': '按显示顺序排序',
'Sort by Name': '按名称排序',
'Filter Accounts': '过滤账户', 'Filter Accounts': '过滤账户',
'Filter Transaction Categories': '过滤交易类型', 'Filter Transaction Categories': '过滤交易类型',
'User Settings': '用户设置', 'User Settings': '用户设置',