Эх сурвалжийг харах

三亚三维规划中数据模型查看问题解决

lkk 3 сар өмнө
parent
commit
5145350089

+ 85 - 30
src/views/ConstructionApplication3D/projectManagement/projectManagement.vue

@@ -1019,41 +1019,96 @@ export default {
       //打开新项目图层
     },
 
-    //选中报建模型
-    SelectConstructionModelHendle(Minfo) {
-      if (this.WaitingSelectionModel != Minfo) {
+    // //选中报建模型
+    // SelectConstructionModelHendle(Minfo) {
+    //   if (this.WaitingSelectionModel != Minfo) {
+    //     this.removeModel();
+    //     this.WaitingSelectionModel = null;
+    //     this.removeAll();
+
+    //     var wshData = this.wsh.find((c) => c.id == Minfo.projectinformationid);
+    //     if (wshData && wshData.meetingprogress != "1") {
+    //       // 清除其他选定样式
+    //       for (let key in this.$refs) {
+    //         if (key.indexOf("Model") !== -1) {
+    //           let item = this.$refs[key][0];
+    //           if (item) {
+    //             item.childNodes.forEach((Citem) => {
+    //               if (
+    //                 Citem.className &&
+    //                 Citem.className.indexOf("status ce") !== -1
+    //               ) {
+    //                 Citem.style.display = "none";
+    //               }
+    //             });
+    //           }
+    //         }
+    //       }
+    //       // 添加当前选定样式及待选模型
+    //       this.$refs["Model" + Minfo.id][0].childNodes.forEach((item) => {
+    //         if (item.className && item.className.indexOf("status ce") !== -1) {
+    //           item.style.display = "block";
+    //         }
+    //       });
+    //     }
+    //     this.WaitingSelectionModel = Minfo;
+    //     //添加模型
+    //     this.addModel(Minfo);
+    //   }
+    // },
+        // 修改SelectConstructionModelHendle方法
+        SelectConstructionModelHendle(Minfo) {
+      // 如果点击的是已选中的模型,则取消选择
+      if (this.WaitingSelectionModel === Minfo) {
         this.removeModel();
+        this.clearSelectionStyle(Minfo);
         this.WaitingSelectionModel = null;
-        this.removeAll();
-
-        var wshData = this.wsh.find((c) => c.id == Minfo.projectinformationid);
-        if (wshData && wshData.meetingprogress != "1") {
-          // 清除其他选定样式
-          for (let key in this.$refs) {
-            if (key.indexOf("Model") !== -1) {
-              let item = this.$refs[key][0];
-              if (item) {
-                item.childNodes.forEach((Citem) => {
-                  if (
-                    Citem.className &&
-                    Citem.className.indexOf("status ce") !== -1
-                  ) {
-                    Citem.style.display = "none";
-                  }
-                });
-              }
+        return;
+      }
+
+      // 否则处理新选择
+      this.removeModel();
+      this.removeAll();
+      this.WaitingSelectionModel = null;
+
+      var wshData = this.wsh.find((c) => c.id == Minfo.projectinformationid);
+      if (wshData && wshData.meetingprogress != "1") {
+        // 清除其他选定样式
+        for (let key in this.$refs) {
+          if (key.indexOf("Model") !== -1) {
+            let item = this.$refs[key][0];
+            if (item) {
+              item.childNodes.forEach((Citem) => {
+                if (
+                  Citem.className &&
+                  Citem.className.indexOf("status ce") !== -1
+                ) {
+                  Citem.style.display = "none";
+                }
+              });
             }
           }
-          // 添加当前选定样式及待选模型
-          this.$refs["Model" + Minfo.id][0].childNodes.forEach((item) => {
-            if (item.className && item.className.indexOf("status ce") !== -1) {
-              item.style.display = "block";
-            }
-          });
         }
-        this.WaitingSelectionModel = Minfo;
-        //添加模型
-        this.addModel(Minfo);
+        // 添加当前选定样式
+        this.$refs["Model" + Minfo.id][0].childNodes.forEach((item) => {
+          if (item.className && item.className.indexOf("status ce") !== -1) {
+            item.style.display = "block";
+          }
+        });
+      }
+
+      this.WaitingSelectionModel = Minfo;
+      this.addModel(Minfo);
+    },
+
+    // 新增清除样式方法
+    clearSelectionStyle(Minfo) {
+      if (this.$refs["Model" + Minfo.id] && this.$refs["Model" + Minfo.id][0]) {
+        this.$refs["Model" + Minfo.id][0].childNodes.forEach((item) => {
+          if (item.className && item.className.indexOf("status ce") !== -1) {
+            item.style.display = "none";
+          }
+        });
       }
     },
     //添加项目模型