Browse Source

销售退货、连锁调入打印预览

chenrui 4 years ago
parent
commit
aaa9bdf3c3

+ 8 - 0
src/api/allocLinkagePut.js

@@ -60,3 +60,11 @@ export const allocLinkagePutDetailUpdate = (params) => {
     method: 'post'
   })
 }
+// 连锁调拨调入 详情  打印
+export const allocLinkagePutDetailPrint = params => {
+  return axios.request({
+    url: `allocLinkagePut/print/${params.sn}/${params.type}`,
+    method: 'get',
+    responseType: 'blob'
+  })
+}

+ 8 - 6
src/api/salesReturn.js

@@ -145,7 +145,6 @@ export const salesReturnSave = (params) => {
     method: 'post'
   })
 }
-
 //  销售退货 提交
 export const salesReturnSubmit = (params) => {
   return axios({
@@ -153,8 +152,11 @@ export const salesReturnSubmit = (params) => {
     method: 'get'
   })
 }
-
-
-
-
-
+// 销售退货 详情  打印
+export const salesReturnDetailPrint = params => {
+  return axios.request({
+    url: `salesReturn/print/${params.sn}/${params.type}`,
+    method: 'get',
+    responseType: 'blob'
+  })
+}

+ 1 - 1
src/api/storeCallOut.js

@@ -99,7 +99,7 @@ export const storeCallOutDetailDel = (params) => {
     method: 'post'
   })
 }
-// 散件采购(入库) 详情  打印
+// 店内调出 详情  打印
 export const storeCallOutDetailPrint = params => {
   return axios.request({
     url: `storeCallOut/print/${params.sn}/${params.type}/${params.costFlag}`,

+ 45 - 4
src/views/allocationManagement/chainTransferIn/detail.vue

@@ -14,8 +14,12 @@
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
-        <a-button key="2" id="chainTransferInDetail-preview-btn">打印预览</a-button>
-        <a-button key="1" type="primary" id="chainTransferInDetail-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="chainTransferInDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
+        <a-button key="1" type="primary" id="chainTransferInDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
       </template>
     </a-page-header>
     <!-- 基础信息 -->
@@ -48,13 +52,15 @@
         bordered>
       </s-table>
     </a-card>
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
-import { allocLinkagePutDetailList, allocLinkagePutDetailSn, allocLinkagePutDetailCount } from '@/api/allocLinkagePut'
+import { allocLinkagePutDetailList, allocLinkagePutDetailSn, allocLinkagePutDetailCount, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
 export default {
   components: { STable, VSelect },
   data () {
@@ -84,11 +90,14 @@ export default {
             data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
           }
           this.getDetailCount(params)
+          this.localDataSource = data.list
           return data
         })
       },
       basicInfoData: null, //  基本信息
-      productTotal: null //  合计
+      productTotal: null, //  合计
+      localDataSource: [],
+      printerType: 'INK' //  打印机类型
     }
   },
   computed: {
@@ -124,6 +133,38 @@ export default {
     //  编辑
     handleEdit () {
       this.$router.push({ path: `/allocationManagement/chainTransferIn/edit/${this.basicInfoData.id}/${this.basicInfoData.allocationLinkagePutSn}` })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      const _this = this
+      allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).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()
+      }
     }
   },
   beforeRouteEnter (to, from, next) {

+ 43 - 4
src/views/allocationManagement/chainTransferIn/edit.vue

@@ -7,8 +7,12 @@
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
-        <a-button key="2" id="chainTransferInEdit-preview-btn">打印预览</a-button>
-        <a-button key="1" type="primary" id="chainTransferInEdit-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="chainTransferInEdit-preview-btn" :disabled="loadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
+        <a-button key="1" type="primary" id="chainTransferInEdit-print-btn" :disabled="loadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
       </template>
     </a-page-header>
     <!-- 基础信息 -->
@@ -100,6 +104,8 @@
           style="padding: 0 60px;">提交入库</a-button>
       </div>
     </a-affix>
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
@@ -108,7 +114,7 @@ import { STable, VSelect } from '@/components'
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import { warehouseCascadeList } from '@/api/warehouse'
-import { allocLinkagePutDetailSn, allocLinkagePutDetailList, allocLinkagePutDetailCount, allocLinkagePutDetailUpdate, allocLinkagePutAudit } from '@/api/allocLinkagePut'
+import { allocLinkagePutDetailSn, allocLinkagePutDetailList, allocLinkagePutDetailCount, allocLinkagePutDetailUpdate, allocLinkagePutAudit, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
 export default {
   components: { STable, VSelect },
   data () {
@@ -147,7 +153,8 @@ export default {
         onChange: (current) => this.changePage(current)
       },
       basicInfoData: null, //  基本信息
-      productTotal: null //  合计
+      productTotal: null, //  合计
+      printerType: 'INK' //  打印机类型
     }
   },
   methods: {
@@ -304,6 +311,38 @@ export default {
           this.warehouseCascadeData = []
         }
       })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      const _this = this
+      allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).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()
+      }
     }
   },
   beforeRouteEnter (to, from, next) {

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

@@ -146,8 +146,8 @@ export default {
   methods: {
     //  返回
     handleBack () {
-      // this.$router.push({ name: 'salesQueryList' })
-      this.$router.back()
+      this.$router.push({ name: 'salesQueryList' })
+      // this.$router.back()
     },
     // 编辑
     handleEdit () {

+ 45 - 5
src/views/salesManagement/salesReturn/detail.vue

@@ -5,9 +5,12 @@
         <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
       </template>
       <template slot="extra">
-        <a-button key="3" id="salesReturnDetail-preview-btn">打印预览</a-button>
-        <a-button key="4" type="primary" id="salesReturnDetail-print-btn">快速打印</a-button>
-        <!-- <a-button key="5" id="salesReturnDetail-export-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="salesReturnDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
+        <a-button key="1" type="primary" id="salesReturnDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
       </template>
     </a-page-header>
     <!-- 基础信息 -->
@@ -45,13 +48,15 @@
         bordered>
       </s-table>
     </a-card>
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
 <script>
 import { getOperationalPrecision } from '@/libs/tools.js'
 import { STable, VSelect } from '@/components'
-import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList } from '@/api/salesReturn'
+import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDetailPrint } from '@/api/salesReturn'
 export default {
   name: 'SalesReturnDetail',
   components: { STable, VSelect },
@@ -95,11 +100,14 @@ export default {
             // 折后退货金额小计  由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
             data.list[i].saleReturnSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
           }
+          this.localDataSource = data.list
           this.disabled = false
           return data
         })
       },
-      detailData: null //  详情数据
+      localDataSource: [],
+      detailData: null, //  详情数据
+      printerType: 'INK' //  打印机类型
     }
   },
   methods: {
@@ -122,6 +130,38 @@ export default {
           this.detailData = null
         }
       })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      const _this = this
+      salesReturnDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).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()
+      }
     }
   },
   mounted () {

+ 2 - 2
src/views/salesManagement/salesReturn/queryPart.vue

@@ -134,7 +134,7 @@ export default {
       this.columns = [
         { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
         { title: '产品编码', dataIndex: 'dealerProductEntity.code', align: 'center', sorter: true, width: 220 },
-        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center' },
+        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', ellipsis: true },
         { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', customRender: function (text) { return text || '--' }, width: 220 },
         { title: '销售单号', dataIndex: 'salesBillNo', align: 'center', width: 220 },
         { title: '销售审核时间', dataIndex: 'auditTime', align: 'center', customRender: function (text) { return text || '--' }, width: 160 },
@@ -147,7 +147,7 @@ export default {
       this.columns = [
         { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
         { title: '产品编码', dataIndex: 'productCode', align: 'center', sorter: true },
-        { title: '产品名称', dataIndex: 'productName', align: 'center' },
+        { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true },
         { title: '原厂编码', dataIndex: 'productOrigCode', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '售价', dataIndex: 'salePrice', align: 'center', width: 100, scopedSlots: { customRender: 'price' } },
         { title: '单位', dataIndex: 'unit', align: 'center', customRender: function (text) { return text || '--' }, width: 100 },

+ 45 - 6
src/views/salesManagement/salesReturn/salesReturnEdit.vue

@@ -8,8 +8,12 @@
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
-        <a-button key="2" id="salesReturnEdit-preview-btn">打印预览</a-button>
-        <a-button key="1" type="primary" id="salesReturnEdit-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="salesReturnEdit-preview-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
+        <a-button key="1" type="primary" id="salesReturnEdit-print-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
       </template>
     </a-page-header>
     <a-card size="small" :bordered="false" class="pages-wrap">
@@ -57,7 +61,7 @@
         </a-col>
         <a-col :span="6">
           <div style="float:right;overflow: hidden;">
-            <a-button id="salesReturn-dru">导入明细</a-button>
+            <!-- <a-button id="salesReturn-dru">导入明细</a-button> -->
             <a-button
               size="small"
               type="primary"
@@ -151,6 +155,8 @@
     </a-affix>
     <!-- 选择客户弹框 -->
     <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
@@ -160,7 +166,7 @@ import queryPart from './queryPart.vue'
 import EditableCell from '@/views/common/editInput.js'
 import chooseCustomModal from './chooseCustomModal.vue'
 import { warehouseCascadeList } from '@/api/warehouse'
-import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit } from '@/api/salesReturn'
+import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint } from '@/api/salesReturn'
 export default {
   name: 'SalesDetail',
   components: {
@@ -192,7 +198,7 @@ export default {
       columns: [
         { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
         { title: '产品编码', dataIndex: 'dealerProductEntity.code', align: 'center', width: 220, customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', width: 220, customRender: function (text) { return text || '--' } },
         { title: '售价', dataIndex: 'price', align: 'center', width: 150, scopedSlots: { customRender: 'price' } },
         { title: '单位', dataIndex: 'dealerProductEntity.unit', align: 'center', width: 100, customRender: function (text) { return text || '--' } },
@@ -229,7 +235,8 @@ export default {
           this.chooseLoadData = data.list
           return data
         })
-      }
+      },
+      printerType: 'INK' //  打印机类型
     }
   },
   methods: {
@@ -421,6 +428,38 @@ export default {
           this.$message.success(res.message)
         }
       })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      const _this = this
+      salesReturnDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).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()
+      }
     }
   },
   mounted () {

+ 45 - 6
src/views/salesManagement/salesReturn/salesReturnGrabEdit.vue

@@ -8,8 +8,12 @@
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
-        <a-button key="2" id="salesReturnGrabEdit-preview-btn">打印预览</a-button>
-        <a-button key="1" type="primary" id="salesReturnGrabEdit-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="salesReturnEdit-preview-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
+        <a-button key="1" type="primary" id="salesReturnEdit-print-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
       </template>
     </a-page-header>
     <a-card size="small" :bordered="false" class="pages-wrap">
@@ -57,7 +61,7 @@
         </a-col>
         <a-col :span="6">
           <div style="float:right;overflow: hidden;">
-            <a-button id="salesReturn-dru">导入明细</a-button>
+            <!-- <a-button id="salesReturn-dru">导入明细</a-button> -->
             <a-button
               size="small"
               type="primary"
@@ -141,6 +145,8 @@
     </a-affix>
     <!-- 选择客户弹框 -->
     <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
@@ -150,7 +156,7 @@ import queryPart from './queryPart.vue'
 import EditableCell from '@/views/common/editInput.js'
 import chooseCustomModal from './chooseCustomModal.vue'
 import { warehouseCascadeList } from '@/api/warehouse'
-import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit } from '@/api/salesReturn'
+import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint } from '@/api/salesReturn'
 export default {
   name: 'SalesDetail',
   components: {
@@ -182,7 +188,7 @@ export default {
       columns: [
         { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
         { title: '产品编码', dataIndex: 'dealerProductEntity.code', align: 'center', width: 220, customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', width: 220, customRender: function (text) { return text || '--' } },
         { title: '销售单号', dataIndex: 'salesBillNo', align: 'center', width: 200, customRender: function (text) { return text || '--' } },
         { title: '售价', dataIndex: 'price', align: 'center', width: 100, scopedSlots: { customRender: 'price' } },
@@ -221,7 +227,8 @@ export default {
           this.chooseLoadData = data.list
           return data
         })
-      }
+      },
+      printerType: 'INK' //  打印机类型
     }
   },
   methods: {
@@ -415,6 +422,38 @@ export default {
           this.$message.success(res.message)
         }
       })
+    },
+    // 打印预览/快捷打印
+    handlePrint (type) {
+      const _this = this
+      salesReturnDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).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()
+      }
     }
   },
   mounted () {