LXXXY 5 роки тому
батько
коміт
25984a2749
1 змінених файлів з 53 додано та 57 видалено
  1. 53 57
      src/components/point/report/objectInstance.vue

+ 53 - 57
src/components/point/report/objectInstance.vue

@@ -81,37 +81,17 @@ export default {
                   let param = {
                     Filters: `FloorId='${res1.Content[0].FloorId}'`
                   }
-                  //获取楼层信息
-                  getFloorMsgByFloorID(param, res2 => {
-                    //刷新canvas
-                    that.refreshCanvas = new Date().getTime();
-                    if (!that.views[key]) {
-                      that.views[key] = new SGraphyView(`${that.forms[key].instanceId}`)
-                    }
-                    that.views[key].scene = null;
-                    that.scenes[key] = null;
-                    that.scenes[key] = new LocationPointScene();
-                    if (res2.Content[0].StructureInfo && res2.Content[0].StructureInfo.FloorMap) {
-                      //获取数据,并加载canvas
-                      that.scenes[key].loadUrl(`/image-service/common/file_get?systemId=revit&key=${res2.Content[0].StructureInfo.FloorMap}`).then(() => {
-                        that.forms[key].loading = false;
-                        that.views[key].scene = that.scenes[key];
-                        that.scenes[key].isSpaceSelectable = false;
-                        let canvasOption = {
-                          /** 标记的id  */
-                          Id: res1.Content[0].EquipID,
-                          /** 标记的名称  */
-                          Name: res1.Content[0].EquipName,
-                          /** X坐标 */
-                          X: res1.Content[0].LocationJson.X,
-                          /** Y坐标 */
-                          Y: -res1.Content[0].LocationJson.Y
-                        }
-                        that.scenes[key].addMarker(canvasOption);
-                        that.views[key].fitSceneToView();
-                      })
-                    }
-                  });
+                  let canvasOption = {
+                    /** 标记的id  */
+                    Id: res1.Content[0].EquipID,
+                    /** 标记的名称  */
+                    Name: res1.Content[0].EquipName,
+                    /** X坐标 */
+                    X: res1.Content[0].LocationJson.X,
+                    /** Y坐标 */
+                    Y: -res1.Content[0].LocationJson.Y
+                  }
+                  this.loadDataToInstanceByFloorID(param, key, item.TypeCode, canvasOption);
                 }
               })
             }
@@ -129,32 +109,13 @@ export default {
                   let param = {
                     Filters: `FloorId='${res1.Content[0].FloorId}'`
                   }
-                  //获取楼层信息
-                  getFloorMsgByFloorID(param, res2 => {
-                    that.refreshCanvas = new Date().getTime();
-                    if (!that.views[key]) {
-                      that.views[key] = new SGraphyView(`${that.forms[key].instanceId}`)
-                    }
-                    that.views[key].scene = null;
-                    that.scenes[key] = null;
-                    that.scenes[key] = new DivideFloorScene();
-                    if (res2.Content[0].StructureInfo && res2.Content[0].StructureInfo.FloorMap) {
-                      //获取数据并加载canvas
-                      that.scenes[key].loadUrl(`/image-service/common/file_get?systemId=revit&key=${res2.Content[0].StructureInfo.FloorMap}`).then(() => {
-                        that.forms[key].loading = false;
-                        that.views[key].scene = that.scenes[key];
-                        that.scenes[key].isSpaceSelectable = false;
-                        let canvasOption = {
-                          RoomLocalName: res1.Content[0].RoomLocalName,
-                          OutLine: res1.Content[0].Outline,
-                          RoomID: res1.Content[0].RoomID,
-                          Color: new SColor('#F9C3C3')
-                        }
-                        that.scenes[key].addZone(canvasOption);
-                        that.views[key].fitSceneToView();
-                      })
-                    }
-                  });
+                  let canvasOption = {
+                    RoomLocalName: res1.Content[0].RoomLocalName,
+                    OutLine: res1.Content[0].Outline,
+                    RoomID: res1.Content[0].RoomID,
+                    Color: new SColor('#F9C3C3')
+                  }
+                  this.loadDataToInstanceByFloorID(param, key, item.TypeCode, canvasOption);
                 }
                 else {
                   this.drawCanvas = false;
@@ -170,6 +131,41 @@ export default {
           }
         });
       })
+    },
+    //通过floorid获取信息,后通过floormap获取数据后绘制canvas
+    loadDataToInstanceByFloorID(param, key, typecode, options) {
+      let that = this;
+      //获取楼层信息
+      getFloorMsgByFloorID(param, res2 => {
+        //刷新canvas
+        that.refreshCanvas = new Date().getTime();
+        if (!that.views[key]) {
+          that.views[key] = new SGraphyView(`${that.forms[key].instanceId}`)
+        }
+        that.views[key].scene = null;
+        that.scenes[key] = null;
+        //类型
+        if (typecode == 'Eq' || typecode == 'Ec')
+          that.scenes[key] = new LocationPointScene();
+        else if (typecode == 'Sp')
+          that.scenes[key] = new DivideFloorScene();
+        else
+          that.scenes[key] = null;
+        if (res2.Content[0].StructureInfo && res2.Content[0].StructureInfo.FloorMap) {
+          //获取数据,并加载canvas
+          that.scenes[key].loadUrl(`/image-service/common/file_get?systemId=revit&key=${res2.Content[0].StructureInfo.FloorMap}`).then(() => {
+            that.views[key].scene = that.scenes[key];
+            that.scenes[key].isSpaceSelectable = false;
+            if (typecode == 'Eq' || typecode == 'Ec')
+              that.scenes[key].addMarker(options);
+            else if (typecode == 'Sp')
+              that.scenes[key].addZone(options);
+            else
+              ;
+            that.views[key].fitSceneToView();
+          })
+        }
+      });
     }
   },
   mounted() {