<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>报关单管理列表</title>
   <%--  <link href="<%=basePath %>static/css/login.css" rel="stylesheet">  --%>
   <%--  <link rel="stylesheet" href="<%=basePath %>/static/css/main.css" /> --%>
    
    <script src="<%=request.getContextPath()%>/resource/library/easyui/jquery.min.js"></script>
    <link href="<%=request.getContextPath()%>/resource/library/layui2.4.5/css/layui.css" rel="stylesheet">
    <script src="<%=request.getContextPath()%>/resource/library/layui2.4.5/layui.js"></script>
	<style>
    body{
   /*  margin: 10px; */
  /*   text-align: center; */
	}
  </style>
</head>
<body>
<input type="hidden" name="bookId" value="<%=request.getAttribute("bookId")%>">
<input type="hidden" name="flag" value="">
<input type="hidden" id="startTime" value="">
<input type="hidden" id="endTime" value="">
	<blockquote class="layui-elem-quote"  align="left">报关单查询列表</blockquote>
		<div>
		<div class="layui-inline">
				<label class="layui-form-label"
					style="font-weight: bold; font-size: 15px; width: 80px;">日期段:</label>
				<div class="layui-input-inline">
					<input type="text" autocomplete="off" class="layui-input" id="flightdate" name="flightdate" placeholder=" - "/>
				</div>
			</div>
			
			<div class="layui-inline">
				<div class="layui-inline">
					<label class="layui-form-label"
						style="font-weight: bold; font-size: 15px; width:90px;">进出库类别:</label>
					<div class="layui-input-inline">
						<form class="layui-form">
							 <select name="flag" id="flag">
							 	 <option value="">请选择</option>
						        <option value="0">进库</option>
						        <option value="1">出库</option>
						     </select>
			 			</form>
					</div>
				</div>
			</div>
			<div class="layui-inline">
				 <button class="layui-btn" lay-submit="" id="searchBtn" data-type="getInfo" margin-left15px>     查询</button>
			</div>
		</div>
	    <!-- <button class="layui-btn" lay-submit="" id="searchBtn" data-type="getInfo">查询</button> -->
	  
	</div>
	<hr>
	<blockquote class="layui-elem-quote"  align="left">明细</blockquote>

	<div class="layui-inline" >
		<table class="layui-hide" id="flight" lay-filter="flight" style="width:99%; text-align="center"></table>
	</div>
	             
	 
	<script>
	layui.use('table', function(){
	  var table = layui.table;
	  
	  table.render({
	    elem: '#flight'
	    ,url:'<%=request.getContextPath()%>/rest/manifest/find'
	    ,toolbar: '#toolbar'
	    ,title: '统计查询'
	    ,height: 'full-200'
	    ,cols: [[
			{type: 'checkbox', fixed: 'left'}
	      ,{field:'entryId', align:'center',title:'报关单号', width:200,sort:true}
	      ,{field:'flag', align:'center',title:'进出库标识', width:125}
	      ,{field:'startDate', align:'center',title:'时间', width:200,sort:true}
	      ,{field:'count', align:'center',title:'总报关单数', width:110 ,templet: function(d){
	    	  debugger;
	    	  var text = d.LAY_INDEX;
	    	  if(text==1){
	    		  return d.count
	    	  }else{
	    		  return ' '
	    	  }
			}}
	      
	      /* ,{fixed: 'right', title:'操作',align:'center', toolbar: '#barDemo', width:300} */
	    ]]
	  });
	  
	  $('#searchBtn').on('click',function(){
	      var type = $(this).data('type');
	      active[type] ? active[type].call(this) : '';
	  });
	  // 点击获取数据
	  var  active = {
	      getInfo: function () {
	          var flightdate = $('#flightdate').val();
	          var flag=$('#flag').val();
	          /* if (flightno) { */
	              var index = layer.msg('查询中,请稍候...',{icon: 16,time:false,shade:0});
	              setTimeout(function(){
	                  table.reload('flight', { //表格的id
	                      url:'<%=request.getContextPath()%>/rest/manifest/find',
	                      method:"post",
	                      where: {
	                          'flag':$.trim(flag),
	                          'flightdate':$.trim(flightdate)
	                      }
	                  });
	                  layer.close(index);
	              },800);
	         /*  } else {
	              layer.msg("请输入航班号");
	          } */
	      },
	  };
	  $("#flightno").bind("keyup", function (e) {
	      if (e.keyCode == 13) {
	          var type = "getInfo";
	          active[type] ? active[type].call(this) : '';
	      }
	  });
	});
	</script>
	
	 <script type="text/javascript">
		layui.use(['form', 'laydate'], function(){
			var form = layui.form
			,laydate = layui.laydate;
			
			//日期
			laydate.render({
			elem: '#flightdate'
		    ,range: true
			,done: function(value, date, endDate){
				StartTime = dateToStringForLayui(date);
				$("#startTime").val(StartTime);
				EndTime = dateToStringForLayui(endDate);
				$("#endTime").val(EndTime);
			  }
			});
			form.on('select', function(data){
				  console.log(data.elem); //得到select原始DOM对象
				  console.log(data.value); //得到被选中的值]
				  $("#flag").val(data.value)
				  console.log(data.othis); //得到美化后的DOM对象
				});  
			
		});  

		 function dateToStringForLayui(dateObj) {
				var FullYear = dateObj.year;
				var Month = dateObj.month;
				var Day = dateObj.date;
				/* var Hours = dateObj.hours;
				var Minutes = dateObj.minutes;
				var Seconds = dateObj.seconds; */
			return FullYear+"-"+Month+"-"+Day/* +" "+Hours+":"+Minutes+":"+Seconds */
		 
		}
		 
	</script>
</body>
</html>