/**
|
* 车辆管理管理初始化
|
*/
|
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] + " ";
|
}
|
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);
|
}
|