Browse Source

add buildfloor canvas

haojianlong 5 years ago
parent
commit
c23e37465a

+ 2 - 2
package.json

@@ -11,7 +11,7 @@
     },
     "dependencies": {
         "@sybotan-web/base": "2.1.2",
-        "@sybotan-web/draw": "2.1.40",
+        "@sybotan-web/draw": "2.1.47",
         "@sybotan-web/graphy": "2.1.13",
         "axios": "^0.18.0",
         "echarts": "^4.1.0",
@@ -23,7 +23,7 @@
         "vue-axios": "^2.1.4",
         "vue-router": "^3.0.1",
         "vuex": "^3.1.0",
-        "cad-engine": "2.0.193"
+        "cad-engine": "2.0.198"
     },
     "devDependencies": {
         "ajv": "^6.9.1",

+ 7 - 1
src/api/model/file.js

@@ -278,4 +278,10 @@ let api = {
     }
 
 }
-export default api
+export default api
+
+//楼层与平面图绑定
+export function bindFloorModel(param, success) {
+    let url = `${baseUrl}/model-floor/bind`;
+    httputils.postJson(url, param, success)
+}

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

@@ -1,7 +1,7 @@
 <template>
   <el-dialog id="checkGraphy" title="添加平面图" :visible.sync="checkGraphyVisible" width="900px" @close="handleClose">
     <div class="bodys">
-      <el-cascader :options="options" :show-all-levels="false" :props="props" @change="handleChange" @active-item-change='handleItemChange' clearable
+      <el-cascader :options="options" :show-all-levels="false" @change="handleChange" @active-item-change='handleItemChange' clearable
         placeholder="请选择模型文件" v-model="casVal"></el-cascader>
       <div>
@@ -22,7 +22,7 @@
 import drawFloor from "./drawFloor";
 import { mapGetters, mapActions } from "vuex";
 import request from "@/api/model/file.js";
-import { floorUpdate } from "@/api/scan/request";
+import { bindFloorModel } from "@/api/model/file";
 export default {
   components: {
     drawFloor
@@ -37,7 +37,7 @@ export default {
       checkGraphyVisible: false,
       options: [],
       floor: {}, // 当前选中的楼层数据
-      props: {}
+      modelIdToFloorId: {}
     };
   },
   methods: {
@@ -59,10 +59,9 @@ export default {
         return
       }
       let pa = {
-        Content: [{ FloorID: this.floor.FloorID, ModeId: this.jsonKey }],
-        Projection: ['ModeId']
+        Content: [{ FloorId: this.floor.FloorID, Id: this.modelIdToFloorId[this.jsonKey] }]
       };
-      floorUpdate(pa, res => {
+      bindFloorModel(pa, res => {
         this.$message.success("更新成功");
         this.handleClose()
         this.$emit('refresh')
@@ -81,6 +80,7 @@ export default {
       };
       request.queryFloorList(data, res => {
         let tempArr = res.Content.map(t => {
+          this.modelIdToFloorId[t.CurrentModelId] = t.Id;
           return {
             value: t.CurrentModelId,
             label: t.FloorName

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

@@ -14,6 +14,7 @@ import { SGraphyView } from "@sybotan-web/graphy/lib";
 import { DivideFloorScene } from "cad-engine"
 import { SColor, SPoint } from "@sybotan-web/draw/lib";
 import canvasFun from "@/components/business_space/newGraphy/canvasFun"
+import { floorQuery } from "@/api/scan/request";
 export default {
   components: {
     canvasFun
@@ -45,7 +46,7 @@ export default {
   created() {
     this.modelId = this.$route.query.modelId;
     this.FloorID = this.$route.query.FloorID;
-    this.Outline = this.$route.query.Outline || [];
+    this.OutlineFlag = this.$route.query.OutlineFlag;
   },
   mounted() {
     this.cadWidth = document.getElementById(`drawFloor${this.id}`).offsetWidth;
@@ -56,31 +57,44 @@ export default {
       let that = this;
       that.clearGraphy()
       let id = `floorCanvas${that.id}`;
-      console.log(id)
       that.view = new SGraphyView(id)
       that.drawMainScene = new DivideFloorScene();
       that.canvasLoading = true;
+      // base/a12a88d1d92411e98e2ded11576ff4c3.jsonz
+      // that.drawMainScene.loadUrl(`/image-service/common/file_get?systemId=revit&key=base/a12a88d1d92411e98e2ded11576ff4c3.jsonz`).then(res=>{
+      //   console.log(res)
+      //   that.view.scene = that.drawMainScene
+      //   that.view.fitSceneToView();
+      // })
       that.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: ModelId }).then(res => {
-        // 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.canvasLoading = false;
-        // that.view.maxScale = that.view.scale * 1000;
-        // that.$refs.canvasFun.maxScale = that.view.maxScale;
-        // if (that.Outline.length) {
-        //   let newArr = that.Outline.map(t => {
-        //     return new SPoint(t.X, t.Y);
-        //   })
-        //   that.drawMainScene.addSceneMark(newArr)
-        // }
-        // }
+        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.canvasLoading = false;
+          that.view.maxScale = that.view.scale * 1000;
+          that.$refs.canvasFun.maxScale = that.view.maxScale;
+          if (that.OutlineFlag) {
+            this.getFloorData()
+          }
+        }
+      })
+    },
+    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)
       })
     },
     // 清空平面图

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

@@ -239,7 +239,7 @@ export default {
         this.modelId = row.ModeId;
         let pa = { modelId: this.modelId, FloorID: row.FloorID }
         if (row.Outline && row.Outline.length) {
-          pa.Outline = row.Outline;
+          pa.OutlineFlag = true;
         }
         this.$router.push({ name: "repetitionGraphy", query: pa });
       }

+ 1 - 1
src/views/ready/buildfloor/repetitionGraphy.vue

@@ -34,7 +34,6 @@ export default {
   created() {
     this.modelId = this.$route.query.modelId;
     this.FloorID = this.$route.query.FloorID;
-    this.Outline = this.$route.query.Outline || [];
   },
   mounted() {
     this.$refs.drawFloor.initGraphy(this.modelId)
@@ -65,6 +64,7 @@ export default {
         Projection: ['Outline']
       }
       floorUpdate(pa, res => {
+        this.isEdit = false;
         this.$message.success("更新成功");
       })
     },