 
/*function change(sel){
	if(sel.value=="1"){
		$("#sh1").show();
		$("#sh2").show();
		$("#sh3").html("&nbsp;");
		$("#sh4").html("&nbsp;");
	}
	if(sel.value=="2"){
		$("#sh3").html("赔案号：");
		$("#sh4").html("<input id=\"claimNo\" type='text' class='input i_s_240'/><a href='#' class='icon_add' onclick=\"queryByClaimNo();\"></a>");
		$("#sh1").hide();
		$("#sh2").hide();
	}
}*/
var count = 0;
function queryByClaimNo(){
	count++;
	//$("#cts").html("");
	//$("#cts1").html("");
	var claimNo = $("#claimNoInput").val();

	if (claimNo == "" || claimNo==null) {
		alert("赔案号不能为空!");
		return;
	}
	$.ajax({
		type : "POST",
		url : "/claimserver/batchOperation/queryByClaimNo.do",
		data : {
			"claimNo" : claimNo
		},
		error : function() {
			alert("查询数据失败！");
		},
		success : function(data) {
			if (data==null || data == "") {
				alert("当前赔案号无数据");
			}
			var cls=new Array();
			var flag = false;
			if(count>1){
//				var trs=$("#cts").find("tr");
//				cls=trs[trs.length-1].cells(2).innerHTML;
				cls=document.getElementsByName("claimNo");
			}
			for ( var t = 0; t < cls.length; t++) {
				//alert(cls[t]);alert(cls[t].value);
				if(cls[t].value==claimNo){
					
					alert("当前赔案号数据已在列表中");
					flag=true;
				}
			}
			cls=new Array();
			if(flag==false){
			for ( var i = 0; i < data.length; i++) {
					//$("#cts").html("");claimNo==trs[i].cell[3].value
				$("#cts").append(
						" <tr>"
								+"<td>"+data[i].gathering+"<input type='hidden' name='claimNo' value='"+data[i].claimNo+"'/></td>"
			                    +"<td>"+data[i].hospital+"<input type='hidden' name='parterId' value='"+data[i].parterId+"'/></td>"
                    +"<td>"+data[i].claimNo+"</td>"
                    +"<td>"+data[i].accept+"</td>"
                    +"<td>"+data[i].name+"</td>"
		                    +"<td>"+data[i].bills+"<input type='hidden' name='bills' value='"+data[i].bills+"'/></td>"
		                    +"<td>"+data[i].claims+"<input type='hidden' name='claims' value='"+data[i].claims+"'/></td>"
		                    +"<td><a href='#' class='icon_del' id='del_"+i+"' onclick=\"delData(this);\"></a></td></tr>");
				
				}
				var most=0;
				var most1=0;
//				for( var i = 0; i < data.length; i++){
//					most=most+data[i].bills;
//					most1=most1+data[i].claims;
//					
//				}
//				if(most!=0 || most1!=0){
					$("#cts1").html("");
					$("#cts1").html(
						"<tr><td>累计</td><td></td><td></td><td></td><td></td><td id='most'>"+most+"</td><td id='most1'>"+most1+"</td></tr>"	
					
					);
//				}
					var doc=document.getElementsByName("bills");
					var doc1=document.getElementsByName("claims");
					var bmostsss=new Number(0);
					var bmostsss1=new Number(0);
					for( var i = 0; i < doc.length; i++){
						mostsss=new Number(doc[i].value);
						mostsss1=new Number(doc1[i].value);
						bmostsss=mostsss+bmostsss;
						bmostsss1=mostsss1+bmostsss1;
			}
					$("#most").html("");
					$("#most").html(bmostsss);
					$("#most1").html("");
					$("#most1").html(bmostsss1);
			}


		}

	});
	
	
}
function delData(obj){
	var ok=confirm("是否确定删除？");
	if(ok){
		obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
	}
	var doc=document.getElementsByName("bills");
	var doc1=document.getElementsByName("claims");
	var bmostsss=new Number(0);
	var bmostsss1=new Number(0);
	for( var i = 0; i < doc.length; i++){
		mostsss=new Number(doc[i].value);
		mostsss1=new Number(doc1[i].value);
		bmostsss=mostsss+bmostsss;
		bmostsss1=mostsss1+bmostsss1;
	}
	$("#most").html("");
	$("#most").html(bmostsss);
	$("#most1").html("");
	$("#most1").html(bmostsss1);
}