<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/lib/libVipList.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="userId" th:if="${vip.userId}" th:value="${vip.userId}"/>
		     <input type="hidden" name="stat" th:if="${vip.stat}" th:value="${vip.stat}"/>
		     <input type="hidden" name="vipno" th:if="${vip.vipno}" th:value="${vip.vipno}"/>
		     <input type="hidden" name="activateTime" th:if="${vip.activateTime}"   th:value="${#calendars.format(vip.activateTime,'yyyy-MM-dd HH:mm:ss')}"  />
		     <input type="hidden" name="level" th:if="${vip.level}" th:value="${vip.level}"/>
		     <input type="hidden" name="qrcodeUrl" th:if="${vip.qrcodeUrl}" th:value="${vip.qrcodeUrl}"/>
		     <input type="hidden" name="counseling" th:if="${vip.counseling}" th:value="${vip.counseling}"/>
		     <input type="hidden" name="flowId" th:if="${vip.flowId}" th:value="${vip.flowId}"/>
		     <input type="hidden" name="isUpdate" th:if="${vip.isUpdate}" th:value="${vip.isUpdate}"/>
		     <input type="hidden" name="orderUser" th:if="${vip.orderUser}" th:value="${vip.orderUser}"/>
		     <input type="hidden" name="orderTime" th:if="${vip.orderTime}" th:value="${vip.orderTime}"/>
		     <input type="hidden" name="cardCode" th:if="${vip.cardCode}" th:value="${vip.cardCode}"/>
		     <input type="hidden" name="derver" th:if="${vip.derver}" th:value="${vip.derver}"/>
		     <input type="hidden" name="courseName" th:if="${vip.courseName}" th:value="${vip.courseName}"/>
		     <input type="hidden" name="studyPlan" th:if="${vip.studyPlan}" th:value="${vip.studyPlan}"/>
		     <input type="hidden" name="tagsCharacter" th:if="${vip.tagsCharacter}" th:value="${vip.tagsCharacter}"/>
		     <input type="hidden" name="tagsHabit" th:if="${vip.tagsHabit}" th:value="${vip.tagsHabit}"/>
		     <input type="hidden" name="planTemplateId" th:if="${vip.planTemplateId}" th:value="${vip.planTemplateId}"/>
		<ul class="forminfo">
			<li class="clearfix">
				<label>家长姓名:<b>*</b></label>
				<input type="text" id="parentName" class="dfinput fl" name="parentName"  th:value="${vip.parentName}"/>
			</li>
			<li class="clearfix">
				<label> 孩子姓名:<b>*</b></label>
				<input type="text" id="childName" class="dfinput fl" name="childName"  th:value="${vip.childName}"/>
			</li>
			<li class="clearfix">
				    <label>性别：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="sex">
						   		 <option  value="1" th:selected="${  vip.sex eq '1' }"  >男</option>
						   		 <option  value="2" th:selected="${  vip.sex eq '2' }"  >女</option>
						</select>
					</div>
			 </li>
			   
			<li class="clearfix">
				<label>联系方式:<b>*</b></label>
				<input type="text" id="phone" class="dfinput fl" name="phone"  th:value="${vip.phone}"/>
			</li>
			<li class="clearfix">
				<label>学校:<b>*</b></label>
				<div class="vocation" id="school" style="margin-right: 5px; width: 300px">
						<select class="select1" name="school">
						   		 <option  th:each="sort:${area}"  th:value="${sort.name}" th:selected="${ sort.name eq vip.school }" th:text="${sort.name}" ></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="grade">
						   		 <option  th:each="sort:${grade}"  th:value="${sort.name}" th:selected="${ sort.name eq vip.grade }" th:text="${sort.name}" ></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="banben">
						   		 <option  value=""   >请选择</option>
						   		 <option  value="1" th:selected="${ vip.banben eq 1 }"  >北师大(深圳)</option>
						   		 <option  value="2" th:selected="${ vip.banben eq 2 }"  >人教版(广州)</option>
						</select>
					</div>
			   </li>
			   
			<li>
			    <input type="hidden" name="imgUrl" id="imgUrl" th:value="${vip.imgUrl}"/>
				<label class="upload-file">用户头像<b>*</b></label>
				<img id="imgUrlImg" th:src=" ${vip.imgUrl} !=null  ? (${vip.imgUrl} !='' ? ${imgUrl}+''+${vip.imgUrl}+'?x-oss-process=image/resize,m_lfit,h_100,w_100' : '' ) :'' "  style="width:200px;height:140px; margin-left: 109px;" />
				<input type="file" id="upfile">
			</li>
			<li class="clearfix">
				<label>生日:<b>*</b></label>
				 <input id="birthday"  name="birthday"  type="text" th:value="${#calendars.format(vip.birthday,'yyyy-MM-dd')}"  class="dfinput fl"
					        	onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'%y-%M-%d'})"/>
			</li>
			<li class="clearfix">
				<label>家庭地址:</label>
				<textarea rows="10" id="family" name="family" class="textinput"  cols="10">[[${vip.family}]]</textarea>
			</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 th:include="sys/common/fileUpload" th:remove="tag"></script> 
<script type="text/javascript">

$(function(){
	$("#submitFrom").validate({
		rules : {
			
			parentName : {
				required : true,
				maxlength: 300
			},
			childName : {
				required : true,
				maxlength: 300
			}
		},
		messages: {
			parentName : {
				required : "家长姓名不能为空",
				maxlength : "最多300个字符",
			},
			childName : {
				required : "孩子姓名不能为空",
				maxlength : "最多300个字符",
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/lib/libVipUpdateSave";
	var params = $("#submitFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
				if(data.meta.success){
					layer.msg("操作成功!",{icon:1});
					var isType='[[${isType}]]';
			    	setTimeout(function(){
			    		if(isType==1){
				    		window.location.href ='[[${sysUrl}]]/sys/lib/libVipList.html';
			    		}else{
			    			window.location.href ='[[${sysUrl}]]/sys/sales/libVipServiceList.html';
			    		}
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}
$(function(){
	initUpload(uploadOptions("upfile","上传头像"),"imgUrl","imgUrlImg");
});

//附件上传
function uploadFile(){
	$("#upfile").uploadify("upload", "*");
}

</script>
</html>