浏览代码

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

guolei 1 年之前
父节点
当前提交
187bbd29a2
共有 1 个文件被更改,包括 17 次插入3 次删除
  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);