import React, { useRef } from 'react'; import { DatePicker } from 'antd'; import { onBlurFn } from '../onBlurFn'; import { antiAssign } from '../../../../utils/utils'; import styles from './styles.less'; export const ApolloDate = (props: any) => { const { origin, onChange, showTime } = props; const selfProps = antiAssign(props, [ 'onChange', 'columnConfig', 'tableId', 'rowData', 'cellRenderProps', 'maxPopHeight', 'getPopupContainer', 'origin', 'disableOptions', 'rowId', 'onBlurFn', 'getInstanceDetail', ]); selfProps.disabled = !!props.disabled; const isOpen = useRef(); const changeValue = (date, dateString) => { if (typeof onChange === 'function') { if (typeof onBlurFn === 'function' && !isOpen.current) { onBlurFn({ ...props, value: date }); } onChange(date, dateString); } }; const dateOnBlurFn = (e: boolean) => { isOpen.current = e; }; const timeOnBlurFn = (e: boolean) => { isOpen.current = e; if (typeof onBlurFn === 'function' && !e) { onBlurFn(props); } }; return origin === 'editForm' ? ( ) : ( ); };