<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>
  body{min-width:180px;}
    	.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: 209px;
		    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;
    	}
    	.dfinput{
    	 width: 209px;
    	}
    </style>
</head>

<body>
<div class="formbody">
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="id" th:if="${staffing.id}" th:value="${staffing.id}"/>
		     <input type="hidden" name="type"  th:value="${staffing.type}"/>
		     <input type="hidden" name="userId"  th:value="${staffing.userId}"/>
		     <input type="hidden" name="libId"  th:value="${staffing.libId}"/>
		     <input type="hidden" name="orgCode"  th:value="${staffing.orgCode}"/>
		     <input type="hidden" name="stat"  th:value="${staffing.stat}"/>
		<ul class="forminfo">
				<li class="clearfix">
					<label>微信昵称:<b>*</b></label>
					<input type="text" class="dfinput fl" disabled="disabled"  th:value="${staffing.user.name}"/>
				</li>
				<li class="clearfix">
					<label>人员姓名:<b>*</b></label>
					<input type="text" id="name" class="dfinput fl" name="name"  th:value="${staffing.name}"/>
				</li>
				<li class="clearfix">
					<label>联系方式:<b>*</b></label>
					<input type="text" id="telephone" class="dfinput fl" name="telephone"  th:value="${staffing.telephone}"/>
				</li>
				 <li class="clearfix">
				    <label>性别：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 316px">
						<select class="select1" name="sex">
						          <option    value="">请选择</option>
						   		 <option  th:selected="${staffing.sex eq 1 }"  value="1">男</option>
						   		 <option  th:selected="${staffing.sex eq 2 }"  value="2">女</option>
						</select>
					</div>
			   </li>
				<li class="clearfix" th:if="${staffing.orgCode eq 'SSJ-ZB-XS'}">
					<label>登陆账号:<b>*</b></label>
					<div onclick="selectRole()">
						<input type="text" id="adminName"  disabled="disabled" class="dfinput fl"  th:value="${staffing.adminName}" />
						<input type="hidden" id="adminId" name="adminName" th:value="${staffing.adminName}" />
					</div>
				</li>
				<li>
					<label>&nbsp;</label>
					<button type="submit" class="btn">保存</button>
					<button type="button" class="btn" onclick="closeWins()">取消</button>
				</li>
		</ul>
	</form>
</div>
</body>
<script type="text/javascript">

$(function(){
	
	
	$("#submitFrom").validate({
		rules : {
			
			name : {
				required : true
			},
			telephone : {
				required : true
			},
			sex : {
				required : true
			}
		},
		messages: {
			name : {
				required : "不能为空"
			},
			telephone : {
				required : "不能为空"
			},
			sex : {
				required : "不能为空"
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/sales/staffingListSave";
	var params = $("#submitFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
				if(data.meta.success){
					layer.msg("操作成功!",{icon:1});
					setTimeout(function(){
						   closeWin();
						},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
					setTimeout(function(){
						   closeWin();
						},1000);
				}
		}
		
	});
}

function closeWin(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function closeWins(){
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}

function selectRole(){
	var url ='[[${sysUrl}]]/sys/bookList/adminlist.html';
	layer.open({
		type: 2,
		title: "选择登陆账号",
		closeBtn: 1, //不显示关闭按钮
		shift: 0.8,
		//offset: '100px',
		area: ['80%', '90%'],
		content: url
	});
}

</script>
</html>