<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;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a th:href="@{/sys/imuser/school/list}">导入老师/学生</a></li>
		<li><a href="#">老师列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="${sysUrl+'/sys/imlibuser/teacher/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:teacherAdd();" 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> -->
<!-- 	</ul> -->
	
	
	<table class="tablelist">
		<thead>
		    <tr>
		    	<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="${item.user_name}"></td>
<!-- 				<td th:text="${item.school}"></td> -->
				<td th:text="${item.mobile}"></td>
				<td th:text="${item.grade}"></td>
				<td th:text="${item.class_name}"></td>
<!-- 				<td > -->
<!-- 					<a th:if="${item.is_correct==1}" th:href="${'javascript:teacherIsCorrectSave(''' + item.user_id + ''',0)'}"  class="tablelink" style="color:red">取消批改</a> -->
<!-- 					<a th:if="${item.is_correct!=1}" th:href="${'javascript:teacherIsCorrectSave(''' + item.user_id + ''',1)'}"  class="tablelink">设置批改</a> -->
<!-- 				</td> -->
				<td>
					<a th:if="${search.get('type')=='1'}" th:href="${'javascript:teacherDel(''' + item.id + ''',''' + item.cid + ''')'}"  class="tablelink">删除科任老师</a>
					<a th:if="${search.get('type')=='2'}" th:href="${'javascript:headmasterDel(''' + item.id + ''',''' + item.cid + ''')'}"  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">
$("#exbutton").on('click',function(){
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/imlibuser/teacher/exlist/[[${tbLibJoin.id}]]";
	$("#seachform").submit();
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/imlibuser/teacher/list/[[${tbLibJoin.id}]]";
});
</script>

<script type="text/javascript">
	
	function teacherAdd(){
		layer.open({
		    type: 2,
		    title: '添加老师',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['50%', '50%'],
		    content: '[[${sysUrl}]]/sys/imlibuser/teacher/add/[[${tbLibJoin.id}]]'
		});
	}

	function teacherDel(teacherId,classId){
		parent.layer.confirm("您确定要删除科任老师?", {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/imlibuser/teacher/data/del/[[${tbLibJoin.id}]]/"+teacherId+'/'+classId;
			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 headmasterDel(teacherId,classId){
		parent.layer.confirm("您确定要删除班主任?", {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/imlibuser/headmaster/data/del/[[${tbLibJoin.id}]]/"+teacherId+'/'+classId;
			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 teacherIsCorrectSave(teacherId,isCorrect){
		var title="";
		if(isCorrect==1){
			title="您确定要【设置】此老师为批改老师的身份？";
		}else{
			title="您确定要【取消】此老师为批改老师的身份？";
		}
		
		parent.layer.confirm(title, {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/imlibuser/teacher/data/iscorrect/save/[[${tbLibJoin.id}]]/"+teacherId;
			var params ={isCorrect:isCorrect};
			$.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>