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