Browse Source

时间修改

1178232204@qq.com 3 years ago
parent
commit
103d253e9a

+ 17 - 53
src/components/BlockLossManage/editBlock.js

@@ -6,24 +6,27 @@ import apiObj from '@api/index';
 import BlockContext from './block-context';
 import moment from "moment";
 import "moment/locale/zh-cn"
-import { getCookie } from '@utils/index'
-const { RangePicker } = DatePicker;
+import { getCookie, disabledDate, getDaysBetween } from '@utils/index'
 const { post, api, xPost } = apiObj;
 const { TextArea } = Input;
 function EditBlock(props) {
     useEffect(() => {
-        if (type == 2) {
-            setLimit(true)
-        }
     }, []);
     const [form] = Form.useForm();
     const [disable, setDisable] = useState(true);
-    const [startValue, setStartValue] = useState();
-    const [endValue, setendValue] = useState();
     const [limit, setLimit] = useState(false);
     const { blockDetail, type } = useContext(BlockContext);
     const initialValues = blockDetail;
     const onFinish = values => {
+        values.startDate = moment(values.startDate).format('YYYY-MM-DD 00:00:00');
+        values.endDate = moment(values.endDate).format('YYYY-MM-DD 23:23:59');
+        if (values.startDate > values.endDate) {
+            message.warning('开始时间不能大于结束时间');
+            return
+        } else if(!limit && getDaysBetween(values.startDate, values.endDate)>7){
+            message.warning('开始时间与结束时间相差不能超过7天');
+            return
+        }
         if (type == 1) {
             dataRepari(values)
         } else if (type == 2) {
@@ -31,17 +34,14 @@ function EditBlock(props) {
         } else {
             editBlock(values)
         }
-
     };
     function change(e) {
         const formData = form.getFieldsValue();
         const { value } = e.target;
-        if (type == 1) {
-            if (value) {
-                setLimit(true)
-            } else {
-                setLimit(false)
-            }
+        if (value) {
+            setLimit(true)
+        } else {
+            setLimit(false)
         }
         if (formData.behospitalCode || (formData.startDate != undefined && formData.endDate != undefined)) {
             setDisable(false)
@@ -66,7 +66,6 @@ function EditBlock(props) {
         })
     }
     function onStartChange(val) {
-        setStartValue(val)
         const formData = form.getFieldsValue();
         if (formData.behospitalCode || (formData.startDate != undefined && formData.endDate != undefined)) {
             setDisable(false)
@@ -75,7 +74,6 @@ function EditBlock(props) {
         }
     }
     function onEndChange(val) {
-        setendValue(val)
         const formData = form.getFieldsValue();
         if (formData.behospitalCode || (formData.startDate != undefined && formData.endDate != undefined)) {
             setDisable(false)
@@ -83,36 +81,8 @@ function EditBlock(props) {
             setDisable(true)
         }
     }
-    function disabledStartDate(startValue) {
-        if (!startValue || !endValue) {
-            //如果没有选择结束日期,则选择开始日期时,开始日期不能大于今天
-            return startValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }
-        //如果选择了结束日期,则结束日期和开始日期之差大于30天(24*60*60*1000*30是30天的毫秒数),还需要开始日期小于结束日期,返回true,禁止选择
-        if(limit){
-            return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }else{
-            return endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 30 || endValue.valueOf() <= startValue.valueOf();
-        }
-    }
-
-    function disabledEndDate(endValue) {
-        if (!endValue || !startValue) {
-            ////如果没有选择开始日期,则结束日期时大于今天
-            return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }
-        if(limit){
-            return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }else{
-            return endValue.valueOf() <= startValue.valueOf() || endValue.valueOf() > new Date().getTime() || endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 30;
-        }
-        //结束日期这里稍微复杂了一些,如果选择了开始日期,则结束日期和开始日期除了不能超过30个自然日之外,还需要结束日期不能小于开始日期,还需要不能超过今天,返回true为不能选择,所以用或链接,式子之间的符号正好与咱们分析的相反
-        return endValue.valueOf() <= startValue.valueOf() || endValue.valueOf() > new Date().getTime() || endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 30;
-    }
     //数据补录
     function dataRepari(values) {
-        values.startDate = moment(values.startDate).format('YYYY-MM-DD 00:00:00');
-        values.endDate = moment(values.endDate).format('YYYY-MM-DD 23:23:59');
         let params = {
             behospitalCode: values.behospitalCode,
             endDate: values.endDate,
@@ -131,8 +101,6 @@ function EditBlock(props) {
     }
     //数据对比
     function dataCompare(values) {
-        values.startDate = moment(values.startDate).format('YYYY-MM-DD 00:00:00');
-        values.endDate = moment(values.endDate).format('YYYY-MM-DD 23:23:59');
         let params = {
             behospitalCode: values.behospitalCode,
             endDate: values.endDate,
@@ -247,9 +215,7 @@ function EditBlock(props) {
                         <Form.Item label="日期" >
                             <Form.Item name="startDate" className='times'>
                                 <DatePicker
-                                    allowClear={false}
-                                    disabledDate={disabledStartDate}
-                                    value={startValue}
+                                    disabledDate={disabledDate}
                                     placeholder="请选择开始日期"
                                     onChange={onStartChange}
                                 />
@@ -258,10 +224,8 @@ function EditBlock(props) {
                             <span style={{ margin: '0 5px', position: 'relative', top: '2px' }}>-</span>
                             <Form.Item name="endDate" className='times'>
                                 <DatePicker
-                                    allowClear={false}
-                                    disabledDate={disabledEndDate}
-                                    value={endValue}
-                                    placeholder="请选择结束始日期"
+                                    disabledDate={disabledDate}
+                                    placeholder="请选择结束日期"
                                     onChange={onEndChange}
                                 />
                             </Form.Item>

+ 11 - 70
src/components/BlockLossManage/index.js

@@ -7,9 +7,8 @@ import './index.less'
 import apiObj from '@api/index';
 import EditBlock from './editBlock';
 import BlockContext from './block-context';
-import { getValueFromEvent } from '@utils/index'
+import { getValueFromEvent, disabledDate, getDaysBetween } from '@utils/index'
 const { post, api, xPost } = apiObj;
-const { RangePicker } = DatePicker;
 const { Option } = Select;
 function BlockLossManage() {
     useEffect(() => {
@@ -23,8 +22,6 @@ function BlockLossManage() {
     const [size, setSize] = useState(15);
     const [current, setCurrent] = useState(1);
     const [type, setType] = useState(null);
-    const [isLimit, setIsLimit] = useState(false);
-    const [isLimit2, setIsLimit2] = useState(false);
     const [blockData, setBlockData] = useState({});
     const [blockDetail, setBlockDetail] = useState(null);//详情数据
     const [params, setParams] = useState({
@@ -69,63 +66,6 @@ function BlockLossManage() {
             }
         })
     }
-    function onStartChange(val) {
-        setIsLimit2(true)
-    }
-    function onEndChange(val) {
-        setIsLimit(true)
-    }
-    function disabledStartDate(current) {
-        if (isLimit) {
-            // 受到只能选七天日期限制
-            const formData = form.getFieldsValue();
-            const endDate = formData.endDate
-            if (!endDate) {
-                return current && current > Date.now()
-            }
-            return (
-                (current && current < moment(endDate).subtract(364, 'days').startOf('day')) ||
-                current > moment(endDate).add(0, 'days')
-            )
-            
-        } else {
-            return current && current > Date.now()
-        }
-
-    }
-    function disabledEndDate(current) {
-        if (isLimit2) {
-            const formData = form.getFieldsValue();
-            // 受到只能选七天日期限制
-            const startDate = formData.startDate
-            if (!startDate) {
-                return current > moment().add(1, 'days')
-            }
-            return (
-                current > moment(startDate).add(365, 'days') ||
-                (current && current < moment(startDate).subtract(0, 'days').startOf('day'))
-            )
-        } else {
-            return current > moment().add(0, 'days')
-        }
-    }
-    // function disabledStartDate(startValue) {
-    //     if (!startValue || !endValue) {
-    //         //如果没有选择结束日期,则选择开始日期时,开始日期不能大于今天
-    //         return startValue.valueOf() >= new Date().getTime();//大于今天的日期一律返回true,禁止选择
-    //     }
-    //     //如果选择了结束日期,则结束日期和开始日期之差大于30天(24*60*60*1000*30是30天的毫秒数),还需要开始日期小于结束日期,返回true,禁止选择
-    //     return endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 365 || endValue.valueOf() <= startValue.valueOf();
-    // }
-
-    // function disabledEndDate(endValue) {
-    //     if (!endValue || !startValue) {
-    //         ////如果没有选择开始日期,则结束日期时大于今天
-    //         return endValue.valueOf() >= new Date().getTime();//大于今天的日期一律返回true,禁止选择
-    //     }
-    //     //结束日期这里稍微复杂了一些,如果选择了开始日期,则结束日期和开始日期除了不能超过30个自然日之外,还需要结束日期不能小于开始日期,还需要不能超过今天,返回true为不能选择,所以用或链接,式子之间的符号正好与咱们分析的相反
-    //     return endValue.valueOf() <= startValue.valueOf() || endValue.valueOf() >= new Date().getTime() || endValue.valueOf() - startValue.valueOf() >= 24 * 60 * 60 * 1000 * 365;
-    // }
     //修改
     function showModal(title, row, type) {
         setVisible(true)
@@ -168,12 +108,17 @@ function BlockLossManage() {
     const onFinish = (value) => {
         value.startDate = moment(value.startDate).format('YYYY-MM-DD 00:00:00');
         value.endDate = moment(value.endDate).format('YYYY-MM-DD 23:23:59');
+        if (value.startDate > value.endDate) {
+            message.warning('开始时间不能大于结束时间');
+            return
+        } else if(getDaysBetween(value.startDate, value.endDate)>365){
+            message.warning('开始时间与结束时间相差不能超过一年');
+            return
+        }
         const param = {
             ...data,
             ...value,
         }
-        setIsLimit(false)
-        setIsLimit2(false)
         setCurrent(1)
         setParams(param)
         getBlockLossPage(param);
@@ -182,8 +127,6 @@ function BlockLossManage() {
     const onReset = () => {
         setCurrent(1)
         setParams(data)
-        setIsLimit(false)
-        setIsLimit2(false)
         form.resetFields();
         getBlockLossPage(data);
         blockLossTypeGather(date)
@@ -263,9 +206,8 @@ function BlockLossManage() {
                                 <Form.Item name="startDate" className='times'>
                                     <DatePicker
                                         allowClear={false}
-                                        disabledDate={disabledStartDate}
+                                        disabledDate={disabledDate}
                                         placeholder="请选择开始日期"
-                                        onChange={onStartChange}
                                     />
 
                                 </Form.Item>
@@ -273,9 +215,8 @@ function BlockLossManage() {
                                 <Form.Item name="endDate" className='times'>
                                     <DatePicker
                                         allowClear={false}
-                                        disabledDate={disabledEndDate}
-                                        placeholder="请选择结束始日期"
-                                        onChange={onEndChange}
+                                        disabledDate={disabledDate}
+                                        placeholder="请选择结束日期"
                                     />
                                 </Form.Item>
                             </Form.Item>

+ 29 - 55
src/components/FieldProblem/editProblem.js

@@ -6,27 +6,34 @@ import apiObj from '@api/index';
 import BlockContext from './problem-context';
 import moment from "moment";
 import "moment/locale/zh-cn"
-import { getCookie } from '@utils/index'
+import { getCookie, disabledDate, getDaysBetween } from '@utils/index'
 const { post, api, xPost } = apiObj;
 const { TextArea } = Input;
 function EditBlock(props) {
     useEffect(() => {
     }, []);
     const [form] = Form.useForm();
-    const [startValue, setStartValue] = useState();
-    const [endValue, setendValue] = useState();
     const [disable, setDisable] = useState(true);
     const [limit, setLimit] = useState(false);
     const { problemDetail, type } = useContext(BlockContext);
     const initialValues = problemDetail;
     const onFinish = values => {
+        values.startDate = moment(values.startDate).format('YYYY-MM-DD 00:00:00');
+        values.endDate = moment(values.endDate).format('YYYY-MM-DD 23:23:59');
+        if (values.startDate > values.endDate) {
+            message.warning('开始时间不能大于结束时间');
+            return
+        } else if (!limit && getDaysBetween(values.startDate, values.endDate) > 7) {
+            message.warning('开始时间与结束时间相差不能超过7天');
+            return
+        }
         if (type == 1) {
             dataCheck(values)
         } else {
             editProblem(values)
         }
 
-    };
+    }
 
     function change(e) {
         const formData = form.getFieldsValue();
@@ -43,7 +50,6 @@ function EditBlock(props) {
         }
     }
     function onStartChange(val) {
-        setStartValue(val)
         const formData = form.getFieldsValue();
         if (formData.behospitalCode || (formData.startDate != undefined && formData.endDate != undefined)) {
             setDisable(false)
@@ -52,7 +58,6 @@ function EditBlock(props) {
         }
     }
     function onEndChange(val) {
-        setendValue(val)
         const formData = form.getFieldsValue();
         if (formData.behospitalCode || (formData.startDate != undefined && formData.endDate != undefined)) {
             setDisable(false)
@@ -60,32 +65,6 @@ function EditBlock(props) {
             setDisable(true)
         }
     }
-    function disabledStartDate(startValue) {
-        if (!startValue || !endValue) {
-            //如果没有选择结束日期,则选择开始日期时,开始日期不能大于今天
-            return startValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }
-        //如果选择了结束日期,则结束日期和开始日期之差大于30天(24*60*60*1000*30是30天的毫秒数),还需要开始日期小于结束日期,返回true,禁止选择
-        if(limit){
-            return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }else{
-            return endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 30 || endValue.valueOf() <= startValue.valueOf();
-        }
-    }
-
-    function disabledEndDate(endValue) {
-        if (!endValue || !startValue) {
-            ////如果没有选择开始日期,则结束日期时大于今天
-            return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }
-        if(limit){
-            return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-        }else{
-            return endValue.valueOf() <= startValue.valueOf() || endValue.valueOf() > new Date().getTime() || endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 30;
-        }
-        //结束日期这里稍微复杂了一些,如果选择了开始日期,则结束日期和开始日期除了不能超过30个自然日之外,还需要结束日期不能小于开始日期,还需要不能超过今天,返回true为不能选择,所以用或链接,式子之间的符号正好与咱们分析的相反
-        return endValue.valueOf() <= startValue.valueOf() || endValue.valueOf() > new Date().getTime() || endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 30;
-    }
     function editProblem(values) {
         let params = {
             id: problemDetail.id,
@@ -103,8 +82,6 @@ function EditBlock(props) {
     }
     //数据对比
     function dataCheck(values) {
-        values.startDate = moment(values.startDate).format('YYYY-MM-DD 00:00:00');
-        values.endDate = moment(values.endDate).format('YYYY-MM-DD 23:23:59');
         let params = {
             behospitalCode: values.behospitalCode,
             dateEnd: values.endDate,
@@ -211,7 +188,7 @@ function EditBlock(props) {
                         name="tableVal"
                         label="上传字段值"
                     >
-                        <span>{initialValues.tableVal? initialValues.tableVal.length > 15 ? <span title={initialValues.tableVal}>{initialValues.tableVal.substring(0, 15) + '...'}</span> : initialValues.tableVal : '-'}</span>
+                        <span>{initialValues.tableVal ? initialValues.tableVal.length > 15 ? <span title={initialValues.tableVal}>{initialValues.tableVal.substring(0, 15) + '...'}</span> : initialValues.tableVal : '-'}</span>
                     </Form.Item>
                 </Col>
                 <Col span={12} hidden={type != 3}>
@@ -247,27 +224,24 @@ function EditBlock(props) {
                 <Col span={24} hidden={type == 3}>
                     {type != 3 ?
                         <Form.Item label="日期" >
-                        <Form.Item name="startDate" className='times'>
-                            <DatePicker
-                                allowClear={false}
-                                disabledDate={disabledStartDate}
-                                value={startValue}
-                                placeholder="请选择开始日期"
-                                onChange={onStartChange}
-                            />
+                            <Form.Item name="startDate" className='times'>
+                                <DatePicker
+                                    allowClear={false}
+                                    disabledDate={disabledDate}
+                                    placeholder="请选择开始日期"
+                                    onChange={onStartChange}
+                                />
 
+                            </Form.Item>
+                            <span style={{ margin: '0 5px', position: 'relative', top: '2px' }}>-</span>
+                            <Form.Item name="endDate" className='times'>
+                                <DatePicker
+                                    disabledDate={disabledDate}
+                                    placeholder="请选择结束日期"
+                                    onChange={onEndChange}
+                                />
+                            </Form.Item>
                         </Form.Item>
-                        <span style={{ margin: '0 5px', position: 'relative', top: '2px' }}>-</span>
-                        <Form.Item name="endDate" className='times'>
-                            <DatePicker
-                                allowClear={false}
-                                disabledDate={disabledEndDate}
-                                value={endValue}
-                                placeholder="请选择结束始日期"
-                                onChange={onEndChange}
-                            />
-                        </Form.Item>
-                    </Form.Item>
                         : ''}
                 </Col>
                 <Col span={24} hidden={type == 3} style={{ marginTop: 15 }}>
@@ -289,7 +263,7 @@ function EditBlock(props) {
                         <Button htmlType="button" onClick={e => cancel()}>
                             关闭
                         </Button>
-                        <Button type="primary" htmlType="submit" disabled={disable &&  type == 1}>
+                        <Button type="primary" htmlType="submit" disabled={disable && type == 1}>
                             {type == 1 ? '确定' : '保存'}
                         </Button>
                     </Space>

+ 13 - 73
src/components/FieldProblem/index.js

@@ -1,6 +1,5 @@
 import React, { useState, useEffect, useRef } from 'react';
 import { Form, Input, Button, Table, Row, Col, Select, Modal, DatePicker, Space, message } from 'antd';
-import { getCookie, disabledDate } from '@utils/index'
 import '@common/common.less';
 import moment from "moment";
 import "moment/locale/zh-cn"
@@ -8,7 +7,7 @@ import './index.less'
 import apiObj from '@api/index';
 import EditProblem from './editProblem';
 import ProblemContext from './problem-context';
-import { getValueFromEvent } from '@utils/index'
+import { getCookie,getValueFromEvent, disabledDate, getDaysBetween } from '@utils/index'
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function FieldProblem() {
@@ -21,8 +20,6 @@ function FieldProblem() {
     const [total, setTotal] = useState(0);
     const [type, setType] = useState(0);//1新增 2修改
     const [visible, setVisible] = useState(false);
-    const [isLimit, setIsLimit] = useState(false);
-    const [isLimit2, setIsLimit2] = useState(false);
     const [size, setSize] = useState(15);
     const [current, setCurrent] = useState(1);
     const [probleData, setProbleData] = useState({});
@@ -86,64 +83,6 @@ function FieldProblem() {
     function onSearch(val) {
         getModeName(val)
     }
-    function onStartChange() {
-        setIsLimit2(true)
-    }
-    function onEndChange() {
-        setIsLimit(true)
-    }
-    function disabledStartDate(current) {
-        if (isLimit) {
-            // 受到只能选七天日期限制
-            const formData = form.getFieldsValue();
-            const endDate = formData.behospitalEndDate
-            if (!endDate) {
-                return current && current > Date.now()
-            }
-            return (
-                (current && current < moment(endDate).subtract(364, 'days').startOf('day')) ||
-                current > moment(endDate).add(0, 'days')
-            )
-            
-        } else {
-            return current && current > Date.now()
-        }
-
-    }
-    function disabledEndDate(current) {
-        if (isLimit2) {
-            const formData = form.getFieldsValue();
-            // 受到只能选七天日期限制
-            const startDate = formData.behospitalStartDate
-            if (!startDate) {
-                return current > moment().add(1, 'days')
-            }
-            return (
-                current > moment(startDate).add(365, 'days') ||
-                (current && current < moment(startDate).subtract(0, 'days').startOf('day'))
-            )
-        } else {
-            return current > moment().add(0, 'days')
-        }
-    }
-    // function disabledStartDate(startValue) {
-    //     if (!startValue || !endValue) {
-    //         //如果没有选择结束日期,则选择开始日期时,开始日期不能大于今天
-    //         return startValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-    //     }
-    //     //如果选择了结束日期,则结束日期和开始日期之差大于30天(24*60*60*1000*30是30天的毫秒数),还需要开始日期小于结束日期,返回true,禁止选择
-    //     return endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 365 || endValue.valueOf() <= startValue.valueOf();
-    // }
-
-    // function disabledEndDate(endValue) {
-    //     if (!endValue || !startValue) {
-    //         ////如果没有选择开始日期,则结束日期时大于今天
-    //         return endValue.valueOf() > new Date().getTime();//大于今天的日期一律返回true,禁止选择
-    //     }
-    //     //结束日期这里稍微复杂了一些,如果选择了开始日期,则结束日期和开始日期除了不能超过30个自然日之外,还需要结束日期不能小于开始日期,还需要不能超过今天,返回true为不能选择,所以用或链接,式子之间的符号正好与咱们分析的相反
-    //     return endValue.valueOf() <= startValue.valueOf() || endValue.valueOf() > new Date().getTime() || endValue.valueOf() - startValue.valueOf() > 24 * 60 * 60 * 1000 * 365;
-    // }
-    //修改
     function showModal(title, row, type) {
         setVisible(true)
         setProblemDetail(row)
@@ -182,20 +121,23 @@ function FieldProblem() {
     const onFinish = (value) => {
         value.behospitalStartDate = moment(value.behospitalStartDate).format('YYYY-MM-DD 00:00:00');
         value.behospitalEndDate = moment(value.behospitalEndDate).format('YYYY-MM-DD 23:23:59');
+        if (value.behospitalStartDate > value.behospitalEndDate) {
+            message.warning('开始时间不能大于结束时间');
+            return
+        } else if(getDaysBetween(value.behospitalStartDate, value.behospitalEndDate)>365){
+            message.warning('开始时间与结束时间相差不能超过一年');
+            return
+        }
         const param = {
             ...data,
             ...value,
         }
-        setIsLimit(false)
-        setIsLimit2(false)
         setCurrent(1)
         setParams(param)
         getColumnResultPage(param);
         getColumnResultNumber({ behospitalStartDate: value.behospitalStartDate, behospitalEndDate: value.behospitalEndDate })
     };
     const onReset = () => {
-        setIsLimit(false)
-        setIsLimit2(false)
         setCurrent(1)
         setParams(data)
         form.resetFields();
@@ -245,8 +187,8 @@ function FieldProblem() {
             }
         },
         {
-            title: '更新时间', dataIndex: 'solveTime', key: 'solveTime', render: (text, record) => {
-                return record.solveTime || '-';
+            title: '更新时间', dataIndex: 'gmtModified', key: 'gmtModified', render: (text, record) => {
+                return record.gmtModified || '-';
             }
         },
         {
@@ -280,9 +222,8 @@ function FieldProblem() {
                                 <Form.Item name="behospitalStartDate" className='times'>
                                     <DatePicker
                                         allowClear={false}
-                                        disabledDate={disabledStartDate}
+                                        disabledDate={disabledDate}
                                         placeholder="请选择开始日期"
-                                        onChange={onStartChange}
                                     />
 
                                 </Form.Item>
@@ -290,9 +231,8 @@ function FieldProblem() {
                                 <Form.Item name="behospitalEndDate" className='times'>
                                     <DatePicker
                                         allowClear={false}
-                                        disabledDate={disabledEndDate}
-                                        placeholder="请选择结束始日期"
-                                        onChange={onEndChange}
+                                        disabledDate={disabledDate}
+                                        placeholder="请选择结束日期"
                                     />
                                 </Form.Item>
                             </Form.Item>

+ 8 - 1
src/utils/index.js

@@ -66,7 +66,7 @@ export function getTimeDetail() {
     return str;
 }
 export function getValueFromEvent(e) {
-    return e.target.value.replace(/\s*/g,"");
+    return e.target.value.replace(/\s*/g, "");
 }
 //存取cookie
 export function setCookie(cname, cvalue) {
@@ -103,4 +103,11 @@ export function filterIds(arr, str) {    //arr需遍历的数组;str需拼接
 
 export function disabledDate(current) {
     return current && current >= moment().endOf('day'); // 选择时间要大于等于当前天。若今天不能被选择,去掉等号即可。
+}
+
+export function getDaysBetween(dateString1, dateString2) {
+    var startDate = Date.parse(dateString1)
+    var endDate = Date.parse(dateString2)
+    var days = Math.floor((endDate - startDate) / (1 * 24 * 60 * 60 * 1000))
+    return days
 }