Browse Source

点击事件

YaolongHan 6 years ago
parent
commit
44c5c849be

+ 0 - 1
src/assets/graphy/SGraphy/mainScene.js

@@ -130,7 +130,6 @@ var mainScene = /** @class */ (function (_super) {
     // 鼠标交互类事件
     // 点击
     mainScene.prototype.click = function (_this, fn) {
-        console.log('xxxxxxxxxxx', fn);
         this.root.children.forEach(function (item) {
             item.connect("click", _this, fn);
         });

+ 4 - 1
src/assets/graphy/SGraphy/newItems/SGraphyPolygonItem.js

@@ -40,6 +40,9 @@ var SGraphyPolygonItem = /** @class */ (function (_super) {
         _this.color = SColor.Black;
         _this.width = 100;
         _this.isBusiness = 1;
+        _this.cacheColor = SColor.Black; //需要缓存的边框
+        _this.cacheFillColor = SColor.White; //需要缓存的填充色
+        _this.cacheWidth = 100;
         // 修改绘制路径格式
         var newSpacePaths = PolygonItemData.space.Paths[0].map(function (item) {
             return new SPoint(item.X, -item.Y);
@@ -50,7 +53,7 @@ var SGraphyPolygonItem = /** @class */ (function (_super) {
         // 边框色
         PolygonItemData.color ? _this.color = PolygonItemData.color : _this.color = SColor.Black;
         //边框宽度
-        PolygonItemData.width ? _this.width = PolygonItemData.width : _this.width = _this.scale * 100;
+        PolygonItemData.width ? _this.width = PolygonItemData.width : _this.width = 100;
         //中心点
         _this.centerOfGravityPoint = {
             x: PolygonItemData.space.LocationPoint.X,

+ 4 - 1
src/assets/graphy/SGraphy/newItems/SGraphyPolygonItem.ts

@@ -17,6 +17,9 @@ export class SGraphyPolygonItem extends SGraphyItem {
 	centerOfGravityPoint: { x: number, y: number };
 	businessName: null | string | undefined;
 	isBusiness: number = 1;
+	cacheColor:SColor= SColor.Black             //需要缓存的边框
+	cacheFillColor:SColor = SColor.White        //需要缓存的填充色
+	cacheWidth:number = 100;
 	// actived: boolean = false; 				//是否激活
 	/**
 	 * 构造函数
@@ -43,7 +46,7 @@ export class SGraphyPolygonItem extends SGraphyItem {
 		// 边框色
 		PolygonItemData.color ? this.color = PolygonItemData.color : this.color = SColor.Black;
 		//边框宽度
-		PolygonItemData.width ? this.width = PolygonItemData.width : this.width = this.scale*100;
+		PolygonItemData.width ? this.width = PolygonItemData.width : this.width = 100;
 		//中心点
 		this.centerOfGravityPoint = {
 			x: PolygonItemData.space.LocationPoint.X,

+ 39 - 34
src/components/business_space/graphy/business.vue

@@ -648,8 +648,8 @@
             //点击元空间
             checkSpace(e) {
                 // let item = tools.mouseInElement(this.view, e);
-                // console.log(item)
                 let item = e ;
+                
                 let items = this.mainScene.root.children;
                 //点击业务空间
                 if (
@@ -681,12 +681,10 @@
                             i.isBusiness = 6;
                         }
                     });
-                    //测试//////////
-                    // this.idList.push({
-                    //     id: item.businessId,
-                    //     name: item.businessName || item.name
-                    // });
-                    /////////////
+                    this.idList.push({
+                        id: item.businessId,
+                        name: item.businessName || item.name
+                    });
                 }
                 //点击没有业务空间的元空间
                 if (
@@ -694,7 +692,7 @@
                     (item.isBusiness == 4 || item.isBusiness == 1) &&
                     this.type != 5
                 ) {
-                    // console.log("点击的是没有业务空间的元空间", item);
+                    console.log("点击的是没有业务空间的元空间",this.type, item);
                     if (this.type == 4) {
                         this.idList = [];
                         items.map(i => {
@@ -702,18 +700,17 @@
                                 i.isBusiness = 2;
                             } else if (i.isBusiness == 3) {
                                 i.isBusiness = 1;
+                                console.log(i)
                             }
                         });
                         // console.log("清空", this.idList);
                     }
                     this.type = 3;
                     item.isBusiness = 3;
-                    //////////测试
-                    // this.idList.push({
-                    //     id: item.id,
-                    //     name: item.businessName || item.name
-                    // });
-                    /////////////////
+                    this.idList.push({
+                        id: item.id,
+                        name: item.businessName || item.name
+                    });
                 }
                 //在重新编辑业务空间状态
                 if (
@@ -722,10 +719,10 @@
                     (item.isBusiness == 4 || item.isBusiness == 1)
                 ) {
                     item.isBusiness = 3;
-                    // this.idList.push({
-                    //     id: item.id,
-                    //     name: item.businessName || item.name
-                    // });
+                    this.idList.push({
+                        id: item.id,
+                        name: item.businessName || item.name
+                    });
                 }
                 //在重新编辑时的提示
                 if (
@@ -734,19 +731,19 @@
                 ) {
                     // console.log("44444");
                     item.isBusiness = 3;
-                    // this.idList.push({
-                    //     id: item.id,
-                    //     name: item.businessName || item.name,
-                    //     parentId: item.businessId
-                    // });
+                    this.idList.push({
+                        id: item.id,
+                        name: item.businessName || item.name,
+                        parentId: item.businessId
+                    });
                 }
                 if (item.isBusiness == 5) {
                     this.$message("该空间为业务空间,请勿点击");
                 };
                 // 点击之后对所有色块重新着色
                 items.forEach((a)=>{
-                   this.isBusinessToColor(item)
-                })
+                   this.isBusinessToColor(a)
+                });
             },
             //isbusiness转换相应的颜色
             /**
@@ -754,28 +751,34 @@
              */
             isBusinessToColor(item){
                 if (item.isBusiness == 1) {
-                    item.color = item.color || new SColor('#000');
-                } else if (this.isBusiness == 2) {
+                    item.color =  item.cacheColor || new SColor('#000');
+                    item.fillColor = SColor.White;
+                    item.width = item.cacheWidth;
+                } else if (item.isBusiness == 2) {
                     //已有id 的业务空间
-                    item.color = item.color || new SColor('#000');
-                    item.fillColor = item.fillColor || new SColor('#fff')
-                } else if (this.isBusiness == 3) {
+                    item.color = item.cacheColor || new SColor('#000');
+                    item.fillColor =item.cacheFillColor || new SColor('#fff');
+                    item.width = item.cacheWidth;
+                } else if (item.isBusiness == 3) {
                     //被选择的元空间
-                    item.color = item.color || new SColor('#000');
+                    item.color = item.cacheColor|| new SColor('#000');
                     item.width = 800;
                     item.fillColor =new SColor('#1abc9c')
                 } else if (item.isBusiness == 4) {
                     item.color =  new SColor(251,226,1,.8) || new SColor('#000');
-                    item.fillColor = item.fillColor || new SColor('#fff');
+                    item.fillColor = item.cacheFillColor || new SColor('#fff');
+                     item.width = item.cacheWidth;
                 } else if (item.isBusiness == 5) {
+                    item.width = item.cacheWidth;
                     item.fillColor = new SColor(11,12,12,.2) || new SColor('#fff')
                 } else if (item.isBusiness == 6) {
                     item.color = new SColor(68,161,140,.4) || new SColor('#000');
                     item.width = 800;
                     item.fillColor =new SColor('#1abc9c');
                 } else if (item.isBusiness == 7) {
-                    item.color = item.color || new SColor('#000')
-                    item.fillColor = item.fillColor || new SColor('#fff')
+                    item.width = item.cacheWidth;
+                    item.color = item.cacheColor || new SColor('#000');
+                    item.fillColor = item.cacheFillColor || new SColor('#fff');
                 }
             },
             /**  搜索 ------------------------------------------------------------------------------ */
@@ -896,6 +899,8 @@
                                     canvas.businessId = item.id;
                                     canvas.businessName = item.name;
                                     canvas.fillColor = new SColor(colorArr[index % 10]);
+                                    canvas.cacheFillColor = canvas.fillColor;
+                                    canvas.cacheColor = canvas.color;
                                     canvas.isBusiness = 2;
                                     //判断相邻代码
                                     if (!item.isAbut) {