rightMenu.js
7.65 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
/**
* 右键菜单
*/
var _menu = (function() {
$('#rightMenu .menu-item button').on('click', function(){
var method = $(this).data('method')
,id = $('.pb-table tr td.active-menu').parent().data('id');
if(!id){
layer.alert('无法获取当前选中项', {icon: 2, title: '异常'});
return;
}
var schedul = _data.getSchedulById(id);
if(!schedul){
layer.alert('无法找到当前项对应的班次信息,请尝试刷新页面!', {icon: 2, title: '异常'});
return;
}
menuObject[method](schedul);
});
// 表格右键呼出菜单
var ac = 'active-menu'
,items = '.pb-table.data tr td[name!=lineNo]';
$('.portlet-fullscreen').on('contextmenu', items,
function(e) {
e.preventDefault();
$('.pb-table tr td.' + ac).removeClass(ac);
var item = $(this);
item.addClass(ac);
showMenu(e.pageX, e.pageY + 3);
$(document).one('click', function() {
$('#rightMenu').removeClass('show-menu');
item.removeClass(ac);
});
})
// 点击选中
.on('click',items, function() {
$('.pb-table tr td.' + ac).removeClass(ac);
$(this).addClass(ac);
});
var menuObject = {
//待发调整
outgoAdjust: function(schedul){
var index = layer.open({
type: 1,
area: ['630px', '545px'],
maxmin: true,
skin:'layui-layer-molv',
content: template('outgo_adjust_body_temp', schedul),
shift: 5,
title: '待发调整',
success: function(){
dictionaryUtils.transformDom($('#outgoAdjustForm .nt-dictionary'));
$('#outgoAdjustForm button.confirm').one('click', function(){
var params = $('#outgoAdjustForm').serializeJSON();
$post('/realSchedule/outgoAdjust', params, function(rs){
layer.close(index);
layer.msg('调整成功!');
schedul.dfsj = rs.dfsj;
schedul.remarks = rs.remarks;
_alone.refreshSchedule(schedul);
});
});
}
});
},
//计划烂班
planDestroy: function(schedul){
var data = {item: schedul, array : _data.getSchedulByVeh(schedul.clZbh)}
var index = layer.open({
type: 1,
area: ['370px', '645px'],
maxmin: true,
skin:'layui-layer-molv',
content: template('plan_destroy_body_temp', data),
shift: 5,
title: '计划烂班设置',
success: function(){
var f = $('#planDestroyForm');
//红色
$('.icheck', f).iCheck({
checkboxClass: 'icheckbox_square-red',
increaseArea: '20%'
});
//蓝色
$('.icheck-blue', f).iCheck({
checkboxClass: 'icheckbox_minimal-blue',
increaseArea: '20%'
});
$('[data-toggle="tooltip"]', f).tooltip();
//滚动到选中项
var cont = $('.custom-check-box', f)
,checked = $('.icheck:checked', f);
if(checked.length > 0){
cont.animate({
scrollTop: checked.offset().top - cont.offset().top + checked.scrollTop()
}, 500);
}
//确定
$('button.confirm', f).on('click', function(){
f.submit();
});
f.validate({
submitHandler : function(){
var params = f.serializeJSON()
,text = '确定烂掉部分班次['+schedul.clZbh+'] '
,idsStr = '';
$.each(params.ids, function(i, id){
var s = _data.getSchedulById(id);
text += (s.fcsj + ', ');
idsStr += (id + ',');
});
text = text.substr(0, text.length - 2);
if(params.spaceAdjust == 1){
text += '<br>并自动调整后续班次间隔 <span class="font-red">'+params.spaceNum+'</span>分钟'
}
layer.close(index);
//弹出确认框
index = layer.confirm(text, {
btn : [ '确定烂班' , '取消' ],
icon : 3,
shift: 5,
skin : 'layui-layer-cfm-delete'
}, function(){
params.idsStr = idsStr;
$post('/realSchedule/destroy', params, function(rs){
layer.close(index);
$.each(rs.list, function(){
var old = _data.getSchedulById(this.id);
old.dfsj = this.dfsj;
old.dfsjT = this.dfsjT;
old.remarks = this.remarks;
old.status = this.status;
_alone.refreshSchedule(old);
});
layer.msg('调整间隔成功!');
_alone.calculateLineNo($('tr[data-id='+schedul.id+']').parents('table')[0]);
});
});
return false;
}
});
}
});
},
//实发调整
realOutgoAdjust: function(){
layer.open({
type: 1,
area: ['350px', '455px'],
maxmin: true,
skin:'layui-layer-molv',
content: template('real_outgo_adjust_body_temp', {}),
shift: 5,
title: '实发调整',
success: function(){
}
});
},
//子任务
childTask: function(schedul){
var layIndex = layer.msg('加载中...', {icon: 16});
$.get('/pages/control/line/child_pages/child_task.html', function(content){
layer.close(layIndex);
layer.open({
type: 1,
area: '930px',
maxmin: true,
content: content,
shift: 5,
title: '临加/子任务',
success: function(){
dictionaryUtils.transformDom($('#childTaskDiv .nt-dictionary'));
$('#childTaskDiv').trigger('init', {
selected: schedul,
_data: _data,
_alone: _alone
});
}
});
});
},
//临加班次
temporaryAdd: function(schedul){
$.get('/pages/control/line/child_pages/temporary_add.html', function(content){
layer.open({
type: 1,
area: ['930px', '785px'],
maxmin: true,
skin:'layui-layer-molv',
content: content,
shift: 5,
title: '临加/抽增',
success: function(){
$('#temporaryAddDiv').trigger('init', {data: _data.getLineLpMap(), selected: schedul});
}
});
});
},
//调整人车
vehicAndPerAdjust: function(){
$.get('/pages/control/line/child_pages/vehicAndper_adjust.html', function(content){
layer.open({
type: 1,
area: ['730px', '655px'],
maxmin: true,
skin:'layui-layer-molv',
content: content,
shift: 5,
title: '调整85路车辆/人员',
success: function(){
}
});
});
},
//指令重发
directiveRepeat: function(schedul){
var text = '[路牌: '+schedul.lpName+' 计划时间:'+schedul.fcsj+' 待发时间:'+schedul.dfsj+']';
var index = layer.confirm(schedul.clZbh + '重发调度指令? ' + text, {
btn : [ '是' , '否' ],
icon : 3,
shift: 5
}, function(){
//走短语下发
layer.close(index);
layer.msg('正在下发指令', {icon: 16});
$.post('/directive/phrase', {nbbm: schedul.clZbh, text: text},
function(code){
if(code == 0){
layer.msg('发送成功');
}
else
layer.alert('发送调度指令失败', {icon: 2, title: '操作失败'});
});
});
}
}
function showMenu(x, y) {
var menu = $('#rightMenu'),
docWidth = $(document).width(), docHeight = $(document).height(),
menuHeight = menu.height(),
menuWidth = menu.width(),
offset = 12;
/* 边界 */
if (y > (docHeight - menuHeight)) {
y = docHeight - menuHeight - offset;
}
if (x > (docWidth - (menuWidth * 2))) {
x = docWidth - (menuWidth * 2) - offset;
}
menu.css('left', x + 'px')
.css('top', y + 'px')
.addClass('show-menu');
}
return menuObject;
})();