<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: 70px;
	}
	.date_width{
	     width: 100px;
	}
</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/fx/bookList/orderCloseList.html}" method="post">
	<ul class="seachform">
			<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="C006" th:selected="${ search.get('order_type') eq 'C006' }"  >直接零售</option>
						<option value="C004" th:selected="${ search.get('order_type') eq 'C004' }" >辅助零售</option>
					</select>
			</li>
			<li>
				<label>开始时间</label>
				<input type="text" id="beginDate" name="beginDate" autocomplete="off"   onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" th:value="${search.beginDate }" class="scinput date_width " placeholder="开始时间">
			</li>
			
			
			<li>
				<label>结束时间</label>
				<input type="text" id="endDate" name="endDate" autocomplete="off"  onclick="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}'})" th:value="${search.endDate }" class="scinput date_width" placeholder="结束时间">
			</li>
			<li>
			    <label>订单编号</label>
			    <input name="order_no" type="text" class="scinput" th:value="${search.get('order_no')}"/>
		   </li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
			<input type="button" id="button" style="width: 100px;" class="scbtnbution" value="导出明细" />
		</li>
		<ul class="toolbar">
			<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>订单类型</th>
		        <th>订单金额</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') lt '2'}"/></td>
				<td th:text="${itemStat.count}" ></td>
					<td th:text="${item.get('wx_name')}">
					</td>
					<td th:text="${item.get('order_no')}">
					</td>
					<td  th:text="${item.get('price_type')}"></td>
					<td th:text=" ${#strings.contains(item.get('order_money'),'.00')} ?  ${#numbers.formatDecimal(item.get('order_money'),1,0)} :  ${#numbers.formatDecimal(item.get('order_money'),1,2)} " style="color:  red;"></td>
					
					
			        <td  th:text="${#calendars.format(item.get('create_time'),'yyyy-MM-dd HH:mm')}" ></td>
				    <td  th:text="${#calendars.format(item.get('pay_time'),'yyyy-MM-dd HH:mm')}" ></td>
				    <td  th:text="${#calendars.format(item.get('refund_time'),'yyyy-MM-dd HH:mm')}" ></td>
					<td  th:text="${item.get('is_close')}"></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>
<script type="text/javascript">
	$(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;
		});
	}
	$("#button").on('click',function(){
		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/fx/bookList/exportOrder";
		$("#seachform").submit();
		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/fx/bookList/orderCloseList.html";
	});
	function showIndex(selectIds){
		var content ="您确定要添加管理员吗?";
		parent.layer.confirm(content, {
			icon: 4, btn: ['确定','关闭'] //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/fx/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>
</body>
</html>