feat: custom table with row children
This commit is contained in:
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -243,7 +243,7 @@ const Models: React.FC = () => {
|
||||
<Column
|
||||
title="Operation"
|
||||
key="operation"
|
||||
render={(text, record) => {
|
||||
render={(text, record: ListItem) => {
|
||||
return (
|
||||
<Space>
|
||||
<Tooltip title="编辑">
|
||||
|
||||
Reference in New Issue
Block a user