From e92549a72b13dd39ae284806c87b31685e5ddd91 Mon Sep 17 00:00:00 2001 From: FCD <2453864257@qq.com> Date: Wed, 2 Jul 2025 14:27:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=BD=93=E5=89=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=9C=80=E5=A4=A7=E8=A1=A8=E6=A0=BC=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/useTableMaxHeight.js | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/utils/useTableMaxHeight.js diff --git a/src/utils/useTableMaxHeight.js b/src/utils/useTableMaxHeight.js new file mode 100644 index 0000000..a6537a1 --- /dev/null +++ b/src/utils/useTableMaxHeight.js @@ -0,0 +1,43 @@ +export default { + data() { + return { + tableHeight: 100 + } + }, + methods: { + calculateHeight() { + let conditionHeight = 0 + if (this.pageHeaderRef && this.pageHeaderRef.offsetHeight) { + conditionHeight = this.pageHeaderRef.offsetHeight + } + + + const remainingHeight = window.innerHeight - this.fixedHeight - conditionHeight + this.tableHeight = Math.max(remainingHeight, this.minHeight) + } + }, + mounted() { + this.$nextTick(() => { + this.calculateHeight() + window.addEventListener('resize', this.calculateHeight) + }); + + }, + beforeDestroy() { + window.removeEventListener('resize', this.calculateHeight) + }, + props: { + pageHeaderRef: { + type: HTMLElement, + default: null + }, + fixedHeight: { + type: Number, + default: 200 + }, + minHeight: { + type: Number, + default: 350 + } + } +}