<%@ 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"%>
<link rel="stylesheet" type="text/css" href="${ctx}/css/newCss/dialog.css">
<title>疑案管理</title>
<style>
	.input_txt{
		width: 200px
	}
</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="searchCon left_menu">

			<ul id="accordion" class="accordion">
				<li>
					<div class="link"><i class="fa fa-apply"></i>任务申请<i class="fa fa-chevron-down"></i></div>
					<ul class="submenu">
						<li><a href="${ctx}/sysPersonal/taskApply.do">任务申请</a></li>
						<li><a href="${ctx}/sysPersonal/modelTaskApply.do">专项模型申请</a></li>
					</ul>
				</li>
				<li>
					<div class="link"><i class="fa fa-mark"></i>标注管理<i class="fa fa-chevron-down"></i></div>
					<ul class="submenu">
						<li><a href="${ctx}/sysPersonal/markExport.do">标注管理</a></li>
					</ul>
				</li>
				<li>
					<div class="link"><i class="fa fa-send-view"></i>调查查看情况<i class="fa fa-chevron-down"></i></div>
					<ul class="submenu">
						<li class="on"><a href="${ctx}/outService/canSendM6.do">可发起调查</a></li>
						<li><a href="${ctx}/outService/alreadySendM6.do">已发起调查</a></li>
						<li><a href="${ctx}/outService/succSendM6.do">已完成调查</a></li>
						<li ><a href="${ctx}/outService/backSendM6.do">退回调查</a></li>
					</ul>
				</li>
				<li>
					<div class="link"><i class="fa fa-send-view"></i>风险数据查询<i class="fa fa-chevron-down"></i></div>
					<ul class="submenu">
						<li><a href="${ctx}/sysRisk/RiskQuery.do">风险数据查询</a></li>
					</ul>
				</li>
			</ul>
		</div> -->
		<!--主要内容-->
		<input type="hidden" value="${sendNumber}" name="sendNumber" id="sendNumber">
		<div class="resultCon">
			<!--输入框查询的内容-->	
			<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="name" 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>
							</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="flagValue" maxlength="20" placeholder="请输入系列案"/>
						    <span style="float: right;margin-right:20px;margin-bottom: 10px;">
							    <button class="btn btn-primary" id="searchBtn"><span class="glyphicon glyphicon-search" aria-hidden="ture"></span>查询</button>
							    <button class="btn btn-primary" id="sendM6"><span class="glyphicon glyphicon-send" 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;"><!-- background-color: #f2f6ff; -->
				<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>

	<!--表格模板引擎-->
	<script type="text/html" id="tb_template">
		<thead>
			<tr>
				
				<th>案件号</th>
				<th>标注日期</th>
				<th>系列案</th>
				<th>案件金额</th>
				<th>标注状态</th>
				<th>标注内容</th>			
			</tr>
		</thead>
		<tbody data-type="body">
			<!if(list.length>0) {!>
				<!for(var i=0,len=list.length;i<len;i++){
					var item = list[i],classItem = (i%2!=0)?"odd td_odd":"even";
					var itemArr=item.name;
					var markMess=item.markMess;
				!>
				
				<tr class="gradeA <!=classItem!>" data-rowdata="<!=itemArr!>" data-markmess="<!=markMess!>">
					
					<td title="<!=item.name!>"><input type="checkbox" class="check_box" /><!=item.name!></td>				
					<td title="<!=item.markDate!>"><!=item.markDate!></td>
					<td title="<!=item.seriesCaseName!>"><!=item.seriesCaseName!></td>
					<td title="<!=item.value!>"><!=item.value!></td>
					<td title="<!=item.markStatus!>"><!=item.markStatus!></td>
					<td title="<!=item.markMess!>"><span><!=item.markMess!></span></td>			
				</tr>
			<!}!>
			<!}else{!>
				<tr>
					<td colspan="5"> 暂无数据</td>
				</tr>
			<!}!>
		</tbody>
	</script>

	<script src="${ctx}/js/lib/core.js"></script>
	<script src="${ctx}/component/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script src="${ctx}/js/lib/perfect-scrollbar.jquery.js"></script>
	<script>
		var sysRoleDialog;
		var markMess='',checked_arr=[];
		$(function() {

			//查询
			$("#searchBtn").click(function() {
				search();				
			});
			search();
			
			//点击选择需要发起调查的数据
			/*$("#tbwrap").delegate("tr.gradeA .check_box","click",function(){
				alert("aaaaa");
			});*/

	        //发起
	        $(".reSearch").delegate("#sendM6","click",function() {
				// 3.1 获取主键
				//var caseName = $("#tbwrap .on").data("rowdata");
				
					$(".check_box").each(function(){
					if(this.checked){
						var rowdata=$(this).parent().parent().data("rowdata");
						if(checked_arr.indexOf(rowdata)<0){
							checked_arr.push(rowdata);
							if(markMess==''){
								markMess= $(this).parent().parent().data("markmess");
							}
						}														
					}else{	
						for(var k=0;k<checked_arr.length;k++){
							if(checked_arr[k]==$(this).parent().parent().data("rowdata")){
								checked_arr.splice(k,1);
							}
						}						
					}
					
				});
				var checked_val="";
				var inpNum = $("#sendNumber").val();
				for(var i=0;i<checked_arr.length;i++){
					if(checked_arr.length>inpNum){
						alert("发起案件数量不能大于"+inpNum+"!");
						return false;
					}
					checked_val+=checked_arr[i]+","
				}
				
				if(checked_arr.length==1){
					if(!confirm("个案发起")){
						return;
					}
				}else if(checked_arr.length>1){
					if(!confirm("串案发起")){
						return;
					}
				}else{
					alert("请选择！");
					return;
				}
			
				var s=checked_val.substr(checked_val.length-1,1);
				if(s==","){
					checked_val=checked_val.substring(0,checked_val.length-1);
				}
				var caseName=checked_val+";"+markMess;
				// 3.2 弹窗窗口，显示详细信息
				seajs.use("component/dialog", function(dialog) {
					sysUserDialog = new dialog({
						"width" : 800,
						"height" : 600,
						"contentType" : "iframe",
						"html" : "${ctx}/outService/alertsendM6.do?caseName="+encodeURI(caseName),
						"title" : "编辑详细信息" //标题
					});
				});		
			});
	       /* $("#sendM6").click(function(){
	        	var caseName = $("#tbwrap .on").data("rowdata");
	        	window.location.href="${ctx}/sysPersonal/alreadySendM6.do";
	        });*/
		})

		//函数
		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='name']").val(),//案件号
				flagValue:$("[name='flagValue']").val()
			};

			seajs.use([ "component/table" ], function(uiTable) {
				$.post("${ctx}/outService/showExportInfo.do",paramData,function(data){
					var table = new uiTable({
						 "con": "#tbwrap",//放table的容器,"rowCount":22,"currentPage":1}
						 "data": {
							 "list": data.dataList//渲染需要的数据
						 },
						 "template": "tb_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");
								if(checked_arr.indexOf(rowdata)<0){
									checked_arr.push(rowdata);
									if(markMess==''){
										markMess= $(this).parent().parent().data("markmess");
									}
								}														
							}else{
								for(var k=0;k<checked_arr.length;k++){
									if(checked_arr[k]==$(this).parent().parent().data("rowdata")){
										checked_arr.splice(k,1);
									}
								}	
							}
							
						});
						 var paramData = {
									currentPage:page,
									beginDate:beginDate,
									endDate:endDate,
									markStatus:$("[name='markStatus']").find("option:selected").data("markstatus"),
									name:$("[name='name']").val(),//案件号
									flagValue:$("[name='flagValue']").val()
								};
						 $.post("${ctx}/outService/showExportInfo.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].name)>=0){
						 			$(".check_box").eq(i).prop("checked",true);
						 		}
						 	}
						 });
					 });
				});
			});
		}

		//控制窗口大小
	    $(function () {
			$(".resultCon").perfectScrollbar();
			resize();
            $(window).resize(function(){
				resize();
			});
			
	    });
	    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>
</body>
</html>