schedulingplan.js
35.5 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
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
var weekOfday = Number(moment().format('E'));//计算今天是这周第几天
var clicknum = 0;//定义上下周点击次数
var startDate, endDate;
var weekNum = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
var fun = {
init: function () {
// 初始化
fun.refreshQueryTime();
//收费员下拉框
fun.initChargerSelect();
// domStr,isNeedAll, plFilterFun, isIncludeRechargePlNo, plBusiType
commSelect.plName_select("#parkIds",null,null,null,3);
$('#scheduType').selectpicker('render');
// 获取今天时间
var todaytime = moment().subtract('days', 0).format('YYYY/MM/DD');
// $('#time-opr-nowtime').text(todaytime);
fun.queryDutyRosterser();
},
//更新查询时间
refreshQueryTime: function () {
var start = weekOfday - 7 * clicknum - 1;
var end = weekOfday - clicknum * 7 - 7;
startDate = moment().subtract('days', start).format('YYYY-MM-DD');
endDate = moment().subtract('days', end).format('YYYY-MM-DD');
//console.log(startDate,endDate);
},
timeoprprevbtn: function () {
$('#time-opr-nextbtn').removeClass('weekActive');
$('#time-opr-prevbtn').addClass('weekActive');
clicknum--;
// if (clicknum == 0) {
// $('#time-opr-prevbtn').addClass('display-none');
// } else {
//
// }
fun.refreshQueryTime();
fun.queryDutyRosterser();
},
timeoprnextbtn: function () {
$('#time-opr-prevbtn').removeClass('weekActive');
$('#time-opr-nextbtn').addClass('weekActive');
if (clicknum == 4) {
return false;
} else {
clicknum++;
console.log(clicknum)
fun.refreshQueryTime();
fun.queryDutyRosterser();
}
},
breakOperFun: function () {
$('#schplan-oper-add').selectpicker('render');
fun.queryNoRestCharger();
},
//调班操作
exchangeOperFun: function () {
fun.queryWorkChargerForDateList();
},
//永久调班操作
exchangeForeverOperFun: function () {
fun.queryChargerInfoForDutyRosterBase();
},
getQueryParam: function () {
var chargeCodes = JSON.parse($('#scheduType').val());
var plNos = JSON.parse($('#parkIds').val());
var req = {
startDate: new Date(startDate + ' 00:00:00'.replace(new RegExp(/-/gm), "/")),
endDate: new Date(endDate + ' 23:59:59'.replace(new RegExp(/-/gm), "/")),
sysCode: sysComm.sysCode,
}
// 视图类型 10:收费员视图 20:停车场视图
if (fun.isChargerView()) {
req.chargeCodes = chargeCodes;
req.viewType = 10;
req.workState = [10, 20, 30, 40];
//$('#scheduType').val();
} else {
req.chargeCodes = [];
req.plNo = plNos;
req.viewType = 20;
req.workState = [10, 40];//停车场视图只需要查询上班的记录
}
return req;
},
//根据停车场编号查询收费员信息
initChargerSelect: function () {
var data = fun.getChargerMsg();
var htmls = '';
var html = '';
var chargerCodes = [];
for (var i = 0; i < data.length; i++) {
chargerCodes.push(data[i].chargerCode);
html += "<option value='[\"" + data[i].chargerCode + "\"]'>" + data[i].chargerName + "</option>";
}
var chargerCodesStr = JSON.stringify(chargerCodes);
htmls = '<option value=' + chargerCodesStr + ' selected>所有收费员</option>' + html;
$("#scheduType").empty();
$("#scheduType").append(htmls);
$('#scheduType').selectpicker('refresh');
},
getChargerMsg: function () {
var plNo = "";
var chargers = "";
var req = {
baseRequest: {pageNum: 1, pageSize: 0},
plNo: plNo,
parkAreaCode: "",
groupCode: "",
onduty: "",
status: "",
nameOrNo: "",
// chargerCodes:fn.getChargerCodes(),
orgId:fn.getOrgId(),
sysCode: sysComm.sysCode
};
var opt = {
async: false,
data: JSON.stringify(req),
method: "POST",
url: dataUrl.util.queryCashierListInfo(),
success: function (res) {
if (res.code == '8888') {
chargers = JSON.stringify(res.data.rows);
}
}
}
sysAjax(opt);
return JSON.parse(chargers);
},
//判断是否收费员视图
isChargerView: function () {
return $('#schtolltype').hasClass('ITD-graynav-topbaractive');
},
/*查询排班计划*/
queryDutyRosterser: function () {
var req = fun.getQueryParam();
var opt = {
method: 'post',
url: dataUrl.util.queryDutyRoster(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
//console.log(res.data);
if (req.viewType == 10) {
//收费员视图
fun.handelChargerViewDutyRosterData(req, res.data);
} else {
//停车场视图
fun.handelParkViewDutyRosterData(req, res.data);
}
}
}
};
sysAjax(opt);
},
/*查询临时调班收费员*/
queryWorkChargerForDateList: function () {
$("#schplan-tboper-add").empty();
$('#schplan-tboper-add').selectpicker('refresh');
var chargerCodeSource = $.trim($('#chargerCodeExchange').val());
var req = {
dutyDay: $("#dutyDayExchange").val(),
sysCode: sysComm.sysCode
}
var opt = {
method: 'post',
url: dataUrl.util.queryWorkChargerForDateList(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
//console.log(res.data);
var data = res.data;
var html = '';
var chargerCodes = [];
for (var i = 0; i < data.length; i++) {
if(chargerCodeSource != data[i].chargerCode){
chargerCodes.push(data[i].chargerCode);
html += "<option value='[\"" + data[i].chargerCode + "\"]' data-dutytype='" + data[i].dutyType + "' >" + data[i].chargerName + "</option>";
}
}
$("#schplan-tboper-add").empty();
$("#schplan-tboper-add").append(html);
$('#schplan-tboper-add').selectpicker('refresh');
$('#achplan_tibanmodel').modal('show');
}
}
};
sysAjax(opt);
},
/*查询永久调班收费员*/
queryChargerInfoForDutyRosterBase: function () {
$("#schplan-ftboper-add").empty();
$('#schplan-ftboper-add').selectpicker('refresh');
var chargerCodeSource =$.trim($('#chargerCodeExchangeForever').val());
var req = {
sysCode: sysComm.sysCode
}
var opt = {
method: 'post',
url: dataUrl.util.queryChargerInfoForDutyRosterBase(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
var data = res.data;
var html = '';
var chargerCodes = [];
for (var i = 0; i < data.length; i++) {
debugger
if(chargerCodeSource != data[i].chargerCode){
chargerCodes.push(data[i].chargerCode);
html += "<option value='[\"" + data[i].chargerCode + "\"]' data-dutytype='" + data[i].dutyType + "' >" + data[i].chargerName + "</option>";
}
}
$("#schplan-ftboper-add").empty();
$("#schplan-ftboper-add").append(html);
$('#schplan-ftboper-add').selectpicker('refresh');
$('#achplan_tipeForever').modal('show');
}
}
};
sysAjax(opt);
},
/*查询永久调班收费员数据*/
queryChargerInfoForDutyRosterBaseOfData: function () {
var req = {
sysCode: sysComm.sysCode
}
var chargerCodes = [];
var opt = {
method: 'post',
url: dataUrl.util.queryChargerInfoForDutyRosterBase(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async:false,
success: function (res) {
if (res.code == '8888') {
var data = res.data;
for (var i = 0; i < data.length; i++) {
chargerCodes.push(data[i].chargerCode);
}
}
}
};
sysAjax(opt);
return chargerCodes;
},
//调班处理
exchangeDutyRoster:function(souceChargerCode,targetChargerCode,dutyDay,exchangeType){
var req = {
sysCode: sysComm.sysCode,
souceChargerCode:souceChargerCode,
targetChargerCode:targetChargerCode,
dutyDay:dutyDay,
exchangeType:exchangeType
}
var opt = {
method: 'post',
url: dataUrl.util.exchangeDutyRoster(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
//1-临时调换 2-永久调换
if(exchangeType == 1){
//
$('#achplan_tibanmodel').modal('hide');
}else{
$('#achplan_tipeForever').modal('hide');
}
fun.queryDutyRosterser();
}else {
alert('调班失败');
}
}
};
sysAjax(opt);
},
/*处理停车场视图排班计划数据*/
handelParkViewDutyRosterData: function (req, data) {
var dateFilterArray = [];
//表头数据初始化
$("#park-wrap").empty();
var html = '<ul class="schedulingplan-data-wrap ITD-common-display-flex">' +
'<li class="width-180 text-center">停车场/时间</li>';
var tempTime = req.startDate;
for (var i = 0; i < 7; i++) {
var day = Number(moment(tempTime).format('E'));
var dateStr = (tempTime.getMonth() + 1) + '月' + tempTime.getDate() + '日 ' + weekNum[day - 1];
html += '<li class="ITD-common-perflex text-center">' + dateStr + '</li>';
dateFilterArray.push(tempTime.getTime());
tempTime.setDate(tempTime.getDate() + 1);
}
html += '</ul>';
$("#park-wrap").html(html);
if (data.length == 0) {
$("#park-wrap").append('<div class="formatNoMatches"></div><div class="text-center padding20-0 ITD-common-fontsize12 ITD-common-color050">暂无数据</div>');
} else {
//数据格式整理
var resData = data;
var parkData = {};
var berthData = {};
var groupData = {};
var dutyDayData = {};
var data = {};
$.each(resData, function (index, item) {
var plNo = item.plNo;
var berthNo = item.berthRangeNo;
var groupId = item.groupId;
var dutyDay = item.dutyDay;
if (parkData[plNo] == undefined || parkData[plNo] == null) {
parkData[plNo] = item.plName;
data[plNo] = {};
}
if (data[plNo][berthNo] == undefined || data[plNo][berthNo] == null) {
berthData[berthNo] = item.berthRangeName;
data[plNo][berthNo] = {};
}
if (data[plNo][berthNo][groupId] == undefined || data[plNo][berthNo][groupId] == null) {
groupData[groupId] = {};
groupData[groupId].groupName = item.groupName;
groupData[groupId].groupStartTime = item.groupStartTime;
groupData[groupId].groupEndTime = item.groupEndTime;
data[plNo][berthNo][groupId] = {};
}
if (data[plNo][berthNo][groupId][dutyDay] == undefined || data[plNo][berthNo][groupId][dutyDay] == null) {
dutyDayData[dutyDay] = {};
dutyDayData[dutyDay].dutyDay = item.dutyDay;
data[plNo][berthNo][groupId][dutyDay] = [];
}
data[plNo][berthNo][groupId][dutyDay].push(item);
});
//console.log('data:');
//console.log(data);
html = '<div class="schedulingplan-main-wrap">';
for (var plNo in data) {
html += '<ul class="schedulingplan-park-wrap ITD-common-display-flex ITD-common-fontsize12">' +
'<li class="width-50 border-right-bottom pos-rel ITD-overflowhidden">' +
'<div class=" pos-abs between-pos ITD-common-fontsize14 margin-bottom-5 text-left width16" title="' + fun.strFormatter(parkData[plNo]) + '">' + fun.strFormatter(parkData[plNo]) + '</div>' +
'</li>' +
' <li class=" ITD-common-perflex">';
for (var berth in data[plNo]) {
html += '<ul class="schedulingplan-parkright-wrap ITD-common-display-flex ">' +
'<li class="width-50 text-center border-right-bottom pos-rel ITD-overflowhidden ">' +
'<div class="width16 text-center pos-abs between-pos " title="' + fun.strFormatter(berthData[berth]) + '">' + fun.strFormatter(berthData[berth]) + '</div>' +
'</li>' +
'<li class="ITD-common-perflex border-right-bottom">';
for (var group in data[plNo][berth]) {
html += '<ul class="interval-wrap ITD-common-display-flex ">' +
'<li class="width-90 border-right-bottom schedulingmanage-com-margin ">' +
'<div>' + fun.strFormatter(groupData[group].groupName) + '</div>' +
'<div>' + fun.strFormatter((DateUtils.long2String(groupData[group].groupStartTime, 3)).substr(0, 5)) + '</div>' +
'<div class="" style="padding-left: 10px;">-</div>' +
'<div>' + fun.strFormatter((DateUtils.long2String(groupData[group].groupEndTime, 3)).substr(0, 5)) + '</div>' +
'</li>';
$.each(dateFilterArray, function (index, filter) {
var isFind = false;
//console.log('filter====================:'+DateUtils.long2String(filter, 1));
for (var dutyDay in data[plNo][berth][group]) {
//;
//console.log('duty:'+dutyDay);
//console.log('duty:'+DateUtils.long2String(parseInt(dutyDay), 1));
if (DateUtils.long2String(filter, 1) == DateUtils.long2String(parseInt(dutyDay), 1)) {
isFind = true;
var tempHtml = '<li class="ITD-common-perflex border-right-bottom schedulingmanage-com-margin ">';
for (var i in data[plNo][berth][group][dutyDay]) {
var temp = data[plNo][berth][group][dutyDay][i];
if (temp.workState == 10) {//正常上班
tempHtml += '<div>' + fun.strFormatter(temp.chargerName) + '</div>';
} else if (temp.workState == 40) {//代班
tempHtml += '<div class="replace-person">' + fun.strFormatter(temp.chargerName) + ' <span>' + fun.strFormatter(temp.chargerNameRep) + '</span></div>';
}
}
tempHtml += '</li>';
html += tempHtml;
}
}
if (!isFind) {
html += '<li class="ITD-common-perflex border-right-bottom schedulingmanage-com-margin "><div>暂无排班</div></li>';
}
});
html += '</ul>';
}
html += '</li></ul>';
}
html += '</li></ul>';
}
html += '</div>';
$("#park-wrap").append(html);
}
},
/*处理收费员视图排班计划数据*/
handelChargerViewDutyRosterData: function (req, data) {
//数据初始化
var dateFilterArray = [];
$("#toll-wrap").empty();
var html = '<ul class="schedulingplan-data-wrap ITD-common-display-flex">' +
'<li class="width-90 text-center">收费员/时间</li>';
var tempTime = req.startDate;
for (var i = 0; i < 7; i++) {
var day = Number(moment(tempTime).format('E'));
var dateStr = (tempTime.getMonth() + 1) + '月' + tempTime.getDate() + '日 ' + weekNum[day - 1];
html += '<li class="ITD-common-perflex text-center">' + dateStr + '</li>';
dateFilterArray.push(tempTime.getTime());
tempTime.setDate(tempTime.getDate() + 1);
}
html += '</ul>';
$("#toll-wrap").html(html);
if (data.length == 0) {
$("#toll-wrap").append('<div class="formatNoMatches"></div><div class="text-center padding20-0 ITD-common-fontsize12 ITD-common-color050">暂无数据</div>');
} else {
//数据格式整理
var resData = data;
var chargerData = {};
var data = {};
$.each(resData, function (index, item) {
var chargerCode = item.chargerCode;
if (data[chargerCode] == undefined || data[chargerCode] == null) {
chargerData[chargerCode] = {};
chargerData[chargerCode] = item.chargerName;
data[chargerCode] = [];
}
data[chargerCode].push(item);
});
var foreverChargerCodeArray = fun.queryChargerInfoForDutyRosterBaseOfData();
//填充内容
html = '<div class="schedulingplan-main-wrap">';
for (var chargerCode in data) {
html += '<ul class="schedulingplan-con-wrap ITD-common-display-flex ITD-common-fontsize12">';
html += '<li class="width-90 text-center"><div class="ITD-common-fontsize16 margin-bottom-10 ITD-hidden-nowrap">' + fun.strFormatter(chargerData[chargerCode]) + '</div>' +
'<div class="ITD-common-fontsize12 ITD-common-color070 ">' + fun.strFormatter(chargerCode) + '</div>' ;
if(foreverChargerCodeArray.indexOf(chargerCode)>-1){
html += '<div class="schedulingplan-forfalls" chargerCode=' + chargerCode + ' >永久调班</div></li>';
}
$.each(dateFilterArray, function (index, filter) {
var isFind = false;
for (var i in data[chargerCode]) {
var _item = data[chargerCode][i];
if (DateUtils.long2String(filter, 1) == DateUtils.long2String(parseInt(_item.dutyDay), 1)) {
isFind = true;
if (_item.workState == 10) {//正常工作
html += '<li class="ITD-common-perflex ITD-common-color070 schedulingplan-falls-wrap ITD-hidden-nowrap">' +
'<div class="ITD-hidden-nowrap" title="' + fun.strFormatter(_item.plName) + '">' + fun.strFormatter(_item.plName) + '</div>' +
'<div class="ITD-hidden-nowrap" title="' + fun.strFormatter(_item.berthRangeName) + '"> ' + fun.strFormatter(_item.berthRangeName) + '</div>' +
'<div>' + fun.strFormatter(_item.groupName) + '</div>' +
'<div>' + fun.strFormatter((DateUtils.long2String(_item.groupStartTime, 3)).substr(0, 5)) + ' - ' + fun.strFormatter((DateUtils.long2String(_item.groupEndTime, 3)).substr(0, 5)) + '</div>' +
'<span class="schedulingplan-falls schedulingplan-tipex" dutyDay="' + _item.dutyDay + ' "chargerCode="' + _item.chargerCode + '"planId="' + _item.planId + '">调休</span>' +
'<span class="schedulingplan-falls schedulingplan-tipebanx" dutyDay="' + _item.dutyDay + ' "chargerCode="' + _item.chargerCode + ' "planId="' + _item.planId + '">调班</span>' +
'</li>';
} else if (_item.workState == 20) {//休息
html += '<li class="ITD-common-perflex text-center ITD-common-color070 schedulingplan-rest ">休息</li>';
} else if (_item.workState == 30) {//调休
html += '<li class="ITD-common-perflex ITD-common-color070 schedulingplan-falls-wrap schedulingplan-adjust-wrap ITD-hidden-nowrap">' +
'<div class="ITD-hidden-nowrap" title="' + fun.strFormatter(_item.plName) + '">' + fun.strFormatter(_item.plName) + '</div>' +
'<div class="ITD-hidden-nowrap" title="' + fun.strFormatter(_item.berthRangeName) + '">' + fun.strFormatter(_item.berthRangeName) + '</div>' +
'<div class="replace-person">' + fun.strFormatter(_item.groupName) + ' <span>' + fun.strFormatter(_item.chargerNameRep) + '</span></div>' +
'<div>' + fun.strFormatter((DateUtils.long2String(_item.groupStartTime, 3)).substr(0, 5)) + ' - ' + fun.strFormatter((DateUtils.long2String(_item.groupEndTime, 3)).substr(0, 5)) + '</div>' +
//'<div class="schedulingplan-falls">调休</div>'+
'</li>';
} else if (_item.workState == 40) {//代班
html += '<li class="ITD-common-perflex ITD-common-color070 schedulingplan-falls-wrap ITD-hidden-nowrap schedulingplan-replace-wrap">' +
'<div class="ITD-hidden-nowrap" title="' + fun.strFormatter(_item.plName) + '">' + fun.strFormatter(_item.plName) + '</div>' +
'<div class="ITD-hidden-nowrap" title="' + fun.strFormatter(_item.berthRangeName) + '">' + fun.strFormatter(_item.berthRangeName) + '</div>' +
'<div class="replace-person">' + fun.strFormatter(_item.groupName) + ' <span>' + fun.strFormatter(_item.chargerNameRep) + '</span></div>' +
'<div>' + fun.strFormatter((DateUtils.long2String(_item.groupStartTime, 3)).substr(0, 5)) + ' - ' + fun.strFormatter((DateUtils.long2String(_item.groupEndTime, 3)).substr(0, 5)) + '</div>' +
//'<div class="schedulingplan-falls">调休</div>'+
'</li>';
}
}
}
if (!isFind) {
html += '<li class="ITD-common-perflex text-center ITD-common-color070 schedulingplan-rest ">暂无排班</li>';
}
});
html += '</ul>';
}
$("#toll-wrap").append(html);
}
},
strFormatter: function (value) {
if (value == undefined || value == null || value == "") {
return '-';
}
return value;
},
/**
* todo 查询组织下排班计划中的收费员
*/
/*查询对应日期休息的收费员*/
queryNoRestCharger: function () {
$("#schplan-oper-add").empty();
$('#schplan-oper-add').selectpicker('refresh');
var req = {
planId: $("#planId").val(),
dutyDay: $("#dutyDay").val(),
sysCode: sysComm.sysCode
}
var opt = {
method: 'post',
url: dataUrl.util.queryRelaxChargerList(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
//console.log(res.data);
var data = res.data;
var html = '';
var chargerCodes = [];
if (data.length == 0) {
$('#achplan_notipe').modal('show');
} else {
for (var i = 0; i < data.length; i++) {
chargerCodes.push(data[i].chargerCode);
html += "<option value='[\"" + data[i].chargerCode + "\"]' data-dutytype='" + data[i].dutyType + "' >" + data[i].chargerName + "</option>";
}
$("#schplan-oper-add").empty();
$("#schplan-oper-add").append(html);
$('#schplan-oper-add').selectpicker('refresh');
console.log(data.length)
$('#achplan_tipe').modal('show');
}
}
}
};
sysAjax(opt);
},
/*保存调休记录*/
saveTakeRestRecord: function () {
if ($("#schplan-oper-add").val() == undefined || $("#schplan-oper-add").val() == null || $("#schplan-oper-add").val() == '') {
return;
}
var option = $("#schplan-oper-add").find("option:selected");
var req = {
dutyDay: $("#dutyDay").val(),
chargerCode: $("#chargerCode").val(),
dutyType: option.data('dutytype'),
chargeCodeRep: JSON.parse(option.val())[0],
chargeCodeRepName: option.text(),
sysCode: sysComm.sysCode
}
var opt = {
method: 'post',
url: dataUrl.util.saveTakeRestRecord(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
console.log(res.data);
$('#achplan_tipe').modal('hide');
fun.queryDutyRosterser();
}
}
};
sysAjax(opt);
}
};
fun.init();
//切换 搜索部分 是否生效
documentBindFunc.on('click', "#schplan-toptab-ser div.ITD-graynav-topbar", function () {
$(this).addClass('ITD-graynav-topbaractive').siblings('div').removeClass('ITD-graynav-topbaractive');
$("#park-wrap").empty();
fun.queryDutyRosterser();
});
documentBindFunc.on('click', '#schparktype', function () {
$('#parkingtype').removeClass('display-none');
$('#park-wrap').removeClass('display-none');
$('#tolltype').addClass('display-none');
$('#toll-wrap').addClass('display-none');
$('#queryType').attr('data-value', '1');
//切换完后,调用查询表格
// fun.createTableData();
});
documentBindFunc.on('click', '#schtolltype', function () {
$('#tolltype').removeClass('display-none');
$('#toll-wrap').removeClass('display-none');
$('#parkingtype').addClass('display-none');
$('#park-wrap').addClass('display-none');
$('#queryType').attr('data-value', '2');
//切换完后,调用查询表格
// fun.createTableData();
});
// 查询按钮
documentBindFunc.on('click', '#chargegroup-queryBtnser', function () {
fun.queryDutyRosterser();
});
// 上一周点击time-opr-prevbtn
documentBindFunc.on('click', '#time-opr-prevbtn', function () {
fun.timeoprprevbtn();
});
// 下一周点击time-opr-nextbtn
documentBindFunc.on('click', '#time-opr-nextbtn', function () {
fun.timeoprnextbtn();
});
// 调休弹窗
documentBindFunc.on('click', '.schedulingplan-tipex', function () {
$("#dutyDay").val('');
$("#chargerCode").val('');
$("#planId").val('');
$("#dutyDay").val($(this).attr('dutyDay'));
$("#chargerCode").val($(this).attr('chargerCode'));
$("#planId").val($(this).attr('planId'));
fun.breakOperFun();
});
// 调休保存按钮
documentBindFunc.on('click', '#planbreak-submit', function () {
fun.saveTakeRestRecord();
});
//调班弹窗 schedulingplan-tipebanx
documentBindFunc.on('click', '.schedulingplan-tipebanx', function () {
$("#dutyDayExchange").val('');
$("#chargerCodeExchange").val('');
$("#planIdExchange").val('');
$("#dutyDayExchange").val($(this).attr('dutyDay'));
$("#chargerCodeExchange").val($(this).attr('chargerCode'));
$("#planIdExchange").val($(this).attr('planId'));
console.log($(this).attr('dutyDay') + 'dutyDay');
fun.exchangeOperFun();
$('#schplan-tboper-add').selectpicker('render');
$('#achplan_tibanmodel').modal('show');
});
//永久调班弹窗
documentBindFunc.on('click', '.schedulingplan-forfalls', function () {
$("#dutyDayExchangeForever").val('');
$("#chargerCodeExchangeForever").val('');
$("#planIdExchangeForever").val('');
//
$("#dutyDayExchangeForever").val($(this).attr('dutyDay'));
$("#chargerCodeExchangeForever").val($(this).attr('chargerCode'));
$("#planIdExchangeForever").val($(this).attr('planId'));
fun.exchangeForeverOperFun();
//x下拉框初始化
$('#schplan-ftboper-add').selectpicker('render');
//时间初始化
$('#schefdaterange-btnsta').val(moment().subtract('days', -1).format('YYYY-MM-DD'));
//开始日期
$("#schefdaterange-btnsta").datetimepicker({
startDate: moment().subtract('days', -1).format('YYYY-MM-DD'),
format: 'yyyy-mm-dd',
autoclose: true,
startView: 2,
//maxDate:moment().subtract('months', 3),
minView: 2,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-right"
});
$('#achplan_tipeForever').modal('show');
});
// 调班保存按钮
documentBindFunc.on('click', '#planbreak-tbsubmit', function () {
var souceChargerCode = $.trim($('#chargerCodeExchange').val());
var targetChargerCode = JSON.parse($('#schplan-tboper-add').val())[0];
var dutyDay = $('#dutyDayExchange').val();
var exchangeType = 1;
fun.exchangeDutyRoster(souceChargerCode,targetChargerCode,dutyDay,exchangeType);
});
// 永久调班保存按钮
documentBindFunc.on('click', '#planbreak-ftbsubmit', function () {
var souceChargerCode = $.trim($('#chargerCodeExchangeForever').val());
var targetChargerCode = JSON.parse($('#schplan-ftboper-add').val())[0];
var dutyDay = new Date($('#schefdaterange-btnsta').val().replace(/-/g,"/"));
var exchangeType = 2;
fun.exchangeDutyRoster(souceChargerCode,targetChargerCode,dutyDay,exchangeType);
});
//导出
var InterValObj; //timer变量,控制时间
var count = 8; //间隔函数,1秒执行
var curCount;//当前剩余秒数
function sendMessage() {
curCount = count;
//设置button效果,开始计时
$("#sch_exportBtn").attr("disabled", "true");
$(".ITD-export-btn").css("width", "138px");
$("#sch_exportBtn").val(curCount + "秒后可再次导出");
InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器,1秒执行一次
}
//timer处理函数
function SetRemainTime() {
if (curCount == 0) {
window.clearInterval(InterValObj);//停止计时器
$("#sch_exportBtn").removeAttr("disabled");//启用按钮
$(".ITD-export-btn").css("width", "72px");
$("#sch_exportBtn").val("导出");
} else {
curCount--;
$("#sch_exportBtn").val(curCount + "秒后可再次导出");
}
}
//导出excle
documentBindFunc.on('click', '#sch_exportBtn', function () {
//获取table所有行数据
// var parkLot = $("#recordtable").bootstrapTable('getData');
var parkLot = "保证有数据导出";
//获取table总条数
// var numTotal = $("#recordtable").bootstrapTable('getOptions').totalRows;
var numTotal = 100;
if (parkLot.length < 1) {
$('.ITD-alertmodel-contentmsg').text('无数据可导出!');
$('#ITD-tipsmodel').modal('show');
setTimeout(function () {
$('.ITD-alertmodel-contentmsg').text('');
$('#ITD-tipsmodel').modal('hide');
}, 3000);
return false;
}
if (numTotal > 10000) {
$('.ITD-alertmodel-contentmsg').text('数据量过大,请缩小查询范围!');
$('#ITD-tipsmodel').modal('show');
setTimeout(function () {
$('.ITD-alertmodel-contentmsg').text('');
$('#ITD-tipsmodel').modal('hide');
}, 3000);
return false;
}
//执行倒计时函数
sendMessage();
var params = fun.getQueryParam();
var url = dataUrl.util.excleDutyRosterList();
url += '?sysCode=' + params.sysCode;
if (null != params.startDate && "" != params.startDate) {
var tempDate = params.startDate;
var startDate = DateUtils.date2String(tempDate, 7);
url += '&startDate=' + startDate;
tempDate.setDate(tempDate.getDate() + 27);
var endDate = DateUtils.date2String(tempDate, 7);
url += '&endDate=' + endDate;
}
var orgId = fn.getOrgId();
if (orgId != null) {
url += '&orgId=' + orgId;
}
url = encodeURI(url);
window.downloadFile(url);
});
//导出功能
window.downloadFile = function (sUrl) {
//iOS devices do not support downloading. We have to inform user about this.
if (/(iP)/g.test(navigator.userAgent)) {
alert('Your device does not support files downloading. Please try again in desktop browser.');
return false;
}
//If in Chrome or Safari - download via virtual link click
if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
//Creating new link node.
var link = document.createElement('a');
link.href = sUrl;
if (link.download !== undefined) {
//Set HTML5 download attribute. This will prevent file from opening if supported.
var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
link.download = fileName;
}
//Dispatching click event.
if (document.createEvent) {
var e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
link.dispatchEvent(e);
return true;
}
}
// Force file download (whether supported by server).
if (sUrl.indexOf('?') === -1) {
sUrl += '?download';
}
window.open(sUrl, '_self');
return true;
}
window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;