Commit 9589d331 authored by Administrator's avatar Administrator

地图模式

parent b77aceea
...@@ -14,3 +14,10 @@ export function users() { ...@@ -14,3 +14,10 @@ export function users() {
method: 'get', method: 'get',
}); });
} }
export function deviceinfo(id) {
return request({
url: '/devices/device_info/' + id,
method: 'get',
});
}
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
></el-amap-circle-marker> ></el-amap-circle-marker>
<!-- 右上角设备和用户切换按钮 --> <!-- 右上角设备和用户切换按钮 -->
<div class="toolbar"> <div class="toolbar">
<el-button type="primary" size="mini" round @click="allDevices">全部设备</el-button>
<el-switch <el-switch
v-model="markersDeviceVisible" v-model="markersDeviceVisible"
active-text="设备" active-text="设备"
...@@ -65,7 +66,7 @@ ...@@ -65,7 +66,7 @@
<el-collapse v-model="activeNames"> <el-collapse v-model="activeNames">
<el-collapse-item name="1"> <el-collapse-item name="1">
<template slot="title"> <template slot="title">
设备列表<i class="header-icon el-icon-info"></i> 设备列表 - {{ leftDeviceName }}
</template> </template>
<el-table :data="markersDevice" style="100%" max-height="700"> <el-table :data="markersDevice" style="100%" max-height="700">
<el-table-column property="devicenum" label="设备编号" width="200px"></el-table-column> <el-table-column property="devicenum" label="设备编号" width="200px"></el-table-column>
...@@ -89,7 +90,7 @@ ...@@ -89,7 +90,7 @@
import Vue from 'vue'; import Vue from 'vue';
import VueAMap from 'vue-amap'; import VueAMap from 'vue-amap';
import { AMapManager } from 'vue-amap'; import { AMapManager } from 'vue-amap';
import { devices, users } from '@/api/map'; import { devices, users, deviceinfo } from '@/api/map';
Vue.use(VueAMap); Vue.use(VueAMap);
...@@ -125,7 +126,6 @@ export default { ...@@ -125,7 +126,6 @@ export default {
return ''; return '';
} }
mapcenter = mapcenter.replace(/\s*/g, ''); mapcenter = mapcenter.replace(/\s*/g, '');
// console.log(mapcenter.split(','));
return mapcenter.split(','); return mapcenter.split(',');
}, },
deviceLocationFilter(center) { deviceLocationFilter(center) {
...@@ -179,9 +179,7 @@ export default { ...@@ -179,9 +179,7 @@ export default {
'moveend': () => { 'moveend': () => {
}, },
'zoomchange': () => { 'zoomchange': () => {
// console.log('zoom:', _this.$refs.map);
_this.zoom = this.$refs.map.$$getInstance().getZoom(); _this.zoom = this.$refs.map.$$getInstance().getZoom();
console.log(_this.zoom);
}, },
'click': (e) => { 'click': (e) => {
// alert('map clicked'); // alert('map clicked');
...@@ -206,6 +204,8 @@ export default { ...@@ -206,6 +204,8 @@ export default {
deviceListVisible: true, // 用户设备列表是否显示 deviceListVisible: true, // 用户设备列表是否显示
activeNames: ['1'], // 左侧设备列表默认打开 activeNames: ['1'], // 左侧设备列表默认打开
markerUserZIndex: 100, markerUserZIndex: 100,
deviceAll: undefined,
leftDeviceName: '全部设备',
}; };
}, },
watch: { watch: {
...@@ -217,16 +217,22 @@ export default { ...@@ -217,16 +217,22 @@ export default {
// const users = devices.users(); // const users = devices.users();
users() users()
.then(res => { .then(res => {
console.log(res.data);
this.markers = res.data; this.markers = res.data;
}); });
devices({}) devices({})
.then(res => { .then(res => {
console.log(res.data);
this.markersDevice = res.data; this.markersDevice = res.data;
}); });
}, },
methods: { methods: {
allDevices() {
devices()
.then(res => {
this.leftDeviceName = '全部设备';
this.markersDevice = res.data;
this.zoom = 6;
});
},
getUserDevices(center) { getUserDevices(center) {
// alert(userid); // alert(userid);
this.zoom = 12; this.zoom = 12;
...@@ -234,18 +240,14 @@ export default { ...@@ -234,18 +240,14 @@ export default {
this.markerVisible = true; this.markerVisible = true;
this.markersDeviceVisible = true; this.markersDeviceVisible = true;
}, },
getDeviceInfo(device) {
console.log(device);
alert('deviceInfo');
},
rebuildEvent(marker) { rebuildEvent(marker) {
var mapcenter = marker.mapcenter.replace(/\s*/g, ''); var mapcenter = marker.mapcenter.replace(/\s*/g, '');
// console.log(mapcenter);
const that = this; const that = this;
const position = mapcenter.split(','); const position = mapcenter.split(',');
return { return {
click(e) { click(e) {
// alert(that.zoom); // alert(that.zoom);
that.leftDeviceName = marker.nickname;
that.getUserDevices(position); that.getUserDevices(position);
that.deviceListVisible = true; that.deviceListVisible = true;
that.markerUserZIndex = 1000; that.markerUserZIndex = 1000;
...@@ -257,20 +259,7 @@ export default { ...@@ -257,20 +259,7 @@ export default {
const that = this; const that = this;
return { return {
click(e) { click(e) {
console.log(marker); that.getUserDeviceInfo(marker.id);
// const position = marker.devicecoord.replace(/\s*/g, '');
// console.log(position.split(','));
that.gridData = [
{
title: '设备编号',
content: marker.devicenum,
},
{
title: '坐标',
content: marker.devicecoord,
},
];
that.dialogTableVisible = true;
}, },
}; };
}, },
...@@ -278,10 +267,55 @@ export default { ...@@ -278,10 +267,55 @@ export default {
getUserDeviceList(uid) { getUserDeviceList(uid) {
devices({ uid: uid }) devices({ uid: uid })
.then(res => { .then(res => {
console.log(res.data);
this.markersDevice = res.data; this.markersDevice = res.data;
}); });
}, },
// 获取设备详细信息
getUserDeviceInfo(id) {
deviceinfo(id)
.then(res => {
this.dialogTableVisible = true;
const deviceInfo = res.data;
this.gridData = [
{
title: '设备编号',
content: deviceInfo.devicenum,
},
{
title: '坐标',
content: deviceInfo.devicecoord,
},
{
title: '设备类型',
content: deviceInfo.tname,
},
{
title: '用户',
content: deviceInfo.usernickname,
},
{
title: '检测介质',
content: deviceInfo.gas,
},
{
title: '状态',
content: deviceInfo.status_name,
},
{
title: '安装位置',
content: deviceInfo.deviceinfo,
},
{
title: '联系人',
content: deviceInfo.devicelinkman,
},
{
title: '电话',
content: deviceInfo.devicephone,
},
];
});
},
}, },
}; };
</script> </script>
......
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