/* eslint-disable no-undef */
import {extendInclude, extendRule, initFilter} from "../../utils/common";
import moment from 'moment';

/**
 * @return {string}
 */

export default {
  onChange: ({value,colInfo,getFieldValue,setFieldValue,setFieldEditable}) => {


  },
  onFetchAutoFilter:({colInfo,params,getFieldValue})=>{

  },
  onBeforeEdit:({isNew,getFieldValue,login,dispatch,setFieldValueByBatch,setFieldEditable,stateData})=>{
    if(isNew) {
      const json = initFilter(login.OrgId);
      json.Count = 1;
      json.CodeType = 3501

      dispatch({
        type: 'app/genSystemCode',
        payload: json,
        onComplete: (ret) => {
         //console.log(stateData);
         // console.log(login);
          if (ret) {
            const temps=[];
            temps.push({field:'CODE',value: ret});
            temps.push({field:'Nav_User.NAME',value: login.user.NAME});
            temps.push({field:'USER_ID',value:login.userId});
            setFieldValueByBatch(temps);
            // stateData.Nav_OrderDetail.forEach((n)=>{
            //   n['ARRIVAL_TIME']=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
            // })
            //temps.push({field:'Nav_OrderDetail.ARRIVAL_TIME',value:moment(new Date()).format('YYYY-MM-DD HH:mm:ss')});
          }
        }
      })

    }
  },
  onBeforeSave:({data,getFieldValue,setFieldValue})=>{
  },
  onAfterAddSubRow:({record,srcRow,pageCode})=>{
    record['ARRIVAL_TIME']=moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
  }
}
