From 20a8d64ea1a7780cffb5d57e39adf678bac3cfc6 Mon Sep 17 00:00:00 2001 From: z Date: Thu, 11 Jan 2024 14:40:34 +0800 Subject: [PATCH] init --- src/assets/js/usePrint.js | 11 +++++------ src/components/pdf/index.vue | 7 ++++++- src/components/print_table_package/index.vue | 8 ++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/assets/js/usePrint.js b/src/assets/js/usePrint.js index 9767d45..e402fe0 100644 --- a/src/assets/js/usePrint.js +++ b/src/assets/js/usePrint.js @@ -1,11 +1,10 @@ import { ref } from "vue"; -export default function usePrint(THEAD_HEIGHT) { +export default function usePrint() { const buttonRef = ref(null); const A4_HEIGHT_MM = 297; const A4_HEIGHT_MM_TO_PX_PROPORTION = 3.78; - let A4_HEIGHT_PX = - A4_HEIGHT_MM * A4_HEIGHT_MM_TO_PX_PROPORTION - THEAD_HEIGHT; + let A4_HEIGHT_PX = A4_HEIGHT_MM * A4_HEIGHT_MM_TO_PX_PROPORTION; let elements = []; const printObj = { id: "printContent", @@ -16,9 +15,9 @@ export default function usePrint(THEAD_HEIGHT) { const fnPrint = () => { document.querySelector("#printContent").style.overflow = "visible"; elements = document.querySelectorAll("#printContent > table > tr"); - if (!document.querySelector("#printContent > table thead")) { - A4_HEIGHT_PX = A4_HEIGHT_PX + THEAD_HEIGHT; - } + const thead = document.querySelector("#printContent > table thead"); + if (thead) A4_HEIGHT_PX = A4_HEIGHT_PX - thead.offsetHeight; + else A4_HEIGHT_PX = A4_HEIGHT_PX + thead.offsetHeight; fnIsPaging(); buttonRef.value.$el.click(); }; diff --git a/src/components/pdf/index.vue b/src/components/pdf/index.vue index 7dc3b15..73ecff2 100644 --- a/src/components/pdf/index.vue +++ b/src/components/pdf/index.vue @@ -1,5 +1,9 @@