每次切换筛选条件之后,分页组件当前页还停留在上次页面的当前页,没有默认切换到当前筛选条件的第一页,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 }
})
}
})
}
如果筛选条件的分页条件 Page对象是共用的话,你需要在筛选条件的请求数据前 初始化你的Page对象,
初始化我的page对象好像也不行呢
@WhereWhenWho: 你每次请求数据都输出你的page对象 看看是怎么样的,可以加微信方便聊
@一只小熊猫: