Sfoglia il codice sorgente

已选择结束点和开始点添加判空逻辑

guolei 1 anno fa
parent
commit
187bbd29a2
1 ha cambiato i file con 17 aggiunte e 3 eliminazioni
  1. 17 3
      src/views/workManagement/components/pathDialog.vue

+ 17 - 3
src/views/workManagement/components/pathDialog.vue

@@ -119,8 +119,14 @@
 
 			},
 			switchStartPoint(newVal) {
-				console.log(this.selectTrack)
-				let pointNames = this.dataParams.selectedPoints[this.selectTrack.id]["start"];
+				let currentSelectPath = this.dataParams.selectedPoints[this.selectTrack.id];
+				if(!currentSelectPath){
+					currentSelectPath = {
+						'start':[],
+						'end':[]
+					};
+				}
+				let pointNames = currentSelectPath["start"];
 				let searchIndex = pointNames.indexOf(this.preStartPointName);
 				if (searchIndex != -1) {
 					pointNames.splice(searchIndex, 1);
@@ -130,7 +136,15 @@
 				this.changeMap();
 			},
 			switchEndPoint(newVal) {
-				let pointNames = this.dataParams.selectedPoints[this.selectTrack.id]["end"];
+				let currentSelectPath = this.dataParams.selectedPoints[this.selectTrack.id];
+				if(!currentSelectPath){
+					currentSelectPath = {
+						'start':[],
+						'end':[]
+					};
+				}
+				let pointNames = currentSelectPath["end"];
+				
 				let searchIndex = pointNames.indexOf(this.preEndPointName);
 				if (searchIndex != -1) {
 					pointNames.splice(searchIndex, 1);