<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/include/header2.jsp"%>
<title>疑案管理</title>
<style>
	.input_txt{
		width: 200px;
	}
	.modal label {
	    width: 6em;
	}
	#myModal .input_txt{
		width: 180px;
	}
	#myModal input[disabled='disabled']{
		background-color: #ebebe4;
	}
	/*.deliveryBtn{
		background-color: #00b591;
		padding: 5px 15px;
		border-radius: 5px;
		color: #fff;
		margin-right: 7px;
		cursor: pointer;
	}
	.table_list td, .table_list th {
		width: 19%;
	}
	#queryDiv div span select {
		width: 140px;
	}
	#queryDiv .a_btn, #queryDiv .b_btn {
	    height: 28px;
	    margin-right: 10px;
	}
	table#tbwrap tbody tr:hover {
	    background: #1c1b31;
	}
	.table_list td span {
	    white-space: nowrap;
	    width: 200px;
	    display: inline-block;
	    overflow: hidden;
	    text-overflow: ellipsis;
	}
	.on{
		background: #1c1b31;
	}
	.table_list td, .table_list th {
	    padding: 0px 5px;
	}*/
</style>
</head>
<body class="bg1">
	<div class="headCon">
		<jsp:include page="/WEB-INF/jsp/top2.jsp">
		<jsp:param name="index" value="疑案管理" />
		</jsp:include>
	</div>
	<div class="clear"></div>

	<div class="container_fluid">
		<!--左侧菜单-->
		<div class="searchCon left_menu managerLeft">
			<jsp:include page="/include/personalLeft.jsp">
				<jsp:param name="index" value="已完成调查" />
			</jsp:include>
		</div>

		<!--主要内容-->
		<div class="resultCon">
			<input type="hidden" id="CSRFToken" value="${csrfToken }"/>
			<!--输入框查询的内容-->	
			<div class="reSearch">
				<div class="p_bar" style="border-bottom: 1px dashed #afb4bb;">您当前的位置：已完成调查</div>
				<div class="row">
					<div class="col-md-4">
						<div class="search-group">
						    <span class="search_text" style="line-height: 35px;">案件号:</span>
						    <input type="text" class="input_txt" name="caseId" placeholder="请输入案件号"/>
						</div>
						<div class="search-group">
						    <span class="search_text" style="line-height: 35px;">标注状态:</span>
						    <select class="input_txt" name="markStatus">
								<option value="" data-markstatus="">请选择...</option>
								<option value="可疑" data-markstatus="1">可疑</option>
								<option value="欺诈" data-markstatus="2">欺诈</option>
								<option value="正常" data-markstatus="0">正常</option>
							</select>
						</div>
					</div>
					<div class="col-md-8">
						<div class="search-group">
							<span class="search_text" style="line-height: 35px;">时间范围:</span>
						      	<input 
									name="minY" 
									id="minY" 
									class="input_txt"  
									readonly="readonly"
									placeholder="请输入起始日期"
									onfocus="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss',realDateFmt:'yyyy-MM-dd',realTimeFmt:'HH:mm:ss',minDate:'2010-01-01',maxDate:'#F{$dp.$D(\'maxY\')||\'%y-%M-%d\'}'})"/>
							    <b style="font-size:16px">/</b>
							    <input 
									name="maxY" 
									id="maxY" 
									class="input_txt"  
									readonly="readonly" 
									placeholder="请输入结束日期"
									onfocus="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss',realDateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'minY\')||\'2010-01-01\'}',maxDate:'%y-%M-%d'})" />								    
						</div>
						<div class="search-group">
						<!-- 
						    <span class="search_text" style="line-height: 35px;">组号:</span>
							<input type="text" class="input_txt" name="groupNo" maxlength="20" placeholder="请输入组号"/>
						 -->
							<span class="search_text" style="line-height: 35px;">系列案:</span>
							<input type="text" class="input_txt" name="flagValue" maxlength="20" placeholder="请输入系列案"/>

							<span style="float: right;margin-right:20px;margin-bottom: 10px;">
								<button class="btn btn-primary" id="addBtn"><span class="glyphicon glyphicon-export" aria-hidden="ture"></span>标注导出</button>
							    <button class="btn btn-primary" id="searchBtn"><span class="glyphicon glyphicon-search" aria-hidden="ture"></span>查询</button>
							</span>

						</div>
					</div>
				</div>
			</div>	
			<!--表格的内容-->	
			<div class="clear"></div><!-- 清除浮动 -->
			<div class="resultTable" style="width: 99%;padding: 10px;border-radius: 5px;">
				<table id="tbwrap" class="table table-bordered" style="table-layout:fixed;"></table>
				<div class="page eui-pager-custom" id="j_pager"></div>
			</div>
		</div>
	</div>
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header" style="padding:5px 15px;">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel" style="color:#000;">
						风险信息
					</h4>
				</div>
				<div class="modal-body" style="color:#222;">					
					<div style="overflow: hidden;">
						<h4 style="margin-top:0;">案件信息</h4>
						<div style="float:left;width:50%;">
							<p><label>案件号：</label><input class="input_txt" type="text" disabled="disabled"></p>
							<p><label>机构名称：</label><input class="input_txt" type="text" disabled="disabled"></p>
							<p><label>机构号码：</label><input class="input_txt" type="text" disabled="disabled"></p>
						</div>
						<div>
							<p><label>修理厂：</label><input class="input_txt" type="text" disabled="disabled"></p>
							<p><label>车商名称：</label><input class="input_txt" type="text" disabled="disabled"></p>
							<p><label>案件金额：</label><input class="input_txt" type="text" disabled="disabled"></p>
						</div>						
					</div>
					<div style="overflow: hidden;">
						<label style="float:left;">调查报告：</label>
						<textarea class="form-control" disabled="disabled" style="width: 390px; 
						height: 70px;background-color: #ebebe4;"></text area>
					</div>
					<div style="overflow: hidden;">
						<h4 style="margin-top:0;">人员信息</h4>
						<div style="float:left;width:50%;">
							<p><label>姓名：</label><input class="input_txt" type="text" disabled="disabled"></p>
							<p><label>身份证号：</label><input class="input_txt" type="text" disabled="disabled"></p>
						</div>
						<div>
							<p><label>电话：</label><input class="input_txt" type="text" disabled="disabled"></p>
						</div>						
					</div>
					<div style="overflow: hidden;">
						<h4 style="margin-top:0;">车辆信息</h4>
						<div style="float:left;width:50%;">
							<p><label>车牌号：</label><input class="input_txt" type="text" disabled="disabled"></p>
							<p><label>车架号：</label><input class="input_txt" type="text" disabled="disabled"></p>
						</div>
						<div>
							<p>
								<label>案件的定性：</label>
								<select class="input_txt" style="width: 150px;">
		                            <option value="0">黑名单</option>
		                            <option value="1">灰名单</option>
		                        </select>
							</p>
						</div>						
					</div>
					<div style="overflow: hidden;">
						<label style="float:left;">备注：</label>
						<textarea class="form-control" style="width: 390px; 
						height: 70px;"></textarea>
					</div>
										
				</div>	
				<div class="modal-footer">
					<button type="button" class="btn btn-danger" data-dismiss="modal">取消
					</button>
					<button type="button" class="btn btn-primary" data-dismiss="modal" id="riskConfrim">
					确定
					</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
</body>
<!--蒙版的模板引擎,单个入库-->
<script type="text/html" id="modal_template">
	<div style="overflow: hidden;">
		<h4 style="margin-top:0;">案件信息</h4>
		<div style="float:left;width:50%;">
			<p><label>案件号：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.notificationNo!>" value="<!=data.notificationNo!>"></p>
			<p><label>机构名称：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.underWritingBranchName!>" value="<!=data.underWritingBranchName!>"></p>
			<p><label>机构号码：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.underWritingBranchCode!>" value="<!=data.underWritingBranchCode!>"></p>
			<p><label>检出金额：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.involvedAmount!>" value="<!=data.involvedAmount!>"></p>
			<!if(data.exist){!>
				<p><label style="width: 7em;">整案减损金额：</label><input class="input_txt canEdit" style="width: 165px;" disabled="disabled" type="number" title="<!=data.caseInvolvedAmount!>" value="<!=data.caseInvolvedAmount!>"></p>
			<!}else{!>
				<p><label style="width: 7em;">整案减损金额：</label><input class="input_txt canEdit" style="width: 165px;" type="number" title="<!=data.caseInvolvedAmount!>" value="<!=data.caseInvolvedAmount!>"></p>
			<!}!>
		</div>
		<div>
			<p><label>修理厂：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.garage!>" value="<!=data.garage!>"></p>
			<p><label>车商名称：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.supplierName!>" value="<!=data.supplierName!>"></p>
			<p><label>案件金额：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.claimAmount!>" value="<!=data.claimAmount!>"></p>
			<!if(data.flag=="0"){!>
				<p><label>系列案名称：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.flagValue!>" value="<!=data.flagValue!>"></p>
			<!}else if(data.flag=="1"){!>
				<p><label>人员名称：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.flagValue!>" value="<!=data.flagValue!>"></p>
			<!}else{!>

			<!}!>
		</div>						
	</div>
	<div style="overflow: hidden;">
		<label style="float:left;">调查报告：</label>
		<textarea class="form-control" disabled="disabled" style="width: 463px; 
		height: 70px;background-color: #ebebe4;"><!=data.investigationReport!></textarea>
	</div>
	<div style="overflow: hidden;">
		<h4 style="margin-top:0;">人员信息</h4>
		<div style="float:left;width:50%;">
			<p><label>姓名：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.name!>" value="<!=data.name!>"></p>
			<p><label>身份证号：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.certificateNo!>" value="<!=data.certificateNo!>"></p>
		</div>
		<div>
			<p><label>电话：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.phoneNumber!>" value="<!=data.phoneNumber!>"></p>
		</div>						
	</div>
	<div style="overflow: hidden;">
		<h4 style="margin-top:0;">车辆信息</h4>
		<div style="float:left;width:50%;">
			<p><label>车牌号：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.targetCarPlateNo!>" value="<!=data.targetCarPlateNo!>"></p>
			<p><label>车架号：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.targetCarVIN!>" value="<!=data.targetCarVIN!>"></p>
		</div>
		<div>
			<p>
			<label>案件的定性：</label>
			<!if(data.exist){!>
				<input class="input_txt" type="text" disabled="disabled" title="<!=data.caseNature!>" value="<!=data.caseNature!>">
			<!}else{!>
				<select class="input_txt caseNatureCon" style="width: 180px;">
                    <option value="0">黑名单</option>
                    <option value="1">灰名单</option>
                    <option value="2">正常</option>
                </select>
			<!}!>
				
				
			</p>
		</div>						
	</div>
	<div style="overflow: hidden;">
		<label style="float:left;">备注：</label>
		<!if(data.exist){!>
			<input class="input_txt" type="text" disabled="disabled" value="<!=data.remark!>">
		<!}else{!>
			<textarea class="form-control remarkCon" style="width: 463px;height: 70px;"></textarea>
		<!}!>
	</div>
</script>

<!--多个案件入库的模板引擎-->
<script type="text/html" id="modal22_template">
	<div style="overflow: hidden;">
		<div style="overflow: hidden;" class="caseMoney">	
			<div style="float:left;width:50%;">
				<!for(var i=0;i<data.notificationNo.length;i++){!>
					<p style="overflow: hidden;">
						<label style="float:left;">案件号：</label>
						<input class="input_txt" type="text" disabled="disabled" title="<!=data.notificationNo[i]!>" value="<!=data.notificationNo[i]!>">
					</p>
				<!}!>
			</div>
			<div style="float:left;width:50%;">
				<!for(var i=0;i<data.caseInvolvedAmounts.length;i++){
					var item=data.caseInvolvedAmounts[i]==""?"0.00":data.caseInvolvedAmounts[i];!>
					<p><label style="width: 7em;">整案减损金额：</label><input class="input_txt canEdit" style="width: 165px;" type="number" data-caseid="<!=data.notificationNo[i]!>" title="<!=item!>" value="<!=item!>"></p>
				<!}!>
			</div>
		</div>
		<div style="overflow: hidden;">	
			<div style="float:left;width:50%;">
				<p><label>案件的定性：</label>
				<!if(data.exist){!>
					<input class="input_txt" type="text" disabled="disabled" title="<!=data.caseNature!>" value="<!=data.caseNature!>">
				<!}else{!>
					<select class="input_txt caseNatureCon2" style="width: 180px;">
	                    <option value="0">黑名单</option>
	                    <option value="1">灰名单</option>
	                    <option value="2">正常</option>
	                </select>
				<!}!>	
				</p>
			</div>
			<div>
				<!if(data.flag=="0"){!>
					<p><label>系列案名称：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.flagValue!>" value="<!=data.flagValue!>" style="width: 165px;margin-left:1em;"></p>
				<!}else if(data.flag=="1"){!>
					<p><label>人员名称：</label><input class="input_txt" type="text" disabled="disabled" title="<!=data.flagValue!>" value="<!=data.flagValue!>" style="width: 165px;margin-left:1em;"></p>
				<!}else{!>

				<!}!>
			</div>
		</div>
		<p style="overflow: hidden;"><label style="float:left;">备注：</label>
		<!if(data.exist){!>
			<input class="input_txt" type="text" disabled="disabled" value="<!=data.remark!>">
		<!}else{!>
			<textarea class="form-control remarkCon2" style="width: 463px;height: 70px;"></textarea>
		<!}!>
		</p>
	</div>
</script>

<script type="text/html" id="send_template">
	<thead>
		<tr>
			
			<th style="width:17%;">案件号</th>
			<th style="width:16%;">发起日期</th>
			<th style="width:17%;">系列案</th>
			<th style="width:7%;">标注状态</th>
			<th style="width:8%;">案件金额</th>
			<th style="width:10%;">整案减损金额</th>
			<th style="width:18%;">调查报告</th>
			
			<th style="width:7%;">完成入库</th>
		</tr>
	</thead>
	<tbody data-type="body">
		<!if(list.length>0){
			for(var i=0;i<list.length;i++){
				var item = list[i],classItem = (i%2!=0)?"odd td_odd":"even";
				var itemArr=item.notificationNo;
				var itemYes=item.isStorage;
				!>
				<tr class="gradeA <!=classItem!>"  data-rowdata="<!=itemArr!>" data-money="<!=list[i].involvedAmount!>" data-isStorage="<!=itemYes!>">
					
				<!if(item.isStorage=="是"){!>
					<td title="<!=list[i].notificationNo!>">&nbsp&nbsp&nbsp<!=list[i].notificationNo!></td>
				<!}else{!>
					<td title="<!=list[i].notificationNo!>"><input type="checkbox" class="check_box" data-case="<!=itemArr!>" /><!=list[i].notificationNo!></td>
				<!}!>
					<td title="<!=list[i].sendTime!>"><!=list[i].sendTime!></td>
					<td title="<!=list[i].seriesCaseName!>"><span><!=list[i].seriesCaseName!></span></td>
					<td title="<!=list[i].markStatus!>"><!=list[i].markStatus!></td>
					<td title="<!=list[i].value!>"><!=list[i].value!></td>
					<td title="<!=list[i].involvedAmount!>"><!=list[i].involvedAmount!></td>
					<td title="<!=list[i].investigationReport!>"><span><!=list[i].investigationReport!></span></td>
					<td>
						<button class="btn btn-primary saveM6"  data-casename="<!=list[i].notificationNo!>"
							data-value="<!=list[i].value!>" data-involvedamount="<!=list[i].involvedAmount!>" 
							data-investigationreport="<!=list[i].investigationReport!>"
						>
							<!=list[i].isStorage!>
						</button>
						<button class="alertShow" data-toggle="modal" data-target="#myModal" hidden></button>
					</td>
				</tr>
			<!}
		}else{!>
			<tr>
				<td colspan="8"> 暂无数据</td>
			</tr>
		<!}!>
	</tbody>
</script><!--  -->
<script src="${ctx}/js/lib/core.js"></script>
<script src="${ctx}/component/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

<script>
	var checked_arr=[];
	var checkedMoney_arr=[];
	var checked_val="";

	$(function(){
		//导出
		$("#addBtn").click(function(){
			var start = $("#minY").val().toString();
			var end = $("#maxY").val().toString();
			var flagValue=encodeURI($("[name='flagValue']").val());
			var markStatus=$("[name='markStatus']").find("option:selected").data("markstatus");
			<!--$("[name='markStatus']").find("option:selected").val().toString();-->
			var minTime = new Date(Date.parse(start.replace(/-/g,"/")));
			var maxTime = new Date(Date.parse(end.replace(/-/g,"/")));
			if(minTime.getTime()>maxTime.getTime()){
				alert("起始时间不能大于终止时间！");
				return false;
			}
			download(start,end,markStatus,flagValue);
		});
		
		//下载
		function download(start,end,markStatus,flagValue){
			var $form = $("<form style='display:none' target='downloadframe' action='${ctx}/outService/succSendM6Export.do' method='post'>");
			var $start = $("<input name='start' value='"+start+"'>");
			var $end = $("<input name='end' value='"+end+"'>");
			var $markStatus = $("<input name='markStatus' value='"+markStatus+"'>");
			var $flagValue=$("<input name='flagValue' value='"+flagValue+"'>");
			$form.append($start).append($end).append($markStatus).append($flagValue);
			$("body").append($form);
			$form.submit();
			$form.remove();
		}



		//入库操作，点击否
		var riskData=null;
		var no_button=null;
		$("#tbwrap").delegate(".saveM6","click",function(){
			$(".check_box").each(function(){
				if(this.checked){
					var rowdata=$(this).parent().parent().data("rowdata");
					var money=$(this).parent().parent().data("money");//减损金额
					if(checked_arr.indexOf(rowdata)<0){
						checked_arr.push(rowdata);
						checkedMoney_arr.push(money);//减损金额
					}														
				}else{	
					for(var k=0;k<checked_arr.length;k++){
						if(checked_arr[k]==$(this).parent().parent().data("rowdata")){
							checked_arr.splice(k,1);
							checkedMoney_arr.splice(k,1);
						}
					}						
				}
				
			});

			var caseName=$(this).data("casename");
			if(checked_arr.indexOf(caseName)<0&&(checked_arr.length>0)){
				alert("只可点击选择中的数据！");
				return false;
			}
			checked_val=""
			for(var i=0;i<checked_arr.length;i++){
				checked_val+=checked_arr[i]+","
			}
			var s=checked_val.substr(checked_val.length-1,1);
			if(s==","){
				checked_val=checked_val.substring(0,checked_val.length-1);
			}
			var checked_money=checkedMoney_arr.join(",");//减损金额

			var value=$(this).data("value");
			var involvedAmount=$(this).data("involvedamount");
			var investigationReport=$(this).data("investigationreport");
			var n_button=$(this);			
			if(checked_arr.length>1){
				$.ajax({
					type:"POST",
					url:"${ctx}/sysRisk/judgeBatchCases.do",
					data:{notificationNos:checked_val,caseInvolvedAmounts:checked_money},
					success:function(result){
						if(typeof(result)=="string"){
							result=JSON.parse(result);
						}
						if(result.status=="succ"){
							var data={notificationNo:checked_arr,caseInvolvedAmounts:checkedMoney_arr,flag:result.node.flag,flagValue:result.node.flagValue,caseInvolvedAmount:result.amountTotal};
							n_button.parent().find(".alertShow").click();
							var ht = baidu.template("modal22_template",{data:data});
							$(".modal-body").html(ht);
							$(".modal-footer").html('<button type="button" class="btn btn-danger" data-dismiss="modal">取消'
								+'</button><button type="button" class="btn btn-primary" data-dismiss="modal" id="riskConfrim1">确定</button>');
						}else if(result.status=="err"){
							alert(result.mess);
						}else{
							alert("请求失败！");
						}						
					},
					error:function(){
						alert("失败");
					}
				});				
				
			}else{
				$.ajax({
					type:"POST",
					url:"${ctx}/sysRisk/operation.do",
					data:{notificationNo:caseName,claimAmount:value,involvedAmount:involvedAmount,investigationReport:investigationReport},
					success:function(result){
						n_button.parent().find(".alertShow").click();
						if(n_button.html()!="否"){
							$("#riskConfrim").hide();
							$("#riskConfrim1").hide();
						}else{
							$("#riskConfrim").show();
							$("#riskConfrim1").show();
						}
						console.log(result);
						var data=saveM6Data(result);
						var ht = baidu.template("modal_template",{data:data});
						$(".modal-body").html(ht);
						riskData=data;
						no_button=n_button;
					},
					error:function(){
						alertHide();
						alert("失败");
					}
				})
			}			
		})

		//点击确定
		$("#myModal #riskConfrim").click(function(){
			var caseNature=$(".caseNatureCon option:selected").text();
			var remark=$(".remarkCon").val();
			var caseInvolvedAmount=$("#myModal .canEdit").val();
			if(riskData!=null){
				var data= riskData;
				data.caseNature=caseNature;
				data.remark=remark;
				data.caseInvolvedAmount=caseInvolvedAmount;
				data=JSON.stringify(data);
				$.ajax({
					type:"POST",
					url:"${ctx}/sysRisk/saveSysRisk.do",
					data:{data:data},
					success:function(result){
						if(typeof(result)=="string"){
							result=JSON.parse(result);
						}
						if(result.status=="succ"){
							alert(result.mess);
							no_button.html("是");
							no_button.parent().parent().find("input.check_box").remove();
							$("#tbwrap td .saveM6").each(function(){
								for(var k=0;k<checked_arr.length;k++){
									if($(this).data("casename")==checked_arr[k]){
										$(this).text("是");
										$(this).parent().parent().find("input.check_box").remove();
									}
								}

							})
							checked_arr=[];
							checkedMoney_arr=[];//减损金额
							checked_val="";
						}else if(result.status=="err"){
							alert(result.mess);
						}else{
							alert(result.mess);
						}
						search();//相当于刷新
					},
					error:function(){
						alert("失败");
					}
				})
			}
		});
		//选择多时，点击确定
		$("#myModal").delegate(" #riskConfrim1","click",function(){
			if(checked_arr.length>1){
				if(!confirm(checked_val+"批量入库")){
					return;
				}
			}
			var caseAndMoney=[];
			$("#myModal .canEdit").each(function(){
				var caseId=$(this).data("caseid");
				var money=$(this).val();
				caseAndMoney.push(caseId+"="+money);
			});
			var checkedCon=caseAndMoney.join(",");
			var caseNature=$(".caseNatureCon2 option:selected").text();
			var remark=$(".remarkCon2").val();
			$.ajax({
				type:"POST",
				url:"${ctx}/sysRisk/saveSysRisks.do",
				data:{remark:remark,caseNature:caseNature,notificationNos:checkedCon},
				success:function(result){
					if(typeof(result)=="string"){
						var result=JSON.parse(result); //字符串转json
					}	
					if(result.status=="succ"){
						alert(result.mess);
						$("#tbwrap td .saveM6").each(function(){
							for(var k=0;k<checked_arr.length;k++){
								if($(this).data("casename")==checked_arr[k]){
									$(this).text("是");
									$(this).parent().parent().find("input.check_box").remove();
								}
							}

						})
						checked_arr=[];
						checkedMoney_arr=[];//减损金额
						checked_val="";
					}else if(result.status=="err"){
						alert(result.mess);
					}else{
						alert(result.mess);
					}
					search();//相当于刷新
				},
				error:function(){
					alert("失败");
				}
			})
		});

		//弹出框数据重组
		function saveM6Data(data){
			var json={
				"notificationDate":"",
				"weaverId":data.sysRisk.weaverId,
				"notificationNo":data.sysRisk.notificationNo,
				"markTime":data.markTime,
				"inRiskTime":"",   //入库时间
				"claimAmount":"0.00",  //标注金额
				"involvedAmount":data.sysRisk.involvedAmount, //检出金额
				"caseNature":"",  //案件定性				
				"underWritingBranchName":"",   //机构名称
				"underWritingBranchCode":"",  //机构号码
				"garage":"", //修理厂名称
				"supplierName":"",  //车商名称
				"investigationReport":data.sysRisk.investigationReport,   //调查报告
				"name":"",  //姓名
				"certificateNo":"", //证件号码
				"certificateType":"身份证",  //证件类型
				"phoneNumber":"",   //电话
				"targetCarPlateNo":"",  //车牌号码
				"targetCarVIN":"", //车架号码
				"remark":"",  //备注
				"exist":data.sysRisk.exist,
				"flag":data.sysRisk.flag, //0或1，0是机构或1是人员
				"flagValue":data.sysRisk.flagValue,  //名称
				"caseInvolvedAmount":data.sysRisk.caseInvolvedAmount  //整案减损金额
			};
			if(data.sysRisk.exist){
				json=data.sysRisk;
			}else{
				for(var i=0;i<data.graphResult.nodes.length;i++){
					var item=data.graphResult.nodes[i];
					if(item.type=="C"){
						for(var k=0;k<item.attrs.length;k++){
							switch(item.attrs[k].name){
								case "daja#CASE_UNDERWIRTING_BRANCH_CODE":json.underWritingBranchCode=item.attrs[k].value;break;
								case "daja#CASE_UNDERWIRTING_BRANCH_NAME":json.underWritingBranchName=item.attrs[k].value;break;
								case "daja#CASE_TARGET_CAR_VIN":json.targetCarVIN=item.attrs[k].value;break;
								case "daja#CASE_TARGET_CAR_PLATENO":json.targetCarPlateNo=item.attrs[k].value;break;
								case "daja#CASE_ACCIDENTDRIVER_NAME":json.name=item.attrs[k].value;break;
								case "daja#CASE_ACCIDENTDRIVER_TEL":json.phoneNumber=item.attrs[k].value;break;
								case "daja#CASE_NOTIFICATIONDATE":json.notificationDate=item.attrs[k].value;break;
								case "daja#CASE_CLAIMAMOUNT":json.claimAmount=item.attrs[k].value;break;
							}
						}
					}else if(item.type=="P"){
						for(var k=0;k<item.attrs.length;k++){
							switch(item.attrs[k].name){
								case "daja#Person_CERTIFICATENO":json.certificateNo=item.attrs[k].value;break;
							}
						}
					}else if(item.type=="S"){
						for(var k=0;k<item.attrs.length;k++){
							switch(item.attrs[k].name){
								case "daja#SettlementAccount_CERTIFICATETYPE":json.certificateType=item.attrs[k].value;break;
							}
						}
					}
				}
			}
			return json;
		}

		// 查询
		$("#searchBtn").click(function() {
			search();
		});
		search();

	});

	function search() {
		//查询时，时间判断
		var beginDate = $("#minY").val().toString();
		var endDate = $("#maxY").val().toString();
		var minTime = new Date(Date.parse(beginDate.replace(/-/g,"/")));
		var maxTime = new Date(Date.parse(endDate.replace(/-/g,"/")));
		if(minTime.getTime()>maxTime.getTime()){
			alert("起始时间不能大于终止时间！");
			return false;
		}
		// 这里放包含查询条件的DIV
		var paramData = {
			page:1,
			beginDate:beginDate,
			endDate:endDate,
			markStatus:$("[name='markStatus']").find("option:selected").data("markstatus"),
			name:$("[name='caseId']").val(),
			flagValue:$("[name='flagValue']").val()
		};

		seajs.use([ "component/table" ], function(uiTable) {
			$.post("${ctx}/outService/getResearchList.do",paramData,function(data){
				var table = new uiTable({
					 "con": "#tbwrap",//放table的容器
					 "data": {
						 "list": data.dataList//渲染需要的数据
					 },
					 "template": "send_template",//渲染的模板
					 "pager": {//翻页
						 "con": "#j_pager",//翻页容器
						 "data": {
							 "currentPage": data.currentPage,//当前页
							 "pageCount": data.totalPage,
							 "rowCount": data.total
						 },
						 //翻页样式
						 template: '<ul class="pagination" style="margin: 0;"><li><a title="首页" class="page_first" data-role="first" href="#">首页</a></li><li><a title="上一页" class="page_prev" href="#" data-role="prev">上一页</a></li><li class="pageNum" data-value="pageNum"><a></a></li><li><a title="下一页" class="page_next" href="#" data-role="next">下一页</a></li><li><a title="尾页" class="page_last" href="#" data-role="last">尾页</a></li></ul><div class="pageGo">共<span data-role="rowCount"></span>条 跳转到 <input  type="text" data-target="input" class="input_txt" style="width:80px;"/><a href="#" data-role="go" class="go">GO</a></div>'
					 }
				 });
				 table.getPager().bind("changePage", function (event, page, hander) {//点击翻页时
				 	//获取当前页选择数据
						$(".check_box").each(function(){
							if(this.checked){
								var rowdata=$(this).parent().parent().data("rowdata");
								var money=$(this).parent().parent().data("money");
								if(checked_arr.indexOf(rowdata)<0){
									checked_arr.push(rowdata);
									checkedMoney_arr.push(money);//减损金额
								}														
							}else{
								for(var k=0;k<checked_arr.length;k++){
									if(checked_arr[k]==$(this).parent().parent().data("rowdata")){
										checked_arr.splice(k,1);
										checkedMoney_arr.splice(k,1);//减损金额
									}
								}	
							}
							
						});

					 var paramData = {
						currentPage:page,
						beginDate:beginDate,
						endDate:endDate,
						markStatus:$("[name='markStatus']").find("option:selected").data("markstatus"),
						name:$("[name='caseId']").val(),
						flagValue:$("[name='flagValue']").val()
					};
					 $.post("${ctx}/outService/getResearchList.do",paramData,function(change){
						 table.render({//重新渲染
								list: change.dataList//传入新的渲染数据
							});
							hander({
								"currentPage": change.currentPage,
								"pageCount": change.totalPage,
								"rowCount": change.total
							});
						//判断该页是否有选择
						 	for(var i=0;i<change.dataList.length;i++){
						 		if(checked_arr.indexOf(change.dataList[i].notificationNo)>=0){
						 			$(".check_box").each(function(k){
						 				if($(this).data("case")==change.dataList[i].notificationNo){
						 					$(".check_box").eq(k).prop("checked",true);
						 				}
						 			})
						 			
						 		}
						 	}
					 });
				 });
			});
		});
	}
</script>
<script src="${ctx}/js/lib/perfect-scrollbar.jquery.js"></script>
<script>
    $(function () {
		$(".resultCon").perfectScrollbar();
		resize();
        $(window).resize(function(){
			resize();
		});
        //数字时控制输入
		$("body").delegate("input[type='number']","keydown",function(){	
			var k=event.keyCode;
			if((k<=57&&k>=48)||(k<=105&&k>=96)||(k==8)||(k==190)||(k==110)){
				return true;
			}else{
				return false;
			}
		});
    });
    function resize(){
		//获取窗口高度
		var windowheight=$(window).height();
		var leftList = windowheight-40;
		$(".searchCon").css({"height":leftList+"px"});
		$(".resultCon").css({"height":leftList-12+"px"});
		//$(".tableMain").css({"height":windowheight-40-42-131+"px"});
		//$(".table_list").css({"height":windowheight-40-42-100-85+"px"});
		$(".resultCon").perfectScrollbar("update");
	}
</script>
</html>