Commit 4645629a by 李伟康

Merge branch 'v1.0.0' of http://192.168.3.233:8090/ujia/uj-store into v1.0.0

2 parents a28f9ad1 1b222cf8
Pipeline #365 for 4645629a failed in 0 seconds
......@@ -79,7 +79,7 @@ export function DataTable<T extends object>({
rowSelection,
actionColumnTitle = '操作',
actionColumnWidth,
actionColumnFixed,
actionColumnFixed = 'right',
toolbarClassName,
toolbarTitle,
fillHeight = false,
......@@ -196,6 +196,7 @@ export function DataTable<T extends object>({
]
: [...columns, ...(actionColumn ? [actionColumn] : [])];
const hasLineLimit = hasLineConfigured(sourceColumns);
const minTableWidth = getMinimumTableWidth(sourceColumns);
const tableColumns = withLineLimit(sourceColumns);
const TableComponent = fillHeight ? FillTable<T> : UTable<T>;
return (
......@@ -226,6 +227,7 @@ export function DataTable<T extends object>({
columns={tableColumns}
tableLayout={hasLineLimit ? 'fixed' : undefined}
rowSelection={resolvedSelection}
scroll={{ ...props.scroll, x: props.scroll?.x ?? minTableWidth }}
styles={{
header: { cell: { paddingLeft: 20 } },
body: { cell: { paddingLeft: 20 } },
......@@ -266,6 +268,15 @@ function hasLineConfigured<T extends object>(columns: ColumnsType<T>): boolean {
});
}
function getMinimumTableWidth<T extends object>(columns: ColumnsType<T>): number {
return columns.reduce((width, column) => {
if ('children' in column && column.children) {
return width + getMinimumTableWidth(column.children);
}
return width + (typeof column.width === 'number' ? column.width : 120);
}, 0);
}
function withLineLimit<T extends object>(columns: DataTableColumnsType<T>): ColumnsType<T> {
return columns.map((column) => {
if ('children' in column && column.children) {
......
......@@ -238,8 +238,8 @@ export default function StoreListing() {
total,
showSizeChanger: false,
pageSizeOptions: [10, 20, 50, 100],
showTotal: (count, range) =>
`共 ${count.toLocaleString('zh-CN')} 条记录 · 每页 ${params.size ?? DEFAULT_PAGE_SIZE} 条 · 当前 ${range[0]}–${range[1]} 条`,
showTotal: (count) =>
`共 ${count.toLocaleString('zh-CN')} 条记录 · 每页 ${params.size ?? DEFAULT_PAGE_SIZE} 条`,
onChange: (current, size) =>
setParams((previous) => ({
...previous,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!