<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>
		<li><a href="#">SN码管理</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/card/snCodeList/{id}.html(id=${id})}" method="post">
	<ul class="seachform">
		<li>
			<label>奖品名称</label>
			<input name="award_type" type="text" class="scinput" th:value="${search.get('award_type')} == null  ? '': ${search.get('award_type')}"/>
		</li>
		 <li>
				<label>中奖状态</label>
					<select class="scinput select_width"  name="award_status" th:switch="${search.get('award_status')}" >
						<option value=""  th:selected="${ search.get('award_status') eq '' }"   >全部</option>
						<option value="0" th:selected="${ search.get('award_status') eq '0' }"  >未抽中</option>
						<option value="1" th:selected="${ search.get('award_status') eq '1' }"  >被抽中</option>
						<option value="2" th:selected="${ search.get('award_status') eq '2' }"  >已领奖</option>
						<option value="3" th:selected="${ search.get('award_status') eq '3' }"  >已兑奖</option>
					</select>
		</li>
		<li>
			<label>中奖人</label>
			<input name="wx_name" type="text" class="scinput" th:value="${search.get('wx_name')} == null  ? '': ${search.get('wx_name')}"/>
		</li>
	
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar">
					<a th:href="@{/sys/card/cardlist.html}"><li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/goto.png}" /></span>返回</li></a>
				</ul>
		</li>
		<li>
			<input type="button" id="zbbutton" style="width: 120px;" class="scbtnbution" value="导出奖品记录" />
		</li>
		
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
		        <th style="width: 50px;">序号</th>
		        <th>奖品名称</th>
		        <th>兑奖SN码</th>
		        <th>奖品状态</th>
		        <th>中奖者手机号</th>
		        <th>中奖人</th>
		        <th>中奖时间</th>
		        <th>领奖时间</th>
		        <th>操作</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${itemStat.count}" ></td>
					<td th:text="${item.get('award_type')}" ></td>
					<td th:text="${item.get('sn_code')}" ></td>
					<td th:switch="${item.get('award_status')}" >
					    <span th:case="1" >被抽中</span>
					    <span th:case="2" >已领奖</span>
					    <span th:case="3" >已兑奖</span>
					    <span th:case="*" >未抽中</span>
					</td>
					<td th:text="${item.get('award_tel')}" ></td>
					<td th:text="${item.get('wx_name')}" ></td>
					<td th:text="${#calendars.format(item.get('award_time'),'yyyy-MM-dd HH:mm:ss')}"></td>
				   <td th:text="${#calendars.format(item.get('use_time'),'yyyy-MM-dd HH:mm:ss')}"></td>
				   <td  >
					  <a href="javascript:;" class="tablelink"  th:if="${item.get('award_status')==1}"   th:onclick="'duijiang(\''+${item.id}+'\');'"   >用户兑奖</a>
				  </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">

function duijiang (id){
	parent.layer.confirm("您确定给该用户兑奖吗？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/card/duijiang',
			type: "post",
			data : {
				'id' : id
			},
			dataType: "json",
			success:function(data){
					if(data.meta.success){
						parent.layer.msg("兑奖成功!",{icon:1});
						location.reload();
					}else{
						parent.layer.msg(data.meta.message,{icon:11});
					}
			}
		});
	});
}

$("#zbbutton").on('click',function(){
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/card/exportZhongJiang/[[${id}]]";
	$("#seachform").submit();
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/card/snCodeList/[[${id}]].html";
});

</script>
</html>