|
|
@@ -203,7 +203,8 @@ export function validateDateRange(
|
|
|
startErrorMessage: string = "开始时间不能早于当前时间",
|
|
|
endErrorMessage: string = "结束时间不能早于当前时间",
|
|
|
rangeErrorMessage: string = "开始时间必须早于结束时间",
|
|
|
- checkToday: boolean = true
|
|
|
+ checkToday: boolean = true,
|
|
|
+ allowSameDay: boolean = false
|
|
|
) {
|
|
|
return (rule: any, value: any, callback: any) => {
|
|
|
if (!value) {
|
|
|
@@ -254,7 +255,8 @@ export function validateDateRange(
|
|
|
if (endDate) {
|
|
|
const end = new Date(endDate);
|
|
|
end.setHours(0, 0, 0, 0);
|
|
|
- if (selectedDate >= end) {
|
|
|
+ const isInvalid = allowSameDay ? selectedDate > end : selectedDate >= end;
|
|
|
+ if (isInvalid) {
|
|
|
callback(new Error(rangeErrorMessage));
|
|
|
return;
|
|
|
}
|
|
|
@@ -265,7 +267,8 @@ export function validateDateRange(
|
|
|
if (startDate) {
|
|
|
const start = new Date(startDate);
|
|
|
start.setHours(0, 0, 0, 0);
|
|
|
- if (selectedDate <= start) {
|
|
|
+ const isInvalid = allowSameDay ? selectedDate < start : selectedDate <= start;
|
|
|
+ if (isInvalid) {
|
|
|
callback(new Error(rangeErrorMessage));
|
|
|
return;
|
|
|
}
|