Explorar o código

打印还原为html打印

chenrui %!s(int64=3) %!d(string=hai) anos
pai
achega
f88bad3500
Modificáronse 3 ficheiros con 10 adicións e 32 borrados
  1. 1 2
      src/api/sales.js
  2. 8 29
      src/libs/JGPrint.js
  3. 1 1
      vue.config.js

+ 1 - 2
src/api/sales.js

@@ -138,10 +138,9 @@ export const salesDetailPrint = params => {
     method: 'get'
   }
   // 喷墨打印
-  if(params.type=='INK'){
+  if (params.type == 'INK') {
     data.responseType = 'blob'
   }
-  data.responseType = 'blob'
   return axios.request(data)
 }
 // 销售 详情  导出

+ 8 - 29
src/libs/JGPrint.js

@@ -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: 打印预览,打印,导出

+ 1 - 1
vue.config.js

@@ -110,7 +110,7 @@ const vueConfig = {
     proxy: {
       '/api': {
         // target: 'http://192.168.16.151:80/qpls-md',
-        target: 'http://qpls-md.360arrow.com.cn/qpls-md', //  Ô¤·¢²¼
+        target: 'http://p.iscm.360arrow.com/qpls-md', //  Ô¤·¢²¼
         // target: 'http://qpls-md.360arrow.com/qpls-md', //  Éú²ú
         // ws: false,
         ws: true,