rightMenu.js
4.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
/**
* 右键菜单
*/
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;
}
console.log(schedul);
menuObject[method](schedul);
});
var menuObject = {
bindClickMenu : function() {
var ac = 'active-menu';
// 表格右键呼出菜单
$('.pb-table.data tr td[name!=lineNo]').on('contextmenu',
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', function() {
$('.pb-table tr td.' + ac).removeClass(ac);
$(this).addClass(ac);
});
},
//待发调整
outgoAdjust: function(schedul){
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(){
$('#outgoAdjustForm button.confirm').one('click', function(){
var params = $('#outgoAdjustForm').serializeJSON();
console.log(params);
});
}
});
},
//计划烂班
planDestroy: function(){
layer.open({
type: 1,
area: ['370px', '585px'],
maxmin: true,
skin:'layui-layer-molv',
content: template('plan_destroy_body_temp', {}),
shift: 5,
title: '计划烂班设置',
success: function(){
$('#planDestroyForm .icheck').iCheck({
checkboxClass: 'icheckbox_square-red',
increaseArea: '20%'
});
}
});
},
//实发调整
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(){
$.get('/pages/control/line/child_pages/child_task.html', function(content){
layer.open({
type: 1,
area: ['930px', '885px'],
maxmin: true,
skin:'layui-layer-molv',
content: content,
shift: 5,
title: '子任务编辑',
success: function(){
}
});
});
},
//临加班次
temporaryAdd: function(){
$.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(){
}
});
});
},
//调整人车
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(){
}
});
});
}
}
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;
})();