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.PUBLISH = params.customParams;
  },
  onBeforeEdit: ({ isNew, pageCode, login, dispatch, app, updateSubTableData, stateData, setFieldVisible, getFieldValue, setFieldEditable, setFieldValue }) => {
    let s = 0;
    var status = getFieldValue('STATUS');
    if (!isNew && status !== undefined) {
      s = status;
    }
    if (isNew) {
      setFieldVisible("IS_HELP", false);
      setFieldVisible("Nav_Repair_User.NAME", false);
    } else {
      setFieldVisible("IS_HELP", s >= 0);
      setFieldVisible("Nav_Repair_User.NAME", s >= 0);

      setFieldEditable("Nav_Device.NAME", s == 0);
      setFieldEditable("DESCRPTION", s == 0);
      setFieldEditable("EMERGENCY_LEVEL_NAME", s == 0);
      setFieldEditable("Nav_Repair_Charge_User.NAME", s == 0);
      
    }
  },
  onChange: ({ colInfo, getFieldValue, setFieldVisible, dispatch, updateSubTableData }) => {
    if ((colInfo.FIELD_NAME == 'IS_HELP')) {
      let help = getFieldValue('IS_HELP')
      if(help){
        setFieldVisible("Nav_Repair_User.NAME", false);
      }else{
        setFieldVisible("Nav_Repair_User.NAME", true);
      }
    }
  }
}
