<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;
    	}
    </style>
</head>

<body>
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    	<li><a th:href="@{/sys/problem/experiencelist.html}">0元活动管理</a></li>
    	<li><a th:href="@{/sys/problem/experiencelist.html}">0元活动设置</a></li>
    </ul>
</div>
<div class="formbody">
	<div class="formtitle"><span>0元活动信息</span></div>
	<form id="roleFrom"   method="post" class="form-horizontal form-validate">
		<input  type="hidden" id="id" th:if="${experience.id}" th:value="${experience.id}" name="id">
		<ul class="forminfo">
			<li class="clearfix">
				<label class="fl">孩子姓名<b>*</b></label>
				  <input  type="text" id="name"  th:value="${experience.name}" class="dfinput fl"  name="name">
			</li>
			<li class="clearfix" id="clearfix">
				    <label>年级：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="grade">
						   		 <option  th:each="sort:${grade}"  th:value="${sort.name}" th:selected="${ sort.name eq experience.grade }" th:text="${sort.name}" ></option>
						</select>
					</div>
			   </li>
			<li class="clearfix">
				<label class="fl">电话<b>*</b></label>
				  <input  type="text" id="phone"  th:value="${experience.phone}" class="dfinput fl"  name="phone">
			</li>
				<li>
			    <label>类别：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 179px">
					<select class="select1" name="type">
					   		 <option  value="1"  th:selected="${experience.type==1}" >0元阅读</option>
					   		 <option  value="2"  th:selected="${experience.type==2}" >0元试听课</option>
					</select>
				</div>
		   </li>
			<li>
			    <label>科目：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 179px">
					<select class="select1" name="course">
					   		 <option  value="语文" th:selected="${experience.course eq '语文'}" >语文</option>
					   		 <option  value="数学" th:selected="${experience.course eq '数学'}" >数学</option>
					   		 <option  value="英语" th:selected="${experience.course eq '英语'}" >英语</option>
					</select>
				</div>
		   </li>
		   <li class="clearfix">
				<label class="fl">图书馆<b>*</b></label>
				  <input  type="text" id="library"  th:value="${experience.library}" class="dfinput fl"  name="library">
			</li>
			<li class="clearfix">
				<label class="fl">信息来源<b>*</b></label>
				  <input  type="text" id="source"  th:value="${experience.source}" class="dfinput fl"  name="source">
			</li>
			<li>
				<label>&nbsp;</label>
				<button type="submit" class="btn">保存</button>
				<button type="button" class="btn" onclick="window.history.go(-1);">取消</button>
			</li>
		</ul>
	</form>
</div>
</body>
<script type="text/javascript">

$(function(){
	$("#roleFrom").validate({
		rules : {
			name : {
				required : true
			 },
			 grade : {
		        required : true
	         },
	         phone : {
			    required : true
			 }
			},
		messages: {
			name : {
				required : "请输入学生姓名"
			 },
			 grade : {
		        required : "请输入就读年级"
	         },
	         type : {
			    required : "请输入联系电话"
			 }
		   },
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/problem/saveExperience";
	var params = $("#roleFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
			if(data.code=="999"){
					layer.msg("操作成功!",{icon:1});
			    	setTimeout(function(){
			    		window.location.href ='[[${sysUrl}]]/sys/problem/experiencelist.html';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}


</script>
</html>