|
@@ -7,12 +7,9 @@ export const JGPrint = function (data, type, printerType) {
|
|
|
if (!data) {
|
|
|
return
|
|
|
}
|
|
|
- const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
- document.getElementById('print').innerHTML = '<iframe id="printfsqd" name="printfsqd" src="' + url + '" hidden></iframe>'
|
|
|
// 针式打印
|
|
|
if (printerType == 'NEEDLE') {
|
|
|
const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
- console.log(LODOP)
|
|
|
if (!LODOP) {
|
|
|
confirm({
|
|
|
title: '提示?',
|
|
@@ -26,16 +23,17 @@ export const JGPrint = function (data, type, printerType) {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ console.log('+++data', data)
|
|
|
const rx = /<body[^>]*>([\s\S]+?)<\/body>/i///
|
|
|
let m = rx.exec(data)
|
|
|
if (m) m = m[1]
|
|
|
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
- // LODOP.SET_PRINT_PAGESIZE(3, '2140', '60', '') // 这里3表示纵向打印且纸高“按内容的高度”;2140表示纸宽214.0mm;60表示页底空白6.0mm
|
|
|
- // LODOP.ADD_PRINT_HTM('0', '0', 'RightMargin:0.5cm', 'BottomMargin:0.5cm', m)
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3, '2100', '60', '') // 这里3表示纵向打印且纸高“按内容的高度”;2140表示纸宽214.0mm;60表示页底空白6.0mm
|
|
|
+ LODOP.ADD_PRINT_HTM('0', '0', 'RightMargin:0.1cm', 'BottomMargin:0.1cm', m)
|
|
|
// LODOP.ADD_PRINT_TABLE(0, 0, '100%', '100%', m)
|
|
|
- LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', new Blob([data], { type: 'application/pdf' }))
|
|
|
- LODOP.SET_PRINT_STYLEA(0, 'PDFScalMode', 1)
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3, 0, 0, '')
|
|
|
+ // LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data)
|
|
|
+ // LODOP.SET_PRINT_STYLEA(0, 'PDFScalMode', 1)
|
|
|
+ // LODOP.SET_PRINT_PAGESIZE(3, 0, 0, '')
|
|
|
if (type == 'preview') {
|
|
|
LODOP.PREVIEW()
|
|
|
}
|
|
@@ -44,6 +42,8 @@ export const JGPrint = function (data, type, printerType) {
|
|
|
}
|
|
|
} else {
|
|
|
// 喷墨打印
|
|
|
+ const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
+ document.getElementById('print').innerHTML = '<iframe id="printfsqd" name="printfsqd" src="' + url + '" hidden></iframe>'
|
|
|
if (type == 'preview') { // 预览
|
|
|
window.open(url)
|
|
|
} else if (type == 'print') { // 打印
|
|
@@ -104,27 +104,6 @@ export const downloadExcel = function (data, fileName) {
|
|
|
link.click()
|
|
|
}
|
|
|
|
|
|
-// 文件流转url
|
|
|
-export const getObjectURL = function (file) {
|
|
|
- let url = null
|
|
|
- if (window.createObjectURL != undefined) { // basic
|
|
|
- url = window.createObjectURL(file)
|
|
|
- } else if (window.webkitURL != undefined) { // webkit
|
|
|
- try {
|
|
|
- url = window.webkitURL.createObjectURL(file)
|
|
|
- } catch (error) {
|
|
|
-
|
|
|
- }
|
|
|
- } else if (window.URL != undefined) { // mozilla(firefox)
|
|
|
- try {
|
|
|
- url = window.URL.createObjectURL(file)
|
|
|
- } catch (error) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- return url
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
*printerType: 打印机类型
|
|
|
*type: 打印预览,打印,导出
|