完善:质量分析平台查询与分析功能
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { Table as AntdTable } from 'antd';
|
||||
import type { ColumnType, TableProps } from 'antd/es/table';
|
||||
|
||||
type QualityTableProps<T extends object> = TableProps<T> & {
|
||||
/** Offset for tables whose page is controlled outside Ant Design. */
|
||||
indexOffset?: number;
|
||||
};
|
||||
|
||||
export function QualityTable<T extends object>({
|
||||
columns,
|
||||
dataSource,
|
||||
pagination,
|
||||
indexOffset = 0,
|
||||
className,
|
||||
size = 'small',
|
||||
...props
|
||||
}: QualityTableProps<T>) {
|
||||
const pageConfig = typeof pagination === 'object' && pagination !== null ? pagination : undefined;
|
||||
const page = pageConfig?.current ?? 1;
|
||||
const pageSize = pageConfig?.pageSize ?? (pagination === undefined ? 10 : dataSource?.length ?? 0);
|
||||
const pageOffset = indexOffset + Math.max(0, page - 1) * pageSize;
|
||||
const indexColumn: ColumnType<T> = {
|
||||
title: '序号',
|
||||
key: '__quality-row-number__',
|
||||
width: 68,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
className: 'quality-table-index-column',
|
||||
render: (_value, _record, index) => pageOffset + index + 1,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="quality-table-frame">
|
||||
<AntdTable<T>
|
||||
{...props}
|
||||
className={['quality-table', className].filter(Boolean).join(' ')}
|
||||
columns={[indexColumn, ...(columns ?? [])]}
|
||||
dataSource={dataSource}
|
||||
pagination={pagination}
|
||||
size={size}
|
||||
bordered
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user