<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>
  body{min-width:480px;}
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
</style>
<body>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/sales/getUserListSR.html}" method="post">
	<input type="hidden" id="libId" name="libId" th:value="${search.get('libId')}">
	<input type="hidden" id="orgCode" name="orgCode" th:value="${search.get('orgCode')}">
	<input type="hidden" id="type" name="type" th:value="${search.get('type')}">
	<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>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar">
					<li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/select.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>
		        <th>是否关注</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				    <td><input name="selectlist" type="checkbox" th:data-id="${item.get('id')}" /></td>
				    <td th:text="${itemStat.count}" ></td>
					<td class="getname" th:text="${item.get('wx_name')}"></td>
					<td class="getname" th:text="${item.get('name')}"></td>
					
					<td  class="imgtd">
							<img  th:if="${item.get('photo')}!=null" th:src="${imgUrl}+''+${item.get('photo')}" style="width: 50px;height: 50px;" />
					</td>
					<td class="getname" th:text="${item.get('telephone')}"></td>
					<td class="getname"  th:switch="${item.sex}">
					   <span th:case="1">男</span>
					   <span th:case="2">女</span>
					   <span th:case="*"></span>
					</td>
				<td th:text="${item.get('subscribe')} ? (${item.get('subscribe')} == 1 ? '已关注' :'未关注') :'未关注'" ></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(){
	$('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);
	   	 }else{
	   		closeWin();
	   	 }
		 
	 });
	$('[name=selectlist]:checkbox').change(function () {
		$(this).checked = !$(this).checked;
	 });
	
})
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/lib/addAdmin";
			var id= $("#libId").val();
			var type= $("#type").val();
			 var params ={
			            'id' : id,
			            'type' : type,
			            'ids' : selectIds
			        };
		$.post(url,params,function(data){
			if(data.meta.success){
				parent.layer.msg("添加成功",{icon:1});
				setTimeout(function(){
				   closeWin();
				},1000);
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
				setTimeout(function(){
					   closeWin();
					},1000);
			}
		});
	});
}
function closeWin(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}

</script>
</html>