Bladeren bron

3.8问题修改

haojianlong 4 jaren geleden
bovenliggende
commit
701c0eb52a
3 gewijzigde bestanden met toevoegingen van 81 en 20 verwijderingen
  1. 1 1
      package.json
  2. 63 17
      src/views/ledger/facility/batchPoint.vue
  3. 17 2
      src/views/ready/buildfloor/repetitionGraphy.vue

+ 1 - 1
package.json

@@ -20,7 +20,7 @@
   },
   "dependencies": {
     "@saga-web/base": "2.1.27",
-    "@saga-web/cad-engine": "2.0.581",
+    "@saga-web/cad-engine": "2.0.583",
     "@saga-web/draw": "2.1.110",
     "@saga-web/graph": "2.1.133",
     "@saga-web/topology": "1.0.85",

+ 63 - 17
src/views/ledger/facility/batchPoint.vue

@@ -2,9 +2,12 @@
   	<div id="manageTenantZone">
 		<el-row style="margin:5px 0 0 0;">
 			<el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goback"></el-button>
-			<floor-cascader @change="changeFloor"></floor-cascader>
+			<div id="buildFloor">
+                <span class="buildFloor">建筑楼层</span>
+                <el-cascader ref="floorCascader" placeholder="请选择" :props="props" :options="bfOptions" filterable size="small" @change="changeFloor"></el-cascader>
+            </div>
 			<my-cascader ref="cascader" @change="changeDevice"></my-cascader>
-			<el-button type="primary" size="mini" @click="handleClickSave" style="float:right;">确认</el-button>
+			<el-button type="primary" size="mini" @click="handleClickSave" :disabled="!isChange" style="float:right;">确认</el-button>
 			<el-button size="mini" style="float:right;margin-right:10px;" @click="cancel">取消</el-button>
 		</el-row>
 		<el-row class="main-container">
@@ -59,7 +62,7 @@
 					<div class="no-data" v-show="!showCanvas">
 						<div class="position-icon">
 							<i class="icon-wushuju iconfont"></i>
-							数据暂无
+							暂无数据
 						</div>
 					</div>
 				</el-col>
@@ -87,7 +90,7 @@
 <script>
 import floorCascader from "@/components/ledger/lib/floorCascader";
 import myCascader from "@/components/ledger/lib/cascader";
-import { queryEquip, updateEquip } from '@/api/scan/request';
+import { queryEquip, updateEquip, buildingQuery } from '@/api/scan/request';
 import { LocationPointScene, FloorView, Opt, SpaceItem, ZoneItem } from "@saga-web/cad-engine/lib";
 import { SPoint } from "@saga-web/draw";
 import { mapGetters } from "vuex";
@@ -155,6 +158,13 @@ export default {
         total: 0,
         isChange: false, //平面图设备是否更改
         isMarking: false, // 标记是否选中的是无坐标的设备,true-打点,打完以后重置为false
+        props: {
+            value: 'BuildID',
+            label: 'BuildLocalName',
+            children: 'Floor'
+        }, // 建筑楼层字段绑定
+        bfOptions: [], // 建筑楼层下拉
+        fIdToFloor: {}, // 楼层id映射楼层对象
 	};
   },
   computed: {
@@ -166,7 +176,9 @@ export default {
 		return this.loading || this.noMore
 	}
   },
-  created() {},
+  created() {
+      this.getCascader()
+  },
   mounted() {
     this.cadWidth = document.getElementById('canvasBox').offsetWidth;
     this.cadHeight = document.getElementById('canvasBox').offsetHeight;
@@ -183,6 +195,30 @@ export default {
             this.$router.push({ name: "facilityLedger" });
         })
     },
+    getCascader() {
+      let param = {
+        Cascade: [
+          { Name: "floor", Orders: "FloorSequenceID desc" }
+        ],
+        Orders: "BuildLocalName asc",
+        PageNumber: 1,
+        PageSize: 50
+      }
+      buildingQuery(param, res => {
+        this.fIdToFloor = {}
+        this.bfOptions = res.Content.map(t => {
+            if (t.Floor && t.Floor.length) {
+                 t.Floor = t.Floor.map(item => {
+                    this.fIdToFloor[item.FloorID] = item;
+                    item.BuildID = item.FloorID
+                    item.BuildLocalName = item.FloorLocalName || item.FloorName
+                    return item
+                }).filter(it => it)
+            }
+            return t
+        })
+      })
+    },
     // 二次确认
     confirm(callback) {
         if (this.isChange) {
@@ -374,33 +410,34 @@ export default {
 		this.getEquipData();
 	},
     //修改楼层
-    changeFloor(value, data) {
-        this.floorData = data;
+    changeFloor(value) {
 		this.showCanvas = false;
 		this.clearGraphy();
 		if (value[0]) {
 			this.buildId = value[0];
-		}
+        }
 		if (value[1]) {
 			this.floorId = value[1];
+            this.floorData = this.fIdToFloor[value[1]];
 		} else {
-			this.floorId = "";
+            this.floorId = "";
+            this.floorData = {}
 		}
-		if (data.StructureInfo && data.StructureInfo.FloorMap) {
-			this.floorMap = data.StructureInfo.FloorMap;
+		if (this.floorData.StructureInfo && this.floorData.StructureInfo.FloorMap) {
+			this.floorMap = this.floorData.StructureInfo.FloorMap;
 			this.showCanvas = true;
 			this.getGraphy();
 		} else {
 			this.initParams();
 			this.floorMap = "";
         }
-        if (data.StructureInfo && data.StructureInfo.Height) {
-            this.maxHeight = data.StructureInfo.Height;
+        if (this.floorData.StructureInfo && this.floorData.StructureInfo.Height) {
+            this.maxHeight = this.floorData.StructureInfo.Height;
         } else {
             this.maxHeight = 99000;
         }
-		if (data.Outline && data.Outline.length) {
-			this.floorOutline = data.Outline;
+		if (this.floorData.Outline && this.floorData.Outline.length) {
+			this.floorOutline = this.floorData.Outline;
 		} else {
 			this.floorOutline = null;
 		}
@@ -424,7 +461,8 @@ export default {
     },
     // 保存数据
     handleClickSave() {
-        if (this.scene && this.scene.iconList.length) {
+        if (this.scene && this.scene.iconList.length && this.isChange) {
+            this.isChange = false
             let param = {Content: []}
             this.scene.iconList.map((item) => {
                 if (item.data.id) {
@@ -435,7 +473,6 @@ export default {
                 }
             })
             updateEquip(param, () => {
-                this.isChange = false
                 this.$message({message: '保存成功!', type: 'success'});
             })
         }
@@ -521,6 +558,15 @@ export default {
 #manageTenantZone {
   position: relative;
   height: 100%;
+  #buildFloor{
+    margin-left: 10px;
+    float: left;
+    .buildFloor {
+        color: #999999;
+        font-size: 14px;
+        margin-right: 12px;
+    }
+  }
   .main-container {
     margin-top: 10px;
     background: #fff;

+ 17 - 2
src/views/ready/buildfloor/repetitionGraphy.vue

@@ -4,7 +4,7 @@
         <div class='buttons'>
             <el-button icon='el-icon-back' size='mini' @click='backRouter'></el-button>
             <template v-if="!hasModel">
-                <el-upload class='upload-demo' action='string' :http-request='uploadAndSubmit' :show-file-list='false' v-if="step==-1" accept=".jpg,.png">
+                <el-upload class='upload-demo' action='string' :http-request='uploadAndSubmit' :show-file-list='false' v-if="step==-1" accept=".jpg,.png" :before-upload="beforeUpload">
                     <el-button size="mini">{{hasGraph?'替换平面图图片':'上传平面图图片'}}</el-button>
                 </el-upload>
                 <el-button style='float:right;' size='mini' type='primary' v-if="step==0" @click="nextStep" :disabled="nextStepBtnDisable">下一步</el-button>
@@ -277,6 +277,22 @@ export default {
             }
             reader.readAsArrayBuffer(file)
         },
+        // 上传前判断
+        beforeUpload(file) {
+            // 拿到当前上传图片的name,判断其后缀名是否符合
+            let type = this.isImage(file.name);
+            if (!type) {
+                this.$message.error('仅支持png、jpg格式的图片');
+                return false
+            }
+            return true
+        },
+        // 封装一个判断图片文件后缀名的方法
+        isImage(fileName) {
+            if (typeof fileName !== 'string') return;
+            let name = fileName.toLowerCase();
+            return name.endsWith('.png') || name.endsWith('.jpg');
+        },
         // 更新楼层key 为图片,同时更新比例尺
         updateFloorKey(){
             const scaleItem = this.$refs.drawFloor.scaleItem;
@@ -311,7 +327,6 @@ export default {
         // 根据modelid初始化
         initFromModelId(id){
             const temp = id.split('.')[1];
-            console.log(id);
             if (temp) {
                 if (temp.toLowerCase() == 'png' || temp.toLowerCase() == 'jpg') {
                     this.$refs.drawFloor.initGraphy(id, 3)