<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>私塾家</title>
<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
<script th:include="sys/common/metaJS" th:remove="tag"></script> 
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.select_width{
	     width: 220px;
	}
	.date_width{
	     width: 150px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">销售管理</a></li>
		<li><a href="#">销售数据</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/bookList/salsetList.html}" method="post">
	  <input type="hidden" name="type" id="reportType" />
	<ul class="seachform">
			
			<li>
				<label>订单号</label>
				<input type="text" id="orderNo" name="orderNo" th:value="${search.get('orderNo')}" class="scinput date_width " placeholder="订单号">
			</li>
			<li>
				<label>小塾号</label>
				<input type="text" id="seachDerver" name="seachDerver" th:value="${search.get('seachDerver')}" class="scinput date_width " placeholder="小塾号">
			</li>
			<li>
				<label>开始日期</label>
				<input type="text" id="startDate" name="startDate" autocomplete="off" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'startDate\')}'})" th:value="${search.get('startDate') }" class="scinput date_width " placeholder="开始时间">
			</li>
			<li>
				<label>结束时间</label>
				<input type="text" id="endDate" name="endDate" autocomplete="off"  onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" th:value="${search.get('endDate') }" class="scinput date_width " placeholder="开始时间">
			</li>
			<li>
				<label>结算状态</label>
				<select class="scinput select_width" style="width: 146px;" name="order_type" th:switch="${search.get('order_type')}" >
					<option value=""  th:selected="${ search.get('order_type') eq '' }"  >全部</option>
					<option value="已结算" th:selected="${ search.get('order_type') eq '已结算' }"  >已结算</option>
					<option value="未结算" th:selected="${ search.get('order_type') eq '未结算'}" >未结算</option>
				</select>
			</li>
		<li>
			<label>商户</label>
			<select class="scinput select_width" style="width: 146px;" name="unit_name"  >
				<option value=""   >全部</option>
				<option th:each="item:${unitList}"  th:value="${item.posCode}"  th:selected="${ search.get('unit_name') eq item.posCode }"  th:text="${item.unitName}"></option>
			</select>
		</li>

			<li>
				<input type="button" class="scbtn" value="查询" />
				<input type="button" id="button" class="scbtn" value="导出" />
			</li>

		<ul class="toolbar" th:if="${admin == 1}">
			<li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/select.png}" /></span>结算</li>
		</ul>
		
	</ul>
	</form>


	

	<table class="tablelist">
		<thead>
		    <tr>
				<th><input type="checkbox" onchange="selectAll()"></th>
				<th style="width: 50px;">序号</th>
		    	<th>订单号</th>
				<th>商户</th>
				<th>imei</th>
				<th>支付人</th>
				<th>微信昵称</th>
				<th>小孩</th>
				<th>是否结算</th>
				<th>小塾号</th>
				<th>simcard</th>
		    	<th>产品类型</th>
		    	<th>金额</th>
				<th>开始时间</th>
				<th>结束时间</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td><input name="selectlist" type="checkbox" th:data-id="${item.get('id')}" th:if="${item.get('is_close') eq '未结算'}"/></td>
					<td th:text="${itemStat.count}"></td>
					<td th:text="${item.get('order_no')}"></td>

				<td th:text="${item.get('unit_name')}"></td>
				<td th:text="${item.get('imei')}"></td>
				<td th:text="${item.get('pay_user')}"></td>
				<td th:text="${item.get('wx_name')}"></td>
				<td th:text="${item.get('child_name')}"></td>
				<td th:text="${item.get('is_close')}"></td>
				<td th:text="${item.get('derver')}"></td>
				<td th:text="${item.get('simcard')}"></td>

				<td th:text="${item.get('details')}"></td>
				<td th:text="${item.get('price')}"></td>
				<td th:text="${item.get('create_time')}"></td>
				<td th:text="${item.get('end_time')}"></td>
			</tr>
		</tbody>
	</table>
	
	
	



	<!-- 分页 -->
	<div class="pagin">
    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
   	</div>
</div>
</body>
<script type="text/javascript">
$("#button").on('click',function(){
	$("#reportType").val(1);
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/bookList/exportDetail";
	$("#seachform").submit();
	//document.getElementById("seachform").action = "[[${sysUrl}]]/sys/bookList/exportDetail";
	window.setTimeout(function(){
		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/bookList/salsetList.html";
	},3000);
	// document.getElementById("seachform").action = "[[${sysUrl}]]/sys/bookList/salsetList.html";
});

$(function(){
	$('ul.toolbar li.click').click(function () {
		var selectIds=[];
		$('[name=selectlist]:checkbox:checked').each(function() {
			var id = $(this).attr('data-id');
			selectIds.push(id);
		});
		if(selectIds.length>0){
			showIndex(selectIds);
		}
	});
	$('[name=selectlist]:checkbox').change(function () {
		$(this).checked = !$(this).checked;
	});

})
function selectAll() {
	$('[name=selectlist]:checkbox').each(function() {
		this.checked = !this.checked;
	});
}
function showIndex(selectIds){
	var content ="您确定要标记结算吗?";
	parent.layer.confirm(content, {
		icon: 4, btn: ['确定','关闭'] //按钮
	}, function(){
		var url="[[${sysUrl}]]/sys/bookList/orderDetailClose";
		var params ={
			'ids' : selectIds
		};
		$.post(url,params,function(data){
			if(data.meta.success){
				parent.layer.msg("标记结算成功",{icon:1});
				closeWin();
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
				closeWin();
			}
		});
	});
}
function closeWin(){
	location.reload();
}
</script>


</html>