<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>
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>

	<style>
		body {
			min-width: 180px;
		}

		.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;
		}
		.selectg {
			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;
		}

		.btn {
			width: 100px;
		}

		label.control-label-error {
			color: Red;
		}

		.forminfo li label {
			width: 85px;
			line-height: 34px;
			display: block;
			float: left;
		}
	</style>
</head>

<body>
<div class="formbody">
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="libId" id="libId" th:value="${how.libId}"/>
		     <input type="hidden" name="id" id="id" th:if="${how.id}"  th:value="${how.id}"/>
		<ul class="forminfo">
			    <li class="clearfix" id="clearfix">
				    <label>课程：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="courseName">
						   		 <option  th:each="sort:${zyb_course}"  th:value="${sort.name}" th:if="${sort.name ne '总体'}" th:selected="${ sort.name eq how.courseName }" th:text="${sort.name}" ></option>
						</select>
					</div>
			   </li>
			  <li>
				<label>大纲内容:<b>*</b></label>
				<textarea rows="5" id="name" name="name" class="textinput" style="width: 346px;    height: 112px;" cols="5">[[${how.name}]]</textarea>
			  </li>
			  <li>
				<label>模块:<b>*</b></label>
				<input type="text" id="module" class="dfinput fl" name="module"  th:value="${how.module}"/>
			 </li>
			  <li>
				<label>单元序号:<b>*</b></label>
				<input type="number" id="num" class="dfinput fl" name="num"  th:value="${how.num}" />
			 </li>
			  <li>
				<label>是否专题:<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 346px">
				    <label><input type="radio" class="isZt" name="isZt" th:checked="${ how.isZt eq 0  }" value="0" />否</label>
					<label><input type="radio" class="isZt" name="isZt" th:checked="${ how.isZt eq 1 }" value="1" />是</label>
				</div>
			 </li>
			  <li th:if="${#strings.isEmpty(how.id)}" id="vocation_version">
				<label>版本:<b>*</b></label>
				<div class="vocation_version" style="margin-right: 5px; width: 546px">
				
				 	<label th:each="version:${versions['数学'] }" class="other" th:style="${how!=null && how.courseName!=null && how.courseName eq '数学' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  th:value="${version.versionType }" />[[${version.versionName}]]</label>
			 	 	<label th:each="version:${versions['语文'] }" class="chinese" th:style="${how!=null && how.courseName!=null && how.courseName eq '语文' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  th:value="${version.versionType }" />[[${version.versionName}]]</label>
			 		<label th:each="version:${versions['英语'] }" class="english" th:style="${how!=null && how.courseName!=null && how.courseName eq '英语' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  th:value="${version.versionType }" />[[${version.versionName}]]</label>
			
				
<!-- 				    <label class="other" th:style="${how!=null && how.courseName!=null && how.courseName eq '数学' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  value="1" />北师大</label> -->
<!-- 					<label class="other" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '数学' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  value="2" />人教版</label> -->
<!-- 					<label class="other" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '数学' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  value="5" />江苏版</label> -->
<!-- 					<label class="other" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '数学' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  value="6" />思维拓展</label> -->
					
<!-- 					<label class="chinese" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '语文' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  value="2" />人教(部编)</label> -->
					
<!-- 					<label class="english" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '英语' ? '' : 'display: none'}"><input type="checkbox" class="version"  name="version"  value="2" />教科版</label> -->
<!-- 					<label class="english" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '英语' ? '' : 'display: none'}"><input type="checkbox" class="version"   name="version"  value="3" />沪教版（新）</label> -->
<!-- 					<label class="english" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '英语' ? '' : 'display: none'}"><input type="checkbox" class="version"   name="version"  value="7" />朗文版</label> -->
<!-- 					<label class="english" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '英语' ? 'width: 100px;' : 'display: none;width: 100px;'}"><input type="checkbox" class="version"   name="version"  value="8" />人教版（PEP）</label> -->
<!-- 					<label class="english" th:style="${how!=null && how.courseName!=null &&  how.courseName eq '英语' ? '' : 'display: none'}"><input type="checkbox" class="version"   name="version"  value="9" />牛津版</label> -->
				</div>
			 </li>
			  <li class="clearfix schoolgrade" th:if="${#strings.isEmpty(how.id)}" style="display: none ">
				    <label>年级：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="selectg" name="gradeNum">
						   		 <option th:value="${list.aliases}" th:selected="${ how.gradeNum+'' eq list.aliases }" 
						   		  th:if="${list.aliases ne '0'}"
						   		  th:each="list:${grade}" th:text="${list.name}">学前</option>
						</select>
					</div>
			   </li>
			  <li th:if="${#strings.isEmpty(how.id)}" class="schoolgrade" style="display: none ">
				    <label>学期：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 346px">
					    <label><input type="radio" class="isZt" name="semester"  value="1" />上学期</label>
						<label><input type="radio" class="isZt" name="semester"  value="2" />下学期</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(){
	
	$(".version").on("click",function(){
		if($('.version').is(':checked')){
			$('.schoolgrade').show();
		}else{
			$('.schoolgrade').hide();
		}
	});
	
	$(".select1").change(function(){
		if($(this).val()=='英语'){
			$(".english").show();
			$(".other").hide();
			$(".chinese").hide();
		}else if($(this).val()=='语文'){
			$(".chinese").show();
			$(".english").hide();
			$(".other").hide();
		}else{
			$(".chinese").hide();
			$(".english").hide();
			$(".other").show();
		}
	});
	
	
	
	$("#submitFrom").validate({
		rules : {
			
			name : {
				required : true
			},
			num : {
				required : true
			}
		},
		messages: {
			name : {
				required : "大纲不能为空"
			},
			num : {
				required : "单元序号不能为空"  
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/zuoyb/knowHowSave";
	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>