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("Nav_Users", false);
      setFieldVisible("PERFORM_DESCRIPTION", false);
      setFieldVisible("REASON", false);
      setFieldVisible("NOTHROUGH_REASON", false);
    } else {
      //修改
      switch (stateData.PERFORM_STATUS) {
        case 5:
            setFieldVisible("Nav_Users", false);
            setFieldVisible("PERFORM_DESCRIPTION", false);
            setFieldVisible("REASON", true);
          break;
        case 10:
            setFieldVisible("Nav_Users", true);
            setFieldVisible("PERFORM_DESCRIPTION", true);
            setFieldVisible("REASON", false);
          break;
        default:
            setFieldVisible("Nav_Users", false);
            setFieldVisible("PERFORM_DESCRIPTION", false);
            setFieldVisible("REASON", false);
          break;
      }
      if(stateData.STATUS === 40)
      {
        setFieldVisible("NOTHROUGH_REASON", true);
      }
      else
      {
        setFieldVisible("NOTHROUGH_REASON", false);
      }
    }
  },
  onChange: ({ value, colInfo, record, stateData, getFieldValue, setFieldRequired, setFieldVisible, setFieldValue }) => {
    if (colInfo !== null && colInfo.FIELD_NAME === "PERFORM_STATUS") {
      //不需要执行5 需要执行10
      switch (value) {
        case 5:
            setFieldVisible("Nav_Users", false);
            setFieldVisible("PERFORM_DESCRIPTION", false);
            setFieldVisible("REASON", true);
          break;
        case 10:
            setFieldVisible("Nav_Users", true);
            setFieldVisible("PERFORM_DESCRIPTION", true);
            setFieldVisible("REASON", false);
          break;
        default:
            setFieldVisible("Nav_Users", false);
            setFieldVisible("PERFORM_DESCRIPTION", false);
            setFieldVisible("REASON", false);
          break;
      }
    }
  },
}
