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');
    var curUid = login.user.ID;
    var launchUid = getFieldValue('USER_ID');
    var acceptUid = getFieldValue('ASSIGNEE_ID');
    var doUid = getFieldValue('SURVEY_USER_ID');
    if (!isNew && status !== undefined) {
      s = status;
    }
    if (isNew) {
      setFieldVisible("START_TIME", false);
      setFieldVisible("Nav_User.NAME", false);
    } else {
      setFieldVisible("START_TIME", s >= 0);
      setFieldVisible("Nav_User.NAME", s >= 0);
      setFieldEditable("START_TIME", false);
      setFieldEditable("Nav_User.NAME", false);
    }
    setFieldVisible("Nav_ExternalContactDetail.NAME", s >= 0);
    setFieldVisible("NAME", s >= 0);
    setFieldVisible("Nav_ItemEnum.NAME", s >= 0);
    setFieldVisible("DESCRIPTION", s >= 0);
    setFieldVisible("Nav_FileList", s >= 0);
    setFieldVisible("Nav_Department.NAME", s >= 1);
    setFieldVisible("Nav_Assignee.NAME", s >= 1);
    setFieldVisible("ASSIGNEE_STATUS", s >= 1);
    setFieldVisible("ASSIGNEE_DESCRIPTION", s >= 1);
    setFieldVisible("Nav_SurveyDepartment.NAME", s >= 1);
    setFieldVisible("Nav_SurveyUser.NAME", s >= 1);
    setFieldVisible("SURVEY_DESCRIPTION", s >= 2);
    setFieldVisible("Nav_SurveyFileList", s >= 2);
    setFieldVisible("SATISFACTION_STATUS", s >= 3);

    setFieldEditable("Nav_ExternalContactDetail.NAME", s == 0 && (!launchUid || curUid === launchUid));
    setFieldEditable("NAME", s == 0 && (!launchUid || curUid === launchUid));
    setFieldEditable("Nav_ItemEnum.NAME", s == 0 && (!launchUid || curUid === launchUid));
    setFieldEditable("DESCRIPTION", s == 0 && (!launchUid || curUid === launchUid));
    setFieldEditable("Nav_FileList", s == 0 && (!launchUid || curUid === launchUid));
    setFieldEditable("Nav_Department.NAME", false);
    setFieldEditable("Nav_Assignee.NAME", false);
    setFieldEditable("ASSIGNEE_STATUS", s === 1 && (curUid === acceptUid));
    setFieldEditable("ASSIGNEE_DESCRIPTION", s === 1 && (curUid === acceptUid));
    setFieldEditable("Nav_SurveyDepartment.NAME", s === 1 && (curUid === acceptUid));
    setFieldEditable("Nav_SurveyUser.NAME", s === 1 && (curUid === acceptUid));
    setFieldEditable("SURVEY_DESCRIPTION", s === 2 && (curUid === doUid));
    setFieldEditable("Nav_SurveyFileList", s === 2 && (curUid === doUid));
    setFieldEditable("SATISFACTION_STATUS", s === 3 && (curUid === launchUid));
  },
}
