vehicleManageInspectionAdd.js 3.0 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13

// 车辆年检
layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'fileUpload', 'tagEditor', 'laydate'], function (exports) {
	winui.renderColor();
	layui.use(['form'], function (form) {
		var index = parent.layer.getFrameIndex(window.name);
	    var $ = layui.$,
	    	laydate = layui.laydate;
doc_wei's avatar
doc_wei 已提交
14 15

		// 获取当前登录员工信息
W
weizhiqiang 已提交
16
		systemCommonUtil.getSysCurrentLoginUserMation(function (data) {
doc_wei's avatar
doc_wei 已提交
17 18 19 20
			var userName = data.bean.userName;
			$("#inspectionTitle").html("车辆年检登记单-" + userName + "-" + (new Date()).getTime()) + Math.floor(Math.random() * 100);
		});

21
		// 查询所有的车牌号用于下拉选择框
W
weizhiqiang 已提交
22
		adminAssistantUtil.queryAllVehicleList(function (data) {
23 24
			$("#licensePlate").html(getDataUseHandlebars(getFileContent('tpl/template/select-option-must.tpl'), data));
			form.render('select');
doc_wei's avatar
doc_wei 已提交
25
		});
26

doc_wei's avatar
doc_wei 已提交
27
 		// 本次年检时间
W
weizhiqiang 已提交
28
 		laydate.render({elem: '#thisInspectionTime', type: 'date', trigger: 'click'});
doc_wei's avatar
doc_wei 已提交
29 30
 		
 		// 下次年检时间
W
weizhiqiang 已提交
31
 		laydate.render({elem: '#nextInspectionTime', type: 'date', trigger: 'click'});
doc_wei's avatar
doc_wei 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

		skyeyeEnclosure.init('enclosureUpload');
 		matchingLanguage();
 		form.render();
 	    form.on('submit(formAddBean)', function (data) {
 	        if (winui.verifyForm(data.elem)) {
 	        	var params = {
        			inspectionTitle: $("#inspectionTitle").html(),
        			inspectionArea: $("#inspectionArea").val(),
        			contactInformation: $("#contactInformation").val(),
        			inspectionPrice: $("#inspectionPrice").val(),
        			thisInspectionTime: $("#thisInspectionTime").val(),
        			nextInspectionTime: $("#nextInspectionTime").val(),
 	        		roomAddDesc: $("#roomAddDesc").val(),
					vehicleId: $("#licensePlate").val(),
					enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload')
 	        	};
 	        	if(params.contactInformation != ""){
 	        		var mobile = /^0?1[3|4|5|8][0-9]\d{8}$/, phone = /^0[\d]{2,3}-[\d]{7,8}$/;
 	 	        	var flag = mobile.test(params.contactInformation) || phone.test(params.contactInformation);
 	                if(!flag){
doc_wei's avatar
doc_wei 已提交
53
 	                	winui.window.msg('请输入正确的联系电话', {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
54 55 56 57 58 59 60
 	 	        		return false;
 	                }
 	        	}
                if(params.inspectionPrice != ""){
 	        		var str = /^0{1}([.]\d{1,2})?$|^[1-9]\d*([.]{1}[0-9]{1,2})?$/;
 	 	        	var flag = str.test(params.inspectionPrice);
 	                if(!flag){
doc_wei's avatar
doc_wei 已提交
61
 	                	winui.window.msg('年检费用小数点后最多两位!', {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
62 63 64
 	 	        		return false;
 	                }
 	        	}
W
weizhiqiang 已提交
65
 	        	AjaxPostUtil.request({url: flowableBasePath + "inspection002", params: params, type: 'json', callback: function (json) {
66 67
					parent.layer.close(index);
					parent.refreshCode = '0';
doc_wei's avatar
doc_wei 已提交
68 69 70 71 72
	 	   		}});
 	        }
 	        return false;
 	    });

doc_wei's avatar
doc_wei 已提交
73
	    $("body").on("click", "#cancle", function() {
doc_wei's avatar
doc_wei 已提交
74 75 76 77
	    	parent.layer.close(index);
	    });
	});
});