<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: 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/zuoyb/zuoybCourseList.html}">作业吧班级管理</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/zuoyb/zuoybCourseList.html}" method="post">
	<input type="hidden" name="EQ_libId" th:value="${search.get('EQ_libId')}">
	<ul class="seachform">
		<li>
			<label>课程</label>
			<input name="course_name" type="text" class="scinput" th:value="${search.get('course_name')}"/>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li  >
				<ul class="toolbar"  th:onclick="'zuoybCourseAdd(\''+${search.get('EQ_libId')}+'\')'">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增</li>
				</ul>
		</li>
		<li>
				<ul class="toolbar">
					<a th:href="@{/sys/lib/libJoinList.html}"><li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/goto.png}" /></span>返回</li></a>
				</ul>
		</li>
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
		        <th style="width: 80px;">时段</th>
		        <th style="text-align: center;" >排序</th>
		        <th>星期一</th>
		        <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.get('course_hour')}+''+${item.get('course_name')}"></td>
					 <td style="text-align: center;" >
					 <input type="number" th:value="${item.num}" th:onBlur="'updateCourseNum(\''+${item.id}+'\',\''+${item.num}+'\',this)'"  class="dfinput" style="width: 70px; height: 30px;color: red;"  >
					</td>
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;" 
					   th:onclick="'getZybManage(\''+${item.get('monday')}+'\',\''+1+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					   >请选择老师</a>
					</td>
					
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;"
					   th:onclick="'getZybManage(\''+${item.get('tuesday')}+'\',\''+2+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					    >请选择老师</a>
					</td>
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;"
					   th:onclick="'getZybManage(\''+${item.get('wednesday')}+'\',\''+3+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					     >请选择老师</a>
					</td>
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;"
					   th:onclick="'getZybManage(\''+${item.get('thursday')}+'\',\''+4+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					     >请选择老师</a>
					</td>
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;"
					   th:onclick="'getZybManage(\''+${item.get('friday')}+'\',\''+5+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					     >请选择老师</a>
					</td>
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;"
					   th:onclick="'getZybManage(\''+${item.get('saturday')}+'\',\''+6+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					     >请选择老师</a>
					</td>
					<td>
					   <a href="javascript:;" style="text-align:center;color: red; margin-right: 10px;"
					   th:onclick="'getZybManage(\''+${item.get('sunday')}+'\',\''+7+'\',\''+${item.get('lib_id')}+'\',\''+${item.get('course_hour')}+'\',\''+${item.get('id')}+'\');'"
					     >请选择老师</a>
					</td>
					
					<td >
						<a href="javascript:;"  th:onclick="'deleteById(\''+${item.get('id')}+'\')'"  class="tablelink" >删除</a>
						<a th:href="@{/sys/zuoyb/scoringContentList.html( EQ_zybCourseId=${item.get('id')},EQ_libId=${search.get('EQ_libId')},type=2)}"  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 updateCourseNum(id,oldNum,_this){
	var num = $(_this).val();
	if(num == oldNum){
		return false;
	}
	if(num ==''|| num ==null){
		return false;
	}
	$(_this).removeAttr("onBlur");
	$.ajax({
		url : "[[${sysUrl}]]/sys/zuoyb/updateCourseNum",
		type : "post",
		data : {
			id : id,
			num : num
		},
		dataType : "json",
		success : function(data) {
			if(data.meta.success){
				 parent.layer.msg('操作成功',{icon:1});
				 $(_this).attr("onBlur","updateCourseNum("+id+","+num+",this)");
			}else{
				parent.layer.msg('操作失败',{icon: 9})
				$(_this).attr("onBlur","updateCourseNum("+id+","+oldNum+",this)");
			}
		}
	});
}

function deleteById(id){
	layer.confirm("确定删除该课程吗？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/zuoyb/zuoybCourseDelete',
			type: "post",
			data:{
				'id': id
			},
			dataType: "json",
			success:function(data){
					
					if(data.meta.success){
						layer.msg("删除成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},1000);
					}else{
						layer.msg(data.meta.message,{icon:11});
					}
			}
		});
	});
}

function zuoybCourseAdd(id){
	layer.open({
	    type: 2,
	    title: "添加课程",
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    //offset: '100px',
	    area: ['80%', '50%'],
	    content: '[[${sysUrl}]]/sys/zuoyb/zuoybCourseAdd.html?libId='+id
	});
}
function getZybManage(weekId,days,libId,courseHour, zybCourseId){
	layer.open({
	    type: 2,
	    title: "添加管理员",
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    //offset: '100px',
	      area: ['80%', '90%'],
	    content: '[[${sysUrl}]]/sys/zuoyb/selectZybList.html?weekId='+weekId+'&days='+days+'&libId='+libId+'&courseHour='+courseHour+'&zybCourseId='+zybCourseId
	});
}
</script>
</html>