Browse Source

Merge branch 'graphEq' of git.sagacloud.cn:web/ibms into graphEq

zhangyu 4 years ago
parent
commit
da081e0a2b

+ 28 - 2
src/views/ready/buildfloor/drawGraphy/drawFloor.vue

@@ -13,6 +13,7 @@ import { DivideFloorScene, FloorView, Opt } from "@saga-web/cad-engine/lib"
 import { SColor, SPoint } from "@saga-web/draw/lib";
 import canvasFun from "@/components/business_space/newGraphy/canvasFun"
 import { floorQueryOutline } from "@/api/scan/request";
+import { EditLineItem } from "@saga-web/cad-engine"
 import { mapGetters } from "vuex";
 export default {
   components: {
@@ -34,7 +35,9 @@ export default {
         isEdit: false,
         divide: true
       },
-      shadeList: []
+      shadeList: [],
+      type: 1, // 当前图展示类型
+      scaleItem: null, // 比例尺item
     };
   },
   props: {
@@ -82,6 +85,7 @@ export default {
       // type=2 => id:floormap
       // type=3 => id:图片的key
       let that = this;
+      that.type = type;
       that.modelId = Id;
       that.clearGraphy()
       that.drawMainScene = new DivideFloorScene();
@@ -117,7 +121,17 @@ export default {
       this.view.fitSceneToView();
       this.drawMainScene.isSpaceSelectable = false;
 
-      this.$emit('getGraphSuc');
+      if (this.type == 3) {
+        this.addScaleItem(this.floorData.Properties)
+        this.$emit('getGraphSuc');
+        if (this.floorData.Properties) {
+          const x = this.floorData.Properties.X;
+          const y = this.floorData.Properties.Y;
+          if (x != 0 || y != 0) {
+            this.drawMainScene.imgList[0].moveTo(x, y);
+          }
+        }
+      }
 
       if (this.$refs.canvasFun) {
         this.view.minScale = this.view.scale;
@@ -170,6 +184,18 @@ export default {
         this.$emit('changeSign', res.Content.length > 1);
       });
     },
+    // 添加比例尺item 当楼层图为图片类型时 回显比例尺
+    addScaleItem(data) {
+      this.scaleItem = new EditLineItem(null)
+      this.scaleItem.strokeColor = SColor.Red;
+      this.drawMainScene.addItem(this.scaleItem)
+      if (data && data.Line && data.Line.length == 2) {
+        this.scaleItem.line = data.Line;
+        this.scaleItem.text = data.Text;
+        // todo
+        this.scaleItem.pointChange();
+      }
+    },
     // 清空平面图
     clearGraphy() {
       if (this.view) {

+ 36 - 23
src/views/ready/buildfloor/repetitionGraphy.vue

@@ -3,14 +3,16 @@
     <div id='repetitionGraphy'>
         <div class='buttons'>
             <el-button icon='el-icon-back' size='mini' @click='backRouter'></el-button>
-            <template v-if="!!hasModel">
+            <template v-if="!hasModel">
                 <el-upload class='upload-demo' action='string' :http-request='uploadAndSubmit' :show-file-list='false' v-if="step==-1">
                     <el-button size="mini">{{hasGraph?'替换平面图图片':'上传平面图图片'}}</el-button>
                 </el-upload>
-                <el-button v-if='step>-1' style='float:right;' size='mini' type='primary' @click="nextStep">{{step==0?'下一步':step==1?'保存':''}}</el-button>
+                <el-button style='float:right;' size='mini' type='primary' v-if="step==0" @click="nextStep">下一步</el-button>
+                <el-button style='float:right;' size='mini' type='primary' v-if="step==1" @click="nextStep">保存</el-button>
+                <el-button style='float:right;' size='mini' v-if="step==1" @click="lastStep">上一步</el-button>
             </template>
             <template v-else>
-                <el-button v-if='!isEdit' size='mini' @click='changeGraphy'>{{hasGraph?'关联模型文件':'替换模型文件'}}</el-button>
+                <el-button v-if='!isEdit' size='mini' @click='changeGraphy'>{{hasGraph?'替换模型文件':'关联模型文件'}}</el-button>
                 <el-button v-if='(sign||otherSign)&&!isEdit' size='mini' @click='editGraphy'>编辑平面图</el-button>
                 <el-button v-if='isEdit' size='mini' @click='cancel'>取消</el-button>
                 <el-button v-if='isEdit' size='mini' @click='confirm' type='primary'>确认</el-button>
@@ -72,7 +74,7 @@ export default {
             otherSign: false,
             hasGraph: false, // 当前楼层是否有平面图
             hasModel: false, // 项目中时候有模型文件
-            step: -1, // 当前处于第几步
+            step: -1, // 当前处于第几步 同时为比例尺item判断是否创建的可编辑的依据
             key: '', // 当楼层图为图片时图的key
             stepDes: [
                 '请在图上点击两点绘制线段并标记实际长度',
@@ -242,8 +244,13 @@ export default {
             }
             reader.readAsArrayBuffer(file)
         },
-        // 更新楼层key 为图片
+        // 更新楼层key 为图片,同时更新比例尺
         updateFloorKey(){
+            const scaleItem = this.$refs.drawFloor.scaleItem;
+            // 比例尺坐标处理,当底图被对齐操作后,需要跟随底图改变坐标
+            const line = scaleItem.line.map(t => {
+                return { x: t.x + this.baseImgItem.x, y: t.y + this.baseImgItem.y }
+            })
             let Param = {
                 Content: [{
                     FloorId: this.FloorID,
@@ -251,8 +258,8 @@ export default {
                     Properties: {
                         X: this.baseImgItem.x, 
                         Y: this.baseImgItem.y,
-                        line: this.scaleItem.line,
-                        Scale: this.scaleItem
+                        Line: line,
+                        Text: scaleItem.text
                     }
                 }],
                 Projection: ['FloorMap', 'Properties'],
@@ -260,6 +267,9 @@ export default {
             manageUpdateFloor(Param, (res) => {
                 this.$message.success('更新成功')
                 this.step = -1;
+                this.baseImgItem.globalAlpha = 1
+                this.removeLast()
+                this.$refs.drawFloor.fit()
             })
         },
         // 根据modelid初始化
@@ -270,6 +280,13 @@ export default {
                 this.$refs.drawFloor.initGraphy(id, 1)
             }
         },
+        // 上一步
+        lastStep() {
+            this.step = 0;
+            this.$refs.drawFloor.scaleItem.show()
+            this.baseImgItem.globalAlpha = 1
+            this.removeLast()
+        },
         // 下一步||保存
         nextStep() {
             this.baseImgItem = this.$refs.drawFloor.drawMainScene.imgList[0]
@@ -278,28 +295,24 @@ export default {
             // 下一步
             if (this.step == 0) {
                 this.step = 1;
-                this.scaleItem.hide();
-                // 
+                this.$refs.drawFloor.scaleItem.hide();
+                // 获取楼层列表
                 this.getFloorData()
             } else if (this.step == 1) {
                 // 保存
                 this.updateFloorKey();
             }
         },
-        //  比例尺
-        setScale() {
-            this.scaleItem = new EditLineItem(null)
-            this.$refs.drawFloor.drawMainScene.addItem(this.scaleItem)
-            this.scaleItem.connect('changText', this, this.changeText)
-            this.scaleItem.strokeColor = SColor.Red;
-            this.scaleItem.status = SItemStatus.Create;
-            this.$refs.drawFloor.drawMainScene.grabItem = this.scaleItem;
-            this.scaleItem.moveable = true;
-        },
-        // 加载图成功
+        // 加载图成功 仅在底图为图片时返回成功
         getGraphSuc() {
-            if (this.key) {
-                this.setScale();
+            const scaleItem = this.$refs.drawFloor.scaleItem
+            if (this.step == 0) {
+                scaleItem.status = SItemStatus.Create;
+                this.$refs.drawFloor.drawMainScene.grabItem = scaleItem;
+                scaleItem.connect('changText', this, this.changeText)
+                scaleItem.moveable = true;
+            } else if (this.step == -1) {
+                scaleItem.status = SItemStatus.Normal;
             }
         },
         // 修改比例尺文字
@@ -326,7 +339,7 @@ export default {
                     }
                 }
                 this.$refs.drawFloor.drawMainScene.addItem(this.curImgItem);
-                this.$refs.drawFloor.view.fitSceneToView()
+                this.$refs.drawFloor.fit()
             }
         },
         // 清除上一张底图