# 打印
封装动态加载js
export const dynamicLoadJs=(url, callback?)=>{
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
if (typeof (callback) == 'function') {
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
callback();
script.onload = script.onreadystatechange = null;
}
};
}
head.appendChild(script);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
根据业务动态加载 Lodop
if(localStorage.Userid==32){
let url='//duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/kangsheng/LodopFuncs.js'
dynamicLoadJs(url,()=>{
setTimeout(() => {
window.LODOP = getLodop();
}, 3000);
});
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
组件内引用
window.LODOP.SET_PRINT_PAGESIZE(0, 800, 400, ""); // 设置纸张大小
window.LODOP.NewPage(); // 多张页面可以调用这个 分页打印
// 打印图片
window.LODOP.ADD_PRINT_IMAGE(
a.y,
a.x,
a.h,
a.w,
"<img border='0' src='https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/dxgjAdmin/ksQRcode/i33NSkpmhxYYemrR1658226093440.jpg' />"
);
window.LODOP.SET_PRINT_STYLEA(0, "Stretch", 2);
// end
// 打印文字
window.LODOP.ADD_PRINT_TEXT(
a.y,
a.x,
a.w,
a.h,
a.name + ": x x x x x x"
);
window.LODOP.SET_PRINT_STYLEA(0, "FontSize", a.size);
// 打印
window.LODOP.PREVIEW();
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
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