lineSelect.html
11.1 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<!DOCTYPE html>
<html lang="zh">
<head>
<meta name="renderer" content="webkit"/>
<meta charset="utf-8"/>
<title>选择线路</title>
<link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/css/uikit.gradient.min.css"/>
<link rel="stylesheet"
href="/real_control_v2/assets/plugins/uikit-2.27.1/components/form-advanced.gradient.min.css"/>
<link rel="stylesheet"
href="/real_control_v2/assets/plugins/uikit-2.27.1/components/sortable.gradient.min.css"/>
<style type="text/css">
::-webkit-scrollbar {
width: 16px;
height: 16px;
}
::-webkit-scrollbar-track, ::-webkit-scrollbar-thumb {
border-radius: 999px;
border: 5px solid transparent;
}
::-webkit-scrollbar-track {
box-shadow: 1px 1px 5px rgba(0, 0, 0, .2) inset;
}
::-webkit-scrollbar-thumb {
min-height: 20px;
background-clip: content-box;
box-shadow: 0 0 0 5px rgba(0, 0, 0, .2) inset;
}
::-webkit-scrollbar-corner {
background: transparent;
}
input[type="checkbox"] {
vertical-align: bottom;
}
.line-btn-list {
padding: 0 15px 15px 15px;
height: 180px;
overflow: auto;
}
.line-btn-list-selected {
padding: 0 15px 15px 15px;
height: 35px;
overflow: auto;
}
.line-btn-list span.line-item {
border: 1px solid #e0dfdf;
padding: 4px 9px;
margin: 5px;
-webkit-user-select: none;
user-select: none;
display: inline-block;
cursor: default;
transition: all .1s;
}
.line-btn-list span.line-item.active {
background: #5E96D2;
border: 1px solid #5E96D2;
box-shadow: 0px 3px 4px 0 rgba(111, 172, 237, 0.3), 0px 3px 5px 0 rgba(111, 172, 237, 0.3);
color: #ffffff;
}
input.i-cbox[type=checkbox] {
vertical-align: middle;
margin-top: -3px;
}
.line-btn-list span.line-item.active input.i-cbox[type=checkbox] {
border: 0;
}
.line-btn-list span.line-item.active input.i-cbox[type=checkbox]:checked:before {
color: #86f78b;
}
.uk-panel-title {
text-indent: 15px;
}
.line-btn-list-selected span.line-item {
padding: 4px 9px;
margin: 2px;
color: #fff;
background: #5e96d2;
box-shadow: 0px 3px 4px 0 rgba(111, 172, 237, 0.3), 0px 3px 5px 0 rgba(111, 172, 237, 0.3);
user-select: none;
display: inline-block;
cursor: move;
border-radius: 5px;
}
#lineSearchInput {
width: 300px;
box-shadow: 0px 3px 4px 0 rgba(217, 226, 235, 0.3), 0px 3px 5px 0 rgba(200, 217, 236, 0.3);
height: 35px;
}
#submitBtn{
border-radius: 0;
border-color: #00aff2;
transition: all .3s;
}
#submitBtn:disabled{
border-color: #ebe9e9;
}
</style>
</head>
<body>
<div class="wrapper ng-scope">
<div class="dialog dialog-shadow">
<form class="uk-form" style="width: 100%;">
<div class="uk-grid">
<div class="uk-width-medium-1-1">
<div class="uk-panel uk-panel-divider">
<div class="uk-form-row">
<div class="uk-form-icon" style="margin: 15px;">
<i class="uk-icon-search"></i>
<input type="text" placeholder="搜索线路..." id="lineSearchInput">
</div>
</div>
<h3 class="uk-panel-title">待选择的线路</h3>
<div class="line-btn-list">
</div>
</div>
<div class="uk-panel uk-panel-divider">
<h3 class="uk-panel-title">已选择的线路</h3>
<div class="line-btn-list-selected uk-sortable" data-uk-sortable data-uk-observe>
</div>
<button disabled class="uk-button uk-button-primary uk-button-large uk-width-1-1" type="button" id="submitBtn">确定
</button>
</div>
</div>
</div>
</form>
</div>
</div>
<script>
delete window.exports;
delete window.module;
</script>
<!-- jQuery -->
<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
<script src="/real_control_v2/assets/plugins/uikit-2.27.1/uikit.min.js"></script>
<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/sortable.min.js"></script>
<script src="/assets/plugins/pinyin.js"></script>
<script src="/real_control_v2/js/common.js"></script>
<!-- EventProxy -->
<script src="/assets/js/eventproxy.js"></script>
<script>
if (typeof(process) == 'undefined' || !process) {
alert('不支持当前环境!!');
}
const ipcMain = require('electron').ipcRenderer
!function () {
var all = {};
//线路编码映射
var lineIdMap = {};
var storage = window.localStorage;
var auth;
gb_common.$get('/line/all', {destroy_eq: 0}, function (list) {
//用户分配的线路
$.get('/realControAuthority/findByCurrentUser', function (t) {
auth = t;
var newArray = [], authArray = t.lineCodeStr.split(',');
$.each(list, function () {
if (this.lineCode && authArray.indexOf(this.lineCode) != -1) {
newArray.push(this);
}
});
var htmlStr = '';
$.each(newArray, function () {
htmlStr += '<span class="line-item" data-name="' + this.name + '" data-code="' + this.lineCode + '">' +
' <input class="i-cbox" type="checkbox"> ' + this.name +
'</span>';
//拼音首字母
this.camelChars = pinyin.getCamelChars(this.name);
//全拼
this.fullChars = pinyin.getFullChars(this.name).toUpperCase();
lineIdMap[this.lineCode] = this;
});
all = list;
$('.line-btn-list').html(htmlStr);
$('.line-btn-list .line-item').on('click', function () {
var box = $(this).find('input[type=checkbox]')[0];
if ($(this).hasClass('active')) {
$(this).removeClass('active');
box.checked = false;
removeSelected(this);
}
else {
$(this).addClass('active');
box.checked = true;
addSelected(this);
}
});
});
});
$('#lineSearchInput').on('input', function () {
var t = $(this).val().toUpperCase();
if (!t) {
$('.line-btn-list .line-item').show();
return;
}
var rs = [];
$.each(all, function () {
if (this.camelChars.indexOf(t) != -1
|| this.fullChars.indexOf(t) != -1
|| this.name.indexOf(t) != -1) {
rs.push(this.lineCode);
}
});
$('.line-btn-list .line-item').hide().each(function () {
var code = $(this).data('code') + '';
if (rs.indexOf(code) != -1)
$(this).show();
});
});
function addSelected(that) {
$('.line-btn-list-selected').append('<span class="line-item" data-code="' + $(that).data('code') + '">' + $(that).data('name') + '</span>');
$('#submitBtn').removeAttr('disabled');
}
function removeSelected(that) {
var code = $(that).data('code');
$('.line-btn-list-selected .line-item[data-code='+code+']').remove();
if($('.line-btn-list-selected .line-item').length == 0){
$('#submitBtn').attr('disabled', 'disabled');
}
}
function error(rs) {
return rs.status == 'ERROR' || rs.status == 500;
}
/**
* 确定
*/
$('#submitBtn').on('click', function () {
var ep = EventProxy.create('car2DeviceId', 'routes', 'checkLineConfig', function () {
ipcMain.send('webPageGotoControl');
});
var lsData = [], codeStr='', code;
$('.line-btn-list-selected .line-item').each(function () {
code = $(this).data('code');
lsData.push(lineIdMap[code]);
codeStr += (code + ',');
});
//将选择的线路信息写入localstorage
storage.setItem('lineControlItems', JSON.stringify(lsData));
//缓存车辆自编号和设备号对照
$.get('/gps/Car2DeviceId', function (rs) {
storage.setItem('car2DeviceId', JSON.stringify(rs));
ep.emitLater('car2DeviceId');
});
//监控模式还是主调模式
storage.setItem('operationMode', auth.pattern);
//缓存线路路由
codeStr = codeStr.substr(0, codeStr.length - 1);
$.get('/realMap/multiRouteByLine', {codeStr: codeStr}, function (rs) {
for(var key in rs){
storage.setItem(key, JSON.stringify(rs[key]));
}
ep.emitLater('routes');
});
//检查线路配置信息
$.ajax({
url: '/lineConfig/check',
traditional: true,
data: {codeArray: codeStr.split(',')},
method: 'POST',
success: function (rs) {
if (rs.status == 0){
ep.emitLater('checkLineConfig');
}
else if (rs.status == 1){
initLineConfig(rs.not, function () {
ep.emitLater('checkLineConfig');
});
}
}
});
});
function initLineConfig(arr, cb) {
var i = 0;
(function () {
if (i >= arr.length) {
cb && cb();
return;
}
var f = arguments.callee
, lineCode = arr[i];
$.post('/lineConfig/init/' + lineCode, function (rs) {
if (rs == 1) {
i++;
f();
}
});
})();
}
}();
</script>
</body>
</html>