Browse Source

fix(exctab): 修复创建元素的功能

duy 1 ngày trước cách đây
mục cha
commit
299d2077e9
1 tập tin đã thay đổi với 36 bổ sung24 xóa
  1. 36 24
      src/views/exctab/ElementIdentification/index.vue

+ 36 - 24
src/views/exctab/ElementIdentification/index.vue

@@ -102,6 +102,7 @@
                         >关联WBS并创建元素</el-button
                       >
                       <el-button
+                      :loading="elloading"
                         type="success"
                         size="mini"
                         @click="addtoElement()"
@@ -1148,13 +1149,13 @@ export default {
     
             if (
             this.clickData.name &&
-            this.clickData.tableType &&
+            this.clickData.tabType &&
             this.clickData.tableOwner
           ) {
        
             this.submitExcelRelationWbsTreeAndElement({
               nodeName: this.clickData.nodeName,
-              tableType: this.clickData.tableType,
+              tableType: this.clickData.tabType,
               tableOwner: this.clickData.tableOwner,
               elementList: this.tableData,
               excelTabId: this.from.id,
@@ -1416,29 +1417,40 @@ export default {
       }
       this.activeName="link"
     },
-    async submitExcelRelationWbsTreeAndElement(da) {
-      //保存接口
-      da.elementList.forEach((ele) => {
-        ele.eName = ele.textInfo;
-        ele.eType = ele.textElementType;
-        ele.eAllowDeviation = ele.textDeviation;
+   async submitExcelRelationWbsTreeAndElement(da) {
+  try {
+    // 预处理数据
+    da.elementList.forEach((ele) => {
+      ele.eName = ele.textInfo;
+      ele.eType = ele.textElementType;
+      ele.eAllowDeviation = ele.textDeviation;
+    });
+
+    this.elloading = true; // 开始加载
+    const { data: res } = await submitExcelRelationWbsTreeAndElement(da);
+    console.log(res);
+
+    if (res.code === 200) {
+      this.$message({
+        type: "success",
+        message: "设置成功",
       });
-      const { data: res } = await submitExcelRelationWbsTreeAndElement(da);
-      console.log(res);
-       this.elloading=false
-      if (res.code == 200) {
-      // this.refreshNodeBy()//刷新树形控件数据
-
-        this.$message({
-          type: "success",
-          message: "设置成功",
-        });
-        this.AssociatedPublicTap = false;
-        this.AssociatedPublicClose();
-         this.eleDialog=false;
-
-      }
-    },
+      this.AssociatedPublicTap = false;
+      this.AssociatedPublicClose();
+      this.eleDialog = false;
+    } else {
+      this.$message({
+        type: "error",
+        message: "请求失败:" + (res.message || "未知错误"),
+      });
+    }
+  } catch (error) {
+    console.error("请求异常:", error);
+  
+  } finally {
+    this.elloading = false; // 无论成功或失败,最终都关闭加载状态
+  }
+},
     //#endregion
    // tree局部刷新
     refreshNodeBy(){