code refactor

This commit is contained in:
MaysWind 2026-04-12 22:57:20 +08:00
parent ff1158be00
commit 0222f61da6
3 changed files with 14 additions and 21 deletions

View file

@ -18,13 +18,13 @@ import {
getCurrentUnixTime
} from '@/lib/datetime.ts';
export interface DayAndDisplayName {
readonly day: number;
readonly displayName: string;
}
export function useAccountEditPageBase() {
const { tt, getAllAccountCategories, getAllAccountTypes, getMonthdayShortName } = useI18n();
const {
tt,
getAvailableMonthDays,
getAllAccountCategories,
getAllAccountTypes
} = useI18n();
const settingsStore = useSettingsStore();
const userStore = useUserStore();
@ -80,21 +80,14 @@ export function useAccountEditPageBase() {
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories(customAccountCategoryOrder.value));
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
const allAvailableMonthDays = computed<DayAndDisplayName[]>(() => {
const allAvailableDays: DayAndDisplayName[] = [];
const allAvailableMonthDays = computed<TypeAndDisplayName[]>(() => {
const allAvailableDays: TypeAndDisplayName[] = getAvailableMonthDays(28);
allAvailableDays.push({
day: 0,
allAvailableDays.splice(0, 0, {
type: 0,
displayName: tt('Not set'),
});
for (let i = 1; i <= 28; i++) {
allAvailableDays.push({
day: i,
displayName: getMonthdayShortName(i),
});
}
return allAvailableDays;
});
@ -114,7 +107,7 @@ export function useAccountEditPageBase() {
function getAccountCreditCardStatementDate(statementDate?: number): string | null {
for (const item of allAvailableMonthDays.value) {
if (item.day === statementDate) {
if (item.type === statementDate) {
return item.displayName;
}
}

View file

@ -118,7 +118,7 @@
<v-col cols="12" :md="account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0 ? 6 : 12" v-if="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate">
<v-autocomplete
item-title="displayName"
item-value="day"
item-value="type"
auto-select-first
persistent-placeholder
:disabled="loading || submitting"

View file

@ -189,7 +189,7 @@
@click="accountContext.showCreditCardStatementDatePopup = true"
>
<list-item-selection-popup value-type="item"
key-field="day" value-field="day"
key-field="type" value-field="type"
title-field="displayName"
:title="tt('Statement Date')"
:enable-filter="true"
@ -322,7 +322,7 @@
@click="accountContext.showCreditCardStatementDatePopup = true"
>
<list-item-selection-popup value-type="item"
key-field="day" value-field="day"
key-field="type" value-field="type"
title-field="displayName"
:title="tt('Statement Date')"
:enable-filter="true"