tav-ui
Version:
1 lines • 2.75 kB
Source Map (JSON)
{"version":3,"file":"useTableFullHeight2.mjs","sources":["../../../../../../../../packages/components/table/src/hooks/useTableFullHeight.ts"],"sourcesContent":["import { nextTick, unref } from 'vue'\nimport type { ComputedRef, Ref } from 'vue'\nimport type { BasicTableProps } from '../types/table'\n\ninterface ComponentElRef<T extends HTMLElement = HTMLDivElement> {\n $el: T\n}\ntype ComponentRef<T extends HTMLElement = HTMLDivElement> = ComponentElRef<T> | null\n\nexport function useTableFullHeight(\n propsRef: ComputedRef<BasicTableProps>,\n tableElRef: Ref<ComponentRef>\n) {\n const { fullHeight } = unref(propsRef)\n if (!fullHeight) return\n\n let headEl: HTMLElement | null\n let bodyEl: HTMLElement | null\n let contentEl: HTMLElement | null\n async function calcTableHeight() {\n await nextTick()\n const table = unref(tableElRef)\n if (!table) return\n const tableEl: HTMLElement = table.$el\n if (!tableEl) return\n\n if (!bodyEl) {\n bodyEl = tableEl.querySelector('.ant-table-body')\n if (!bodyEl) return\n }\n\n headEl = tableEl.querySelector('.ant-table-thead')\n\n if (!headEl) return\n // const { height: headHeight } = headEl.getBoundingClientRect();\n // const { height: bodyHeight } = bodyEl.getBoundingClientRect();\n // const { height: contentHeight } = contentEl.getBoundingClientRect();\n // console.log(contentHeight, \"sksksks\");\n // hack: 高度4\n //兼容\n // if (dataObj?.result?.length > 0) {\n // // headHeight - 4\n // bodyEl.style.maxHeight = `${contentHeight - headHeight}px`;\n // // bodyEl.style.maxHeight = `${bodyHeight - headHeight - 4}px`;\n // } else {\n // bodyEl.style.maxHeight = `${\n // contentHeight - headHeight > 170 ? contentHeight - headHeight : 170\n // }px`;\n // }\n bodyEl.style.minHeight = `${170}px`\n }\n\n calcTableHeight()\n}\n"],"names":[],"mappings":";;AACO,SAAS,kBAAkB,CAAC,QAAQ,EAAE,UAAU,EAAE;AACzD,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AACzC,EAAE,IAAI,CAAC,UAAU;AACjB,IAAI,OAAO;AACX,EAAE,IAAI,MAAM,CAAC;AACb,EAAE,IAAI,MAAM,CAAC;AACb,EAAE,IAAI,SAAS,CAAC;AAChB,EAAE,eAAe,eAAe,GAAG;AACnC,IAAI,MAAM,QAAQ,EAAE,CAAC;AACrB,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AACpC,IAAI,IAAI,CAAC,KAAK;AACd,MAAM,OAAO;AACb,IAAI,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;AAC9B,IAAI,IAAI,CAAC,OAAO;AAChB,MAAM,OAAO;AACb,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AACxD,MAAM,IAAI,CAAC,MAAM;AACjB,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;AACvD,IAAI,IAAI,CAAC,MAAM;AACf,MAAM,OAAO;AACb,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AACxC,GAAG;AACH,EAAE,eAAe,EAAE,CAAC;AACpB;;;;"}