赖素文
authored
|
1
|
|
赖素文
authored
|
2
|
let action = null;
|
赖素文
authored
|
3
|
let mapObj = null;
|
赖素文
authored
|
4
|
var app = null;
|
赖素文
authored
|
5
|
|
赖素文
authored
|
6
7
8
9
10
11
12
13
14
15
16
17
18
|
layui.config({
base: "/js/",
version: 1
}).use(['system'], function () {
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sysU = new system.u(),
sendDataWhere = null,
areaName = "configure",
controllerName = "BaseProject",
|
赖素文
authored
|
19
|
vueApp = null;
|
赖素文
authored
|
20
21
22
23
24
25
26
|
action = {
}
app = {
data: {
|
赖素文
authored
|
27
|
mapEle: "container",
|
赖素文
authored
|
28
29
|
},
methods: {
|
赖素文
authored
|
30
31
32
|
/**
* 初始化地图
*/
|
赖素文
authored
|
33
34
35
|
initMap() {
mapObj = mapApp(app.data.mapEle).initMap();
},
|
赖素文
authored
|
36
37
38
|
/**
* 获取项目数据
*/
|
赖素文
authored
|
39
|
getProjectDataList() {
|
赖素文
authored
|
40
|
var ajaxConfig = {
|
赖素文
authored
|
41
|
data: { pageRequest: null, entity: { flag: "projectMapList" } },
|
赖素文
authored
|
42
43
44
|
url: `/configure/BaseProject/Load`,
success: function (result) {
if (sysU.successBefore(result)) return false;
|
赖素文
authored
|
45
46
47
|
app.methods.createMarkerInfo(result);
app.methods.initVueDataValue(result);
app.methods.createSidebarList(result);
|
赖素文
authored
|
48
49
50
51
|
}
};
sysU.ajax(ajaxConfig);
},
|
赖素文
authored
|
52
53
54
|
/**
* 创建marker标注
*/
|
赖素文
authored
|
55
|
createMarkerInfo(json) {
|
赖素文
authored
|
56
57
|
json.Result.forEach(item => {
var content = `<h4 style = 'margin:0;'>${item.projectAddress}</h4>
|
赖素文
authored
|
58
59
|
设备总数:${item.eqCount}、在线:<span style='color:blue;'>${item.eqOnLine}</span>、待机:${item.eqOff}、故障:<span style='color:red;'>${item.eqAlarm}</span>
<div style = 'display: flex;' >
|
赖素文
authored
|
60
|
<div><a style='text-decoration: underline;color: blue;' onclick='app.methods.mapMarkerClick(${JSON.stringify(item)})' href='#'>项目概述</a></div>
|
赖素文
authored
|
61
|
</div >` ;//定义大标题 写html语句标签
|
赖素文
authored
|
62
|
mapObj.createMarkerInfo(content, {
|
赖素文
authored
|
63
|
title: "项目名称:" + item.projectName,
|
赖素文
authored
|
64
|
longitude: item.longitude,
|
赖素文
authored
|
65
66
|
latitude: item.latitude,
id: item.id
|
赖素文
authored
|
67
68
69
|
});
})
},
|
赖素文
authored
|
70
|
|
赖素文
authored
|
71
|
mapMarkerClick(item) {
|
赖素文
authored
|
72
73
|
var url = `/configure/BaseProject/ProjectOverview?id=${item.id}&keys=${item.keys}&projectName=${item.projectName}`;
var urlHtml = $(`<a title="项目概述" data-url="${url}"><i class="layui-icon" data-icon=""></i><cite>项目概述</cite></a>`)
|
赖素文
authored
|
74
|
window.top.tab.tabAdd(urlHtml);
|
赖素文
authored
|
75
76
77
78
79
80
|
},
/**
* 创建右侧项目列表
*/
createSidebarList(json) {
var sidebarList = [];
|
赖素文
authored
|
81
|
var index = 1;
|
赖素文
authored
|
82
|
json.Result.forEach(item => {
|
赖素文
authored
|
83
|
var content = `<dd><a class='projectListA' onclick='app.methods.findLocateMarker(${item.id.toString()},event)' href="javascript:;">【${index++}】${item.projectName}</a></dd>`;//定义大标题 写html语句标签
|
赖素文
authored
|
84
85
86
87
88
89
90
91
92
|
sidebarList.push(content)
})
if (sidebarList.length > 0) {
$(".sidebar-list-item").empty().append(sidebarList.join(" "))
}
},
/**
* 查找Marker并打开对应的infoWindow信息框
*/
|
赖素文
authored
|
93
|
findLocateMarker(markerId, event) {
|
赖素文
authored
|
94
|
mapObj.getLocateMarker(markerId);
|
赖素文
authored
|
95
96
|
$(".projectListA").css("color", "rgba(255, 255, 255, .7)")
$(event.currentTarget).css("color", "#42b983")
|
赖素文
authored
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
},
/**
* 初始化vue
*/
initVue: function () {
vueApp = new Vue({
el: '.vueApp',
data: {
footer: {
projectCount: 0,
eqCount: 0,
eqOnlineRate: "",
eqTuoRate: "",
}
},
methods: {
}
});
},
/**
* vue 集合赋值
*/
|
赖素文
authored
|
120
|
initVueDataValue: (result) => {
|
赖素文
authored
|
121
122
123
124
|
vueApp.footer.projectCount = result.Result.length;
vueApp.footer.eqCount = 12;
vueApp.footer.eqOnlineRate = "16.67%";
vueApp.footer.eqTuoRate = "89.67%";
|
赖素文
authored
|
125
126
127
|
}
},
registerEvent: function () {
|
赖素文
authored
|
128
129
|
},
|
赖素文
authored
|
130
131
|
init: function () {
app.methods.initMap();
|
赖素文
authored
|
132
133
|
app.methods.initVue();
app.methods.getProjectDataList();
|
赖素文
authored
|
134
|
app.registerEvent();
|
赖素文
authored
|
135
|
}
|
赖素文
authored
|
136
137
138
|
};
app.init();
});
|