alarm_frm.html
22.2 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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>所有异常_frm</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
<link rel="stylesheet" type="text/css" href="../../css/home.css"/>
<link rel="stylesheet" type="text/css" href="../../css/element.css"/>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
</head>
<style>
html,
body {
background: #F4F6F9;
}
</style>
<body>
<div id="app">
<template>
<div>
<!-- <div class="search-view-inline" style="width: 50%;" tapmode > -->
<div class="search-view-inline" style="margin-bottom: 0px;">
<div class="select-list aui-ellipsis-1" style="width: 33%;" tapmode @click="selectCondition(0)">
<span class="choose-device-title" id="select_imei">{{ chooseModel }}</span>
<i></i>
</div>
<label style="background-color:rgba(240,245,255,1);left: 33%;"></label>
<div class="select-list aui-ellipsis-1" style="width: 33%;" tapmode @click="selectCondition(1)">
<span class="choose-device-title" id="select_status">{{ chooseType }}</span>
<i></i>
</div>
<label style="background-color:rgba(240,245,255,1);left: 66%;"></label>
<div class="select-list aui-ellipsis-1" style="width: 33%;" tapmode @click="selectCondition(2)">
<span class="choose-device-title" id="select_imei">{{ exceptionType }}</span>
<i></i>
</div>
</div>
<div class="search-view-inline" style="margin-bottom: 0px;">
<div class="select-list aui-ellipsis-1" style="width: 50%;" tapmode @click="selectCondition(3)">
<span class="choose-device-title" id="select_status">开始: {{ chooseTimeStart }}</span>
<i></i>
</div>
<label style="background-color:rgba(240,245,255,1);"></label>
<div class="select-list aui-ellipsis-1" style="width: 50%;" tapmode @click="selectCondition(4)">
<span class="choose-device-title" id="select_status">结束: {{ chooseTimeEnd }}</span>
<i></i>
</div>
</div>
</div>
<div v-if="pageList.length>0" class="alarm-panel">
<div v-for="(page_d, page_i) in pageList">
<div class="alarm-list-panel" tapmode @click="chooseToHandle(page_d, page_i)">
<el-row>
<el-col :span=spanImg class="alarm-choose-area">
<img src="../../image/alarm/icon-unselected.png" :id="'select_'+ page_i" style="width:18px;height:18px;margin-top: 3.2rem;margin-left:0.5rem;" />
</el-col>
<el-col :span=spanV>
<div class="alarm-info-panel">
<el-row class="alarm-top-14">
<el-col :span=2>
<div class="alarm-number-id">{{ page_i+1 | addSuffix }}</div>
</el-col>
<el-col :span=11>
<span class="alarm-device-imei">{{ page_d | nameFilter}}</span>
</el-col>
<el-col :span=11>
<span class="alarm-type">{{ page_d.store.storeType.name }}</span>
<span v-if="page_d.status === '已处理'" class="alarm-status">已处理</span>
<span v-else class="alarm-status not-handle">未处理</span>
</el-col>
</el-row>
<p class="alarm-device-i">设备编号:{{ page_d.imei }}</p>
<div class="alarm-list-line"></div>
</div>
<p class="alarm-warning-item-content alarms-style" v-if="page_d.type != '01001' && exceptionType === '报警信息'" >
<em class="ararm-btn" v-for="(alarm_d, alarm_i) in page_d.warning"><span class="ararm-text">{{ alarm_d }}</span></em>
</p>
<p class="alarm-warning-item-content alarms-style" v-if="page_d.type === '01001' && exceptionType === '报警信息'" >
<em class="ararm-btn" v-for="(ty500_d, ty500_i) in page_d.extra"><span class="ararm-text">{{ ty500_d.type }}</span></em>
</p>
<p class="alarm-warning-item-content alarms-style" v-if="page_d.type != '01001' && exceptionType === '故障信息'" >
<em class="ararm-btn" v-for="(fault_d, fault_i) in page_d.fault"><span class="ararm-text">{{ fault_d }}</span></em>
</p>
</el-col>
<div class="alarm-list-footer">
<el-row>
<el-col :span=spanImg>
</el-col>
<el-col :span=spanV>
<span class="ararm-update-time">更新时间:{{ parseTime(page_d.createdAt,'{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</el-col>
</el-row>
</div>
</el-row>
</div>
</div>
</div>
<div v-if="spanImg === 2" class="alarm-footer-area">
<div style="margin-left:15px;margin-right:15px;">
<div class="aui-row aui-row-flex" style="height:64px;">
<div class="aui-col aui-col-span-12" style="margin-top:18px;height:28px;">
<div class="aui-row aui-row-flex" style="line-height:28px;" tapmode @click="selectAllAlarm()">
<img src="../../image/alarm/icon-unselected.png" id="img_select" style="width:18px;height:18px;margin-top:0.2rem;" />
<span> {{ chooseHandleTitle }}</span>
</div>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-center aui-row-flex-middle aui-row-flex-end" style="margin-top:18px;height:28px;" tapmode @click="signRead()">
<div style="border:1px solid rgba(91,127,248,1);border-radius:17px;">
<span class="alarm-sign-handle">标记已处理</span>
</div>
</div>
</div>
</div>
</div>
<div v-if="pageList.length === 0">
<div style="top:8rem;" class="no-data"><img src="../../image/img-nullInfo.png" />
<p style="font-size:16px;font-weight:500;color:rgba(55,57,78,1);">无设备异常信息</p>
<p>先去别的地方看看吧~</p>
</div>
</div>
</template>
</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/element.js"></script>
<script type="text/javascript" src="../../script/ctrl.js"></script>
<script type="text/javascript" src="../../script/fastclick.js "></script>
<script type="text/javascript">
var vm,
that;
apiready = function(){
api.parseTapmode();
$(function() {
FastClick.attach(document.body);
});
//---------初始化vue
vm = new Vue({
el: '#app',
data: {
spanV: 24,
spanImg: 0,
token: api.getPrefs({sync: true,key: 'userToken'}),
searchCondition: {
userId: api.getPrefs({sync: true,key: 'userID'}),
page: 1,
limit: 50,
type: 'app',
storeTypeId: '',
storeModelId: '',
// keyword: '',
timerange: [parseTime((new Date()).getTime()-1000*60*60*24*180,'{y}-{m}-{d}')+ ' 00:00:00', parseTime((new Date()).getTime(),'{y}-{m}-{d}')+ ' 23:59:59'],
},
typeList: [],
chooseModel: '所有类型',
chooseType: '所有型号',
exceptionType: '报警信息',
chooseTimeStart: parseTime((new Date()).getTime()-1000*60*60*24*180,'{y}-{m}-{d}'),
chooseTimeEnd: parseTime((new Date()).getTime(),'{y}-{m}-{d}'),
pageList: [],
hasNext: true,
idList: [],
chooseHandleTitle: '全部选择',
},
mounted() {
//window.chooseProduct = this.chooseProduct;
},
filters: {
addSuffix(v) {
let res_num = Number(v)
res_num < 10 ? res_num = "0" + v : v
return res_num
},
nameFilter(v) {
if (v.store_name === '') {
return v.imei
}else {
return v.store_name
}
}
},
created() {
that = this
api.addEventListener({
name: 'handleAllAlarmMsgBegin'
}, function(ret, err){
if (ret.value.isEdit) {
that.spanV = 22
that.spanImg = 2
}else {
that.spanV = 24
that.spanImg = 0
}
});
api.addEventListener({
name: 'change_alarm_device_model'
}, function(ret, err){
that.chooseModel = ret.value.name
that.searchCondition.storeModelId = ret.value.model
//改变类型时,重置型号
that.chooseType = '所有型号'
that.searchCondition.storeTypeId = ''
that.getPageList(that.exceptionType, true)
});
api.addEventListener({
name: 'change_alarm_device_type'
}, function(ret, err){
that.chooseType = ret.value.name
that.searchCondition.storeTypeId = ret.value.typeId
that.getPageList(that.exceptionType, true)
});
api.addEventListener({
name: 'change_alarm_device_exception'
}, function(ret, err){
that.exceptionType = ret.value.name
that.getPageList(that.exceptionType, true)
});
api.setRefreshHeaderInfo({
bgColor: '#F4F6F9',
textColor: 'rgba(55,57,78,1)',
textDown: '下拉刷新设备列表...',
textUp: '松开刷新...'
}, function(ret, err) {
that.resetValues()
that.getPageList('报警信息', true)
// chooseProduct('all', '所有设备')
});
api.addEventListener({
name:'scrolltobottom',
extra:{
threshold:0 //设置距离底部多少距离时触发,默认值为0,数字类型
}
}, function(ret, err){
that.addPageSearch()
});
this.initTypeList()
this.getPageList(this.exceptionType, true)
},
methods: {
async getPageList(exceptionType, bool) {
api.showProgress({
style: 'default',
animationType: 'fade',
title: '加载中...',
text: '',
modal: false
});
if (bool) {
this.pageList = []
this.searchCondition.page = 1
this.searchCondition.limit = 50
this.idList = []
}
let params = trim_nulls(this.searchCondition)
// console.log("条件:----" + JSON.stringify(params));
let result;
if (exceptionType === '报警信息') {
result = await post_get_alarm_list(params, this.token)
// console.log(JSON.stringify(result));
}else if (exceptionType === '故障信息') {
result = await post_get_fault_list(params, this.token)
}
let list = result.data.rows
list.forEach(d => {
//TY500定制化
if (d.type === '01001') {
let arr = handleFormatTY500Alert(d);
d.extra = arr
}
});
// this.pageList = list //追加数组
for(let i=0; i<list.length; i++){
this.pageList.push(list[i]);
}
this.hasNext = result.data.next
//-----
api.hideProgress();
api.refreshHeaderLoadDone();
},
chooseToHandle(v, i) {
if (this.spanImg === 2) {
let imgPath = $api.byId('select_' + i).src
if (imgPath.indexOf("unselected") != -1) { //点击前是未选择状态(点击选择)
$api.byId('select_' + i).src = '../../image/alarm/icon-selected.png'
//handle...
this.idList.push(v.id)
}else {
$api.byId('select_' + i).src = '../../image/alarm/icon-unselected.png'
//handle...
let index = this.idList.indexOf(v.id);
this.idList.splice(index,1)
}
}else if (this.spanImg === 0) { //未编辑状态点击进入详情页
let product_id = v.store.storeType.id
let imei = v.store.imei
this.showProductPage(product_id, imei)
}
},
showProductPage(product_id, imei) {
// let res = await get_alert_html_str(api.pageParam.value.storeType)
//这里以后全部是配置对应的http地址...
//测试写法--start
console.log(product_id);
let url_ = 'http://iot.uccc.cc:9090/app_html/store'+product_id+'/index_win.html'
api.openWin({
name: 'store_' + product_id + '_indexWin',
url: url_,
// url: 'http://iot.uccc.cc:9090/app_html/store01001/index_win.html',
bounces: false,
pageParam: {imei : imei,
productId: product_id}
});
},
async initTypeList() {
let res = await get_store_model();
this.typeList = res.data
},
selectCondition(step) {
switch (step) {
case 0:
api.openFrame({
name: 'alarmModelFooter',
url: './alarm_model_footer.html',
bounces: false,
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: api.winHeight
},
pageParam: {
list: this.typeList,
from: 'alarm_frm'
}
});
break;
case 1:
let list = []
if (this.chooseModel != '所有类型') {
this.typeList.forEach(d => {
if (d.name === this.chooseModel) {
list = d.data
}
});
}else {
this.typeList.forEach(d => {
d.data.forEach(e => {
list.push(e)
});
});
}
api.openFrame({
name: 'alarmTypeFooter',
url: './alarm_type_footer.html',
bounces: false,
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: api.winHeight
},
pageParam: {
list: list,
from: 'alarm_frm'
}
});
break;
case 2:
api.openFrame({
name: 'alarmExceptionFooter',
url: './alarm_exception_footer.html',
bounces: false,
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: api.winHeight
},
pageParam: {
exceptionType: this.exceptionType
}
});
break;
case 3:
let date_;
if (this.chooseTimeStart == '') {
date_ = parseTime((new Date()).getTime()-1000*60*60*24*180,'{y}-{m}-{d}');
}else {
date_ = this.chooseTimeStart;
}
api.openPicker({
type: 'date',
date: date_,
title: '异常时间'
}, function(ret, err) {
if (ret) {
let allDate = timeFormater(ret.year,ret.month,ret.day);
let date = new Date(allDate);
let curdate = new Date();
if (curdate.getTime() < date.getTime()) {
api.toast({msg: '请选择有效查询日期!',duration: 2000,location: 'bottom'});
return;
}
that.chooseTimeStart = allDate
let st = allDate + ' 00:00:00'
that.searchCondition.timerange[0] = st
// that.searchCondition.timerange[1] = et
that.getPageList(that.exceptionType, true)
}
});
break;
case 4:
let date2_;
if (this.chooseTimeEnd == '') {
date2_ = parseTime((new Date()).getTime(),'{y}-{m}-{d}');
}else {
date2_ = this.chooseTimeEnd;
}
api.openPicker({
type: 'date',
date: date2_,
title: '异常时间'
}, function(ret, err) {
if (ret) {
let allDate2 = timeFormater(ret.year,ret.month,ret.day);
let date2 = new Date(allDate2);
let curdate2 = new Date();
if (curdate2.getTime() < date2.getTime()) {
api.toast({msg: '请选择有效查询日期!',duration: 2000,location: 'bottom'});
return;
}
that.chooseTimeEnd = allDate2
let et = allDate2 + ' 23:59:59'
that.searchCondition.timerange[1] = et
// that.searchCondition.timerange[1] = et
that.getPageList(that.exceptionType, true)
}
});
break;
}
},
resetValues() {
this.searchCondition= {
userId: api.getPrefs({sync: true,key: 'userID'}),
page: 1,
limit: 50,
type: 'app',
storeTypeId: '',
storeModelId: '',
timerange: [this.chooseTimeStart, this.chooseTimeEnd], //fix:不修改成默认时间
}
this.chooseModel= '所有类型'
this.chooseType= '所有型号'
this.exceptionType= '报警信息'
// this.chooseTimeStart= parseTime((new Date()).getTime()-1000*60*60*24*180,'{y}-{m}-{d}') fix:不修改成默认时间
// this.chooseTimeEnd= parseTime((new Date()).getTime(),'{y}-{m}-{d}') fix:不修改成默认时间
this.spanImg = 0
this.spanV = 24
api.sendEvent({
name: 'reloadAlarmPage'
});
},
addPageSearch() {
if (this.hasNext) {
this.searchCondition.page += 1
this.getPageList(this.exceptionType, false)
}else {
api.toast({msg: '暂无更多数据!',duration: 2000,location: 'bottom'});
}
},
selectAllAlarm() {
this.idList = []
if (this.chooseHandleTitle === '全部选择') {
this.chooseHandleTitle = '取消全部'
this.pageList.forEach((d, i) => {
this.idList.push(d.id)
$api.byId('select_' + i).src = '../../image/alarm/icon-selected.png'
$api.byId('img_select').src = '../../image/alarm/icon-selected.png'
});
}else if (this.chooseHandleTitle === '取消全部') {
this.chooseHandleTitle = '全部选择'
this.pageList.forEach((d, i) => {
$api.byId('select_' + i).src = '../../image/alarm/icon-unselected.png'
$api.byId('img_select').src = '../../image/alarm/icon-unselected.png'
});
// this.getPageList(this.exceptionType, true)
}
},
async signRead() {
// console.log(this.idList.length);
let handleRes;
if (this.exceptionType === '报警信息') {
handleRes = await batch_resolve_warning(this.idList, this.token, this.searchCondition.userId)
}else if (this.exceptionType === '故障信息') {
handleRes = await batch_resolve_fault(this.idList, this.token, this.searchCondition.userId)
// let handleRes = await batch_resolve_warning(this.idList, this.token, this.searchCondition.userId)
}
if (handleRes.code == 0) {
this.getPageList(this.exceptionType, true)
this.chooseHandleTitle = '全部选择'
api.sendEvent({
name: 'change_device',
});
}
}
}
})
};
</script>
</html>