|
@@ -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>
|