修改看版配置

master
夜笙歌 2 weeks ago
parent e727a76170
commit 7d6648fa01

@ -39,11 +39,13 @@
"file-saver": "2.0.5", "file-saver": "2.0.5",
"fuse.js": "7.0.0", "fuse.js": "7.0.0",
"highlight.js": "11.9.0", "highlight.js": "11.9.0",
"html2canvas": "^1.4.1",
"image-conversion": "^2.1.1", "image-conversion": "^2.1.1",
"js-beautify": "1.14.11", "js-beautify": "1.14.11",
"js-cookie": "3.0.5", "js-cookie": "3.0.5",
"jsbarcode": "^3.11.6", "jsbarcode": "^3.11.6",
"jsencrypt": "3.3.2", "jsencrypt": "3.3.2",
"jspdf": "^3.0.1",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"pinia": "2.1.7", "pinia": "2.1.7",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",

@ -98,18 +98,22 @@
</div> </div>
</div> </div>
<el-dialog v-model="isView" title="预览"> <el-dialog v-model="isView" title="预览">
<div id="printInfo" v-if="isView"> <div id="printInfo" v-if="isView" ref="printRef">
<View /> <View />
</div> </div>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button type="primary" v-print="printInfoObj"></el-button> <el-button type="primary" @click="printFun"></el-button>
<!-- <el-button type="primary" v-print="printInfoObj"></el-button>-->
<el-button @click="isView = false">关闭</el-button> <el-button @click="isView = false">关闭</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { VueFlow, useVueFlow } from '@vue-flow/core'; import { VueFlow, useVueFlow } from '@vue-flow/core';
@ -129,6 +133,7 @@ const router = useRouter();
const { onDragStart, onDrop, onDragOver } = tool(); const { onDragStart, onDrop, onDragOver } = tool();
const { cmToPx } = options; const { cmToPx } = options;
const printRef = ref();
const isView = ref(false); const isView = ref(false);
const flowRef = ref(); const flowRef = ref();
const isSnapToGrid = ref(true); const isSnapToGrid = ref(true);
@ -254,7 +259,15 @@ const printInfoObj = {
console.log('触发预览的回调'); console.log('触发预览的回调');
} }
}; };
const printFun = () => {
const element = printRef.value;
html2canvas(element).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF();
pdf.addImage(imgData, 'PNG', 0, 0);
pdf.save(`${new Date().getTime()}.pdf`);
});
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.vue-flow__node-area) { :deep(.vue-flow__node-area) {

Loading…
Cancel
Save