Pu Zhibing
7 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
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
/**
 * 车辆管理管理初始化
 */
var TCar = {
    id: "TCarTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
TCar.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.insertTime != '' && row.insertTime != null) {
                    var time = row.insertTime.replace(" ",'<br>');
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.insertTime + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '车辆ID', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '所属<br/>分公司', field: 'companyName', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.companyName != '' && row.companyName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.companyName + '" onfocus="TUser.tooltip()">' + row.companyName + '</p>']
                }else{
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="-" onfocus="TUser.tooltip()">-</p>']
                }
                return btn;
            }
        },
        {title: '所属<br/>加盟商', field: 'franchiseeName', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.franchiseeName != '' && row.franchiseeName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.franchiseeName + '" onfocus="TUser.tooltip()">' + row.franchiseeName + '</p>']
                }else{
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="-" onfocus="TUser.tooltip()">-</p>']
                }
                return btn;
            }
        },
        {title: '车辆<br/>品牌', field: 'brandName', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.brandName != '' && row.brandName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.brandName + '" onfocus="TUser.tooltip()">' + row.brandName + '</p>']
                }else{
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="-" onfocus="TUser.tooltip()">-</p>']
                }
                return btn;
            }
        },
        {title: '车辆<br/>类型', field: 'modelName', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.modelName != '' && row.modelName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.modelName + '" onfocus="TUser.tooltip()">' + row.modelName + '</p>']
                }else{
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="-" onfocus="TUser.tooltip()">-</p>']
                }
                return btn;
            }
        },
        {title: '颜色', field: 'carColor', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.carColor != '' && row.carColor != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.carColor + '" onfocus="TUser.tooltip()">' + row.carColor + '</p>']
                }else{
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="-" onfocus="TUser.tooltip()">-</p>']
                }
                return btn;
            }
        },
        {title: '服务<br/>模式', field: 'serverStr', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.serverStr != '' && row.serverStr != null) {
                    var labelStr = "";
                    var labelStrs = "";
                    var labelArray = row.serverStr.split(",");
                    for(var i=0;i<labelArray.length;i++){
                        labelStr += labelArray[i] +"<br>";
                        labelStrs += labelArray[i] + "&#10;";
                    }
                    labelStr = labelStr.substring(0,labelStr.length-4);
                    labelStrs = labelStrs.substring(0,labelStrs.length-5);
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + labelStrs + '" onfocus="TUser.tooltip()">' + labelStr + '</p>']
                }
                return btn;
            }
        },
        {title: '车牌号', field: 'carLicensePlate', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.carLicensePlate != '' && row.carLicensePlate != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.carLicensePlate + '" onfocus="TUser.tooltip()">' + row.carLicensePlate + '</p>']
                }
                return btn;
            }
        },
        {title: '车辆照片', field: 'peopleAndCarsPhone', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                if (row.peopleAndCarsPhone == null || row.peopleAndCarsPhone == '') {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 50px;height:50px;" src="' + Feng.ctxPath + '/static/img/NoPIC.png" /></a>';
                } else {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 90px;height:50px;" src="' + row.peopleAndCarsPhone + '" /></a>';
                }
            },
            events: 'operateEvents'
        },
        {title: 'roadworthiness sticker', field: 'drivingLicenseNumber', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.drivingLicenseNumber != '' && row.drivingLicenseNumber != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.drivingLicenseNumber + '" onfocus="TUser.tooltip()">' + row.drivingLicenseNumber + '</p>']
                }
                return btn;
            }
        },
        {title: 'roadworthiness sticker照片', field: 'drivingLicensePhoto', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                if (row.drivingLicensePhoto == null || row.drivingLicensePhoto == '') {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 50px;height:50px;" src="' + Feng.ctxPath + '/static/img/NoPIC.png" /></a>';
                } else {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 90px;height:50px;" src="' + row.drivingLicensePhoto + '" /></a>';
                }
            },
            events: 'operateEvents'
        },
        {title: '座位数', field: 'seat', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.seat != '' && row.seat != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.seat + '" onfocus="TUser.tooltip()">' + row.seat + '</p>']
                }
                return btn;
            }
        },
        {title: '关联司机', field: 'driverName', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.driverName != '' && row.driverName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.driverName + '" onfocus="TUser.tooltip()">' + row.driverName + '</p>']
                }
                return btn;
            }
        },
        {title: '年检<br/>到期时间', field: 'annualInspectionTime', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.annualInspectionTime != '' && row.annualInspectionTime != null) {
                    var time = row.annualInspectionTime.substring(0,10);
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + time + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '商业保险<br/>到期时间', field: 'commercialInsuranceTime', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.commercialInsuranceTime != '' && row.commercialInsuranceTime != null) {
                    var time = row.commercialInsuranceTime.substring(0,10);
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + time + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '保险照片', field: 'insurancePhoto', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                if (row.insurancePhoto == null || row.insurancePhoto == '') {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 50px;height:50px;" src="' + Feng.ctxPath + '/static/img/NoPIC.png" /></a>';
                } else {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 90px;height:50px;" src="' + row.insurancePhoto + '" /></a>';
                }
            },
        }
    ];
};
 
/**
 * 检查是否选中
 */
TCar.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TCar.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加车辆管理
 */
TCar.openAddTCar = function () {
    var index = layer.open({
        type: 2,
        title: '添加车辆',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tCar/tCar_add'
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看车辆管理详情
 */
TCar.auth = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '审核车辆',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tCar/tCar_auth/' + TCar.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 删除车辆管理
 */
TCar.delete = function () {
    if (this.check()) {
        var nickname = TCar.seItem.carLicensePlate;
        if (nickname == "" || nickname == null || nickname == undefined){
            nickname = "该车辆";
        }else{
            nickname = "【"+nickname+"】";
        }
        swal({
            title: "您是否确认删除"+ nickname + "?",
            text: "请谨慎操作,删除后数据无法恢复!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "删除",
            closeOnConfirm: true
        }, function () {
            var ajax = new $ax(Feng.ctxPath + "/tCar/delete", function (data) {
                swal("删除成功", "您已经成功删除了"+ nickname + "。", "success");
                TCar.table.refresh();
            }, function (data) {
                swal("删除失败", data.responseJSON.message+"!", "warning");
            });
            ajax.set("tCarId",TCar.seItem.id);
            ajax.start();
        });
    }
};
 
 
TCar.carInsurance = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '车辆保险',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tCar/carInsurance?carId=' + TCar.seItem.id
        });
        this.layerIndex = index;
    }
};
 
 
 
/**
 * 查询车辆管理列表
 */
TCar.search = function () {
    var queryData = {};
    queryData['createTime'] = $("#createTime").val();
    queryData['id'] = $("#id").val();
    queryData['brandName'] = $("#brandName").val();
    queryData['modelName'] = $("#modelName").val();
    queryData['carColor'] = $("#carColor").val();
    queryData['serverStr'] = $("#serverStr").val();
    queryData['carLicensePlate'] = $("#carLicensePlate").val();
    queryData['driverName'] = $("#driverName").val();
    queryData['companyName'] = $("#companyName").val();
    queryData['franchiseeName'] = $("#franchiseeName").val();
    TCar.table.refresh({query: queryData});
};
 
TCar.resetSearch = function () {
    $("#createTime").val("");
    $("#id").val("");
    $("#brandName").val("");
    $("#modelName").val("");
    $("#carColor").val("");
    $("#serverStr").val("");
    $("#carLicensePlate").val("");
    $("#driverName").val("");
    $("#companyName").val("");
    $("#franchiseeName").val("");
    TCar.search();
};
 
$(function () {
    var defaultColunms = TCar.initColumn();
    var table = new BSTable(TCar.id, "/tCar/listAuth", defaultColunms);
    table.setPaginationType("server");
    TCar.table = table.init();
});
 
/**
 * 下载模板
 */
TCar.uploadCarModel = function () {
    window.location.href = Feng.ctxPath + "/tCar/uploadCarModel";
}
 
var agreement = function(){
    this.init = function(){
        //模拟上传excel  
        $("#uploadEventBtn").unbind("click").bind("click",function(){
            $("#uploadEventFile").click();
        });
    };
}
/**
 * 导入合同
 */
TCar.exportCar = function () {
    var uploadEventFile = $("#uploadEventFile").val();
    if(uploadEventFile == ''){
        Feng.info("请选择Excel,再上传");
    }else if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel  
        Feng.info("只能上传Excel文件");
    }else{
        var url = Feng.ctxPath + '/tCar/exportCar';
        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);
        }
    }
}
TCar.sendAjaxRequest = function(url,type,data){
    $.ajax({
        url : url,
        type : type,
        data : data,
        success : function(result) {
            if(result.code==500) {
                Feng.info(result.message);
            }else {
                Feng.success("导入成功!");
            }
            TCar.table.refresh();
        },
        error : function() {
            Feng.error("excel上传失败!");
        },
        cache : false,
        contentType : false,
        processData : false
    });
};
 
var agreement;
$(function(){
    agreement = new agreement();
    agreement.init();
});
 
/**
 * 导出车辆操作
 */
TCar.outCar = function () {
    var operation = function() {
        window.location.href = Feng.ctxPath + "/tCar/outCar";
    };
    Feng.confirm("是否确认导出车辆信息?", operation);
}