1 avBody = avalon.define("avBody", function (vm) { 2 3 vm.Address = "";//地址 4 vm.BrandModel = "";//品牌型号 5 vm.CarProprietor = "";//车辆所有人 6 vm.CarType = "";//车辆类型 7 vm.EngineNubmer = "";//发动机号 8 vm.IdentifyNumber = "";//识别号 9 vm.InsuranceExpiresTime = "";//保险到期 10 vm.YearTestExpiresTime = "";//年检到期 11 vm.PlateNumber = "";//车牌号 12 vm.GetCarManageInfo = []; 13 vm.CoachId = ""; 14 vm.ID = ""; 15 vm.CheckCarType = function (value, obj) { 16 if (value == "C2") { 17 $("#radC2").attr("style", "background-color:#4caf5e;margin-left:50px;"); 18 $("#radC1").attr("style", "background-color:#888;margin-left:0px;"); 19 } else { 20 $("#radC1").attr("style", "background-color:#4caf5e;margin-left:0px;"); 21 $("#radC2").attr("style", "background-color:#888;margin-left:50px;"); 22 value = "C1"; 23 } 24 avBody.CarType = value; 25 } 26 vm.LicenseExpriesTime = ""; 27 vm.GetLocalTime = function (nS) { 28 return new Date(parseInt(nS.replace("/Date(", "").replace(")/", "")));//.toLocaleString().replace(/:\d{1,2}$/, ' ') 29 }; 30 vm.GetLocalTimeNull = function (nS) { 31 if (nS != null && nS != "") { 32 var date = avBody.GetLocalTime(nS); 33 34 var d = date.getFullYear() + "-" + (date.getMonth() + 1 >= 10 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : "0" + date.getDate()); 35 return d; 36 } else { 37 return ''; 38 } 39 40 }; 41 //加载教练信息 42 vm.LoadData = function () { 43 44 $.postToken(appPath + "CostManage/GetCTCarInfo", { CoachId: avBody.QueryString("CoachId") }, function (data) { 45 if (data.IsSuccess) { 46 avBody.GetCarManageInfo = data.Data; 47 //隐藏lodaing 48 $(".loadinghouse").hide(); 49 //显示列表 50 $("#div_GetCTCarinfo").show(); 51 52 } else { 53 alert("获取车辆失败!!"); 54 } 55 }); 56 57 58 }; 59 vm.GetCTCarInfoByID = function (el) { 60 avBody.ID = el.ID; 61 avBody.showcardeatail(); 62 $.postToken(appPath + "CostManage/GetCTCarInfo", {ID:el.ID,CoachId:avBody.QueryString("CoachId")}, function (data) { 63 if (data.IsSuccess) { 64 var entity = data.Data[0]; 65 avBody.Address = entity["Address"];//地址 66 avBody.BrandModel = entity["BrandModel"];//品牌型号 67 avBody.CarProprietor = entity["CarProprietor"];//车辆所有人 68 avBody.CarType = entity["CarType"];//车辆类型 69 avBody.EngineNubmer = entity["EngineNubmer"];//发动机号 70 avBody.IdentifyNumber = entity["IdentifyNumber"];//识别号 71 avBody.InsuranceExpiresTime = avBody.GetLocalTimeNull(entity["InsuranceExpiresTime"]);//保险到期 72 avBody.YearTestExpiresTime = avBody.GetLocalTimeNull(entity["YearTestExpiresTime"]);//年检到期 73 avBody.LicenseExpriesTime = avBody.GetLocalTimeNull(entity["LicenseExpriesTime"]);//年检到期 74 $("#txtInsuranceExpiresTime").val(avBody.InsuranceExpiresTime); 75 $("#txtYearTestExpiresTime").val(avBody.YearTestExpiresTime); 76 $("#txtLicenseExpriesTime").val(avBody.LicenseExpriesTime); 77 avBody.PlateNumber = entity["PlateNumber"];//车牌号 78 // $("#txtInsuranceExpiresTime").val(entity["InsuranceExpiresTime"]); 79 $("#SelCarType").val(entity["CarType"]); 80 avBody.CheckCarType(avBody.CarType); 81 82 } else { 83 alert("获取车辆失败!!"); 84 } 85 }); 86 87 88 }; 89 vm.SubmitBtn = function (obj) { 90 if (avBody.ID != "") { 91 avBody.UptCostManageInfo(avBody.ID,obj); 92 } else { 93 avBody.AddCTCarInfo(obj); 94 } 95 }; 96 97 vm.AddCTCarInfo = function (obj) { 98 99 avBody.InsuranceExpiresTime = $("#txtInsuranceExpiresTime").val(); 100 avBody.YearTestExpiresTime = $("#txtYearTestExpiresTime").val(); 101 avBody.LicenseExpriesTime = $("#txtLicenseExpriesTime").val(); 102 103 var parm = { 104 105 Address: avBody.Address,//地址 106 BrandModel: avBody.BrandModel ,//品牌型号 107 CarProprietor: avBody.CarProprietor ,//车辆所有人 108 CarType: avBody.CarType,//车辆类型 109 EngineNubmer: avBody.EngineNubmer,//发动机号 110 IdentifyNumber:avBody.IdentifyNumber ,//识别号 111 InsuranceExpiresTime:avBody.InsuranceExpiresTime,//保险到期 112 YearTestExpiresTime: avBody.YearTestExpiresTime,//年检到期 113 PlateNumber: avBody.PlateNumber, //车牌号 , 114 CoachId: avBody.QueryString("CoachId"), 115 LicenseExpriesTime: avBody.LicenseExpriesTime//营运证有效期 116 }; 117 var thisObj = $(obj); 118 var oldVal = thisObj.val(); 119 $(obj).attr("disabled", true).val("提交中..."); 120 $.postToken(appPath + "CostManage/AddCTCarInfo", parm, function (data) { 121 if (data.IsSuccess) { 122 alert 123 alert("添加成功!"); 124 avBody.Address = "";//地址 125 avBody.BrandModel = "";//品牌型号 126 avBody.CarProprietor = "";//车辆所有人 127 avBody.CarType = "";//车辆类型 128 avBody.EngineNubmer = "";//发动机号 129 avBody.IdentifyNumber = "";//识别号 130 avBody.InsuranceExpiresTime = "";//保险到期 131 avBody.YearTestExpiresTime = "";//年检到期 132 avBody.PlateNumber = "";//车牌号 133 $("#SelCarType").val(""); 134 avBody.LoadData(); 135 } else { 136 137 alert("添加失败!" + data.Message); 138 } 139 140 thisObj.attr("disabled", false).val(oldVal); 141 }); 142 143 144 145 }; 146 147 vm.UptCostManageInfo = function (Id, obj) { 148 149 avBody.InsuranceExpiresTime = $("#txtInsuranceExpiresTime").val(); 150 avBody.YearTestExpiresTime = $("#txtYearTestExpiresTime").val(); 151 avBody.LicenseExpriesTime=$("#txtLicenseExpriesTime").val(); 152 153 var parm = { 154 ID: Id, 155 Address: avBody.Address,//地址 156 BrandModel: avBody.BrandModel ,//品牌型号 157 CarProprietor: avBody.CarProprietor ,//车辆所有人 158 CarType: avBody.CarType,//车辆类型 159 EngineNubmer: avBody.EngineNubmer,//发动机号 160 IdentifyNumber:avBody.IdentifyNumber ,//识别号 161 InsuranceExpiresTime:avBody.InsuranceExpiresTime,//保险到期 162 YearTestExpiresTime: avBody.YearTestExpiresTime,//年检到期 163 PlateNumber: avBody.PlateNumber ,//车牌号 , 164 CoachId: avBody.QueryString("CoachId"), 165 LicenseExpriesTime: avBody.LicenseExpriesTime//营运证有效期 166 }; 167 var thisObj = $(obj); 168 var oldVal = thisObj.val(); 169 $(obj).attr("disabled", true).val("提交中..."); 170 $.postToken(appPath + "CostManage/UptCTCarInfo", parm, function (data) { 171 if (data.IsSuccess) { 172 alert("修改成功!"); 173 avBody.LoadData(); 174 175 } else { 176 177 alert("修改失败!" + data.Message); 178 } 179 180 thisObj.attr("disabled", false).val(oldVal); 181 }); 182 }; 183 vm.DelCTCarInfo = function (Id,obj) { 184 185 var parm = { 186 ID: Id, 187 CoachId: avBody.QueryString("CoachId") 188 }; 189 190 if (confirm("确认要删除该车辆吗?")) { 191 var thisObj = $(obj); 192 var oldVal = thisObj.val(); 193 $(obj).attr("disabled", true).val("提交中..."); 194 $.postToken(appPath + "CostManage/DelCTCarInfo", parm, function (data) { 195 if (data.IsSuccess) { 196 197 avBody.backcar(); 198 } else { 199 200 alert("删除失败!" + data.Message); 201 } 202 203 thisObj.attr("disabled", false).val(oldVal); 204 }); 205 } else { 206 return false; 207 } 208 }; 209 vm.showcardeatail = function () { 210 211 if (avBody.ID != null && avBody.ID != "") { 212 $("#Delbtn").show(); 213 } else { 214 $("#Delbtn").hide(); 215 } 216 $(".cardetaile").slideDown(); 217 $(".carcontent").slideUp(); 218 219 avBody.Address = "";//地址 220 avBody.BrandModel = "";//品牌型号 221 avBody.CarProprietor = "";//车辆所有人 222 avBody.CarType = "";//车辆类型 223 avBody.EngineNubmer = "";//发动机号 224 avBody.IdentifyNumber = "";//识别号 225 avBody.InsuranceExpiresTime = "";//保险到期 226 avBody.YearTestExpiresTime = "";//年检到期 227 $("#txtInsuranceExpiresTime").val(""); 228 $("#txtYearTestExpiresTime").val(""); 229 avBody.PlateNumber = "";//车牌号 230 avBody.CheckCarType(""); 231 }; 232 vm.backcar = function () { 233 $(".cardetaile").slideUp(); 234 $(".carcontent").slideDown(); 235 $("#SelCarType").val("");//车辆类型 236 avBody.ID = ""; 237 avBody.Address = "";//地址 238 avBody.BrandModel = "";//品牌型号 239 avBody.CarProprietor = "";//车辆所有人 240 avBody.CarType = "";//车辆类型 241 avBody.EngineNubmer = "";//发动机号 242 avBody.IdentifyNumber = "";//识别号 243 avBody.InsuranceExpiresTime = "";//保险到期 244 $("#txtInsuranceExpiresTime").val(""); 245 $("#txtYearTestExpiresTime").val(""); 246 avBody.YearTestExpiresTime = "";//年检到期 247 248 avBody.PlateNumber = "";//车牌号 249 avBody.LoadData(); 250 251 }; 252 //End 253 vm.QueryString = function (name) { 254 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); 255 var r = window.location.search.substr(1).match(reg); 256 if (r != null) return r[2]; 257 return null; 258 }; 259 }); 260 261 $(function () { 262 //if (avBody.QueryString("CoachId") == "" || avBody.QueryString("CoachId") == null) { 263 // alert("参数错误!!"); 264 // return false; 265 //} 266 avBody.CoachId = avBody.QueryString("CoachId"); 267 avBody.LoadData(); 268 });
用代码行来衡量开发进度,无异于用重量来衡量制造飞机的进度。