diff --git a/packages/core/client/src/schema-component/antd/date-picker/util.ts b/packages/core/client/src/schema-component/antd/date-picker/util.ts index aa0a810ae..e037070bd 100644 --- a/packages/core/client/src/schema-component/antd/date-picker/util.ts +++ b/packages/core/client/src/schema-component/antd/date-picker/util.ts @@ -44,7 +44,7 @@ export interface Moment2strOptions { picker?: 'year' | 'month' | 'week' | 'quarter'; } -export const moment2str = (value?: Dayjs, options: Moment2strOptions = {}) => { +export const moment2str = (value?: Dayjs | null, options: Moment2strOptions = {}) => { const { showTime, gmt, picker, utc = true } = options; if (!value) { return value; @@ -71,9 +71,9 @@ export const mapDatePicker = function () { ...props, format: format, value: str2moment(props.value, props), - onChange: (value: Dayjs) => { + onChange: (value: Dayjs | null) => { if (onChange) { - if (!props.showTime) { + if (!props.showTime && value) { value = value.startOf('day'); } onChange(moment2str(value, props));