<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 type="text/css">
    body{min-width:280px;}
    </style>
</head>


<body>
<div class="formbody">
	<div class="formtitle"><span>基本信息</span></div>
	<form id="submitFrom" method="post" class="form-horizontal form-validate">
		<input type="hidden" name="pId" th:value="${org.id}" />
		<input type="hidden" name="name" th:value="${org.name}" />
		<input type="hidden" name="code" th:value="${org.code}" id="code"/>
		<ul class="forminfo">
			<li>
				<label>开始序号<b>*</b></label>
				<input type="text" name="beginIndex" id="beginIndex"  class="dfinput" />
			</li>
			<li>
				<label>数量<b>*</b></label>
				<input type="text" name="totalNum"  class="dfinput"/>
			</li>
			<li>
				<label>&nbsp;</label>
				<button type="submit" class="btn">保存</button>
				<button type="button" class="btn" onclick="closeWin();">取消</button>
			</li>
		</ul>
	</form>
</div>
<script type="text/javascript">

$(function(){
	
	
	$(function(){
		$("#submitFrom").validate({
			rules : {

				beginIndex : {
					required : true,
					maxlength: 300
				},
				totalNum : {
					required : true,
					maxlength: 300
				}
			},
			messages: {
				beginIndex : {
					required : "名称不能为空",
					maxlength : "最多300个字符"
				},
				totalNum : {
					required : "名称不能为空",
					maxlength : "最多300个字符"
				}
			},
			errorPlacement : function(error, element) {
					error.appendTo(element.parent()); 
			},
			submitHandler : function(form) {
				roleFrom();
			}
		});
		
	});
	function roleFrom(){
		var url="[[${sysUrl}]]/sys/org/batchSave";
		var params = $("#submitFrom").serialize();
		var id="";
		if($("#submitFrom").find("input[name='id']").val() != undefined){
			id = $("#submitFrom").find("input[name='id']").val();
		}
		var pid = $("#submitFrom").find("input[name='pId']").val();
		var name =$("#submitFrom").find("input[name='name']").val()+$("#beginIndex").val();
		$.post(url,params,function(data){
			if(data != null){
					if(data.meta.success){
						parent.layer.msg('操作成功',{icon:1});
						refreshTree(id, pid, name);
				    	setTimeout(function(){
				    		parent.refreshList();
							closeWin();
						},1000);
					}else{
						layer.msg(data.meta.message,{icon:11});
					}
			}
			
		});
	}
});

function refreshTree(id, pid, name){
	parent.refreshNode(id, pid, name);
}

function closeWin(){
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}
</script>
</body>
</html>