<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>
	<link th:href="@{/static/js/select/fselect.css}" rel="stylesheet" type="text/css">
<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>
	<script src="sys/js/select/fSelect.js" th:src="@{/static/js/select/fselect.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;
		}

		.select2 {
			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: 110px;
			line-height: 34px;
			display: block;
			float: left;
		}
		.showstyle{
			display: none
		}
	</style>
</head>

<body>
<div class="formbody">
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="id" id="id" th:if="${how.id}"  th:value="${how.id}"/>
		     <input type="hidden" name="schoolId" id="schoolId"   th:value="${how.schoolId}"/>
		<ul class="forminfo">
			<li class="clearfix" id="clearfix">
				<label>学校：<b>*</b></label>
				<div   onclick="window.open('../problem/schoolList.html', 'newwindow', 'height=530, width=1100, top=200, left=250, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no');" style="margin-right: 5px; width: 346px">
					<input type="text"  id="schoolName" style="width: 180px; " th:value="${how.schoolName}" disabled="disabled" class="dfinput" >
				</div>
				<input type="hidden" name="schoolName" id="schoolName2" th:value="${how.schoolName}"/>
			</li>
			    <li class="clearfix" >
				    <label>课程：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="courseName" id="yicourseNam" th:value="${how.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 id="vocation_version">
				<label>版本:<b>*</b></label>
				<div class="vocation_version" style="margin-left: 110px; width: 446px">
					<div th:remove="tag" th:each="map:${version}">
						<div th:remove="tag" th:each="item:${map.value}">
							<label  th:classappend="${item.courseName=='语文' ? 'chinese ' : item.courseName=='数学'? 'other showstyle' : 'english showstyle'}" ><input type="checkbox" class="version" th:checked="${how.courseName eq item.courseName && how.banben == item.versionType}" name="banben"  th:value="${item.versionType}" th:text="${item.versionName}" /></label>
						</div>
					</div>
				</div>
			 </li>
			  <li class="clearfix schoolgrade">
				    <label>年级：<b>*</b></label>
					<div class="vocation " style="margin-right: 5px; width: 300px" >

						<select class="select2 mselect"  multiple="multiple">
							<optgroup label="年级">
						   		 <option th:value="${list.aliases}" th:selected="${ how.grade+'' eq list.aliases }"
						   		  th:if="${list.aliases ne '0'}"
						   		  th:each="list:${grade}" th:text="${list.name}">学前</option>
							</optgroup>
						</select>

					</div>
			   </li>
            <input name="grade" type="hidden" id="grade" th:value="${how.grade}"/>
			<input name="area" type="hidden" id="area" th:value="${how.area}"/>
				<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(){
	$(".select1").change(function(){
		if($(this).val()=='英语'){
			$(".english").show();
			$(".other").hide();
			$(".chinese").hide();
		}else if($(this).val()=='数学'){
			$(".chinese").hide();
			$(".english").hide();
			$(".other").show();
		}else{
			$(".chinese").show();
			$(".english").hide();
			$(".other").hide();
		}

	});

	var courseName = "[[${how.courseName}]]";
	if(courseName=='英语'){
		$(".english").show();
		$(".other").hide();
		$(".chinese").hide();
	}else if(courseName=='数学'){
		$(".chinese").hide();
		$(".english").hide();
		$(".other").show();
	}else{
		$(".chinese").show();
		$(".english").hide();
		$(".other").hide();
	}
	
	$("#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();
		}
	});
	$('.mselect').fSelect();
	var grade = "[[${how.grade}]]";
	if(grade){
		$('.fs-label').text(grade)
	}

});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/problem/banbenSave";
    //取值
    $("#grade").val($('.fs-label').text());
	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>