zhaoyk 3 роки тому
батько
коміт
45d769d389

+ 33 - 15
adm_comp/src/lib/TemplateEditor.ts

@@ -82,13 +82,21 @@ export class TemplateEditor extends Editor {
 				let color = "#5783FA";
 				if(item.bindEquipment)
 					color = "#000000";
-				this.ctx.strokeStyle = color; //#FA943B
-				this.ctx.setLineDash([]);
-				if(this.getSelComp() == item)
-					this.ctx.lineWidth = 2;
-				else
-					this.ctx.lineWidth = 1;
+				let lw = 1;
+				let ld = [];
+				
+				if(this.getSelComp() == item) { //选中状态
+					lw = 2;
+					if(this.tmpMainPipe) { //重新绘制该干管
+						ld = [5, 5];
+						color = '#ff5500';
+					}
+				}
 					
+				this.ctx.strokeStyle = color;
+				this.ctx.lineWidth = lw;
+				this.ctx.setLineDash(ld);
+				
 				this.ctx.beginPath();
 				for(const arr of item.locationPath){
 					var iter = 0;
@@ -360,20 +368,30 @@ export class TemplateEditor extends Editor {
 			//显示当前坐标位置
 			this.editorPart.dynInfo = ViewTool.pointToStr(point);
 			
+			//重新绘制时,需要考虑关联容器
+			let relatedCons: Array<string>;
+			const sel = this.getSelComp();
+			if(sel.compType == 'mainPipe')
+				relatedCons = (<MainPipe>sel).relatedContainers;
+			if(relatedCons && relatedCons.length == 0)
+				relatedCons = null;
+			
 			//计算定位参考点
 			var min: number = Number.MAX_VALUE;
 			var nearRp: any;
 			for(const cId in this.refPoints) {
-				const rps = this.refPoints[cId];
-				if(rps && rps.length) {
-					for(const rp of rps){
-						const p1 = rp.location;
-						const distance = Math.sqrt(Math.pow(p1.x - point.x, 2) + Math.pow(p1.y - point.y, 2));
-						if(distance < min) {
-							min = distance;
-							nearRp = rp;
+				if(!relatedCons || relatedCons.indexOf(cId) >= 0){
+					const rps = this.refPoints[cId];
+					if(rps && rps.length) {
+						for(const rp of rps){
+							const p1 = rp.location;
+							const distance = Math.sqrt(Math.pow(p1.x - point.x, 2) + Math.pow(p1.y - point.y, 2));
+							if(distance < min) {
+								min = distance;
+								nearRp = rp;
+							}
 						}
-					}
+					}	
 				}
 			}
 			this.currentRefPoint = nearRp;

+ 3 - 0
adm_comp/src/views/DiagramTemplate.vue

@@ -954,6 +954,9 @@
 			});
 
 			const params:any = {lines: lines, templateId: this.currentTemplate.id};
+			const sel = this.editor.getSelComp();
+			if(sel.compType == 'mainPipe')
+				params.currentCompId = sel.id;
 			this.callAction('drawMainPipe', params);
 		}