import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, guid } from "../../utils/common";
import moment from 'moment';
import { Button, Row, Col, Form, Input, Select, Upload, Icon, Modal, Spin,Table } from 'antd';
/**
 * @return {string}
 */
// 编辑
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
    // params.record.FORM_CODE = params.data.reloadKey.substring(0,params.data.reloadKey.indexOf("_"));
  },
  onBeforeEdit: ({ isNew,login, dispatch,stateData, setFieldVisible,setFieldValueByBatch }) => {
    if (isNew) {
        let json = initFilter(login.OrgId);
        dispatch({
            type: 'app/getDataByPost',
            url: 'PR/PRSurveyRecord/GetRecordDetail',
            payload: json,
          onComplete: (ret) => {
            if (ret) {
              let temps = [];
  
              let detail = ret.Nav_Details.map((item, i) => {
                item['ROW_NO'] = i + 1;
                return item;
              });
              temps.push({ field: 'TYPE', value: ret.TYPE })
              temps.push({ field: 'PARAMETER', value: ret.PARAMETER})
              temps.push({ field: 'VALUE', value: ret.VALUE})
              temps.push({ field: 'Nav_Details', value: detail })
              setFieldValueByBatch(temps);
            }
          }
        });
        // let jsonUser = initFilter(login.OrgId);
        // extendRule(jsonUser, "ID", 1, login.userId);
        // dispatch({
        //     type: 'app/getDataByPost',
        //     url: 'FM/User/Get',
        //     payload: json,
        //   onComplete: (ret) => {
        //     if (ret) {
        //         let temps = [];
        //         temps.push({ field: 'Nav_Users.Nav_User', value: ret })
        //       setFieldValueByBatch(temps);
        //     }
        //   }
        // });
      }
  }
}
