forked from integrated_whb/integrated_whb_vue
init
parent
5db9c3f30a
commit
20a8d64ea1
|
@ -1,11 +1,10 @@
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
export default function usePrint(THEAD_HEIGHT) {
|
export default function usePrint() {
|
||||||
const buttonRef = ref(null);
|
const buttonRef = ref(null);
|
||||||
const A4_HEIGHT_MM = 297;
|
const A4_HEIGHT_MM = 297;
|
||||||
const A4_HEIGHT_MM_TO_PX_PROPORTION = 3.78;
|
const A4_HEIGHT_MM_TO_PX_PROPORTION = 3.78;
|
||||||
let A4_HEIGHT_PX =
|
let A4_HEIGHT_PX = A4_HEIGHT_MM * A4_HEIGHT_MM_TO_PX_PROPORTION;
|
||||||
A4_HEIGHT_MM * A4_HEIGHT_MM_TO_PX_PROPORTION - THEAD_HEIGHT;
|
|
||||||
let elements = [];
|
let elements = [];
|
||||||
const printObj = {
|
const printObj = {
|
||||||
id: "printContent",
|
id: "printContent",
|
||||||
|
@ -16,9 +15,9 @@ export default function usePrint(THEAD_HEIGHT) {
|
||||||
const fnPrint = () => {
|
const fnPrint = () => {
|
||||||
document.querySelector("#printContent").style.overflow = "visible";
|
document.querySelector("#printContent").style.overflow = "visible";
|
||||||
elements = document.querySelectorAll("#printContent > table > tr");
|
elements = document.querySelectorAll("#printContent > table > tr");
|
||||||
if (!document.querySelector("#printContent > table thead")) {
|
const thead = document.querySelector("#printContent > table thead");
|
||||||
A4_HEIGHT_PX = A4_HEIGHT_PX + THEAD_HEIGHT;
|
if (thead) A4_HEIGHT_PX = A4_HEIGHT_PX - thead.offsetHeight;
|
||||||
}
|
else A4_HEIGHT_PX = A4_HEIGHT_PX + thead.offsetHeight;
|
||||||
fnIsPaging();
|
fnIsPaging();
|
||||||
buttonRef.value.$el.click();
|
buttonRef.value.$el.click();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<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'">
|
<div v-if="visible && model === 'dialog'">
|
||||||
<vue-pdf
|
<vue-pdf
|
||||||
ref="pdfRef"
|
ref="pdfRef"
|
||||||
|
@ -53,6 +57,7 @@ const pdfRef = ref(null);
|
||||||
const numOfPages = ref(0);
|
const numOfPages = ref(0);
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (props.visible) {
|
if (props.visible) {
|
||||||
|
console.log(1111);
|
||||||
const loadingTask = createLoadingTask(VITE_FILE_URL + props.src);
|
const loadingTask = createLoadingTask(VITE_FILE_URL + props.src);
|
||||||
loadingTask.promise
|
loadingTask.promise
|
||||||
.then((pdf) => {
|
.then((pdf) => {
|
||||||
|
|
|
@ -28,17 +28,13 @@ import usePrint from "@/assets/js/usePrint.js";
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "LayoutPrintTablePackage",
|
name: "LayoutPrintTablePackage",
|
||||||
});
|
});
|
||||||
const props = defineProps({
|
defineProps({
|
||||||
theadHeight: {
|
|
||||||
type: Number,
|
|
||||||
default: 81.59,
|
|
||||||
},
|
|
||||||
entrance: {
|
entrance: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "",
|
default: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { fnPrint, printObj, buttonRef } = usePrint(props.theadHeight);
|
const { fnPrint, printObj, buttonRef } = usePrint();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in New Issue