<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 th:include="sys/common/selectSearchJS" 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>
    	.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 href="#">图书馆</a></li>
    	<li><a th:href="@{/sys/lib/libJoinList.html}">图书馆管理</a></li>
    </ul>
</div>
<div class="formbody">
	<div class="formtitle"><span th:text="${ws.id} ? '修改图书馆' :'新增图书馆'">新增图书馆</span></div>
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="id" th:if="${ws.id}" th:value="${ws.id}"/>
		     <input type="hidden" name="qrCode" th:if="${ws.qrCode}" th:value="${ws.qrCode}"/>
		     <input type="hidden" name="leagueLat"  th:value="${ws.leagueLat}"/>
		     <input type="hidden" name="leagueLng"  th:value="${ws.leagueLng}"/>

		     <input type="hidden" name="workStart"  th:value="${ws.workStart}"/>
		     <input type="hidden" name="workEnd"  th:value="${ws.workEnd}"/>
		     <input type="hidden" name="weekeedStart"  th:value="${ws.weekeedStart}"/>
		     <input type="hidden" name="weekeedEnd"  th:value="${ws.weekeedEnd}"/>
		      <input type="hidden" name="startJiaTime"  th:value="${ws.startJiaTime}"/>
		     <input type="hidden" name="endJiaTime"  th:value="${ws.endJiaTime}"/>
			 <input type="hidden" name="version"  th:value="${ws.version}"/>
			<input type="hidden" name="platformService"  th:value="${ws.platformService}"/>
			<input type="hidden" name="libService"  th:value="${ws.libService}"/>
		<ul class="forminfo">
			<li class="clearfix">
				<label>图书馆名称:<b>*</b></label>
				<input type="text" id="leagueName" class="dfinput fl" name="leagueName"  th:value="${ws.leagueName}"/>
			</li>
			<li class="clearfix">
				<label>图书馆CODE:<b>*</b></label>
				<input type="text" id="leagueCode" class="dfinput fl" name="leagueCode"  th:value="${ws.leagueCode}"/>
			</li>
			<li class="clearfix">
				<label>图书馆地址:<b>*</b></label>
				<input type="text" id="leagueAddress" class="dfinput fl" name="leagueAddress"  th:value="${ws.leagueAddress}"/>
			</li>
			<li class="clearfix">
				<label>图书馆城市:<b>*</b></label>
				<input type="text" id="leagueCity" class="dfinput fl" name="leagueCity"  th:value="${ws.leagueCity}" placeholder="广州,深圳,佛山"/>
			</li>
			<li class="clearfix">
				<label>图书馆电话:<b>*</b></label>
				<input type="text" id="leaduePhone" class="dfinput fl" name="leaduePhone"  th:value="${ws.leaduePhone}"/>
			</li>
			<li class="clearfix">
				<label>图书馆客服:<b>*</b></label>
				<input type="text" id="leadueManager" class="dfinput fl" name="leadueManager"  th:value="${ws.leadueManager}"/>
			</li>
			<li class="clearfix">
				<label>共享签约时间:<b>*</b></label>
				<input id="createTime" autocomplete="off"  name="createTime"  class="dfinput fl" type="text"  th:value="${#calendars.format(ws.createTime,'yyyy-MM-dd HH:mm:ss')}"
					        	onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
			</li>
			<li class="clearfix">
				<label>是否激活</label>
				<div class="vocation" style="margin-right: 5px; width: 346px">
					<select name="type" id="type" class="select1"> 
						<option th:selected="${ ws.type eq 1 }" value="1" >是</option>
						<option th:selected="${ ws.type eq 2 }" value="2" >推荐</option>
						<option th:selected="${ ws.type eq 0 }" th:if="${ ws.type  eq 0  } "   value="0" >否</option>
					</select>
				</div>
			</li>
			<li class="clearfix">
				<label>图书馆类型</label>
				<div class="vocation" style="margin-right: 5px; width: 346px">
					<select name="libtype" id="libtype" class="select1"> 
						<option th:selected="${ ws.libtype eq 1 }" value="1" >家庭图书馆</option>
						<option th:selected="${ ws.libtype eq 2 }" value="2" >共享图书馆A</option>
						<option th:selected="${ ws.libtype eq 3 }" value="3" >共享图书馆B</option>
						<option th:selected="${ ws.libtype eq 4 }" value="4" >共享图书馆C</option>
						<option th:selected="${ ws.libtype eq 5 }" value="5" >学校类型</option>
					</select>
				</div>
			</li>
			<li class="clearfix">
				<label>关联组织架构</label>
				<div class="vocation" style="margin-right: 5px; width: 346px">
					<select name="orgCode" id="orgCode" class="select1"> 
						 <option th:each="sort:${orgList}" th:selected="${ ws.orgCode eq sort.code }"  th:value="${sort.code}">[[${sort.name}]]</option>
					</select>
				</div>
			</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(){
	$("#submitFrom").validate({
		rules : {
			
			leagueName : {
				required : true,
				maxlength: 300
			},
			leagueCode : {
				required : true,
				maxlength: 300
			}
		},
		messages: {
			leagueName : {
				required : "名称不能为空",
				maxlength : "最多300个字符",
			},
			leagueCode : {
				required : "CODE不能为空",
				maxlength : "最多300个字符",
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	
	var url="[[${sysUrl}]]/sys/lib/libJoinSave";
	var params = $("#submitFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
				if(data.meta.success){
					layer.msg("操作成功!",{icon:1});
			    	setTimeout(function(){
			    		window.location.href ='[[${sysUrl}]]/sys/lib/libJoinList.html';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
					
					
				}
		}
		
	});
}
</script>
</html>