/**
|
* 车辆管理管理初始化
|
*/
|
var TCar = {
|
id: "TCarTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
var language =$("#language").val()
|
/**
|
* 初始化表格的列
|
*/
|
TCar.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: language==1?'添加时间':(language==2?'Add Time':'Tambahkan waktu'), field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter:function (data) {
|
return currentTime(data);
|
|
}
|
},
|
{title: language==1?'车辆ID':(language==2?'Vehicle ID':'ID Kendaraan'), field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: language==1?'所属<br/>机构':(language==2?'Affiliated organization':'Organisasi Afiliasi'), 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: language==1?'车辆<br/>品牌':(language==2?'Vehicle brand':'Merek kendaraan'), 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: language==1?'车辆<br/>类型':(language==2?'Vehicle type':'Jenis Kendaraan'), 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: language==1?'颜色':(language==2?'Vehicle color':'Warna kendaraan'), 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: language==1?'服务<br/>模式':(language==2?'Service mode':'Mode Layanan'), field: 'serverStr', visible: true, align: 'center', valign: 'middle',width:'8%',
|
},
|
{title: language==1?'车牌号':(language==2?'License plate number':'Nomor plat nomor'), 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: language==1?'车辆照片':(language==2?'Vehicle photos':'Foto kendaraan'), field: 'carPhoto', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter: function (value, row) {
|
if (row.carPhoto == null || row.carPhoto == '') {
|
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.carPhoto + '" /></a>';
|
}
|
},
|
events: 'operateEvents'
|
},
|
{title: language==1?'行驶证<br/>号码':(language==2?'Driving permit number':'Nomor ijin mengemudi'), 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: language==1?'行驶证<br/>照片':(language==2?'Photo of driving license':'Foto SIM'), 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: language==1?'关联司机':(language==2?'Associated driver':'Driver terkait'), 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: language==1?'年检<br/>到期时间':(language==2?'Annual inspection expiration time':'Waktu Kedaluwarsa Inspeksi Tahunan'), field: 'annualInspectionTime', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter:function (data) {
|
return currentTime1(data);
|
}
|
},
|
{title: language==1?'商业保险<br/>到期时间':(language==2?'Expiration time of commercial insurance':'Waktu kedaluwarsa asuransi komersial'), field: 'commercialInsuranceTime', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter:function (data) {
|
return currentTime1(data);
|
}
|
},
|
{title: language==1?'车辆剩余电量':(language==2?'Residual electric capacity of vehicle':'Kapasitas listrik sisa dari kendaraan'), field: 'commercialInsuranceTime', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter:function (data) {
|
return ""
|
|
}
|
}
|
];
|
};
|
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
|
}
|
|
function currentTime1(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 ;
|
return strDate
|
}
|
/**
|
* 检查是否选中
|
*/
|
TCar.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
if(language==1){
|
Feng.info("请先选中表格中的某一记录!");
|
}else if(language==2){
|
Feng.info("Please select 条记录 in the table first!");
|
}else {
|
Feng.info("Pilih catatan di tabel terlebih dahulu!");
|
}
|
return false;
|
}else{
|
TCar.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加车辆管理
|
*/
|
TCar.openAddTCar = function () {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'添加':(language==2?'Add':'Tambahkan'),
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tCar/tCar_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看车辆管理详情
|
*/
|
TCar.openTCarDetail = 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 + '/tCar/tCar_update/' + TCar.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除车辆管理
|
*/
|
TCar.delete = function () {
|
if (this.check()) {
|
var nickname = TCar.seItem.carLicensePlate;
|
if (nickname == "" || nickname == null || nickname == undefined){
|
if(language==1){
|
nickname = "该车辆";
|
}else if(language==2){
|
nickname = "The vehicle";
|
}else {
|
nickname = "Kendaraan";
|
}
|
|
}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: true
|
}, function () {
|
var ajax = new $ax(Feng.ctxPath + "/tCar/delete", function (data) {
|
if(language==1){
|
swal("删除成功", "您已经成功删除了" + nickname + "。", "success");
|
}else if(language==2){
|
swal("Delete succeeded!", "You have successfully deleted it" + nickname + "。", "success");
|
}else {
|
swal("Hapus berhasil!", "Anda berhasil menghapus" + nickname + "。", "success");
|
}
|
TCar.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("tCarId",TCar.seItem.id);
|
ajax.start();
|
});
|
}
|
};
|
|
|
TCar.carInsurance = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'车辆保险':(language==2?'Vehicle insurance':'Asuransi kendaraan'),
|
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/list", 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 == ''){
|
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 + '/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 {
|
if(language==1){
|
Feng.success("导入成功!");
|
}else if(language==2){
|
Feng.success("SUCCESSFUL IMPORT!");
|
}else {
|
Feng.success("Import berhasil!");
|
}
|
}
|
TCar.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();
|
});
|
|
/**
|
* 导出车辆操作
|
*/
|
TCar.outCar = function () {
|
var operation = function() {
|
window.location.href = Feng.ctxPath + "/tCar/outCar";
|
};
|
if(language==1){
|
Feng.confirm("是否确认导出车辆信息?", operation);
|
}else if(language==2){
|
Feng.confirm("Are you sure to export vehicle information?", operation);
|
}else {
|
Feng.confirm("Apakah Anda pasti akan mengekspor informasi kendaraan?", operation);
|
}
|
}
|