<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/jquery.validate.min.js" th:src="@{/static/sys/js/jquery.validate.min.js}"></script>
<script src="sys/js/jquery-validation/messages_zh.js" th:src="@{/static/sys/js/jquery-validation/messages_zh.js}"></script>

 <style>
    	.clearfix:after {
			visibility: hidden;
			display: block;
			font-size: 0;
			content: " ";
			clear: both;
			height: 0;
		}
		.clearfix { display: inline-table; }
		* html .clearfix { height: 1%; }
		.clearfix { display: block; }
		.fl{display:inline;float:left}
		clearfix >control-label-error{display:inline;float:left;marign-left:10px}
		 label.control-label-error {
  				color: Red;
             }
          .lispan {line-height: 34px;}   
          
          .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;
    	}
    	     label.control-label-error {color: Red;}	
    </style>
</head>

<body>
<div class="formbody">
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="libId"  th:value="${libId}"/>
		<ul class="forminfo">
			   <li class="clearfix" id="clearfix">
				    <label>课程：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 346px">
						<select class="select1" name="courseName">
						   		 <option th:each="sort:${zyb_course}"   th:value="${sort.id}" th:text="${sort.name}"></option>
						</select>
					</div>
			   </li>
			  <li class="clearfix" id="clear">
				<label class="fl">时段<b>*</b></label>
				<div th:each="item : ${zyb_hour}" th:remove="tag">
					  <label class="fl" style="width: 70px;" th:for="${item.code}" ><input type="checkbox" th:id="${item.code}"  name="courseHour" th:value="${item.id}"/>[[${item.name}]]时段</label>
				</div>
			  </li>
				<li>
					<label>&nbsp;</label>
					<button type="submit" class="btn">保存</button>
					<button type="button" class="btn" onclick="closeWin();">取消</button>
				</li>
		</ul>
	</form>
</div>
</body>
<script type="text/javascript">

$(function(){
	
	
	
	$("#submitFrom").validate({
		rules : {
			
			courseName : {
				required : true
			},
			courseHour : {
				required : true
			}
		},
		messages: {
			courseName : {
				required : "不能为空"
			},
			courseHour : {
				required : "不能为空"
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/zuoyb/zuoybCourseListSave";
	var params = $("#submitFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
				if(data.meta.success){
					parent.layer.msg("新增成功",{icon:1});
					closeWin();
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
					closeWin();
				}
		}
		
	});
}
function closeWin(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}



</script>
</html>