一个月时间选择问题

This commit is contained in:
筱野
2025-10-12 22:52:57 +08:00
parent 5bb1fe7a56
commit e78b5297ac
2 changed files with 15 additions and 3 deletions

View File

@@ -41,7 +41,15 @@ const FilterPopup = (props: FilterPopupProps) => {
const handleDateChange = (dates: Date[]) => {
console.log(dates,'datesdatesdatesdatesdates');
let times: String[] = [];
if (dates.length > 1) {
times = [dayjs(dates[0]).format('YYYY-MM-DD'), dayjs(dates[dates.length - 1]).format('YYYY-MM-DD')]
onChange({
'dateRange': times,
})
return;
}
if (Array.isArray(dates)) {
const currentDay = dayjs(dates[0]).format('YYYY-MM-DD');
if (filterOptions.dateRange.length === 0 || filterOptions.dateRange.length === 2) {
times.push(currentDay);

View File

@@ -89,7 +89,10 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
onClose();
}
};
const dialogClose = () => {
setType("year");
onClose();
}
const calculateMonthDifference = (date1, date2) => {
if (!(date1 instanceof Date) || !(date2 instanceof Date)) {
throw new Error("Both arguments must be Date objects");
@@ -143,7 +146,7 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
const month = value[1] as number;
setSelected(new Date(year, month - 1, 1));
};
const dialogClose = () => {
const onCancel = () => {
if (type === "month") {
setType("year");
} else if (type === "time") {
@@ -171,12 +174,13 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
}
}, [type, pendingJump]);
console.log([selectedHour, selectedMinute], "selectedHour, selectedMinute");
console.log([selectedHour, selectedMinute], visible,type, "selectedHour, selectedMinute");
return (
<CommonPopup
visible={visible}
onClose={dialogClose}
onCancel={onCancel}
showHeader={!!title}
title={title}
hideFooter={false}