sqs.vue
2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-11-22 17:09:14
-->
<template>
<div style="text-align:center">
<el-button type="primary" @click="handlePrint(1)">打印第1页</el-button>
<el-button type="primary" @click="handlePrint(2)">打印第2页</el-button>
<!-- 打印模板需要此模块 -->
<object
id="LODOP_OB"
classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA"
v-show="false">
<embed
id="LODOP_EM"
type="application/x-print-lodop"
width="820"
height="450"
pluginspage="install_lodop32.exe" />
</object>
</div>
</template>
<script>
import Vue from 'vue'
import { getLodop } from "@/utils/LodopFuncs";
import { getPrintTemplateByCode } from "@/api/print";
import { getPrintApplicationForm } from "@/api/workFlow.js";
export default {
props: {
formData: {
type: Object,
default: () => {
return {}
}
}
},
data () {
return {
}
},
methods: {
handlePrint (val) {
if (val == 1) {
getPrintTemplateByCode({ tmpno: Vue.prototype.BASE_API.adapter }).then(res => {
if (res.code === 200) {
getPrintApplicationForm(this.formData.bsmSldy).then(infoRes => {
if (infoRes.code === 200) {
let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
// 装载第一个模板并设置数据
LODOP.ADD_PRINT_DATA("ProgramData", res.result.tmpcontent);
for (let key in infoRes.result) {
LODOP.SET_PRINT_STYLEA(key, "CONTENT", infoRes.result[key]);
}
// 进行预览
LODOP.PREVIEW();
} else {
this.$message.error(infoRes.message);
}
});
} else {
this.$message.error(res.message);
}
})
} else {
getPrintTemplateByCode({ tmpno: Vue.prototype.BASE_API.adapter + '-2' }).then(res => {
if (res.code === 200) {
getPrintApplicationForm(this.formData.bsmSldy).then(infoRes => {
if (infoRes.code === 200) {
let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
// 装载第一个模板并设置数据
LODOP.ADD_PRINT_DATA("ProgramData", res.result.tmpcontent);
for (let key in infoRes.result) {
LODOP.SET_PRINT_STYLEA(key, "CONTENT", infoRes.result[key]);
}
// 进行预览
LODOP.PREVIEW();
} else {
this.$message.error(infoRes.message);
}
});
} else {
this.$message.error(res.message);
}
})
}
}
}
}
</script>