mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 16:07:33 +08:00
fix the display format of the fiscal year start date not updated after changing the number system on user profile page
This commit is contained in:
@@ -2,9 +2,14 @@ import { ref, computed } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { NumeralSystem } from '@/core/numeral.ts';
|
||||
import type { MonthDay } from '@/core/datetime.ts';
|
||||
import { FiscalYearStart } from '@/core/fiscalyear.ts';
|
||||
|
||||
import {
|
||||
isDefined
|
||||
} from '@/lib/common.ts';
|
||||
|
||||
import {
|
||||
getLocalDatetimeFromUnixTime,
|
||||
getThisYearFirstUnixTime,
|
||||
@@ -16,6 +21,7 @@ export interface CommonFiscalYearStartSelectionProps {
|
||||
disabled?: boolean;
|
||||
readonly?: boolean;
|
||||
label?: string;
|
||||
numeralSystem?: number;
|
||||
}
|
||||
|
||||
export interface CommonFiscalYearStartSelectionEmits {
|
||||
@@ -37,7 +43,7 @@ function getFiscalYearStartFromProps(props: CommonFiscalYearStartSelectionProps)
|
||||
}
|
||||
|
||||
export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSelectionProps) {
|
||||
const { formatGregorianTextualMonthDayToGregorianLikeLongMonthDay } = useI18n();
|
||||
const { getCurrentNumeralSystemType, formatGregorianTextualMonthDayToGregorianLikeLongMonthDay } = useI18n();
|
||||
|
||||
const disabledDates = (date: Date) => {
|
||||
// Disable February 29 (leap day)
|
||||
@@ -46,6 +52,14 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele
|
||||
|
||||
const selectedFiscalYearStart = ref<number>(getFiscalYearStartFromProps(props));
|
||||
|
||||
const actualNumeralSystem = computed<NumeralSystem>(() => {
|
||||
if (isDefined(props.numeralSystem)) {
|
||||
return NumeralSystem.valueOf(props.numeralSystem) ?? NumeralSystem.Default;
|
||||
} else {
|
||||
return getCurrentNumeralSystemType();
|
||||
}
|
||||
});
|
||||
|
||||
const selectedFiscalYearStartValue = computed<Date>({
|
||||
get: () => {
|
||||
const fiscalYearStart = FiscalYearStart.valueOf(selectedFiscalYearStart.value);
|
||||
@@ -71,7 +85,7 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele
|
||||
fiscalYearStart = FiscalYearStart.Default;
|
||||
}
|
||||
|
||||
return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString());
|
||||
return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString(), actualNumeralSystem.value);
|
||||
});
|
||||
|
||||
const allowedMinDate = computed<Date>(() => getLocalDatetimeFromUnixTime(getThisYearFirstUnixTime()));
|
||||
|
||||
Reference in New Issue
Block a user