alone.js
3 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
/**
* 单线路调度
*/
var _alone = (function(){
var upCode = 0
,downCode = 1;
var aloneObject = {
init: function(cb){
_data.queryRealSchedule(lineCodes, function(schList){
var schTempList;
for(var lineCode in lineMap){
schTempList = schList[lineCode];
tab = $('#tab_line_' + lineCode);
tab.append(template('alone_main_temp', lineMap[lineCode]));
//有排班数据
if(schTempList){
var rs = splitDir(schTempList);
//填充表格数据
calculateLineNo(
tab.find('table[data-type=up] tbody').html(template('alone_plan_table_temp', {list: rs.up}))[0]
);
calculateLineNo(
tab.find('table[data-type=down] tbody').html(template('alone_plan_table_temp', {list: rs.down}))[0]
);
//滚动条
tab.find('._body').slimscroll({
height: 'calc(100% - 80px)',
alwaysVisible: true
});
}
_data.queryStationRoute(lineCode , 'lineSvg' + lineCode , drawSvg.initAloneSvg);
}
$('.console-log .log-item-list').slimscroll({
height: '100%'
})
//托管Question
$('#tgQuestion').popover({
content: template('tg_question_info_temp', {}),
html: true,
placement: 'left',
trigger: 'hover',
container: '.portlet-fullscreen'
});
initRemarksPop();
cb && cb();
});
},
//刷新单个班次
refreshSchedule: function(schedule){
//xlBm
var $tr = $('tr[data-id='+schedule.id+']', '#tab_line_' + schedule.xlBm)
,newTr = template('alone_plan_table_temp', {list: [schedule]});
$tr.replaceWith(newTr);
initRemarksPop();
},
//添加一个班次到表格
addScheduleToTable: function(schedule){
var upDown = schedule.xlDir==0?'up':'down';
//重新渲染表格
var table = $('#tab_line_' + schedule.xlBm).find('.pb-table[data-type='+upDown+']');
//获取班次信息
var schArray = _data.findSchByLine(schedule.xlBm, schedule.xlDir);
calculateLineNo(
table.find('tbody').html(template('alone_plan_table_temp', {list: schArray}))[0]
);
var currTr = table.find('tr[data-id='+schedule.id+']');
console.log(currTr);
//重新设置滚动条,
table.find('._body').slimscroll({
height: 'calc(100% - 80px)',
alwaysVisible: true,
start: currTr
});
},
//重新计算行号
calculateLineNo: calculateLineNo
}
//计算行号
function calculateLineNo(table){
var rows = table.rows;
$.each(rows,function(i, r){
var cells = r.cells;
$(cells[0]).text(i + 1);
});
}
function splitDir(list){
var rs = {up: [], down: []};
$.each(list, function(){
if(this.xlDir == upCode)
rs.up.push(this);
else
rs.down.push(this);
});
return rs;
}
function initRemarksPop(){
//备注POPOVER
$('.remarks-popover', '.pb-table').popover({trigger: 'hover',container: '.portlet-fullscreen',placement:'bottom'});
}
return aloneObject;
})();