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 {

  onBeforeEdit: ({ isNew, stateData, setFieldVisible }) => {
    // 控制控件显示 / 隐藏
    if (isNew) {
      //新增
      setFieldVisible("POLICY_DATETIME", true);
      setFieldVisible("TARGET_DATETIME", true);
      setFieldVisible("MONTH", false);
      setFieldVisible("DATA", false);
      setFieldVisible("WEEKDATA", false);
    } else {
      //修改
      switch (stateData.PLANCHECKFREQUENCY) {
        case 0:
          setFieldVisible("POLICY_DATETIME", true);
          setFieldVisible("TARGET_DATETIME", true);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          break;
        // case 5:
        //   setFieldVisible("POLICY_DATETIME", false);
        //   setFieldVisible("TARGET_DATETIME", false);
        //   setFieldVisible("MONTH", true);
        //   setFieldVisible("DATA", true);
        //   setFieldVisible("WEEKDATA", false);
        //   break;
        case 10:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          break;
        case 20:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", true);
          break;
        case 30:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          break;
        case 40:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", true);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          break;
        case 50:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", true);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          break;
        case 60:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", true);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          break;
        default:
          setFieldVisible("POLICY_DATETIME", true);
          setFieldVisible("TARGET_DATETIME", true);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", 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 0:
          setFieldVisible("POLICY_DATETIME", true);
          setFieldVisible("TARGET_DATETIME", true);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          // setFieldVisible("RUNDATA", true);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        // case 5:
        //   setFieldVisible("POLICY_DATETIME", false);
        //   setFieldVisible("TARGET_DATETIME", false);
        //   setFieldVisible("MONTH", true);
        //   setFieldVisible("DATA", true);
        //   setFieldVisible("WEEKDATA", false);
        //   // setFieldVisible("RUNDATA", true);
        //   setFieldValue("MONTH", null);
        //   setFieldValue("WEEKDATA", null);
        //   setFieldValue("DATA", null);
        //   setFieldValue("RUNDATA", null);
        //   setFieldValue("POLICY_DATETIME", null);
        //   setFieldValue("TARGET_DATETIME", null);
        //   break;
        case 10:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        case 20:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", true);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        case 30:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        case 40:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", true);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        case 50:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", true);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        case 60:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", true);
          setFieldVisible("DATA", true);
          setFieldVisible("WEEKDATA", false);
          // setFieldVisible("RUNDATA", true);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
        default:
          setFieldVisible("POLICY_DATETIME", false);
          setFieldVisible("TARGET_DATETIME", false);
          setFieldVisible("MONTH", false);
          setFieldVisible("DATA", false);
          setFieldVisible("WEEKDATA", false);
          setFieldValue("MONTH", null);
          setFieldValue("WEEKDATA", null);
          setFieldValue("DATA", null);
          setFieldValue("RUNDATA", null);
          setFieldValue("POLICY_DATETIME", null);
          setFieldValue("TARGET_DATETIME", null);
          break;
      }
    }
  },
}
