import ConfirmButton from '../../components/common/ConfirmButton';
import { message } from 'antd'
import { extendInclude, extendRule, getDataFieldValue, initFilter, empty, extendOrder, guid, getSubTableData, auditOptionShow } from "../../utils/common";
export default {
  onBeforeSaveHandleRecord(params) {
    // params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.OPERARTETYPE = params.customParams;
    params.record.TaskID = params.data.TaskID
  },

  // onBeforeEdit({params}) {
  // var dealId = params.data.id
  //隐患内容 如果有值 不可编辑 Nav_SubmitContent.NAME 
  onBeforeEdit: ({ isNew, stateData, dispatch, setFieldVisible }) => {
    // var dealId = params.data.id
    // debugger
    if (!isNew) {
      auditOptionShow(stateData, stateData.OPERARTETYPE, 50, 'AUDIT_OPINION', stateData.ID, dispatch, setFieldVisible)// 驳回
    } else {
      setFieldVisible("AUDIT_OPINION", false)
    }
  },

  //延期后整改期限应该大于申请延期期限！
  onChange: ({ dispatch, colInfo, getFieldValue, setFieldValueByBatch }) => {
    if (colInfo.FIELD_NAME == "Nav_SubmitNoticePerson.NAME") {
      var noticeId = getFieldValue("RISK_SUBMIT_NOTICE_PERSON_ID");
      if (noticeId == null || noticeId == '') {
        let temps = [];
        temps.push({ field: "Nav_ListApplyDetail", value: null });
        setFieldValueByBatch(temps);
      } else {
        var orgId = colInfo.ORG_ID;   //登录后有存储登录信息
        let json = initFilter(orgId, noticeId);
        dispatch({
          type: 'app/getDataByPost',
          url: 'BS/BSRiskSubmitDelayApply/GetNoticePersonCanDelayContent',
          payload: json,
          onlyData: false,
          onComplete: (ret) => {
            let temps = [];
            if (ret && ret.IsSuccessful && ret.Data) {
              let detail = ret.Data.map((item, i) => {
                item['ROW_NO'] = i + 1;
                return item;
              });
              temps.push({ field: "Nav_ListApplyDetail", value: detail });
            } else {
              temps.push({ field: "Nav_ListApplyDetail", value: null });
            }
            setFieldValueByBatch(temps);
          }
        });
      }
    }
  },
  onSubChange: ({ row, pageCode, record, colInfo, getSubFieldValue, dispatch, stateData, props }) => {
    if (colInfo.FIELD_NAME == "LastDateApply") {
      if (record.LastDateApply != "" && record.LastDateApply < record.LastDate) {
        message.error("延期后整改期限应该大于申请延期期限！")
      }
    }
  },

}
