码迷,mamicode.com
首页 > 其他好文 > 详细

处理分页 当前页>1时, 操作的最后一页的最后一条数据后,向前提前一页

时间:2018-12-15 15:53:40      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:请求   失败   job   tab   success   comm   提前   tabs   state   

* handleAgentJobs({ payload }, { call, put }) {
const data = yield call(handleAgentJob, payload)
if (data && data.code === 200) {
yield put({
type: ‘handleAgentAbandonPage‘,
payload
});
} else {
message.error(data && data.message || ‘请求失败‘);
}
},
* handleAbabonJobs({ payload }, { call, put }) {
const data = yield call(handleAbandonJob, payload)
if (data && data.code === 200) {
yield put({
type: ‘handleAgentAbandonPage‘,
payload
})
} else {
message.error(data && data.message || ‘请求失败‘);
}
},




* handleAgentAbandonPage({ payload }, { call, put, select }) {
const pagination = yield select(_ => _.jobManage.agentJobs.pagination);
let page = pagination.page;
let total = pagination.total || 10;
let current = pagination.current || 1;
if (current > 1 && (total%10 === 1)) { // 当前页>1时, 操作的最后一页的最后一条数据后,向前提前一页
payload.page = page - 1;
yield put({
type: COMMON_LOADING,
stateKey: ‘agentJobs‘
});
payload.callback && payload.callback();
let data = ‘‘;
if(payload.status === AGENT_TABS_KEYS.AGENT){
data = yield call(queryAgentJobs, payload);
}else if(payload.status === AGENT_TABS_KEYS.NEWS){
data = yield call(queryNewJobs, payload);
}else if(payload.status === AGENT_TABS_KEYS.ABANDON){
data = yield call(queryGiveUpJobs, payload);
}
if (data && data.code === 200) {
yield put({
type: COMMON_LOAD_SUCCESS,
stateKey: ‘agentJobs‘,
result: {
...data.data,
dataMessage: data.message,
dataCode: data.code
}
});

yield put({
type: ‘setPagination‘,
stateKey: ‘agentJobs‘,
payload: {
total: data.data.totalElements - 1,
current: data.data.number || 1
}
});
} else {
yield put({
type: COMMON_LOAD_FAIL,
stateKey: ‘agentJobs‘,
error: data
});
message.error(data && data.message || ‘请求失败‘);
}

} else {
payload.callback && payload.callback();
yield put({
type: ‘setPagination‘,
stateKey: ‘agentJobs‘,
payload: {
total: total - 1,
current: current
}
});
}
}

处理分页 当前页>1时, 操作的最后一页的最后一条数据后,向前提前一页

标签:请求   失败   job   tab   success   comm   提前   tabs   state   

原文地址:https://www.cnblogs.com/liuerpeng/p/10123377.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!