import ConfirmButton from '../../components/common/ConfirmButton';
import { message } from 'antd'
import { extendInclude, extendRule, getDataFieldValue, initFilter, empty, extendOrder, guid, getSubTableData } from "../../utils/common";
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.OPERATETYPE = params.customParams;
  },
  onBeforeEdit: ({ isNew, stateData, setFieldVisible, setFieldValue, setRowFieldVisible, setFieldValueByBatch, updateSubTableData }) => {
    if (stateData.SUBMIT_TYPE == undefined || stateData.SUBMIT_TYPE == 10) {
      //检查上报  隐藏 属性： 检查类型  检查层级    子表：检查项目  检查项目分类
      setFieldVisible("Nav_Submit.Nav_CheckType.NAME", false)
      setFieldVisible("Nav_Submit.Nav_CheckTypeLevel.Nav_Enums.NAME", false)
      if (stateData.Nav_ListRiskSubmitContent[0].CHECK_PROJECT_ID == null || stateData.Nav_ListRiskSubmitContent[0].CHECK_PROJECT_ID == undefined || stateData.Nav_ListRiskSubmitContent[0].CHECK_PROJECT_CATEGORY_ID == null || stateData.Nav_ListRiskSubmitContent[0].CHECK_PROJECT_CATEGORY_ID == undefined) {
        // setRowFieldVisible("T_BS_RISK_SUBMIT_CONTENT", { "Nav_CheckProjectCategory.NAME": false })
      } else {
        setRowFieldVisible("T_BS_RISK_SUBMIT_CONTENT", { "Nav_CheckProject.NAME": false, "Nav_CheckProjectCategory.NAME": false })
      }
    }

    var list = stateData.Nav_ListRiskSubmitContent;
    //显示驳回信息
    if (list != null && list.length == 1 && list[0].CHECK_USER_REFUSED_REASON != null && list[0].CHECK_USER_REFUSED_REASON.length > 0) {
      setFieldValue("CHECK_USER_REFUSED_REASON", list[0].Nav_UserCheck.NAME + "（" + list[0].CHECK_USER_REFUSED_REASON + ")")
    } else if (list != null && list.length == 1 && list[0].DEAL_USER_REFUSED_REASON != null && list[0].DEAL_USER_REFUSED_REASON.length > 0) {
      setFieldValue("CHECK_USER_REFUSED_REASON", list[0].Nav_UserDeal.NAME + "（" + list[0].DEAL_USER_REFUSED_REASON + ")")
    } else {
      setFieldVisible("CHECK_USER_REFUSED_REASON", false)
    }
  },
  // 隐患通知
  // 控制 整改期限  小于系统整改期限
  onSubChange: ({ row, pageCode, record, colInfo, dispatch, stateData, props }) => {

    if (colInfo.FIELD_NAME == "LastDateUser") {
      if (record.LastDateUser > record.LastDateSystem) {
        message.error('整改期限不能大于系统整改期限！');
      }
    } else if (colInfo.FIELD_NAME == "Nav_UserCheck.NAME") {
      if (stateData.Nav_ListRiskSubmitContent != null && stateData.Nav_ListRiskSubmitContent.length == 1 && stateData.Nav_ListRiskSubmitContent[0].CHECK_USER_REFUSED_REASON != null && stateData.Nav_ListRiskSubmitContent[0].CHECK_USER_REFUSED_REASON.length > 0) {
        stateData.Nav_ListRiskSubmitContent[0].CHECK_USER_REFUSED_REASON = ''
      }
    }
    // else if (colInfo.FIELD_NAME == "Nav_DepartmentDeal.NAME") {
    //   // DEAL_USER_ID,Nav_UserDeal.ID,Nav_UserDeal.NAME
    //   // ID,ID,NAME
    // }
  },
}
