|
|
@@ -3,10 +3,11 @@
|
|
|
<!-- 地图 -->
|
|
|
<div id="container" style="height:100%"></div>
|
|
|
<!-- 搜索框 -->
|
|
|
- <div id="panel" style="display:flex;justify-content: center;align-items: center">
|
|
|
+ <div id="panel" style="display:flex;justify-content: center;align-items: center;">
|
|
|
+
|
|
|
<div class="search">
|
|
|
<el-select @change="setSuggestion" :clearable="true" @clear="clear" v-model="value" style="width:100%"
|
|
|
- filterable remote reserve-keyword placeholder="请输入地址关键词" :remote-method="getSuggestions" :loading="loading">
|
|
|
+ filterable remote reserve-keyword placeholder="请输入设备名称关键词" :remote-method="getSuggestions" :loading="loading">
|
|
|
<el-option v-for="(item,index) in suggestionList" :key="index" :label="item.name" :value="item">
|
|
|
<span style="float: left">{{ item.name }}</span>
|
|
|
<el-tooltip class="item" effect="dark" :content="item.address" placement="top-start">
|
|
|
@@ -16,22 +17,31 @@
|
|
|
</el-select>
|
|
|
</div>
|
|
|
|
|
|
- <div style="margin-left: 10px" v-if="operaType!=3">
|
|
|
- <el-button @click="addDevice" icon="el-icon-plus" :type="operaType==1?'primary':''" circle></el-button>
|
|
|
+ <div style="margin-left: 10px;display:flex" v-show="operaType!=3">
|
|
|
+ <el-button @click="addDevice" size="small" type="primary" v-text="operaType==1?'取消添加':'添加设备'"
|
|
|
+ style="border-radius:4px 0 0 4px;margin-right:-2px;height:36px;padding:10px"></el-button>
|
|
|
+ <el-button @click="move" size="small"
|
|
|
+ style="margin:0;border-radius:0 4px 4px 0;margin-left:-2px;height:36px;padding:10px;border:1px solid #3b8ff4;color:#3b8ff4">
|
|
|
+ 移动设备
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
|
|
|
-
|
|
|
- <div style="margin-left: 10px">
|
|
|
- <el-button @click="operaMarkers" size="small" v-text="operaType==3?'保存':'移动设备位置'"
|
|
|
- :type="operaType==3?'primary':''" :style="operaType==3?'border-radius:4px 0 0 4px':''"></el-button>
|
|
|
- <el-button @click="cancelMove" size="small" v-if="operaType==3"
|
|
|
- style="margin:0;border-radius:0 4px 4px 0;border:1px solid #62a5f6">取消</el-button>
|
|
|
+ <div style="margin-left: 10px;display:flex" v-show="operaType==3">
|
|
|
+ <el-button @click="save" size="small" type="primary" style="border-radius:4px 0 0 4px;height:34px">保存
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="cancelMove" size="small"
|
|
|
+ style="margin:0;border-radius:0 4px 4px 0;height:34px;border:1px solid #3b8ff4;color:#3b8ff4">取消
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
+
|
|
|
+
|
|
|
</div>
|
|
|
<!-- 设备列表 -->
|
|
|
- <device-list @click="clickDevice" ref="deviceList"></device-list>
|
|
|
+ <device-list @select="selectDevice" @dropdownClick="dropdownClick" @click="clickDevice" ref="deviceList">
|
|
|
+ </device-list>
|
|
|
|
|
|
<door-device-form ref="doorDeviceForm" @reloadData="reloadData"></door-device-form>
|
|
|
+ <video-device-form ref="videoDeviceForm" @reloadData="reloadData"></video-device-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -40,35 +50,53 @@
|
|
|
</script>
|
|
|
|
|
|
<script>
|
|
|
+ //设备列表
|
|
|
+ import deviceList from "./comps/device-list.vue"
|
|
|
+ // 门禁
|
|
|
import {
|
|
|
- deepClone
|
|
|
- } from '@/util/util.js'
|
|
|
+ getDoorDeviceCoordinates,
|
|
|
+ edit as editDoordevice,
|
|
|
+ updateBatch as updateDoordeviceBatch,
|
|
|
+ getList as getDoordeviceList,
|
|
|
+ remove as removeDoordevice
|
|
|
+ } from "@/api/device/doordevice.js"
|
|
|
import doorDeviceForm from "./comps/door-device-form.vue"
|
|
|
+ //监控
|
|
|
import {
|
|
|
- getDoorDeviceCoordinates
|
|
|
- } from "@/api/device/doordevice.js"
|
|
|
- import * as mapUtil from "./js/mapUtil.js"
|
|
|
- import deviceList from "./comps/device-list.vue"
|
|
|
+ getVideoDeviceCoordinates,
|
|
|
+ edit as editGbdevicechannel,
|
|
|
+ updateBatch as updateGbdevicechannelBatch,
|
|
|
+ getList as getGbdevicechannelList,
|
|
|
+ remove as removeGbdevicechannel
|
|
|
+ } from "@/api/device/gb/gbdevicechannel.js"
|
|
|
+ import videoDeviceForm from "./comps/video-device-form.vue"
|
|
|
+ //地图
|
|
|
import {
|
|
|
- edit,
|
|
|
- updateBatch,
|
|
|
- getList,
|
|
|
- remove
|
|
|
- } from "@/api/device/doordevice.js"
|
|
|
+ deepClone
|
|
|
+ } from '@/util/util.js'
|
|
|
+ import * as mapUtil from "./js/mapUtil.js"
|
|
|
+
|
|
|
let _this = this
|
|
|
let TMap, map, markers, editor, geocoder;
|
|
|
let infoWindow; //窗口
|
|
|
export default {
|
|
|
components: {
|
|
|
deviceList,
|
|
|
- doorDeviceForm
|
|
|
+ doorDeviceForm,
|
|
|
+ videoDeviceForm
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ //0:门禁设备 1:监控设备
|
|
|
+ refName: 'doorDeviceForm',
|
|
|
+ activeIndex: 0,
|
|
|
+
|
|
|
markerGeometries: [],
|
|
|
|
|
|
//0无操作,1添加操作,2修改操作,3移动操作
|
|
|
operaType: 0,
|
|
|
+ //监控设备不需要添加操作
|
|
|
+ needAdd: true,
|
|
|
operaEditItem: '',
|
|
|
|
|
|
dialogVisible: false,
|
|
|
@@ -114,11 +142,12 @@
|
|
|
},
|
|
|
async init() {
|
|
|
_this = this
|
|
|
- await this.getDoorDeviceCoordinates()
|
|
|
+ await this.getDeviceCoordinates()
|
|
|
this.initMap()
|
|
|
},
|
|
|
addDevice() {
|
|
|
infoWindow.close();
|
|
|
+ this.removeEditRemark()
|
|
|
if (this.operaType == 1) {
|
|
|
this.operaType = 0
|
|
|
} else {
|
|
|
@@ -157,28 +186,60 @@
|
|
|
//再打开窗口
|
|
|
this.openInfoWindow(item)
|
|
|
},
|
|
|
- // animation:qq.maps.MarkerAnimation.DROP,
|
|
|
+ //组件事件
|
|
|
+ async selectDevice(index) {
|
|
|
+ this.needAdd = true
|
|
|
+ this.activeIndex = index
|
|
|
+ //重新获取坐标集合
|
|
|
+ await this.getDeviceCoordinates()
|
|
|
+ //重新更新坐标集合
|
|
|
+ if (index == 0) {
|
|
|
+ this.refName = 'doorDeviceForm'
|
|
|
+ this.updateGeometries()
|
|
|
+ } else if (index == 1) {
|
|
|
+ this.needAdd = false
|
|
|
+ this.refName = 'videoDeviceForm'
|
|
|
+ this.updateGeometries('videoDevice')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 移除编辑中的点
|
|
|
+ */
|
|
|
+ removeEditRemark() {
|
|
|
+ let geometries = deepClone(markers.geometries) || null
|
|
|
+ if (geometries) {
|
|
|
+ let editItem = geometries.find(item => item.id.indexOf('edit') >= 0)
|
|
|
+ if (editItem) {
|
|
|
+ markers.remove([editItem.id])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
clickDevice(item) {
|
|
|
+ //先关闭窗口
|
|
|
+ infoWindow.close();
|
|
|
let flag = this.coordinates.some(line => line.id == item.id)
|
|
|
if (flag) {
|
|
|
+ this.operaType = 0
|
|
|
+ //移除编辑中的点
|
|
|
+ this.removeEditRemark()
|
|
|
map.setCenter(new TMap.LatLng(item.latitude, item.longitude))
|
|
|
- //先关闭窗口
|
|
|
- infoWindow.close();
|
|
|
//再打开窗口
|
|
|
this.openInfoWindow(item)
|
|
|
return
|
|
|
}
|
|
|
this.operaType = 2
|
|
|
- //选取设备坐标
|
|
|
+ //点击的id
|
|
|
let id = item.id + 'edit'
|
|
|
- //获取所有的标记点,如果存在编辑中的标记,先移除再添加
|
|
|
- let geometries = deepClone(markers.geometries) || null
|
|
|
- if (geometries) {
|
|
|
- let editItem = geometries.find(item => item.id.indexOf('edit') >= 0)
|
|
|
- if (editItem) {
|
|
|
- markers.remove([editItem.id])
|
|
|
- }
|
|
|
+
|
|
|
+ //重复点击相同的设备,则取消操作
|
|
|
+ let activeMarkers = markers.getGeometryById(id)
|
|
|
+ if (this.$isNotEmpty(activeMarkers)) {
|
|
|
+ this.operaType = 0
|
|
|
+ this.removeEditRemark()
|
|
|
+ return
|
|
|
}
|
|
|
+ //获取所有的标记点,如果存在编辑中的标记,先移除再添加
|
|
|
+ this.removeEditRemark()
|
|
|
this.operaEditItem = item
|
|
|
let position = map.getCenter()
|
|
|
this.addMarkers(id, position, this.operaEditItem.name)
|
|
|
@@ -189,12 +250,16 @@
|
|
|
message: '请点击地图选取设备坐标',
|
|
|
duration: 6000
|
|
|
});
|
|
|
-
|
|
|
},
|
|
|
//获取设备坐标集合
|
|
|
- async getDoorDeviceCoordinates() {
|
|
|
- let res = await getDoorDeviceCoordinates()
|
|
|
- this.coordinates = res.data.data
|
|
|
+ async getDeviceCoordinates() {
|
|
|
+ console.log("123");
|
|
|
+ this.coordinates = []
|
|
|
+ if (this.activeIndex == 0) {
|
|
|
+ this.coordinates = (await getDoorDeviceCoordinates()).data.data
|
|
|
+ } else if (this.activeIndex == 1) {
|
|
|
+ this.coordinates = (await getVideoDeviceCoordinates()).data.data
|
|
|
+ }
|
|
|
},
|
|
|
async initMap() {
|
|
|
let scripts = ['https://map.qq.com/api/gljs?libraries=service&v=1.exp',
|
|
|
@@ -262,22 +327,31 @@
|
|
|
|
|
|
})
|
|
|
},
|
|
|
- confirmEdit() {
|
|
|
+ async confirmEdit() {
|
|
|
//旧的标记会带有edit字符,保存成功后需要移除edit字符
|
|
|
let id = this.operaEditItem.id + 'edit'
|
|
|
let old = markers.getGeometryById(id)
|
|
|
let model = {
|
|
|
id: this.operaEditItem.id,
|
|
|
latitude: old.position.lat,
|
|
|
- longitude: old.position.lng
|
|
|
+ longitude: old.position.lng,
|
|
|
}
|
|
|
- this.$confirm(`确定选取该坐标作为设备【${this.operaEditItem.name}】的坐标?`, {
|
|
|
+ let position = new TMap.LatLng(old.position.lat, old.position.lng)
|
|
|
+ model.address = await this.getAddress(position)
|
|
|
+
|
|
|
+ this.$confirm(`确定选取【${model.address}】作为设备【${this.operaEditItem.name}】的坐标?`, {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
type: "success"
|
|
|
})
|
|
|
.then(() => {
|
|
|
- return edit(model);
|
|
|
+ let flag = false
|
|
|
+ if (this.activeIndex == 0) {
|
|
|
+ flag = editDoordevice(model)
|
|
|
+ } else if (this.activeIndex == 1) {
|
|
|
+ flag = editGbdevicechannel(model)
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
})
|
|
|
.then(() => {
|
|
|
this.$refs.deviceList.fetchDeviceList()
|
|
|
@@ -315,14 +389,14 @@
|
|
|
let id = 'add'
|
|
|
let geometries = deepClone(markers.geometries) || null
|
|
|
if (!geometries) {
|
|
|
- _this.addMarkers(id, position)
|
|
|
- _this.$refs.doorDeviceForm.showAddForm(model)
|
|
|
+ this.addMarkers(id, position)
|
|
|
+ this.$refs[this.refName].showAddForm(model)
|
|
|
return
|
|
|
}
|
|
|
let flag = geometries.find(item => item.id == "add")
|
|
|
if (!flag) {
|
|
|
_this.addMarkers(id, position)
|
|
|
- _this.$refs.doorDeviceForm.showAddForm(model)
|
|
|
+ this.$refs[this.refName].showAddForm(model)
|
|
|
return
|
|
|
}
|
|
|
markers.updateGeometries([{
|
|
|
@@ -331,7 +405,7 @@
|
|
|
styleId: 'addStyle',
|
|
|
content: '点击地图选点',
|
|
|
}])
|
|
|
- _this.$refs.doorDeviceForm.showAddForm(model)
|
|
|
+ this.$refs[this.refName].showAddForm(model)
|
|
|
},
|
|
|
addMarkers(id, position, content = '点击地图选点', styleId = 'addStyle') {
|
|
|
markers.add([{
|
|
|
@@ -403,6 +477,24 @@
|
|
|
"strokeColor": '#fff', // 标注点文本描边颜色
|
|
|
"strokeWidth": 2, // 标注点文本描边宽度
|
|
|
}),
|
|
|
+ "videoDevice": new TMap.MarkerStyle({
|
|
|
+ "width": 30,
|
|
|
+ "height": 30,
|
|
|
+ "anchor": {
|
|
|
+ x: 16,
|
|
|
+ y: 36
|
|
|
+ },
|
|
|
+ "src": '/img/icon/video-device4.png',
|
|
|
+ "color": '#333', // 标注点文本颜色
|
|
|
+ "size": 14, // 标注点文本文字大小
|
|
|
+ "direction": 'bottom', // 标注点文本文字相对于标注点图片的方位
|
|
|
+ "offset": {
|
|
|
+ x: 0,
|
|
|
+ y: 2
|
|
|
+ }, // 标注点文本文字基于direction方位的偏移属性
|
|
|
+ "strokeColor": '#fff', // 标注点文本描边颜色
|
|
|
+ "strokeWidth": 2, // 标注点文本描边宽度
|
|
|
+ }),
|
|
|
"addStyle": new TMap.MarkerStyle({
|
|
|
"width": 30,
|
|
|
"height": 30,
|
|
|
@@ -424,22 +516,29 @@
|
|
|
},
|
|
|
geometries: []
|
|
|
});
|
|
|
+ this.updateGeometries()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 更新标记集合
|
|
|
+ */
|
|
|
+ updateGeometries(styleId = 'marker') {
|
|
|
//更新标点坐标
|
|
|
if (this.$isEmpty(this.coordinates)) {
|
|
|
+ markers.setGeometries([])
|
|
|
return
|
|
|
}
|
|
|
let geometries = []
|
|
|
this.coordinates.forEach((item) => {
|
|
|
let obj = {
|
|
|
- "id": item.id,
|
|
|
- "styleId": 'marker',
|
|
|
- "content": item.name,
|
|
|
- "position": new TMap.LatLng(item.latitude, item.longitude),
|
|
|
- "properties": item,
|
|
|
+ id: item.id,
|
|
|
+ styleId,
|
|
|
+ content: item.name,
|
|
|
+ position: new TMap.LatLng(item.latitude, item.longitude),
|
|
|
+ properties: item,
|
|
|
}
|
|
|
geometries.push(obj)
|
|
|
})
|
|
|
- markers.updateGeometries(geometries);
|
|
|
+ markers.setGeometries(geometries);
|
|
|
//点击标记弹出信息窗口
|
|
|
let position = new TMap.LatLng(this.coordinates[0].latitude, this.coordinates[0].longitude)
|
|
|
//初始化infoWindow
|
|
|
@@ -461,6 +560,7 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
//开启标记拖动
|
|
|
markersDrag() {
|
|
|
// 初始化几何图形及编辑器
|
|
|
@@ -501,19 +601,13 @@
|
|
|
_this.delDevice(data)
|
|
|
});
|
|
|
},
|
|
|
- operaMarkers() {
|
|
|
- if (this.operaType == 3) {
|
|
|
- this.save()
|
|
|
- } else {
|
|
|
- this.move()
|
|
|
- }
|
|
|
- },
|
|
|
cancelMove() {
|
|
|
markers.updateGeometries(this.markerGeometries)
|
|
|
this.operaType = 0
|
|
|
editor.setSelectable(false)
|
|
|
},
|
|
|
move() {
|
|
|
+ this.removeEditRemark()
|
|
|
//移动前先把旧的数据保存起来
|
|
|
this.markerGeometries = deepClone(markers.getGeometries())
|
|
|
console.log(this.markerGeometries, "oldMarkerGeometries");
|
|
|
@@ -527,9 +621,11 @@
|
|
|
infoWindow.close()
|
|
|
markers.remove(["add"])
|
|
|
this.operaType = 3
|
|
|
+ console.log(this.operaType);
|
|
|
editor.setSelectable(true)
|
|
|
},
|
|
|
async save() {
|
|
|
+ this.removeEditRemark()
|
|
|
this.operaType = 0
|
|
|
editor.setSelectable(false)
|
|
|
let oldMarkers = this.markerGeometries
|
|
|
@@ -553,21 +649,28 @@
|
|
|
updateObj.push(model)
|
|
|
}
|
|
|
})
|
|
|
- console.log(updateObj, "updateObj");
|
|
|
- if (this.$isNotEmpty(updateObj)) {
|
|
|
- let res = await updateBatch(updateObj)
|
|
|
- if (res.data.success) {
|
|
|
- this.$message.success('操作成功')
|
|
|
- }
|
|
|
+ if (this.$isEmpty(updateObj)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let flag = false
|
|
|
+ if (this.activeIndex == 0) {
|
|
|
+ flag = (await updateDoordeviceBatch(updateObj)).data.success
|
|
|
+ } else if (this.activeIndex == 1) {
|
|
|
+ flag = (await updateGbdevicechannelBatch(updateObj)).data.success
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ } else {
|
|
|
+ this.$message.error('操作失败')
|
|
|
}
|
|
|
},
|
|
|
detail(data) {
|
|
|
infoWindow.close();
|
|
|
- _this.$refs.doorDeviceForm.showDialog(data)
|
|
|
+ _this.$refs[this.refName].showDialog(data)
|
|
|
},
|
|
|
edit(data) {
|
|
|
infoWindow.close();
|
|
|
- _this.$refs.doorDeviceForm.showDialog(data, false)
|
|
|
+ _this.$refs[this.refName].showDialog(data, false)
|
|
|
},
|
|
|
delDevice(data) {
|
|
|
//先关闭窗口
|
|
|
@@ -578,7 +681,13 @@
|
|
|
type: "warning"
|
|
|
})
|
|
|
.then(() => {
|
|
|
- return remove(data.id);
|
|
|
+ let flag = false
|
|
|
+ if (this.activeIndex == 0) {
|
|
|
+ flag = removeDoordevice(data.id)
|
|
|
+ } else if (this.activeIndex == 1) {
|
|
|
+ flag = removeGbdevicechannel(data.id)
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
})
|
|
|
.then(() => {
|
|
|
//更新设备列表
|
|
|
@@ -592,12 +701,48 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ dropdownClick(evt) {
|
|
|
+ let name = evt.name
|
|
|
+ let data = evt.data
|
|
|
+ switch (name) {
|
|
|
+ case '详情':
|
|
|
+ this.detail(data)
|
|
|
+ break;
|
|
|
+ case '编辑':
|
|
|
+ this.edit(data)
|
|
|
+ break;
|
|
|
+ case '删除':
|
|
|
+ this.delDevice(data)
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
+ /deep/ .el-input__inner {
|
|
|
+ -webkit-appearance: none;
|
|
|
+ background-color: #fff;
|
|
|
+ background-image: none;
|
|
|
+ -webkit-box-sizing: border-box;
|
|
|
+ box-sizing: border-box;
|
|
|
+ color: #606266;
|
|
|
+ display: inline-block;
|
|
|
+ font-size: inherit;
|
|
|
+ height: 38px;
|
|
|
+ line-height: 38px;
|
|
|
+ outline: 0;
|
|
|
+ padding: 0 15px;
|
|
|
+ -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
|
+ transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
.device-body {
|
|
|
height: 100%;
|
|
|
margin: 0px;
|