Просмотр исходного кода

散件入库 详情 打印预览

chenrui 4 лет назад
Родитель
Сommit
9e127661b4
2 измененных файлов с 38 добавлено и 4 удалено
  1. 8 0
      src/api/sparePartsPur.js
  2. 30 4
      src/views/bulkManagement/bulkWarehousingOrder/detail.vue

+ 8 - 0
src/api/sparePartsPur.js

@@ -100,3 +100,11 @@ export const sparePartsPurDetailDel = (params) => {
     method: 'get'
     method: 'get'
   })
   })
 }
 }
+// 散件采购(入库) 详情  打印
+export const sparePartsPurDetailPrint = params => {
+  return axios.request({
+    url: `sparePartsPur/print/${params.sn}/${params.type}`,
+    method: 'get',
+    responseType: 'blob'
+  })
+}

+ 30 - 4
src/views/bulkManagement/bulkWarehousingOrder/detail.vue

@@ -19,8 +19,12 @@
       </template>
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
       <template slot="extra">
-        <a-button key="2" id="bulkWarehousingOrderDetail-preview-btn">打印预览</a-button>
-        <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn">快速打印</a-button>
+        <a-radio-group key="3" v-model="printerType">
+          <a-radio value="INK">针式</a-radio>
+          <a-radio value="NEEDLE">喷墨</a-radio>
+        </a-radio-group>
+        <a-button key="2" id="bulkWarehousingOrderDetail-preview-btn" @click="handlePrint('preview')">打印预览</a-button>
+        <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn" @click="handlePrint('print')">快捷打印</a-button>
       </template>
       </template>
     </a-page-header>
     </a-page-header>
     <!-- 基础信息 -->
     <!-- 基础信息 -->
@@ -84,13 +88,15 @@
         </a-collapse-panel>
         </a-collapse-panel>
       </a-collapse>
       </a-collapse>
     </a-card> -->
     </a-card> -->
+    <!-- 打印入库单 -->
+    <div id="print"></div>
   </div>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { getOperationalPrecision } from '@/libs/tools.js'
-import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount } from '@/api/sparePartsPur'
+import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
 export default {
 export default {
   components: { STable, VSelect },
   components: { STable, VSelect },
   data () {
   data () {
@@ -123,7 +129,8 @@ export default {
         })
         })
       },
       },
       basicInfoData: null, //  基本信息
       basicInfoData: null, //  基本信息
-      productTotal: null //  合计
+      productTotal: null, //  合计
+      printerType: 'INK' //  打印机类型
     }
     }
   },
   },
   computed: {
   computed: {
@@ -136,6 +143,25 @@ export default {
     handleBack () {
     handleBack () {
       this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
       this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
     },
     },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      sparePartsPurDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
+        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="printf" name="printf" src="' + url + '" hidden></iframe>'
+      if (type == 'preview') { //  预览
+        window.open(url)
+      } else if (type == 'print') { //  打印
+        window.frames['printf'].focus()
+        window.frames['printf'].print()
+      }
+    },
     // 基本信息
     // 基本信息
     getDetail () {
     getDetail () {
       sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
       sparePartsPurDetail({ id: this.$route.params.id }).then(res => {