/**
 * Created by zhouhuan on 2017/10/30.
 */
import { getData, getMeta } from '../../utils/DataTemplate';

export default {
  namespace: 'FWQuanShu',
  state: {
    detailData: {},
    metas: [],
  },
  effects: {
    *getFWQuanShuDetail({ payload }, { put, call }) {
      const coordinate = {
        containerType: 'module',
        containerName: 'query-DSRFWQuanShu',
        datasourceName: 'QueryfwqsDetailByID',
      };
      const result = yield call(getData, coordinate, { params: { pID: payload } });
      yield put({ type: 'setFWQuanShuDetail', payload: { ...result[0] } });
      const metas = yield call(getMeta, coordinate);
      yield put({ type: 'setMetas', payload: metas });
    },
  },
  reducers: {
    setFWQuanShuDetail(state, { payload }) {
      return {
        ...state,
        detailData: payload,
      };
    },
    setMetas(state, { payload }) {
      return { ...state, metas: payload };
    },
  },
};

