Explorar el Código

导出加上转圈渲染

yusm hace 4 meses
padre
commit
6fd46311fd

+ 4 - 1
fhKeeper/formulahousekeeper/timesheet/src/http.js

@@ -294,7 +294,7 @@ export default {
      * @param fileName 如果是导出 Excel 表格文件名后缀最好用.xls 而不是.xlsx,否则文件可能会因为格式错误导致无法打开
      * @param exception 异常的回调函数
      */
-    downloadFile (url, data, fileName, exception) {
+    downloadFile (url, data, fileName, exception, callback) {
         var user = sessionStorage.getItem('user') , token = "";
         if(user != null){
             token = JSON.parse(user).id
@@ -322,6 +322,9 @@ export default {
                     elink.click()
                     document.body.removeChild(elink)
                 }
+                if (callback) {
+                    callback();
+                }
             }
         ).catch(
             (error) => {

+ 25 - 12
fhKeeper/formulahousekeeper/timesheet/src/views/expense/expense.vue

@@ -340,10 +340,10 @@
                   <el-button @click="getList" size="small">{{ $t('find') }}</el-button>
                 </el-form-item>
                 <el-form-item v-if="currentClick == '2-1'">
-                  <el-button @click="exportDocument()" size="small">{{ $t('danJuDaoChu') }}</el-button>
+                  <el-button :loading="exportingData" @click="exportDocument()" size="small">{{ $t('danJuDaoChu') }}</el-button>
                 </el-form-item>
                 <el-form-item v-if="currentClick == '2-1'">
-                  <el-button @click="exportDocumentFile()" size="small">{{ $t('baoXiaoPingZhengDaoChu') }}</el-button>
+                  <el-button :loading="exportingData" @click="exportDocumentFile()" size="small">{{ $t('baoXiaoPingZhengDaoChu') }}</el-button>
                 </el-form-item>
                 <el-form-item v-if="currentClick == '2-1' && permissions.costExpenseRelease">
                   <el-button @click="documentIssuance(1)" size="small">{{ $t('faFang') }}</el-button>
@@ -1112,7 +1112,7 @@ export default {
         id: null
       },
       basecostSettingList: [],
-
+      exportingData:false,
       fileList: [],
       muHeight: document.documentElement.clientHeight || document.body.clientHeight,
       xiamianWidth: document.documentElement.clientWidth || document.body.clientWidth,
@@ -2390,6 +2390,7 @@ export default {
     },
     // 单据导出
     exportDocument() {
+      this.exportingData = true;
       var stat = ''
       var end = ''
       if (this.date) {
@@ -2407,6 +2408,7 @@ export default {
         sendState: this.sendState
       },
         res => {
+          this.exportingData = false;
           if (res.code == "ok") {
             var filePath = res.data;
             const a = document.createElement('a'); // 创建a标签
@@ -2436,15 +2438,26 @@ export default {
         stat = this.date[0]
         end = this.date[1]
       }
-      const formData = new FormData();
-      formData.append('code', this.code);
-      formData.append('startDate', stat);
-      formData.append('endDate', end);
-      formData.append('ownerId', this.ownerId);
-      formData.append('type', this.type);
-      formData.append('projectId', this.selectProject ? this.selectProject : null);
-      formData.append('sendState', this.sendState);
-      this.http.downloadFile(`/expense-sheet/export`, formData, '报销凭证导出.zip')
+      this.exportingData=true
+      var that = this;
+      this.http.downloadFile(`/expense-sheet/export`, {
+        code: this.code,
+        startDate: stat,
+        endDate: end,
+        ownerId: this.ownerId,
+        type: this.type,
+        projectId: this.selectProject ? this.selectProject : null,
+        sendState: this.sendState
+      }, '报销凭证导出.zip', function(err) {
+        that.exportingData = false;
+        that.$message({
+              message: err,
+              type: "error"
+            });
+      }, function() {
+        console.log('55555555555')
+        that.exportingData = false;
+      })
     },
     // 单据发放
     documentIssuance(type) {