|
|
@@ -48,9 +48,9 @@ const convertDateValues = (formValues: any, fields: any[]): any => {
|
|
|
const dayjsValue = dayjs(value);
|
|
|
convertedValues[fieldName] = dayjsValue.isValid() ? dayjsValue : undefined;
|
|
|
}
|
|
|
- } else if (value && typeof value === 'object' && 'isValid' in value) {
|
|
|
- // 已经是 dayjs 对象
|
|
|
- convertedValues[fieldName] = value;
|
|
|
+ } else if (value && typeof value === 'object' && 'isValid' in value && typeof value.isValid === 'function') {
|
|
|
+ // 已经是 dayjs 对象,验证 isValid 是函数
|
|
|
+ convertedValues[fieldName] = value.isValid() ? value : undefined;
|
|
|
} else {
|
|
|
convertedValues[fieldName] = undefined;
|
|
|
}
|
|
|
@@ -72,8 +72,8 @@ const convertDateValues = (formValues: any, fields: any[]): any => {
|
|
|
startDayjs = dayjs(start);
|
|
|
startDayjs = startDayjs.isValid() ? startDayjs : null;
|
|
|
}
|
|
|
- } else if (start && typeof start === 'object' && 'isValid' in start) {
|
|
|
- startDayjs = start;
|
|
|
+ } else if (start && typeof start === 'object' && 'isValid' in start && typeof start.isValid === 'function') {
|
|
|
+ startDayjs = start.isValid() ? start : null;
|
|
|
}
|
|
|
// 处理结束时间
|
|
|
let endDayjs: any = null;
|
|
|
@@ -89,8 +89,8 @@ const convertDateValues = (formValues: any, fields: any[]): any => {
|
|
|
endDayjs = dayjs(end);
|
|
|
endDayjs = endDayjs.isValid() ? endDayjs : null;
|
|
|
}
|
|
|
- } else if (end && typeof end === 'object' && 'isValid' in end) {
|
|
|
- endDayjs = end;
|
|
|
+ } else if (end && typeof end === 'object' && 'isValid' in end && typeof end.isValid === 'function') {
|
|
|
+ endDayjs = end.isValid() ? end : null;
|
|
|
}
|
|
|
if (startDayjs && endDayjs) {
|
|
|
convertedValues[fieldName] = [startDayjs, endDayjs];
|
|
|
@@ -408,8 +408,12 @@ export default function MyTask() {
|
|
|
getValueFromEvent={(value) => {
|
|
|
// 选择日期时,将 dayjs 对象转换为毫秒级时间戳
|
|
|
if (!value) return undefined;
|
|
|
- if (value && typeof value === 'object' && 'valueOf' in value) {
|
|
|
- return value.valueOf(); // dayjs 的 valueOf() 返回毫秒级时间戳
|
|
|
+ if (value && typeof value === 'object' && 'valueOf' in value && typeof value.valueOf === 'function' && 'isValid' in value && typeof value.isValid === 'function') {
|
|
|
+ // 确保是有效的 dayjs 对象
|
|
|
+ if (value.isValid()) {
|
|
|
+ return value.valueOf(); // dayjs 的 valueOf() 返回毫秒级时间戳
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
}
|
|
|
return value;
|
|
|
}}
|
|
|
@@ -429,7 +433,7 @@ export default function MyTask() {
|
|
|
const dayjsValue = dayjs(value);
|
|
|
return dayjsValue.isValid() ? dayjsValue : undefined;
|
|
|
}
|
|
|
- if (value && typeof value === 'object' && 'isValid' in value) {
|
|
|
+ if (value && typeof value === 'object' && 'isValid' in value && typeof value.isValid === 'function') {
|
|
|
return value.isValid() ? value : undefined;
|
|
|
}
|
|
|
return undefined;
|
|
|
@@ -458,9 +462,13 @@ export default function MyTask() {
|
|
|
// 选择日期范围时,将 dayjs 对象数组转换为毫秒级时间戳数组
|
|
|
if (!value || !Array.isArray(value) || value.length !== 2) return undefined;
|
|
|
const [start, end] = value;
|
|
|
- if (start && typeof start === 'object' && 'valueOf' in start &&
|
|
|
- end && typeof end === 'object' && 'valueOf' in end) {
|
|
|
- return [start.valueOf(), end.valueOf()]; // 返回毫秒级时间戳数组
|
|
|
+ if (start && typeof start === 'object' && 'valueOf' in start && typeof start.valueOf === 'function' && 'isValid' in start && typeof start.isValid === 'function' &&
|
|
|
+ end && typeof end === 'object' && 'valueOf' in end && typeof end.valueOf === 'function' && 'isValid' in end && typeof end.isValid === 'function') {
|
|
|
+ // 确保都是有效的 dayjs 对象
|
|
|
+ if (start.isValid() && end.isValid()) {
|
|
|
+ return [start.valueOf(), end.valueOf()]; // 返回毫秒级时间戳数组
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
}
|
|
|
return value;
|
|
|
}}
|
|
|
@@ -484,7 +492,7 @@ export default function MyTask() {
|
|
|
startDayjs = dayjs(start);
|
|
|
startDayjs = startDayjs.isValid() ? startDayjs : null;
|
|
|
}
|
|
|
- } else if (start && typeof start === 'object' && 'isValid' in start) {
|
|
|
+ } else if (start && typeof start === 'object' && 'isValid' in start && typeof start.isValid === 'function') {
|
|
|
startDayjs = start.isValid() ? start : null;
|
|
|
}
|
|
|
|
|
|
@@ -500,7 +508,7 @@ export default function MyTask() {
|
|
|
endDayjs = dayjs(end);
|
|
|
endDayjs = endDayjs.isValid() ? endDayjs : null;
|
|
|
}
|
|
|
- } else if (end && typeof end === 'object' && 'isValid' in end) {
|
|
|
+ } else if (end && typeof end === 'object' && 'isValid' in end && typeof end.isValid === 'function') {
|
|
|
endDayjs = end.isValid() ? end : null;
|
|
|
}
|
|
|
|
|
|
@@ -554,7 +562,7 @@ export default function MyTask() {
|
|
|
const dayjsValue = dayjs(value);
|
|
|
return dayjsValue.isValid() ? dayjsValue : undefined;
|
|
|
}
|
|
|
- if (value && typeof value === 'object' && 'isValid' in value) {
|
|
|
+ if (value && typeof value === 'object' && 'isValid' in value && typeof value.isValid === 'function') {
|
|
|
return value.isValid() ? value : undefined;
|
|
|
}
|
|
|
return undefined;
|