Parcourir la source

update new graphy engine

haojianlong il y a 5 ans
Parent
commit
b14104907a

+ 5 - 4
package.json

@@ -10,9 +10,9 @@
         "build": "node build/build.js"
     },
     "dependencies": {
-        "@sybotan-web/base": "2.0.51",
-        "@sybotan-web/draw": "2.0.94",
-        "@sybotan-web/graphy": "2.0.77",
+        "@sybotan-web/base": "2.0.54",
+        "@sybotan-web/draw": "2.0.111",
+        "@sybotan-web/graphy": "2.0.90",
         "axios": "^0.18.0",
         "echarts": "^4.1.0",
         "element-ui": "^2.11.0",
@@ -22,7 +22,8 @@
         "vue": "^2.5.2",
         "vue-axios": "^2.1.4",
         "vue-router": "^3.0.1",
-        "vuex": "^3.1.0"
+        "vuex": "^3.1.0",
+        "cad-engine": "2.0.35"
     },
     "devDependencies": {
         "ajv": "^6.9.1",

+ 26 - 29
src/views/ready/buildfloor/drawGraphy/checkGraphy.vue

@@ -42,10 +42,6 @@ export default {
   components: {
     drawFloor
   },
-  props: {
-    checkGraphyVisible: Boolean,
-    checkGraphyItem: Object
-  },
   computed: {
     ...mapGetters("layout", ["projectId"])
   },
@@ -57,6 +53,7 @@ export default {
       point: [40703.54760591985, 42678.14510522981], //坐标
       pointWidth: 2000,
       findGraphyItemId: "", //高亮的i
+      checkGraphyVisible: false,
       props: {
         //联级框
         lazy: true,
@@ -89,40 +86,37 @@ export default {
             });
           }
         }
-      }
+      },
+      floor:'', // 当前选中的楼层数据
     };
   },
   methods: {
+    // 弹窗显示
+    showDialog(floor){
+      this.floor = floor;
+      this.checkGraphyVisible = true;
+    },
+    // 关闭弹窗
     handleClose() {
-      this.$emit("handleCloseCGraphy");
+      this.checkGraphyVisible = false;
     },
-    // 绑定图片
+    // 更新楼层 平面图文件
     bindGraphy() {
       if(!this.jsonKey){
-            this.$message.warning("请选择模型文件");
-            return
+        this.$message.warning("请选择模型文件");
+        return
       }
-      let data = {
-        Content: [
-          {
-            FloorID: this.checkGraphyItem.FloorID,
-            StructureInfo: {
-              // FloorMap: this.jsonKey
-            }
-          }
-        ]
+      if(!this.floor.StructureInfo){
+        this.floor.StructureInfo = {}
+      }
+      this.floor.StructureInfo.FloorMap = this.jsonKey
+      let pa = {
+        Content: [this.floor]
       };
-      floorUpdate(data, res => {
-        if (res.Result == "success") {
-          this.$message.success("添加成功");
-          this.handleClose()
-        } else {
-          if (res.Message) {
-            this.$message.warning(res.Message);
-          } else {
-            this.$message.warning("绑定失败");
-          }
-        }
+      floorUpdate(pa, res => {
+        this.$message.success("添加成功");
+        this.handleClose()
+        this.$emit('refresh')
       });
     },
     initOption() {
@@ -137,6 +131,9 @@ export default {
     // 点击多级联动
     handleChange(val) {
       console.log(val)
+      this.$refs.drawFloor.initGraphy('3af6d175c34e11e993ac85337be80696')
+      this.dataKey = '3af6d175c34e11e993ac85337be80696'
+      this.jsonKey = val[1]
       // this.jsonKey = val[1];
       // this.dataKey = `/image-service/common/file_get/${this.jsonKey}?systemId=revit`;
     }

+ 13 - 40
src/views/ready/buildfloor/drawGraphy/drawFloor.vue

@@ -5,16 +5,10 @@
 </template>
 
 <script>
-import {
-  SGraphyView,
-  SGraphyScene,
-  SGraphyClockItem
-} from "@sybotan-web/graphy/lib";
-import axios from "axios";
-import { SPoint } from "@sybotan-web/base/lib";
-import { SPen, SPainter, SColor } from "@sybotan-web/draw";
-import { mainScene, SGraphyRectItem } from "@/assets/graphy/index.js";
 import eventBus from "./bus.js";
+import { SGraphyView } from "@sybotan-web/graphy/lib";
+import { FloorScene } from "cad-engine";
+import { SColor } from "@sybotan-web/draw/lib";
 export default {
   props: {
     cadWidth: {
@@ -92,7 +86,7 @@ export default {
     };
   },
   mounted() {
-    this.initGraphy();
+    this.initGraphy('3af6d175c34e11e993ac85337be80696');
     let that = this;
     eventBus.$on("suitableRatios", function() {
       that.view.fitSceneToView();
@@ -105,7 +99,7 @@ export default {
     });
     eventBus.$on("openDrags", function(val) {
        if(val){
-         
+
        }
     });
   },
@@ -125,7 +119,7 @@ export default {
         this.drawItemColor(item, color);
       });
     },
-    initGraphy() {
+    initGraphy(ModelId) {
       if (!this.dataKey) {
         return;
       }
@@ -133,23 +127,12 @@ export default {
       this.view = null;
       // 初始化view类
       this.view = new SGraphyView("canvas" + this.indexs);
-      this.drawMainScene = new mainScene(null);
-      this.drawMainScene
-        .urlGetData(
-          "/image-service/common/file_get/Fl4201050001c72ff970d2ba11e8a57543fa3e79672520181120041440bim.jsonz?systemId=revit" ///////////测试路径
-          // this.dataKey       //开发url
-        )
-        .then(() => {
-          //  将场景赋给view对图进行绘制
-          this.view.scene = this.drawMainScene;
-          // 自动缩放比例
-          this.view.fitSceneToView();
-          // 绘制地图颜色
-          this.drawAllItemColor();
-          // this.drawMainScene.click(this, this.clickItem);
-          this.drawMainScene.mouseMove(this, this.leftClickMove);
-          eventBus.$emit("viewScale", this.view.scale);
-        });
+      this.drawMainScene = new FloorScene(null);
+      let that = this;
+      this.drawMainScene.getFloorData('/modelapi/base-graph/query',{ ModelId:ModelId }).then(res=>{
+        that.view.scene = that.drawMainScene
+        that.view.fitSceneToView();
+      })
       if (this.isScale) {
         this.cancelScale(this.view);
       }
@@ -170,21 +153,11 @@ export default {
       //计算缩放比例
       this.view.scale = val;
     },
-    moveScence() {
-      //获取中心点
-      let rect = this.view.scene.worldRect();
-      // 移动画布
-      this.view.pos.x =
-        (-(rect.right + rect.left) / 2) * this.view.scale + this.view.width / 2;
-      this.view.pos.y =
-        (-(rect.bottom + rect.top) / 2) * this.view.scale +
-        this.view.height / 2;
-    }
   },
   watch: {
     dataKey(str) {
       if (str) {
-        this.initGraphy();
+        this.initGraphy('3af6d175c34e11e993ac85337be80696');
       }
     },
     findGraphyItemId(str) {

+ 21 - 81
src/views/ready/buildfloor/index.vue

@@ -11,12 +11,7 @@
         </div>
         <h4>建筑</h4>
         <div class="build-list">
-          <div
-            v-for="(item,index) in buildList"
-            :key="item.BuildID"
-            :class="{'floor-item':true,active:item.active}"
-            @click="changeBuild(index)"
-          >
+          <div v-for="(item,index) in buildList" :key="item.BuildID" :class="{'floor-item':true,active:item.active}" @click="changeBuild(index)">
             <span>
               {{item.BuildLocalName || item.BuildName}}
               <el-badge class="mark" :is-dot="false" />
@@ -29,32 +24,18 @@
           <el-button size="small" type="default" @click="addFloor">添加楼层</el-button>
         </div>
         <div class="table-box">
-          <el-table
-            :data="tableData"
-            style="width: 100%"
-            height="100%"
-            v-loading="loading"
-            :header-cell-style="headerStyle"
-          >
+          <el-table :data="tableData" style="width: 100%" height="100%" v-loading="loading" :header-cell-style="headerStyle">
             <el-table-column label="楼层本地名">
               <template slot-scope="scope">{{scope.row.FloorLocalName||scope.row.FloorName}}</template>
             </el-table-column>
             <el-table-column label="楼层信息">
               <template slot-scope="scope">
-                <el-button
-                  size="mini"
-                  @click="editFloorData(scope.row)"
-                  plain
-                  icon="el-icon-edit-outline"
-                ></el-button>
+                <el-button size="mini" @click="editFloorData(scope.row)" plain icon="el-icon-edit-outline"></el-button>
               </template>
             </el-table-column>
             <el-table-column prop="Datasource" label="平面图">
               <template slot-scope="scope">
-                <p
-                  v-if="scope.row.StructureInfo&&scope.row.StructureInfo.FloorMap"
-                  @click="checfDrawImg(scope.row,1)"
-                >
+                <p v-if="scope.row.StructureInfo&&scope.row.StructureInfo.FloorMap" @click="checfDrawImg(scope.row,1)">
                   <i class="iconfont icon-floorplan"></i>
                   查看平面图
                 </p>
@@ -71,62 +52,29 @@
             </el-table-column>
             <el-table-column prop="SubTypeName" label="楼层贯通关系">
               <template slot-scope="scope">
-                <span
-                  style="margin-right:20px"
-                >{{scope.row.FloorThroughList?scope.row.FloorThroughList.length:0}}</span>
-                <el-button
-                  size="mini"
-                  @click="changeConnection(scope.row)"
-                  plain
-                  icon="el-icon-edit-outline"
-                ></el-button>
+                <span style="margin-right:20px">{{scope.row.FloorThroughList?scope.row.FloorThroughList.length:0}}</span>
+                <el-button size="mini" @click="changeConnection(scope.row)" plain icon="el-icon-edit-outline"></el-button>
               </template>
             </el-table-column>
             <el-table-column prop="action" label="操作">
               <template slot-scope="scope">
-                <el-button
-                  size="mini"
-                  @click="handleDelete(scope.row)"
-                  type="danger"
-                  plain
-                  icon="el-icon-delete"
-                ></el-button>
+                <el-button size="mini" @click="handleDelete(scope.row)" type="danger" plain icon="el-icon-delete"></el-button>
               </template>
             </el-table-column>
           </el-table>
         </div>
         <!-- 分页 -->
-        <el-pagination
-          class="fr"
-          v-show="tableData && tableData.length"
-          @size-change="handleSizeChange"
-          @current-change="handleCurrentChange"
-          :current-page="page.pageNumber"
-          :page-sizes="page.pageSizes"
-          :page-size="page.pageSize"
-          layout="total, sizes, prev, pager, next, jumper"
-          :total="page.total"
-        ></el-pagination>
+        <el-pagination class="fr" v-show="tableData && tableData.length" @size-change="handleSizeChange" @current-change="handleCurrentChange"
+          :current-page="page.pageNumber" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
+          :total="page.total"></el-pagination>
       </div>
     </el-row>
     <!-- 添加-修改楼层 -->
-    <addFloor
-      :title="floorTitle"
-      ref="addFloorDialog"
-      :curBuildId="curBuildId"
-      :curFloorId="curFloorId"
-      @refresh="refresh"
-    ></addFloor>
+    <addFloor :title="floorTitle" ref="addFloorDialog" :curBuildId="curBuildId" :curFloorId="curFloorId" @refresh="refresh"></addFloor>
     <!-- 添加-修改建筑 -->
     <addBuild :title="buildTitle" ref="addBuildDialog"></addBuild>
     <!-- 删除建筑-删除楼层 -->
-    <el-dialog
-      title="提示"
-      :visible.sync="delDialogVis"
-      width="20%"
-      @close="handleClose"
-      id="messageDialog"
-    >
+    <el-dialog title="提示" :visible.sync="delDialogVis" width="20%" @close="handleClose" id="messageDialog">
       <div>确定要删除该{{delText}}?</div>
       <span slot="footer" class="dialog-footer">
         <el-button size="small" @click="delDialogVis=false">取消</el-button>
@@ -136,11 +84,7 @@
     <!-- 添加贯通关系弹窗 -->
     <addConnectivity ref="addConnectivity" @refresh="refresh"></addConnectivity>
     <!-- 查看图片弹窗 -->
-    <checkGraphy
-      :checkGraphyVisible="checkGraphyVisible"
-      @handleCloseCGraphy="checkGraphyVisible=false"
-      :checkGraphyItem="checkGraphyItem"
-    ></checkGraphy>
+    <checkGraphy ref="checkGraphy" @refresh="refresh"></checkGraphy>
   </div>
 </template>
 
@@ -160,7 +104,6 @@ export default {
   },
   data() {
     return {
-      checkGraphyVisible: false, //查看平面图弹窗
       repetitionGraphyVisible: false, // 替换平面图弹窗
       floorTitle: "添加楼层",
       buildTitle: "添加建筑",
@@ -187,13 +130,12 @@ export default {
       curBuildId: "", //当前选中的建筑id
       curFloorId: "", //当前选中的楼层id
       jsonKey: "",
-      checkGraphyItem:{}
     };
   },
   computed: {
     ...mapGetters("layout", ["projectId"])
   },
-  mounted() {},
+  mounted() { },
   created() {
     this.init();
   },
@@ -246,9 +188,9 @@ export default {
       this.curFloorId = floor.FloorID;
     },
     //确认删除弹窗关闭
-    handleClose() {},
-    handleSizeChange(pageSize) {},
-    handleCurrentChange(pageNumber) {},
+    handleClose() { },
+    handleSizeChange(pageSize) { },
+    handleCurrentChange(pageNumber) { },
     addFloor() {
       this.curFloorId = "";
       this.$refs.addFloorDialog.showDialog();
@@ -296,15 +238,13 @@ export default {
       this.$refs.addConnectivity.floor = row;
     },
     // 查看平面图
-    checfDrawImg(item, index) {
+    checfDrawImg(row, index) {
       if (3 == index) {
-        // 查看
+        this.$refs.checkGraphy.showDialog(row)
         this.jsonKey = "";
-        this.checkGraphyItem = item
-        this.checkGraphyVisible = true;
       } else {
-        this.jsonKey = item.StructureInfo.FloorMap;
-        this.$router.push({ name: "repetitionGraphy",query:{jsonKey:this.jsonKey}});
+        this.jsonKey = row.StructureInfo.FloorMap;
+        this.$router.push({ name: "repetitionGraphy", query: { jsonKey: this.jsonKey } });
       }
     }
   },