Przeglądaj źródła

报错加载状态修改

duy 2 tygodni temu
rodzic
commit
1ee6a568b1
1 zmienionych plików z 25 dodań i 28 usunięć
  1. 25 28
      src/views/exctab/excelmodel/excelmodel.vue

+ 25 - 28
src/views/exctab/excelmodel/excelmodel.vue

@@ -116,7 +116,7 @@
                <el-link v-if="from.templateExtension" class="marleft10 colorblue" @click="delectExcelMSModel">删除</el-link>
               <el-link v-if="from.templateExtension" underline class="marleft10 colorblue"
                 style="text-decoration:underline;" @click="downloadExcelModel()">下载模板</el-link>
-               <el-button type="success" size="mini" @click="saveExcelInfo" :loading="saveExcelJsonLoad">保存数据</el-button>
+               <el-button type="success" size="mini" @click="saveExcelInfo" :loading="saveExcelJsonLoad" style="margin-left: 5px;">保存数据</el-button>
              </div>
               </div>
            
@@ -1128,34 +1128,31 @@ s
       }
     },
     //保存表格数据
-  async  saveExcelInfo(){
-    this.saveExcelJsonLoad = true;
-    const saveData= await  this.$refs.luckySheet.getData()
-
-       const { data: res } = await saveExcelJson(
-        {
-          key: this.from.id,
-          jsonExcel: JSON.stringify(saveData)
-         
-        })
-            this.saveExcelJsonLoad = false;
-      if (res.code == 200) {
-     this.saveExcelJsonLoad = false;
-        this.$message({
-          message: '保存成功',
-          type: 'success'
-        })
-      
-        
-        
-      }else{
-         this.saveExcelJsonLoad = false;
-        this.$message.error(res.msg)
-        this.getInitialData()
-       
-      }
-
+async saveExcelInfo() {
+  this.saveExcelJsonLoad = true; // 开始加载
+  try {
+    const saveData = await this.$refs.luckySheet.getData();
+    const { data: res } = await saveExcelJson({
+      key: this.from.id,
+      jsonExcel: JSON.stringify(saveData)
+    });
+    
+    if (res.code === 200) {
+      this.$message({
+        message: '保存成功',
+        type: 'success'
+      });
+    } else {
+      this.$message.error(res.msg);
+      this.getInitialData();
     }
+  } catch (error) {
+
+  } finally {
+    // 无论成功还是失败,最终都会执行这里
+    this.saveExcelJsonLoad = false;
+  }
+}
   },
   created() {
     this.excelType()//清表类型