Browse Source

打印优化

lilei 3 years ago
parent
commit
dff02770cf

+ 1 - 1
src/libs/JGPrint.js

@@ -171,7 +171,7 @@ export const jGPrintPdf = function (data, type, taskName) {
       return
       return
     }
     }
     blobToBaseByPdf(data, function (dataurl) {
     blobToBaseByPdf(data, function (dataurl) {
-      console.log(dataurl)
+      // console.log(dataurl)
       LODOP.PRINT_INIT(taskName)
       LODOP.PRINT_INIT(taskName)
       LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) //  隐藏底图上有模拟走纸板的条纹线
       LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) //  隐藏底图上有模拟走纸板的条纹线
       //执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态
       //执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态

+ 4 - 31
src/views/allocationManagement/transferOut/detail.vue

@@ -92,7 +92,7 @@
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import printModal from './printModal.vue'
 import printModal from './printModal.vue'
-import { hdExportExcel } from '@/libs/exportExcel'
+import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint, allocateBillDetailExcel } from '@/api/allocateBill'
 import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint, allocateBillDetailExcel } from '@/api/allocateBill'
 export default {
 export default {
   name: 'TransferOutDetail',
   name: 'TransferOutDetail',
@@ -193,7 +193,7 @@ export default {
     handleExcel () {
     handleExcel () {
       const _this = this
       const _this = this
       this.spinning = true
       this.spinning = true
-      hdExportExcel(allocateBillDetailExcel, { allocateSn: this.outBizSn || this.$route.params.sn }, '调拨明细', function () {
+      exportExcel(allocateBillDetailExcel, { allocateSn: this.outBizSn || this.$route.params.sn }, '调拨明细', function () {
         _this.spinning = false
         _this.spinning = false
       })
       })
     },
     },
@@ -207,35 +207,8 @@ export default {
       const params = JSON.parse(JSON.stringify(objs))
       const params = JSON.parse(JSON.stringify(objs))
       delete params.type
       delete params.type
       _this.spinning = true
       _this.spinning = true
-      allocateBillDetailPrint(params).then(res => {
-        _this.spinning = false
-        if (res.type == 'application/json') {
-          var reader = new FileReader()
-          reader.addEventListener('loadend', function () {
-            const obj = JSON.parse(reader.result)
-            _this.$notification.error({
-              message: '提示',
-              description: obj.message
-            })
-          })
-          reader.readAsText(res)
-        } else {
-          this.print(res, objs.isPreview)
-        }
-      })
-    },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printftod" name="printftod" src="' + url + '" hidden></iframe>'
-      if (type == '1') { //  预览
-        window.open(url)
-      } else if (type == '0') { //  打印
-        window.frames['printftod'].focus()
-        window.frames['printftod'].print()
-      }
+      const taskName = this.nowType == 'dbPrint' ? '调拨' : '调拨分类'
+      printFun(allocateBillDetailPrint, params, objs.isPreview ? 'preview' : 'print', taskName, () => { _this.spinning = false })
     },
     },
     pageInit () {
     pageInit () {
       this.$refs.table.refresh(true)
       this.$refs.table.refresh(true)

+ 4 - 31
src/views/allocationManagement/transferOut/edit.vue

@@ -229,7 +229,7 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import ImportGuideModal from './importGuideModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import printModal from './printModal.vue'
 import printModal from './printModal.vue'
-import { hdExportExcel } from '@/libs/exportExcel'
+import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { queryStockProductPage } from '@/api/stock'
 import { queryStockProductPage } from '@/api/stock'
 import { productPriceInfo } from '@/api/product'
 import { productPriceInfo } from '@/api/product'
 import AllocateType from '@/views/common/allocateType.js'
 import AllocateType from '@/views/common/allocateType.js'
@@ -542,7 +542,7 @@ export default {
     handleExcel () {
     handleExcel () {
       const _this = this
       const _this = this
       this.spinning = true
       this.spinning = true
-      hdExportExcel(allocateBillDetailExcel, { allocateSn: this.$route.params.sn }, '调拨明细', function () {
+      exportExcel(allocateBillDetailExcel, { allocateSn: this.outBizSn || this.$route.params.sn }, '调拨明细', function () {
         _this.spinning = false
         _this.spinning = false
       })
       })
     },
     },
@@ -556,35 +556,8 @@ export default {
       const params = JSON.parse(JSON.stringify(objs))
       const params = JSON.parse(JSON.stringify(objs))
       delete params.type
       delete params.type
       _this.spinning = true
       _this.spinning = true
-      allocateBillDetailPrint(params).then(res => {
-        _this.spinning = false
-        if (res.type == 'application/json') {
-          var reader = new FileReader()
-          reader.addEventListener('loadend', function () {
-            const obj = JSON.parse(reader.result)
-            _this.$notification.error({
-              message: '提示',
-              description: obj.message
-            })
-          })
-          reader.readAsText(res)
-        } else {
-          this.print(res, objs.isPreview)
-        }
-      })
-    },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printftoe" name="printftoe" src="' + url + '" hidden></iframe>'
-      if (type == '1') { //  预览
-        window.open(url)
-      } else if (type == '0') { //  打印
-        window.frames['printftoe'].focus()
-        window.frames['printftoe'].print()
-      }
+      const taskName = this.nowType == 'dbPrint' ? '调拨' : '调拨分类'
+      printFun(allocateBillDetailPrint, params, objs.isPreview ? 'preview' : 'print', taskName, () => { _this.spinning = false })
     },
     },
     // 刷新当前页面
     // 刷新当前页面
     refashPage () {
     refashPage () {

+ 6 - 36
src/views/allocationManagement/transferReturn/print.vue

@@ -6,7 +6,7 @@
       v-if="$hasPermissions('B_transferReturnPrint')"
       v-if="$hasPermissions('B_transferReturnPrint')"
       id="editGrap-db-print-btn"
       id="editGrap-db-print-btn"
       :disabled="disabled"
       :disabled="disabled"
-      @click="handlePrint('views')">打印预览</a-button>
+      @click="handlePrint('preview')">打印预览</a-button>
     <a-button
     <a-button
       key="2"
       key="2"
       type="primary"
       type="primary"
@@ -30,7 +30,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import { hdExportExcel } from '@/libs/exportExcel'
+import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { allocateReturnExcel, allocateReturnPrint } from '@/api/allocateReturn'
 import { allocateReturnExcel, allocateReturnPrint } from '@/api/allocateReturn'
 export default {
 export default {
   props: {
   props: {
@@ -51,44 +51,14 @@ export default {
       const params = {
       const params = {
         allocateReturnSn: this.params.allocateReturnSn || ''
         allocateReturnSn: this.params.allocateReturnSn || ''
       }
       }
-      this.$emit('loading')
-      allocateReturnPrint(params).then(res => {
-        _this.spinning = false
-        if (res.type == 'application/json') {
-          var reader = new FileReader()
-          reader.addEventListener('loadend', function () {
-            const obj = JSON.parse(reader.result)
-            _this.$notification.error({
-              message: '提示',
-              description: obj.message
-            })
-          })
-          reader.readAsText(res)
-        } else {
-          this.print(res, type)
-        }
-        _this.$emit('unloading')
-      })
-    },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      console.log(url)
-      document.getElementById('print').innerHTML = '<iframe id="printftoe" name="printftoe" src="' + url + '" hidden></iframe>'
-      if (type == 'views') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printftoe'].focus()
-        window.frames['printftoe'].print()
-      }
+      _this.$emit('loading')
+      printFun(allocateReturnPrint, params, type, '调拨退货单', () => { _this.$emit('unloading') })
     },
     },
     // 导出
     // 导出
     handleExcel () {
     handleExcel () {
       const _this = this
       const _this = this
-      this.$emit('loading')
-      hdExportExcel(allocateReturnExcel, { allocateReturnSn: this.params.allocateReturnSn || '' }, '调拨退货单明细', function () {
+      _this.$emit('loading')
+      exportExcel(allocateReturnExcel, { allocateReturnSn: this.params.allocateReturnSn || '' }, '调拨退货单明细', function () {
         _this.$emit('unloading')
         _this.$emit('unloading')
       })
       })
     }
     }

+ 3 - 31
src/views/inventoryManagement/makeInventory/check.vue

@@ -150,8 +150,6 @@
       @close="visiblePrint=false"
       @close="visiblePrint=false"
       @ok="printOkText == '好的' ? visiblePrint=false : handlePrint('print')"
       @ok="printOkText == '好的' ? visiblePrint=false : handlePrint('print')"
       @fail="handlePrint('preview')" />
       @fail="handlePrint('preview')" />
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -160,6 +158,7 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import tablePagination from '@/views/common/tablePagination.vue'
 import tablePagination from '@/views/common/tablePagination.vue'
 import printModal from '@/views/common/auditModal.vue'
 import printModal from '@/views/common/auditModal.vue'
+import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseCheck } from '@/api/checkWarehouse'
 import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseCheck } from '@/api/checkWarehouse'
 export default {
 export default {
   name: 'MakeInventoryCheck',
   name: 'MakeInventoryCheck',
@@ -382,35 +381,8 @@ export default {
     handlePrint (type) {
     handlePrint (type) {
       const _this = this
       const _this = this
       _this.spinningPrint = true
       _this.spinningPrint = true
-      checkWarehouseDetailPrint({ checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE' }).then(res => {
-        _this.spinningPrint = false
-        if (res.type == 'application/json') {
-          var reader = new FileReader()
-          reader.addEventListener('loadend', function () {
-            const obj = JSON.parse(reader.result)
-            _this.$notification.error({
-              message: '提示',
-              description: obj.message
-            })
-          })
-          reader.readAsText(res)
-        } else {
-          this.print(res, type)
-        }
-      })
-    },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfbod'].focus()
-        window.frames['printfbod'].print()
-      }
+      const params = { checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE' }
+      printFun(checkWarehouseDetailPrint, params, type, '盘点单', () => { _this.spinningPrint = false })
     }
     }
   },
   },
   mounted () {
   mounted () {

+ 3 - 31
src/views/inventoryManagement/supervisionDisk/check.vue

@@ -159,8 +159,6 @@
       @close="visiblePrint=false"
       @close="visiblePrint=false"
       @ok="printOkText == '好的' ? visiblePrint=false : handlePrint('print')"
       @ok="printOkText == '好的' ? visiblePrint=false : handlePrint('print')"
       @fail="handlePrint('preview')" />
       @fail="handlePrint('preview')" />
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -169,6 +167,7 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import tablePagination from '@/views/common/tablePagination.vue'
 import tablePagination from '@/views/common/tablePagination.vue'
 import printModal from '@/views/common/auditModal.vue'
 import printModal from '@/views/common/auditModal.vue'
+import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseSupervise, checkWarehouseReCheck } from '@/api/checkWarehouse'
 import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseSupervise, checkWarehouseReCheck } from '@/api/checkWarehouse'
 export default {
 export default {
   name: 'SupervisionDiskCheck',
   name: 'SupervisionDiskCheck',
@@ -414,35 +413,8 @@ export default {
     handlePrint (type) {
     handlePrint (type) {
       const _this = this
       const _this = this
       _this.spinningPrint = true
       _this.spinningPrint = true
-      checkWarehouseDetailPrint({ checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE_SUPERVISE' }).then(res => {
-        _this.spinningPrint = false
-        if (res.type == 'application/json') {
-          var reader = new FileReader()
-          reader.addEventListener('loadend', function () {
-            const obj = JSON.parse(reader.result)
-            _this.$notification.error({
-              message: '提示',
-              description: obj.message
-            })
-          })
-          reader.readAsText(res)
-        } else {
-          this.print(res, type)
-        }
-      })
-    },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfbod'].focus()
-        window.frames['printfbod'].print()
-      }
+      const params = { checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE_SUPERVISE' }
+      printFun(checkWarehouseDetailPrint, params, type, '盘点单', () => { _this.spinningPrint = false })
     }
     }
   },
   },
   mounted () {
   mounted () {

+ 3 - 29
src/views/salesManagement/backorder/detailModal.vue

@@ -53,6 +53,7 @@
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
 import { STable } from '@/components'
 import { STable } from '@/components'
+import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { oosDetail, oosDetailList, oosDetailPrint } from '@/api/oos'
 import { oosDetail, oosDetailList, oosDetailPrint } from '@/api/oos'
 export default {
 export default {
   name: 'BackorderDetailModal',
   name: 'BackorderDetailModal',
@@ -125,35 +126,8 @@ export default {
     handlePrint (type) {
     handlePrint (type) {
       const _this = this
       const _this = this
       _this.spinning = true
       _this.spinning = true
-      oosDetailPrint({ sn: this.itemSn }).then(res => {
-        _this.spinning = false
-        if (res.type == 'application/json') {
-          var reader = new FileReader()
-          reader.addEventListener('loadend', function () {
-            const obj = JSON.parse(reader.result)
-            _this.$notification.error({
-              message: '提示',
-              description: obj.message
-            })
-          })
-          reader.readAsText(res)
-        } else {
-          this.print(res, type)
-        }
-      })
-    },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfbod'].focus()
-        window.frames['printfbod'].print()
-      }
+      // 打印或预览
+      printFun(oosDetailPrint, { sn: this.itemSn }, type, '缺货单', () => { _this.spinning = false })
     }
     }
   },
   },
   watch: {
   watch: {

+ 0 - 1
src/views/salesManagement/salesReturn/detail.vue

@@ -104,7 +104,6 @@
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
-import moment from 'moment'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import { printFun, exportExcel } from '@/libs/JGPrint.js'