forked from integrated_whb/integrated_whb_vue
init
parent
5db9c3f30a
commit
20a8d64ea1
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<template>
|
||||
<el-dialog title="文档" :model-value="visible && model === 'dialog'">
|
||||
<el-dialog
|
||||
title="文档"
|
||||
:model-value="visible && model === 'dialog'"
|
||||
@update:model-value="visible = false"
|
||||
>
|
||||
<div v-if="visible && model === 'dialog'">
|
||||
<vue-pdf
|
||||
ref="pdfRef"
|
||||
|
@ -53,6 +57,7 @@ const pdfRef = ref(null);
|
|||
const numOfPages = ref(0);
|
||||
watchEffect(() => {
|
||||
if (props.visible) {
|
||||
console.log(1111);
|
||||
const loadingTask = createLoadingTask(VITE_FILE_URL + props.src);
|
||||
loadingTask.promise
|
||||
.then((pdf) => {
|
||||
|
|
|
@ -28,17 +28,13 @@ import usePrint from "@/assets/js/usePrint.js";
|
|||
defineOptions({
|
||||
name: "LayoutPrintTablePackage",
|
||||
});
|
||||
const props = defineProps({
|
||||
theadHeight: {
|
||||
type: Number,
|
||||
default: 81.59,
|
||||
},
|
||||
defineProps({
|
||||
entrance: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
});
|
||||
const { fnPrint, printObj, buttonRef } = usePrint(props.theadHeight);
|
||||
const { fnPrint, printObj, buttonRef } = usePrint();
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
Loading…
Reference in New Issue