From 64c152fb2daa154861b2ef5827cd1fbbaea3a1c0 Mon Sep 17 00:00:00 2001 From: zuiidea Date: Fri, 10 Feb 2017 16:20:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/users/list.js | 47 +++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/components/users/list.js b/src/components/users/list.js index 23e4247..4a9150b 100644 --- a/src/components/users/list.js +++ b/src/components/users/list.js @@ -1,7 +1,8 @@ import React from 'react' -import {Table, Popconfirm} from 'antd' +import {Table, Dropdown, Button, Menu, Icon, Modal} from 'antd' import {TweenOneGroup} from 'rc-tween-one' import styles from './list.less' +const confirm = Modal.confirm class list extends React.Component { constructor (props) { @@ -56,19 +57,26 @@ class list extends React.Component { ) } + handleMenuClick = (record, e) => { + const {onDeleteItem, onEditItem} = this.props + if (e.key === '1') { + onEditItem(record) + } else if (e.key === '2') { + confirm({ + title: '您确定要删除这条记录吗?', + onOk () { + onDeleteItem(record.id) + } + }) + } + } + onEnd = (e) => { e.target.style.height = 'auto' } render () { - const { - loading, - dataSource, - pagination, - onPageChange, - onDeleteItem, - onEditItem - } = this.props + const {loading, dataSource, pagination, onPageChange} = this.props const columns = [ { title: '头像', @@ -117,16 +125,17 @@ class list extends React.Component { title: '操作', key: 'operation', width: 100, - render: (text, record) => ( -

- onEditItem(record)} style={{ - marginRight: 4 - }}>编辑 - onDeleteItem(record.id)}> - 删除 - -

- ) + render: (text, record) => { + return ( + 编辑 + 删除 + }> + + ) + } } ] const self = this From 26bff8fbb79aaa2fe12d2dc79621e7130544bb81 Mon Sep 17 00:00:00 2001 From: felixpmg Date: Sun, 12 Feb 2017 14:49:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?users-motion=20rc-tween-one=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/users/list.js | 15 ++++----------- src/routes/users.js | 1 + 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/users/list.js b/src/components/users/list.js index 2d64112..3d44965 100644 --- a/src/components/users/list.js +++ b/src/components/users/list.js @@ -39,15 +39,13 @@ class list extends React.Component { ease: 'easeOutQuad' } ] - const {current} = this.props.pagination - this.currentPage = current - this.newPage = current } getBodyWrapper = (body) => { // 切换分页去除动画; - if (this.currentPage !== this.newPage) { - this.currentPage = this.newPage + const { page = 1 } = this.props.location.query + const { current } = this.props.pagination + if(current != +page) { return body } return ( @@ -61,11 +59,6 @@ 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, @@ -139,7 +132,7 @@ class list extends React.Component { return
record.id} getBodyWrapper={this.getBodyWrapper} /> + }} columns={columns} dataSource={dataSource} loading={loading} onChange={onPageChange} pagination={pagination} simple rowKey={record => record.id} getBodyWrapper={this.getBodyWrapper} /> } } diff --git a/src/routes/users.js b/src/routes/users.js index 2832ddf..dd02126 100644 --- a/src/routes/users.js +++ b/src/routes/users.js @@ -30,6 +30,7 @@ function Users ({ location, dispatch, users }) { dataSource: list, loading, pagination: pagination, + location, onPageChange (page) { const { query, pathname } = location dispatch(routerRedux.push({