Browse Source

批量维护设备位置修改1

zhangyu 4 years ago
parent
commit
d97e19de2b
1 changed files with 67 additions and 20 deletions
  1. 67 20
      src/views/ledger/facility/batchPoint.vue

+ 67 - 20
src/views/ledger/facility/batchPoint.vue

@@ -4,8 +4,8 @@
 			<el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goback"></el-button>
 			<floor-cascader @change="changeFloor"></floor-cascader>
 			<my-cascader ref="cascader" @change="changeDevice"></my-cascader>
-			<el-button style="float:right;margin-top:1px;">取消</el-button>
-			<el-button style="float:right;margin-top:1px;margin-right:10px;">确认</el-button>
+			<!-- <el-button style="float:right;margin-top:1px;">取消</el-button> -->
+			<el-button @click="handleClickSave" style="float:right;margin-top:1px;margin-right:10px;">保存</el-button>
 		</el-row>
 		<el-row class="main-container">
 			<el-row class="main-container-header">
@@ -29,7 +29,7 @@
 					<div class="equip-list">
 						<el-scrollbar style="height:100%;" v-show="equipList.length">
 							<ul v-infinite-scroll="getEquipData" infinite-scroll-disabled="disabled">
-								<li class="equip-item" v-for="item in equipList" :key="item.EquipID" :title="item[showName]">
+								<li class="equip-item" v-for="item in equipList" :key="item.EquipID" :title="item[showName]" @click="handleSelectIcon(item)">
 									<p class="equip-item-text">{{item[showName] || '--'}}</p>
 									<i v-if="item.BIMLocation" class="iconfont icon-hook equip-item-icon" style="color: #67C23A;"></i>
 									<i v-else class="iconfont icon-cross equip-item-icon" style="color: #F56C6C;"></i>
@@ -64,7 +64,7 @@
 <script>
 import floorCascader from "@/components/ledger/lib/floorCascader";
 import myCascader from "@/components/ledger/lib/cascader";
-import { queryEquip } from '@/api/scan/request';
+import { queryEquip, updateEquip } from '@/api/scan/request';
 import { LocationPointScene, FloorView, Opt, SpaceItem, ZoneItem } from "@saga-web/cad-engine/lib";
 import { mapGetters } from "vuex";
 export default {
@@ -115,7 +115,8 @@ export default {
 		loading: false,
 		pageNumber: 1,
 		pageSize: 50,
-		total: 0
+        total: 0,
+        isChange: false //平面图设备是否更改
 	};
   },
   computed: {
@@ -135,8 +136,28 @@ export default {
   methods: {
     // 返回
     goback() {
-      this.$router.push({ name: "facilityLedger" });
-	},
+        this.confirm(() => {
+            this.$router.push({ name: "facilityLedger" });
+        })
+    },
+    // 二次确认
+    confirm(callback) {
+        if (this.isChange) {
+            this.$confirm('平面图数据未保存,此操作将不会保存修改数据!', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                callback();
+            });
+        } else {
+            callback();
+        }
+    },
+    // 点击列表设备选中平面图设备
+    handleSelectIcon(item) {
+        
+    },
 	//获取所以主体数据---用于维护信息
 	getEquipData() {
 		if (this.classCode && this.floorId && (this.floorId != "noKnow" || this.floorId != "all")) {
@@ -175,9 +196,16 @@ export default {
 				if (this.view && this.view.scene) {
 					res.Content.forEach(item =>{
 						if (item.LocationJson && item.LocationJson.X && item.LocationJson.Y) {
-							this.scene.addMarker({X: item.LocationJson.X, Y: -item.LocationJson.Y});
+                            this.scene.addIconText({
+                                id: item.EquipID,
+                                X: item.LocationJson.X, 
+                                Y: -item.LocationJson.Y, 
+                                Z: item.LocationJson.Z,
+                                text: [`${item.EquipLocalName || '--'}\n${item.EquipLocalID || '--'}\n${item.LocationJson.Y || '--'}`]
+                            });
 						}
-					});
+                    });
+                    this.scene.iconMove(this, this.iconMove);
 					this.view.update();
 				}
 				this.total = res.Total;
@@ -187,13 +215,20 @@ export default {
 				this.loading = false;
 			})
 		}
-	},
+    },
+    //设备移动回调
+    iconMove(item) {
+        this.isChange = true;
+    },
 	//初始化条件并查询设备
 	initParams() {
 		this.pageNumber = 1;
 		this.total = 0;
 		this.equipList = [];
-		this.clearMark();
+        this.clearIcon();
+        if (this.view) {
+            this.view.update();
+        }
 		this.getEquipData();
 	},
     //修改楼层
@@ -238,7 +273,24 @@ export default {
 	//检索关键字
 	handleChangeKeyword() {
 		this.initParams();
-	},
+    },
+    // 保存数据
+    handleClickSave() {
+        if (this.scene && this.scene.iconList.length) {
+            let param = {Content: []}
+            this.scene.iconList.map((item) => {
+                if (item.data.id && item.data.Z) {
+                    param.Content.push({
+                        EquipID: item.data.id,
+                        BIMLocation: `${item.x},${-item.y},${item.data.Z}`
+                    })
+                }
+            })
+            updateEquip(param, () => {
+                this.$message({message: '保存成功!', type: 'success'});
+            })
+        }
+    },
 	// 获取底图
     getGraphy() {
       this.scene = new LocationPointScene();
@@ -285,14 +337,9 @@ export default {
       this.view = new FloorView("floorCanvas");
 	},
 	//清空标记
-	clearMark() {
-		if (this.view && this.view.scene) {
-			this.scene.markerList.forEach((t) => {
-				this.scene.removeItem(t)
-			})
-			this.scene.markerList = [];
-			this.view.update();
-		}
+	clearIcon() {
+        if (this.scene)
+        this.scene.clearIcon();
 	},
   },
   watch: {