parent
6ea8cc9986
commit
3a021e7879
@ -0,0 +1,50 @@
|
||||
import { RightOutlined } from '@ant-design/icons';
|
||||
import { Button, Checkbox } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
|
||||
interface HeaderPrefixProps {
|
||||
expandable?: boolean | React.ReactNode;
|
||||
enableSelection?: boolean;
|
||||
onSelectAll?: (e: any) => void;
|
||||
indeterminate?: boolean;
|
||||
selectAll?: boolean;
|
||||
}
|
||||
|
||||
const HeaderPrefix: React.FC<HeaderPrefixProps> = (props) => {
|
||||
const { expandable, enableSelection, onSelectAll, indeterminate, selectAll } =
|
||||
props;
|
||||
if (expandable && enableSelection) {
|
||||
return (
|
||||
<div className="header-row-prefix-wrapper">
|
||||
<span style={{ marginRight: 5, padding: '0 14px' }}></span>
|
||||
<Checkbox
|
||||
onChange={onSelectAll}
|
||||
indeterminate={indeterminate}
|
||||
checked={selectAll}
|
||||
></Checkbox>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (expandable) {
|
||||
return (
|
||||
<div className="header-row-prefix-wrapper">
|
||||
{_.isBoolean(expandable) ? (
|
||||
<Button type="text" size="small">
|
||||
<RightOutlined />
|
||||
</Button>
|
||||
) : (
|
||||
expandable
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (enableSelection) {
|
||||
return (
|
||||
<div className="header-row-prefix-wrapper">{<Checkbox></Checkbox>}</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export default React.memo(HeaderPrefix);
|
||||
@ -0,0 +1,72 @@
|
||||
import { Empty } from 'antd';
|
||||
import React from 'react';
|
||||
import TableRow from './table-row';
|
||||
|
||||
interface TableBodyProps {
|
||||
dataSource: any[];
|
||||
columns: React.ReactNode[];
|
||||
rowKey: string;
|
||||
rowSelection?: any;
|
||||
expandable?: any;
|
||||
expandedRowKeys?: any;
|
||||
onExpand?: any;
|
||||
childParentKey?: any;
|
||||
pollingChildren?: any;
|
||||
watchChildren?: any;
|
||||
renderChildren?: any;
|
||||
loadChildren?: any;
|
||||
loadChildrenAPI?: any;
|
||||
onCell?: any;
|
||||
}
|
||||
|
||||
const TableBody: React.FC<TableBodyProps> = ({
|
||||
dataSource,
|
||||
rowKey,
|
||||
rowSelection,
|
||||
expandable,
|
||||
expandedRowKeys,
|
||||
onExpand,
|
||||
childParentKey,
|
||||
pollingChildren,
|
||||
watchChildren,
|
||||
renderChildren,
|
||||
loadChildren,
|
||||
loadChildrenAPI,
|
||||
columns,
|
||||
onCell
|
||||
}) => {
|
||||
if (!dataSource.length) {
|
||||
return (
|
||||
<div className="empty-wrapper">
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="seal-table-content">
|
||||
{dataSource.map((item, index) => (
|
||||
<TableRow
|
||||
key={item[rowKey]}
|
||||
record={item}
|
||||
rowIndex={index}
|
||||
columns={columns}
|
||||
rowSelection={rowSelection}
|
||||
expandable={expandable}
|
||||
rowKey={rowKey}
|
||||
childParentKey={childParentKey}
|
||||
pollingChildren={pollingChildren}
|
||||
watchChildren={watchChildren}
|
||||
renderChildren={renderChildren}
|
||||
loadChildren={loadChildren}
|
||||
loadChildrenAPI={loadChildrenAPI}
|
||||
onCell={onCell}
|
||||
onExpand={onExpand}
|
||||
expandedRowKeys={expandedRowKeys}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableBody;
|
||||
Loading…
Reference in new issue