|
@@ -7,13 +7,19 @@ import { getViewportOffset } from '@/utils/domUtils'
|
|
|
import { useWindowSizeFn } from '@/hooks/event/useWindomSizeFn'
|
|
import { useWindowSizeFn } from '@/hooks/event/useWindomSizeFn'
|
|
|
import type { DensitySize } from '@ant-design/pro-table/lib/components/ToolBar/DensityIcon'
|
|
import type { DensitySize } from '@ant-design/pro-table/lib/components/ToolBar/DensityIcon'
|
|
|
|
|
|
|
|
-export function useTableScroll(
|
|
|
|
|
- tableElRef: RefObject<HTMLElement>,
|
|
|
|
|
- columnsRef: ProColumns<any> = [],
|
|
|
|
|
- selectKeysRef: string[] = [],
|
|
|
|
|
- sizeRef: DensitySize = 'middle',
|
|
|
|
|
|
|
+export function useTableScroll({
|
|
|
|
|
+ tableElRef,
|
|
|
|
|
+ columnsRef = [],
|
|
|
|
|
+ selectKeysRef = [],
|
|
|
|
|
+ sizeRef = 'middle',
|
|
|
|
|
+ paginationRef
|
|
|
|
|
+}: {
|
|
|
|
|
+ tableElRef: RefObject<HTMLElement>
|
|
|
|
|
+ columnsRef: ProColumns<any>
|
|
|
|
|
+ selectKeysRef: string[]
|
|
|
|
|
+ sizeRef: DensitySize
|
|
|
paginationRef: boolean
|
|
paginationRef: boolean
|
|
|
-) {
|
|
|
|
|
|
|
+}) {
|
|
|
// let bodyEl: HTMLElement | null
|
|
// let bodyEl: HTMLElement | null
|
|
|
const [tableHeight, setTableHeight] = useState(null)
|
|
const [tableHeight, setTableHeight] = useState(null)
|
|
|
const [_dataSource, setDataSource] = useState(null)
|
|
const [_dataSource, setDataSource] = useState(null)
|
|
@@ -92,8 +98,7 @@ export function useTableScroll(
|
|
|
let hasScrollBar = el?.style.width !== '100%'
|
|
let hasScrollBar = el?.style.width !== '100%'
|
|
|
|
|
|
|
|
if (el?.style.width !== '100%') {
|
|
if (el?.style.width !== '100%') {
|
|
|
- const contentWidth =
|
|
|
|
|
- tableContainerEl?.querySelector('div.ant-table-content')?.clientWidth || 0
|
|
|
|
|
|
|
+ const contentWidth = tableContainerEl?.querySelector('div.ant-table-content')?.clientWidth || 0
|
|
|
|
|
|
|
|
hasScrollBar = el?.clientWidth > contentWidth
|
|
hasScrollBar = el?.clientWidth > contentWidth
|
|
|
}
|
|
}
|
|
@@ -146,8 +151,7 @@ export function useTableScroll(
|
|
|
}
|
|
}
|
|
|
const tableEl = tableElRef.current
|
|
const tableEl = tableElRef.current
|
|
|
|
|
|
|
|
- const tableWidth = tableEl && tableEl?.offsetWidth
|
|
|
|
|
- // console.log(tableWidth - 48, width)
|
|
|
|
|
|
|
+ const tableWidth = tableEl?.offsetWidth
|
|
|
|
|
|
|
|
return tableWidth - 48 > width ? '100%' : width
|
|
return tableWidth - 48 > width ? '100%' : width
|
|
|
}, [selectKeysRef, columnsRef, tableElRef?.current])
|
|
}, [selectKeysRef, columnsRef, tableElRef?.current])
|