mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 09:44:26 +08:00
code refactor
This commit is contained in:
@@ -62,6 +62,12 @@ const allSortingTypes = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const allSortingTypesArray = [
|
||||||
|
allSortingTypes.Amount,
|
||||||
|
allSortingTypes.DisplayOrder,
|
||||||
|
allSortingTypes.Name
|
||||||
|
]
|
||||||
|
|
||||||
const defaultSortingType = allSortingTypes.Amount.type;
|
const defaultSortingType = allSortingTypes.Amount.type;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -71,5 +77,6 @@ export default {
|
|||||||
defaultChartDataType: defaultChartDataType,
|
defaultChartDataType: defaultChartDataType,
|
||||||
defaultDataRangeType: datetime.allDateRanges.ThisMonth.type,
|
defaultDataRangeType: datetime.allDateRanges.ThisMonth.type,
|
||||||
allSortingTypes: allSortingTypes,
|
allSortingTypes: allSortingTypes,
|
||||||
|
allSortingTypesArray: allSortingTypesArray,
|
||||||
defaultSortingType: defaultSortingType,
|
defaultSortingType: defaultSortingType,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -996,6 +996,7 @@ export default {
|
|||||||
'Amount value exceeds limitation': 'Amount value exceeds limitation',
|
'Amount value exceeds limitation': 'Amount value exceeds limitation',
|
||||||
'Unable to delete this transaction': 'Unable to delete this transaction',
|
'Unable to delete this transaction': 'Unable to delete this transaction',
|
||||||
'Unable to get transaction statistics': 'Unable to get transaction statistics',
|
'Unable to get transaction statistics': 'Unable to get transaction statistics',
|
||||||
|
'Categorical Analysis': 'Categorical Analysis',
|
||||||
'Total Amount': 'Total Amount',
|
'Total Amount': 'Total Amount',
|
||||||
'Total Assets': 'Total Assets',
|
'Total Assets': 'Total Assets',
|
||||||
'Total Liabilities': 'Total Liabilities',
|
'Total Liabilities': 'Total Liabilities',
|
||||||
|
|||||||
@@ -996,6 +996,7 @@ export default {
|
|||||||
'Amount value exceeds limitation': '金额数值超出限制',
|
'Amount value exceeds limitation': '金额数值超出限制',
|
||||||
'Unable to delete this transaction': '无法删除该交易',
|
'Unable to delete this transaction': '无法删除该交易',
|
||||||
'Unable to get transaction statistics': '无法获取交易统计数据',
|
'Unable to get transaction statistics': '无法获取交易统计数据',
|
||||||
|
'Categorical Analysis': '分类分析',
|
||||||
'Total Amount': '总金额',
|
'Total Amount': '总金额',
|
||||||
'Total Assets': '总资产',
|
'Total Assets': '总资产',
|
||||||
'Total Liabilities': '总负债',
|
'Total Liabilities': '总负债',
|
||||||
|
|||||||
@@ -6,13 +6,53 @@
|
|||||||
<v-navigation-drawer :permanent="alwaysShowNav" v-model="showNav">
|
<v-navigation-drawer :permanent="alwaysShowNav" v-model="showNav">
|
||||||
<div class="mx-6 my-4">
|
<div class="mx-6 my-4">
|
||||||
<btn-vertical-group :disabled="loading" :buttons="[
|
<btn-vertical-group :disabled="loading" :buttons="[
|
||||||
{ name: $t('Pie Chart'), value: allChartTypes.Pie },
|
{ name: $t('Categorical Analysis'), value: 'categoricalAnalysis' },
|
||||||
{ name: $t('Bar Chart'), value: allChartTypes.Bar }
|
]" v-model="activeTab" />
|
||||||
]" v-model="query.chartType" @update:model-value="setChartType" />
|
|
||||||
</div>
|
</div>
|
||||||
<v-divider />
|
<v-divider />
|
||||||
|
<div class="mx-6 mt-4" v-if="activeTab === 'categoricalAnalysis'">
|
||||||
|
<small>{{ $t('Chart Type') }}</small>
|
||||||
|
<v-select
|
||||||
|
item-title="name"
|
||||||
|
item-value="type"
|
||||||
|
class="mt-2"
|
||||||
|
density="compact"
|
||||||
|
:disabled="loading"
|
||||||
|
:items="allChartTypesArray"
|
||||||
|
v-model="queryChartType"
|
||||||
|
>
|
||||||
|
<template #selection="{ item }">
|
||||||
|
<span class="cursor-pointer">{{ $t(item.title) }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item="{ props, item }">
|
||||||
|
<v-list-item v-bind="props" :title="$t(item.title)"></v-list-item>
|
||||||
|
</template>
|
||||||
|
</v-select>
|
||||||
|
</div>
|
||||||
|
<div class="mx-6 mt-4" v-if="activeTab === 'categoricalAnalysis'">
|
||||||
|
<small>{{ $t('Sort By') }}</small>
|
||||||
|
<v-select
|
||||||
|
item-title="name"
|
||||||
|
item-value="type"
|
||||||
|
class="mt-2"
|
||||||
|
density="compact"
|
||||||
|
:disabled="loading"
|
||||||
|
:items="allSortingTypesArray"
|
||||||
|
v-model="querySortingType"
|
||||||
|
>
|
||||||
|
<template #selection="{ item }">
|
||||||
|
<span class="cursor-pointer">{{ $t(item.title) }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item="{ props, item }">
|
||||||
|
<v-list-item v-bind="props" :title="$t(item.title)"></v-list-item>
|
||||||
|
</template>
|
||||||
|
</v-select>
|
||||||
|
</div>
|
||||||
<v-tabs show-arrows class="my-4" direction="vertical"
|
<v-tabs show-arrows class="my-4" direction="vertical"
|
||||||
:disabled="loading" v-model="query.chartDataType">
|
:disabled="loading" v-model="query.chartDataType"
|
||||||
|
v-if="activeTab === 'categoricalAnalysis'">
|
||||||
<v-tab class="tab-text-truncate" :key="dataType.type" :value="dataType.type"
|
<v-tab class="tab-text-truncate" :key="dataType.type" :value="dataType.type"
|
||||||
v-for="dataType in allChartDataTypes">
|
v-for="dataType in allChartDataTypes">
|
||||||
<span class="text-truncate">{{ $t(dataType.name) }}</span>
|
<span class="text-truncate">{{ $t(dataType.name) }}</span>
|
||||||
@@ -22,7 +62,7 @@
|
|||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
<v-main>
|
<v-main>
|
||||||
<v-window class="d-flex flex-grow-1 disable-tab-transition w-100-window-container" v-model="activeTab">
|
<v-window class="d-flex flex-grow-1 disable-tab-transition w-100-window-container" v-model="activeTab">
|
||||||
<v-window-item value="statisticsPage">
|
<v-window-item value="categoricalAnalysis">
|
||||||
<v-card variant="flat" min-height="680">
|
<v-card variant="flat" min-height="680">
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="title-and-toolbar d-flex align-center">
|
<div class="title-and-toolbar d-flex align-center">
|
||||||
@@ -63,24 +103,6 @@
|
|||||||
@click="shiftDateRange(query.startTime, query.endTime, 1)"/>
|
@click="shiftDateRange(query.startTime, query.endTime, 1)"/>
|
||||||
</v-btn-group>
|
</v-btn-group>
|
||||||
|
|
||||||
<v-menu location="bottom">
|
|
||||||
<template #activator="{ props }">
|
|
||||||
<v-btn class="ml-3" color="default" variant="outlined"
|
|
||||||
:prepend-icon="icons.sort" :disabled="loading"
|
|
||||||
v-bind="props">{{ querySortingTypeName }}</v-btn>
|
|
||||||
</template>
|
|
||||||
<v-list>
|
|
||||||
<v-list-item :key="sortingType.type" :value="sortingType.type"
|
|
||||||
:append-icon="(query.sortingType === sortingType.type ? icons.check : null)"
|
|
||||||
v-for="sortingType in allSortingTypes">
|
|
||||||
<v-list-item-title
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="setSortingType(sortingType.type)">
|
|
||||||
{{ $t(sortingType.fullName) }}
|
|
||||||
</v-list-item-title>
|
|
||||||
</v-list-item>
|
|
||||||
</v-list>
|
|
||||||
</v-menu>
|
|
||||||
<v-btn density="compact" color="default" variant="text"
|
<v-btn density="compact" color="default" variant="text"
|
||||||
class="ml-2" :icon="true" :disabled="loading"
|
class="ml-2" :icon="true" :disabled="loading"
|
||||||
v-if="!loading" @click="reload">
|
v-if="!loading" @click="reload">
|
||||||
@@ -255,7 +277,7 @@ import { useStatisticsStore } from '@/stores/statistics.js';
|
|||||||
|
|
||||||
import datetimeConstants from '@/consts/datetime.js';
|
import datetimeConstants from '@/consts/datetime.js';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
import statisticsConstants from '@/consts/statistics.js';
|
||||||
import { getNameByKeyValue, limitText, formatPercent } from '@/lib/common.js'
|
import { limitText, formatPercent } from '@/lib/common.js'
|
||||||
import {
|
import {
|
||||||
getShiftedDateRangeAndDateType,
|
getShiftedDateRangeAndDateType,
|
||||||
getDateRangeByDateType
|
getDateRangeByDateType
|
||||||
@@ -287,7 +309,7 @@ export default {
|
|||||||
const { mdAndUp } = useDisplay();
|
const { mdAndUp } = useDisplay();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'statisticsPage',
|
activeTab: 'categoricalAnalysis',
|
||||||
initing: true,
|
initing: true,
|
||||||
loading: true,
|
loading: true,
|
||||||
alwaysShowNav: mdAndUp.value,
|
alwaysShowNav: mdAndUp.value,
|
||||||
@@ -327,9 +349,21 @@ export default {
|
|||||||
queryChartDataCategory() {
|
queryChartDataCategory() {
|
||||||
return this.statisticsStore.transactionStatisticsChartDataCategory;
|
return this.statisticsStore.transactionStatisticsChartDataCategory;
|
||||||
},
|
},
|
||||||
querySortingTypeName() {
|
queryChartType: {
|
||||||
const querySortingTypeName = getNameByKeyValue(this.allSortingTypes, this.query.sortingType, 'type', 'fullName', 'System Default');
|
get: function () {
|
||||||
return this.$t(querySortingTypeName);
|
return this.query.chartType;
|
||||||
|
},
|
||||||
|
set: function(value) {
|
||||||
|
this.setChartType(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
querySortingType: {
|
||||||
|
get: function () {
|
||||||
|
return this.query.sortingType;
|
||||||
|
},
|
||||||
|
set: function(value) {
|
||||||
|
this.setSortingType(value);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
queryStartTime() {
|
queryStartTime() {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.startTime);
|
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.startTime);
|
||||||
@@ -340,12 +374,27 @@ export default {
|
|||||||
allChartTypes() {
|
allChartTypes() {
|
||||||
return statisticsConstants.allChartTypes;
|
return statisticsConstants.allChartTypes;
|
||||||
},
|
},
|
||||||
|
allChartTypesArray() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'Pie Chart',
|
||||||
|
type: this.allChartTypes.Pie
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Bar Chart',
|
||||||
|
type: this.allChartTypes.Bar
|
||||||
|
}
|
||||||
|
];
|
||||||
|
},
|
||||||
allChartDataTypes() {
|
allChartDataTypes() {
|
||||||
return statisticsConstants.allChartDataTypes;
|
return statisticsConstants.allChartDataTypes;
|
||||||
},
|
},
|
||||||
allSortingTypes() {
|
allSortingTypes() {
|
||||||
return statisticsConstants.allSortingTypes;
|
return statisticsConstants.allSortingTypes;
|
||||||
},
|
},
|
||||||
|
allSortingTypesArray() {
|
||||||
|
return statisticsConstants.allSortingTypesArray;
|
||||||
|
},
|
||||||
allDateRanges() {
|
allDateRanges() {
|
||||||
return datetimeConstants.allDateRanges;
|
return datetimeConstants.allDateRanges;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<f7-popover class="chart-data-type-popover-menu"
|
<f7-popover class="chart-data-type-popover-menu"
|
||||||
v-model:opened="showChartDataTypePopover">
|
v-model:opened="showChartDataTypePopover">
|
||||||
<f7-list dividers>
|
<f7-list dividers>
|
||||||
|
<f7-list-item group-title :title="$t('Categorical Analysis')" />
|
||||||
<f7-list-item :title="$t(dataType.name)"
|
<f7-list-item :title="$t(dataType.name)"
|
||||||
:key="dataType.type"
|
:key="dataType.type"
|
||||||
v-for="dataType in allChartDataTypes"
|
v-for="dataType in allChartDataTypes"
|
||||||
|
|||||||
Reference in New Issue
Block a user