Browse Source

返回时校验是否上传图片

haojianlong 4 years ago
parent
commit
1db9dcaa8e

+ 1 - 1
package.json

@@ -20,7 +20,7 @@
   },
   "dependencies": {
     "@saga-web/base": "2.1.27",
-    "@saga-web/cad-engine": "2.0.571",
+    "@saga-web/cad-engine": "2.0.572",
     "@saga-web/draw": "2.1.110",
     "@saga-web/graph": "2.1.129",
     "@saga-web/topology": "1.0.85",

+ 31 - 0
src/components/ready/buildfloor/backTips.vue

@@ -0,0 +1,31 @@
+<template>
+  <el-dialog title="提示" :visible.sync="dialogVis" width="500px" id="tipsDialog" :close-on-click-modal='false'>
+    <el-row>
+      <div style="line-height:32px;">上传图片未保存,退出后上传图片将失效。是否确认退出?</div>
+    </el-row>
+    <span slot="footer" class="dialog-footer">
+      <el-button size="small" @click="dialogVis=false">取消</el-button>
+      <el-button size="small" type="primary" @click="confirm">确认</el-button>
+    </span>
+  </el-dialog>
+</template>
+<script>
+export default {
+  data() {
+    return {
+      dialogVis: false,
+      scaleInput: '',
+      item: '', // 当前修改的item
+    }
+  },
+  methods: {
+    showDialog(v) {
+      this.dialogVis = true
+    },
+    confirm() {
+      this.dialogVis = false;
+      this.$emit('back');
+    }
+  }
+}
+</script>

+ 19 - 14
src/views/ready/buildfloor/drawGraphy/drawFloor.vue

@@ -12,7 +12,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 { floorQueryOutline, floorQueryAndSign } from "@/api/scan/request";
 import { EditLineItem } from "@saga-web/cad-engine"
 import { mapGetters } from "vuex";
 export default {
@@ -27,7 +27,6 @@ export default {
       cadWidth: 800,
       cadHeight: 600,
       canvasLoading: false,
-      modelId: '',
       FloorID: '',
       Outline: [],
       floorData: {},
@@ -38,6 +37,7 @@ export default {
       shadeList: [],
       type: 1, // 当前图展示类型
       scaleItem: null, // 比例尺item
+      urlModelId: '', // url中传入的modelid
     };
   },
   props: {
@@ -65,6 +65,7 @@ export default {
   },
   created() {
     this.FloorID = this.$route.query.FloorID;
+    this.urlModelId = this.$route.query.modelId
     Opt.sceneMarkColor = new SColor('#00000080');
     if (!this.dialog) {
       this.init();
@@ -86,7 +87,6 @@ export default {
       // type=3 => id:图片的key
       let that = this;
       that.type = type;
-      that.modelId = Id;
       that.clearGraphy()
       that.drawMainScene = new DivideFloorScene();
       that.canvasLoading = true;
@@ -149,20 +149,25 @@ export default {
       let pa = {
         Filters: `FloorID='${this.FloorID}'`
       }
-      floorQueryOutline(pa, res => {
-        this.floorData = res.Content[0];
-        if (this.floorData.StructureInfo && this.floorData.StructureInfo.FloorMap) {
-          this.getOtherFloorOutLine();
-          let floorMap = this.floorData.StructureInfo.FloorMap
-          if (floorMap.split('.')[1] == 'png' || floorMap.split('.')[1] == 'jpg') {
+      const temp = this.urlModelId.split('.')[1]
+      if (temp == 'png' || temp == 'jpg') { //底图为图片且已经绑定过图片
+        floorQueryAndSign(pa, res => {
+          this.floorData = res.Content[0];
+          if (this.floorData.StructureInfo && this.floorData.StructureInfo.FloorMap) {
+            let floorMap = this.floorData.StructureInfo.FloorMap
             this.initGraphy(floorMap, 3)
-          } else {
+          }
+        })
+      } else {
+        floorQueryOutline(pa, res => {
+          this.floorData = res.Content[0];
+          if (this.floorData.StructureInfo && this.floorData.StructureInfo.FloorMap) {
+            this.getOtherFloorOutLine();
+            let floorMap = this.floorData.StructureInfo.FloorMap
             this.initGraphy(floorMap, 2)
           }
-        } else {
-
-        }
-      })
+        })
+      }
     },
     // 获取绑定该模型id的其他楼层轮廓线
     getOtherFloorOutLine() {

+ 22 - 3
src/views/ready/buildfloor/repetitionGraphy.vue

@@ -3,7 +3,7 @@
     <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>
@@ -46,12 +46,15 @@
         <checkGraphy ref='checkGraphy' @refresh='refresh' :alreadyRelatedModel='alreadyRelatedModel'></checkGraphy>
         <!-- 设定比例尺弹窗 -->
         <setScaleDialog ref="setScaleDialog"></setScaleDialog>
+        <!-- 退出时弹窗提示 -->
+        <backTips ref='backTips' @back="runBack"></backTips>
     </div>
 </template>
 <script>
 import drawFloor from './drawGraphy/drawFloor'
 import checkGraphy from './drawGraphy/checkGraphy' //查看图片
 import setScaleDialog from '@/components/ready/buildfloor/setScaleDialog'
+import backTips from '@/components/ready/buildfloor/backTips'
 import { floorUpdateOutline, floorQueryAndSign, manageUpdateFloor } from '@/api/scan/request'
 import { getFileNameById, countModel } from '@/api/model/file'
 import { EditLineItem, SItemStatus, SImageShowType, IconTextItem} from "@saga-web/cad-engine"
@@ -61,7 +64,8 @@ export default {
     components: {
         drawFloor,
         checkGraphy,
-        setScaleDialog
+        setScaleDialog,
+        backTips
     },
     data() {
         return {
@@ -74,7 +78,7 @@ export default {
             otherSign: false,
             hasGraph: false, // 当前楼层是否有平面图
             hasModel: false, // 项目中时候有模型文件
-            step: -1, // 当前处于第几步 同时为比例尺item判断是否创建的可编辑的依据
+            step: -1, // 当前处于第几步 同时为比例尺item判断是否创建的可编辑的依据;能否返回上页的依据
             key: '', // 当楼层图为图片时图的key
             stepDes: [
                 '请在图上点击两点绘制线段并标记实际长度',
@@ -112,6 +116,14 @@ export default {
         },
         // 返回路由
         backRouter() {
+            // 底图为图片  上传完图片后未保存
+            if (this.step > -1) {
+                this.$refs.backTips.showDialog();
+            } else {
+                this.runBack()
+            }
+        },
+        runBack() {
             this.$router.push({ name: 'buildFloor' })
         },
         // 替换模型文件
@@ -311,6 +323,7 @@ export default {
                 this.$refs.drawFloor.drawMainScene.grabItem = scaleItem;
                 scaleItem.connect('changText', this, this.changeText)
                 scaleItem.moveable = true;
+                this.clearScaleData(scaleItem);
             } else if (this.step == -1) {
                 scaleItem.status = SItemStatus.Normal;
             }
@@ -348,6 +361,12 @@ export default {
                 this.$refs.drawFloor.drawMainScene.removeItem(this.curImgItem);
                 this.curImgItem = null;
             }
+        },
+        // 清空比例尺数据
+        clearScaleData(scaleItem) {
+            scaleItem.line = [];
+            scaleItem.pointChange();
+            scaleItem.text = '';
         }
     },
     watch: {