messenger.js
3.09 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
var _messenger = (function(){
//定时到离站信使清理掉(不包含80)
// !function(){
// var f = arguments.callee
// ,ct = Date.parse(new Date()) / 1000
// ,list, time, lineCode;
//
// try {
// var lineArray = _data.getLines();
//
// $.each(lineArray, function(){
// lineCode = this.lineCode;
//
// list = $('#messengerList' + lineCode).find('.log-item.fache,.log-item.zhongdian');
// $.each(list, function(){
// time = parseInt($(this).data('time'));
// if(ct - time >= 30)
// removeLogItem($(this));
// });
// //更新未处理的消息数量
// setUntreatedNum(lineCode);
// });
// } catch (e) {
// console.log(e);
// }
// setTimeout(f, 30000);
// }();
//未处理消息数量
function setUntreatedNum(lineCode){
var len = $('#messengerList' + lineCode).find('.log-item').length;
var $e = $('#top-tabs-wrap .top-nav li a[data-id='+lineCode+'] span zz:eq(0)');
$e.text(len);
}
//应发未发 班次数量
function setYFWFNum(lineCode){
var size = _data.getYfwfNumByLine(lineCode);
var $e = $('#top-tabs-wrap .top-nav li a[data-id='+lineCode+'] span zz:eq(1)');
$e.text(size);
}
/** 信使操作 */
$('.portlet-fullscreen').on('click', '.log-item-handle a.log-close', function(){
removeLogItem($(this).parents('.log-item'));
});
//80上报事件处理
//同意
$('.portlet-fullscreen').on('click','.log-item-handle .confirm', function(){
send80Reply(this, 0);
});
//不同意
$('.portlet-fullscreen').on('click','.log-item-handle .dissent', function(){
send80Reply(this, -1);
});
function send80Reply(that, reply){
var $handle = $(that).parents('.log-item.handle');
var id = $handle.data('id');
var $run = $handle.find('.log-item-runing');
$run.show();
$.post('/directive/reply80', {id: id, reply: reply}, function(rs){
if(rs.status == 'ERROR')
$run.hide();
if(rs.msg)
layer.alert(rs.msg, {icon: 0});
});
}
var messengerObj = {
init: function(){
$.get('/directive/findNoCofm80', {lineCodes: lineCodes}
, function(rs){
//填充未确认的80数据
for(var lineCode in rs){
$.each(rs[lineCode], function(){
this.dateStr = moment(this.timestamp).format('HH:mm.ss');
this.text = reqCodeMap[this.data.requestCode];
});
rs[lineCode].sort(function(a, b){
return b.timestamp - a.timestamp;
});
var htmlStr = template('console_80_temp', {list: rs[lineCode]});
$('#messengerList' + lineCode).html(htmlStr);
}
});
//消息框滚动条
$('.console-log .log-item-list').slimscroll({
height: '100%'
});
},
setUntreatedNum: setUntreatedNum,
setYFWFNum: setYFWFNum
}
function removeLogItem($that){
var lineCode = $that.parents('.log-item-list').data('code');
console.log('removeLogItem', lineCode);
$that.fadeOut('normal', function(){
$that.remove();
//重新计算信使数量
setUntreatedNum(lineCode);
});
}
countDown('messenger.js');
return messengerObj;
})();