import { message, Checkbox, Radio } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty, onBeforeSaveHandleRecordLog, Format } 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.STATUS = params.customParams;
    onBeforeSaveHandleRecordLog(params, 'OH010', '体检通知前端日志')
  },
  action: ({ }) => {

    debugger

  },

  onSubChange: ({ row, setDataState, pageCode, record, colInfo, dispatch, stateData, props }) => {
    //如果修改原有库 直接填写对应ID 
    // debugger
    // if (record.ISMAINCHANGE == undefined || record.ISMAINCHANGE == null || !record.ISMAINCHANGE) {
    //   var MainId = record.CHECK_MAIN_ID
    //   if (MainId != null && MainId != undefined && MainId.length > 0) {
    //     stateData.Nav_ListSafeCheckDetail[record.ROW_NO - 1].ISMAINCHANGE = true
    //   }
    // }

    if (colInfo.FIELD_NAME == "Nav_ExamBatch.BATCH") {
      //更新选中人员
      let tmp = "";
      var DEPARTMENT_ID_WORKSHOP = record.DEPARTMENT_ID_WORKSHOP
      var DEPARTMENT_ID = record.DEPARTMENT_ID
      var banchRecord = record.Nav_ExamBatch
      //有车间 车间所有的一起同步
      // DEPARTMENT_ID_WORKSHOP
      //没有车间有部门 所有的一起同步 
      // DEPARTMENT_ID
      if (DEPARTMENT_ID_WORKSHOP || DEPARTMENT_ID) {
        for (var x = 0; x < stateData.Nav_ListNoticeRegister.length; x++) {
          let regist = stateData.Nav_ListNoticeRegister[x]
          // let banch = regist.Nav_ExamBatch
          if (!regist.Nav_ExamBatch) {
            if (DEPARTMENT_ID_WORKSHOP && DEPARTMENT_ID_WORKSHOP.length > 0) {
              if (regist.DEPARTMENT_ID_WORKSHOP && regist.DEPARTMENT_ID_WORKSHOP == DEPARTMENT_ID_WORKSHOP) {
                regist.Nav_ExamBatch = banchRecord
                regist.EXAM_BATCH_ID = banchRecord.ID
              }

            } else if (DEPARTMENT_ID && DEPARTMENT_ID.length > 0) {
              if (regist.DEPARTMENT_ID && regist.DEPARTMENT_ID == DEPARTMENT_ID && regist.DEPARTMENT_ID_WORKSHOP == null) {
                regist.Nav_ExamBatch = banchRecord
                regist.EXAM_BATCH_ID = banchRecord.ID
              }
            }
          }


          // if (banch) {
          //   for (let i = 0; i < banch.length; i++) {
          //     if (!banch[i].IS_DELETED) {
          //       if (tmp.indexOf(banch[i].Nav_User.NAME) == -1) {
          //         tmp += (tmp.length > 0 ? "," : "") + banch[i].Nav_User.NAME
          //       }
          //     }
          //   }
          // }
        }
      }
      stateData.CheckUsers = tmp
      setDataState({ ...stateData });

      // } else if (colInfo.FIELD_NAME == "QUESTION_LEVEL") {
      //   if (record.QUESTION_LEVEL == "10") {
      //     stateData.Nav_ListSafeCheckDetail[record.ROW_NO - 1].SERIOUS_RISK = 1
      //   } else {
      //     stateData.Nav_ListSafeCheckDetail[record.ROW_NO - 1].SERIOUS_RISK = 0
      //   }
    }


  },


}
