|
@@ -129,25 +129,43 @@
|
|
<div @click="previewEvent">
|
|
<div @click="previewEvent">
|
|
<img src="../../assets/teacherdev/word-eyes.png" alt="" /> 预览
|
|
<img src="../../assets/teacherdev/word-eyes.png" alt="" /> 预览
|
|
</div>
|
|
</div>
|
|
- <div @click="download('pdfDom')">
|
|
|
|
|
|
+ <div @click="download2('pdfDom')">
|
|
<img src="../../assets/teacherdev/word-download.png" alt="" /> 下载
|
|
<img src="../../assets/teacherdev/word-download.png" alt="" /> 下载
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="word_main" v-if="writeTableData && writeTableData.result">
|
|
|
|
+ <div
|
|
|
|
+ class="word_main_table"
|
|
|
|
+ v-for="(itemT, indexT) in writeTableData.result"
|
|
|
|
+ :key="indexT"
|
|
|
|
+ >
|
|
|
|
+ <writeTable
|
|
|
|
+ :type="typeIndex"
|
|
|
|
+ :dataConfig="writeTableData"
|
|
|
|
+ :data="itemT"
|
|
|
|
+ :pageNumber="indexT + 1"
|
|
|
|
+ :totalNumber="writeTableData.result.length"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div
|
|
<div
|
|
|
|
+ style="display: none"
|
|
class="word_main"
|
|
class="word_main"
|
|
id="pdfDom"
|
|
id="pdfDom"
|
|
|
|
+ ref="pdfDom"
|
|
v-if="writeTableData && writeTableData.result"
|
|
v-if="writeTableData && writeTableData.result"
|
|
>
|
|
>
|
|
<div
|
|
<div
|
|
- class="word_main_table"
|
|
|
|
|
|
+ class="none_word_main_table"
|
|
v-for="(itemT, indexT) in writeTableData.result"
|
|
v-for="(itemT, indexT) in writeTableData.result"
|
|
:key="indexT"
|
|
:key="indexT"
|
|
>
|
|
>
|
|
<writeTable
|
|
<writeTable
|
|
- :type="typeIndex"
|
|
|
|
|
|
+ :none="true"
|
|
|
|
+ :type="'none' + typeIndex"
|
|
:dataConfig="writeTableData"
|
|
:dataConfig="writeTableData"
|
|
:data="itemT"
|
|
:data="itemT"
|
|
- :pageNumber="indexT + 1"
|
|
|
|
|
|
+ :pageNumber="' ' + (indexT + 1)"
|
|
:totalNumber="writeTableData.result.length"
|
|
:totalNumber="writeTableData.result.length"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
@@ -211,6 +229,9 @@ import writeTable from "./writeTable.vue";
|
|
import html2canvas from "html2canvas";
|
|
import html2canvas from "html2canvas";
|
|
import { jsPDF } from "jspdf";
|
|
import { jsPDF } from "jspdf";
|
|
import canvg from "canvg";
|
|
import canvg from "canvg";
|
|
|
|
+
|
|
|
|
+import FileSaver from "file-saver";
|
|
|
|
+import htmlDocx from "html-docx-js/dist/html-docx";
|
|
export default {
|
|
export default {
|
|
//import引入的组件需要注入到对象中才能使用
|
|
//import引入的组件需要注入到对象中才能使用
|
|
components: {
|
|
components: {
|
|
@@ -386,17 +407,20 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
download2() {
|
|
download2() {
|
|
- // 1
|
|
|
|
- // this.getPdf("#pdfDom")
|
|
|
|
- // 2
|
|
|
|
- var pdf = new jsPDF("", "pt", "a4");
|
|
|
|
- pdf.html(document.getElementById("pdfDom"), {
|
|
|
|
- // 只有 addFileToVFS 方法添加的字体才能用于 .html 方法
|
|
|
|
- callback: function (pdf) {
|
|
|
|
- //pdf.output('datauristring');// 渲染 pdf
|
|
|
|
- pdf.save("A4.pdf"); //自动下载
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
|
|
+ var printBox = document.getElementById("pdfDom");
|
|
|
|
+ // var printBox = document.getElementsByClassName("pdfDom")[0];
|
|
|
|
+ //拿到打印的区域的html内容
|
|
|
|
+ var newContent = printBox.innerHTML;
|
|
|
|
+ //将旧的页面储存起来,当打印完成后返给给页面。
|
|
|
|
+ var oldContent = document.body.innerHTML;
|
|
|
|
+ //赋值给body
|
|
|
|
+ document.body.innerHTML = newContent;
|
|
|
|
+ //执行window.print打印功能
|
|
|
|
+ window.print();
|
|
|
|
+ // 重新加载页面,以刷新数据。以防打印完之后,页面不能操作的问题
|
|
|
|
+ window.location.reload();
|
|
|
|
+ document.body.innerHTML = oldContent;
|
|
|
|
+ return false;
|
|
},
|
|
},
|
|
changepreviewIndex(type) {
|
|
changepreviewIndex(type) {
|
|
if (type == "add") {
|
|
if (type == "add") {
|