import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, guid } from "../../utils/common";
import moment from 'moment';
import { Button, Row, Col, Form, Input, Select, Upload, Icon, Modal, Spin,Table } from 'antd';
/**
 * @return {string}
 */
// 编辑
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
    // params.record.FORM_CODE = params.data.reloadKey.substring(0,params.data.reloadKey.indexOf("_"));
  },
  onBeforeEdit: ({ isNew, stateData, setFieldVisible,setFieldValue,setFieldRequired }) => {
    // 控制控件显示 / 隐藏
    if (isNew) {
      //新增
      setFieldVisible("PLACE", false);
      setFieldVisible("DESCRIPTION", false);
      setFieldVisible("IS_DEAL", false);
      setFieldVisible("IS_HELP", false);
      setFieldVisible("REASON", false);
      setFieldVisible("MEASURES", false);
      setFieldVisible("IS_RELIABLE", false);
      setFieldVisible("OPINION", false);
      setFieldValue("IS_DEAL", 0);
      setFieldValue("IS_HELP", 0);
      setFieldValue("IS_RELIABLE", 0);
    } else {
      //修改
      switch (stateData.MONITOR_STATUS) {
        case 5:
      setFieldVisible("PLACE", false);
      setFieldVisible("DESCRIPTION", false);
      setFieldVisible("IS_DEAL", false);
      setFieldVisible("IS_HELP", false);
      setFieldVisible("REASON", false);
      setFieldVisible("MEASURES", false);
      setFieldVisible("IS_RELIABLE", false);
      setFieldVisible("OPINION", false);
      setFieldValue("IS_DEAL", 0);
      setFieldValue("IS_HELP", 0);
      setFieldValue("IS_RELIABLE", 0);
          break;
        case 10:
      setFieldVisible("PLACE", true);
      setFieldVisible("DESCRIPTION", true);
      setFieldVisible("IS_DEAL", true);
      setFieldVisible("IS_HELP", true);
      setFieldVisible("REASON", true);
      setFieldVisible("MEASURES", true);
      setFieldVisible("IS_RELIABLE", true);
      setFieldVisible("OPINION", true);
      setFieldRequired("PLACE",true);
      setFieldRequired("DESCRIPTION",true);
      setFieldRequired("IS_DEAL",true)
          break;
        default:
      setFieldVisible("PLACE", false);
      setFieldVisible("DESCRIPTION", false);
      setFieldVisible("IS_DEAL", false);
      setFieldVisible("IS_HELP", false);
      setFieldVisible("REASON", false);
      setFieldVisible("MEASURES", false);
      setFieldVisible("IS_RELIABLE", false);
      setFieldVisible("OPINION", false);
      setFieldValue("IS_DEAL", 0);
      setFieldValue("IS_HELP", 0);
      setFieldValue("IS_RELIABLE", 0);
          break;
      }
    }
  },
  onChange: ({ value, colInfo, record, stateData, getFieldValue, setFieldRequired, setFieldVisible, setFieldValue }) => {
    if (colInfo !== null && colInfo.FIELD_NAME === "MONITOR_STATUS") {
      //正常5 不正常10
      switch (value) {
        case 5:
      setFieldVisible("PLACE", false);
      setFieldVisible("DESCRIPTION", false);
      setFieldVisible("IS_DEAL", false);
      setFieldVisible("IS_HELP", false);
      setFieldVisible("REASON", false);
      setFieldVisible("MEASURES", false);
      setFieldVisible("IS_RELIABLE", false);
      setFieldVisible("OPINION", false);
      setFieldValue("IS_DEAL", 0);
      setFieldValue("IS_HELP", 0);
      setFieldValue("IS_RELIABLE", 0);
          break;
        case 10:
            setFieldVisible("PLACE", true);
      setFieldVisible("DESCRIPTION", true);
      setFieldVisible("IS_DEAL", true);
      setFieldVisible("REASON", true);
      setFieldVisible("IS_HELP", false);
      setFieldVisible("MEASURES", false);
      setFieldVisible("IS_RELIABLE", false);
      setFieldVisible("OPINION", false);
      setFieldRequired("PLACE",true);
      setFieldRequired("DESCRIPTION",true);
      setFieldRequired("IS_DEAL",true)
      setFieldRequired("REASON",true);
          break;
        default:
            setFieldVisible("PLACE", false);
            setFieldVisible("DESCRIPTION", false);
            setFieldVisible("IS_DEAL", false);
            setFieldVisible("IS_HELP", false);
            setFieldVisible("REASON", false);
            setFieldVisible("MEASURES", false);
            setFieldVisible("IS_RELIABLE", false);
            setFieldVisible("OPINION", false);
            setFieldValue("IS_DEAL", 0);
            setFieldValue("IS_HELP", 0);
                setFieldValue("IS_RELIABLE", 0);
          break;
      }
    }
    if(colInfo !== null && colInfo.FIELD_NAME === "IS_DEAL")
    {
        let dealValue=getFieldValue("IS_DEAL");
        if(dealValue === 0)
        {
          setFieldRequired("REASON",true);
          setFieldVisible("REASON", true);
          setFieldVisible("IS_HELP", false);
          setFieldVisible("MEASURES", false);
          setFieldVisible("IS_RELIABLE", false);
          setFieldVisible("OPINION", false);
          setFieldValue("IS_HELP", 0);
          setFieldValue("IS_RELIABLE", 0);
        }
        else
        {
          setFieldVisible("REASON", false);
          setFieldRequired("REASON",false);
          setFieldVisible("IS_HELP", true);
          setFieldRequired("IS_HELP",true);
        }
    }
    if(colInfo !== null && colInfo.FIELD_NAME === "IS_HELP")
    {
        let dealValue=getFieldValue("IS_HELP");
        if(dealValue === 0)
        {
          setFieldVisible("MEASURES", false);
          setFieldVisible("IS_RELIABLE", false);
          setFieldVisible("OPINION", false);
          setFieldValue("IS_RELIABLE", 0);
        }
        else
        {
          setFieldVisible("MEASURES", true);
          setFieldVisible("IS_RELIABLE", true);
          setFieldVisible("OPINION", true);
          setFieldRequired("MEASURES", true);
          setFieldRequired("IS_RELIABLE", true);
          setFieldRequired("OPINION", true);
        }
    }
  },
}
