lilei 3 năm trước cách đây
mục cha
commit
d7a5c5fbb9

+ 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)
 }

+ 1 - 1
src/views/common/print.vue

@@ -25,7 +25,7 @@ export default {
   props: {
     disabled: {
       type: Boolean,
-      default: true
+      default: false
     },
     showExport: {
       type: Boolean,

+ 9 - 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 :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,
@@ -107,39 +102,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: this.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) {