Files
antd-admin/src/components/Users/UserList.jsx
T
2016-10-10 22:25:56 +08:00

68 lines
1.4 KiB
React

import React, { PropTypes } from 'react';
import { Table, Popconfirm, Pagination } from 'antd';
function UserList({
total, current, loading, dataSource,
onPageChange,
onDeleteItem,
onEditItem,
}) {
const columns = [{
title: '姓名',
dataIndex: 'name',
key: 'name',
render: (text) => <a href="#">{text}</a>,
}, {
title: '年龄',
dataIndex: 'age',
key: 'age',
}, {
title: '住址',
dataIndex: 'address',
key: 'address',
}, {
title: '操作',
key: 'operation',
render: (text, record) => (
<p>
<a onClick={() => onEditItem(record)}>编辑</a>
&nbsp;
<Popconfirm title="确定要删除吗?" onConfirm={() => onDeleteItem(record.id)}>
<a>删除</a>
</Popconfirm>
</p>
),
}];
return (
<div>
<Table
columns={columns}
dataSource={dataSource}
loading={loading}
rowKey={record => record.id}
pagination={false}
/>
<Pagination
className="ant-table-pagination"
total={total}
current={current}
pageSize={10}
onChange={onPageChange}
/>
</div>
);
}
UserList.propTypes = {
onPageChange: PropTypes.func,
onDeleteItem: PropTypes.func,
onEditItem: PropTypes.func,
dataSource: PropTypes.array,
loading: PropTypes.any,
total: PropTypes.any,
current: PropTypes.any,
};
export default UserList;