<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;
	}
</style>
<body>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/zuoyb/selectZybSRList.html}" method="post">
	<input type="hidden" id="days" name="days" th:value="${search.get('days')}">
	<input type="hidden" id="libId" name="libId" th:value="${search.get('libId')}">
	<input type="hidden" id="courseHour" name="courseHour" th:value="${search.get('courseHour')}">
	<ul class="seachform">
		<li>
			<label>昵称/真实姓名</label>
			<input name="name" type="text" class="scinput" th:value="${search.get('name')} == null  ? '': ${search.get('name')}"/>
		</li>
		<li>
		<label>状态</label>
					<select class="scinput select_width" name="type" >
					    <option value=""  th:selected="${ search.get('type') eq '' }"  >全部</option>
						<option value="1" th:selected="${ search.get('type') eq '1' }" >已选择</option>
						<option value="2" th:selected="${ search.get('type') eq '2' }" >未选择</option>
					</select>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar" id="select">
					<li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/select.png}" /></span>选择</li>
				</ul>
		</li>
		<li>
				<ul class="toolbar" id="delete">
					<li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/t03.png}" /></span>删除</li>
				</ul>
		</li>
		
	</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>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				    <td><input name="selectlist" type="checkbox" th:data-id="${item.get('user_id')}" th:checked="${item.get('xz') eq '1' ? false :true }"  /></td>
				    <td th:text="${itemStat.count}" ></td>
					<td class="getname" th:classappend="${item.get('xz')} ne '1' ? 'stylecss' "   th:text="${item.get('name')}"></td>
					<td class="getname" th:classappend="${item.get('xz')} ne '1' ? 'stylecss' "   th:text="${item.get('wx_name')}"></td>
					<td th:text="${item.get('telephone')}" th:classappend="${item.get('xz')} ne '1' ? 'stylecss' "  ></td>
					<td  th:switch="${item.get('sex')}">
					   <span th:case="1">男</span>
					   <span th:case="2">女</span>
					   <span th:case="*"></span>
					</td>
					<td  class="imgtd">
							<img  th:if="${item.get('photo')}!=null" th:src="${imgUrl}+''+${item.get('photo')}" style="width: 50px;height: 50px;" />
					</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(){
	 
		$('#select 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);
		   	 }else{
		   		closeWin();
		   	 }
			 
		 });
		$('[name=selectlist]:checkbox').change(function () {
			$(this).checked = !$(this).checked;
		 });
		
		$('#delete 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){
				 deleteTeacher(selectIds);
		   	 }else{
		   		closeWin();
		   	 }
			 
		 });
})

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/zuoyb/bachAddSRTeacher";
		var libId= $("#libId").val();
		var days= $("#days").val();
		var courseHour= $("#courseHour").val();
		 var params ={
		            'libId' : libId,
		            'days' : days,
		            'ids' : selectIds,
		            'courseHour' : courseHour
		        };
		$.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 deleteTeacher(selectIds){
	var content ="您确定要删除吗?";
	parent.layer.confirm(content, {
		icon: 4, btn: ['确定','关闭'] //按钮
	}, function(){
		var url="[[${sysUrl}]]/sys/zuoyb/bachDeleteSRTeacher";
		var libId= $("#libId").val();
		var days= $("#days").val();
		var courseHour= $("#courseHour").val();
		 var params ={
		            'libId' : libId,
		            'days' : days,
		            'ids' : selectIds,
		            'courseHour' : courseHour
		        };
		$.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(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}

</script>
</html>