qymljy 2 лет назад
Родитель
Сommit
f424b0b7b1
2 измененных файлов с 46 добавлено и 3 удалено
  1. 6 3
      src/SDrpManagement/QuotedPrice/index.vue
  2. 40 0
      src/components/export_file/index2.vue

+ 6 - 3
src/SDrpManagement/QuotedPrice/index.vue

@@ -14,7 +14,7 @@
       >
       <template #titleRight>
 <!--        <el-button type="primary" size="small" @click="onExport" plain>导 出</el-button>-->
-
+        <exportFile :param="param" fileName="报价单" ></exportFile>
       </template>
       <template #custom >
         <div class="mt-10">
@@ -122,10 +122,12 @@
 
 <script>
 import importExcel from './modules/importQuotedPrice.vue'
+import exportFile from '@/components/export_file/index2'
 export default {
   name: "index",
   components:{
-    importExcel
+    importExcel,
+    exportFile
   },
   data(){
     return {
@@ -165,6 +167,7 @@ export default {
         startdate:'',
         enddate:'',
       },
+      param:{}
     }
   },
   methods:{
@@ -198,7 +201,7 @@ export default {
       }else {
         this.$refs.quotedPriceList.param.content.sort = [sort[0]]
       }
-
+      this.param = this.$refs.quotedPriceList.param
       this.$refs.quotedPriceList.listData()
     },
     /*是否经销商*/

+ 40 - 0
src/components/export_file/index2.vue

@@ -0,0 +1,40 @@
+<template>
+  <el-button type="primary" size="small" @click="exportData" plain>导 出</el-button>
+</template>
+
+<script>
+export default {
+  props:['param','type','columns','columnsIndex','fileName','dataid'],
+  data(){
+    return{
+      columnsData:[]
+    }
+  },
+  methods:{
+    async exportData(){
+      console.log(this.param,'param22')
+      this.param.content.isExport = 1
+      /*导出数据*/
+      const res = await this.$api.requested(this.param)
+      this.downFile(res.data,this.fileName)
+      this.param.content.isExport = 0
+    },
+    downFile(url, fileName) {
+      console.log(url,'url')
+      const x = new XMLHttpRequest()
+      x.open('GET', url, true)
+      x.responseType = 'blob'
+      x.onload = function() {
+        const url = window.URL.createObjectURL(x.response)
+        const a = document.createElement('a')
+        a.href = url
+        a.download = fileName
+        a.click()
+      }
+      x.send()
+    }
+  }
+}
+</script>
+<style>
+</style>