vehicleManageInsuranceDetails.js 3.6 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
var enclosureList = new Array();

layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui'], function (exports) {
	winui.renderColor();
	layui.use(['form'], function (form) {
		var index = parent.layer.getFrameIndex(window.name);
	    var $ = layui.$;
	    var insuranceaddtableTemplate = $('#insuranceaddtableTemplate').html();
	    
	    showGrid({
		 	id: "showForm",
doc_wei's avatar
doc_wei 已提交
17
		 	url: flowableBasePath + "insurance006",
doc_wei's avatar
doc_wei 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
		 	params: {rowId:parent.rowId},
		 	pagination: false,
		 	template: getFileContent('tpl/vehicleManageInsurance/vehicleManageInsuranceDetailsTemplate.tpl'),
		 	ajaxSendLoadBefore: function(hdb){
		 	},
		 	ajaxSendAfter:function(json){
		 		var coveragestr = "";
		 		var arr = json.bean.coverageId.split(",");
					for(var i = 0; i < arr.length; i++){
						var str = arr[i].split("-");
						for(var j = 0; j < str.length; j++){
							coveragestr = coveragestr + str[0] + ",";
						}
					}
		 		//险种
		 		showGrid({
		 		 	id: "coverageChoose",
doc_wei's avatar
doc_wei 已提交
35
		 		 	url: flowableBasePath + "coverage006",
doc_wei's avatar
doc_wei 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
		 		 	params: {},
		 		 	pagination: false,
		 		 	template: getFileContent('tpl/template/checkbox-property.tpl'),
		 		 	ajaxSendLoadBefore: function(hdb){
		 		 	},
		 		 	ajaxSendAfter:function(thisjson){
		 		 		if(!isNull(json.bean.coverageId)){
		 		 			var arr = json.bean.coverageId.split(",");
							for(var i = 0; i < arr.length; i++){
								$('input:checkbox[rowId="' + arr[i] + '"]').attr("checked", true);
							}
		 		 		}
		 		 		form.render('checkbox');
		 		 	}
		 		});
		 		//附件回显
			    if(json.bean.enclosureInfo.length != 0 && json.bean.enclosureInfo != ""){
			    	enclosureList = json.bean.enclosureInfo;
			    	var str = "";
	    			$.each([].concat(enclosureList), function(i, item){
	    				str += '<a rowid="' + item.id + '" class="enclosureItem" rowpath="' + item.fileAddress + '" href="javascript:;" style="color:blue;">' + item.name + '</a><br>';
	    			});
	    			$("#enclosureUploadBtn").html(str);
		        }
		        matchingLanguage();
doc_wei's avatar
doc_wei 已提交
61
			    AjaxPostUtil.request({url: flowableBasePath + "coverage006", params:{}, type: 'json', callback: function(thisjson){
doc_wei's avatar
doc_wei 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
		    		if(thisjson.returnCode == 0) {
		    			var row = thisjson.rows;
		    			var coveragearr = coveragestr.split(",");
		 		 		for(var i = 0;i < thisjson.total; i++){
		 		 			var params = {
	 		 	        		id: row[i].id,
	 		 	        		name: row[i].name
	 		 	        	};
		 		 			var f = false;
		 		 			for(var m = 0;m < coveragearr.length; m++){
		 		 				if(row[i].id == coveragearr[m]){
		 		 					f = true;
		 		 				}
		 		 			}
		 		 			if(f){
		 		 				$("#addTable").append(getDataUseHandlebars(insuranceaddtableTemplate, params));
		 		 			}
		 		 			form.render('checkbox');
		 		 		}
	 			 		var arr = json.bean.coverageId.split(",");
	 					for(var i = 0; i < arr.length; i++){
	 						var str = arr[i].split("-");
	 						for(var j = 0; j < str.length; j++){
	 							var fu = $("#addTable").find("span[rowId="+str[0]+"]").parent();
	 		 	            	fu.next().find("span").html(str[1]);//对应的保费
	 		 	            	fu.next().next().find("span").html(str[2]);//对应的保额
	 		 	            	if(str.length > 3){
	 		 	            		fu.next().next().next().find("span").html(str[3]);//对应的备注
	 		 	            	}
	 						}
	 					}
		    		}else {
doc_wei's avatar
doc_wei 已提交
94
		    			winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
95 96 97 98 99 100
		    		}
			     }
		      });
		 	}
		});
	    
doc_wei's avatar
doc_wei 已提交
101
	    $("body").on("click", ".enclosureItem", function() {
doc_wei's avatar
doc_wei 已提交
102 103 104 105
	    	download(fileBasePath + $(this).attr("rowpath"), $(this).html());
	    });
	});
});