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 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/11589370.html
未经授权禁止转载,违者必究!