-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
320 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Revision History: | ||
* Initial: 2017/10/22 Wang RiYu | ||
*/ | ||
|
||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import Styles from './index.less' | ||
import { | ||
Table, | ||
} from 'antd' | ||
|
||
const expandedTable = ({ data }) => { | ||
const columns = [ | ||
{ | ||
title: 'ID', | ||
dataIndex: 'id', | ||
width: '20%', | ||
}, { | ||
title: '题目内容', | ||
dataIndex: 'content', | ||
}, { | ||
title: '完成时间', | ||
dataIndex: 'time', | ||
width: '20%', | ||
}, | ||
] | ||
|
||
const EmptyDiv = { | ||
height: '66px', | ||
lineHeight: '66px', | ||
background: '#f5f2f9' | ||
} | ||
|
||
const pagination = { | ||
defaultPageSize: 10, | ||
showQuickJumper: true, | ||
showTotal: total => `共 ${total} 条`, | ||
defaultCurrent: 1, | ||
total: null, | ||
} | ||
|
||
return ( | ||
<div> | ||
{ | ||
data.length > 0 | ||
? <Table | ||
className={Styles.expandedTable} | ||
columns={columns} | ||
dataSource={data} | ||
pagination={pagination} | ||
bordered | ||
rowKey={record => record.id} | ||
/> | ||
: <div style={EmptyDiv}>此列表为空</div> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
expandedTable.propTypes = { | ||
data: PropTypes.array | ||
} | ||
|
||
export default expandedTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.expandedTable { | ||
background: #ffffff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Revision History: | ||
* Initial: 2017/10/22 Wang RiYu | ||
*/ | ||
|
||
import React from 'react' | ||
import ExpandedTable from './expandedTable' | ||
import { | ||
Table, | ||
Button | ||
} from 'antd'; | ||
|
||
const list = ({ | ||
loading, | ||
dataSource, | ||
expandedData, | ||
confirm, | ||
release, | ||
expandedRowKey, | ||
getExpandedData, | ||
RowKeysChange, | ||
}) => { | ||
const columns = [{ | ||
title: 'ID', | ||
dataIndex: 'id', | ||
}, { | ||
title: '用户名', | ||
dataIndex: 'name', | ||
}, { | ||
title: '刷题记录', | ||
dataIndex: 'record', | ||
}, { | ||
title: '操作', | ||
dataIndex: 'operation', | ||
width: '100px', | ||
render: (text, record) => ( | ||
<div style={{display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center'}}> | ||
<Button style={{width: '100px'}}>管理</Button> | ||
</div> | ||
) | ||
}] | ||
|
||
const pagination = { | ||
defaultPageSize: 10, | ||
showQuickJumper: true, | ||
showTotal: total => `共 ${total} 条`, | ||
defaultCurrent: 1, | ||
total: null, | ||
} | ||
|
||
const expandedTableProps = { | ||
data: expandedData, | ||
} | ||
|
||
const onExpandedTable = (expanded, record) => { | ||
getExpandedData(record.id) | ||
} | ||
|
||
return ( | ||
<Table | ||
simple | ||
bordered | ||
// loading={loading} | ||
pagination={pagination} | ||
dataSource={dataSource} | ||
columns={columns} | ||
rowKey={record => record.id} | ||
footer={() => <div style={{textAlign: 'center'}}>用户管理</div>} | ||
expandedRowRender={() => <ExpandedTable {...expandedTableProps} />} | ||
onExpand={onExpandedTable} | ||
expandedRowKeys={expandedRowKey} | ||
onExpandedRowsChange={(key) => RowKeysChange(key)} | ||
/> | ||
) | ||
} | ||
|
||
export default list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters