Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/views/maintain/space/index.vue
shaun-sheep 4 gadi atpakaļ
vecāks
revīzija
2df59df321

+ 41 - 9
src/utils/graph/FloorScene.ts

@@ -14,7 +14,9 @@ import { VirtualWall } from "@persagy-web/big/lib/types/floor/VirtualWall";
 import { Wall } from "@persagy-web/big/lib/types/floor/Wall";
 import { Zone } from "@persagy-web/big/lib/types/floor/Zone";
 import { FloorData } from "@persagy-web/big/lib/types/FloorData";
-import { SGraphScene } from "@persagy-web/graph/lib";
+import { SColor } from "@persagy-web/draw/lib";
+import { SGraphItem, SGraphScene } from "@persagy-web/graph/lib";
+import zoneColor from "./config/zoneColor";
 
 /**
  * 楼层平面图
@@ -55,7 +57,7 @@ export class FloorScene extends SGraphScene {
         );
     } // Set isSpaceSelectable
 
-    /** 空间是否可选  */
+    /** 业务空间是否可选  */
     _isZoneSelectable: boolean = true;
     get isZoneSelectable(): boolean {
         return this._isZoneSelectable;
@@ -66,8 +68,13 @@ export class FloorScene extends SGraphScene {
         }
         this._isZoneSelectable = v;
         this.zoneList.map(
-            (t: SZoneItem): SZoneItem => {
+            (t: SZoneItem, i: number): SZoneItem => {
                 t.selectable = this._isZoneSelectable;
+                if (v) {
+                    t.fillColor = new SColor(zoneColor[i % zoneColor.length]);
+                } else {
+                    t.fillColor = ItemColor.zoneUnselectColor;
+                }
                 return t;
             }
         );
@@ -209,8 +216,8 @@ export class FloorScene extends SGraphScene {
      *  @param  zone   业务空间list
      */
     addZoneList(zone: Zone[]): void {
-        zone.forEach((t): void => {
-            this.addZone(t);
+        zone.forEach((t, i): void => {
+            this.addZone(t, i);
         });
     } // Function addZoneList()
 
@@ -219,9 +226,10 @@ export class FloorScene extends SGraphScene {
      *
      *  @param  zone   业务空间
      */
-    addZone(zone: Zone): void {
+    addZone(zone: Zone, i: number): void {
         let item = new SZoneItem(null, zone);
         item.selectable = this.isZoneSelectable;
+        item.fillColor = new SColor(zoneColor[i % zoneColor.length])
         this.zoneList.push(item);
         this.addItem(item);
     } // Function addZone()
@@ -229,7 +237,31 @@ export class FloorScene extends SGraphScene {
     /**
      * 选择器触发事件
     */
-   listChange() {
-       console.log(arguments);       
-   }
+    listChange(item: SGraphItem, data: SGraphItem[]): void {
+        this.changeSelect(item, data)
+    }
+    changeSelect(item: SGraphItem, data: SGraphItem[]): void { }
+
+    /**
+     * 初始化空间颜色
+    */
+    initSpaceColor(): void {
+        this.spaceList.forEach(
+            (t: SSpaceItem) => {
+                t.fillColor = ItemColor.spaceColor;
+            }
+        );
+    }
+
+    /**
+      * 初始化业务空间颜色
+     */
+    initZoneColor(): void {
+        this.zoneList.forEach(
+            (t: SZoneItem, i: number) => {
+                t.fillColor = new SColor(zoneColor[i % zoneColor.length]);
+            }
+        );
+    }
+
 }

+ 11 - 0
src/utils/graph/config/zoneColor.ts

@@ -0,0 +1,11 @@
+const colorArr = [
+  "#fed44c",
+  "#3485d6",
+  "#a384fc",
+  "#4caf50",
+  "#ff6316",
+  "#fd8bbe",
+  "#03a9f3",
+  "#ea615b"
+];
+export default colorArr;

+ 12 - 2
src/views/maintain/space/components/spaceGraph.vue

@@ -148,12 +148,17 @@ export default class spaceGraph extends Vue {
             this.$message.warning("数据解析异常");
             return;
         }
-        this.view?.fitSceneToView();
-        this.view!.minScale = this.view!.scale;
+        if (this.view) {
+            this.view.fitSceneToView();
+            this.view.minScale = this.view.scale;
+        }
         if (this.$refs.canvasFun) {
             // @ts-ignore
             this.$refs.canvasFun.everyScale = this.view.scale;
         }
+        if (this.scene) {
+            this.scene.changeSelect = this.changeSelect;
+        }
     }
     // 清除canvas
     clearGraphy() {
@@ -232,6 +237,11 @@ export default class spaceGraph extends Vue {
 
     groupCreateZone() {}
 
+    //
+    changeSelect() {
+        console.log(arguments);
+    }
+
     // 适配底图到窗口
     fit() {
         this.view?.fitSceneToView();