<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> 
</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 th:href="@{/sys/wxcard/wxcardList.html}">卡券管理</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/wxcard/wxcardList.html}" method="post">
	<ul class="seachform">
		<li>
		<label>卡券类型</label>
					<select class="scinput select_width" name="type" >
					    <option value=""  th:selected="${ search.get('type') eq '' }"  >全部</option>
						<option value="CASH" th:selected="${ search.get('type') eq 'CASH' }" >现金券</option>
						<option value="MEMBER_CARD" th:selected="${ search.get('type') eq 'MEMBER_CARD' }" >会员卡</option>
					</select>
		</li>
		<li>
		<label>状态</label>
					<select class="scinput select_width" name="auditStat" >
					    <option value=""  th:selected="${ search.get('auditStat') eq '' }"  >全部</option>
						<option value="card_pass_check" th:selected="${ search.get('auditStat') eq 'card_pass_check' }" >审核通过</option>
						<option value="card_not_pass_check" th:selected="${ search.get('auditStat') eq 'card_not_pass_check' }" >审核不通过</option>
					</select>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar"  onclick="libCardAdd();">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增卡券</li>
				</ul>
				<ul class="toolbar"  onclick="pushList();" th:if="${ #httpSession.getAttribute('admin') !=null} ">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>设置测试白名单</li>
				</ul>
		</li>
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
		        <th style="width: 50px;">序号</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:switch="${item.get('card_type')}" >
					    <span th:case="CASH" style="color: red;" >现金券</span>
					    <span th:case="MEMBER_CARD" >会员卡</span>
				   </td>
					<td th:text="${item.get('card_store')}" ></td>
					<td th:text="${item.get('card_id')}"></td>
					<td th:text="${item.get('audit_stat')}"></td>
					<td>
						<a href="javascript:;"  th:onclick="'deleteById(\''+${item.id}+'\',1)'"  class="tablelink" >更新会员卡信息</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 libCardAdd(){
	window.location.href ='[[${sysUrl}]]/sys/wxcard/initAddPage.html';
}
function deleteById(id,stat){
	var desc="确定更新吗？";
	layer.confirm(desc,
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/wxcard/updateCardInfo',
			type: "post",
			data:{
				'cardId': id,
				'stat': stat
			},
			dataType: "json",
			success:function(data){
					
					if(data.meta.success){
						parent.layer.msg("操作成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},1000);
					}else{
						parent.layer.msg(data.meta.message,{icon:11});
					}
			}
		});
	});
}
function pushList(){
	parent.layer.open({
		type: 2,
		title: "设置卡券测试白名单",
		shadeClose: false,
		shade: 0.8,
		scrollbar: true,
		area: ['43%', '60%'],
	    content: '[[${sysUrl}]]/sys/wxcard/cardTest.html'
	});
}
</script>
</html>