Browse Source

'修改删除item错误问题'

zhangyu 4 years ago
parent
commit
1e0eea1b1c
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/components/mapClass/EditScence.ts

+ 10 - 3
src/components/mapClass/EditScence.ts

@@ -613,6 +613,7 @@ export class EditScence extends SGraphScene {
      */
     deleiteItem(): void {
         if (this.focusItem) {
+            debugger
             this.removeItem(this.focusItem);
             let a = -1
             this.Nodes.forEach((item: any, index: number) => {
@@ -620,21 +621,27 @@ export class EditScence extends SGraphScene {
                     a = index
                 }
             });
-            this.Nodes.splice(a, 1);
+            if(a > -1) {
+                this.Nodes.splice(a, 1);
+            }
             let b = -1;
             this.Markers.forEach((item: any, index: number) => {
                 if (item.id == this.focusItem.id) {
                     b = index
                 }
             });
-            this.Markers.splice(b, 1);
+            if (b > -1) {
+                this.Markers.splice(b, 1);
+            }
             let c = -1;
             this.Relations.forEach((item: any, index: number) => {
                 if (item.id == this.focusItem.id) {
                     c = index
                 }
             });
-            this.Relations.splice(c, 1);
+            if (c > -1) {
+                this.Relations.splice(c, 1);
+            }
             this.focusItem = null;
         }
         if (this.view) {