首页 新闻 会员 周边 捐助

react antd 分页,切换筛选条件之后分页组件没有默认第一页

0
悬赏园豆:100 [待解决问题]

每次切换筛选条件之后,分页组件当前页还停留在上次页面的当前页,没有默认切换到当前筛选条件的第一页,table数据渲染的是当前筛选条件的第一页,就是分页组件不对,请各位大神不吝赐教
//点击分页
handleTableChange = (page,pageSize) => {
const { dispatch ,eventId} = this.props;
const { pagination, QueryClause,filterValue } = this.state;
this.setState({spinning:true})
dispatch({
type: 'eventInvoice/getInvoiceListByFilter',
payload: {
EventId: this.state.InputValue,
InvoiceStatus: this.state.invoiceStatus,
PaymentStatus:this.state.PaymentStatus,
InvoiceType: this.state.invoiceType,
InvoiceSendType: this.state.sendType,
Page: page,
ItemsPerPage: pageSize,
QueryClause:filterValue
},
callback: (data, arr) => {
this.setState({spinning: false,
selectedRowKeys: [] ,
pagination: { current: data.CurrentPageNumber, pageSize: pageSize, total: data.TotleCount }
})
}
});
}
//各筛选条件
changeStatus = (name, value) => {
const { dispatch } = this.props;
if (name == "invoiceStatus") {
this.setState({ invoiceStatus: value })
} else if (name == "invoiceType") {
this.setState({ invoiceType: value })
}else if(name == "PaymentStatus"){
this.setState({ PaymentStatus: value })
} else {
this.setState({ sendType: value });
}
this.setState({ spinning: true, selectedRowKeys: [] })
setTimeout(() => {
this.InvoiceListByFilter()
}, 50);
}
//数据接口函数
InvoiceListByFilter = (current=1) => {
const { dispatch } = this.props;
const {filterValue,pagination} = this.state;
dispatch({
type: 'eventInvoice/getInvoiceListByFilter',
payload: {
EventId: this.state.InputValue,
InvoiceStatus: this.state.invoiceStatus,
PaymentStatus:this.state.PaymentStatus,
InvoiceType: this.state.invoiceType,
InvoiceSendType: this.state.sendType,
QueryClause:filterValue,
Page:current,
ItemsPerPage: pagination.pageSize,
},
callback: data => {
this.setState({
spinning: false,
selectedRowKeys: [],
pagination: { current: data.CurrentPageNumber, pageSize: pagination.pageSize, total: data.TotleCount }
})
}
})
}

WhereWhenWho的主页 WhereWhenWho | 初学一级 | 园豆:102
提问于:2019-08-09 17:15
< >
分享
所有回答(1)
0

如果筛选条件的分页条件 Page对象是共用的话,你需要在筛选条件的请求数据前 初始化你的Page对象,

一只小熊猫 | 园豆:361 (菜鸟二级) | 2019-08-16 10:11

初始化我的page对象好像也不行呢

 

支持(0) 反对(0) WhereWhenWho | 园豆:102 (初学一级) | 2019-08-19 10:32

@WhereWhenWho: 你每次请求数据都输出你的page对象 看看是怎么样的,可以加微信方便聊

支持(1) 反对(0) 一只小熊猫 | 园豆:361 (菜鸟二级) | 2019-08-19 15:39

@一只小熊猫: 

InvoiceListByFilter = () => {
const { dispatch } = this.props;
const {filterValue,pagination} = this.state;
let newCurrent={
...pagination,
current:1
}
this.setState({
pagination:newCurrent
})
console.log(this.state.pagination)
dispatch({
type: 'eventInvoice/getInvoiceListByFilter',
payload: {
EventId: this.state.InputValue,
InvoiceStatus: this.state.invoiceStatus,
PaymentStatus:this.state.PaymentStatus,
InvoiceType: this.state.invoiceType,
InvoiceSendType: this.state.sendType,
QueryClause:filterValue,
Page:this.state.pagination.current,
ItemsPerPage: pagination.pageSize,
},
callback: data => {
this.setState({
spinning: false,
selectedRowKeys: [],
pagination: { current: data.CurrentPageNumber, pageSize: pagination.pageSize, total: data.TotleCount }
})
}
})
}
打印page:current都是对着的,是1 
支持(0) 反对(0) WhereWhenWho | 园豆:102 (初学一级) | 2019-08-19 17:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册