xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

redux & dispatch & payload

redux & dispatch & payload

react & react-redux & redux-saga


    // contrast
    dispatch({
      type: "pointCheckDetail/getContrastData",
      payload: {
        id,
      },
    });
    // status
    dispatch({
      type: "pointCheckDetail/getPointCheckResults",
      payload: {},
    });
    // table
    dispatch({
      type: "pointCheckDetail/getPointCheckDetails",
      payload: {
        id,
        contrasts,
      },
    });


  effects: {
    *initData({ payload }, { put }) {
      yield put({
        type: "save",
        payload: {
          ...initialState,
          ...payload,
        }
      });
    },
    *getBasicData({ payload }, { put, call }) {
      yield put({
        type: "showLoading",
      });
      const {
        id,
      } = payload;
      const res = yield call(getPointCheckBasics, id);
      if (res.success) {
        yield put({
          type: "save",
          payload: {
            loading: false,
            // dataSource: res.data,
          },
        });
      } else {
        yield put({
          type: "hiddenLoading",
        });
        message.error(`获取数据失败!`);
      }
    },
    *getContrastData({ payload }, { put, call }) {
      yield put({
        type: "showLoading",
      });
      const {
        id,
      } = payload;
      const res = yield call(getPointCheckContrasts, id);
      if (res.success) {
        yield put({
          type: "save",
          payload: {
            loading: false,
            // contrast: contrastShaper(res.data),
            contrast: contrastShaper([]),
          },
        });
      } else {
        yield put({
          type: "hiddenLoading",
        });
        message.error(`获取数据失败!`);
      }
    },
    *getResultData({}, { put, call }) {
      yield put({
        type: "showLoading",
      });
      const res = yield call(getPointCheckResults, );
      if (res.success) {
        yield put({
          type: "save",
          payload: {
            loading: false,
            // dataSource: res.data,
          },
        });
      } else {
        yield put({
          type: "hiddenLoading",
        });
        message.error(`获取数据失败!`);
      }
    },
    *updateReportName({ payload }, { put, call }) {
      yield put({
        type: "showLoading",
      });
      // const {
      //   id,
      //   name,
      // } = payload;
      const res = yield call(putPointCheckReportName, payload);
      if (res.success) {
        yield put({
          type: "save",
          payload: {
            loading: false,
            // dataSource: res.data,
          },
        });
      } else {
        yield put({
          type: "hiddenLoading",
        });
        message.error(`获取数据失败!`);
      }
    },
    *getTableData({ payload }, { put, call }) {
      yield put({
        type: "showLoading",
      });
      // const {
      //   id,
      //   contrasts,
      // } = payload;
      const res = yield call(getPointCheckDetails, payload);
      if (res.success) {
        yield put({
          type: "save",
          payload: {
            loading: false,
            // dataSource: res.data,
          },
        });
      } else {
        yield put({
          type: "hiddenLoading",
        });
        message.error(`获取数据失败!`);
      }
    },
  },


refs

https://zzk.cnblogs.com/my/s/blogpost-p?Keywords=redux-saga



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2019-09-26 10:34  xgqfrms  阅读(1457)  评论(1编辑  收藏  举报