<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>
<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/sales/libVipServiceList.html}">会员服务管理</a></li>
	</ul>
</div>
<div class="formbody">
	<div class="formtitle"><span>修改会员服务</span></div>
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="id" th:if="${vip.id}" th:value="${vip.id}"/>
		     <input type="hidden" name="libId"  th:value="${vip.libId}"/>
		     <input type="hidden" name="vipId"  th:value="${vip.vipId}"/>
		     <input type="hidden" name="orderDetailsId"  th:value="${vip.orderDetailsId}"/>
		     <input type="hidden" name="species"  th:value="${vip.species}"/>
		     <input type="hidden" name="stat"  th:value="${vip.stat}"/>
		     <input type="hidden" name="isJia"  th:value="${vip.isJia}"/>
		     <input type="hidden" name="courseCount"  th:value="${vip.courseCount}"/>
	         <input type="hidden" name="zybCourseId"  th:value="${vip.zybCourseId}"/>
	         <input type="hidden" name="courseHour"  th:value="${vip.courseHour}"/>
		      <span th:if="${ vip.species eq  'S003'  } " th:remove="tag">
	         <input type="hidden" name="deposit"  th:value="${vip.deposit}"/>
	         <input type="hidden" name="borrowNum"  th:value="${vip.borrowNum}"/>
	         <input type="hidden" name="borrowDay"  th:value="${vip.borrowDay}"/>
	         <input type="hidden" name="outMoney"  th:value="${vip.outMoney}"/>
		      </span>
		<ul class="forminfo">
			<li class="clearfix" >
			    <label>购买时间：<b>*</b></label>
				<input type="text" id="startTime" class="dfinput fl" name="startTime" 
				th:value="${#calendars.format(vip.startTime,'yyyy-MM-dd HH:mm:ss')}"
				onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
		   </li>
			<li class="clearfix" >
			    <label>到期时间：<b>*</b></label>
				<input type="text" id="endTime" class="dfinput fl" name="endTime" 
				th:value="${#calendars.format(vip.endTime,'yyyy-MM-dd HH:mm:ss')}"
				onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
		   </li>
		   <span th:if="${ vip.species eq  'S003'  } " th:remove="tag"> 
		    <li class="clearfix">
				    <label>服务类型：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 346px">
						<select class="select1" name="type" >
						   		 <option th:each="sort:${cardType}" th:selected="${vip.type eq sort.code }" th:if="${sort.code eq 'C004' || sort.code eq 'C005' || sort.code eq 'C006'  }" th:value="${sort.code}">[[${sort.name}]]</option>
						</select>
					</div>
			 </li>
		   </span>
		   <span th:if="${ vip.species eq  'S001'  } " th:remove="tag"> 
		    <li class="clearfix">
				    <label>服务类型：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 346px">
						<select class="select1" name="type" >
						   		 <option th:each="sort:${cardType}" th:selected="${vip.type eq sort.code }" th:if="${ sort.code eq 'C001' || sort.code eq 'C002' || sort.code eq 'C003' || sort.code eq 'C007' || sort.code eq 'C008' }" th:value="${sort.code}">[[${sort.name}]]</option>
						</select>
					</div>
			 </li>
			<li>
				<label>押金金额</label>
				<input type="number" id="deposit" class="dfinput fl" name="deposit"  th:value="${vip.deposit}"/>
			</li>
			<li>
				<label>可借书籍</label>
				<input type="number" id="borrowNum" class="dfinput fl" name="borrowNum" th:value="${vip.borrowNum}"/>
			</li>
			<li>
				<label>可借天数</label>
				<input type="number" id="borrowDay" class="dfinput fl" name="borrowDay"  th:value="${vip.borrowDay}"/>
			</li>
			<li>
				<label>逾期每日需付费</label>
				<input type="number" id="outMoney" class="dfinput fl" name="outMoney"  th:value="${vip.outMoney}"/>
			</li>
			</span>
			<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 : {
			
			startTime : {
				required : true
			},
			endTime : {
				required : true
			}
		},
		messages: {
			startTime : {
				required : "开始时间不能为空"
			},
			endTime : {
				required : "结束时间不能为空"
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/sales/libVipServieUpdateSave";
	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/sales/libVipServiceList.html';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}

</script>
</html>