import { message } from 'antd'
import { extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty, extendOrder } from "../../utils/common";
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
  },
  onBeforeEdit({ stateData, data, dispatch, setFieldVisible }) {
    if (stateData.STATUS == 9) {
      dispatch({
        type: 'app/getDataByPost',
        url: 'HM/HMHazardRecord/GetRejectContent',
        payload: {
          ID: data.id,
        },
        onComplete: (ret) => {
          if (ret) {
            stateData.AUDIT_OPINION = ret;
          }
        }
      });
    } else {
      setFieldVisible('AUDIT_OPINION', false);
    }
  },
  onSubChange: ({ row, pageCode, record, colInfo, dispatch, stateData, props,saveRowRecord }) => { 
    if (colInfo.FIELD_NAME != 'MODIFY_TYPE') { 
      if(record["MODIFY_TYPE"]==0){
        record["MODIFY_TYPE"] = 1;
      }
      saveRowRecord(record);
    }
    // if (colInfo.FIELD_NAME == 'CODE') { 
    //   let CODE = getDataFieldValue(record, 'CODE');
    //   if(CODE!=null&& CODE.length>1){
    //     const json = initFilter(null, CODE)
    //     dispatch({
    //       type: 'app/getDataByPost',
    //       url: 'HM/HMRiskRecord/searchCode',
    //       payload: json,
    //       onComplete: (ret) => {
    //         if (!ret) {
    //           message.error('输入的编号已重复!');
    //         } 
    //       }
    //     })
    //   }
    // }
  },
}
