|
|
@ -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) {
|
|
|
|