<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 th:href="@{/sys/usercenter/studentList.html}">学生列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/usercenter/studentList.html}" method="post">
		<ul class="seachform">
			<li>
				<label>名字/家长/学校/年级/小塾设备号：</label>
				<input name="LIKE_value" type="text" class="scinput" th:value="${search.get('LIKE_value')}"/>
			</li>
			<li>
				<label>开始时间</label>
				<input type="text" id="beginDate" autocomplete="off" name="beginDate"  onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" th:value="${search.get('beginDate') }" class="scinput date_width " placeholder="开始时间">
			</li>


			<li>
				<label>结束时间</label>
				<input type="text" id="endDate" autocomplete="off" name="endDate"  onclick="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}'})" th:value="${search.get('endDate') }" class="scinput date_width" placeholder="结束时间">
			</li>
			<li>
				<label>小孩类型：</label>
				<select class="scinput select_width"  name="child_type" th:switch="${search.get('child_type')}" >
					<option value=""  th:selected="${ search.get('child_type') eq '' }"  >全部</option>
					<option value="0" th:selected="${ search.get('child_type') eq '0' }"  >普通用户</option>
					<option value="1" th:selected="${ search.get('child_type') eq '1' }" >内部用户</option>
				</select>
			</li>
			<li>
				<label>&nbsp;</label>
				<input type="button" class="scbtn" value="查询" />
			</li>
		</ul>
	</form>
	<table class="tablelist">
		<thead>
		<tr>
			<th>名字</th>
			<th>vipId</th>
			<th>头像</th>
			<th>二维码</th>
			<th>性别</th>
			<th>电话</th>
			<th>学校</th>
			<th>年级</th>
			<th>家长</th>
			<th>小塾设备号</th>
			<th>小孩类型</th>
			<th>激活时间</th>
			<th th:if="${ #httpSession.getAttribute('admin') !=null   &&  #lists.contains(#httpSession.getAttribute('admin').orgcodeList,'SSJ-SSJ-CW')  }">操作</th>
		</tr>
		</thead>
		<tbody>
		<tr th:each="item:${list}" >
			<td th:text="${item.child_name}" ></td>
			<td th:text="${item.id}" ></td>
			<td  class="imgtd">
				<img th:if="${not #lists.isEmpty(item.img_url)}" th:src="${imgUrl}+''+${item.img_url}" style="width: 50px;height: 50px;" />
			</td>
			<td  class="imgtd">
				<img th:if="${not #lists.isEmpty(item.qrcode_url)}" th:src="${imgUrl}+''+${item.qrcode_url}" style="width: 50px;height: 50px;" />
			</td>
			<td th:switch="${item.sex}">
				<a href="javascript:;" th:case="1">男</a>
				<a href="javascript:;" th:case="2">女</a>
			</td>
			<td th:text="${item.phone}" ></td>
			<td th:text="${item.school}" ></td>
			<td th:text="${item.grade}" ></td>
			<td th:text="${item.parent_name}" ></td>
            <td th:text="${item.derver}" ></td>
			<td th:switch="${item.child_type}">
				<a href="javascript:;" th:case="0">普通用户</a>
				<a href="javascript:;" th:case="1">内部用户</a>
			</td>
			<td style="width: 141px;" th:text="${#calendars.format(item.activate_time,'yyyy-MM-dd HH:mm:ss')}" ></td>
			<td th:if="${ #httpSession.getAttribute('admin') !=null   &&  #lists.contains(#httpSession.getAttribute('admin').orgcodeList,'SSJ-SSJ-CW')  }">
				<a th:href="@{/sys/usercenter/studentDetail.html(id=${item.id})}" class="tablelink" >详情</a>
                <a href="javascript:;" th:onclick="'save(\''+${item.id}+'\')'" class="tablelink">修改</a>
				<a href="javascript:;" th:onclick="'untieDerver(\''+${item.derver}+'\')'" 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 save(id){
        layer.open({
            type: 2,
            title: '编辑孩子',
            closeBtn: 1, //不显示关闭按钮
            shift: 0.8,
            //offset: '100px',
            area: ['50%', '90%'],
            content: '[[${sysUrl}]]/sys/usercenter/studentEdit.html?id='+id
        });
    }

	function untieDerver(derver) {
    	if(isNaN(derver)){
			alert("该小孩已被解绑，无需解绑");
		}else{
			parent.layer.confirm("您确定解绑该小塾?", {
				icon: 4, btn: ['确定', '关闭'] //按钮
			}, function () {
				var url = "[[${sysUrl}]]/sys/usercenter/untieDerver";
				var params = {
					'derver': derver
				};
				$.post(url, params, function (data) {
					if (data.code == '999') {
						parent.layer.msg("解绑成功", {icon: 1});
						closeWin();
					} else {
						parent.layer.msg(data.msg, {icon: 11});
					}
				});
			});
		}
	}

</script>
</html>