Forráskód Böngészése

添加数据格式异常处理

haojianlong 5 éve
szülő
commit
fdf208d520
6 módosított fájl, 99 hozzáadás és 46 törlés
  1. 8 8
      package-lock.json
  2. 3 3
      package.json
  3. 14 13
      src/DivideFloorScene.ts
  4. 41 21
      src/FloorScene.ts
  5. 12 1
      src/LocationPointScene.ts
  6. 21 0
      src/index.ts

+ 8 - 8
package-lock.json

@@ -1,6 +1,6 @@
 {
-    "name": "cad-engine",
-    "version": "2.0.252",
+    "name": "@saga-web/cad-engine",
+    "version": "2.0.270",
     "lockfileVersion": 1,
     "requires": true,
     "dependencies": {
@@ -30,17 +30,17 @@
             "integrity": "sha512-V9UT6B330kOQzKeYPIizpX9fEIHOMeJ0XFUZrq8tCTUg4Nmhzp1WBSEI9XcDSLS4WYAapVQqYrQ+tuIDeUxN5g=="
         },
         "@saga-web/draw": {
-            "version": "2.1.56",
-            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/draw/-/draw-2.1.56.tgz",
-            "integrity": "sha512-OBOCmtx8vLtjc5XKxb8mNcJNwx9no660I1Q64OkazNOpdPPzZJY5eBqvQLkK5ZcWLdTVnZIXA4nh4OAdmpT3Ow==",
+            "version": "2.1.57",
+            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/draw/-/draw-2.1.57.tgz",
+            "integrity": "sha512-V3UhPKKW0KvpVo3Pou3xVmOInui+IctEGd2khEUXVEOKHuLWIk48dRTc+ZSGnqI9JlcxcoDbjL48lvWZUwrI0A==",
             "requires": {
                 "@saga-web/base": "^2.1.8"
             }
         },
         "@saga-web/graphy": {
-            "version": "2.1.27",
-            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/graphy/-/graphy-2.1.27.tgz",
-            "integrity": "sha512-L6Lv9JDCesP3NJqC4lBTYc8L4bMP3+egFIlNXuTrGthE7879TJqcS5pYbYTlg8wT8aQNJpU0cRGxcaEQJ2YDpQ==",
+            "version": "2.1.28",
+            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/graphy/-/graphy-2.1.28.tgz",
+            "integrity": "sha512-NDhg2rb0T/UPzkiYODDE/ONH/TNo8oj+rjem/wPbvab+cl4VxddZVNHU+eXyVeH3FrrEEIUbOcDFsV0pkADCvQ==",
             "requires": {
                 "@saga-web/draw": "^2.1.56"
             }

+ 3 - 3
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.268",
+    "version": "2.0.278",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -32,8 +32,8 @@
     },
     "dependencies": {
         "@saga-web/base": "2.1.8",
-        "@saga-web/draw": "2.1.56",
-        "@saga-web/graphy": "2.1.27",
+        "@saga-web/draw": "2.1.57",
+        "@saga-web/graphy": "2.1.28",
         "axios": "^0.18.0",
         "pako": "^1.0.10"
     }

+ 14 - 13
src/DivideFloorScene.ts

@@ -48,11 +48,12 @@ export class DivideFloorScene extends FloorScene {
     sceneMark: SGraphyItem | null = null;
     /** 业务空间list   */
     zoneList: ZoneItem[] = [];
+
     /** 业务空间是否可选  */
     _isZoneSelectable: boolean = true;
     get isZoneSelectable(): boolean {
         return this._isZoneSelectable;
-    } // Get isSpaceSelectable
+    } // Get isZoneSelectable
     set isZoneSelectable(v: boolean) {
         if (this._isZoneSelectable === v) {
             return;
@@ -187,26 +188,26 @@ export class DivideFloorScene extends FloorScene {
     } // Function addZone
 
     /**
-     *  设置空间是否可选
+     *  清空选中的空间
      *
      */
-    setSpaceSelectable(selectable: boolean): void {
-        this.spaceList.map(sp => {
-            sp.selectable = selectable;
-            return sp;
+    clearSpaceSelection(): void {
+        this.spaceList = this.spaceList.map(t => {
+            t.selected = false;
+            return t;
         });
-    } // Function setSpaceSelectable
+    } // Function clearSpaceSelection
 
     /**
-     *  设置业务空间是否可选
+     *  清空选中的空间
      *
      */
-    setZoneSelectable(selectable: boolean): void {
-        this.zoneList.map(zone => {
-            zone.selectable = selectable;
-            return zone;
+    clearZoneSelection(): void {
+        this.zoneList = this.zoneList.map(t => {
+            t.selected = false;
+            return t;
         });
-    } // Function setZoneSelectable
+    } // Function clearZoneSelection
 
     /**
      *  切换业务空间

+ 41 - 21
src/FloorScene.ts

@@ -195,7 +195,7 @@ export class FloorScene extends SGraphyScene {
                     this.unzip(blob)
                         .then((jsonData: any) => {
                             that.addBaseMapItem(jsonData);
-                            relove();
+                            relove(jsonData);
                         })
                         .catch((error: any) => {
                             console.log(error);
@@ -222,8 +222,16 @@ export class FloorScene extends SGraphyScene {
                 //解压数据
                 let base64Data = btoa(binaryString);
                 let unGzipData = that.unzipBase64(base64Data);
-                that.data = unGzipData.entityList[0].Elements;
-                resolve(that.data);
+                try {
+                    that.data = unGzipData.entityList
+                        ? unGzipData.entityList[0].Elements
+                        : unGzipData.EntityList[0].Elements;
+                    resolve(that.data);
+                } catch (e) {
+                    console.log(e);
+                    console.log(unGzipData);
+                    resolve("error");
+                }
             };
         });
     } // Function unzip
@@ -258,24 +266,36 @@ export class FloorScene extends SGraphyScene {
      *  @param  data    itemList对象
      */
     private addBaseMapItem(data: FloorData) {
-        data.Walls.map((t: Wall) => {
-            this.addWall(t);
-        });
-        data.Columns.map((t: Column) => {
-            this.addColumn(t);
-        });
-        data.Windows.map((t: Casement) => {
-            this.addCasement(t);
-        });
-        data.VirtualWalls.map((t: VirtualWall) => {
-            this.addVirtualWall(t);
-        });
-        data.Doors.map((t: Door) => {
-            this.addDoor(t);
-        });
-        data.Spaces.map((t: Space) => {
-            this.addSpace(t);
-        });
+        if (data.Walls) {
+            data.Walls.map((t: Wall) => {
+                this.addWall(t);
+            });
+        }
+        if (data.Columns) {
+            data.Columns.map((t: Column) => {
+                this.addColumn(t);
+            });
+        }
+        if (data.Windows) {
+            data.Windows.map((t: Casement) => {
+                this.addCasement(t);
+            });
+        }
+        if (data.VirtualWalls) {
+            data.VirtualWalls.map((t: VirtualWall) => {
+                this.addVirtualWall(t);
+            });
+        }
+        if (data.Doors) {
+            data.Doors.map((t: Door) => {
+                this.addDoor(t);
+            });
+        }
+        if (data.Spaces) {
+            data.Spaces.map((t: Space) => {
+                this.addSpace(t);
+            });
+        }
     } // Function addBaseMapItem
 
     /**

+ 12 - 1
src/LocationPointScene.ts

@@ -21,7 +21,6 @@
 import { FloorScene } from "./FloorScene";
 import { MarkerItem } from "./items/MarkItem";
 import { Marker } from "./types/Marker";
-import { SMouseEvent } from "@saga-web/base/lib";
 
 /**
  * 位置标签绘制标志
@@ -91,4 +90,16 @@ export class LocationPointScene extends FloorScene {
             m.connect("click", _this, fn);
         });
     } // Function markerClick()
+
+    /**
+     * 空间的点击事件
+     *
+     * @param   _this    接收者
+     * @param   fn       处理函数
+     */
+    spaceClick(_this: any, fn: Function) {
+        this.spaceList.map(m => {
+            m.connect("click", _this, fn);
+        });
+    } // Function spaceClick()
 } // Class LocationPointScene

+ 21 - 0
src/index.ts

@@ -1,5 +1,26 @@
 import { FloorScene } from "./FloorScene";
 import { LocationPointScene } from "./LocationPointScene";
 import { DivideFloorScene } from "./DivideFloorScene";
+import { SpaceItem } from "./items/SpaceItem";
+import { ColumnItem } from "./items/ColumnItem";
+import { DoorItem } from "./items/DoorItem";
+import { ZoneItem } from "./items/ZoneItem";
+import { WindowItem } from "./items/WindowItem";
+import { WallItem } from "./items/WallItem";
+import { VirtualWallItem } from "./items/VirtualWallItem";
+import { SceneMarkItem } from "./items/SceneMarkItem";
+import { MarkerItem } from "./items/MarkItem";
 
 export { FloorScene, LocationPointScene, DivideFloorScene };
+
+export {
+    SpaceItem,
+    ColumnItem,
+    DoorItem,
+    MarkerItem,
+    SceneMarkItem,
+    VirtualWallItem,
+    WallItem,
+    WindowItem,
+    ZoneItem
+};