/* eslint-disable no-undef */
import {extendInclude, extendRule, getDataFieldValue} 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}) => {
    let maintainStatus=getFieldValue('MAINTAIN_STATUS');
    let startTime=new Date(getFieldValue('START_MAINTAIN_TIME'));
    let completeTime=new Date(getFieldValue('PREDICT_COMPLETE_TIME'));
    if(maintainStatus==0 && (colInfo.FIELD_NAME=='START_MAINTAIN_TIME' || colInfo.FIELD_NAME=='PREDICT_COMPLETE_TIME')) {
      if (true) {
        let diffDay=completeTime.getDate()-startTime.getDate() +1;
        if(diffDay<=0){
          diffDay=new Date().getDate()-startTime.getDate() +1;
          const temps=[];
          temps.push({field:'PREDICT_MAINTAIN_TIME',value:diffDay});
          temps.push({field:'PREDICT_COMPLETE_TIME',value:new Date()});
          setFieldValueByBatch(temps);
          
          //setFieldValue('PREDICT_MAINTAIN_TIME',diffDay);
          //setFieldValue('PREDICT_COMPLETE_TIME',new Date().getDate());
          message.error('预计时间大于等于开始时间');
        }else{
          setFieldValue('PREDICT_MAINTAIN_TIME',diffDay);
        }
      }
    }
  },
  onFetchAutoFilter:({colInfo,params,getFieldValue,pageCode})=>{

  },
  onBeforeEdit:({stateData,isNew,getFieldValue,setFieldValueByBatch,setFieldEditable})=>{
    console.log(stateData);
   let maintainStatus=getFieldValue('MAINTAIN_STATUS');
    if(maintainStatus==0){
      const temps=[];
      temps.push({field:'START_MAINTAIN_TIME',value:new Date()})
      temps.push({field:'PREDICT_COMPLETE_TIME',value:new Date()})
      setFieldValueByBatch(temps);
   }
  },
  onBeforeSave:({data,getFieldValue,setFieldValue})=>{
  },
}
