|
|
@@ -11,7 +11,8 @@ export function useTableScroll(
|
|
|
tableElRef: RefObject<HTMLElement>,
|
|
|
columnsRef: ProColumns<any> = [],
|
|
|
selectKeysRef: string[] = [],
|
|
|
- sizeRef: DensitySize = 'middle'
|
|
|
+ sizeRef: DensitySize = 'middle',
|
|
|
+ paginationRef: boolean
|
|
|
) {
|
|
|
// let bodyEl: HTMLElement | null
|
|
|
const [tableHeight, setTableHeight] = useState(null)
|
|
|
@@ -30,19 +31,21 @@ export function useTableScroll(
|
|
|
|
|
|
let paginationHeight = 0
|
|
|
if (dataSource && dataSource?.length) {
|
|
|
- paginationHeight += 32
|
|
|
- if (sizeRef) {
|
|
|
- switch (sizeRef) {
|
|
|
- case 'large':
|
|
|
- paginationHeight += 32
|
|
|
- break
|
|
|
- case 'small':
|
|
|
- paginationHeight += 24
|
|
|
- break
|
|
|
-
|
|
|
- default:
|
|
|
- paginationHeight += 24
|
|
|
- break
|
|
|
+ if (paginationRef) {
|
|
|
+ paginationHeight += 32
|
|
|
+ if (sizeRef) {
|
|
|
+ switch (sizeRef) {
|
|
|
+ case 'large':
|
|
|
+ paginationHeight += 32
|
|
|
+ break
|
|
|
+ case 'small':
|
|
|
+ paginationHeight += 24
|
|
|
+ break
|
|
|
+
|
|
|
+ default:
|
|
|
+ paginationHeight += 24
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -71,13 +74,15 @@ export function useTableScroll(
|
|
|
const tbodyEl: HTMLElement = tableElRef.current
|
|
|
?.querySelector('.ant-table-container')
|
|
|
?.querySelector('.ant-table-tbody')
|
|
|
- const hasScrollBar =
|
|
|
- tableElRef.current?.querySelector('.ant-table-container')?.querySelector('table')?.style
|
|
|
- .width !== '100%'
|
|
|
+ const el = tableElRef.current?.querySelector('.ant-table-container')?.querySelector('table')
|
|
|
+ let hasScrollBar = el?.style.width !== '100%'
|
|
|
+
|
|
|
+ if (el?.style.width !== '100%') {
|
|
|
+ hasScrollBar = el?.clientWidth > el?.style.width
|
|
|
+ }
|
|
|
+
|
|
|
+ const notDataHeight = `${height - (hasScrollBar ? 8 : 0)}px`
|
|
|
|
|
|
- const notDataHeight = `calc(100vh - 48px - 48px - 64px - ${headerHeight}px - ${
|
|
|
- hasScrollBar ? 8 : 0
|
|
|
- }px)`
|
|
|
tbodyEl && (tbodyEl!.style.height = notDataHeight)
|
|
|
return
|
|
|
}
|