-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdevice_message.html
More file actions
776 lines (747 loc) · 32.8 KB
/
device_message.html
File metadata and controls
776 lines (747 loc) · 32.8 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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<link rel="shortcut icon" href="/img/favicon.ico" />
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/buttons.dataTables.min.css" rel="stylesheet" />
<link href="css/jquery.dataTables.min.css" rel="stylesheet" />
<link href="css/select.dataTables.min.css" rel="stylesheet" />
<link href="css/scroller.dataTables.min.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<link href="css/viccom.css" rel="stylesheet" />
<link href="css/animate.min.css" rel="stylesheet" />
<link rel="stylesheet" href="js/layui/css/layui.css" media="all">
<title>设备消息</title>
<style>
.table>tbody>tr td{
cursor: pointer;
}
</style>
</head>
<body>
<!-- 顶部导航 start -->
<nav class="nav_herder">
<div class="nav_left gate_hand" onClick="location='index.html'"><img src="img/cloud_thingslink_logo.png" class="logo"/>冬笋物联网</div>
<div class="pull-right nav_right">
<p class="J_getMembers hd"><img src="img/top_management.png"/><span>成员管理</span></p><em>|</em>
<p><img src="img/top_news.png"/></p><em>|</em>
<p onClick="location='personal_info.html'"><img src="img/top_avatar.png"/><span class="J_nickname">昵称</span></p><em>|</em>
<p><img src="img/top_quit.png" id="J_logout"/></p>
</div>
</nav>
<!-- 顶部导航 end -->
<div class="down-main">
<!-- 左侧导航 start -->
<div class="left-main left-full">
<div class="sidebar-fold"><img src="img/nav_shrink.png"/></div>
<div class="subNav" onClick="location='platform_message.html'"> <!-- 跳转页面 -->
<img src="img/platform1.png" style="width: 30px;" class="hd_img"/>
<img src="img/platform_select.png" style="width: 30px;" class="hover_img"/>
<p class="sublist-title">平台消息</p>
</div>
<div class="subNav bg-color" onClick="location='device_message.html'">
<img src="img/device2.png" style="width: 30px;" class="hd_img"/>
<img src="img/device_select.png" style="width: 30px;" class="hover_img"/>
<p class="sublist-title">设备消息</p>
</div>
</div>
<!-- 左侧导航 end -->
<div class="right-product my-index right-full">
<!-- 标题 -->
<p class="mes_title">设备消息<span>(全部消息<span class="allMessage"></span>条,其中未确认消息 <span class="disposed_message"></span> 条,<a class="isLook">查看未确认</a><input
type="hidden" name="isLook" value="">)</span></p>
<div class="mes_content">
<!-- 功能栏 -->
<div class="mes_search">
<button class="confirmation">确认消息</button>
<button class="confirmationAll">确认所有消息</button>
<div style="width: 730px;">
<div class="btn-group search_filter1" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="search_keyword1" data-search_keyword="1">全部消息类型</span><input type="hidden" name="search_keyword1" value="">
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li data-name=""><a style="cursor:pointer">全部消息类型</a></li>
<li data-name=""><a style="cursor:pointer">通讯</a></li>
<li data-name=""><a style="cursor:pointer">网关系统</a></li>
<li data-name=""><a style="cursor:pointer">采集设备</a></li>
<li data-name=""><a style="cursor:pointer">采集数据</a></li>
<li data-name=""><a style="cursor:pointer">网关应用</a></li>
</ul>
</div>
<div class="btn-group search_filter2" role="group">
<input type="hidden" value="" id="time_classify">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="search_keyword2" data-search_keyword="1">时间</span><input type="hidden" name="search_keyword2" value="">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li data-name="device_time1"><a style="cursor:pointer">1小时</a></li>
<li data-name="device_time2"><a style="cursor:pointer">24小时</a></li>
<li data-name="device_time3"><a style="cursor:pointer">3天</a></li>
</ul>
</div>
<div class="btn-group search_filter3" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="search_keyword3" data-search_keyword="1">等级</span><input type="hidden" name="search_keyword3" value="">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li data-name="device_time1"><a style="cursor:pointer">常规</a></li>
<li data-name="device_time2"><a style="cursor:pointer">警告</a></li>
<li data-name="device_time3"><a style="cursor:pointer">错误</a></li>
<li data-name="device_time4"><a style="cursor:pointer">致命</a></li>
</ul>
</div>
<div class="bs-example J_mineSearchForm">
<div class="input-group" style="width:300px;">
<div class="input-group-btn search_filter4">
<button type="button" class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="search_keyword4" data-search_keyword="1">标题</span><input type="hidden" name="search_keyword3" value="">
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="version">
<li data-name=""><a style="cursor:pointer">标题</a></li>
<li data-name=""><a style="cursor:pointer">序列号</a></li>
</ul>·
</div><!-- /btn-group -->
<input type="text" class="form-control J_keyword" placeholder="输入关键词">
<span class="input-group-addon search"></span>
</div><!-- /input-group -->
</div>
<i id="glyphicon-refresh" class="glyphicon glyphicon-repeat"></i>
</div>
</div>
</div>
<!-- 表格 -->
<div style="margin: 0 15px;border: 1px solid #E5E9EE;">
<table id="device_message" class="table dataTable no-footer " style="background-color:#FFFFFF;">
<thead>
<tr>
<th><label class="checkbox"><input index="0" name="select_all" type="checkbox" class="box"><em></em></label></th>
<th>标题</th>
<th>序列号</th>
<th>发生时间</th>
<th>消息类型</th>
<th>等级</th>
<th>ID</th>
<th>状态</th>
</tr>
</thead>
</table>
</div>
</div>
<!--无内容状态-->
<div class="none hd">
<p><img src="img/photo_wdwg.png"/></p>
<p>很抱歉,您还没有消息,请先绑定新网关!</p>
<!--<button class="bind">绑定新网关</button>-->
</div>
<!--无内容状态end-->
</div>
<!--<div style="position: fixed;bottom: 15px;z-index: 9999;" class="copyright">SymTech Application © 2008-2017</div>-->
<!-- 加载script start -->
<script src="https://code.jquery.com/jquery-3.3.1.js" type="text/javascript"></script>
<script src="js/jQuery.cookie.js" type="text/javascript"></script>
<script src="js/layui/layui.js" charset="utf-8"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<!--<script src="js/jquery.dataTables.min.js" type="text/javascript"></script>-->
<script src="js/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script src="js/dataTables.buttons.js" type="text/javascript"></script>
<script src="js/dataTables.select.min.js" type="text/javascript"></script>
<script src="js/dataTables.scroller.min.js" type="text/javascript"></script>
<script src="js/arrayFun.js" type="text/javascript"></script>
<script src="js/common.js" type="text/javascript"></script>
<script src="js/user.js" type="text/javascript"></script>
<script src="js/index.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
var token = $.cookie('DS_auth_token');
$.ajaxSetup({
headers: { // 默认添加请求头
"X-Frappe-CSRF-Token": token
}
});
$('.J_nickname').text(getCookie('full_name'));
//时间戳转换
function timestampToTime(timestamp) {
var date = new Date(timestamp);
var Y = date.getFullYear() + '-';
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
var D = (date.getDate() < 10 ? '0'+(date.getDate()) : date.getDate()) + ' ';
var h = date.getHours() + ':';
var m = (date.getMinutes() < 10 ? '0'+(date.getMinutes()) : date.getMinutes()) + ':';
var s = '00';
return Y+M+D+h+m+s;
}
//查看范围
var date0 = timestampToTime(Date.parse(new Date()) - 24 * 90 * 60 * 60 * 1000);
//获取全部消息条数 ---- 设备
$.ajax({
url:"/apis/api/method/iot.user_api.count_device_event",
type:"GET",
success:function (req) {
console.log(req.message);
count = req.message;
$('.allMessage').text(req.message);
return false;
},
error:function (error) {
console.log('error');
console.log(error);
}
});
//获取未读信息条数
$.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
data: {start:0,limit:500},
dataType: "json",
success: function (data) {
var a = 0;
var list = data.message;
for(var i=0;i<list.length;i++){
if(list[i].disposed == 0){
a++;
}
}
$('.disposed_message').text(a);
},
error: function (error) {
console.log(error)
}
});
var myfilters = {
start: 0,
limit: 100
};
var myajax = function(data, callback, oSettings ) {
return $.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
contentType: "application/json",
data:JSON.stringify(myfilters),
success: function (data) {
callback(data);
}
})
};
//datatables配置
var table = $('#device_message').DataTable({
dom: 'rt<"#table_footer"Bp>',
buttons: [],
// "bStateSave": false,
// stateSave: true,
"bFilter": true, //是否启动过滤,搜索功能
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
destroy:true,
"ajax": myajax,
"sAjaxDataProp": "message",
"columns": [
{"data": null},
{"data": "event_info"},
{"data": "device"},
{"data": "creation"},
{"data": "event_type"},
{"data": "event_level"},
{"data": "name"},
{"data": "disposed"}
],
"language": {
"sProcessing": "处理中...",
"sLengthMenu": "显示 _MENU_ 项结果",
"sZeroRecords": "没有匹配结果",
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
"sInfoPostFix": "",
"sSearch": "搜索:",
"sUrl": "",
"sEmptyTable": "表中数据为空",
"sLoadingRecords": "载入中...",
"sInfoThousands": ",",
"oPaginate": {
"sFirst": "首页",
"sPrevious": "上页",
"sNext": "下页",
"sLast": "末页"
},
"oAria": {
"sSortAscending": ": 以升序排列此列",
"sSortDescending": ": 以降序排列此列"
}
},
rowCallback: function (row, data, dataIndex) {
//时间截取----- 毫秒
var timeText = $(row).children('td').eq(3).text();
$(row).children('td').eq(3).text(timeText.substring(0,19));
//判断是否确认消息
if($(row).children('td').eq(7).text() == 0 ){
console.log('未确认');
$(row).children('td').eq(1).children($("on")).addClass('disposed')
}else{
console.log('已确认')
}
},
columnDefs: [
{
// 指定第第一列
targets: [0],
searchable: false,
orderable: false,
width: '5%',
render: function (data, type, row, meta) {
var gen_html = '<label class="checkbox"><input index="0" name="select_single" type="checkbox" class="box"><em></em></label>';
return gen_html;
}
},
{
// 指定第第2列
targets: [1],
width: '25%',
render: function (data, type, row, meta) {
return '<i class="on"></i>' + data;
}
},
{
// 指定第第3列
targets: [2],
width: '25%'
},
{
// 指定第第4列
targets: [3],
width: '20%'
},
{
// 指定第第5列
// className:"hide_column",
targets: [4],
width: '13%'
},
{
// 指定第第6列
// className:"hide_column",
targets: [5],
width: '12%'
},
{
// 指定第第7列
className:"hide_column",
targets: [6]
},
{
// 指定第第8列
className:"hide_column",
targets: [7]
}
],
"order" : [ [ 1, 'asc' ] ],
'order' : [3,'desc']
});
var sn = decodeURI(window.location.href.split("=")[1]);
console.log(sn);
if(sn != "undefined"){
$('input.J_keyword').val(sn);
$('.search_keyword4').text("序列号");
table
.columns(2)
.search(sn)
.draw();
}
//点击行进入详情
$('#device_message tbody').on('click','tr td:nth-child(2)',function() {
console.log($(this));
var name = $(this).parent('tr').find('td:nth-child(7)').text();
location.href = 'device_details.html?device_sn=' + name;
} );
//点击查看所有未读消息
$('.isLook').click(function () {
if($(this).text() == "查看未确认"){
$('input[name=isLook]').val(0); //查看未处理
table
.column(7)
.search(0)
.draw();
$(this).text("查看所有");
}else if($(this).text() == "查看所有"){
$('input[name=isLook]').val(''); //查看所有
table
.column(7)
.search("")
.draw();
$(this).text("查看未确认");
}
});
//下拉框--- 关键词
$('.search_filter4 li').on('click', function(){
$('.search_keyword4').text($(this).text());
});
//下拉框--- 分类搜索
$('input.J_keyword').on( 'keyup click', function () { //点击搜索框
var key = $('input.J_keyword').val(); //搜索框内容
if($('.search_keyword4').text()=="序列号"){
table
.columns(2)
.search(key)
.draw();
}
if($('.search_keyword4').text()=="标题"){
table
.columns(1)
.search(key)
.draw();
}
} );
// 下拉框--- 时间
$('.search_filter2 li').on('click', function(){
$('.search_keyword2').text($(this).text());
var content = $('.search_keyword2').text();
if(content == "1小时"){
//获取当前时间前一小时
var an_hour_ago = Date.parse(new Date()) - 1 * 60 * 60 * 1000;
var date1 = timestampToTime(an_hour_ago);
$('input[name=search_keyword2]').val(date1);
var param1 = {
start: 0,
limit: 100,
filters: {
creation:[">",date1]
}
};
var myajax1 = function(data, callback, oSettings ) {
return $.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
contentType: "application/json",
data:JSON.stringify(param1),
success: function (data) {
if(JSON.stringify(data) == "{}"){
alt('一小时之内暂时没有消息',2);
}else{
console.log(data);
callback(data);
}
}
})
}
table.settings()[0].ajax = myajax1;
table.ajax.reload();
}else if(content == "24小时"){
//获取当前时间前24小时
var one_day_ago = Date.parse(new Date()) - 24 * 60 * 60 * 1000;
var date2 = timestampToTime(one_day_ago);
$('input[name=search_keyword2]').val(date2);
var param1 = {
start: 0,
limit: 150,
filters: {
creation:[">",date2]
}
};
var myajax2 = function(data, callback, oSettings ) {
return $.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
contentType: "application/json",
data:JSON.stringify(param1),
success: function (data) {
if(data == ''){
console.log('kong')
}else{
console.log(data);
callback(data);
}
}
})
}
table.settings()[0].ajax = myajax2;
table.ajax.reload();
}else if(content == "3天"){
//获取当前时间前72小时
var three_day_ago = Date.parse(new Date()) - 72 * 60 * 60 * 1000;
var date3 = timestampToTime(three_day_ago);
$('input[name=search_keyword2]').val(date3);
var param3 = {
start: 0,
limit: 400,
filters: {
creation:[">",date3]
}
};
console.log(param3)
var myajax3 = function(data, callback, oSettings ) {
return $.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
contentType: "application/json",
data:JSON.stringify(param3),
success: function (data) {
callback(data);
console.log(data)
}
})
}
table.settings()[0].ajax = myajax3;
table.ajax.reload();
}
});
//下拉框--- 消息类型
$('.search_filter1 li').on('click', function(){
$('.search_keyword1').text($(this).text());
var content = $('.search_keyword1').text();
if(content == "通讯"){
$('input[name=search_keyword1]').val('通讯');
table
.column(4)
.search("通讯")
.draw();
}else if(content == "网关系统"){
$('input[name=search_keyword1]').val('系统');
table
.column(4)
.search("系统")
.draw();
}else if(content == "采集数据"){
$('input[name=search_keyword1]').val('数据');
table
.column(4)
.search("数据")
.draw();
}else if(content == "采集设备"){
$('input[name=search_keyword1]').val('设备');
table
.column(4)
.search("设备")
.draw();
}else if(content == "网关应用"){
$('input[name=search_keyword1]').val('应用');
table
.column(4)
.search("应用")
.draw();
}else if(content != ""){
table
.column(3)
.search("")
.draw()
}
});
//下拉框--- 等级
$('.search_filter3 li').on('click', function(){
$('.search_keyword3').text($(this).text());
var content = $('.search_keyword3').text();
if(content == "常规"){
$('input[name=search_keyword3]').val(1);
table
.column(5)
.search(1)
.draw();
}else if(content == "警告"){
$('input[name=search_keyword3]').val(2);
table
.column(5)
.search(2)
.draw();
}else if(content == "错误"){
$('input[name=search_keyword3]').val(3);
table
.column(5)
.search(3)
.draw();
}else if(content == "致命"){
$('input[name=search_keyword3]').val(99);
table
.column(5)
.search(99)
.draw();
}else if(content != "等级"){
table
.column(5)
.search("")
.draw()
}
});
//全选
var $selectAll = $('input[name=select_all]');
var $selectSingle = $('input[name=select_single]');
console.log($selectSingle);
$selectAll.click(function () {
console.log('全选');
if ($selectAll.prop("checked") == true) {
// 上面的复选框已被选中
$(":checkbox[name='select_single']").prop("checked", true);
} else {
// 上面的复选框没被选中
$(":checkbox[name='select_single']").prop("checked", false);
}
});
//确认消息
$('.confirmation').click(function () {
var checkBox = $('input:checkbox[name=select_single]');
var eventId = $('#device_message tbody tr td:nth-child(7)');
var title = $('#device_message tbody tr td:nth-child(2)>i');
var dm = $('.disposed_message').text();
console.log(dm)
var arr = [];
console.log(checkBox.length);
console.log(eventId.length);
checkBox.each(function (i) {
if(checkBox[i].checked == true){
var ids = eventId.eq(i).text();
if(ids != 'undefined'){
arr.push(ids); //得到记录ID,放到arr数组中
}
}
});
console.log(arr);
//确认消息
var dataS = {
"disposed": 1,
"events": arr
};
console.log(dataS);
if(arr.length != 0){
$.ajax({
url:"/apis/api/method/iot.user_api.dispose_device_events",
type:"POST",
data:JSON.stringify(dataS),
contentType:"application/json",
dataType:'JSON',
success:function(data){
checkBox.each(function (i) {
if(checkBox[i].checked == true){
checkBox[i].checked = false;
var a = title.eq(i);
a.removeClass('disposed')
}
$(".disposed_message").text( dm - arr.length )
})
},
error:function(error){
console.log('error')
}
});
}else{
alt("请选择需要确认的信息",2)
}
});
//确认所有消息
$('.confirmationAll').click(function () {
var title = $('#device_message tbody tr td:nth-child(2)>i');
$.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
data:{
'start':0,
'limit':500
},
dataType: "json",
success: function (data) {
var list = data.message; //所有消息
var aList = [];
for(var i=0;i<list.length;i++){
if(list[i].disposed == 0){
aList.push(list[i].name);
title.eq(i).removeClass('disposed');
}
}
//确认消息
if(aList.length != 0){
var dataS = {
"disposed":1,
"events": aList
};
$.ajax({
url:"/apis/api/method/iot.user_api.dispose_device_events",
type:"POST",
data:JSON.stringify(dataS),
contentType:"application/json",
dataType:'JSON',
success:function(data){
title.each(function (i) {
title.eq(i).removeClass('disposed');
});
$("#platform_message").dataTable().fnDraw(true);
// document.execCommand('Refresh')
},
error:function(error){
}, complete: function () {
if(aList.length != 0){
var myfilters = {
start: 0,
limit: 100
};
var myajax11 = function(data, callback, oSettings ) {
return $.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
contentType: "application/json",
data:JSON.stringify(myfilters),
success: function (data) {
callback(data);
}
})
};
table.settings()[0].ajax = myajax11;
table.ajax.reload();
}
}
});
$('.disposed_message').text(0);
}else{
alt("暂时没有未读消息",2)
}
}, error: function (error) {}
});
});
//刷新数据
$('#glyphicon-refresh').click(function () {
var is_look = $('input[name=isLook]').val(); //是否查看 isLook:0未查看
var mess_type = $('input[name=search_keyword1]').val(); //消息类型 search_keyword1
var sel_time = $('input[name=search_keyword2]').val(); //时间范围
var grade = $('input[name=search_keyword3]').val(); //等级
var param1 = {
start: 0,
limit: 100,
filters: {
"disposed" : is_look,
"event_type" : mess_type, //消息类型
"event_level" : grade,
"creation" :[">", sel_time]
}
};
var oneData;
var myajax1 = function(data, callback, oSettings ) {
return $.ajax({
url: "/apis/api/method/iot.user_api.device_event",
type: "POST",
async:false,
contentType: "application/json",
data:JSON.stringify(param1),
success: function (data) {
oneData = data;
if(JSON.stringify(data) == "{}"){
alt('暂时没有最新消息',2);
}else{
console.log(data);
callback(data);
}
}
})
};
if(JSON.stringify(oneData) !== "{}"){
table.settings()[0].ajax = myajax1;
table.ajax.reload();
}
})
});
</script>
</body>
</html>