avBody = avalon.define("avBody", function (vm) {

     vm.Address = "";//地址
vm.BrandModel = "";//品牌型号
vm.CarProprietor = "";//车辆所有人
vm.CarType = "";//车辆类型
vm.EngineNubmer = "";//发动机号
vm.IdentifyNumber = "";//识别号
vm.InsuranceExpiresTime = "";//保险到期
vm.YearTestExpiresTime = "";//年检到期
vm.PlateNumber = "";//车牌号
vm.GetCarManageInfo = [];
vm.CoachId = "";
vm.ID = "";
vm.CheckCarType = function (value, obj) {
if (value == "C2") {
$("#radC2").attr("style", "background-color:#4caf5e;margin-left:50px;");
$("#radC1").attr("style", "background-color:#888;margin-left:0px;");
} else {
$("#radC1").attr("style", "background-color:#4caf5e;margin-left:0px;");
$("#radC2").attr("style", "background-color:#888;margin-left:50px;");
value = "C1";
}
avBody.CarType = value;
}
vm.LicenseExpriesTime = "";
vm.GetLocalTime = function (nS) {
return new Date(parseInt(nS.replace("/Date(", "").replace(")/", "")));//.toLocaleString().replace(/:\d{1,2}$/, ' ')
};
vm.GetLocalTimeNull = function (nS) {
if (nS != null && nS != "") {
var date = avBody.GetLocalTime(nS); var d = date.getFullYear() + "-" + (date.getMonth() + 1 >= 10 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : "0" + date.getDate());
return d;
} else {
return '';
} };
//加载教练信息
vm.LoadData = function () { $.postToken(appPath + "CostManage/GetCTCarInfo", { CoachId: avBody.QueryString("CoachId") }, function (data) {
if (data.IsSuccess) {
avBody.GetCarManageInfo = data.Data;
//隐藏lodaing
$(".loadinghouse").hide();
//显示列表
$("#div_GetCTCarinfo").show(); } else {
alert("获取车辆失败!!");
}
}); };
vm.GetCTCarInfoByID = function (el) {
avBody.ID = el.ID;
avBody.showcardeatail();
$.postToken(appPath + "CostManage/GetCTCarInfo", {ID:el.ID,CoachId:avBody.QueryString("CoachId")}, function (data) {
if (data.IsSuccess) {
var entity = data.Data[0];
avBody.Address = entity["Address"];//地址
avBody.BrandModel = entity["BrandModel"];//品牌型号
avBody.CarProprietor = entity["CarProprietor"];//车辆所有人
avBody.CarType = entity["CarType"];//车辆类型
avBody.EngineNubmer = entity["EngineNubmer"];//发动机号
avBody.IdentifyNumber = entity["IdentifyNumber"];//识别号
avBody.InsuranceExpiresTime = avBody.GetLocalTimeNull(entity["InsuranceExpiresTime"]);//保险到期
avBody.YearTestExpiresTime = avBody.GetLocalTimeNull(entity["YearTestExpiresTime"]);//年检到期
avBody.LicenseExpriesTime = avBody.GetLocalTimeNull(entity["LicenseExpriesTime"]);//年检到期
$("#txtInsuranceExpiresTime").val(avBody.InsuranceExpiresTime);
$("#txtYearTestExpiresTime").val(avBody.YearTestExpiresTime);
$("#txtLicenseExpriesTime").val(avBody.LicenseExpriesTime);
avBody.PlateNumber = entity["PlateNumber"];//车牌号
// $("#txtInsuranceExpiresTime").val(entity["InsuranceExpiresTime"]);
$("#SelCarType").val(entity["CarType"]);
avBody.CheckCarType(avBody.CarType); } else {
alert("获取车辆失败!!");
}
}); };
vm.SubmitBtn = function (obj) {
if (avBody.ID != "") {
avBody.UptCostManageInfo(avBody.ID,obj);
} else {
avBody.AddCTCarInfo(obj);
}
}; vm.AddCTCarInfo = function (obj) { avBody.InsuranceExpiresTime = $("#txtInsuranceExpiresTime").val();
avBody.YearTestExpiresTime = $("#txtYearTestExpiresTime").val();
avBody.LicenseExpriesTime = $("#txtLicenseExpriesTime").val(); var parm = { Address: avBody.Address,//地址
BrandModel: avBody.BrandModel ,//品牌型号
CarProprietor: avBody.CarProprietor ,//车辆所有人
CarType: avBody.CarType,//车辆类型
EngineNubmer: avBody.EngineNubmer,//发动机号
IdentifyNumber:avBody.IdentifyNumber ,//识别号
InsuranceExpiresTime:avBody.InsuranceExpiresTime,//保险到期
YearTestExpiresTime: avBody.YearTestExpiresTime,//年检到期
PlateNumber: avBody.PlateNumber, //车牌号 ,
CoachId: avBody.QueryString("CoachId"),
LicenseExpriesTime: avBody.LicenseExpriesTime//营运证有效期
};
var thisObj = $(obj);
var oldVal = thisObj.val();
$(obj).attr("disabled", true).val("提交中...");
$.postToken(appPath + "CostManage/AddCTCarInfo", parm, function (data) {
if (data.IsSuccess) {
alert
alert("添加成功!");
avBody.Address = "";//地址
avBody.BrandModel = "";//品牌型号
avBody.CarProprietor = "";//车辆所有人
avBody.CarType = "";//车辆类型
avBody.EngineNubmer = "";//发动机号
avBody.IdentifyNumber = "";//识别号
avBody.InsuranceExpiresTime = "";//保险到期
avBody.YearTestExpiresTime = "";//年检到期
avBody.PlateNumber = "";//车牌号
$("#SelCarType").val("");
avBody.LoadData();
} else { alert("添加失败!" + data.Message);
} thisObj.attr("disabled", false).val(oldVal);
}); }; vm.UptCostManageInfo = function (Id, obj) { avBody.InsuranceExpiresTime = $("#txtInsuranceExpiresTime").val();
avBody.YearTestExpiresTime = $("#txtYearTestExpiresTime").val();
avBody.LicenseExpriesTime=$("#txtLicenseExpriesTime").val(); var parm = {
ID: Id,
Address: avBody.Address,//地址
BrandModel: avBody.BrandModel ,//品牌型号
CarProprietor: avBody.CarProprietor ,//车辆所有人
CarType: avBody.CarType,//车辆类型
EngineNubmer: avBody.EngineNubmer,//发动机号
IdentifyNumber:avBody.IdentifyNumber ,//识别号
InsuranceExpiresTime:avBody.InsuranceExpiresTime,//保险到期
YearTestExpiresTime: avBody.YearTestExpiresTime,//年检到期
PlateNumber: avBody.PlateNumber ,//车牌号 ,
CoachId: avBody.QueryString("CoachId"),
LicenseExpriesTime: avBody.LicenseExpriesTime//营运证有效期
};
var thisObj = $(obj);
var oldVal = thisObj.val();
$(obj).attr("disabled", true).val("提交中...");
$.postToken(appPath + "CostManage/UptCTCarInfo", parm, function (data) {
if (data.IsSuccess) {
alert("修改成功!");
avBody.LoadData(); } else { alert("修改失败!" + data.Message);
} thisObj.attr("disabled", false).val(oldVal);
});
};
vm.DelCTCarInfo = function (Id,obj) { var parm = {
ID: Id,
CoachId: avBody.QueryString("CoachId")
}; if (confirm("确认要删除该车辆吗?")) {
var thisObj = $(obj);
var oldVal = thisObj.val();
$(obj).attr("disabled", true).val("提交中...");
$.postToken(appPath + "CostManage/DelCTCarInfo", parm, function (data) {
if (data.IsSuccess) { avBody.backcar();
} else { alert("删除失败!" + data.Message);
} thisObj.attr("disabled", false).val(oldVal);
});
} else {
return false;
}
};
vm.showcardeatail = function () { if (avBody.ID != null && avBody.ID != "") {
$("#Delbtn").show();
} else {
$("#Delbtn").hide();
}
$(".cardetaile").slideDown();
$(".carcontent").slideUp(); avBody.Address = "";//地址
avBody.BrandModel = "";//品牌型号
avBody.CarProprietor = "";//车辆所有人
avBody.CarType = "";//车辆类型
avBody.EngineNubmer = "";//发动机号
avBody.IdentifyNumber = "";//识别号
avBody.InsuranceExpiresTime = "";//保险到期
avBody.YearTestExpiresTime = "";//年检到期
$("#txtInsuranceExpiresTime").val("");
$("#txtYearTestExpiresTime").val("");
avBody.PlateNumber = "";//车牌号
avBody.CheckCarType("");
};
vm.backcar = function () {
$(".cardetaile").slideUp();
$(".carcontent").slideDown();
$("#SelCarType").val("");//车辆类型
avBody.ID = "";
avBody.Address = "";//地址
avBody.BrandModel = "";//品牌型号
avBody.CarProprietor = "";//车辆所有人
avBody.CarType = "";//车辆类型
avBody.EngineNubmer = "";//发动机号
avBody.IdentifyNumber = "";//识别号
avBody.InsuranceExpiresTime = "";//保险到期
$("#txtInsuranceExpiresTime").val("");
$("#txtYearTestExpiresTime").val("");
avBody.YearTestExpiresTime = "";//年检到期 avBody.PlateNumber = "";//车牌号
avBody.LoadData(); };
//End
vm.QueryString = function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return r[2];
return null;
};
}); $(function () {
//if (avBody.QueryString("CoachId") == "" || avBody.QueryString("CoachId") == null) {
// alert("参数错误!!");
// return false;
//}
avBody.CoachId = avBody.QueryString("CoachId");
avBody.LoadData();
});
04-28 14:19