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

81 lines
1.7 KiB
TypeScript

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;
columns: ColumnsType<any>;
}
const DeletableTable: React.FC<DeletableTableProps> = (props) => {
const {
dataSource,
onDelete,
isSerial = true,
isAction = true,
scrollY = 400,
...restProps
} = props;
// 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>
// ),
// },
// ];
// if (isSerial) {
// columns.unshift({
// title: '序号',
// dataIndex: 'order',
// key: 'order',
// width: 80,
// render: (_, record, index) => <span>{index + 1}</span>,
// });
// }
// if (isAction) {
// columns.push({
// title: '操作',
// key: 'action',
// render: (_, record) => (
// <Button type="link" danger onClick={() => onDelete(record)}>
// 删除
// </Button>
// ),
// });
// }
// return columns;
// };
return (
<div>
<Table
// columns={getColumns()}
dataSource={dataSource}
scroll={{ y: scrollY }}
{...restProps}
/>
</div>
);
};
export default DeletableTable;