fix: 修复季度范围选择器禁用bug

This commit is contained in:
xuzhendong666 2021-06-17 19:26:14 +08:00
parent b35a4f967d
commit 287d2ba4f0

View File

@ -531,8 +531,8 @@ export class DateRangePicker extends React.Component<
checkStartIsValidDate(currentDate: moment.Moment) { checkStartIsValidDate(currentDate: moment.Moment) {
let {endDate, startDate} = this.state; let {endDate, startDate} = this.state;
let {minDate, maxDate, minDuration, maxDuration, viewMode} = this.props;
let {minDate, maxDate, minDuration, maxDuration} = this.props; const precision = viewMode === 'quarters' ? 'quarter' : 'day';
maxDate = maxDate =
maxDate && endDate maxDate && endDate
@ -541,9 +541,9 @@ export class DateRangePicker extends React.Component<
: endDate : endDate
: maxDate || endDate; : maxDate || endDate;
if (minDate && currentDate.isBefore(minDate, 'day')) { if (minDate && currentDate.isBefore(minDate, precision)) {
return false; return false;
} else if (maxDate && currentDate.isAfter(maxDate, 'day')) { } else if (maxDate && currentDate.isAfter(maxDate, precision)) {
return false; return false;
} else if ( } else if (
// 如果配置了 minDuration 那么 EndDate - minDuration 之后的天数也不能选 // 如果配置了 minDuration 那么 EndDate - minDuration 之后的天数也不能选
@ -565,8 +565,8 @@ export class DateRangePicker extends React.Component<
checkEndIsValidDate(currentDate: moment.Moment) { checkEndIsValidDate(currentDate: moment.Moment) {
let {startDate} = this.state; let {startDate} = this.state;
let {minDate, maxDate, minDuration, maxDuration, viewMode} = this.props;
let {minDate, maxDate, minDuration, maxDuration} = this.props; const precision = viewMode === 'quarters' ? 'quarter' : 'day';
minDate = minDate =
minDate && startDate minDate && startDate
@ -575,9 +575,9 @@ export class DateRangePicker extends React.Component<
: startDate : startDate
: minDate || startDate; : minDate || startDate;
if (minDate && currentDate.isBefore(minDate, 'day')) { if (minDate && currentDate.isBefore(minDate, precision)) {
return false; return false;
} else if (maxDate && currentDate.isAfter(maxDate, 'day')) { } else if (maxDate && currentDate.isAfter(maxDate, precision)) {
return false; return false;
} else if ( } else if (
startDate && startDate &&