import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty } from "../../utils/common";
import { connect } from 'dva';
import moment from 'moment';
/**
 * @return {string}
 */
// 编辑
export default {
  onBeforeEdit: ({ stateData,record, isNew, getFieldValue, setFieldValueByBatch, setFieldEditable,login,dispatch }) => {
      if(isNew){
        setDataFieldValue(stateData, 'COMPLETION_TIME', moment().format('YYYY-MM-DD HH:mm:ss'));
        setDataFieldValue(stateData, 'DEPARTMENT_ID', login.user.DEPARTMENT_ID);
        let json = initFilter(login.OrgId);
        extendRule(json, 'ID', 1, login.user.DEPARTMENT_ID);
        dispatch({
          type: 'app/getDataByPost',
          url: 'FM/Department/Get',
          payload: json,
          onComplete: (ret) => {
            if (ret) {
              setDataFieldValue(stateData, 'Nav_Department', ret);
            }
          }
        })
      }
  },
}
