Browse Source

盘点打印

lilei 2 years ago
parent
commit
37dc6ed494

+ 1 - 3
src/api/checkWarehouse.js

@@ -47,9 +47,7 @@ export const checkWarehouseDetailCount = (params) => {
 }
 // 盘点人盘点/监盘人监盘 盘点  打印
 export const checkWarehouseDetailPrint = params => {
-  const url = `/checkWarehouse/detail/print/${params.checkWarehouseSn}/${params.type}`
-  delete params.checkWarehouseSn
-  delete params.type
+  const url = `/checkWarehouse/detail/print/${params.printType}`
   return axios.request({
     url: url,
     data: params,

+ 19 - 2
src/libs/JGPrint.js

@@ -135,7 +135,19 @@ export const jGPrint = function (data, type, callback, printLogParams,printPageS
       LODOP.PRINTA()
     }
 }
-
+// 浏览器打印pdf功能
+export const winPrintPdf = function(data,taskName,callback){
+  if (!data) {
+    return
+  }
+  const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
+  document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
+  window.frames['printfbod'].onload = function(){
+    callback()
+  }
+  window.frames['printfbod'].focus()
+  window.frames['printfbod'].print()
+}
 // 打印
 export const printFun = function(url,params,type,taskName,callback,printLogParams,hidePrint){
   url(params).then(res => {
@@ -151,7 +163,12 @@ export const printFun = function(url,params,type,taskName,callback,printLogParam
       reader.readAsText(res)
     } else {
        console.log(res,'printFun')
-       jGPrintPdf(res,type,taskName,printLogParams,callback,hidePrint)
+       // 使用浏览器自带打印功能
+       if(type == 'orginPrint'){
+         winPrintPdf(res,taskName,callback)
+       }else{
+         jGPrintPdf(res,type,taskName,printLogParams,callback,hidePrint)
+       }
     }
   })
 }

+ 13 - 25
src/views/inventoryManagement/makeInventory/check.vue

@@ -140,16 +140,8 @@
         style="padding: 0 60px;">提交盘点</a-button>
     </div>
     <!-- 盘点打印确认 -->
-    <printModal
-      :openModal="visiblePrint"
-      :content="printContent"
-      :okText="printOkText"
-      cancelText="打印预览"
-      :isCancel="isPrintCancel"
-      :spinning="spinningPrint"
-      @close="visiblePrint=false"
-      @ok="printOkText == '好的' ? visiblePrint=false : handlePrint('print')"
-      @fail="handlePrint('preview')" />
+    <print-modal :openModal="visiblePrint" nowType="CHECK_WAREHOUSE" :itemData="detail" @ok="handlePrint" @close="visiblePrint=false" />
+    <div id="print"></div>
   </div>
 </template>
 
@@ -157,8 +149,8 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import tablePagination from '@/views/common/tablePagination.vue'
-import printModal from '@/views/common/auditModal.vue'
-import { printFun, exportExcel } from '@/libs/JGPrint.js'
+import printModal from './printModal.vue'
+import { printFun } from '@/libs/JGPrint.js'
 import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseCheck } from '@/api/checkWarehouse'
 export default {
   name: 'MakeInventoryCheck',
@@ -197,10 +189,7 @@ export default {
       foldState: false, //  是否折叠列表
       productTotal: null, //  合计
       spinningPrint: false,
-      visiblePrint: false,
-      printContent: '',
-      printOkText: '',
-      isPrintCancel: false
+      visiblePrint: false
     }
   },
   methods: {
@@ -364,24 +353,23 @@ export default {
         this.spinning = false
         if (res.status == 200) {
           if (res.data && res.data == 0) { // 无产品
-            this.printContent = '此盘点单没有产品,无法打印'
-            this.printOkText = '好的'
-            this.isPrintCancel = false
-            this.visiblePrint = true
+            this.$info({
+              title: '提示',
+              content: '此盘点单没有产品,无法打印',
+              centered: true
+            })
           } else { // 有产品
-            this.printContent = '打印范围 —— 所有盘点产品(批次合并)'
-            this.printOkText = '立即打印'
-            this.isPrintCancel = true
+            this.detail.printContent = '打印范围 —— 所有盘点产品(批次合并)'
             this.visiblePrint = true
           }
         }
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (objs, type) {
       const _this = this
       _this.spinningPrint = true
-      const params = { checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE' }
+      const params = { checkWarehouseSn: this.$route.params.sn, ...objs }
       printFun(checkWarehouseDetailPrint, params, type, '盘点单', () => { _this.spinningPrint = false })
     }
   },

+ 128 - 0
src/views/inventoryManagement/makeInventory/printModal.vue

@@ -0,0 +1,128 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    class="sales-print-type-modal"
+    :title="modalTit"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="600">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="sales-print-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="盘点单号">{{ itemData&&itemData.checkWarehouseNo || '--' }}</a-form-model-item>
+        <a-form-model-item label="打印范围">{{ itemData&&itemData.printContent || '--' }}</a-form-model-item>
+        <a-form-model-item label="货架编号" prop="orderBy">
+          <a-radio-group v-model="form.orderBy">
+            <a-radio value="ASC">打印(↑升序)</a-radio>
+            <a-radio value="DESC">打印(↓降序)</a-radio>
+            <a-radio value="-1">不打印</a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button id="sales-print-back" @click="handleCancel">取消</a-button>
+        <a-button type="primary" id="sales-print-save" @click="handleSave('orginPrint')" style="margin-left: 10px;">立即打印</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+export default {
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemData: {
+      type: Object,
+      default: () => {
+        return null
+      }
+    },
+    nowType: {
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      form: {
+        orderBy: undefined
+      },
+      rules: {
+        orderBy: [{ required: true, message: '请选择货架编号', trigger: 'change' }]
+      },
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 }
+      },
+      spinning: false,
+      typeList: []
+    }
+  },
+  computed: {
+    modalTit () {
+      return this.nowType == 'CHECK_WAREHOUSE' ? '盘点打印' : '监盘打印'
+    }
+  },
+  methods: {
+    // 确认
+    handleSave (type) {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const obj = {
+            printType: _this.nowType
+          }
+          // 打印货位编号
+          if (_this.form.orderBy != '-1') {
+            obj.orderBy = _this.form.orderBy
+            obj.printType = obj.printType + '_STACK_PLACE'
+          }
+          _this.$emit('ok', obj, type)
+          _this.isShow = false
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 取消选择分类
+    handleCancel () {
+      this.isShow = false
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .sales-print-type-modal{
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 13 - 25
src/views/inventoryManagement/supervisionDisk/check.vue

@@ -149,16 +149,8 @@
         style="padding: 0 60px;margin-left: 15px">提交监盘</a-button>
     </div>
     <!-- 盘点打印确认 -->
-    <printModal
-      :openModal="visiblePrint"
-      :content="printContent"
-      :okText="printOkText"
-      cancelText="打印预览"
-      :isCancel="isPrintCancel"
-      :spinning="spinningPrint"
-      @close="visiblePrint=false"
-      @ok="printOkText == '好的' ? visiblePrint=false : handlePrint('print')"
-      @fail="handlePrint('preview')" />
+    <print-modal :openModal="visiblePrint" nowType="CHECK_WAREHOUSE_SUPERVISE" :itemData="detail" @ok="handlePrint" @close="visiblePrint=false" />
+    <div id="print"></div>
   </div>
 </template>
 
@@ -166,8 +158,8 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import tablePagination from '@/views/common/tablePagination.vue'
-import printModal from '@/views/common/auditModal.vue'
-import { printFun, exportExcel } from '@/libs/JGPrint.js'
+import printModal from '../makeInventory/printModal.vue'
+import { printFun } from '@/libs/JGPrint.js'
 import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseSupervise, checkWarehouseReCheck } from '@/api/checkWarehouse'
 export default {
   name: 'SupervisionDiskCheck',
@@ -207,10 +199,7 @@ export default {
       foldState: false, //  是否折叠列表
       productTotal: null, //  合计
       spinningPrint: false,
-      visiblePrint: false,
-      printContent: '',
-      printOkText: '',
-      isPrintCancel: false
+      visiblePrint: false
     }
   },
   methods: {
@@ -396,24 +385,23 @@ export default {
         this.spinning = false
         if (res.status == 200) {
           if (res.data && res.data == 0) { // 无产品
-            this.printContent = '打印模板内容是所有有盈亏的产品,此单盘点人盘点无盈亏记录,无法打印'
-            this.printOkText = '好的'
-            this.isPrintCancel = false
-            this.visiblePrint = true
+            this.$info({
+              title: '提示',
+              content: '打印模板内容是所有有盈亏的产品,此单盘点人盘点无盈亏记录,无法打印',
+              centered: true
+            })
           } else { // 有产品
-            this.printContent = '打印范围 —— 有盈亏(批次合并)'
-            this.printOkText = '立即打印'
-            this.isPrintCancel = true
+            this.detail.printContent = '打印范围 —— 有盈亏(批次合并)'
             this.visiblePrint = true
           }
         }
       })
     },
     // 打印预览/快捷打印
-    handlePrint (type) {
+    handlePrint (objs, type) {
       const _this = this
       _this.spinningPrint = true
-      const params = { checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE_SUPERVISE' }
+      const params = { checkWarehouseSn: this.$route.params.sn, ...objs }
       printFun(checkWarehouseDetailPrint, params, type, '盘点单', () => { _this.spinningPrint = false })
     }
   },

+ 2 - 2
vue.config.js

@@ -107,9 +107,9 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        target: 'http://192.168.0.115:8602/ocs-admin',
+        // target: 'http://192.168.0.215:8602/ocs-admin',
         // target: 'https://t.ocs.360arrow.com/ocs-admin', //  Á·Ï°
-        // target: 'http://p.ocs.360arrow.com/ocs-admin', //  Ô¤·¢²¼
+        target: 'http://p.ocs.360arrow.com/ocs-admin', //  Ô¤·¢²¼
         ws: false,
         changeOrigin: true,
         pathRewrite: {