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