lilei 3 tahun lalu
induk
melakukan
720582a8e5

+ 48 - 0
src/libs/JGPrint.js

@@ -0,0 +1,48 @@
+import confirm from 'ant-design-vue/es/modal/confirm'
+import { getLodop } from '@/libs/LodopFuncs'
+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)
+    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
+    }
+    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;45表示页底空白4.5mm
+    LODOP.ADD_PRINT_HTM("0","0","RightMargin:0.5cm","BottomMargin:0.5cm",m);
+    // LODOP.ADD_PRINT_TABLE(0, 0, '100%', '100%', m)
+    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()
+    }
+  }
+}

+ 2 - 48
src/views/salesManagement/salesQuery/detail.vue

@@ -98,7 +98,7 @@ import { getOperationalPrecision } from '@/libs/tools.js'
 import { STable, VSelect } from '@/components'
 import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
 import { salesDetailList } from '@/api/salesDetail'
-import { getLodop } from '@/libs/LodopFuncs'
+import { JGPrint } from '@/libs/JGPrint'
 export default {
   name: 'SalesDetail',
   components: { STable, VSelect },
@@ -207,57 +207,11 @@ export default {
           if (type == 'export') { //  导出
             this.download(res)
           } else {
-            this.print(res, type)
+            JGPrint(res, type, this.printerType)
           }
         }
       })
     },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      // 针式打印
-      if (this.printerType == 'NEEDLE') {
-        const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
-        console.log(LODOP)
-        if (!LODOP) {
-          this.$confirm({
-            title: '提示?',
-            content: h => <div>打印控件未安装,请先下载并安装。/n安装完成后,刷新页面即可打印。</div>,
-            okText: '立即下载',
-            okType: 'danger',
-            cancelText: '暂不打印',
-            onOk () {
-              window.open('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
-            }
-          })
-          return
-        }
-        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', '45', '') // 这里3表示纵向打印且纸高“按内容的高度”;2140表示纸宽214.0mm;45表示页底空白4.5mm
-        LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', m)
-        // LODOP.ADD_PRINT_TABLE(0, 0, '100%', '100%', m)
-        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()
-        }
-      }
-    },
     download (data) {
       if (!data) { return }
       const url = window.URL.createObjectURL(new Blob([data]))

+ 2 - 14
src/views/salesManagement/salesQuery/edit.vue

@@ -181,6 +181,7 @@
 <script>
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
+import { JGPrint } from '@/libs/JGPrint'
 import queryPart from './queryPart.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
 import { stockByProductSn } from '@/api/stock'
@@ -343,24 +344,11 @@ export default {
           if (type == 'export') { //  导出
             this.download(res)
           } else {
-            this.print(res, type)
+            JGPrint(res, type, this.printerType)
           }
         }
       })
     },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printfsqe" name="printfsqe" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfsqe'].focus()
-        window.frames['printfsqe'].print()
-      }
-    },
     download (data) {
       if (!data) { return }
       const url = window.URL.createObjectURL(new Blob([data]))