Browse Source

装箱单面辅料导出功能

jbb 2 years ago
parent
commit
8539ad35c5
1 changed files with 51 additions and 0 deletions
  1. 51 0
      src/views/packing-list/fabric-list.vue

+ 51 - 0
src/views/packing-list/fabric-list.vue

@@ -53,6 +53,7 @@
         <a-button type="primary" @click="bitchSubmitList" icon="check">批量提交</a-button>
         <a-button type="primary" @click="bitchCancelSubmitList" icon="close">批量取消提交</a-button>
         <a-button type="primary" @click="push" icon="export">推送</a-button>
+        <a-button type="primary" icon="download" @click="handleExportXls('装箱单-面辅料')">导出</a-button>
       </div>
 
       <!-- 子表  :scroll="{ x: 1500 }" 内容少 无需滚动-->
@@ -94,6 +95,7 @@
             <a-menu slot="overlay" v-if="record.status=='0'">
               <a-menu-item><a @click="details(record)">详情</a></a-menu-item>
               <a-menu-item><a @click="edit(record)">编辑</a></a-menu-item>
+              <a-menu-item><a @click="itemXls(record)">导出</a></a-menu-item>
               <!-- <a-menu-item><a @click="submit(record)">提交</a></a-menu-item> -->
               <a-menu-item>
                 <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(record.id)">
@@ -104,8 +106,10 @@
             <!-- 已提交 -->
             <a-menu slot="overlay" v-if="record.status=='1'">
               <a-menu-item><a @click="details(record)">详情</a></a-menu-item>
+              <a-menu-item><a @click="itemXls(record)">导出</a></a-menu-item>
               <!-- <a-menu-item><a @click="cancel(record)">取消提交</a></a-menu-item> -->
             </a-menu>
+              
           </a-dropdown>
         </span>
       </a-table>
@@ -122,6 +126,7 @@
 
 <script>
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+import { downFile } from '@/api/manage'
 import JEllipsis from '@/components/jeecg/JEllipsis'
 import moment from 'moment'
 import addFabricDrawer from '@views/packing-list/packinglist-fabrics/addFabricDrawer.vue'
@@ -300,6 +305,52 @@ export default {
     // 操作 附件上传
     accessoryUpload() {},
 
+     // 列表导出
+    handleExportXls(fileName) {
+      downFile('/splfi/syPackingListFabric/exportXls').then(data => {
+        if (!data) {
+          this.$message.warning('文件下载失败')
+          return
+        }
+        if (typeof window.navigator.msSaveBlob !== 'undefined') {
+          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
+        } else {
+          let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
+          let link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = url
+          link.setAttribute('download', fileName + '.xls')
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link) // 下载完成移除元素
+          window.URL.revokeObjectURL(url) // 释放掉blob对象
+        }
+      })
+    },
+
+    // 操作 单条数据导出
+    itemXls(record) {
+       downFile('/splfi/syPackingListFabric/exportXls',{id:record.id}).then(data => {
+         if (!data) {
+          this.$message.warning('文件下载失败')
+          return
+        }
+         if (typeof window.navigator.msSaveBlob !== 'undefined') {
+          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), item + '.xlsx')
+        }else {
+          let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
+          let link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = url
+          link.setAttribute('download', '装箱单' + '.xlsx')
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link) // 下载完成移除元素
+          window.URL.revokeObjectURL(url) // 释放掉blob对象
+        }
+       })
+    },
+
     // 操作 详情
     details(record) {
       console.log('详情', record.id)