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,stateData,setFieldVisible,setFieldEditable,login}) {
    let s = 0;
    if (!isNew && stateData && stateData.STATUS !== undefined) {
      s = stateData.STATUS;
    }
    setFieldVisible("START_TIME", s >= 0);
    setFieldVisible("Nav_User.NAME", s >= 0);
    setFieldVisible("Nav_LaunchDepartment.NAME", s >= 0);
    setFieldVisible("NAME", s >= 0);
    setFieldVisible("Nav_ItemEnum.NAME", s >= 0);
    setFieldVisible("DESCRIPTION", s >= 0);
    setFieldVisible("Nav_FileList", s >= 0);
    setFieldVisible("Nav_Assignee.NAME", s >= 1);
    setFieldVisible("ASSIGNEE_STATUS", s >= 1);
    setFieldVisible("ASSIGNEE_DESCRIPTION", s >= 1);
    setFieldVisible("Nav_DoDepartment.NAME", s >= 1);
    setFieldVisible("Nav_DoUser.NAME", s >= 1);
    setFieldVisible("IMPLEMENT_DESCRIPTION", s >= 2);
    setFieldVisible("Nav_ImpFileList", s >= 2);
    setFieldVisible("SATISFACTION_STATUS", s >= 3);
    let curUid = login.user.ID;
    let launchUid = stateData && stateData.USER_ID ? stateData.USER_ID : null;
    let acceptUid = stateData && stateData.ASSIGNEE_ID ? stateData.ASSIGNEE_ID : null;
    let doUid = stateData && stateData.DO_USER_ID ? stateData.DO_USER_ID : null;
    setFieldEditable("START_TIME", false);
    setFieldEditable("Nav_User.NAME", false);
    setFieldEditable("Nav_LaunchDepartment.NAME", false);
    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);
    setFieldEditable("Nav_Assignee.NAME", false);
    setFieldEditable("ASSIGNEE_STATUS", s === 1 && (curUid === acceptUid));
    setFieldEditable("ASSIGNEE_DESCRIPTION", s === 1 && (curUid === acceptUid));
    setFieldEditable("Nav_DoDepartment.NAME", s === 1 && (curUid === acceptUid));
    setFieldEditable("Nav_DoUser.NAME", s === 1 && (curUid === acceptUid));
    setFieldEditable("IMPLEMENT_DESCRIPTION", s === 2 && (curUid === doUid));
    setFieldEditable("Nav_ImpFileList", s>=0);
    setFieldEditable("SATISFACTION_STATUS", s === 3 && (curUid === launchUid));
  }
}
