Commit bbcb5415 authored by 耿迪迪's avatar 耿迪迪

设备管理新增编辑删除 gengdidi

parent 832648c0
...@@ -5,14 +5,17 @@ import flowMeter from "../components/PopWindow/flowMeter.vue" ...@@ -5,14 +5,17 @@ import flowMeter from "../components/PopWindow/flowMeter.vue"
import dutyPerson from "../components/PopWindow/dutyPerson.vue" import dutyPerson from "../components/PopWindow/dutyPerson.vue"
let defaultCenter = "石家庄"; let defaultCenter = "石家庄";
export let map; export let map;
const PIPEPLINE = "1"; export const DEVICE_TYPE = {
const REGEULATORBOX = "2"; PIPEPLINE : "1",
const VALUEWELL = "3"; REGEULATORBOX : "2",
const FLOWMETER = "4"; VALUEWELL : "3",
const DUTYPERSON = "5"; FLOWMETER : "4",
DUTYPERSON : "5"
}
class gaodeMap { class gaodeMap {
//构造函数中设置中央点默认值 //构造函数中设置中央点默认值
constructor(center) { constructor(center) {
this.markers = [];
this.center = center?center:defaultCenter; this.center = center?center:defaultCenter;
map = new AMap.Map('container', { map = new AMap.Map('container', {
//mask: addMask(result.districtList[0].boundaries), //mask: addMask(result.districtList[0].boundaries),
...@@ -80,9 +83,12 @@ const DUTYPERSON = "5"; ...@@ -80,9 +83,12 @@ const DUTYPERSON = "5";
/** /**
* 添加Market * 添加Market
* @param markerType
* @param lnglats * @param lnglats
*/ */
addMarker(lnglats){ addMarker(markerType,lnglats){
let that = this;
that.markerType = markerType;
let infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(-13, -70)}); let infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(-13, -70)});
for (let i = 0; i < lnglats.length; i++) { for (let i = 0; i < lnglats.length; i++) {
let marker = new AMap.Marker({ let marker = new AMap.Marker({
...@@ -95,31 +101,32 @@ const DUTYPERSON = "5"; ...@@ -95,31 +101,32 @@ const DUTYPERSON = "5";
// 设置拖拽效果 // 设置拖拽效果
raiseOnDrag: true raiseOnDrag: true
}); });
marker.content = '<h4>我是第' + (i + 1) + '个XXX</h4>'; marker.content = this.getMarketContent("data");
marker.content += '<h6>经度:'+lnglats[i][0]+'</h6>';
marker.content += '<h6>纬度:'+lnglats[i][1]+'</h6>';
marker.content += '<button class="btn btn-success btn-xs">历史轨迹</button>';
marker.content += '<button class="btn btn-warning btn-xs">实时跟踪 </button>';
marker.content += '<button class="btn btn-danger btn-xs">设置</button>';
marker.on('mouseover', infoOpen); marker.on('mouseover', infoOpen);
//注释后打开地图时默认关闭信息窗体
//marker.emit('mouseover', {target: marker});
marker.on('mouseout', infoClose); marker.on('mouseout', infoClose);
marker.on('click', newMAp); that.deviceType = markerType;
marker.on('dragend', moveMarker); let editWindow = that.createInfowindow();
marker.on('click', function(e){
if("edit" == that.mapOperateType){
editWindow.show();
}else if("delete" == that.mapOperateType){
if(confirm("确认删除")== true){
map.remove(marker);
} }
map.setFitView();
//鼠标点击事件,设置地图中心点及放大显示级别 }else{
function newMAp(e) {
//map.setCenter(e.target.getPosition());
map.setZoomAndCenter(13, e.target.getPosition()); map.setZoomAndCenter(13, e.target.getPosition());
let infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(-13, -70)}); let infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(-13, -70)});
infoWindow.setContent(e.target.content); infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition()); infoWindow.open(map, e.target.getPosition());
} }
});
marker.on('dragend', function (e) {
alert(e.lnglat);
});
//this.markers.push(marker);
}
map.setFitView();
function infoClose(e) { function infoClose(e) {
infoWindow.close(map, e.target.getPosition()); infoWindow.close(map, e.target.getPosition());
...@@ -130,8 +137,45 @@ const DUTYPERSON = "5"; ...@@ -130,8 +137,45 @@ const DUTYPERSON = "5";
infoWindow.open(map, e.target.getPosition()); infoWindow.open(map, e.target.getPosition());
} }
function moveMarker(e) { }
alert(e.lnglat);
/**
* 添加marker信息
* @param data
* @returns {string}
*/
getMarketContent(data){
let html = "<div>" +
"<table>" +
"<tr>" +
"<td>所属燃气公司</td>" +
"<td>正元</td>" +
"</tr>" +
"<tr>" +
"<td>名称</td>" +
"<td>1234</td>" +
"</tr>" +
"<tr>" +
"<td>地址</td>" +
"<td>石家庄市新华区</td>" +
"</tr>" +
"</table>" +
"</div>";
switch (this.markerType){
case DEVICE_TYPE.REGEULATORBOX :{
return html;
}
case DEVICE_TYPE.VALUEWELL :{
return html;
}
case DEVICE_TYPE.FLOWMETER :{
return html;
}
case DEVICE_TYPE.DUTYPERSON :{
return html;
}
} }
} }
...@@ -183,7 +227,6 @@ const DUTYPERSON = "5"; ...@@ -183,7 +227,6 @@ const DUTYPERSON = "5";
this.mouseTool.on('draw',function(e){ this.mouseTool.on('draw',function(e){
const device = that.createInfowindow(); const device = that.createInfowindow();
e.obj.on("click",function (aa) { e.obj.on("click",function (aa) {
console.log(aa.target._position,"==============");
let postion = aa.target._position; let postion = aa.target._position;
device.editForm.longitude = postion.lng; device.editForm.longitude = postion.lng;
device.editForm.latitude = postion.lat; device.editForm.latitude = postion.lat;
...@@ -199,25 +242,25 @@ const DUTYPERSON = "5"; ...@@ -199,25 +242,25 @@ const DUTYPERSON = "5";
*/ */
createInfowindow(){ createInfowindow(){
switch (this.deviceType){ switch (this.deviceType){
case PIPEPLINE :{ case DEVICE_TYPE.PIPEPLINE :{
break; break;
} }
case REGEULATORBOX :{ case DEVICE_TYPE.REGEULATORBOX :{
return createPop(regulatorBox, { return createPop(regulatorBox, {
title: '调压箱' title: '调压箱'
}); });
} }
case VALUEWELL :{ case DEVICE_TYPE.VALUEWELL :{
return createPop(valveWell, { return createPop(valveWell, {
title: '阀门井' title: '阀门井'
}); });
} }
case FLOWMETER :{ case DEVICE_TYPE.FLOWMETER :{
return createPop(flowMeter, { return createPop(flowMeter, {
title: '流量计' title: '流量计'
}); });
} }
case DUTYPERSON :{ case DEVICE_TYPE.DUTYPERSON :{
return createPop(dutyPerson, { return createPop(dutyPerson, {
title: '值班人员' title: '值班人员'
}); });
...@@ -233,34 +276,18 @@ const DUTYPERSON = "5"; ...@@ -233,34 +276,18 @@ const DUTYPERSON = "5";
draw(deviceType){ draw(deviceType){
let that = this; let that = this;
that.deviceType = deviceType; that.deviceType = deviceType;
if(REGEULATORBOX == deviceType || VALUEWELL == deviceType || FLOWMETER == deviceType || DUTYPERSON == deviceType){ if(DEVICE_TYPE.REGEULATORBOX == deviceType || DEVICE_TYPE.VALUEWELL == deviceType || DEVICE_TYPE.FLOWMETER == deviceType || DEVICE_TYPE.DUTYPERSON == deviceType){
that.mouseTool.marker({
draggable: true
});
}
if(PIPEPLINE == deviceType){
that.mouseTool.polyline({
strokeWeight: 9,
strokeColor:'#80d8ff'
//同Polyline的Option设置
});
}
/*switch(type){
case 'marker':{
that.mouseTool.marker({ that.mouseTool.marker({
draggable: true draggable: true
}); });
break;
} }
case 'polyline':{ if(DEVICE_TYPE.PIPEPLINE == deviceType){
that.mouseTool.polyline({ that.mouseTool.polyline({
strokeWeight: 9, strokeWeight: 9,
strokeColor:'#80d8ff' strokeColor:'#80d8ff'
//同Polyline的Option设置 //同Polyline的Option设置
}); });
break;
} }
}*/
} }
/** /**
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</template> </template>
<script> <script>
import gaodeMap from "utils/gaodeMap.js" import gaodeMap from "utils/gaodeMap.js"
import {map} from "utils/gaodeMap.js" import {map, DEVICE_TYPE, mapOperateType} from "utils/gaodeMap.js"
export default { export default {
data() { data() {
return { return {
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
[114.522668,38.042962], [114.522668,38.042962],
[114.383966,38.091548] [114.383966,38.091548]
]; ];
gaoMap.addMarker(lnglats) gaoMap.addMarker(DEVICE_TYPE.REGEULATORBOX,lnglats)
let path = [ let path = [
[ [
[114.436698,38.083306], [114.436698,38.083306],
...@@ -72,20 +72,20 @@ ...@@ -72,20 +72,20 @@
methods:{ methods:{
addDevice(){ addDevice(){
this.deviceType = true; this.deviceType = true;
this.operationType = "add"; this.gaoMap.mapOperateType = "add";
}, },
editDevice(){ editDevice(){
this.deviceType = false; this.deviceType = false;
this.operationType = "edit"; this.gaoMap.mapOperateType = "edit";
}, },
deleteDevice(){ deleteDevice(){
this.deviceType = false; this.deviceType = false;
this.operationType = "delete"; this.gaoMap.mapOperateType = "delete";
}, },
selectDeviceType(val){ selectDeviceType(val){
if("add" == this.operationType){ // if("add" == this.operationType){
this.gaoMap.draw(val) this.gaoMap.draw(val)
} // }
this.deviceType = false; this.deviceType = false;
this.value = ""; this.value = "";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment