/* eslint-disable no-undef */
import {extendInclude, extendRule} from "../../utils/common";
import { Button, Row, Col, Form, Input,Select,Checkbox,Modal,Transfer,Spin ,Table,DatePicker,InputNumber,message,Upload,Icon} from 'antd';

/**
 * @return {string}
 */

export default {
  onChange: ({value,colInfo,getFieldValue,setFieldValue,setFieldEditable,setFieldValueByBatch}) => {
    let maintainStatus=getFieldValue('MAINTAIN_STATUS');
    let startTime=new Date(getFieldValue('START_MAINTAIN_TIME'));
    let completeTime=new Date(getFieldValue('END_MAINTAIN_TIME'));
    if(maintainStatus==1 && (colInfo.FIELD_NAME=='START_MAINTAIN_TIME' || colInfo.FIELD_NAME=='END_MAINTAIN_TIME')) {
      if (true) {
        let diffDay=completeTime.getDate()-startTime.getDate() +1;
        if(diffDay<=0){
          let diffDay=new Date().getDate()-startTime.getDate() +1;
          const temps=[];
          temps.push({field:'REALITY_MAINTAIN_TIME',value:diffDay});
          temps.push({field:'END_MAINTAIN_TIME',value:new Date()});
          setFieldValueByBatch(temps);
          message.error('完成时间需大于等于开始时间');
        }else{
          console.log(diffDay);
          setFieldValue('REALITY_MAINTAIN_TIME',diffDay);
        }
      }
    }

  },
  onFetchAutoFilter:({colInfo,params,getFieldValue,pageCode})=>{


  },
  onBeforeEdit:({isNew,getFieldValue,setFieldValueByBatch,setFieldEditable})=>{
    let maintainStatus=getFieldValue('MAINTAIN_STATUS');
    if(maintainStatus==1){
      const temps=[];
      let startTime=new Date(getFieldValue('START_MAINTAIN_TIME'));
      let diffDay=new Date().getDate()-startTime.getDate() +1;
      temps.push({field:'END_MAINTAIN_TIME',value:new Date()});
      temps.push({field:'REALITY_MAINTAIN_TIME',value:diffDay});
      setFieldValueByBatch(temps);
    }
  },
  onBeforeSave:({data,getFieldValue,setFieldValue})=>{
  },
}
