同步:完善质量分析工作台并更新主题字体
同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
@@ -1,5 +1,26 @@
|
||||
import { Table as AntdTable } from 'antd';
|
||||
import type { ColumnType, TableProps } from 'antd/es/table';
|
||||
import type { ColumnsType, ColumnType, TableProps } from 'antd/es/table';
|
||||
import { createContext, isValidElement, useContext, useState } from 'react';
|
||||
import { CompactTableCell } from './CompactTableCell';
|
||||
|
||||
export const CompactManagementTables = createContext(false);
|
||||
|
||||
function compactColumns<T extends object>(columns: ColumnsType<T>): ColumnsType<T> {
|
||||
return columns.map(column => {
|
||||
const title = typeof column.title === 'function' ? column.title : <CompactTableCell>{column.title}</CompactTableCell>;
|
||||
if ('children' in column) return { ...column, title, children: compactColumns(column.children) };
|
||||
return {
|
||||
...column, title, ellipsis: { showTitle: false },
|
||||
render: (value, record, index) => {
|
||||
const content = column.render ? column.render(value, record, index) : value;
|
||||
if (content && typeof content === 'object' && !isValidElement(content) && !Array.isArray(content) && 'children' in content) {
|
||||
return { ...content, children: <CompactTableCell>{content.children}</CompactTableCell> };
|
||||
}
|
||||
return <CompactTableCell>{content}</CompactTableCell>;
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
type QualityTableProps<T extends object> = TableProps<T> & {
|
||||
/** Offset for tables whose page is controlled outside Ant Design. */
|
||||
@@ -13,12 +34,20 @@ export function QualityTable<T extends object>({
|
||||
indexOffset = 0,
|
||||
className,
|
||||
size = 'small',
|
||||
onChange,
|
||||
...props
|
||||
}: QualityTableProps<T>) {
|
||||
const compact = useContext(CompactManagementTables);
|
||||
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 [innerPage, setInnerPage] = useState(() => ({ current: pageConfig?.defaultCurrent ?? 1, pageSize: pageConfig?.defaultPageSize ?? 10 }));
|
||||
const pageSize = pageConfig?.pageSize ?? innerPage.pageSize;
|
||||
const total = pageConfig?.total ?? dataSource?.length ?? 0;
|
||||
const page = Math.min(pageConfig?.current ?? innerPage.current, Math.max(1, Math.ceil(total / pageSize)));
|
||||
const pageOffset = indexOffset + (pagination === false ? 0 : Math.max(0, page - 1) * pageSize);
|
||||
const handleChange: TableProps<T>['onChange'] = (next, filters, sorter, extra) => {
|
||||
setInnerPage({ current: next.current ?? 1, pageSize: next.pageSize ?? pageSize });
|
||||
onChange?.(next, filters, sorter, extra);
|
||||
};
|
||||
const indexColumn: ColumnType<T> = {
|
||||
title: '序号',
|
||||
key: '__quality-row-number__',
|
||||
@@ -30,13 +59,15 @@ export function QualityTable<T extends object>({
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="quality-table-frame">
|
||||
<div className={`quality-table-frame${compact ? ' quality-table-compact' : ''}`}>
|
||||
<AntdTable<T>
|
||||
{...props}
|
||||
className={['quality-table', className].filter(Boolean).join(' ')}
|
||||
columns={[indexColumn, ...(columns ?? [])]}
|
||||
tableLayout={props.tableLayout ?? (compact ? 'fixed' : undefined)}
|
||||
columns={[indexColumn, ...(compact ? compactColumns(columns ?? []) : columns ?? [])]}
|
||||
dataSource={dataSource}
|
||||
pagination={pagination}
|
||||
onChange={handleChange}
|
||||
size={size}
|
||||
bordered
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user