| | |
| | | import type { BasicTableProps } from '../types/table'; |
| | | import { unref, computed, h, nextTick, watchEffect } from 'vue'; |
| | | import TableFooter from '../components/TableFooter.vue'; |
| | | import { useEventListener } from '/@/hooks/event/useEventListener'; |
| | | import { useEventListener } from '@/hooks/event/useEventListener'; |
| | | |
| | | export function useTableFooter( |
| | | propsRef: ComputedRef<BasicTableProps>, |
| | | scrollRef: ComputedRef<{ |
| | | x: string | number | true; |
| | | y: string | number | null; |
| | | scrollToFirstRowOnChange: boolean; |
| | | }>, |
| | | scrollRef: ComputedRef<BasicTableProps['scroll']>, |
| | | tableElRef: Ref<ComponentRef>, |
| | | getDataSourceRef: ComputedRef<Recordable>, |
| | | ) { |
| | |
| | | nextTick(() => { |
| | | const tableEl = unref(tableElRef); |
| | | if (!tableEl) return; |
| | | const bodyDom = tableEl.$el.querySelector('.ant-table-content'); |
| | | const bodyDom = tableEl.$el.querySelector(' .ant-table-content, .ant-table-body'); |
| | | useEventListener({ |
| | | el: bodyDom, |
| | | name: 'scroll', |
| | | listener: () => { |
| | | const footerBodyDom = tableEl.$el.querySelector( |
| | | '.ant-table-footer .ant-table-content', |
| | | '.ant-table-footer .ant-table-container [class^="ant-table-"]', |
| | | ) as HTMLDivElement; |
| | | if (!footerBodyDom || !bodyDom) return; |
| | | footerBodyDom.scrollLeft = bodyDom.scrollLeft; |