import { routerRedux } from 'dva/router';
import * as flowPermitEditService from '../../services/PF/flowPermitEdit';

export default {

  namespace: 'PFFlowPermitEdit',
  state: {
  },

  subscriptions: {
    setup({ dispatch, history }) {  // eslint-disable-line

    },
  },

  effects: {
    *getFlow ({ payload,onComplete }, { call, put }) {
      const ret = yield call(flowPermitEditService.getFlow, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(flowPermitEditService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *permitFlow ({ payload, onComplete }, { call, put}) {
      const ret = yield call(flowPermitEditService.permitFlow, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getOperHistoryList ({ payload, onComplete }, { call, put}) {
      const ret = yield call(flowPermitEditService.getOperHistoryList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },

  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    },
  },

};
