Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kne/info-page",
"version": "0.1.29",
"version": "0.2.0",
"description": "一般用在复杂的详情展示页面,InfoPage提供了一个标准的展示信息的格式",
"syntax": {
"esmodules": true
Expand Down
20 changes: 4 additions & 16 deletions src/TableView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const TableView = p => {
p
);
const { className, dataSource, columns, rowKey, rowSelection, valueIsEmpty, emptyIsPlaceholder, placeholder, empty, onRowSelect, render, context, sticky, ...others } = props;
const dataSourceMapRef = useRef(new Map());
const defaultSpan = useMemo(() => {
const assignedSpan = columns.reduce((a, b) => {
return a + (b.span || 0);
Expand All @@ -39,7 +38,6 @@ const TableView = p => {
return dataSource && dataSource.length > 0 ? (
dataSource.map(item => {
const id = getId(item);
dataSourceMapRef.current.set(id, item);
const isChecked = rowSelection?.selectedRowKeys && rowSelection.selectedRowKeys.indexOf(id) > -1;
const columnsValue = computeColumnsValue({ columns, emptyIsPlaceholder, valueIsEmpty, removeEmpty: false, dataSource: item, placeholder, context });
return (
Expand Down Expand Up @@ -67,21 +65,12 @@ const TableView = p => {
if (rowSelection.type === 'checkbox') {
const selectedRowKeys = (rowSelection.selectedRowKeys || []).slice(0);
isChecked ? selectedRowKeys.splice(rowSelection.selectedRowKeys.indexOf(id), 1) : selectedRowKeys.push(id);
rowSelection.onChange(
selectedRowKeys,
selectedRowKeys.map(id => dataSourceMapRef.current.get(id)),
{ context }
);
rowSelection.onChange(selectedRowKeys, id, { context, checked: !isChecked });
} else {
const selectedRowKeys = rowSelection.selectedRowKeys.length && rowSelection.selectedRowKeys[0] === id ? [] : [id];
rowSelection.onChange(
selectedRowKeys,
selectedRowKeys.map(id => dataSourceMapRef.current.get(id)),
{ context }
);
rowSelection.onChange(selectedRowKeys, id, { context, checked: !isChecked });
}
}}
>
}}>
{rowSelection && rowSelection.type === 'checkbox' && (
<Col className={classnames(style['col'], 'info-page-table-col')}>
<span className={classnames(style['col-content'], 'info-page-table-col-content')}>
Expand All @@ -102,8 +91,7 @@ const TableView = p => {
'--col-align': column.align || 'top',
'--col-justify': column.justify || 'flex-start'
}}
className={classnames(style['col'], 'info-page-table-col')}
>
className={classnames(style['col'], 'info-page-table-col')}>
<span className={style['col-content']}>{computeDisplay({ column, placeholder, dataSource: item, context })}</span>
</Col>
);
Expand Down