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("DATA", false);
      setFieldVisible("WEEKDATA", false);
      setFieldVisible("RUNDATA", false);
    } 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;
      }
    } else if (colInfo != null && colInfo.FIELD_NAME == "Nav_CheckTypeLevel.Nav_Enums.NAME") {
      var levelNAME = getFieldValue("Nav_CheckTypeLevel.Nav_Enums.NAME");
      if (levelNAME == null || levelNAME == "") {
        ("PLANCHECKOBJECT", null);
      } else if (levelNAME != null && levelNAME == '班组级') {
        setFieldValue("PLANCHECKOBJECT", 20);
      } else {
        setFieldValue("PLANCHECKOBJECT", 10);
      }
      var checkTypeNAME = getFieldValue('Nav_CheckType.NAME');
      var checkTypeLevel = getFieldValue('Nav_CheckTypeLevel.Nav_Enums.NAME');
      setFieldValue("NAME", (checkTypeLevel == null ? "" : checkTypeLevel) + (checkTypeNAME == null ? "" : checkTypeNAME));
    }
    // else if (colInfo != null && colInfo.FIELD_NAME == "Nav_CheckType.NAME") {
    //   setFieldValue("Nav_CheckTypeLevel.Nav_Enums.NAME", null)
    //   setFieldValue("PLANCHECKOBJECT", null)
    // // } 
  },
  onSubChange: ({ row, pageCode, record, colInfo, dispatch, stateData, props }) => {

    // if (colInfo.FIELD_NAME == "Nav_CheckType.NAME") {
    //   //只要檢查類型修改 清空  項目分類 檢查層級
    //   stateData.Nav_ListContentCheckTypes[0].Nav_CheckProjectCategory = []
    //   stateData.Nav_ListContentCheckTypes[0].Nav_ListContentCheckTypeLevels = []

    //   // if (record.Nav_CheckType.Name) {
    //   // } else {
    //   //   //清空項目分類 檢查層級
    //   // }
    // }

  }
}
