<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: 100px;
	}
	.date_width{
	     width: 100px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">图书馆管理</a></li>
		<li><a th:href="@{/sys/sales/libVipServiceList.html}">会员服务管理</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/sales/libVipServiceList.html}" method="post">
	<ul class="seachform">
		<li>
			<label>孩子姓名</label>
			<input name="child_name" type="text" class="scinput" th:value="${search.get('child_name')} == null  ? '': ${search.get('child_name')}"/>
		</li><li>
			<label>会员卡编号</label>
			<input name="flow_id" type="text" class="scinput" th:value="${search.get('flow_id')} == null  ? '': ${search.get('flow_id')}"/>
		</li>
		<li th:if="${#lists.size(libList) gt 1 }">
				<label>图书馆</label>
					<select class="scinput select_width"  name="libId"   style="width: 220px;" >
						<option value=""   >全部</option>
						<option th:each="item:${libList}"  th:value="${item.id}"  th:selected="${ search.get('libId') eq item.id }"  th:text="${item.leagueName}"></option>
					</select>
		</li>
		<li>
		<label>会员类型</label>
					<select class="scinput select_width" name="level" >
					    <option value=""  th:selected="${ search.get('level') eq '' }"  >全部</option>
						<option value="1" th:selected="${ search.get('level') eq '1' }" >会员卡</option>
						<option value="5" th:selected="${ search.get('level') eq '5' }" >尊享卡</option>
						<option value="4" th:selected="${ search.get('level') eq '4' }" >联名卡</option>
					</select>
		</li>
		<li>
		<label>购卡服务</label>
					<select class="scinput select_width" name="type"   >
					    <option value=""  th:selected="${ search.get('type') eq '' }"  >全部</option>
						<option th:value="${sort.code}" th:each="sort:${cardType}" th:selected="${ search.get('type') eq sort.code }" >[[${sort.name}]]</option>
					</select>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
		        <th style="width: 40px;">序号</th>
		        <th>图书馆</th>
		        <th>购卡服务</th>
		        <th>家长姓名</th>
		        <th>孩子姓名</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 th:text="${itemStat.count}" ></td>
					<td th:title="${item.get('league_name')}" th:text="${item.get('league_name')} ? (${#strings.length(item.get('league_name'))} &gt; 10 ? ${#strings.substring(item.get('league_name'),3,10)} :${item.get('league_name')} ) :'' ">
					</td>
					<td>
				       <span th:remove="tag" th:each="sort:${species}" th:if="${sort.code eq item.get('species')}" th:text="${sort.name}"></span>
				       <span th:remove="tag"  th:each="sort:${cardType}" th:if="${sort.code eq item.get('type')}"  
				       th:styleappend="${item.get('order_details_id') eq 'tiyanjuan'} ? 'color: red;'  " 
				       th:utext="${item.get('order_details_id') eq 'tiyanjuan'} ? (${sort.name}+'（体验券）')  : (${sort.name})"></span>
				    </td>
					<td th:text="${item.get('parent_name')}" ></td>
					<td th:text="${item.get('child_name')}" ></td>
					<td th:text="${item.get('phone')}" ></td>
					<td th:switch="${item.get('level')}" >
					    <span th:case="1" >会员卡</span>
					    <span th:case="5" style="color: red;">尊享卡</span>
					    <span th:case="4">联名卡</span>
				   </td>
				   <td th:switch="${item.get('stat')}" >
				                          
					    <span th:case="1" th:onclick="'showIndex(\''+${item.get('id')}+'\',2);'"  title="点击设置失效">有效</span>
					    <span th:case="2" th:onclick="'showIndex(\''+${item.get('id')}+'\',1);'" style="color: red;" title="点击设置有效">无效</span>
				   </td>
				   <td th:text="${item.get('flow_id')}" ></td>
					<td th:text="${#calendars.format(item.get('start_time'),'yyyy-MM-dd HH:mm')}" ></td>
					<td th:text="${#calendars.format(item.get('end_time'),'yyyy-MM-dd HH:mm')}" ></td>
					<td  class="imgtd">
							<img  th:if="${item.get('qrcode_url')}!=null" th:src="${imgUrl}+''+${item.get('qrcode_url')}" style="width: 50px;height: 50px;" />
					</td>
				   <td>
				     <a th:href="@{/sys/sales/libVipServiceUpdate.html(id=${item.get('id')})}" 
				      class="tablelink" th:if="${item.get('species') ne 'S003' and item.get('species') ne 'S999'  }">修改会员服务</a>
				     <a th:href="@{/sys/lib/libVipUpdate.html(id=${item.get('vip_id')},isType=2)}" 
				       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>
 <script type="text/javascript">
 function showIndex(id,  isShow){
		var content;
			if(isShow == 2){
				content = "您确定要失效该会员服务吗？"
			}else {
				content = "您确定要生效该会员服务吗？"
			}
		
		parent.layer.confirm(content, {
			icon: 4, btn: ['确定','关闭'] //按钮
		}, function(){
			$.ajax({
				url: '[[${sysUrl}]]/sys/sales/showIndex',
				type : "post",
				data : {
					'id' : id,
					'stat' : isShow
				},
				dataType : "json",
				success : function(data) {
					
					if(data.meta.success){
						parent.layer.alert('操作成功',{icon: 1});
						location.reload();
					}else{
						parent.layer.alert(data.msg,{icon: 9})
					}
					
				}
			});
		});
	}
</script> 
</html>