import { message, Checkbox, Radio } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty, onBeforeSaveHandleRecordLog, guid } from "../../utils/common";
import { connect } from 'dva';
import moment from 'moment';
/**
 * @return {string}
 */
// 编辑  制定任务
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
  },
  onBeforeEdit: ({ isNew, stateData, setFieldValue, login }) => {
    let law = 0;
    let system = 0;
    for (let i = 0; i < stateData.Nav_IntegrateDetail?.length; i++) {
      if (stateData.Nav_IntegrateDetail[i].LAW_ID != null) {
        law++;
      }
      if (stateData.Nav_IntegrateDetail[i].SYSTEM_ID != null) {
        system++
      }
    }
    setFieldValue('RATE', (system / law * 100).toFixed(2) + '%')
  },
  onSubChange: ({ colInfo, stateData, setFieldValue }) => {
    if (colInfo.FIELD_NAME == 'Nav_SCSystem.NAME') {
      let law = 0;
      let system = 0;
      for (let i = 0; i < stateData.Nav_IntegrateDetail?.length; i++) {
        if (stateData.Nav_IntegrateDetail[i].LAW_ID != null) {
          law++;
        }
        if (stateData.Nav_IntegrateDetail[i].SYSTEM_ID != null) {
          system++
        }
      }
      stateData.RATE=(system / law * 100).toFixed(2) + '%';
    }
  }
}
