一个月时间选择问题
This commit is contained in:
@@ -41,7 +41,15 @@ const FilterPopup = (props: FilterPopupProps) => {
|
|||||||
const handleDateChange = (dates: Date[]) => {
|
const handleDateChange = (dates: Date[]) => {
|
||||||
console.log(dates,'datesdatesdatesdatesdates');
|
console.log(dates,'datesdatesdatesdatesdates');
|
||||||
let times: String[] = [];
|
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)) {
|
if (Array.isArray(dates)) {
|
||||||
|
|
||||||
const currentDay = dayjs(dates[0]).format('YYYY-MM-DD');
|
const currentDay = dayjs(dates[0]).format('YYYY-MM-DD');
|
||||||
if (filterOptions.dateRange.length === 0 || filterOptions.dateRange.length === 2) {
|
if (filterOptions.dateRange.length === 0 || filterOptions.dateRange.length === 2) {
|
||||||
times.push(currentDay);
|
times.push(currentDay);
|
||||||
|
|||||||
@@ -89,7 +89,10 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
|
|||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const dialogClose = () => {
|
||||||
|
setType("year");
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
const calculateMonthDifference = (date1, date2) => {
|
const calculateMonthDifference = (date1, date2) => {
|
||||||
if (!(date1 instanceof Date) || !(date2 instanceof Date)) {
|
if (!(date1 instanceof Date) || !(date2 instanceof Date)) {
|
||||||
throw new Error("Both arguments must be Date objects");
|
throw new Error("Both arguments must be Date objects");
|
||||||
@@ -143,7 +146,7 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
|
|||||||
const month = value[1] as number;
|
const month = value[1] as number;
|
||||||
setSelected(new Date(year, month - 1, 1));
|
setSelected(new Date(year, month - 1, 1));
|
||||||
};
|
};
|
||||||
const dialogClose = () => {
|
const onCancel = () => {
|
||||||
if (type === "month") {
|
if (type === "month") {
|
||||||
setType("year");
|
setType("year");
|
||||||
} else if (type === "time") {
|
} else if (type === "time") {
|
||||||
@@ -171,12 +174,13 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
|
|||||||
}
|
}
|
||||||
}, [type, pendingJump]);
|
}, [type, pendingJump]);
|
||||||
|
|
||||||
console.log([selectedHour, selectedMinute], "selectedHour, selectedMinute");
|
console.log([selectedHour, selectedMinute], visible,type, "selectedHour, selectedMinute");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommonPopup
|
<CommonPopup
|
||||||
visible={visible}
|
visible={visible}
|
||||||
onClose={dialogClose}
|
onClose={dialogClose}
|
||||||
|
onCancel={onCancel}
|
||||||
showHeader={!!title}
|
showHeader={!!title}
|
||||||
title={title}
|
title={title}
|
||||||
hideFooter={false}
|
hideFooter={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user