import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty,extendOrder, guid } from "../../utils/common";
import { connect } from 'dva';
/**
 * @return {string}
 */
// 编辑
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
  },
  onSubChange: ({ row, pageCode, record, colInfo, dispatch, stateData, props,saveRowRecord }) => {
    // if (colInfo.FIELD_NAME == 'RISK_TYPE') {
    //   let riskType = getDataFieldValue(record, 'RISK_TYPE');
    //   if (riskType == 0 || riskType == 1) {
    //     const json = initFilter();
    //     extendRule(json, 'RISK_TYPE', 1, riskType);
    //     extendOrder(json, 'CODE', 0);
    //     dispatch({
    //       type: 'app/getDataByPost',
    //       url: 'HM/Identifying/OrderEntities',
    //       payload: json,
    //       onComplete: (ret) => {
    //         if (ret) {
    //           let identifyings = [];
    //           if (ret && ret.length > 0) {
    //             ret.forEach(item => {
    //               let objIdentifying = {
    //                 DETAIL_ID: record.ID,
    //                 ID: guid(),
    //                 IDENTIFYING_ID: item.ID,
    //                 Nav_Identifying: { "NAME": item.NAME },
    //                 ORG_ID: record.ORG_ID,
    //               }
    //               identifyings.push(objIdentifying);
    //             })
    //           }
    //           record["Nav_Identifyings"] = identifyings;
    //           console.log(record)
    //           saveRowRecord(record)
    //         }
    //       }
    //     })
    //   } else {
    //     record.Nav_Identifyings = [];
    //     saveRowRecord(record)
    //   }
    // }
  },
  onBeforeEdit: ({ isNew, stateData, setFieldEditable, setFieldVisible, setFieldRequired }) => {
    if (stateData.STATUS == 9) {
      setFieldVisible('AUDIT_OPINION', true);
    } else {
      setFieldVisible('AUDIT_OPINION', false);
    }
  },
  syncData: ({ row, pageCode, record, colInfo, dispatch, stateData, props, getSelectedRecords ,saveRowRecord}) => {
    let DetailCheck = getSelectedRecords();
    if (DetailCheck && DetailCheck.length > 1) {
      let start = DetailCheck[0].START_TIME;
      let end = DetailCheck[0].END_TIME
      for (let i = 1; i < DetailCheck.length; i++) {
        DetailCheck[i].START_TIME = start;
        DetailCheck[i].END_TIME = end;
      }
    }
  },
}
