import { message, Checkbox, Radio } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, guid, getDataFieldValue, setDataFieldValue, initFilter, empty, onBeforeSaveHandleRecordLog, Format } from "../../utils/common";
import { connect } from 'dva';
import moment from 'moment';
import SC030 from "./SC030";
/**
 * @return {string}
 */
// 编辑  应急响应评估
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.STATUS = params.customParams;
    onBeforeSaveHandleRecordLog(params, 'CM030', '应急装备需求调查')
  },

  onBeforeEdit: ({ isNew, setFieldValueByBatch, setFieldEditable, login, stateData, dispatch }) => {
    if (isNew) {
      const temps = [];
      temps.push({ field: 'DEPARTMENT_ID', value: login.user.Nav_Department.ID })
      temps.push({ field: 'Nav_Department.NAME', value: login.user.Nav_Department.NAME })
      temps.push({ field: 'USER_ID', value: login.user.ID })
      temps.push({ field: 'Nav_User.NAME', value: login.user.NAME })
      temps.push({ field: 'START_TIME', value: (new Date()).Format("yyyy-MM-dd") })
      setFieldValueByBatch(temps);

    } else {
      if (stateData.DEPARTMENT_ID != null) {
        const temps = [];
        temps.push({ field: 'DEPARTMENT_ID', value: stateData.DEPARTMENT_ID })
        temps.push({ field: 'Nav_Department.NAME', value: stateData.Nav_Department.NAME })
        temps.push({ field: 'USER_ID', value: stateData.USER_ID })
        temps.push({ field: 'Nav_User.NAME', value: stateData.Nav_User.NAME })
        temps.push({ field: 'START_TIME', value: stateData.START_TIME })
        temps.push({ field: 'END_TIME', value: stateData.END_TIME })
        setFieldValueByBatch(temps);
        setFieldEditable("END_TIME", false);
      }
    }

    setFieldEditable("Nav_Department.NAME", false);
    setFieldEditable("Nav_User.NAME", false);
    setFieldEditable("START_TIME", false);
  },
}
