From 8fb5d5cba83d68861c421eb83c8ad447bee80cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=99=93=E9=9D=99?= <17600756968@163.com> Date: Tue, 21 Jul 2020 17:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=8C=BA=E9=97=B4=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/base/edit/dateRange/index.tsx | 35 +++++++++++++++---- components/apolloTable/editFormV3/index.less | 3 +- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/components/apolloTable/component/base/edit/dateRange/index.tsx b/components/apolloTable/component/base/edit/dateRange/index.tsx index 53c4362..9d88249 100644 --- a/components/apolloTable/component/base/edit/dateRange/index.tsx +++ b/components/apolloTable/component/base/edit/dateRange/index.tsx @@ -1,18 +1,41 @@ -import React from 'react'; +import React, { useRef } from 'react'; import { DatePicker } from 'antd'; -import styles from './styles.less'; +import { onBlurFn } from '../onBlurFn'; import { antiAssign } from '../../../../utils/utils'; +import styles from './styles.less'; const { RangePicker } = DatePicker; export const ApolloDateRange = (props: any) => { - const { onChange, placeholder, beginDatePlaceholder, endDatePlaceholder } = props; + const { onChange, placeholder, showTime, beginDatePlaceholder, endDatePlaceholder, origin } = props; const selfProps = antiAssign(props, ['onChange', 'columnConfig']); - const changeValue = (dates, dateStrings) => { + const isOpen = useRef(); + const changeValue = (date, dateString) => { if (typeof onChange === 'function') { - onChange(dates, dateStrings); + 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 ( + return (origin === 'editForm' ? + :