zhaoyk 2 anni fa
parent
commit
6994b17871

+ 25 - 8
adm_comp/src/lib/TemplateEditor.ts

@@ -44,10 +44,13 @@ export class TemplateEditor extends Editor {
 	setState(state: number): void{
 		this.state = state;
 		
-		if(this.state == 9) 
+		if(this.state == 9) {
+			this.canvas.style.cursor = "crosshair";
 			this.tmpMainPipe = new Array<Array<Point>>();
-		else
+		} else {
+			this.canvas.style.cursor = "auto";
 			this.tmpMainPipe = null;
+		}
 		
 		this.currentTmpMainPipe = null;	
 		this.currentRefPoint = null;
@@ -364,18 +367,32 @@ export class TemplateEditor extends Editor {
 			this.editorPart.dynInfo = ViewTool.pointToStr(point);
 			
 			//重新绘制时,需要考虑关联容器
-			let relatedCons: Array<string>;
+			let relatedConIds: Array<string>;
 			const sel = this.getSelComp();
 			if(sel && sel.compType == 'mainPipe')
-				relatedCons = (<MainPipe>sel).relatedContainers;
-			if(relatedCons && relatedCons.length == 0)
-				relatedCons = null;
+				relatedConIds = (<MainPipe>sel).relatedContainers;
+			const relCons = [];
+			if(relatedConIds && relatedConIds.length > 0){
+				relatedConIds.forEach(cId => relCons.push(Template.getContainerById(cId, this.templateData)));
+			}
 			
 			//计算定位参考点
 			var min: number = Number.MAX_VALUE;
 			var nearRp: any;
 			for(const cId in this.refPoints) {
-				if(!relatedCons || relatedCons.indexOf(cId) >= 0){
+				let flag = false;
+				if(relCons.length == 0)
+					flag = true;
+				else {
+					const con = Template.getContainerById(cId, this.templateData);
+					for(const rc of relCons) {
+						if(rc == con || Container.isParentOf(rc, con)){
+							flag = true;
+							break;
+						}
+					}
+				}
+				if(flag) {
 					const rps = this.refPoints[cId];
 					if(rps && rps.length) {
 						for(const rp of rps){
@@ -386,7 +403,7 @@ export class TemplateEditor extends Editor {
 								nearRp = rp;
 							}
 						}
-					}	
+					}		
 				}
 			}
 			this.currentRefPoint = nearRp;

+ 6 - 2
adm_comp/src/views/DiagramTemplate.vue

@@ -620,7 +620,7 @@
 						confirmButtonText: '确定',
 						cancelButtonText: '取消',
 						type: 'info',
-						inputValidator: val => {return val != null && this.checkId(val)}
+						inputValidator: val => {return this.checkId(val)}
 			       }).then(instance => {
 						const params:any = {newCompId: instance['value'], currentCompId:this.editor.getSelComp().id, templateId: this.currentTemplate.id};
 						this.propsData = {id: params.newCompId}; //方便后续选中操作
@@ -632,6 +632,10 @@
 		
 		//检测id是否冲突
 		checkId(id:string):boolean {
+			if(this['$common'].isEmpty(id))
+				return false;
+			if(id.indexOf(':') >= 0)
+				return false;
 			return Template.getElById(id, this.currentTemplate) == null;
 		}
 		
@@ -736,7 +740,7 @@
 			if(this.propsData.id != this.propsData.id0 && !this.checkId(this.propsData.id)) {
 				this.$message({
 					type: 'warning',
-					message: 'id冲突!'
+					message: 'id不合法或与其他id冲突!'
 				});
 				return;
 			}