<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>员工管理</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
	name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="<c:url value='/styles/lib/bootstrap.min.css'/>" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="<c:url value='/styles/lib/font-awesome.min.css'/>" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href='<c:url value='/styles/lib/ionicons.min.css' />' rel="stylesheet" type="text/css" />
<!-- DATA TABLES -->
<link href="<c:url value='/styles/lib/datatables/dataTables.bootstrap.css' />" rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="<c:url value='/styles/AdminLTE.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/scripts/zTree/css/zTreeStyle/zTreeStyle.css'/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value='/scripts/lib/jquery-1.8.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/zTree/js/jquery.ztree.core-3.5.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/zTree/js/jquery.ztree.excheck-3.5.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/loading/jquery.blockUI.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/loading/loading.js'/>"></script>
<script type="text/javascript" src="${ctx }/scripts/swfupload-jquery-plugin-master/src/jquery.swfupload.js"></script>
<script type="text/javascript" src="${ctx }/scripts/swfupload-jquery-plugin-master/vendor/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<c:url value='/scripts/admin/staffForm.js'/>"></script>
<script type="text/javascript">
	$(document).ready(function(){
		var uploadSetting={
			upload_url: "<c:url value='/uploadTemplate/upload' />",
			file_size_limit : "10240",
			file_types : "*.jpg;*.png",
			file_post_name: "Filedata",  
			file_types_description : "图片文件",
			file_upload_limit : "0",
			button_text:'上传头像',
			flash_url : "${ctx}/scripts/swfupload-jquery-plugin-master/vendor/swfupload/swfupload.swf",
			button_image_url : '${ctx}/scripts/swfupload-jquery-plugin-master/vendor/swfupload/XPButtonUploadText2_61x22.png',
			button_width : 61,
			button_height : 22,
			button_placeholder_id : "metadataAddBtnId",
			debug: false
		};
		$("#images").swfupload(uploadSetting).bind('uploadSuccess', function(event, file, serverData){
			$(this).find("input").remove();
			$(this).find("img").remove();
			$("#images").append('<img src="'+($.parseJSON(serverData).preview)+'" style="height: 200px;">');
			$("#staffPhoto").val($.parseJSON(serverData).url);
		})
		.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
			$(this).swfupload('startUpload');
		})
		.bind('uploadError', function(event, file, errorCode, message){
			alert('上传失败，'+message);
		});
	});
	
	function deleteImage(){
		$("#images").html("");
		$("#staffPhoto").val("");
	}
</script>

</head>
<style>.row{height:auto;overflow: hidden;}.box .box-header{padding-bottom: 0px;}</style>
<body>
	<input type="hidden" value="${ctx}" id="contextPath">
	<section class="content">
		<div class="row">
			<div class="col-md-6" style="float:left;width:50%;">
				<div class="box box-info" >
					<div class="box-header" style="width:90%">
						<h3 class="box-title">编辑员工基本信息 &nbsp;&nbsp; <strong font-color="red">${errormsg}</strong></h3>
					</div>
					<div class="box-body">
						<form:form action="${ctx}/admin/staff/form" style="padding:0;margin:0;" modelAttribute="staff" 
							method="post" id="conditionform" >
							<input type="hidden" name="actType" value="save">
							<input type="hidden" name="funcid" value="${funcid}">
							<form:hidden path="id"  id="staffId"/>
							<input type="hidden" name="buildIds" id="buildIds">
							
							<form:hidden path="headUrl" style="padding:0;margin:0;" cssClass="form-control" id="staffPhoto" />
							<div class="form-group">
								<label>
									<input type="file" name="metaFiles" id="metadataAddBtnId" /> 
									<input type="button" value="删除" onclick="deleteImage()" class="btn btn-default" "/>
								</label>
								<div id="images" style="margin-top: 10px">
									<c:if test="${staff.headUrl!=null && staff.headUrl!=''}">
										<img src="${imageServer }${staff.headUrl}" style="height: 200px;">
									</c:if>
								</div>
							</div>
							<div class="form-group">
								<label><span style="color: red">*</span>工号</label>
								<form:input path="staffNo" style="padding:0;margin:0;" cssClass="form-control" id="staffNo" />
							</div>
							<div class="form-group">
								<label><span style="color: red">*</span>姓名</label>
								<form:input path="name" style="padding:0;margin:0;" cssClass="form-control" id="staffName" />
							</div>
							<div class="form-group">
								<label><span style="color: red">*</span>手机</label> 
								<form:input path="userMobile" style="padding:0;margin:0;" cssClass="form-control" id="userMobile" />
							</div>
							<div class="form-group">
								<label>性别</label> 
								<form:select path="sex" items="${userSexGroup}" itemLabel="itemname" itemValue="itemcode" 
									cssClass="form-control">
								</form:select>
							</div>
							<div class="form-group">
								<label>身份证</label> 
								<form:input path="idCard" style="padding:0;margin:0;" cssClass="form-control" />
							</div>
							<div class="form-group">
								<label><span style="color: red">*</span>运营中心</label> 
								<form:select path="companyId" items="${companyList}" itemLabel="name" itemValue="id"
									cssClass="form-control" id="companyId" onchange="initDept();" >
								</form:select>
							</div>
							<div class="form-group">
								<label><span style="color: red">*</span>所属部门</label> 
								<form:hidden path="deptId"  id="deptId" />
								<select id="deptId_" class="form-control">
                                	<option value="">请选择部门</option>
                                </select>
							</div>
							<div class="form-group">
								<label>职位</label> 
								<form:select path="position" items="${staffPostGroup}" itemLabel="itemname" itemValue="itemcode"
									cssClass="form-control" >
								</form:select>
							</div>
							<div class="form-group">
								<label>在职状态</label> 
								<form:select path="status" items="${staffStatusGroup}" itemLabel="itemname" itemValue="itemcode"
									cssClass="form-control" >
								</form:select>
							</div>
						</form:form>
					</div>
					<div align="absmiddle" style="margin-left:10px;margin-top:10px;">
						<a class="btn btn-primary" href="#" id='btn-save'>保存</a> 
						<a class="btn btn-default" href="<c:url value='/admin/staff/list?funcid=${funcid}' />">返回</a>
					</div>
				</div>
			</div>
			
			<div class="col-md-6"  style="float:left;width:45%;">
				<div class="box box-info">
					<div class="box-header">
						<h3 class="box-title"><span style="color: red">*</span>选择管辖的范围</h3>
					</div>
					<div class="box-body" style="height:680px;overflow:auto;">
						<ul id="organizationTree" class="ztree">
						</ul>
					</div>
				</div>
			</div>
		</div>
	</section>
</body>
</html>
