Browse Source

盘点审核 打印导出

chenrui 3 years ago
parent
commit
8e57ea6362

+ 18 - 0
src/api/checkWarehouse.js

@@ -155,3 +155,21 @@ export const checkWarehouseAuditList = (params) => {
     method: 'post'
   })
 }
+// 库存盘点 详情  导出
+export const checkWarehouseDetailExport = params => {
+  return axios.request({
+    url: `checkWarehouse/detail/exportExcel`,
+    method: 'post',
+    data: params,
+    responseType: 'blob'
+  })
+}
+// 库存盘点 详情  打印
+export const checkWarehouseDetailPrint = params => {
+  return axios.request({
+    url: `checkWarehouse/detail/print/${params.printType}`,
+    method: 'post',
+    data: params,
+    responseType: 'blob'
+  })
+}

+ 131 - 3
src/views/inventoryManagement/inventoryChecking/detailModal.vue

@@ -10,6 +10,30 @@
     :width="960">
     <a-spin :spinning="spinning" tip="Loading...">
       <a-card size="small" :bordered="false" class="inventoryCheckingDetail-cont">
+        <div class="print-cont" v-if="$hasPermissions('B_inventoryCheckingPrint')">
+          <a-radio-group v-model="printerType">
+            <a-radio value="NEEDLE">针式</a-radio>
+            <a-radio value="INK">喷墨</a-radio>
+          </a-radio-group>
+          <a-button
+            type="primary"
+            class="button-error"
+            id="inventoryCheckingDetail-pd-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('pddy')">盘点打印</a-button>
+          <a-button
+            type="primary"
+            class="button-info"
+            id="inventoryCheckingDetail-sh-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('shdy')">审核打印</a-button>
+          <a-button
+            type="primary"
+            class="button-warning"
+            id="inventoryCheckingDetail-export-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('export')">导出Excel</a-button>
+        </div>
         <a-descriptions size="small" :column="3">
           <a-descriptions-item label="盘点单号" :span="3">
             {{ (basicInfoData&&basicInfoData.checkWarehouseNo) || '--' }}
@@ -95,16 +119,22 @@
         </s-table>
       </a-card>
     </a-spin>
+    <!-- 打印导出 -->
+    <print-modal :openModal="openPrintModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openPrintModal=false" />
+    <!-- 打印 -->
+    <div id="print"></div>
   </a-modal>
 </template>
 
 <script>
+import moment from 'moment'
 import { STable } from '@/components'
+import printModal from './printModal.vue'
 import ProductType from '@/views/common/productType.js'
-import { checkWarehouseDetailList, checkWarehouseDetail, checkWarehouseDetailCount } from '@/api/checkWarehouse'
+import { checkWarehouseDetailList, checkWarehouseDetail, checkWarehouseDetailCount, checkWarehouseDetailExport, checkWarehouseDetailPrint, checkWarehouseWarehouse } from '@/api/checkWarehouse'
 export default {
   name: 'InventoryCheckingDetailModal',
-  components: { STable, ProductType },
+  components: { STable, ProductType, printModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -137,13 +167,19 @@ 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
         })
       },
       basicInfoData: null, //  基本信息
       productTotal: null,
-      productType: []
+      productType: [],
+      warehouseList: [], //  仓库  下拉数据
+      localDataSource: [],
+      openPrintModal: false,
+      nowType: null,
+      printerType: 'NEEDLE' //  打印机类型
     }
   },
   computed: {
@@ -200,6 +236,85 @@ export default {
       this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
       this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
+    // 仓库下拉数据
+    getWarehouseList () {
+      checkWarehouseWarehouse({}).then(res => {
+        if (res.status == 200) {
+          this.warehouseList = res.data
+        } else {
+          this.warehouseList = []
+        }
+      })
+    },
+    // 打印导出
+    handlePrint (type) {
+      if (type == 'export') {
+        this.nowType = type
+        this.handleOk()
+      } else {
+        this.nowType = type
+        this.openPrintModal = true
+      }
+    },
+    handleOk (objs) {
+      const _this = this
+      let params
+      let url = checkWarehouseDetailPrint //  打印
+      if (this.nowType == 'export') { //  导出
+        url = checkWarehouseDetailExport
+        params = { checkWarehouseSn: this.itemSn }
+      } else { //  打印
+        params = JSON.parse(JSON.stringify(objs))
+        params.printType = this.printerType
+        delete params.type
+      }
+      _this.spinning = true
+      url(params).then(res => {
+        _this.spinning = false
+        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 {
+          if (this.nowType == 'export' || this.nowType == 'typeExport') {
+            this.download(res)
+          } else {
+            this.print(res, objs.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()
+      }
+    },
+    download (data) {
+      if (!data) { return }
+      const url = window.URL.createObjectURL(new Blob([data]))
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const a = moment().format('YYYYMMDDHHmmss')
+      const fname = '库存盘点' + a
+      link.setAttribute('download', fname + '.xlsx')
+      document.body.appendChild(link)
+      link.click()
     }
   },
   watch: {
@@ -211,6 +326,7 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+        this.printerType = 'NEEDLE'
       } else {
         const _this = this
         setTimeout(() => (
@@ -221,8 +337,20 @@ export default {
     itemSn (newValue, oldValue) {
       if (this.isShow && newValue) {
         this.getDetail()
+        this.getWarehouseList()
       }
     }
   }
 }
 </script>
+<style lang="less">
+  .inventoryCheckingDetail-modal{
+    .ant-modal-body{
+      padding: 0 24px 24px;
+    }
+    .print-cont{
+      text-align: right;
+      padding: 5px 0 10px;
+    }
+  }
+</style>

+ 123 - 3
src/views/inventoryManagement/inventoryChecking/makeInventory.vue

@@ -8,6 +8,30 @@
           <span class="billno">单号:{{ basicInfoData&&basicInfoData.checkWarehouseNo }}</span>
           <a-tag color="blue">{{ basicInfoData&&basicInfoData.stateDictValue }}</a-tag>
         </template>
+        <template slot="extra" v-if="$hasPermissions('B_inventoryCheckingPrint')">
+          <a-radio-group v-model="printerType">
+            <a-radio value="NEEDLE">针式</a-radio>
+            <a-radio value="INK">喷墨</a-radio>
+          </a-radio-group>
+          <a-button
+            type="primary"
+            class="button-error"
+            id="inventoryCheckingDetail-pd-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('pddy')">盘点打印</a-button>
+          <a-button
+            type="primary"
+            class="button-info"
+            id="inventoryCheckingDetail-sh-print-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('shdy')">审核打印</a-button>
+          <a-button
+            type="primary"
+            class="button-warning"
+            id="inventoryCheckingDetail-export-btn"
+            :disabled="localDataSource.length==0"
+            @click="handlePrint('export')">导出Excel</a-button>
+        </template>
       </a-page-header>
       <!-- 基础信息 -->
       <a-card size="small" :bordered="false" class="inventoryCheckMakeInventoryList-cont">
@@ -125,15 +149,21 @@
         @click="handleSubmit"
         style="padding: 0 60px;">盘点完成</a-button>
     </div>
+    <!-- 打印导出 -->
+    <print-modal :openModal="openPrintModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openPrintModal=false" />
+    <!-- 打印 -->
+    <div id="print"></div>
   </div>
 </template>
 
 <script>
+import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import ProductType from '@/views/common/productType.js'
-import { checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseInventory, checkWarehouseDetail, checkWarehouseDetailSave, checkWarehouseCheckZero } from '@/api/checkWarehouse'
+import printModal from './printModal.vue'
+import { checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseInventory, checkWarehouseDetail, checkWarehouseDetailSave, checkWarehouseCheckZero, checkWarehouseWarehouse, checkWarehouseDetailExport, checkWarehouseDetailPrint } from '@/api/checkWarehouse'
 export default {
-  components: { STable, VSelect, ProductType },
+  components: { STable, VSelect, ProductType, printModal },
   props: {},
   data () {
     return {
@@ -159,13 +189,19 @@ export default {
             data.list[i].no = no + i + 1
             data.list[i].checkQtyBackups = data.list[i].checkQty
           }
+          this.localDataSource = data.list || []
           this.getProduceTotal()
           this.disabled = false
           this.spinning = false
           return data
         })
       },
-      productType: []
+      productType: [],
+      warehouseList: [], //  仓库  下拉数据
+      localDataSource: [],
+      openPrintModal: false,
+      nowType: null,
+      printerType: 'NEEDLE' //  打印机类型
     }
   },
   computed: {
@@ -266,10 +302,14 @@ export default {
     },
     // 整单盘零
     handleCheckZero () {
+      this.spinning = true
       checkWarehouseCheckZero({ checkWarehouseSn: this.$route.params.sn }).then(res => {
         if (res.status == 200) {
           this.$message.success(res.message)
           this.$refs.table.refresh(true)
+          this.spinning = false
+        } else {
+          this.spinning = false
         }
       })
     },
@@ -302,11 +342,91 @@ export default {
       this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
       this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
+    // 仓库下拉数据
+    getWarehouseList () {
+      checkWarehouseWarehouse({}).then(res => {
+        if (res.status == 200) {
+          this.warehouseList = res.data
+        } else {
+          this.warehouseList = []
+        }
+      })
+    },
+    // 打印导出
+    handlePrint (type) {
+      if (type == 'export') {
+        this.nowType = type
+        this.handleOk()
+      } else {
+        this.nowType = type
+        this.openPrintModal = true
+      }
+    },
+    handleOk (objs) {
+      const _this = this
+      let params
+      let url = checkWarehouseDetailPrint //  打印
+      if (this.nowType == 'export') { //  导出
+        url = checkWarehouseDetailExport
+        params = { checkWarehouseSn: this.$route.params.sn }
+      } else { //  打印
+        params = JSON.parse(JSON.stringify(objs))
+        params.printType = this.printerType
+        delete params.type
+      }
+      _this.spinning = true
+      url(params).then(res => {
+        _this.spinning = false
+        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 {
+          if (this.nowType == 'export' || this.nowType == 'typeExport') {
+            this.download(res)
+          } else {
+            this.print(res, objs.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()
+      }
+    },
+    download (data) {
+      if (!data) { return }
+      const url = window.URL.createObjectURL(new Blob([data]))
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const a = moment().format('YYYYMMDDHHmmss')
+      const fname = '库存盘点' + a
+      link.setAttribute('download', fname + '.xlsx')
+      document.body.appendChild(link)
+      link.click()
     }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
       vm.getDetail()
+      vm.getWarehouseList()
     })
   }
 }

+ 169 - 0
src/views/inventoryManagement/inventoryChecking/printModal.vue

@@ -0,0 +1,169 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    class="inventoryChecking-print-type-modal"
+    :title="modalTit"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="600">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="inventoryChecking-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.checkTypeDictValue || '--' }}
+          <span v-if="itemData&&itemData.checkType=='SELECT'">({{ itemData.warehouseFlag=='1' ? '区分仓库':'不区分仓库' }})</span>
+        </a-form-model-item>
+        <a-form-model-item label="仓库范围" prop="warehouseSn" v-if="itemData&&itemData.checkType=='SELECT'&&itemData.warehouseFlag=='1'">
+          <a-select id="inventoryChecking-print-form" v-model="form.warehouseSn" placeholder="请选择仓库范围">
+            <a-select-option v-for="(item,index) in warehouseList" :value="item.warehouseSn" :key="index">{{ item.name }}</a-select-option>
+          </a-select>
+        </a-form-model-item>
+        <a-form-model-item label="库存数量" prop="stockQtyFlag" v-if="nowType == 'pddy'">
+          <a-radio-group v-model="form.stockQtyFlag">
+            <a-radio :value="true">打印</a-radio>
+            <a-radio :value="false">不打印</a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+        <a-form-model-item label="产品范围" prop="productScopeFlag" v-if="nowType == 'shdy'">
+          <a-radio-group v-model="form.productScopeFlag">
+            <a-radio :value="true">所有盘点产品</a-radio>
+            <a-radio :value="false">有盈亏的产品</a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="inventoryChecking-print-save" @click="handleSave()">打印预览</a-button>
+        <a-button id="inventoryChecking-print-back" @click="handleCancel" style="margin-left: 15px;">快捷打印</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { checkWarehouseWarehouse } from '@/api/checkWarehouse'
+export default {
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemData: {
+      type: Object,
+      default: () => {
+        return null
+      }
+    },
+    nowType: {
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      form: {
+        stockQtyFlag: true,
+        productScopeFlag: true,
+        warehouseSn: 'all'
+      },
+      rules: {
+        stockQtyFlag: [{ required: true, message: '请选择库存数量', trigger: 'change' }],
+        warehouseSn: [{ required: true, message: '请选择仓库范围', trigger: 'change' }],
+        productScopeFlag: [{ required: true, message: '请选择产品范围', trigger: 'change' }]
+      },
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 }
+      },
+      spinning: false,
+      warehouseList: []
+    }
+  },
+  computed: {
+    modalTit () {
+      let title = ''
+      if (this.nowType == 'pddy') {
+        title = '盘点打印'
+      } else if (this.nowType == 'shdy') {
+        title = '审核打印'
+      }
+      return title
+    }
+  },
+  methods: {
+    // 确认
+    handleSave (isPrint) {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const obj = {
+            checkWarehouseSn: _this.itemData.checkWarehouseSn,
+            stockQtyFlag: _this.nowType == 'pddy' ? _this.form.stockQtyFlag : undefined,
+            productScopeFlag: _this.nowType == 'shdy' ? _this.form.productScopeFlag : undefined,
+            checkPrintFlag: true,
+            type: isPrint || 'preview'
+          }
+          if (_this.itemData && _this.itemData.checkType == 'SELECT' && _this.itemData.warehouseFlag == '1') { //  自选盘点且区分仓库
+            obj.warehouseSn = _this.form.warehouseSn
+          }
+          _this.$emit('ok', obj)
+          _this.isShow = false
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 快捷打印
+    handleCancel () {
+      this.handleSave('print')
+    },
+    // 仓库下拉数据
+    getWarehouseList () {
+      checkWarehouseWarehouse({}).then(res => {
+        if (res.status == 200) {
+          this.warehouseList = [{ warehouseSn: 'all', name: '所有仓库' }]
+          if (res.data && res.data.length > 0) {
+            this.warehouseList = [...this.warehouseList, ...res.data]
+          }
+        } else {
+          this.warehouseList = []
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      } else {
+        this.getWarehouseList()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .inventoryChecking-print-type-modal{
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 0 - 31
src/views/inventoryManagement/inventoryChecking/selfDisk.vue

@@ -79,22 +79,6 @@
           </a-row>
         </div>
         <!-- 列表 -->
-        <!-- <s-table
-          class="sTable"
-          ref="table"
-          size="small"
-          :row-selection="$hasPermissions('B_inventoryWarningBatchSave') ? {
-            selectedRowKeys: selectedRowKeys,
-            onChange: onChange,
-            onSelect: onSelectChange,
-            onSelectAll: onSelectAllChange
-          } : null"
-          :rowKey="(record) => record.id"
-          :columns="columns"
-          :customRow="handleClickRow"
-          :data="loadData"
-          :scroll="{ x: 1280, y: 300 }"
-          bordered> -->
         <s-table
           class="sTable"
           ref="table"
@@ -185,21 +169,6 @@
           </a-row>
         </div>
         <!-- 列表 -->
-        <!-- <s-table
-          class="sTable"
-          ref="chooseTable"
-          size="small"
-          :row-selection="$hasPermissions('B_inventoryWarningBatchSave') ? {
-            selectedRowKeys: selectedRowKeys,
-            onChange: onChange,
-            onSelect: onSelectChange,
-            onSelectAll: onSelectAllChange
-          } : null"
-          :rowKey="(record) => record.id"
-          :columns="columns"
-          :data="loadData"
-          :scroll="{ x: 1280, y: 300 }"
-          bordered> -->
         <s-table
           class="sTable"
           ref="chooseTable"