Browse Source

Merge branch 'deploy_0804' of jianguan-web/qpls-md-html into master

李磊 4 years ago
parent
commit
134bfb8380
30 changed files with 354 additions and 825 deletions
  1. 8 4
      src/api/allocLinkageOut.js
  2. 9 5
      src/api/allocLinkagePut.js
  3. 8 4
      src/api/purchase.js
  4. 8 4
      src/api/receiving.js
  5. 7 3
      src/api/salesReturn.js
  6. 8 4
      src/api/sparePartsPur.js
  7. 8 4
      src/api/storeCallOut.js
  8. 1 1
      src/components/MultiTab/MultiTab.vue
  9. 1 0
      src/layouts/PageView.vue
  10. 53 1
      src/libs/JGPrint.js
  11. 1 2
      src/libs/LodopFuncs.js
  12. 10 39
      src/views/allocationManagement/chainTransferIn/detail.vue
  13. 9 37
      src/views/allocationManagement/chainTransferIn/edit.vue
  14. 10 39
      src/views/allocationManagement/chainTransferOut/detail.vue
  15. 10 39
      src/views/allocationManagement/chainTransferOut/edit.vue
  16. 9 38
      src/views/allocationManagement/storeTransferOut/detail.vue
  17. 10 45
      src/views/allocationManagement/storeTransferOut/edit.vue
  18. 10 39
      src/views/bulkManagement/bulkWarehousingOrder/detail.vue
  19. 10 41
      src/views/bulkManagement/bulkWarehousingOrder/edit.vue
  20. 55 0
      src/views/common/print.vue
  21. 11 37
      src/views/financialManagement/warehousingAudit/detail.vue
  22. 5 5
      src/views/productManagement/newProduct/detail.vue
  23. 19 55
      src/views/purchasingManagement/purchaseOrder/detail.vue
  24. 8 64
      src/views/purchasingManagement/purchaseOrder/edit.vue
  25. 19 63
      src/views/salesManagement/salesQuery/detail.vue
  26. 18 60
      src/views/salesManagement/salesQuery/edit.vue
  27. 9 65
      src/views/salesManagement/salesReturn/detail.vue
  28. 9 63
      src/views/salesManagement/salesReturn/salesReturnEdit.vue
  29. 9 62
      src/views/salesManagement/salesReturn/salesReturnGrabEdit.vue
  30. 2 2
      vue.config.js

+ 8 - 4
src/api/allocLinkageOut.js

@@ -104,9 +104,13 @@ export const getTenantList = (params) => {
 }
 // 连锁调拨调出 详情  打印
 export const allocLinkageOutDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `allocLinkageOut/print/${params.sn}/${params.type}`,
-    method: 'get',
-    responseType: 'blob'
-  })
+    method: 'get'
+  }
+  // 喷墨打印
+  if (params.type == 'INK') {
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
 }

+ 9 - 5
src/api/allocLinkagePut.js

@@ -62,9 +62,13 @@ export const allocLinkagePutDetailUpdate = (params) => {
 }
 // 连锁调拨调入 详情  打印
 export const allocLinkagePutDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `allocLinkagePut/print/${params.sn}/${params.type}`,
-    method: 'get',
-    responseType: 'blob'
-  })
-}
+    method: 'get'
+  }
+  // 喷墨打印
+  if (params.type == 'INK') {
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
+}

+ 8 - 4
src/api/purchase.js

@@ -122,11 +122,15 @@ export const getParentDealer = (params) => {
 }
 // 采购 详情  打印
 export const purchaseDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `purchase/print/${params.sn}/${params.type}`,
-    method: 'get',
-    responseType: 'blob'
-  })
+    method: 'get'
+  }
+  // 喷墨打印
+  if (params.type == 'INK') {
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
 }
 export const purchaseTargetList = (params) => {
   return axios({

+ 8 - 4
src/api/receiving.js

@@ -55,9 +55,13 @@ export const receivingDetailList = (params) => {
 }
 // 入库审核 详情  打印
 export const receivingDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `receiving/print/${params.sn}/${params.type}`,
-    method: 'get',
-    responseType: 'blob'
-  })
+    method: 'get'
+  }
+  // 喷墨打印
+  if (params.type == 'INK') {
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
 }

+ 7 - 3
src/api/salesReturn.js

@@ -162,11 +162,15 @@ export const salesReturnSubmit = (params) => {
 }
 // 销售退货 详情  打印
 export const salesReturnDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `salesReturn/print/${params.sn}/${params.type}`,
     method: 'get',
-    responseType: 'blob'
-  })
+  }
+  // 喷墨打印
+  if(params.type=='INK'){
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
 }
 // 销售退货 详情  导出
 export const salesDetailExport = params => {

+ 8 - 4
src/api/sparePartsPur.js

@@ -113,9 +113,13 @@ export const sparePartsPurDetailDel = (params) => {
 }
 // 散件采购(入库) 详情  打印
 export const sparePartsPurDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `sparePartsPur/print/${params.sn}/${params.type}`,
-    method: 'get',
-    responseType: 'blob'
-  })
+    method: 'get'
+  }
+  // 喷墨打印
+  if (params.type == 'INK') {
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
 }

+ 8 - 4
src/api/storeCallOut.js

@@ -101,9 +101,13 @@ export const storeCallOutDetailDel = (params) => {
 }
 // 店内调出 详情  打印
 export const storeCallOutDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `storeCallOut/print/${params.sn}/${params.type}/${params.costFlag}`,
-    method: 'get',
-    responseType: 'blob'
-  })
+    method: 'get'
+  }
+  // 喷墨打印
+  if (params.type == 'INK') {
+    data.responseType = 'blob'
+  }
+  return axios.request(data)
 }

+ 1 - 1
src/components/MultiTab/MultiTab.vue

@@ -48,7 +48,7 @@ export default {
       const index = this.tabsList.indexOf(targetKey)
       if (index >= 0) {
         const row = this.pages[index]
-        if (row && row.fullPath && row.fullPath.indexOf('/list') == -1) { // 非列表页
+        if (row && row.fullPath && row.fullPath.indexOf('/list') == -1) { // 非列表页,根据当前路由路径判断是子页还是列表页
           this.$store.state.app.isNewSubTab = true
         } else {
           this.$store.state.app.isNewSubTab = false

+ 1 - 0
src/layouts/PageView.vue

@@ -133,6 +133,7 @@ export default {
       height: 100%;
       >div{
         height: 100%;
+        overflow: auto;
       }
     }
     .link {

+ 53 - 1
src/libs/JGPrint.js

@@ -1,5 +1,8 @@
 import confirm from 'ant-design-vue/es/modal/confirm'
+import notification from 'ant-design-vue/es/notification'
 import { getLodop } from '@/libs/LodopFuncs'
+import moment from 'moment'
+// 打印控件
 export const JGPrint = function(data, type, printerType){
   if (!data) {
     return
@@ -35,9 +38,9 @@ export const JGPrint = function(data, type, printerType){
       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') { //  打印
@@ -45,4 +48,53 @@ export const JGPrint = function(data, type, printerType){
       window.frames['printfsqd'].print()
     }
   }
+}
+
+// 导出下载excel
+export const downloadExcel = function (data,fileName){
+   if (!data) { return }
+   const url = window.URL.createObjectURL(new Blob([data]))
+   const link = document.createElement('a')
+   link.style.display = 'none'
+   link.href = url
+   const a = moment().format('YYYYMMDDHHmmss')
+   const fname = fileName + a
+   link.setAttribute('download', fname + '.xlsx')
+   document.body.appendChild(link)
+   link.click()
+}
+
+/*
+  *printerType: 打印机类型
+  *type: 打印预览,打印,导出
+  *url: 数据请求接口
+  *params: 请求参数
+  *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()
+  })
 }

+ 1 - 2
src/libs/LodopFuncs.js

@@ -122,8 +122,7 @@ function getLodop (oOBJECT, oEMBED) {
       if (!needCLodop()) { msgHtml = (is64IE ? strHtm64_Update : strHtmUpdate) }
     }
     //= ==如下空白位置适合调用统一功能(如注册语句、语言选择等):==
-    LODOP.SET_LICENSES('', '13528A153BAEE3A0254B9507DCDE2839', 'EDE92F75B6A3D917F65910', 'D60BC84D7CF2DE18156A6F88987304CB6D8')
-
+    LODOP.SET_LICENSES("","E89B8C436467D381F32C0B7F5674838FA59","","")
     //= ==============================================.com//.com台级//.net
     console.log(msgHtml)
     return LODOP

+ 10 - 39
src/views/allocationManagement/chainTransferIn/detail.vue

@@ -15,12 +15,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_allocLinkagePutPrint')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="chainTransferInDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="chainTransferInDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -59,8 +54,6 @@
         </s-table>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -68,8 +61,10 @@
 import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { allocLinkagePutDetailList, allocLinkagePutDetailSn, allocLinkagePutDetailCount, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -106,8 +101,7 @@ export default {
       },
       basicInfoData: null, //  基本信息
       productTotal: null, //  合计
-      localDataSource: [],
-      printerType: 'NEEDLE' //  打印机类型
+      localDataSource: []
     }
   },
   computed: {
@@ -145,38 +139,15 @@ export default {
       this.$router.push({ path: `/allocationManagement/chainTransferIn/edit/${this.basicInfoData.id}/${this.basicInfoData.allocationLinkagePutSn}` })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = allocLinkagePutDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfcid" name="printfcid" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfcid'].focus()
-        window.frames['printfcid'].print()
-      }
     }
   },
   mounted () {

+ 9 - 37
src/views/allocationManagement/chainTransferIn/edit.vue

@@ -8,12 +8,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_allocLinkagePutPrint')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="chainTransferInEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="chainTransferInEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -111,8 +106,6 @@
         @click="handleSubmit"
         style="padding: 0 60px;">提交入库</a-button>
     </div>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -122,8 +115,10 @@ import { getOperationalPrecision } from '@/libs/tools.js'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import { warehouseCascadeList } from '@/api/warehouse'
 import { allocLinkagePutDetailSn, allocLinkagePutDetailList, allocLinkagePutDetailCount, allocLinkagePutDetailUpdate, allocLinkagePutSubmit, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -313,39 +308,16 @@ export default {
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = allocLinkagePutDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfcie" name="printfcie" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfcie'].focus()
-        window.frames['printfcie'].print()
-      }
-    },
     pageInit () {
       this.getDetail()
       this.getWarehouseCascade()

+ 10 - 39
src/views/allocationManagement/chainTransferOut/detail.vue

@@ -15,12 +15,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $hasPermissions('B_allocLinkageOutPrint')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="chainTransferOutDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="chainTransferOutDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -65,8 +60,6 @@
         </a-collapse>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -74,8 +67,10 @@
 import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { allocLinkageOutDetailSn, allocLinkageOutDetailList, allocLinkageOutDetailCount, allocLinkageOutDetailPrint } from '@/api/allocLinkageOut'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   props: {
     outBizSn: { //  有值则为弹框,无值则为页面
       type: [Number, String],
@@ -116,8 +111,7 @@ export default {
       },
       basicInfoData: null, //  基本信息
       productTotal: null, //  合计
-      localDataSource: [],
-      printerType: 'NEEDLE' //  打印机类型
+      localDataSource: []
     }
   },
   computed: {
@@ -155,38 +149,15 @@ export default {
       this.$router.push({ path: `/allocationManagement/chainTransferOut/edit/${this.basicInfoData.id}/${this.basicInfoData.allocationLinkageOutSn}` })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      allocLinkageOutDetailPrint({ sn: this.outBizSn || this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = allocLinkageOutDetailPrint
+      const params = { sn: this.outBizSn || this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfcod" name="printfcod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfcod'].focus()
-        window.frames['printfcod'].print()
-      }
     }
   },
   mounted () {

+ 10 - 39
src/views/allocationManagement/chainTransferOut/edit.vue

@@ -9,12 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_allocLinkageOutPrint')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="chainTransferOutEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="chainTransferOutEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 选择产品 -->
@@ -191,8 +186,6 @@
         @click="handleSubmit"
         style="padding: 0 60px;">提交</a-button>
     </div>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -204,8 +197,10 @@ import { productQuery } from '@/api/allocWarehouse'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import { warehouseAllList } from '@/api/warehouse'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -296,8 +291,7 @@ export default {
       },
       basicInfoData: null, //  基本信息
       productTotal: null, //  合计
-      localDataSource: [],
-      printerType: 'NEEDLE' //  打印机类型
+      localDataSource: []
     }
   },
   methods: {
@@ -482,39 +476,16 @@ export default {
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      allocLinkageOutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = allocLinkageOutDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfcoe" name="printfcoe" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfcoe'].focus()
-        window.frames['printfcoe'].print()
-      }
-    },
     pageInit () {
       this.chooseResetSearchForm()
       this.getDetail()

+ 9 - 38
src/views/allocationManagement/storeTransferOut/detail.vue

@@ -16,12 +16,7 @@
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $hasPermissions('B_storeCallOutPrint')">
           <a-checkbox key="4" v-model="printCostChecked">打印成本</a-checkbox>
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="storeTransferOutDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="storeTransferOutDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <a-card size="small" :bordered="false" class="storeTransferOutDetail-cont">
@@ -61,8 +56,6 @@
         </s-table>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -70,8 +63,10 @@
 import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { storeCallOutDetailList, storeCallOutDetailCount, storeCallOutDetailSn, storeCallOutDetailPrint } from '@/api/storeCallOut'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   props: {
     outBizSn: { //  有值则为弹框,无值则为页面
       type: [Number, String],
@@ -111,7 +106,6 @@ export default {
       localDataSource: [],
       basicInfoData: null, //  基本信息
       productTotal: null, //  合计
-      printerType: 'NEEDLE', //  打印机类型
       printCostChecked: true //  打印成本
     }
   },
@@ -126,39 +120,16 @@ export default {
       this.$router.push({ path: '/allocationManagement/storeTransferOut/list', query: { closeLastOldTab: true } })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      storeCallOutDetailPrint({ sn: this.outBizSn || this.$route.params.sn, type: this.printerType, costFlag: this.printCostChecked ? '1' : '0' }).then(res => {
+      const url = storeCallOutDetailPrint
+      const params = { sn: this.outBizSn || this.$route.params.sn, type: printerType, costFlag: this.printCostChecked ? '1' : '0' }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfsod" name="printfsod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfsod'].focus()
-        window.frames['printfsod'].print()
-      }
-    },
     // 基本信息
     getDetail () {
       storeCallOutDetailSn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {

+ 10 - 45
src/views/allocationManagement/storeTransferOut/edit.vue

@@ -9,12 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_storeCallOutPrint')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="storeTransferOutEdit-preview-btn" :disabled="chooseLoadDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="storeTransferOutEdit-print-btn" :disabled="chooseLoadDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 选择产品 -->
@@ -186,8 +181,6 @@
         @click="handleSubmit"
         style="padding: 0 60px;">提交</a-button>
     </div>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -199,8 +192,10 @@ import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import { warehouseAllList } from '@/api/warehouse'
 import { productQuery } from '@/api/allocWarehouse'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -263,12 +258,6 @@ export default {
         { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: 115, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
       ],
-      // chooseLoadData: [],
-      // choosePaginationProps: {
-      //   total: 0, //  分页总条数
-      //   current: 1,
-      //   pageSize: 20
-      // },
       // 加载数据方法 必须为 Promise 对象
       chooseLoadData: parameter => {
         this.chooseDisabled = true
@@ -290,8 +279,7 @@ export default {
       },
       chooseLoadDataSource: [],
       basicInfoData: null, //  基本信息
-      productTotal: null, //  合计
-      printerType: 'NEEDLE' //  打印机类型
+      productTotal: null //  合计
     }
   },
   methods: {
@@ -308,39 +296,16 @@ export default {
       this.$refs.table.refresh(true)
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      storeCallOutDetailPrint({ sn: this.$route.params.sn, type: this.printerType, costFlag: '0' }).then(res => {
+      const url = storeCallOutDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType, costFlag: '0' }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfsoe" name="printfsoe" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfsoe'].focus()
-        window.frames['printfsoe'].print()
-      }
-    },
     // 双击快速添加
     handleClickRow (record) {
       return {

+ 10 - 39
src/views/bulkManagement/bulkWarehousingOrder/detail.vue

@@ -20,12 +20,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_bulkWarehousingOrder_print')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="bulkWarehousingOrderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -98,8 +93,6 @@
         </a-collapse>
       </a-card> -->
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -107,8 +100,10 @@
 import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -142,8 +137,7 @@ export default {
       },
       localDataSource: [],
       basicInfoData: null, //  基本信息
-      productTotal: null, //  合计
-      printerType: 'NEEDLE' //  打印机类型
+      productTotal: null //  合计
     }
   },
   computed: {
@@ -157,39 +151,16 @@ export default {
       this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list', query: { closeLastOldTab: true } })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      sparePartsPurDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = sparePartsPurDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfbwod" name="printfbwod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfbwod'].focus()
-        window.frames['printfbwod'].print()
-      }
-    },
     // 基本信息
     getDetail () {
       sparePartsPurDetail({ id: this.$route.params.id }).then(res => {

+ 10 - 41
src/views/bulkManagement/bulkWarehousingOrder/edit.vue

@@ -10,12 +10,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_bulkWarehousingOrder_print')">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="bulkWarehousingOrderEdit-preview-btn" :disabled="chooseLoadDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="bulkWarehousingOrderEdit-print-btn" :disabled="chooseLoadDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="chooseLoadDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -24,7 +19,6 @@
           <a-collapse-panel key="1">
             <template slot="header">
               基础信息
-              <!-- <a-button type="primary" shape="circle" size="small" icon="edit" class="edit-circle-btn" id="bulkWarehousingOrderEdit-edit-circle-btn" @click.stop="handleEditInfo" /> -->
             </template>
             <a-descriptions :column="3">
               <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}</a-descriptions-item>
@@ -152,7 +146,6 @@
           <a-collapse-panel key="1">
             <template slot="header">
               已选产品
-              <!-- <a-button size="small" class="import-btn" id="bulkWarehousingOrderEdit-import-btn" @click.stop="handleImport">导入明细</a-button> -->
             </template>
             <!-- 已选产品 -->
             <div>
@@ -237,8 +230,6 @@
     </div>
     <!-- 选择基本信息弹框 -->
     <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -251,8 +242,10 @@ import { dealerProductTypeList } from '@/api/dealerProductType'
 import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailSave, sparePartsPurDetailDel, sparePartsPurSubmit, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
 import { dealerProductList } from '@/api/dealerProduct'
 import { warehouseCascadeList } from '@/api/warehouse'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect, basicInfoModal },
+  components: { STable, VSelect, basicInfoModal, Print },
   data () {
     return {
       spinning: false,
@@ -366,8 +359,7 @@ export default {
       chooseWarehouseList: [], //  已选产品 仓库  下拉数据
       chooseWarehouseLocList: {}, //  已选产品 仓位  下拉数据
       basicInfoData: null, //  基本信息
-      productTotal: null, //  合计
-      printerType: 'NEEDLE' //  打印机类型
+      productTotal: null //  合计
     }
   },
   methods: {
@@ -382,39 +374,16 @@ export default {
       this.$refs.table.refresh(true)
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      sparePartsPurDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = sparePartsPurDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '', function () {
         _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="printfbwoe" name="printfbwoe" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfbwoe'].focus()
-        window.frames['printfbwoe'].print()
-      }
-    },
     // 双击快速添加
     handleClickRow (record) {
       return {

+ 55 - 0
src/views/common/print.vue

@@ -0,0 +1,55 @@
+<template>
+  <div class="print-page-header">
+    <a-radio-group key="4" id="print-printerType" v-model="printerType">
+      <a-radio value="NEEDLE">针式</a-radio>
+      <a-radio value="INK">喷墨</a-radio>
+    </a-radio-group>
+    <a-button key="3" id="print-preview-btn" :disabled="disabled" @click="handlePrint('preview')">打印预览</a-button>
+    <a-button key="2" type="primary" id="print-print-btn" :disabled="disabled" @click="handlePrint('print')">快捷打印</a-button>
+    <a-button
+      key="1"
+      type="primary"
+      class="button-warning"
+      id="print-export-btn"
+      v-if="showExport"
+      :disabled="disabled"
+      @click="handlePrint('export')">导出Excel</a-button>
+    <!-- 打印 -->
+    <div id="print"></div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'Print',
+  props: {
+    disabled: {
+      type: Boolean,
+      default: false
+    },
+    showExport: {
+      type: Boolean,
+      default: true
+    }
+  },
+  data () {
+    return {
+      printerType: 'NEEDLE' // 打印机类型
+    }
+  },
+  methods: {
+    handlePrint (type) {
+      this.$emit('handlePrint', type, this.printerType)
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .print-page-header{
+    display: inline-block;
+    > *{
+      margin-left: 5px;
+    }
+  }
+</style>

+ 11 - 37
src/views/financialManagement/warehousingAudit/detail.vue

@@ -9,12 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template v-if="$hasPermissions('B_warehousingDetail_print')" slot="extra">
-          <a-radio-group key="3" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="2" id="warehousingAuditDetail-preview-btn" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="warehousingAuditDetail-print-btn" @click="handlePrint('print')">快捷打印</a-button>
+          <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -57,16 +52,16 @@
         </a-collapse>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
 import { receivingDetailList, receivingDetailSn, receivingDetailPrint } from '@/api/receiving'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -93,10 +88,12 @@ export default {
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
           }
+          this.localDataSource = data.list
           this.disabled = false
           return data
         })
       },
+      localDataSource: [],
       basicInfoData: null, //  基本信息
       printerType: 'NEEDLE' //  打印机类型
     }
@@ -107,39 +104,16 @@ export default {
       this.$router.push({ path: '/financialManagement/warehousingAudit/list', query: { closeLastOldTab: true } })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
-      receivingDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+      const url = receivingDetailPrint
+      const params = { sn: this.$route.params.sn, type: printerType }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '入库审核', function () {
         _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="printfwad" name="printfwad" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfwad'].focus()
-        window.frames['printfwad'].print()
-      }
-    },
     getDetail () {
       receivingDetailSn({ sn: this.$route.params.sn }).then(res => {
         if (res.status == 200) {

+ 5 - 5
src/views/productManagement/newProduct/detail.vue

@@ -58,7 +58,7 @@ export default {
     return {
       itemId: null,
       detailsData: null, //  详情数据
-      pageInfo: null
+      prevPageInfo: null
     }
   },
   methods: {
@@ -75,7 +75,7 @@ export default {
     },
     // 返回
     goBack () {
-      this.$router.push({ path: this.pageInfo && this.pageInfo.path, query: { closeLastOldTab: true } })
+      this.$router.push({ path: this.prevPageInfo && this.prevPageInfo.path, query: { closeLastOldTab: true } })
     }
   },
   mounted () {
@@ -85,15 +85,15 @@ export default {
     }
   },
   activated () {
-    // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
-    if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
+    // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面  (当前产品详情页的上级页分别有 上下线产品列表、箭冠产品列表和采购新增编辑页。因此处判断是否为子页是通过上级页路由路径是否有'/list',故需单独处理)
+    if ((this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) || (this.prevPageInfo && (this.prevPageInfo.name == 'purchaseOrderEdit' || this.prevPageInfo.name == 'purchaseOrderAdd'))) {
       this.itemId = this.$route.params.sn
       this.getDetail()
     }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
-      vm.pageInfo = from
+      vm.prevPageInfo = from
     })
   }
 }

+ 19 - 55
src/views/purchasingManagement/purchaseOrder/detail.vue

@@ -11,26 +11,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra">
-          <a-radio-group key="5" v-model="printerType" v-if="$hasPermissions('B_purchasePrint')">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="4" v-if="$hasPermissions('B_purchasePrint')" id="purchaseOrderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button
-            key="3"
-            v-if="$hasPermissions('B_purchasePrint')"
-            type="primary"
-            id="purchaseOrderDetail-print-btn"
-            :disabled="localDataSource.length==0"
-            @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="2"
-            v-if="$hasPermissions('B_purchasePrint')"
-            type="primary"
-            class="button-warning"
-            id="purchaseOrderDetail-export-btn"
-            :disabled="localDataSource.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print v-if="$hasPermissions('B_purchasePrint')" :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
           <!-- <a-button
             key="1"
             v-if="$hasPermissions('B_purchaseExportProduct') && (detail&&detail.billStatus=='FINISH')"
@@ -38,7 +19,7 @@
             class="button-info"
             id="purchaseOrderDetail-export-btn"
             :disabled="localDataSource.length==0"
-            @click="handlePrint('exportProduct')">导出产品</a-button> -->
+            @click="handleExportProduct()">导出产品</a-button> -->
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -153,8 +134,6 @@
         </a-collapse>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -163,8 +142,10 @@ import moment from 'moment'
 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 { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -216,20 +197,25 @@ export default {
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
       let url = purchaseDetailPrint
-      let params = { sn: this.$route.params.sn, type: this.printerType }
+      let params = { sn: this.$route.params.sn, type: printerType }
       if (type == 'export') { //  导出
         url = purchaseDetailExport
         params = { sn: this.$route.params.sn }
       }
-      if (type == 'exportProduct') {
-        url = purchaseExportDetail
-        params = { sn: this.$route.params.sn }
-      }
-      url(params).then(res => {
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '采购单', function () {
+        _this.spinning = false
+      })
+    },
+    // 导出产品
+    handleExportProduct () {
+      const _this = this
+      _this.spinning = true
+      purchaseExportDetail({ sn: this.$route.params.sn }).then(res => {
         _this.spinning = false
         if (res.type == 'application/json') {
           var reader = new FileReader()
@@ -242,27 +228,10 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          if (type == 'export' || type == 'exportProduct') { //  导出
-            this.download(res, type)
-          } else {
-            this.print(res, type)
-          }
+          this.download(res)
         }
       })
     },
-    print (data, type) {
-      if (!data) {
-        return
-      }
-      const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
-      document.getElementById('print').innerHTML = '<iframe id="printfpod" name="printfpod" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfpod'].focus()
-        window.frames['printfpod'].print()
-      }
-    },
     download (data, type) {
       if (!data) { return }
       const url = window.URL.createObjectURL(new Blob([data]))
@@ -270,12 +239,7 @@ export default {
       link.style.display = 'none'
       link.href = url
       const a = moment().format('YYYYMMDDHHmmss')
-      let fname = ''
-      if (type == 'export') {
-        fname = '采购' + a
-      } else if (type == 'exportProduct') {
-        fname = '采购产品' + a
-      }
+      const fname = '采购产品' + a
       link.setAttribute('download', fname + '.xlsx')
       document.body.appendChild(link)
       link.click()

+ 8 - 64
src/views/purchasingManagement/purchaseOrder/edit.vue

@@ -9,19 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_purchasePrint')">
-          <a-radio-group key="4" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="3" id="purchaseOrderEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="2" type="primary" id="purchaseOrderEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="1"
-            type="primary"
-            class="button-warning"
-            id="purchaseOrderEdit-export-btn"
-            :disabled="localDataSource.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -242,13 +230,10 @@
     <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
     <!-- 上次缺货 -->
     <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
 <script>
-import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import ImportGuideModal from './importGuideModal.vue'
 import outStockModal from './outStockModal.vue'
@@ -258,8 +243,10 @@ import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseD
 import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
 import { productListPurchase } from '@/api/product'
 import defImg from '@/assets/def_img@2x.png'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
-  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal },
+  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print },
   data () {
     return {
       spinning: false,
@@ -343,7 +330,6 @@ export default {
         })
       },
       localDataSource: [],
-      printerType: 'NEEDLE', //  打印机类型
       openGuideModal: false, //  导入产品引导
       openOutStockModal: false,
       paramsData: null
@@ -505,7 +491,6 @@ export default {
     },
     // 查看产品
     handlePicDetail (row) {
-      console.log(row)
       this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
     },
     // 上次缺货 导入成功
@@ -515,61 +500,20 @@ export default {
       this.openOutStockModal = false
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
       let url = purchaseDetailPrint
-      let params = { sn: this.$route.params.sn, type: this.printerType }
+      let params = { sn: this.$route.params.sn, type: printerType }
       if (type == 'export') { //  导出
         url = purchaseDetailExport
         params = { sn: this.$route.params.sn }
       }
-      url(params).then(res => {
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '采购单', function () {
         _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 {
-          if (type == 'export') { //  导出
-            this.download(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="printfpoe" name="printfpoe" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfpoe'].focus()
-        window.frames['printfpoe'].print()
-      }
-    },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const a = moment().format('YYYYMMDDHHmmss')
-      const fname = '采购' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     //  返回列表
     handleBack () {
       this.$router.push({ path: '/purchasingManagement/purchaseOrder/list', query: { closeLastOldTab: true } })

+ 19 - 63
src/views/salesManagement/salesQuery/detail.vue

@@ -13,19 +13,7 @@
             @click.stop="handleEdit">编辑</a-button>
         </template>
         <template slot="extra" v-if="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $hasPermissions('B_salesPrint')">
-          <a-radio-group key="4" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="3" id="salesDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="2" type="primary" id="salesDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="1"
-            type="primary"
-            class="button-warning"
-            id="salesDetail-export-btn"
-            :disabled="localDataSource.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -87,21 +75,19 @@
         </s-table>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
 <script>
-import moment from 'moment'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { STable, VSelect } from '@/components'
 import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
 import { salesDetailList } from '@/api/salesDetail'
-import { JGPrint } from '@/libs/JGPrint'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'SalesDetail',
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   props: {
     outBizSn: { //  有值则为弹框,无值则为页面
       type: [Number, String],
@@ -157,11 +143,24 @@ export default {
         })
       },
       localDataSource: [],
-      detailData: null, //  详情数据
-      printerType: 'NEEDLE' //  打印机类型
+      detailData: null //  详情数据
     }
   },
   methods: {
+    // 打印预览/快捷打印
+    handlePrint (type, printerType) {
+      const _this = this
+      _this.spinning = true
+      let url = salesDetailPrint
+      const params = { sn: this.outBizSn || this.$route.params.sn }
+      if (type == 'export') { //  导出
+        url = salesDetailExport
+      }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '销售单', function () {
+        _this.spinning = false
+      })
+    },
     //  返回
     handleBack () {
       this.$router.push({ path: '/salesManagement/salesQuery/list', query: { closeLastOldTab: true } })
@@ -180,49 +179,6 @@ export default {
           this.detailData = null
         }
       })
-    },
-    // 打印预览/快捷打印
-    handlePrint (type) {
-      const _this = this
-      _this.spinning = true
-      let url = salesDetailPrint
-      let params = { sn: this.outBizSn || this.$route.params.sn, type: this.printerType }
-      if (type == 'export') { //  导出
-        url = salesDetailExport
-        params = { sn: this.outBizSn || this.$route.params.sn }
-      }
-      url(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 {
-          if (type == 'export') { //  导出
-            this.download(res)
-          } else {
-            JGPrint(res, type, this.printerType)
-          }
-        }
-      })
-    },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const a = moment().format('YYYYMMDDHHmmss')
-      const fname = '销售' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
     }
   },
   mounted () {

+ 18 - 60
src/views/salesManagement/salesQuery/edit.vue

@@ -9,19 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_salesPrint')">
-          <a-radio-group key="4" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="3" id="salesEdit-preview-btn" :disabled="dataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="2" type="primary" id="salesEdit-print-btn" :disabled="dataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="1"
-            type="primary"
-            class="button-warning"
-            id="salesEdit-export-btn"
-            :disabled="dataSource.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print :disabled="dataSource.length==0" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <a-card size="small" :bordered="false" class="salesEdit-cont">
@@ -173,23 +161,22 @@
     </div>
     <!-- 选择客户弹框 -->
     <choose-custom-modal ref="custModal" :show="openModal" @updateData="updateData" @cancel="openModal=false" />
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
 <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'
 import { salesDetail, salesWriteSubmit, salesWriteDiscount, salesDetailPrint, salesDetailExport } from '@/api/sales'
 import { salesDetailList, salesDetailInsert, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll } from '@/api/salesDetail'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'SalesDetail',
-  components: { STable, VSelect, queryPart, chooseCustomModal },
+  components: { STable, VSelect, queryPart, chooseCustomModal, Print },
   data () {
     return {
       spinning: false,
@@ -243,6 +230,20 @@ export default {
     }
   },
   methods: {
+    // 打印预览/快捷打印
+    handlePrint (type, printerType) {
+      const _this = this
+      _this.spinning = true
+      let url = salesDetailPrint
+      const params = { sn: this.outBizSn || this.$route.params.sn }
+      if (type == 'export') { //  导出
+        url = salesDetailExport
+      }
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '销售单', function () {
+        _this.spinning = false
+      })
+    },
     // 已选产品 销售数量  blur
     qtyBlur (val, record) {
       const _this = this
@@ -316,49 +317,6 @@ export default {
     isCost (val) {
       this.isCosts = val
     },
-    // 打印预览/快捷打印
-    handlePrint (type) {
-      const _this = this
-      _this.spinning = true
-      let url = salesDetailPrint
-      let params = { sn: this.$route.params.sn, type: this.printerType }
-      if (type == 'export') { //  导出
-        url = salesDetailExport
-        params = { sn: this.$route.params.sn }
-      }
-      url(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 {
-          if (type == 'export') { //  导出
-            this.download(res)
-          } else {
-            JGPrint(res, type, this.printerType)
-          }
-        }
-      })
-    },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const a = moment().format('YYYYMMDDHHmmss')
-      const fname = '销售' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     // 更新产品列表
     updateData (priceType) {
       // 价格类型变更

+ 9 - 65
src/views/salesManagement/salesReturn/detail.vue

@@ -6,19 +6,7 @@
           <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
         </template>
         <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
-          <a-radio-group key="4" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="3" id="salesReturnDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="2" type="primary" id="salesReturnDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="1"
-            type="primary"
-            class="button-warning"
-            id="salesReturnDetail-export-btn"
-            :disabled="localDataSource.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <!-- 基础信息 -->
@@ -70,19 +58,18 @@
         </s-table>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
 <script>
-import moment from 'moment'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { STable, VSelect } from '@/components'
 import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'SalesReturnDetail',
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
     return {
       spinning: false,
@@ -130,8 +117,7 @@ export default {
         })
       },
       localDataSource: [],
-      detailData: null, //  详情数据
-      printerType: 'NEEDLE' //  打印机类型
+      detailData: null //  详情数据
     }
   },
   methods: {
@@ -156,60 +142,18 @@ export default {
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
       let url = salesReturnDetailPrint
-      let params = { sn: this.$route.params.sn, type: this.printerType }
+      const params = { sn: this.$route.params.sn }
       if (type == 'export') { //  导出
         url = salesDetailExport
-        params = { sn: this.$route.params.sn }
       }
-      url(params).then(res => {
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '销售退货', function () {
         _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 {
-          if (type == 'export') { //  导出
-            this.download(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="printfsrd" name="printfsrd" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfsrd'].focus()
-        window.frames['printfsrd'].print()
-      }
-    },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const a = moment().format('YYYYMMDDHHmmss')
-      const fname = '销售退货' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
     }
   },
   mounted () {

+ 9 - 63
src/views/salesManagement/salesReturn/salesReturnEdit.vue

@@ -9,19 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
-          <a-radio-group key="4" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="3" id="salesReturnEdit-preview-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="2" type="primary" id="salesReturnEdit-print-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="1"
-            type="primary"
-            class="button-warning"
-            id="salesReturnEdit-export-btn"
-            :disabled="chooseLoadData.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print :disabled="chooseLoadData.length==0" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <a-card size="small" :bordered="false" class="pages-wrap">
@@ -186,25 +174,25 @@
     </div>
     <!-- 选择客户弹框 -->
     <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
 <script>
-import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import queryPart from './queryPart.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
 import { warehouseCascadeList } from '@/api/warehouse'
 import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'SalesDetail',
   components: {
     STable,
     VSelect,
     queryPart,
-    chooseCustomModal
+    chooseCustomModal,
+    Print
   },
   data () {
     return {
@@ -494,61 +482,19 @@ export default {
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
       let url = salesReturnDetailPrint
-      let params = { sn: this.$route.params.sn, type: this.printerType }
+      const params = { sn: this.$route.params.sn }
       if (type == 'export') { //  导出
         url = salesDetailExport
-        params = { sn: this.$route.params.sn }
       }
-      url(params).then(res => {
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '销售退货', function () {
         _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 {
-          if (type == 'export') { //  导出
-            this.download(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="printfsre" name="printfsre" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfsre'].focus()
-        window.frames['printfsre'].print()
-      }
-    },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const a = moment().format('YYYYMMDDHHmmss')
-      const fname = '销售退货' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     pageInit () {
       this.orderId = this.$route.params.id
       this.orderSn = this.$route.params.sn

+ 9 - 62
src/views/salesManagement/salesReturn/salesReturnGrabEdit.vue

@@ -9,19 +9,7 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
-          <a-radio-group key="4" v-model="printerType">
-            <a-radio value="NEEDLE">针式</a-radio>
-            <a-radio value="INK">喷墨</a-radio>
-          </a-radio-group>
-          <a-button key="3" id="salesReturnEdit-preview-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="2" type="primary" id="salesReturnEdit-print-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
-          <a-button
-            key="1"
-            type="primary"
-            class="button-warning"
-            id="salesReturnEdit-export-btn"
-            :disabled="chooseLoadData.length==0"
-            @click="handlePrint('export')">导出Excel</a-button>
+          <Print :disabled="chooseLoadData.length==0" @handlePrint="handlePrint"></Print>
         </template>
       </a-page-header>
       <a-card size="small" :bordered="false" class="pages-wrap">
@@ -174,8 +162,6 @@
     </div>
     <!-- 选择客户弹框 -->
     <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
 </template>
 
@@ -186,13 +172,16 @@ import queryPart from './queryPart.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
 import { warehouseCascadeList } from '@/api/warehouse'
 import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'SalesDetail',
   components: {
     STable,
     VSelect,
     queryPart,
-    chooseCustomModal
+    chooseCustomModal,
+    Print
   },
   data () {
     return {
@@ -482,61 +471,19 @@ export default {
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       _this.spinning = true
       let url = salesReturnDetailPrint
-      let params = { sn: this.$route.params.sn, type: this.printerType }
+      const params = { sn: this.$route.params.sn }
       if (type == 'export') { //  导出
         url = salesDetailExport
-        params = { sn: this.$route.params.sn }
       }
-      url(params).then(res => {
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '销售退货', function () {
         _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 {
-          if (type == 'export') { //  导出
-            this.download(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="printfsrge" name="printfsrge" src="' + url + '" hidden></iframe>'
-      if (type == 'preview') { //  预览
-        window.open(url)
-      } else if (type == 'print') { //  打印
-        window.frames['printfsrge'].focus()
-        window.frames['printfsrge'].print()
-      }
-    },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const a = moment().format('YYYYMMDDHHmmss')
-      const fname = '销售退货' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     pageInit () {
       this.orderId = this.$route.params.id
       this.orderSn = this.$route.params.sn

+ 2 - 2
vue.config.js

@@ -109,8 +109,8 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        // target: 'http://192.168.16.103:8503/qpls-md',
-        target: 'http://qpls-md.360arrow.com.cn/qpls-md', //  Ô¤·¢²¼
+        target: 'http://192.168.16.151:80/qpls-md',
+        // target: 'http://qpls-md.360arrow.com.cn/qpls-md', //  Ô¤·¢²¼
         // target: 'http://qpls-md.360arrow.com/qpls-md', //  Éú²ú
         // ws: false,
         ws: true,