mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
code refactor
This commit is contained in:
@@ -746,6 +746,7 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateTransactionListFilter(filter) {
|
updateTransactionListFilter(filter) {
|
||||||
|
const accountsStore = useAccountsStore();
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (filter && isNumber(filter.dateType) && this.transactionsFilter.dateType !== filter.dateType) {
|
if (filter && isNumber(filter.dateType) && this.transactionsFilter.dateType !== filter.dateType) {
|
||||||
@@ -775,6 +776,11 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
|
|
||||||
if (filter && isString(filter.accountIds) && this.transactionsFilter.accountIds !== filter.accountIds) {
|
if (filter && isString(filter.accountIds) && this.transactionsFilter.accountIds !== filter.accountIds) {
|
||||||
this.transactionsFilter.accountIds = filter.accountIds;
|
this.transactionsFilter.accountIds = filter.accountIds;
|
||||||
|
|
||||||
|
if (datetimeConstants.allBillingCycleDateRangesMap[this.transactionsFilter.dateType] && !accountsStore.getAccountStatementDate(this.transactionsFilter.accountIds)) {
|
||||||
|
this.transactionsFilter.dateType = datetimeConstants.allDateRanges.Custom.type;
|
||||||
|
}
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ import { useAccountsStore } from '@/stores/account.js';
|
|||||||
import { useTransactionsStore } from '@/stores/transaction.js';
|
import { useTransactionsStore } from '@/stores/transaction.js';
|
||||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||||
|
|
||||||
import datetimeConstants from '@/consts/datetime.js';
|
|
||||||
import accountConstants from '@/consts/account.js';
|
import accountConstants from '@/consts/account.js';
|
||||||
import { copyObjectTo } from '@/lib/common.js';
|
import { copyObjectTo } from '@/lib/common.js';
|
||||||
import {
|
import {
|
||||||
@@ -323,15 +322,9 @@ export default {
|
|||||||
self.statisticsStore.updateTransactionStatisticsInvalidState(true);
|
self.statisticsStore.updateTransactionStatisticsInvalidState(true);
|
||||||
}
|
}
|
||||||
} else if (this.type === 'transactionListCurrent') {
|
} else if (this.type === 'transactionListCurrent') {
|
||||||
const filter = {
|
changed = self.transactionsStore.updateTransactionListFilter({
|
||||||
accountIds: isAllSelected ? '' : finalAccountIds
|
accountIds: isAllSelected ? '' : finalAccountIds
|
||||||
};
|
});
|
||||||
|
|
||||||
if (datetimeConstants.allBillingCycleDateRangesMap[self.transactionsStore.transactionsFilter.dateType] && !self.accountsStore.getAccountStatementDate(filter.accountIds)) {
|
|
||||||
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
changed = self.transactionsStore.updateTransactionListFilter(filter);
|
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
self.transactionsStore.updateTransactionListInvalidState(true);
|
self.transactionsStore.updateTransactionListInvalidState(true);
|
||||||
|
|||||||
@@ -1432,15 +1432,9 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter = {
|
const changed = this.transactionsStore.updateTransactionListFilter({
|
||||||
accountIds: accountIds
|
accountIds: accountIds
|
||||||
};
|
});
|
||||||
|
|
||||||
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] && !this.accountsStore.getAccountStatementDate(accountIds)) {
|
|
||||||
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
const changed = this.transactionsStore.updateTransactionListFilter(filter);
|
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ import { useAccountsStore } from '@/stores/account.js';
|
|||||||
import { useTransactionsStore } from '@/stores/transaction.js';
|
import { useTransactionsStore } from '@/stores/transaction.js';
|
||||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||||
|
|
||||||
import datetimeConstants from '@/consts/datetime.js';
|
|
||||||
import accountConstants from '@/consts/account.js';
|
import accountConstants from '@/consts/account.js';
|
||||||
import { copyObjectTo } from '@/lib/common.js';
|
import { copyObjectTo } from '@/lib/common.js';
|
||||||
import {
|
import {
|
||||||
@@ -295,15 +294,9 @@ export default {
|
|||||||
filterAccountIds: filteredAccountIds
|
filterAccountIds: filteredAccountIds
|
||||||
});
|
});
|
||||||
} else if (this.type === 'transactionListCurrent') {
|
} else if (this.type === 'transactionListCurrent') {
|
||||||
const filter = {
|
const changed = self.transactionsStore.updateTransactionListFilter({
|
||||||
accountIds: isAllSelected ? '' : finalAccountIds
|
accountIds: isAllSelected ? '' : finalAccountIds
|
||||||
};
|
});
|
||||||
|
|
||||||
if (datetimeConstants.allBillingCycleDateRangesMap[self.transactionsStore.transactionsFilter.dateType] && !self.accountsStore.getAccountStatementDate(filter.accountIds)) {
|
|
||||||
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
const changed = self.transactionsStore.updateTransactionListFilter(filter);
|
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
self.transactionsStore.updateTransactionListInvalidState(true);
|
self.transactionsStore.updateTransactionListInvalidState(true);
|
||||||
|
|||||||
@@ -981,15 +981,9 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter = {
|
const changed = this.transactionsStore.updateTransactionListFilter({
|
||||||
accountIds: accountIds
|
accountIds: accountIds
|
||||||
};
|
});
|
||||||
|
|
||||||
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] && !this.accountsStore.getAccountStatementDate(accountIds)) {
|
|
||||||
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
const changed = this.transactionsStore.updateTransactionListFilter(filter);
|
|
||||||
|
|
||||||
this.showAccountPopover = false;
|
this.showAccountPopover = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user