import ConfirmButton from '../../components/common/ConfirmButton';
import { message } from 'antd';
import { extendInclude, extendRule, getDataFieldValue, initFilter, empty, extendOrder, guid, auditOptionShow2 } from "../../utils/common";
import moment from 'moment';
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.OPERARTETYPE = params.customParams;
  },
  //隐患整改记录编辑
  onBeforeEdit: ({ isNew, login, stateData, setFieldEditable, setFieldVisible, setFieldValue, dispatch, ListCheckRiskArea, updateSubTableData }) => {
    auditOptionShow2(stateData, stateData.DEALSITUATION, 3, "AUDIT_OPINION", stateData.APPROVE_ID, dispatch, setFieldVisible)

    if (stateData.DEALSITUATION == 5) {
      stateData.DEALSITUATION = ""
    }
    if (stateData.ENDDATE == null) {
      stateData.ENDDATE = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
    }
    // 如果整改责任人 未签名  
    // 如果整改责任人有签名  显示 验收信息 验收时间为当前时间
    // if (stateData.Nav_ListUserSign == undefined || stateData.Nav_ListUserSign.length < 1) {
    if (stateData.ISDEALSIGN == false) {
      setFieldVisible('CHCECKTIME', false)
      setFieldVisible('Nav_ListCheckUserSign', false)
      if (stateData.DEALSITUATION == 3 || stateData.DEALOPINION == null || stateData.DEALOPINION.length < 1) {
        setFieldVisible('DEALOPINION', false)
        setFieldVisible('CHECKOPINION', false)
      }

      setFieldVisible('DEALSITUATION', false)
      //如果 整改责任人 没有签字 并且 登录者不是整改责任人 整改责任人签字隐藏
      if (login.userId != stateData.DEAL_USER_ID) {
        setFieldVisible('Nav_ListUserSign', false)
      }
    } else {
      setFieldValue('CHCECKTIME', moment(new Date()).format('YYYY-MM-DD HH:mm:ss'))
      setFieldEditable("Nav_UserActualDeal.NAME", false)//整改落实人不可编辑
    }

    // 整改责任人 签名 
    if (!stateData.ISDEALSIGN)
      setFieldVisible('Nav_ListUserSign', false)
    if (!stateData.ISCHECKSIGN)
      setFieldVisible('Nav_ListCheckUserSign', false)

  },
}
