vdi/web-fe/src/pages/terminal/mod/selectedTable/table.tsx

82 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-08-07 10:15:11 +00:00
import { Button, Table } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import React from 'react';
interface DeletableTableProps {
dataSource: any[];
isSerial?: boolean;
isAction?: boolean;
scrollY: number;
onDelete?: (recod: any) => void;
rowKey?: string;
rowSelection?: any;
pagination?:any;
2025-08-08 10:09:16 +00:00
columns: ColumnsType<any>;
2025-08-07 10:15:11 +00:00
}
const DeletableTable: React.FC<DeletableTableProps> = (props) => {
const {
dataSource,
onDelete,
isSerial = true,
isAction = true,
scrollY = 300,
...restProps
} = props;
console.log("datasource=====",dataSource);
2025-08-08 10:09:16 +00:00
// const getColumns = (): ColumnsType<any> => {
// const columns: ColumnsType<any> = [
// {
// title: '名称',
// dataIndex: 'name',
// key: 'name',
// },
// {
// title: '类型',
// dataIndex: 'type',
// key: 'type',
// render: (text) => (
// <span>{text == 1 ? '用户' : text == 2 ? '用户组' : ''}</span>
// ),
// },
// ];
2025-08-07 10:15:11 +00:00
2025-08-08 10:09:16 +00:00
// if (isSerial) {
// columns.unshift({
// title: '序号',
// dataIndex: 'order',
// key: 'order',
// width: 80,
// render: (_, record, index) => <span>{index + 1}</span>,
// });
// }
2025-08-07 10:15:11 +00:00
2025-08-08 10:09:16 +00:00
// if (isAction) {
// columns.push({
// title: '操作',
// key: 'action',
// render: (_, record) => (
// <Button type="link" danger onClick={() => onDelete(record)}>
// 删除
// </Button>
// ),
// });
// }
2025-08-07 10:15:11 +00:00
2025-08-08 10:09:16 +00:00
// return columns;
// };
2025-08-07 10:15:11 +00:00
return (
<div>
<Table
2025-08-08 10:09:16 +00:00
// columns={getColumns()}
2025-08-07 10:15:11 +00:00
dataSource={dataSource}
scroll={{ y: scrollY }}
{...restProps}
/>
</div>
);
};
export default DeletableTable;