44323
2023-10-13 4433f665bf1eccaeee8de43b08095bf4e576fc5d
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
/**
 * 司机审核列表管理初始化
 */
var YesDriver = {
    id: "YesDriverTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
var language =$("#language").val()
/**
 * 初始化表格的列
 */
YesDriver.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: language==1?'添加时间':(language==2?'Add Time':'Tambahkan waktu'), field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'7%',
            formatter:function (data) {
                return currentTime(data);
            }
        },
        {title: language==1?'姓名':(language==2?'name':'Nama Lengkap'), field: 'driverName', visible: true, align: 'center', valign: 'middle',width:'5%',
            // formatter: function (value, row) {
            //     var btn = "";
            //     if(row.name != '' && row.name != null) {
            //         btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.name + '" onfocus="TUser.tooltip()">' + row.name + '</p>']
            //     }
            //     return btn;
            // }
        },
        {title: language==1?'头像':(language==2?'portrait':'potret'), field: 'headImgUrl', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                if (row.headImgUrl == null || row.headImgUrl == '') {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 50px;height:50px;" src="' + Feng.ctxPath + '/img/NoPIC.png" /></a>';
                } else {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 90px;height:50px;" src="' + row.headImgUrl + '" /></a>';
                }
            },
            events: 'operateEvents'
        },
        {title: language == 1 ? '手机号' : ( language == 2 ? 'phone' : 'nomor ponsel'), field: 'phone', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.phone != '' && row.phone != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.phone + '" onfocus="TUser.tooltip()">' + row.phone + '</p>']
                }
                return btn;
            }
        },
        {title: language==1?'性别':(language==2?'Gender':'Jenis kelamin'), field: 'sex', visible: true, align: 'center', valign: 'middle',width:'3%',
            formatter: function (value, row) {
                var btn = "";
                if(language==1){
                    if(row.sex != '' && row.sex != null) {
                        if (row.sex == 1) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="男" onfocus="TUser.tooltip()">男</p>']
                        }else if (row.sex == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="女" onfocus="TUser.tooltip()">女</p>']
                        }
                    }
                }else if(language==2){
                    if(row.sex != '' && row.sex != null) {
                        if (row.sex == 1) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="man" onfocus="TUser.tooltip()">man</p>']
                        }else if (row.sex == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="woman" onfocus="TUser.tooltip()">woman</p>']
                        }
                    }
                }else {
                    if(row.sex != '' && row.sex != null) {
                        if (row.sex == 1) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="laki-laki" onfocus="TUser.tooltip()">laki-laki</p>']
                        }else if (row.sex == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="wanita" onfocus="TUser.tooltip()">wanita</p>']
                        }
                    }
                }
                return btn;
            }
        },
        {title:language==1?'所属机构':(language==2?'Affiliated organization':'Organisasi Afiliasi'), field: 'name', visible: true, align: 'center', valign: 'middle',width:'8%',
        },
        {title: language==1?'当前车辆':(language==2?'Current vehicle':'Kendaraan saat ini'), field: 'carId', visible: true, align: 'center', valign: 'middle',width:'7%',
        },
        {title: language==1?'服务模式':(language==2?'Service mode':'Mode Layanan'), field: 'types', visible: true, align: 'center', valign: 'middle',width:'7%',
        },
        {title: language==1?'评分':(language==2?'Rate':'Kecepatan'), field: 'score', visible: true, align: 'center', valign: 'middle',width:'7%',
        },
        {title: language==1?'司机等级':(language==2?'Driver grade':'Nilai pengemudi'), field: 'level', visible: true, align: 'center', valign: 'middle',width:'7%',
            formatter: function (value, row) {
                return value;
            }
        },
        {title: language==1?'历史接单数':(language==2?'Numebr of historical order':'Numebr of Historical Order'), field: 'orderNum', visible: true, align: 'center', valign: 'middle',width:'7%',
        },
        {title: language==1?'历史订单总金额':(language==2?'Total historical order amount':'Jumlah perintah sejarah total'), field: 'money', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter:function (data){
                return "Rp"+data;
            }
        },
        {title: language==1?'当前钱包余额':(language==2?'Current wallet balance':'Balansi dompet saat ini'), field: 'balance', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                return "Rp"+value;
            }
        },
        {title: language==1?'代扣金额':(language==2?'Amount withheld':'Jumlah yang ditahan'), field: 'withholding', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                return "Rp"+value;
            }
        },
        {title: language==1?'状态':(language==2?'State':'Status'), field: 'authState', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.authState != '' && row.authState != null) {
                    if(language==1){
                        if (row.authState == 2) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="正常" onfocus="TUser.tooltip()">正常</p>']
                        }else if (row.authState == 3){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="冻结" onfocus="TUser.tooltip()">冻结</p>']
                        }else if (row.authState == 1) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #4858ff;" title="待审核" onfocus="TUser.tooltip()">待审核</p>']
                        }else if (row.authState == 4){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: rgba(60,70,63,0.54)" title="已拒绝" onfocus="TUser.tooltip()">已拒绝</p>']
                        }
                    }else if(language==2){
                        if (row.authState == 2) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="normal" onfocus="TUser.tooltip()">normal</p>']
                        }else if (row.authState == 3){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="freeze" onfocus="TUser.tooltip()">freeze</p>']
                        }else if (row.authState == 1) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #4858ff;" title="Pending review" onfocus="TUser.tooltip()">Pending review</p>']
                        }else if (row.authState == 4){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: rgba(60,70,63,0.54)" title="Has been rejected" onfocus="TUser.tooltip()">Has been rejected</p>']
                        }
                    }else {
                        if (row.authState == 2) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="normal" onfocus="TUser.tooltip()">normal</p>']
                        }else if (row.authState == 3){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="Membekukan" onfocus="TUser.tooltip()">Membekukan</p>']
                        }else if (row.authState == 1) {
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #4858ff;" title="Tinjauan tertunda" onfocus="TUser.tooltip()">Tinjauan tertunda</p>']
                        }else if (row.authState == 4){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: rgba(60,70,63,0.54)" title="Telah ditolak" onfocus="TUser.tooltip()">Telah ditolak</p>']
                        }
                    }
 
                }
                return btn;
            }
        }
    ];
};
function currentTime(timestamp){
    var time = timestamp + '';
    if(time.length != 13){
        timestamp = timestamp * 1000;
    }
    var date = new Date(timestamp);;
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
 
    var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
    var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
    var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
    var strDate = Y + M + D + h + m + s;
    return strDate
}
/**
 * 检查是否选中
 */
YesDriver.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        YesDriver.seItem = selected[0];
        return true;
    }
};
 
/**
 * 添加司机
 */
YesDriver.add = function(){
    var index = layer.open({
        type: 2,
        title: language==1?'添加':(language==2?'Add':'Tambahkan'),
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tDriver/tDriver_add'
    });
    this.layerIndex = index;
}
YesDriver.withholding = function(){
 
    if (this.check()) {
        var money =  YesDriver.seItem.withholding
        var sTime =  YesDriver.seItem.sTime
        var eTime =  YesDriver.seItem.eTime
        layer.open({
            type: 1
            , title: language == 1 ? '代扣管理' : (language == 2 ? 'Withholding management' : 'Menyingkirkan manajemen')
            , area: ['50%', '50%']
            , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
            , id: 'layerDemo' //防止重复弹出cge
            , content: '<div class="form-horizontal">' +
                '                    <div class="col-sm-11" style="margin-top: 30px">' +
                '                    <div class="col-sm-11">' +
                '                        <div class="form-group">\n' +
                '                            <label class="col-sm-3 control-label">Money:</label>\n' +
                '                            <div class="col-sm-9">\n' +
                '                                          <input class="form-control" id="num" type="number" min="0" value="' + money + '">' +
                '                            </div>\n' +
                '                       </div>' +
                '                        <div class="form-group">\n' +
                '                            <label class="col-sm-3 control-label">Time:</label>\n' +
                '                            <div class="col-sm-9">\n' +
                '                                          <input class="form-control" id="Time"  value="'+currentTime(sTime) +' - '+ currentTime(eTime)+'">' +
                '                            </div>\n' +
                '                       </div>' +
                '                   </div>' +
                '</div>'
 
            , btn: ['Confirm', 'Cancel']
            , btnAlign: 'c' //按钮居中
            , shade: 0.5 //不显示遮罩
            , yes: function () {
                let num = $('#num').val();
                let time = $('#Time').val();
                if (num == '' || time=='') {
                    if (language == 1) {
                        Feng.info("输入框不能为空")
                    } else if (language == 2) {
                        Feng.info("The input field cannot be empty")
                    } else {
                        Feng.info("Catatan eksport informasi pengguna")
                    }
                    return;
 
                } else {
                    var ajax = new $ax(Feng.ctxPath + "/tDriver/withholding", function (data) {
                        if (language == 1) {
                            Feng.success("操作成功!")
                        } else if (language == 2) {
                            Feng.success("Success!")
                        } else {
                            Feng.success("Sukses!")
                        }
                        YesDriver.table.refresh();
                        layer.closeAll();
                    }, function (data) {
                        if (language == 1) {
                            Feng.error("操作失败!")
                        } else if (language == 2) {
                            Feng.error("ERROR!")
                        } else {
                            Feng.error("RALAT!")
                        }
                    });
                    ajax.set("money", num);
                    ajax.set("id", YesDriver.seItem.id);
                    ajax.set("time", time);
                    ajax.start();
                }
 
            },
        });
 
    }
    laydate.render({
        elem: '#Time'
        ,range: true,
        lang:"en",trigger: 'click'
    });
}
 
/**
 * 编辑司机
 */
YesDriver.update = function(){
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'编辑':(language==2?'Edit':'Edit'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tDriver/tDriver_update/' + YesDriver.seItem.id
        });
        this.layerIndex = index;
    }
}
 
/**
 * 跳转至更换车辆页面
 */
YesDriver.changeCar = function(){
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'更换车辆':(language==2?'Replacement of vehicle':'Ganti kendaraan'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tDriver/tDriver_changeCar/' + YesDriver.seItem.id
        });
        this.layerIndex = index;
    }
}
 
/**
 * 冻结司机
 */
YesDriver.freeze = function(){
    if (this.check()) {
        var nickname = YesDriver.seItem.name;
        if (YesDriver.seItem.authState == 3 ){
            if(language==1){
                swal("冻结失败", "【正常】状态下才能执行此操作", "warning");
            }else if(language==2){
                swal("Fail","This operation can only be performed in unfreezing failed [normal] status", "warning");
            }else {
                swal("Gagal", "Operasi ini hanya dapat dilakukan dalam status unfreezing gagal [normal].", "warning");
            }
 
            return;
        }
        var index = layer.open({
            type: 2,
            title: language==1?'冻结司机'+"【"+nickname+"】":(language==2?'Freeze the driver'+"【"+nickname+"】":'membekukan supir'+"【"+nickname+"】"),
            area: ['720px', '450px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tDriver/tDriver_optDriver/' + YesDriver.seItem.id +"/"+2
        });
        this.layerIndex = index;
 
        /*var nickname = YesDriver.seItem.name;
        if (nickname == "" || nickname == null || nickname == undefined){
            nickname = "该司机";
        }else{
            nickname = "【"+nickname+"】";
        }
        if (YesDriver.seItem.authState == 3 ){
            swal("冻结失败", "【正常】状态下才能执行此操作", "warning");
            return;
        }else{
            swal({
                title: "您是否确认冻结"+ nickname + "?",
                text: "请谨慎操作!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "冻结",
                closeOnConfirm: true
            }, function () {
                /!*var ajax = new $ax(Feng.ctxPath + "/tDriver/optDriver", function (data) {
                    swal("冻结成功", "您已经冻结了"+ nickname + "。", "success");
                    YesDriver.table.refresh();
                }, function (data) {
                    swal("冻结失败", data.responseJSON.message+"!", "warning");
                });
                ajax.set("driverId",YesDriver.seItem.id);
                ajax.set("optType",2);
                ajax.start();*!/
            });
        }*/
    }
}
 
/**
 * 解冻司机
 */
YesDriver.thaw = function(){
    if (this.check()) {
        var nickname = YesDriver.seItem.name;
        if (YesDriver.seItem.authState == 2 ){
            if(language==1){
                swal("解冻失败", "【冻结】状态下才能执行此操作", "warning");
            }else if(language==2){
                swal("Fail", "This operation can only be performed in the unfreezing failure [frozen] status.", "warning");
            }else {
                swal("Gagal", "Operasi ini hanya dapat dilakukan dalam status kegagalan [beku] yang tidak bebas.", "warning");
            }
            return;
        }
        var index = layer.open({
            type: 2,
            title: language==1?'解冻司机'+"【"+nickname+"】":(language==2?'Unfreeze the driver'+"【"+nickname+"】":'Lepaskan supir'+"【"+nickname+"】"),
            area: ['720px', '450px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tDriver/tDriver_optDriver/' + YesDriver.seItem.id +"/"+1
        });
        this.layerIndex = index;
        /*var nickname = YesDriver.seItem.name;
        if (nickname == "" || nickname == null || nickname == undefined){
            nickname = "该司机";
        }else{
            nickname = "【"+nickname+"】";
        }
        if (YesDriver.seItem.authState == 2 ){
            swal("解冻失败", "【冻结】状态下才能执行此操作", "warning");
            return;
        }else{
            swal({
                title: "您是否确认解冻"+ nickname + "?",
                text: "请谨慎操作!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "解冻",
                closeOnConfirm: true
            }, function () {
                var ajax = new $ax(Feng.ctxPath + "/tDriver/optDriver", function (data) {
                    swal("解冻成功", "您已经解冻了"+ nickname + "。", "success");
                    YesDriver.table.refresh();
                }, function (data) {
                    swal("解冻失败", data.responseJSON.message+"!", "warning");
                });
                ajax.set("driverId",YesDriver.seItem.id);
                ajax.set("optType",1);
                ajax.start();
            });
        }*/
    }
}
 
/**
 * 删除司机
 */
YesDriver.deleteDriver = function(){
    if (this.check()) {
        var nickname = YesDriver.seItem.name;
        if (nickname == "" || nickname == null || nickname == undefined) {
            if(language==1){
                nickname = "该司机";
            }else if(language==2){
                nickname = "The driver";
            }else {
                nickname = "Pemandu";
            }
        } else {
            nickname = "【" + nickname + "】";
        }
        swal({
            title: language==1?"您是否确认删除" + nickname + "?":(language==2?"Are you sure to delete the" + nickname + "?":"Apakah Anda pasti akan menghapus" + nickname + "?"),
            text: language==1?"请谨慎操作!":(language==2?' Please operate with caution!':'Harap beroperasi dengan hati -hati!'),
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: language==1?"删除":(language==2?'Delete':'Hapus'),
            closeOnConfirm: false
        }, function () {
            var ajax = new $ax(Feng.ctxPath + "/tDriver/delete", function (data) {
                if(language==1){
                    swal("删除成功", "您已经删除了" + nickname + "。", "success");
                }else if(language==2){
                    swal("Success", "You have deleted it" + nickname + "。", "success");
                }else {
                    swal("Success", "Anda telah menghapusnya" + nickname + "。", "success");
                }
                YesDriver.table.refresh();
            }, function (data) {
                if(language==1){
                    swal("删除失败", data.responseJSON.message + "!", "warning");
                }else if(language==2){
                    swal("Failed to delete", data.responseJSON.message + "!", "warning");
                }else {
                    swal("Hapus Gagal", data.responseJSON.message + "!", "warning");
                }
            });
            ajax.set("tDriverId", YesDriver.seItem.id);
            ajax.start();
        });
    }
}
 
YesDriver.training = function(){
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'添加':(language==2?'Add':'Tambahkan'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tDriver/showTraining?id=' + YesDriver.seItem.id
        });
        this.layerIndex = index;
    }
}
 
 
YesDriver.punish = function(){
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'添加':(language==2?'Add':'Tambahkan'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tDriver/showPunish?id=' + YesDriver.seItem.id
        });
        this.layerIndex = index;
    }
}
 
 
/**
 * 查询司机审核列表列表
 */
YesDriver.search = function () {
    var queryData = {};
    queryData['insertTime'] = $("#insertTime").val();
    queryData['companyName'] = $("#companyName").val();
    queryData['phone'] = $("#phone").val();
    queryData['name'] = $("#name").val();
    queryData['addType'] = $("#addType").val();
    queryData['authState'] = $("#authState").val();
    YesDriver.table.refresh({query: queryData});
};
YesDriver.resetSearch = function () {
    $("#insertTime").val("");
    $("#companyName").val("");
    $("#phone").val("");
    $("#name").val("");
    $("#addType").val("");
    $("#authState").val("");
    YesDriver.search();
};
 
$(function () {
    var defaultColunms = YesDriver.initColumn();
    var table = new BSTable(YesDriver.id, "/tDriver/listYesDriver", defaultColunms);
    table.setPaginationType("server");
    YesDriver.table = table.init();
});
 
/**
 * 下载模板
 */
YesDriver.uploadDriverModel = function () {
    window.location.href = Feng.ctxPath + "/tDriver/uploadDriverModel";
}
 
var agreement = function(){
    this.init = function(){
        //模拟上传excel  
        $("#uploadEventBtn").unbind("click").bind("click",function(){
            $("#uploadEventFile").click();
        });
    };
}
/**
 * 导入合同
 */
YesDriver.exportDriver = function () {
    var uploadEventFile = $("#uploadEventFile").val();
    if(uploadEventFile == ''){
         if(language==1){
            Feng.info("请选择Excel,再上传");
        }else if(language==2){
            Feng.info("Please select Excel and upload");
        }else {
            Feng.info("Silakan pilih Excel dan upload");
        }
    }else if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel  
        if(language==1){
            Feng.info("只能上传Excel文件");
        }else if(language==2){
            Feng.info("Only Excel files can be uploaded");
        }else {
            Feng.info("Hanya berkas Excel yang dapat diunggah");
        }
    }else{
        var url = Feng.ctxPath + '/tDriver/exportDriver';
        var file = document.querySelector('input[name=file]').files[0];
        var reader = new FileReader();
        if (file) {
            var formData = new FormData();
            formData.append("myfile", file);
            this.sendAjaxRequest(url, 'POST', formData);
        }
    }
}
YesDriver.sendAjaxRequest = function(url,type,data){
    $.ajax({
        url : url,
        type : type,
        data : data,
        success : function(result) {
            if(result.code==500) {
                Feng.info(result.message);
                $('input[name=file]').val('');
            }else {
                if(language==1){
                    Feng.success("导入成功!");
                }else if(language==2){
                    Feng.success("SUCCESSFUL IMPORT!");
                }else {
                    Feng.success("Import berhasil!");
                }
            }
            YesDriver.table.refresh();
        },
        error : function() {
            if(language==1){
                Feng.error("excel上传失败!");
            }else if(language==2){
                Feng.error("Uploading excel Fails. Procedure!");
            }else {
                Feng.error("Gagal mengunggah excel!");
            }
        },
        cache : false,
        contentType : false,
        processData : false
    });
};
 
var agreement;
$(function(){
    agreement = new agreement();
    agreement.init();
});
 
/**
 * 导出司机操作
 */
YesDriver.outDriver = function () {
    var operation = function() {
        window.location.href = Feng.ctxPath + "/tDriver/outDriver";
    };
    Feng.confirm("是否确认导出司机信息?", operation);
}