<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>
   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;
    	}
    	.btn{
    	  width: 100px;
    	}
     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" id="libId" th:value="${content.libId}"/>
		     <input type="hidden" name="id" id="id" th:if="${content.id}"  th:value="${content.id}"/>
		     <input type="hidden" name="zybCourseId"  id="zybCourseId" th:value="${content.zybCourseId}"/>
		     <input type="hidden" name="type"  th:value="${content.type}"/>
		     <input type="hidden" name="num"  th:value="${content.num}"  th:if="${content.libId ne 'SSJ' && content.type eq 1}"/>
		<ul class="forminfo">
			  <li>
				<label>内容:<b>*</b></label>
				<input type="text" id="content" class="dfinput fl" name="content"  th:value="${content.content}"  />
			  </li>
			    <li class="clearfix" id="clearfix">
				    <label>类型：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="stat">
						   		 <option   value="1" th:selected="${ content.stat eq 1 }" >单选</option>
						   		 <option   value="2" th:selected="${ content.stat eq 2 }" >多选</option>
						   		 <option   value="3" th:selected="${ content.stat eq 3 }" >文本域</option>
						   		 <option   value="4" th:selected="${ content.stat eq 4 }" >输入字符框</option>
						   		 <option   value="5" th:selected="${ content.stat eq 5 }" >输入数字框</option>
						</select>
					</div>
			   </li>
			    <li class="clearfix" id="clearfix">
				    <label>子节点排版：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="childStat">
						   		 <option   value="1" th:selected="${ content.childStat eq 1 }" >一行一个</option>
						   		 <option   value="2" th:selected="${ content.childStat eq 2 }" >一行多个</option>
						</select>
					</div>
			   </li>
			  <li th:if="${content.libId eq 'SSJ' || (content.libId ne 'SSJ' && content.type eq 2)}">
				<label>排序:<b>*</b></label>
				<input type="number" id="num" class="dfinput fl" name="num"  th:value="${content.num}"/>
			 </li>
			  <li>
				<label>匹配语句:</label>
				<input type="text" id="matching" class="dfinput fl" name="matching" placeholder="专注写作业时{变量}" th:value="${content.matching}"  />
			  </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 : {
			
			content : {
				required : true
			},
			num : {
				required : true,
				digits:true,
				remote:{
			               type:"POST",
			               url:"[[${sysUrl}]]/sys/zuoyb/validateNum",            
			               data:{
			            	   oldNum:'[[${content.num}]]',
			            	   zybCourseId:'[[${content.zybCourseId}]]',
			            	   libId:'[[${content.libId}]]',
			            	   num:function(){return $("#num").val();}
			               } 
			            } 
			}
		},
		messages: {
			content : {
				required : "不能为空"
			},
			num : {
				required : "不能为空",
				digits : "只能输入整数",
				remote:"该序号已经存在!"  
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/zuoyb/scoringContentSave";
	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>