feat: custom table with row children

This commit is contained in:
jialin
2024-06-12 09:26:17 +08:00
parent f491b5dfb1
commit 405d95c81f
19 changed files with 611 additions and 12 deletions
+22
View File
@@ -0,0 +1,22 @@
import SealTable from '@/components/seal-table';
import SealColumn from '@/components/seal-table/components/seal-column';
import useTableRowSelection from '@/hooks/use-table-row-selection';
const Table = () => {
const dataSource = [{ name: 'test' }, { name: 'test2' }];
const rowSelection = useTableRowSelection();
return (
<SealTable
dataSource={dataSource}
rowKey="name"
loading={false}
rowSelection={rowSelection}
expandable={true}
>
<SealColumn title="Name" dataIndex="name" key="name" span={12} />
<SealColumn title="Status" dataIndex="status" key="status" span={12} />
</SealTable>
);
};
export default Table;
+7 -1
View File
@@ -4,8 +4,14 @@ import { Tabs } from 'antd';
import { useState } from 'react';
import GPUs from './components/gpus';
import Nodes from './components/nodes';
import Test from './components/test';
const items: TabsProps['items'] = [
{
key: 'test',
label: 'Test',
children: <Test />
},
{
key: 'nodes',
label: 'Nodes',
@@ -18,7 +24,7 @@ const items: TabsProps['items'] = [
}
];
const Resources = () => {
const [activeKey, setActiveKey] = useState('nodes');
const [activeKey, setActiveKey] = useState('test');
const handleChangeTab = (key: string) => {
setActiveKey(key);
+11 -5
View File
@@ -1,4 +1,6 @@
import PageTools from '@/components/page-tools';
import SealTable from '@/components/seal-table';
import SealColumn from '@/components/seal-table/components/seal-column';
import { PageAction } from '@/config';
import type { PageActionType } from '@/config/types';
import useTableRowSelection from '@/hooks/use-table-row-selection';
@@ -208,11 +210,12 @@ const Models: React.FC = () => {
</Space>
}
></PageTools>
<Table
<SealTable
dataSource={dataSource}
rowSelection={rowSelection}
loading={loading}
rowKey="id"
expandable={true}
onChange={handleTableChange}
pagination={{
showSizeChanger: true,
@@ -224,11 +227,12 @@ const Models: React.FC = () => {
onChange: handlePageChange
}}
>
<Column
<SealColumn
title="Model Name"
dataIndex="name"
key="name"
width={400}
span={8}
render={(text, record) => {
return (
<>
@@ -243,7 +247,8 @@ const Models: React.FC = () => {
);
}}
/>
<Column
<SealColumn
span={8}
title="Create Time"
dataIndex="created_at"
key="createTime"
@@ -255,7 +260,8 @@ const Models: React.FC = () => {
return dayjs(val).format('YYYY-MM-DD HH:mm:ss');
}}
/>
<Column
<SealColumn
span={8}
title="Operation"
key="operation"
render={(text, record) => {
@@ -282,7 +288,7 @@ const Models: React.FC = () => {
) : null;
}}
/>
</Table>
</SealTable>
</PageContainer>
<AddModal
open={openAddModal}
+1 -1
View File
@@ -243,7 +243,7 @@ const Models: React.FC = () => {
<Column
title="Operation"
key="operation"
render={(text, record) => {
render={(text, record: ListItem) => {
return (
<Space>
<Tooltip title="编辑">