<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@page import="com.blueland.bpm.engine.util.WorkFlowContants"%>
			
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Cache-Control" content="no-store"/>
	<meta http-equiv="Pragma" content="no-cache"/>
	<meta http-equiv="Expires" content="0"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 	<link rel="stylesheet" href="${ctx}/resource/js/plugins/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>  
    <script type="text/javascript" src="${ctx}/resource/js/plugins/zTree/js/jquery-1.4.4.min.js"></script>  
    <script type="text/javascript" src="${ctx}/resource/js/plugins/zTree/js/jquery.ztree.core-3.4.js"></script>  
    <script type="text/javascript" src="${ctx}/resource/js/plugins/zTree/js/jquery.ztree.excheck-3.4.js"></script>
	<script type="text/javascript" src="${ctx}/resource/js/plugins/zTree/js/jquery.ztree.exedit-3.4.js"></script>
	<link rel="stylesheet" type="text/css" href="${ctx_js_plugins}/userSelect/css/usStyle/usStyle.css" /> 
    <SCRIPT type="text/javascript">
		<!--
		
		var zNodes;  
		var url="${ctx}/pages/user/getUserOrgTree.do?showTreeType=USER";
		var loadImgPath = "${ctx_js_plugins}/userSelect/css/usStyle/img/load.gif";//加载图标路径
		$.ajaxSetup({ 
		    async : false 
		});
		$.post(url,

				function (data, textStatus){
				    //var jsonObject = eval(data);
				    //alert(jsonObject);
				    zNodes=eval(data);
			});
		
		var setting = {
			view: {
				dblClickExpand : false,
				selectedMulti: false
			},
				edit: {
					enable: false,
					drag:{isMove:false}

				},
				data: {
					simpleData: {
						enable: true,  
			            idKey : "id",  
			            pIdKey : "pId" ,
			            DIY:"isAccessTopMenu"
					}
				},async: {
					enable: true,
					url:'${ctx}/pages/user/getUserOrgTree.do?showTreeType=USER',
					autoParam:["id", "name=n","level=lv"],
					otherParam:{"filterNodeIdsStr":"${filterNodeIdsStr }","showTreeType":"${param.showTreeType}","otherParam":"userTreeAsync"},
					dataFilter: filter
				},callback: {
			    	onAsyncSuccess: zTreeOnAsyncSuccess,
			    	beforeClick: beforeClick
				}
		};
		
		/**用于捕获异步加载正常结束的事件回调函数*/
		function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
			//hideSelectedUserTreeNode();
		}
		

		
		function filter(treeId, parentNode, childNodes) {
			return childNodes;
		}
		function beforeClick(treeId, treeNode) {
			//alert(treeNode.isAccess);
			//判断是否有权限访问根节点
			if (treeNode.pId==""||treeNode.isAccessTopMenu=="false") {
				return false;
			} else {
				//if(treeNode.type=="${selectNodeType}"){
					$("#treeNodeId").val(treeNode.id);
					$("#treeNodeName").val(treeNode.name);
					$("#treeNodeType").val(treeNode.type);
				//}
			}
			parent.addNextActivityUser();
			return true;
		}
		$(document).ready(function(){
			$("#loadDIV").hide();
			$("#loadIMG").attr("src",loadImgPath);
			$.fn.zTree.init($("#userOrgTree"), setting,zNodes);			
		});
		
		/**根据姓名或工号查询*/
		function query(){
			var queryVal = $("#queryVal").val();
			if(queryVal==""){
				$.fn.zTree.init($("#userOrgTree"), setting);
				return;
			}else{
				$("#loadDIV").show();
 				//alert($("#loadDIV").attr("style"))
				var data={"queryVal":queryVal,"showTreeType":"USER","id":"${param.orgId}"};					
				$.ajax({
				  type: "POST",
				  url:"${ctx}/pages/user/getUserOrgTree.do",
				  data: data,
				  dataType: "json",
				  success: function(data){
					 $.fn.zTree.init($("#userOrgTree"), setting,data);
					 $("#loadDIV").css("display","none");
					}
				});
			}
			}
		//-->
	</SCRIPT>

</HEAD>

<BODY  bgcolor="#FFFFFF">
<div>
	 &nbsp;&nbsp;姓名:<input type="text" value="" id="queryVal" style="width:100px;padding:0px 5px;;font-size:12px;height: 15px;" onkeydown="if(event.keyCode==13) query();"/>
		<input type="button" style="padding:0px 5px;" class="queryButtonStyle" title="根据用户名或工号查询" onclick="query();"/>
</div>
<div>
<div id="loadDIV" align="center" style="width: 230px;height:420px;">
						<img src="" id="loadIMG" style="margin-top:130px;"/>&nbsp;</br>用户树加载中...
					 </div>
<div><ul id="userOrgTree" class="ztree"></ul></div>
</div>
<form  id="queryForm" name="queryForm" action="" method="post">
	<input name="treeNodeId" id="treeNodeId"  type="hidden"/>
	<input name="treeNodeName" id="treeNodeName"  type="hidden"/>
	<input name="treeNodeType" id="treeNodeType"  type="hidden"/>
	<input name="filterNodeIdsStr" id="filterNodeIdsStr"  type="hidden" value="${filterNodeIdsStr }"/>
	<input name="isShowCheckBox" id="isShowCheckBox"  type="hidden" value="${isShowCheckBox }"/>
	<input name="showTreeType" id="showTreeType"  type="hidden" value="${showTreeType }"/>
	<input name="selectNodeType" id="selectNodeType"  type="hidden" value="${selectNodeType }"/>
</form>
</BODY>
</html>