Browse Source

成本分配列表-导出

jbb 1 year ago
parent
commit
280aa9173f
1 changed files with 28 additions and 1 deletions
  1. 28 1
      src/views/cost-allocation-total/list.vue

+ 28 - 1
src/views/cost-allocation-total/list.vue

@@ -91,6 +91,9 @@
 
     <!-- table区域  -->
     <a-card :bordered="false" style=" marginTop:10px;">
+      <div class="table-operator">
+        <a-button type="primary" @click="exportList('成本分配列表')" icon="plus">导出</a-button>
+      </div>
       <a-table
         bordered
         rowKey="id"
@@ -129,7 +132,7 @@
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import JEllipsis from '@/components/jeecg/JEllipsis'
 import moment from 'moment'
-
+import { downFile } from '@/api/manage'
 import costDetailDrawer from '@views/cost-allocation-total/costDetailDrawer.vue'
 import ChistoryModal from '@views/cost-allocation-total/modal/ChistoryModal'
 
@@ -305,6 +308,30 @@ export default {
       };
       window.parent.postMessage({msg:"startApply", data:data}, "*");
     },
+    //导出
+    exportList(fileName){
+      var params = this.queryParam
+      downFile('/orderData/syCostLossReview/exportXls', params).then(data => {
+        console.log('888')
+        if (!data) {
+          this.$message.warning('文件下载失败')
+          return
+        }
+        if (typeof window.navigator.msSaveBlob !== 'undefined') {
+          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), +fileName + '.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', fileName + '.xlsx')
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link) // 下载完成移除元素
+          window.URL.revokeObjectURL(url) // 释放掉blob对象
+        }
+      })
+    },
 
     handleTableChange(pagination, filters, sorter) {
       this.queryParam.pageNo = pagination.current