Kaynağa Gözat

导出官方无效报告

zhuliu 3 hafta önce
ebeveyn
işleme
2119fdab20

+ 1 - 1
src/api/newApi/report.js

@@ -881,6 +881,6 @@ updateSupplyEvidence(data) {
     * 导出报告清单
   */
   exportReportList(data) {
-    return axios.post("/xiaoshi/reportExport/exportReportList", data);
+    return axios.post("/xiaoshi/reportExport/exportReportList", data,{responseType:'blob'});
   },
 };

+ 3 - 2
src/utils/axios.js

@@ -62,11 +62,12 @@ _axios.interceptors.response.use(
       loadingInstance.close()
     }
     let { code, message } = response.data
-    if(code != 0 && !code ){
+    
+    if (code === 200 || config.responseType === 'blob') {
       isRefreshing = false
       return response.data
     }
-    if (code === 200 || config.responseType === 'blob') {
+    if(code != 0 && !code ){
       isRefreshing = false
       return response.data
     }

+ 4 - 1
src/utils/index.js

@@ -22,7 +22,10 @@ export const downLoad = (data, fileName) => {
   element.setAttribute('download', fileName);
   document.body.appendChild(element);
   element.click();
-  document.body.removeChild(element);
+  setTimeout(() => {
+    document.body.removeChild(element);
+    URL.revokeObjectURL(objectUrl);
+  }, 100);
 }
 
 export const getFileName = (type) => {

+ 5 - 17
src/views/report/components/index.vue

@@ -33,7 +33,7 @@
             </el-dropdown>
             <el-button type="primary" class="margin-left_10 margin-right_10" size="small" @click="showField">显示栏位管理</el-button>
             <el-button v-if="$permission.FunPermissions('xiaoshi/IPREmail')" type="primary" class="margin-right_10" size="small" @click="IPREmail">联系邮箱</el-button>
-            <el-button type="primary" class="margin-right_10" size="small" v-loading="exportBtnLoading" @click="exportExcel">导出</el-button>
+            <el-button type="primary" v-if="componentType==2 && $permission.FunPermissions('xiaoshi/exportReportList')" class="margin-right_10" size="small" :loading="exportBtnLoading" @click="exportExcel">导 出</el-button>
           </div>
 
         </div>
@@ -83,7 +83,7 @@ import patentShare from '@/views/components/drawer/Share.vue';
 
 import IPREmailDialog from '../InvalidResponse/components/dialog/IPREmail.vue'
 import handlePersonDialog from './dialog/handlePerson.vue'
-import { formatDate } from '@/utils';
+import { formatDate,downLoad } from '@/utils';
 export default {
   components: {
     Table,
@@ -308,23 +308,11 @@ export default {
           params.searchQuery ='reportType=(' + this.fixedSearch.reportType.join(' OR ') + ')'
         }
       }
+      this.exportBtnLoading = true
       this.$api.exportReportList(params).then(response=>{
         this.exportBtnLoading = false
-        const anchor = document.createElement('a');
-        if ('download' in anchor) {
-          anchor.href = URL.createObjectURL(response);
-          let now = formatDate(new Date(),"YYYY-MM-DD")
-          anchor.setAttribute("download", now + '- 无效案件详情表.xlsx');
-          anchor.className = "download-js-link";
-          anchor.innerHTML = "downloading...";
-          anchor.style.display = "none";
-          document.body.appendChild(anchor);
-          setTimeout(function () {
-            anchor.click();
-            document.body.removeChild(anchor);
-          }, 66);
-          return true;
-        }
+        let now = formatDate(new Date(),"YYYY-MM-DD")
+        downLoad(response,now + '- 无效案件详情表.xlsx')
       }).catch(error=>{
         this.$message.error('导出失败')
         this.exportBtnLoading = false