import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty } from "../../utils/common";
import { connect } from 'dva';
/**
 * @return {string}
 */
// 编辑  制定任务
export default {

  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.STATUS_APPROVE = params.customParams;
    // onBeforeSaveHandleRecordLog(params, 'DM010', '设备点检')
  },

  onBeforeEdit: ({ isNew, stateData, setFieldVisible, setFieldValue }) => {
    // 控制控件显示 / 隐藏
    if (isNew) {
      //新增
      setFieldVisible("DATA", false);
      setFieldVisible("WEEKDATA", false);
      setFieldVisible("RUNDATA", false);
      setFieldValue("YEARPLAN", (new Date()).Format("yyyy"));
    } else {
      //修改
      switch (stateData.PLANCHECKFREQUENCY) {
        // case 5:
        //   setFieldVisible("DATA", false);
        //   setFieldVisible("WEEKDATA", false);
        //   setFieldVisible("RUNDATA", true);
        //   break;
        case 10:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", false);
          break;
        case 20:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", true);
          setFieldVisible("RUNDATA", false);
          break;
        case 30:
        case 40:
        case 50:
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", false);
          break;
        case 60:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", true);
          break;
        default:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", false);
          break;
      }
    }
  },
  onChange: ({ value, colInfo, record, stateData, data, getFieldValue, setFieldVisible, setFieldValue }) => {
    if (colInfo != null && colInfo.FIELD_NAME == "PLANCHECKFREQUENCY") {
      //单次5 每天10  每周20 每月30  每季40
      switch (value) {
        // case 5:
        //   setFieldVisible("DATA", false);
        //   setFieldVisible("WEEKDATA", false);
        //   setFieldVisible("RUNDATA", true);
        //   setFieldValue("WEEKDATA", null);
        //   setFieldValue("DATA", null);
        //   setFieldValue("RUNDATA", null);
        //   break;
        case 10:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", false);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          break;
        case 20:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", true);
          setFieldVisible("RUNDATA", false);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          break;
        case 30:
        case 40:
        case 50:
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", false);
          setFieldValue("WEEKDATA", null);
          setFieldValue("RUNDATA", null);
          break;
        case 60:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", true);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          break;
        default:
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldVisible("RUNDATA", false);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          break;
      }
    }
  }
}
