瀏覽代碼

打印修改

lilei 3 年之前
父節點
當前提交
16c64ddb1c

+ 74 - 74
src/libs/JGPrint.js

@@ -30,51 +30,51 @@ export const JGPrintTag = function (html, width, height, data) {
   LODOP.PRINT()
 }
 // 打印控件
-export const JGPrint = function (data, type, printerType) {
-  if (!data) {
-    return
-  }
-  // 针式打印
-  if (printerType == 'NEEDLE') {
-    const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
-    console.log(LODOP, 'LODOP')
-    if (!LODOP) {
-      confirm({
-        title: '提示?',
-        content: h => <div>打印控件未安装,请先下载并安装。安装完成后,刷新页面即可打印。</div>,
-        okText: '立即下载',
-        okType: 'danger',
-        cancelText: '暂不打印',
-        onOk () {
-          window.open('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
-        }
-      })
-      return
-    }
-    LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) //  隐藏底图上有模拟走纸板的条纹线
-    LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
-    LODOP.ADD_PRINT_HTM('0', '0', 'RightMargin:0cm', 'BottomMargin:0cm', data)
-    LODOP.SET_PRINT_PAGESIZE(3, 2090, 45, '') // 这里3表示纵向打印且纸高“按内容的高度”;2140表示纸宽214.0mm;60表示页底空白6.0mm
-    // LODOP.SET_PRINT_PAGESIZE(1, 2090, 1000, '')
-    // LODOP.ADD_PRINT_HTM('0', '0', '595pt', 1000, data)
-    if (type == 'preview') {
-      LODOP.PREVIEW()
-    }
-    if (type == 'print') {
-      LODOP.PRINT()
-    }
-  } 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') { //  打印
-      window.frames['printfsqd'].focus()
-      window.frames['printfsqd'].print()
-    }
-  }
-}
+// export const JGPrint = function (data, type, printerType) {
+//   if (!data) {
+//     return
+//   }
+//   // 针式打印
+//   if (printerType == 'NEEDLE') {
+//     const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
+//     console.log(LODOP, 'LODOP')
+//     if (!LODOP) {
+//       confirm({
+//         title: '提示?',
+//         content: h => <div>打印控件未安装,请先下载并安装。安装完成后,刷新页面即可打印。</div>,
+//         okText: '立即下载',
+//         okType: 'danger',
+//         cancelText: '暂不打印',
+//         onOk () {
+//           window.open('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
+//         }
+//       })
+//       return
+//     }
+//     LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) //  隐藏底图上有模拟走纸板的条纹线
+//     LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
+//     LODOP.ADD_PRINT_HTM('0', '0', 'RightMargin:0cm', 'BottomMargin:0cm', data)
+//     LODOP.SET_PRINT_PAGESIZE(3, 2090, 45, '') // 这里3表示纵向打印且纸高“按内容的高度”;2140表示纸宽214.0mm;60表示页底空白6.0mm
+//     // LODOP.SET_PRINT_PAGESIZE(1, 2090, 1000, '')
+//     // LODOP.ADD_PRINT_HTM('0', '0', '595pt', 1000, data)
+//     if (type == 'preview') {
+//       LODOP.PREVIEW()
+//     }
+//     if (type == 'print') {
+//       LODOP.PRINT()
+//     }
+//   } 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') { //  打印
+//       window.frames['printfsqd'].focus()
+//       window.frames['printfsqd'].print()
+//     }
+//   }
+// }
 
 export const demoGetBASE64 = function (dataArray) {
   var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
@@ -142,32 +142,32 @@ export const downloadExcel = function (data, fileName) {
   *fileName: 导出文件名称
   *callback: 回调函数
 */
-export const hdPrint = function (printerType, type, url, params, fileName, callback) {
-  // 打印时需要传打印机类型
-  if (type !== 'export') {
-    params.type = printerType
-  }
-  url(params).then(res => {
-    if (res.type == 'application/json') {
-      var reader = new FileReader()
-      reader.addEventListener('loadend', function () {
-        const obj = JSON.parse(reader.result)
-        notification.error({
-          message: '提示',
-          description: obj.message
-        })
-      })
-      reader.readAsText(res)
-    } else {
-      if (type == 'export') { //  导出
-        downloadExcel(res, fileName)
-      } else { // 打印
-        JGPrint(res, type, printerType)
-      }
-    }
-    callback()
-  })
-}
+// export const hdPrint = function (printerType, type, url, params, fileName, callback) {
+//   // 打印时需要传打印机类型
+//   if (type !== 'export') {
+//     params.type = printerType
+//   }
+//   url(params).then(res => {
+//     if (res.type == 'application/json') {
+//       var reader = new FileReader()
+//       reader.addEventListener('loadend', function () {
+//         const obj = JSON.parse(reader.result)
+//         notification.error({
+//           message: '提示',
+//           description: obj.message
+//         })
+//       })
+//       reader.readAsText(res)
+//     } else {
+//       if (type == 'export') { //  导出
+//         downloadExcel(res, fileName)
+//       } else { // 打印
+//         JGPrint(res, type, printerType)
+//       }
+//     }
+//     callback()
+//   })
+// }
 
 
 /*
@@ -178,7 +178,7 @@ export const hdPrint = function (printerType, type, url, params, fileName, callb
   *fileName: 导出文件名称
   *callback: 回调函数
 */
-export const newHdPrint = function (printerType, type, url, params, fileName, callback) {
+export const hdPrint = function (printerType, type, url, params, fileName, callback) {
   // 打印时需要传打印机类型
   if (type !== 'export') {
     params.type = printerType
@@ -203,7 +203,7 @@ export const newHdPrint = function (printerType, type, url, params, fileName, ca
       if (type == 'export') { //  导出
         downloadExcel(res, fileName)
       } else { // 打印
-        newJGPrint(res, type, printerType)
+        jGPrint(res, type, printerType)
       }
     }
     callback()
@@ -211,7 +211,7 @@ export const newHdPrint = function (printerType, type, url, params, fileName, ca
 }
 
 // 打印控件
-export const newJGPrint = function (data, type, printerType) {
+export const jGPrint = function (data, type, printerType) {
   if (!data) {
     return
   }

+ 2 - 2
src/views/purchasingManagement/purchaseOrder/detail.vue

@@ -145,7 +145,7 @@ import { STable, VSelect } from '@/components'
 import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
 import { purchaseDetailList } from '@/api/purchaseDetail'
 import Print from '@/views/common/print.vue'
-import { newHdPrint, downloadExcel } from '@/libs/JGPrint'
+import { hdPrint, downloadExcel } from '@/libs/JGPrint'
 export default {
   name: 'PurchaseDetail',
   components: { STable, VSelect, Print },
@@ -219,7 +219,7 @@ export default {
         params = { sn: this.$route.params.sn }
       }
       // 打印或导出
-      newHdPrint(printerType, type, url, params, '采购单', function () {
+      hdPrint(printerType, type, url, params, '采购单', function () {
         _this.spinning = false
       })
     },

+ 2 - 2
src/views/purchasingManagement/purchaseOrder/edit.vue

@@ -250,7 +250,7 @@ import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDeta
 import { productListPurchase } from '@/api/product'
 import defImg from '@/assets/def_img@2x.png'
 import Print from '@/views/common/print.vue'
-import { newHdPrint } from '@/libs/JGPrint'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'PurchaseEdit',
   components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print, chooseAddressModal },
@@ -539,7 +539,7 @@ export default {
         params = { sn: this.$route.params.sn }
       }
       // 打印或导出
-      newHdPrint(printerType, type, url, params, '采购单', function () {
+      hdPrint(printerType, type, url, params, '采购单', function () {
         _this.spinning = false
       })
     },