Browse Source

调拨打印和调拨分类打印

chenrui 3 years ago
parent
commit
55ddb7de9c

+ 16 - 2
src/api/allocateBill.js

@@ -105,12 +105,26 @@ export const allocateBillDetailSave = params => {
 }
 // 调拨管理 详情  打印
 export const allocateBillDetailPrint = params => {
+  const url = `/allocateBill/print/${params.printType}/${params.isPreview}`
+  delete params.printType
+  delete params.isPreview
   return axios.request({
-    url: `/allocateBill/print/${params.sn}/${params.isPreview}`,
-    method: 'get',
+    url: url,
+    data: params,
+    method: 'post',
     responseType: 'blob'
   })
 }
+// 调拨管理  详情  打印  产品列表
+export const allocateBillProductTypeList = params => {
+  const url = `/allocateBill/queryProductTypeList/${params.sn}`
+  delete params.sn
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
 // 调拨管理 下载模板
 export const allocateBillDownload = params => {
   return axios.request({

+ 31 - 8
src/views/allocationManagement/transferOut/detail.vue

@@ -15,8 +15,20 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template v-if="$hasPermissions('B_transferOut_print')" slot="extra">
-          <a-button key="2" id="allocateBillDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="allocateBillDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <a-button
+            key="2"
+            type="primary"
+            class="button-error"
+            id="allocateBillDetail-db-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('dbPrint')">调拨打印</a-button>
+          <a-button
+            key="1"
+            type="primary"
+            class="button-info"
+            id="allocateBillDetail-dbfl-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('dbflPrint')">调拨分类打印</a-button>
         </template>
       </a-page-header>
       <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
@@ -54,6 +66,8 @@
         </s-table>
       </a-card>
     </a-spin>
+    <!-- 打印导出 -->
+    <print-modal :openModal="openModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openModal=false" />
     <!-- 打印 -->
     <div id="print"></div>
   </div>
@@ -61,9 +75,10 @@
 
 <script>
 import { STable, VSelect } from '@/components'
+import printModal from './printModal.vue'
 import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint } from '@/api/allocateBill'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, printModal },
   props: {
     outBizSn: { //  有值则为弹框,无值则为页面
       type: [Number, String],
@@ -89,7 +104,9 @@ export default {
       },
       basicInfoData: null, //  基本信息
       productTotal: null, //  合计
-      localDataSource: []
+      localDataSource: [],
+      openModal: false,
+      nowType: null
     }
   },
   computed: {
@@ -145,9 +162,15 @@ export default {
     },
     // 打印预览/快捷打印
     handlePrint (type) {
+      this.nowType = type
+      this.openModal = true
+    },
+    handleOk (objs) {
       const _this = this
+      const params = JSON.parse(JSON.stringify(objs))
+      delete params.type
       _this.spinning = true
-      allocateBillDetailPrint({ sn: this.outBizSn || this.$route.params.sn, isPreview: type == 'preview' ? 1 : 0 }).then(res => {
+      allocateBillDetailPrint(params).then(res => {
         _this.spinning = false
         if (res.type == 'application/json') {
           var reader = new FileReader()
@@ -160,7 +183,7 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.print(res, type)
+          this.print(res, objs.isPreview)
         }
       })
     },
@@ -170,9 +193,9 @@ export default {
       }
       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') { //  预览
+      if (type == '1') { //  预览
         window.open(url)
-      } else if (type == 'print') { //  打印
+      } else if (type == '0') { //  打印
         window.frames['printf'].focus()
         window.frames['printf'].print()
       }

+ 32 - 9
src/views/allocationManagement/transferOut/edit.vue

@@ -8,8 +8,20 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template v-if="$hasPermissions('B_transferOut_print')" slot="extra">
-          <a-button key="2" id="allocateBillEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="allocateBillEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <a-button
+            key="2"
+            type="primary"
+            class="button-error"
+            id="allocateBillEdit-db-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('dbPrint')">调拨打印</a-button>
+          <a-button
+            key="1"
+            type="primary"
+            class="button-info"
+            id="allocateBillEdit-dbfl-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('dbflPrint')">调拨分类打印</a-button>
         </template>
       </a-page-header>
       <a-card size="small" :bordered="false" v-if="basicInfoData" class="allocateBillEdit-cont">
@@ -185,7 +197,9 @@
         style="padding: 0 60px;">提交</a-button>
     </div>
     <!-- 导入产品 -->
-    <importGuideModal :openModal="openGuideModal" :params="{allocateSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
+    <importGuideModal :openModal="openGuideModal" :params="{allocateSn: $route.params.sn}" @close="openGuideModal=false" />
+    <!-- 打印导出 -->
+    <print-modal :openModal="openModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openModal=false" />
     <!-- 打印 -->
     <div id="print"></div>
   </div>
@@ -194,13 +208,14 @@
 <script>
 import { STable, VSelect } from '@/components'
 import ImportGuideModal from './importGuideModal.vue'
+import printModal from './printModal.vue'
 import { queryStockProductPage } from '@/api/stock'
 import { productPriceInfo } from '@/api/product'
 import AllocateType from '@/views/common/allocateType.js'
 import { allocateBillSave, allocateBillDetailList, allocateBillDetailCount, allocateBillDetail, allocateBillDetailSave, allocateBillSubmit, allocateBillDetailDel, allocateBillDetailDelAll, allocateBillDetailPrint, allocateBillBatchInsert } from '@/api/allocateBill'
 
 export default {
-  components: { STable, VSelect, ImportGuideModal, AllocateType },
+  components: { STable, VSelect, ImportGuideModal, AllocateType, printModal },
   data () {
     return {
       spinning: false,
@@ -256,7 +271,9 @@ export default {
       },
       productTotal: null, //  合计
       basicInfoData: null, // 基本信息
-      openGuideModal: false //  导入产品引导
+      openGuideModal: false, //  导入产品引导
+      openModal: false,
+      nowType: null
     }
   },
   computed: {
@@ -493,9 +510,15 @@ export default {
     },
     // 打印预览/快捷打印
     handlePrint (type) {
+      this.nowType = type
+      this.openModal = true
+    },
+    handleOk (objs) {
       const _this = this
+      const params = JSON.parse(JSON.stringify(objs))
+      delete params.type
       _this.spinning = true
-      allocateBillDetailPrint({ sn: this.$route.params.sn, isPreview: type == 'preview' ? 1 : 0 }).then(res => {
+      allocateBillDetailPrint(params).then(res => {
         _this.spinning = false
         if (res.type == 'application/json') {
           var reader = new FileReader()
@@ -508,7 +531,7 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.print(res, type)
+          this.print(res, objs.isPreview)
         }
       })
     },
@@ -518,9 +541,9 @@ export default {
       }
       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') { //  预览
+      if (type == '1') { //  预览
         window.open(url)
-      } else if (type == 'print') { //  打印
+      } else if (type == '0') { //  打印
         window.frames['printf'].focus()
         window.frames['printf'].print()
       }

+ 167 - 0
src/views/allocationManagement/transferOut/printModal.vue

@@ -0,0 +1,167 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    class="allocateBill-print-type-modal"
+    :title="modalTit"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="600">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="allocateBill-print-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="调拨单号">{{ itemData&&itemData.allocateNo || '--' }}</a-form-model-item>
+        <a-form-model-item label="客户名称">{{ itemData&&itemData.dealerInfo&&itemData.dealerInfo.dealerName || '--' }}</a-form-model-item>
+        <a-form-model-item label="产品分类" prop="id" v-if="nowType=='dbflPrint'">
+          <a-select id="allocateBill-print-form" v-model="form.id" placeholder="请选择产品分类">
+            <a-select-option v-for="item in typeList" :value="item.id" :key="item.id">
+              <span v-if="item.id != 'all'">{{ item.productBrandName }} - {{ item.productTypeName3 }}</span>
+              <span v-else>全部</span>
+            </a-select-option>
+          </a-select>
+        </a-form-model-item>
+        <a-form-model-item label="产品价格" prop="priceType" v-if="nowType=='dbPrint'">
+          <a-radio-group v-model="form.priceType">
+            <a-radio value="ALLOCATE_BILL_PRICE">销售价</a-radio>
+            <a-radio value="ALLOCATE_BILL_COST">成本价</a-radio>
+            <a-radio value="ALLOCATE_BILL">不打印</a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="allocateBill-print-save" @click="handleSave('preview')">打印预览</a-button>
+        <a-button id="allocateBill-print-back" @click="handleSave('print')" style="margin-left: 15px;">快捷打印</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { allocateBillProductTypeList } from '@/api/allocateBill'
+export default {
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemData: {
+      type: Object,
+      default: () => {
+        return null
+      }
+    },
+    nowType: {
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      form: {
+        id: undefined,
+        priceType: undefined
+      },
+      rules: {
+        id: [{ required: true, message: '请选择产品分类', trigger: 'change' }],
+        priceType: [{ required: true, message: '请选择产品价格', trigger: 'change' }]
+      },
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 }
+      },
+      spinning: false,
+      typeList: []
+    }
+  },
+  computed: {
+    modalTit () {
+      let title = ''
+      if (this.nowType == 'dbPrint') {
+        title = '调拨打印'
+      } else if (this.nowType == 'dbflPrint') {
+        title = '调拨分类打印'
+      }
+      return title
+    }
+  },
+  methods: {
+    // 确认
+    handleSave (type) {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          if (_this.nowType == 'dbflPrint') {
+            const item = _this.typeList.find(item => item.id == _this.form.id)
+            if (item) {
+              const obj = {
+                allocateSn: _this.itemData.allocateSn,
+                productBrandSn: item.productBrandSn,
+                productTypeSn3: item.productTypeSn3,
+                printType: 'ALLOCATE_BILL_TYPE',
+                isPreview: type == 'preview' ? 1 : 0
+              }
+              _this.$emit('ok', obj)
+            }
+          } else {
+            const obj = {
+              allocateSn: _this.itemData.allocateSn,
+              printType: _this.form.priceType,
+              isPreview: type == 'preview' ? 1 : 0
+            }
+            _this.$emit('ok', obj)
+          }
+          _this.isShow = false
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 获取该销售单产品二级分类
+    getTypeData () {
+      this.typeList = [{ id: 'all' }]
+      allocateBillProductTypeList({ sn: this.itemData.allocateSn || null }).then(res => {
+        if (res.status == 200) {
+          if (res.data && res.data.length > 0) {
+            this.typeList = [...this.typeList, ...res.data]
+          }
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      } else {
+        if (this.nowType == 'dbflPrint') {
+          this.getTypeData()
+        }
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .allocateBill-print-type-modal{
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 2 - 2
src/views/salesManagement/salesQuery/printModal.vue

@@ -17,8 +17,8 @@
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol"
       >
-        <a-form-model-item label="销售单号">{{ itemData&&itemData.salesBillNo || '' }}</a-form-model-item>
-        <a-form-model-item label="客户名称">{{ itemData&&itemData.buyerName || '' }}</a-form-model-item>
+        <a-form-model-item label="销售单号">{{ itemData&&itemData.salesBillNo || '--' }}</a-form-model-item>
+        <a-form-model-item label="客户名称">{{ itemData&&itemData.buyerName || '--' }}</a-form-model-item>
         <a-form-model-item label="产品分类" prop="id" v-if="nowType=='SALES_BILL_TYPE'">
           <a-select id="sales-print-form" v-model="form.id" placeholder="请选择产品分类">
             <a-select-option v-for="item in typeList" :value="item.id" :key="item.id">