Browse Source

modify canvas showtype

haojianlong 5 years ago
parent
commit
ba95bf09d5

+ 0 - 2
src/views/ready/buildfloor/drawGraphy/bus.js

@@ -1,2 +0,0 @@
-import Vue from 'Vue';
-export default new Vue()

+ 2 - 2
src/views/ready/buildfloor/drawGraphy/checkGraphy.vue

@@ -9,7 +9,7 @@
       </div>
       <!-- 展示框 -->
       <div class="showBox">
-        <drawFloor ref="drawFloorDialog" :showTools="false" :id="0"></drawFloor>
+        <drawFloor ref="drawFloorDialog" :showTools="false" :id="0" :dialog="true"></drawFloor>
       </div>
     </div>
     <span slot="footer" class="dialog-footer">
@@ -71,7 +71,7 @@ export default {
     },
     // 点击多级联动
     handleChange(val) {
-      this.$refs.drawFloorDialog.initGraphy(val[1])
+      this.$refs.drawFloorDialog.initGraphy(val[1], 1)
       this.jsonKey = val[1]
     },
     // 通过id查询文件夹下模型文件

+ 54 - 36
src/views/ready/buildfloor/drawGraphy/drawFloor.vue

@@ -9,7 +9,6 @@
 </template>
 
 <script>
-import eventBus from "./bus.js";
 import { SGraphyView } from "@saga-web/graphy/lib";
 import { DivideFloorScene } from "@saga-web/cad-engine/lib"
 import { SColor, SPoint } from "@saga-web/draw/lib";
@@ -30,6 +29,7 @@ export default {
       modelId: '',
       FloorID: '',
       Outline: [],
+      floorData: {}
     };
   },
   props: {
@@ -41,61 +41,79 @@ export default {
     },
     id: {
       default: 0
+    },
+    dialog: {
+      default: false
     }
   },
   created() {
     this.FloorID = this.$route.query.FloorID;
-    this.OutlineFlag = this.$route.query.OutlineFlag;
+    if (!this.dialog) {
+      this.getFloorData();
+    }
   },
   mounted() {
     this.cadWidth = document.getElementById(`drawFloor${this.id}`).offsetWidth;
     this.cadHeight = document.getElementById(`drawFloor${this.id}`).offsetHeight;
   },
   methods: {
-    initGraphy(ModelId) {
+    // 初始化canvas
+    initGraphy(Id, type) {
+      // type=1 => id:模型id
+      // type=2 => id:floormap
       let that = this;
-      that.modelId = ModelId;
+      that.modelId = Id;
       that.clearGraphy()
       that.drawMainScene = new DivideFloorScene();
       that.canvasLoading = true;
-      that.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: ModelId }).then(res => {
-        that.canvasLoading = false;
-        if (res.Result == 'failure') {
-          that.showTools = false;
-          that.$message.warning(res.Message);
-          return;
-        }
-        let Elements = res.EntityList[0].Elements;
-        let flag = false;
-        for (let key in Elements) {
-          if (Elements[key].length > 0) {
-            flag = true;
-          }
-        }
-        if (flag) {
-          that.view.scene = that.drawMainScene
-          that.view.fitSceneToView();
-          that.drawMainScene.isSpaceSelectable = false;
-          if (that.$refs.canvasFun) {
-            that.view.maxScale = that.view.scale * 10;
-            that.view.minScale = that.view.scale;
-            that.$refs.canvasFun.everyScale = that.view.scale;
-          }
-          if (that.OutlineFlag) {
-            that.getFloorData()
-          }
-        }
-      })
+      if (type == 1) {
+        that.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: Id }).then(res => {
+          that.getGraphtSuc(res)
+        })
+      } else {
+        that.drawMainScene.loadUrl(`/image-service/common/file_get?systemId=revit&key=${Id}`).then(res => {
+          that.getGraphtSuc(res)
+        })
+      }
+
+    },
+    // 获取底图成功
+    getGraphtSuc(res) {
+      this.canvasLoading = false;
+      if (res == 'error') {
+        this.FloorMap = '';
+        this.$message.warning('数据解析异常');
+        return;
+      }
+      if (res.Result == 'failure') {
+        this.showTools = false;
+        this.$message.warning(res.Message);
+        return;
+      }
+      this.view.scene = this.drawMainScene;
+      this.view.fitSceneToView();
+      this.drawMainScene.isSpaceSelectable = false;
+
+      if (this.$refs.canvasFun) {
+        this.view.maxScale = this.view.scale * 10;
+        this.view.minScale = this.view.scale;
+        this.$refs.canvasFun.everyScale = this.view.scale;
+      }
+      if (this.floorData.Outline && this.floorData.Outline.length) {
+        let newArr = this.floorData.Outline.map(t => {
+          return new SPoint(t.X, t.Y);
+        })
+        this.drawMainScene.addSceneMark(newArr)
+      }
     },
+    // 获取楼层数据
     getFloorData() {
       let pa = {
         Filters: `FloorID='${this.FloorID}'`
       }
       floorQuery(pa, res => {
-        let newArr = res.Content[0].Outline.map(t => {
-          return new SPoint(t.X, t.Y);
-        })
-        this.drawMainScene.addSceneMark(newArr)
+        this.floorData = res.Content[0];
+        this.initGraphy(this.floorData.StructureInfo.FloorMap, 2)
       })
     },
     // 清空平面图

+ 1 - 4
src/views/ready/buildfloor/index.vue

@@ -43,7 +43,7 @@
                     <i class="iconfont icon-floorplan"></i>
                   </el-badge>平面图重复
                 </p>
-                <p v-else-if="scope.row.ModelId" @click="checkDrawImg(scope.row,1)">
+                <p v-else-if="scope.row.StructureInfo?scope.row.StructureInfo.FloorMap:false" @click="checkDrawImg(scope.row,1)">
                   <i class="iconfont icon-floorplan"></i>
                   查看平面图
                 </p>
@@ -239,9 +239,6 @@ export default {
       } else {
         this.modelId = row.ModelId;
         let pa = { modelId: this.modelId, FloorID: row.FloorID, BuildID: row.BuildID }
-        if (row.Outline && row.Outline.length) {
-          pa.OutlineFlag = true;
-        }
         this.$router.push({ name: "repetitionGraphy", query: pa });
       }
     }