mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
code refactor
This commit is contained in:
@@ -18,13 +18,13 @@ import {
|
|||||||
getCurrentUnixTime
|
getCurrentUnixTime
|
||||||
} from '@/lib/datetime.ts';
|
} from '@/lib/datetime.ts';
|
||||||
|
|
||||||
export interface DayAndDisplayName {
|
|
||||||
readonly day: number;
|
|
||||||
readonly displayName: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useAccountEditPageBase() {
|
export function useAccountEditPageBase() {
|
||||||
const { tt, getAllAccountCategories, getAllAccountTypes, getMonthdayShortName } = useI18n();
|
const {
|
||||||
|
tt,
|
||||||
|
getAvailableMonthDays,
|
||||||
|
getAllAccountCategories,
|
||||||
|
getAllAccountTypes
|
||||||
|
} = useI18n();
|
||||||
|
|
||||||
const settingsStore = useSettingsStore();
|
const settingsStore = useSettingsStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -80,21 +80,14 @@ export function useAccountEditPageBase() {
|
|||||||
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories(customAccountCategoryOrder.value));
|
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories(customAccountCategoryOrder.value));
|
||||||
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
|
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
|
||||||
|
|
||||||
const allAvailableMonthDays = computed<DayAndDisplayName[]>(() => {
|
const allAvailableMonthDays = computed<TypeAndDisplayName[]>(() => {
|
||||||
const allAvailableDays: DayAndDisplayName[] = [];
|
const allAvailableDays: TypeAndDisplayName[] = getAvailableMonthDays(28);
|
||||||
|
|
||||||
allAvailableDays.push({
|
allAvailableDays.splice(0, 0, {
|
||||||
day: 0,
|
type: 0,
|
||||||
displayName: tt('Not set'),
|
displayName: tt('Not set'),
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 1; i <= 28; i++) {
|
|
||||||
allAvailableDays.push({
|
|
||||||
day: i,
|
|
||||||
displayName: getMonthdayShortName(i),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return allAvailableDays;
|
return allAvailableDays;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -114,7 +107,7 @@ export function useAccountEditPageBase() {
|
|||||||
|
|
||||||
function getAccountCreditCardStatementDate(statementDate?: number): string | null {
|
function getAccountCreditCardStatementDate(statementDate?: number): string | null {
|
||||||
for (const item of allAvailableMonthDays.value) {
|
for (const item of allAvailableMonthDays.value) {
|
||||||
if (item.day === statementDate) {
|
if (item.type === statementDate) {
|
||||||
return item.displayName;
|
return item.displayName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
<v-col cols="12" :md="account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0 ? 6 : 12" v-if="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate">
|
<v-col cols="12" :md="account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0 ? 6 : 12" v-if="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate">
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
item-title="displayName"
|
item-title="displayName"
|
||||||
item-value="day"
|
item-value="type"
|
||||||
auto-select-first
|
auto-select-first
|
||||||
persistent-placeholder
|
persistent-placeholder
|
||||||
:disabled="loading || submitting"
|
:disabled="loading || submitting"
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
@click="accountContext.showCreditCardStatementDatePopup = true"
|
@click="accountContext.showCreditCardStatementDatePopup = true"
|
||||||
>
|
>
|
||||||
<list-item-selection-popup value-type="item"
|
<list-item-selection-popup value-type="item"
|
||||||
key-field="day" value-field="day"
|
key-field="type" value-field="type"
|
||||||
title-field="displayName"
|
title-field="displayName"
|
||||||
:title="tt('Statement Date')"
|
:title="tt('Statement Date')"
|
||||||
:enable-filter="true"
|
:enable-filter="true"
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
@click="accountContext.showCreditCardStatementDatePopup = true"
|
@click="accountContext.showCreditCardStatementDatePopup = true"
|
||||||
>
|
>
|
||||||
<list-item-selection-popup value-type="item"
|
<list-item-selection-popup value-type="item"
|
||||||
key-field="day" value-field="day"
|
key-field="type" value-field="type"
|
||||||
title-field="displayName"
|
title-field="displayName"
|
||||||
:title="tt('Statement Date')"
|
:title="tt('Statement Date')"
|
||||||
:enable-filter="true"
|
:enable-filter="true"
|
||||||
|
|||||||
Reference in New Issue
Block a user