Pārlūkot izejas kodu

Merge branch 'deploy_0804' of http://git.chelingzhu.com/jianguan-web/qpls-md-html into deploy_0804

lilei 3 gadi atpakaļ
vecāks
revīzija
0619b80e7f

+ 8 - 4
src/api/purchase.js

@@ -122,11 +122,15 @@ export const getParentDealer = (params) => {
 }
 }
 // 采购 详情  打印
 // 采购 详情  打印
 export const purchaseDetailPrint = params => {
 export const purchaseDetailPrint = params => {
-  return axios.request({
+  const data = {
     url: `purchase/print/${params.sn}/${params.type}`,
     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) => {
 export const purchaseTargetList = (params) => {
   return axios({
   return axios({

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

@@ -11,26 +11,7 @@
         </template>
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra">
         <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
           <!-- <a-button
             key="1"
             key="1"
             v-if="$hasPermissions('B_purchaseExportProduct') && (detail&&detail.billStatus=='FINISH')"
             v-if="$hasPermissions('B_purchaseExportProduct') && (detail&&detail.billStatus=='FINISH')"
@@ -38,7 +19,7 @@
             class="button-info"
             class="button-info"
             id="purchaseOrderDetail-export-btn"
             id="purchaseOrderDetail-export-btn"
             :disabled="localDataSource.length==0"
             :disabled="localDataSource.length==0"
-            @click="handlePrint('exportProduct')">导出产品</a-button> -->
+            @click="handleExportProduct()">导出产品</a-button> -->
         </template>
         </template>
       </a-page-header>
       </a-page-header>
       <!-- 基础信息 -->
       <!-- 基础信息 -->
@@ -153,8 +134,6 @@
         </a-collapse>
         </a-collapse>
       </a-card>
       </a-card>
     </a-spin>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -163,8 +142,10 @@ import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
 import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
 import { purchaseDetailList } from '@/api/purchaseDetail'
 import { purchaseDetailList } from '@/api/purchaseDetail'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, Print },
   data () {
   data () {
     return {
     return {
       spinning: false,
       spinning: false,
@@ -216,20 +197,25 @@ export default {
       })
       })
     },
     },
     // 打印预览/快捷打印
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       const _this = this
       _this.spinning = true
       _this.spinning = true
       let url = purchaseDetailPrint
       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') { //  导出
       if (type == 'export') { //  导出
         url = purchaseDetailExport
         url = purchaseDetailExport
         params = { sn: this.$route.params.sn }
         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
         _this.spinning = false
         if (res.type == 'application/json') {
         if (res.type == 'application/json') {
           var reader = new FileReader()
           var reader = new FileReader()
@@ -242,27 +228,10 @@ export default {
           })
           })
           reader.readAsText(res)
           reader.readAsText(res)
         } else {
         } 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) {
     download (data, type) {
       if (!data) { return }
       if (!data) { return }
       const url = window.URL.createObjectURL(new Blob([data]))
       const url = window.URL.createObjectURL(new Blob([data]))
@@ -270,12 +239,7 @@ export default {
       link.style.display = 'none'
       link.style.display = 'none'
       link.href = url
       link.href = url
       const a = moment().format('YYYYMMDDHHmmss')
       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')
       link.setAttribute('download', fname + '.xlsx')
       document.body.appendChild(link)
       document.body.appendChild(link)
       link.click()
       link.click()

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

@@ -9,19 +9,7 @@
         </template>
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <!-- 操作区,位于 title 行的行尾 -->
         <template slot="extra" v-if="$hasPermissions('B_purchasePrint')">
         <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>
         </template>
       </a-page-header>
       </a-page-header>
       <!-- 基础信息 -->
       <!-- 基础信息 -->
@@ -242,13 +230,10 @@
     <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
     <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
     <!-- 上次缺货 -->
     <!-- 上次缺货 -->
     <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
     <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
-    <!-- 打印 -->
-    <div id="print"></div>
   </div>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
-import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import ImportGuideModal from './importGuideModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import outStockModal from './outStockModal.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 { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
 import { productListPurchase } from '@/api/product'
 import { productListPurchase } from '@/api/product'
 import defImg from '@/assets/def_img@2x.png'
 import defImg from '@/assets/def_img@2x.png'
+import Print from '@/views/common/print.vue'
+import { hdPrint } from '@/libs/JGPrint'
 export default {
 export default {
-  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal },
+  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print },
   data () {
   data () {
     return {
     return {
       spinning: false,
       spinning: false,
@@ -343,7 +330,6 @@ export default {
         })
         })
       },
       },
       localDataSource: [],
       localDataSource: [],
-      printerType: 'NEEDLE', //  打印机类型
       openGuideModal: false, //  导入产品引导
       openGuideModal: false, //  导入产品引导
       openOutStockModal: false,
       openOutStockModal: false,
       paramsData: null
       paramsData: null
@@ -514,61 +500,20 @@ export default {
       this.openOutStockModal = false
       this.openOutStockModal = false
     },
     },
     // 打印预览/快捷打印
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (type, printerType) {
       const _this = this
       const _this = this
       _this.spinning = true
       _this.spinning = true
       let url = purchaseDetailPrint
       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') { //  导出
       if (type == 'export') { //  导出
         url = purchaseDetailExport
         url = purchaseDetailExport
         params = { sn: this.$route.params.sn }
         params = { sn: this.$route.params.sn }
       }
       }
-      url(params).then(res => {
+      // 打印或导出
+      hdPrint(printerType, type, url, params, '采购单', function () {
         _this.spinning = false
         _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 () {
     handleBack () {
       this.$router.push({ path: '/purchasingManagement/purchaseOrder/list', query: { closeLastOldTab: true } })
       this.$router.push({ path: '/purchasingManagement/purchaseOrder/list', query: { closeLastOldTab: true } })