Skip to content

Commit

Permalink
优化 users-motion
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpmg committed Feb 11, 2017
1 parent d1ffb7e commit ceabac1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/components/users/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class list extends React.Component {
}

getBodyWrapper = (body) => {
// 切换分页去除动画;
if (this.currentPage !== this.newPage) {
this.currentPage = this.newPage
return body
Expand All @@ -60,6 +61,11 @@ class list extends React.Component {
e.target.style.height = 'auto'
}

async pageChange(pagination) {
await this.props.onPageChange(pagination)
this.newPage = pagination.current
}

render () {
const {
loading,
Expand Down Expand Up @@ -133,11 +139,7 @@ class list extends React.Component {
return <div>
<Table className={styles.table} bordered scroll={{
x: 1200
}} columns={columns} dataSource={dataSource} loading={loading} onChange={(page) => {
onPageChange(page, () => {
self.newPage = page.current
})
}} pagination={pagination} simple rowKey={record => record.id} getBodyWrapper={this.getBodyWrapper} />
}} columns={columns} dataSource={dataSource} loading={loading} onChange={::this.pageChange} pagination={pagination} simple rowKey={record => record.id} getBodyWrapper={this.getBodyWrapper} />
</div>
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ function Users ({ location, dispatch, users }) {
dataSource: list,
loading,
pagination: pagination,
async onPageChange (page, callback) {
const query = location.query
await dispatch(routerRedux.push({
pathname: '/users',
onPageChange (page) {
const { query, pathname } = location
dispatch(routerRedux.push({
pathname: pathname,
query: {
...query,
page: page.current,
pageSize: page.pageSize
}
}))
await callback && callback()
},
onDeleteItem (id) {
dispatch({
Expand Down

0 comments on commit ceabac1

Please sign in to comment.