赖素文
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
20
|
sysNowClickEle = -1;
vueApp = null;
|
赖素文
authored
|
21
22
23
24
25
26
27
|
action = {
}
app = {
data: {
|
赖素文
authored
|
28
|
mapEle: "container",
|
王硕
authored
|
29
|
refreshDataTimeEle: document.getElementById('refreshDataTime')
|
赖素文
authored
|
30
31
|
},
methods: {
|
赖素文
authored
|
32
33
34
|
/**
* 初始化地图
*/
|
赖素文
authored
|
35
36
37
|
initMap() {
mapObj = mapApp(app.data.mapEle).initMap();
},
|
王硕
authored
|
38
|
|
赖素文
authored
|
39
40
41
|
/**
* 获取项目数据
*/
|
赖素文
authored
|
42
|
getProjectDataList() {
|
赖素文
authored
|
43
|
var ajaxConfig = {
|
赖素文
authored
|
44
45
|
data: null,
url: `/configure/BaseProject/GetProjectMapList`,
|
赖素文
authored
|
46
|
loading: false,
|
赖素文
authored
|
47
48
|
success: function (result) {
if (sysU.successBefore(result)) return false;
|
赖素文
authored
|
49
50
51
|
app.methods.createMarkerInfo(result);
app.methods.initVueDataValue(result);
app.methods.createSidebarList(result);
|
王硕
authored
|
52
53
54
|
if (sysNowClickEle != -1) {
$("#a_" + sysNowClickEle).click().css("color", "#42b983");
}
|
赖素文
authored
|
55
56
57
58
|
}
};
sysU.ajax(ajaxConfig);
},
|
赖素文
authored
|
59
60
61
|
/**
* 创建marker标注
*/
|
赖素文
authored
|
62
|
createMarkerInfo(json) {
|
王硕
authored
|
63
|
let index = 1
|
赖素文
authored
|
64
65
|
json.Result.list.forEach(item => {
var content = `<h4 style = 'margin:0;'>地址:${item.projectAddress}</h4>
|
HuXiYu
authored
|
66
|
设备总数:${item.eqCount}、
|
赖素文
authored
|
67
|
运行:<span style='color:blue;'>${item.eqRunCount}</span>、
|
赖素文
authored
|
68
69
70
|
待机:${item.eqFreeCount}
故障:${item.eqFailureCount}<br/>
离线(5m):<span style='color:red;'>${item.eqOfflineCount}</span>
|
赖素文
authored
|
71
|
<div style = 'display: flex;' >
|
赖素文
authored
|
72
73
|
<div><a style='text-decoration: underline;color: blue;' onclick='app.methods.projectOverviewClick(${JSON.stringify(item)})' href='#'>项目概述</a></div>
<div><a style='text-decoration: underline;color: blue;margin-left:12px' onclick='app.methods.projectAreasMapClick(${JSON.stringify(item)})' href='#'>项目设备区域图</a></div>
|
赖素文
authored
|
74
|
</div >` ;//定义大标题 写html语句标签
|
赖素文
authored
|
75
|
mapObj.createMarkerInfo(content, {
|
王硕
authored
|
76
|
title: `项目名称[${index++}]:` + item.projectName,
|
赖素文
authored
|
77
|
longitude: item.longitude,
|
赖素文
authored
|
78
79
|
latitude: item.latitude,
id: item.id
|
赖素文
authored
|
80
81
82
|
});
})
},
|
赖素文
authored
|
83
84
85
|
//项目概述点击
projectOverviewClick(item) {
var title = "项目概述";
|
赖素文
authored
|
86
87
|
localStorage.setItem("projectMapKeys", item.keys);
localStorage.setItem("projectMapName", item.projectName);
|
赖素文
authored
|
88
89
|
var tabsEle = window.parent.document.querySelectorAll("#top_tabs cite");
for (var i = 0; i < tabsEle.length; i++) {
|
赖素文
authored
|
90
|
if (tabsEle[i].innerText == title) {
|
赖素文
authored
|
91
92
93
94
|
$(tabsEle[i]).next().click()
break;
}
}
|
赖素文
authored
|
95
96
97
|
var url = `/configure/BaseProject/ProjectOverview?id=${item.id}&keys=${item.keys}&projectName=${item.projectName}`;
var urlHtml = $(`<a title="${title}" data-url="${url}"><i class="layui-icon" data-icon=""></i><cite>${title}</cite></a>`)
|
赖素文
authored
|
98
|
window.top.tab.tabAdd(urlHtml);
|
赖素文
authored
|
99
|
},
|
赖素文
authored
|
100
101
102
|
//项目区域图点击
projectAreasMapClick(item) {
var title = "项目设备区域图";
|
王硕
authored
|
103
104
105
106
|
localStorage.setItem("projectMapKeys", item.keys);
localStorage.setItem("projectMapName", item.projectName);
var tabsEle = window.parent.document.querySelectorAll("#top_tabs cite");
for (var i = 0; i < tabsEle.length; i++) {
|
赖素文
authored
|
107
|
if (tabsEle[i].innerText == title) {
|
王硕
authored
|
108
109
110
111
112
|
$(tabsEle[i]).next().click();
break;
}
}
|
赖素文
authored
|
113
114
|
var url = `/configure/BaseProject/ProjectEqAreaView?id=${item.id}&keys=${item.keys}&projectName=${item.projectName}`;
var urlHtml = $(`<a title="${title}" data-url="${url}"><i class="layui-icon" data-icon=""></i><cite>${title}</cite></a>`);
|
王硕
authored
|
115
116
|
window.top.tab.tabAdd(urlHtml);
},
|
赖素文
authored
|
117
118
119
120
121
|
/**
* 创建右侧项目列表
*/
createSidebarList(json) {
var sidebarList = [];
|
赖素文
authored
|
122
|
var index = 1;
|
赖素文
authored
|
123
|
json.Result.list.forEach(item => {
|
王硕
authored
|
124
|
var content = `<dd><a id='a_${item.id}' class='projectListA' onclick='app.methods.findLocateMarker(${item.id.toString()},event)' href="javascript:;">【${index++}】${item.projectName}</a></dd>`;//定义大标题 写html语句标签
|
赖素文
authored
|
125
126
127
128
129
130
131
132
133
|
sidebarList.push(content)
})
if (sidebarList.length > 0) {
$(".sidebar-list-item").empty().append(sidebarList.join(" "))
}
},
/**
* 查找Marker并打开对应的infoWindow信息框
*/
|
赖素文
authored
|
134
|
findLocateMarker(markerId, event) {
|
赖素文
authored
|
135
|
mapObj.getLocateMarker(markerId);
|
王硕
authored
|
136
|
sysNowClickEle = markerId;
|
赖素文
authored
|
137
138
|
$(".projectListA").css("color", "rgba(255, 255, 255, .7)")
$(event.currentTarget).css("color", "#42b983")
|
赖素文
authored
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
},
/**
* 初始化vue
*/
initVue: function () {
vueApp = new Vue({
el: '.vueApp',
data: {
footer: {
projectCount: 0,
eqCount: 0,
eqOnlineRate: "",
eqTuoRate: "",
}
},
methods: {
}
});
},
/**
* vue 集合赋值
*/
|
赖素文
authored
|
162
|
initVueDataValue: (result) => {
|
HuXiYu
authored
|
163
|
var res = result.Result;
|
赖素文
authored
|
164
165
166
167
168
|
vueApp.footer.projectCount = res.list.length;
//设备总数
vueApp.footer.eqCount = res.sumEqCount;
vueApp.footer.eqOnlineRate = res.onlineRate;
vueApp.footer.eqTuoRate = res.tuoShanRate;
|
王硕
authored
|
169
|
},
|
王硕
authored
|
170
|
|
王硕
authored
|
171
172
|
refreshDataMethod: function () {
|
王硕
authored
|
173
174
175
176
|
const tabsEle = Array.from(window.parent.document.querySelectorAll("#top_tabs .layui-this"));
const isOK = tabsEle.some(tab => tab.innerText === "项目地图");
if (!isOK) return;
|
王硕
authored
|
177
178
179
180
181
182
183
184
|
let currenttime = parseInt(app.data.refreshDataTimeEle.innerHTML);
if (currenttime === 0) {
currenttime = 20;
app.methods.getProjectDataList();
} else {
currenttime--;
}
app.data.refreshDataTimeEle.innerHTML = currenttime;
|
赖素文
authored
|
185
186
187
|
}
},
registerEvent: function () {
|
王硕
authored
|
188
|
|
赖素文
authored
|
189
|
},
|
王硕
authored
|
190
|
|
赖素文
authored
|
191
192
|
init: function () {
app.methods.initMap();
|
赖素文
authored
|
193
194
|
app.methods.initVue();
app.methods.getProjectDataList();
|
王硕
authored
|
195
|
setInterval(app.methods.refreshDataMethod, 1000);
|
赖素文
authored
|
196
|
app.registerEvent();
|
赖素文
authored
|
197
|
}
|
赖素文
authored
|
198
199
200
|
};
app.init();
});
|