<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: 220px;
	}
	.date_width{
	     width: 150px;
	}
   .select1{
  		    width:100%;
	    height: 32px;
	    line-height: 32px;
	    border-top: solid 1px #a7b5bc;
	    border-left: solid 1px #a7b5bc;
	    border-right: solid 1px #ced9df;
	    border-bottom: solid 1px #ced9df;
	    opacity:1;
        margin-bottom: 10px;
   	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a th:href="@{/sys/imlibuser/school/list}">导入老师/学生</a></li>
		<li><a href="#">学生列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="${sysUrl+'/sys/imlibuser/student/list/'+tbLibJoin.id}" method="post">
	  <input type="hidden" name="reportType" id="reportType" />
		<ul class="seachform">
			<li>
			  <input style="width: 250px;" name="name" placeholder="输入学生名称" type="text" class="scinput" th:value="${search.get('name')}"/>
		    </li>
		    <li>
			  <input type="button" class="scbtn" value="查询" />
		    </li>
		    <li style="line-height: 35px;">
		    	<span style="font-size: 15px;color: red" th:text="${tbLibJoin.leagueName} "></span> 
		    </li>
		      <li style="line-height: 35px;">
		    	<a th:href="${sysUrl+'/sys/imlibuser/school/list'}">返回上一级</a> 
		    </li>
		    
		</ul>
	</form>
	
	<ul class="seachform">
<!-- 	    <li> -->
<!-- 		  <input type="button" onclick="javascript:studentAdd();" style="width: 100px;height: 30px"  class="scbtn" value="+ 添加学生" /> -->
<!-- 	    </li> -->
	    
	      <li>
		  	<input type="button" id="exbutton" style="width: 100px;height: 30px;background: #ccc no-repeat center;"  class="scbtn" value="导出学生" />
	     </li>
	    
	     <li>
<!-- 		  <input type="button" onclick="javascript:studentServiceEdit();" style="width: 100px;height: 30px;background: red"  class="scbtn" value="E 批量设置" /> -->
	    </li>
	</ul>


	<table class="tablelist">
		<thead>
		    <tr>
		    	<th style="width: 5%">学生姓名</th>
		    	<th style="width: 5%">学校</th>
		    	<th style="width: 5%">年级</th>
		    	<th style="width: 5%">家长姓名</th>
		    	<th style="width: 5%">家长角色</th>
		    	<th style="width: 5%">家长电话</th>
		    	<th style="width: 5%">小塾号</th>
<!-- 		    	<th style="width: 6%">(现)服务开始时间</th> -->
<!-- 		    	<th style="width: 6%">(现)服务结束时间</th> -->
<!-- 		    	<th style="width: 6%">(现)批改方式</th> -->
		        <th style="width: 10%">操作</th>
		        <th style="width: 3%">操作记录</th>
		    </tr> 
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${item.child_name}"></td>
				<td th:text="${item.school}"></td>
				<td th:text="${item.grade}"></td>
				<td th:text="${item.parent_name}"></td>
				<td th:text="${item.parent_role}"></td>
				<td>
					<input type="number" th:value="${item.phone}" th:onBlur="'updateSort(\''+${item.id}+'\',\''+${item.phone}+'\',this)'"  class="dfinput" style="width: 160px; height: 30px;"  />
				</td>
				<td th:text="${item.derver}"></td>
<!-- 				<td th:text="${item.libVipService.startTime}"></td> -->
<!-- 				<td th:text="${item.libVipService.endTime}"></td> -->
<!-- 				<td th:text="${item.libVipService.startTime ==null ? '无服务' : (item.libVipService.species eq 'S999' ? '内部用户' :(item.libVipService.correctType==1 ? '平台批改' :  item.libVipService.correctType==2 ? '机构自批改' : item.libVipService.correctType==3 ? '家长自批改' : '平台批改'))}"></td> -->
				<td>
<!-- 					<a th:href="${'javascript:studentServiceAdd('''+item.id+''')'}"  class="tablelink">添加服务</a> -->
				
					<a th:if="${item.derver==null || item.derver==''}" th:href="${'javascript:studentBind('''+item.id+''')'}"  class="tablelink">添加小塾</a>
					<a th:if="${item.derver!=null && item.derver!=''}" th:href="${'javascript:studentDerverDel('''+item.id+''')'}" style="color:red"  class="tablelink">解绑小塾</a>
					
					<a th:href="${'javascript:studentDel('''+item.id+''')'}"  class="tablelink">移除学生</a>
				</td>
				<td>
					<a class="tablelink"   th:href="${'javascript:studentRecord('''+item.id+''')'}" >查看</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>






<div class="formbody" id="studentServiceEdit" style="display: none">
	<ul class="forminfo">
		<li>
			<label>批改类型：<b>*</b></label>
			<div class="vocation" style="margin-right: 5px; width: 320px">
				<select name="correctType" id="correctType" class="select1" > 
					<option  value="1" >平台</option>
					<option  value="2" >机构</option>
					<option  value="3" >家长</option>
				</select>
			</div>
		</li>
		<li>
			<label>服务日期：<b>*</b></label>
			<div class="vocation" style="margin-right: 5px; width: 345px">
				<input type="text" id="startTime" name="startTime" placeholder="开始日期" autocomplete="off"
					onclick=" WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss', isShowToday: false, isShowClear: false });"  class="scinput date_width " >
				
					&nbsp;-&nbsp;
				
				<input type="text" id="endTime" name="endTime"  placeholder="结束日期" autocomplete="off"
					onclick=" WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss', isShowToday: false, isShowClear: false });"  class="scinput date_width " >
			
			</div>
		</li>
		<li></li>
		<li></li>
		<li></li>
		<li>
			<label>&nbsp;</label>
			<button type="submit" onclick="studentServiceEditSave(1);" class="btn" style="width: 100px">立即生效</button>
			<button type="submit" onclick="studentServiceEditSave(2);" class="btn" style="width: 100px">延迟生效...</button>
			<button type="button" onclick="closeWin();" class="btn" style="background: #ccc;">取消设置</button>
		</li>
	</ul>
</div>



</body>


<script type="text/javascript">
$("#exbutton").on('click',function(){
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/imlibuser/student/exlist/[[${tbLibJoin.id}]]";
	$("#seachform").submit();
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/imlibuser/student/list/[[${tbLibJoin.id}]]";
});
</script>

<script type="text/javascript">


	$("#basecheckbox").bind("click",function(){
	    if($("#basecheckbox").is(':checked')){
	       $("[name='checkbox']").prop("checked",true);
	    }
	    if(!$("#basecheckbox").is(':checked')){
	       $("[name='checkbox']").removeAttr("checked");
	    }
	});

	function closeWin(){
		parent.layer.closeAll();
		layer.closeAll();
	}


	//修改排序号
	function updateSort(id,oldSortNo,_this){
		var sortNo = $(_this).val();
		if(sortNo == oldSortNo){
			return false;
		}
		if(sortNo ==''|| sortNo ==null){
			return false;
		}
		$(_this).removeAttr("onBlur");
		$.ajax({
			url : "[[${sysUrl}]]/sys/imlibuser/updateSortNo",
			type : "post",
			data : {
				id : id,
				phone : sortNo
			},
			dataType : "json",
			success : function(data) {
				if(data.meta.success){
					parent.layer.msg('操作成功',{icon:1});
					location.reload();
				}else{
					parent.layer.msg(data.meta.message,{icon: 9})
					location.reload();
				}
			}
		});
	}
	
	
	function studentServiceAdd(vipId){
		layer.open({
		    type: 2,
		    title: '添加学生服务',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['50%', '60%'],
		    content: '[[${sysUrl}]]/sys/imlibuser/student/service/add/[[${tbLibJoin.id}]]/'+vipId
		});
	}
	
	
	function studentAdd(){
		layer.open({
		    type: 2,
		    title: '添加学生',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['50%', '60%'],
		    content: '[[${sysUrl}]]/sys/imlibuser/student/add/[[${tbLibJoin.id}]]'
		});
	}
	
	
	function studentRecord(vipId){
		layer.open({
		    type: 2,
		    title: '操作记录',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['90%', '50%'],
		    content: '[[${sysUrl}]]/sys/imlibuser/student/record/[[${tbLibJoin.id}]]/'+vipId
		});
	}
	
	
	function studentServiceEdit(){
		var vipIds=[];
		$(".checkbox[type=checkbox]").each(function(){
			if($(this).is(':checked')){
				vipIds.push($(this).val()); 
			}
		}); 
		if(vipIds.length<=0){
			parent.layer.msg("请选择设置学生",{icon:2});
			return;
		}
		
		layer.open({
		    type: 1,
		    title: '学生设置',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['40%', '50%'],
		    content: $("#studentServiceEdit")
		});
	}
	
	
	function studentServiceEditSave(takeType){
		var vipIds=[];
		$(".checkbox[type=checkbox]").each(function(){
			if($(this).is(':checked')){
				vipIds.push($(this).val()); 
			}
		}); 
		if(vipIds.length<=0){
			parent.layer.msg("请选择设置学生",{icon:2});
			return;
		}
		var title="您确定保存数据为：<span style='color:red'>[延迟生效]</span>?";
		if(takeType==1){
			title="您确定保存数据为：<span style='color:red'>[立即生效]</span> ?";
		}else if(takeType==2){
			title="您确定保存数据为：<span style='color:red'>[延迟生效]</span>?";
		}
		parent.layer.confirm(title, {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/imlibuser/student/data/service/save";
			var params ={
					vipIds:vipIds.join(';'),
					correctType:$("#correctType").val(),
					startTime:$("#startTime").val(),
					endTime:$("#endTime").val(),
					takeType:takeType
			};
			$.post(url,params,function(data){
				if(data.meta.success){
					parent.layer.msg("移除成功",{icon:1});
					location.reload();
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
			});
		});
	}
	
	
	function studentBind(vipId){
		layer.open({
		    type: 2,
		    title: '绑定小塾',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['50%', '50%'],
		    content: '[[${sysUrl}]]/sys/imlibuser/student/bind/'+vipId
		});
	}
	
	
	function studentDel(vipId){
		parent.layer.confirm("您确定要删除学生关联?<br/>删除后会同步解绑该馆", 
				{
				icon: 4, 
				btn: ['确定','关闭'],
				offset: '150px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/imlibuser/student/data/del/"+vipId;
			var params ={};
			$.post(url,params,function(data){
				if(data.meta.success){
					parent.layer.msg("删除成功",{icon:1});
					location.reload();
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
			});
		});
	}

	
	function studentDerverDel(vipId){
		parent.layer.confirm("您确定要解绑学生小塾?", {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/imlibuser/student/data/del/derver/"+vipId;
			var params ={};
			$.post(url,params,function(data){
				if(data.meta.success){
					parent.layer.msg("删除成功",{icon:1});
					location.reload();
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
			});
		});
	}
	
	
	

	
</script>


</html>