<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 href="#">图书馆管理</a></li>
		<li><a th:href="@{/sys/lib/libJoinList.html}">图书馆</a></li>
		<li><a href="#">销售卡服务管理</a></li>
	</ul>
</div>
<div class="formbody">
	<div class="formtitle"><span th:text="${salesPrice.id} ? '修改销售卡服务' :'新增销售卡服务'">新增图书</span></div>
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="id" th:if="${salesPrice.id}" th:value="${salesPrice.id}"/>
		     <input type="hidden" name="libId"  th:value="${salesPrice.libId}"/>
		<ul class="forminfo">
			   <li class="clearfix" id="clearfix">
				    <label>卡片种类：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 346px">
						<select class="select1" name="species" >
						   		 <option th:each="sort:${species}" th:if="${ salesPrice.species eq sort.code }"  th:value="${sort.code}">[[${sort.name}]]</option>
						</select>
					</div>
			   </li>
			   <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:if="${salesPrice.type eq sort.code }"  th:value="${sort.code}">[[${sort.name}]]</option>
						</select>
					</div>
			   </li>
				<li class="clearfix">
					<label>押金:<b>*</b></label>
					<input type="number" id="deposit" class="dfinput fl" name="deposit"  th:value="${salesPrice.deposit}"/>
				</li>
				<li class="clearfix">
					<label>可借书籍数量:<b>*</b></label>
					<input type="number" id="borrowNum" class="dfinput fl" name="borrowNum"  th:value="${salesPrice.borrowNum}"/>
				</li>
				<li class="clearfix">
					<label>可借书天数:<b>*</b></label>
					<input type="number" id="borrowDay" class="dfinput fl" name="borrowDay"  th:value="${salesPrice.borrowDay}"/>
				</li>
				<li class="clearfix">
					<label>逾期扣钱:<b>*</b></label>
					<input type="text" id="outMoney" class="dfinput fl" name="outMoney"  th:value="${salesPrice.outMoney}"/>
				</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 : {
			
			deposit : {
				required : true,
				digits:true
			},
			borrowNum : {
				required : true,
				digits:true,
			},
			borrowDay : {
				required : true,
				digits:true
			},
			outMoney : {
				required : true
			}
		},
		messages: {
			
			deposit : {
				required : "不能为空",
				digits : "只能输入整数"
			},
			borrowNum : {
				required : "不能为空",
				digits : "只能输入整数"
			},
			borrowDay : {
				required : "不能为空",
				digits : "只能输入整数"
			},
			outMoney : {
				required : "不能为空"
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/sales/libBorrowedServiceSave";
	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/borrowedServiceList.html?EQ_libId=[[${salesPrice.libId}]]';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}



</script>
</html>