Ver código fonte

销售缺货、下推订单 打印

chenrui 4 anos atrás
pai
commit
da20b65337

+ 19 - 1
src/api/dispatch.js

@@ -62,4 +62,22 @@ export const dispatchStockUpAduit = (params) => {
     data: params,
     method: 'post'
   })
-}
+}
+// 下推 详情  打印
+export const dispatchDetailPrint = params => {
+  const url = `/dispatch/print/${params.type}`
+  delete params.type
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}
+// 下推  详情  该销售单的产品二级分类
+export const dispatchDetailType = (params) => {
+  return axios({
+    url: `/dispatch/detail/queryProductType/${params.dispatchBillSn}`,
+    method: 'get'
+  })
+}

+ 8 - 0
src/api/oos.js

@@ -99,3 +99,11 @@ export const oosProductDetailCount = (params) => {
     method: 'post'
   })
 }
+// 缺货 详情  打印
+export const oosDetailPrint = params => {
+  return axios.request({
+    url: `oos/print/${params.sn}`,
+    method: 'get',
+    responseType: 'blob'
+  })
+}

+ 42 - 2
src/views/salesManagement/backorder/detailModal.vue

@@ -8,6 +8,10 @@
     v-model="isShow"
     @cancle="isShow=false"
     :width="960">
+    <div style="padding: 0 12px;text-align: right;">
+      <a-button id="backorderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')" style="margin-right: 15px;">打印预览</a-button>
+      <a-button type="primary" id="backorderDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+    </div>
     <!-- 基础信息 -->
     <a-card size="small" :bordered="false" class="backorderDetail-cont">
       <a-collapse :activeKey="['1']">
@@ -39,12 +43,14 @@
         bordered>
       </s-table>
     </a-card>
+    <!-- 打印 -->
+    <div id="print"></div>
   </a-modal>
 </template>
 
 <script>
 import { STable } from '@/components'
-import { oosDetail, oosDetailList } from '@/api/oos'
+import { oosDetail, oosDetailList, oosDetailPrint } from '@/api/oos'
 export default {
   name: 'BackorderDetailModal',
   components: { STable },
@@ -81,10 +87,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: []
     }
   },
   methods: {
@@ -97,6 +105,38 @@ export default {
           this.detailData = null
         }
       })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      const _this = this
+      oosDetailPrint({ sn: this.itemSn }).then(res => {
+        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="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()
+      }
     }
   },
   watch: {

+ 118 - 0
src/views/salesManagement/pushOrderManagement/chooseTypeModal.vue

@@ -0,0 +1,118 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    class="pushOrderManagement-print-type-modal"
+    title="选择分类"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="600">
+    <a-spin tip="Loading..." :spinning="spinLoading">
+      <a-form-model
+        id="pushOrderManagement-print-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="选择二级分类" prop="productTypeSn2">
+          <a-select id="pushOrderManagement-print-form" v-model="form.productTypeSn2" placeholder="请选择分类">
+            <a-select-option v-for="item in typeList" :value="item.productTypeSn2" :key="item.productTypeSn2">{{ item.productTypeName2 }}</a-select-option>
+          </a-select>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="pushOrderManagement-print-save" @click="handleSave">确定</a-button>
+        <a-button id="pushOrderManagement-print-back" @click="handleCancel" style="margin-left: 15px;">取消</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { dispatchDetailType } from '@/api/dispatch'
+export default {
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      form: {
+        productTypeSn2: undefined
+      },
+      rules: {
+        productTypeSn2: [{ required: true, message: '请选择分类', trigger: 'change' }]
+      },
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 }
+      },
+      spinLoading: false,
+      typeList: []
+    }
+  },
+  methods: {
+    // 确认
+    handleSave () {
+      const _this = this
+
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.spinLoading = true
+          _this.$emit('ok', _this.form.productTypeSn2)
+          _this.isShow = false
+          _this.spinLoading = false
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 取消选择分类
+    handleCancel () {
+      this.isShow = false
+      this.$refs.ruleForm.resetFields()
+    },
+    // 获取该销售单产品二级分类
+    getTypeData () {
+      dispatchDetailType({ dispatchBillSn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          this.typeList = res.data
+        } else {
+          this.typeList = []
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      } else {
+        this.getTypeData()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .pushOrderManagement-print-type-modal{
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 86 - 6
src/views/salesManagement/pushOrderManagement/detail.vue

@@ -5,7 +5,34 @@
         <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
       </template>
       <template slot="extra">
-        <a-button key="4" type="primary" id="salesDetail-print-btn">快速打印</a-button>
+        <a-button
+          key="4"
+          type="primary"
+          class="button-error"
+          id="salesDetail-xs-print-btn"
+          :disabled="localDataSource.length==0"
+          @click="handlePrint('SALES_BILL')">销售打印</a-button>
+        <a-button
+          key="3"
+          type="primary"
+          class="button-info"
+          id="salesDetail-xsfl-print-btn"
+          :disabled="localDataSource.length==0"
+          @click="handlePrint('SALES_BILL_TYPE')">销售分类打印</a-button>
+        <a-button
+          key="2"
+          type="primary"
+          class="button-success"
+          id="salesDetail-fhdy-print-btn"
+          :disabled="localDataSource.length==0"
+          @click="handlePrint('DISPATCH_BILL')">发货打印</a-button>
+        <a-button
+          key="1"
+          type="primary"
+          class="button-warning"
+          id="salesDetail-fhfl-print-btn"
+          :disabled="localDataSource.length==0"
+          @click="handlePrint('DISPATCH_BILL_TYPE')">发货分类打印</a-button>
       </template>
     </a-page-header>
     <!-- 基础信息 -->
@@ -51,15 +78,20 @@
         </template>
       </s-table>
     </a-card>
+    <!-- 分类打印 -->
+    <choose-type-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
-import { dispatchDetaillList, dispatchFindBySn } from '@/api/dispatch'
+import chooseTypeModal from './chooseTypeModal.vue'
+import { dispatchDetaillList, dispatchFindBySn, dispatchDetailPrint } from '@/api/dispatch'
 export default {
   name: 'SalesDetail',
-  components: { STable, VSelect },
+  components: { STable, VSelect, chooseTypeModal },
   data () {
     return {
       disabled: false,
@@ -98,28 +130,76 @@ export default {
             data.list[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
             data.list[i].productOrigUnit = productOrigUnit || '--'
           }
+          this.localDataSource = data.list
           this.disabled = false
           return data
         })
       },
-      detailData: null //  详情数据
+      detailData: null, //  详情数据
+      openModal: false,
+      localDataSource: [],
+      nowPrintType: '' //  当前打印类型
     }
   },
   methods: {
     //  返回
     handleBack () {
-      this.$router.back()
+      this.$router.push({ path: '/salesManagement/pushOrderManagement/list' })
     },
     //  详情
     getDetail () {
       dispatchFindBySn({ dispatchBillSn: this.$route.params.sn }).then(res => {
-        console.log(res.data)
         if (res.status == 200) {
           this.detailData = res.data
         } else {
           this.detailData = null
         }
       })
+    },
+    // 分类选择
+    handleOk (type) {
+      this.requestFun({ productTypeSn2: type })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      this.nowPrintType = type
+      if (type == 'SALES_BILL' || type == 'DISPATCH_BILL') { //  销售打印/发货打印
+        this.requestFun()
+      } else if (type == 'SALES_BILL_TYPE' || type == 'DISPATCH_BILL_TYPE') { //  销售分类打印/发货分类打印
+        this.openModal = true
+      }
+    },
+    requestFun (productType) {
+      const _this = this
+      const params = {
+        type: this.nowPrintType,
+        dispatchBillSn: this.$route.params.sn
+      }
+      dispatchDetailPrint(Object.assign(params, productType || {})).then(res => {
+        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)
+        }
+      })
+    },
+    print (data) {
+      this.spinLoading = false
+      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>'
+      window.frames['printf'].focus()
+      window.frames['printf'].print()
     }
   },
   mounted () {