tav-ui
Version:
45 lines (42 loc) • 1.53 kB
JavaScript
import { computed, unref, h, watchEffect, nextTick } from 'vue';
import { useEventListener } from '../../../../hooks/event/useEventListener2.mjs';
import TableFooter from '../components/TableFooter2.mjs';
function useTableFooter(propsRef, scrollRef, tableElRef, getDataSourceRef) {
const getIsEmptyData = computed(() => {
return (unref(getDataSourceRef) || []).length === 0;
});
const getFooterProps = computed(() => {
const { summaryFunc, showSummary, summaryData } = unref(propsRef);
return showSummary && !unref(getIsEmptyData) ? () => h(TableFooter, { summaryFunc, summaryData, scroll: unref(scrollRef) }) : void 0;
});
watchEffect(() => {
handleSummary();
});
function handleSummary() {
const { showSummary } = unref(propsRef);
if (!showSummary || unref(getIsEmptyData))
return;
nextTick(() => {
const tableEl = unref(tableElRef);
if (!tableEl)
return;
const bodyDomList = tableEl.$el.querySelectorAll(".ant-table-body");
const bodyDom = bodyDomList[0];
useEventListener({
el: bodyDom,
name: "scroll",
listener: () => {
const footerBodyDom = tableEl.$el.querySelector(".ant-table-footer .ant-table-body");
if (!footerBodyDom || !bodyDom)
return;
footerBodyDom.scrollLeft = bodyDom.scrollLeft;
},
wait: 0,
options: true
});
});
}
return { getFooterProps };
}
export { useTableFooter };
//# sourceMappingURL=useTableFooter2.mjs.map