Map.vue
2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div>
<div class="menu-search">
<el-input
placeholder="请输入对应条件值"
v-model="search.text"
size="small"
class="input-with-select"
>
<el-select
v-model="search.type"
slot="prepend"
placeholder="请选择"
size="small"
>
<el-option label="设备号" value="1"></el-option>
<el-option label="车架号" value="2"></el-option>
<el-option label="姓名" value="3"></el-option>
<el-option label="工单号" value="4"></el-option>
</el-select>
</el-input>
<el-button
icon="el-icon-search"
size="mini"
type="primary"
:loading="search.isSearching"
@click="searchSubmit"
>搜索</el-button
>
<el-button
:icon="search.showResult ? 'fa fa-caret-up' : 'fa fa-caret-down'"
size="mini"
type="primary"
@click="toggleResult"
></el-button>
</div>
</div>
</template>
<script>
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import "utils/mapEvent.js";
import MapMenu from "./MapMenu.vue";
import MapTable from "./MapTable.vue";
import MapControll from "./MapControll.vue";
import EventBus from "../../event-bus";
import { services } from "../../api";
import mock from "../../mock";
const MONITOR_SERVICE = services.monitor;
import { CONSTANT } from "../../constant";
export default {
data() {
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
};
},
methods: {
initMap() {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!this.mapObj
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
//this.bindEvent();
this.isInitMap = true;
} else {
this.checkMapLoaded = check();
}
}, 100);
};
this.checkMapLoaded = check();
},
},
async created() {
let _this = this;
_this.$mapInit({ version: "1.4.2" }).then((AMap) => {
_this.initMap();
});
},
beforeDestroy() {
this.offEvent();
this.monitorInterval && window.clearTimeout(this.monitorInterval);
},
components: {},
};
</script>
<style scoped>
.map-wrap {
position: absolute;
top: 100px;
left: 0;
width: 100%;
height: calc(100% - 100px);
overflow: hidden;
}
.map-container {
width: 100%;
height: 100%;
z-index: 100;
}
.el-loading-mask {
z-index: 101;
}
.menu-search {
position: absolute;
top: 20px;
left: 20px;
}
</style>