<%@ 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 + "/";
	String processDefinitionId=request.getParameter("procDefId");
	String procInstId=request.getParameter("procInstId");
	String curActivityId=request.getParameter("curActivityId");
	String destActivityId=request.getParameter("destActivityId");
	String curActInstId=request.getParameter("curActInstId");
  String userId=request.getParameter("userId");
	String userOrgId=request.getParameter("userOrgId");
	
%>
<!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"/>  
 	<link rel="stylesheet" type="text/css" href="${ctx_js_plugins}/userSelect/css/usStyle/usStyle.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>
    <SCRIPT type="text/javascript">
    var loadImgPath = "${ctx_js_plugins}/userSelect/css/usStyle/img/load.gif";//加载图标路径
    var jQuery_1_4_4= $.noConflict(true);
		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",
						autoParam:["id", "name=n","level=lv"],
				    	otherParam:{"assignTreeId":'',"treeLevel":'',"showTreeType":''}
					},callback: {
			    	beforeClick: beforeClick
				}

		};
		
		
		
		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}"){
					jQuery_1_4_4("#treeNodeId").val(treeNode.id+"^"+treeNode.pId);
					jQuery_1_4_4("#treeNodeName").val(treeNode.name);
					jQuery_1_4_4("#treeNodeType").val(treeNode.type);
				//}
			}
			
			parent.addNextActivityUser();
			return true;
		}
		jQuery_1_4_4(document).ready(function(){
			jQuery_1_4_4("#loadDIV").hide();
			jQuery_1_4_4("#loadIMG").attr("src",loadImgPath);
			jQuery_1_4_4.fn.zTree.init(jQuery_1_4_4("#userOrgTree"), setting);
			//当人员树只有一个人员可供选择时，默认将人员移到已选列表
			try{
				var treeObj = jQuery_1_4_4.fn.zTree.getZTreeObj("userOrgTree");
				/**var userNodes=treeObj.getNodesByParamFuzzy("type", "USER", null);
				if(userNodes.length==1){
					$("#treeNodeId").val(userNodes[0].id+"^"+userNodes[0].pId);
					$("#treeNodeName").val(userNodes[0].name);
					$("#treeNodeType").val(userNodes[0].type);
					window.parent.addNextActivityUser();
				}**/
			}catch(e){}
		});
		
		//-->
		/**根据姓名或工号查询*/
		function query(){
			var queryVal = jQuery_1_4_4("#queryVal").val();
			
			if(queryVal==""){
				jQuery_1_4_4.fn.zTree.init(jQuery_1_4_4("#userOrgTree"), setting);
				return;
			}else{
				jQuery_1_4_4("#loadDIV").show();
				//alert(jQuery_1_4_4("#loadDIV").attr("style"))
				var data={"queryVal":queryVal,"showTreeType":"USER","id":"${param.orgId}"};					
				jQuery_1_4_4.ajax({
				  type: "POST",
				  url:"${ctx}/pages/user/getUserOrgTree.do",
				  data: data,
				  dataType: "json",
				  success: function(data){
					 jQuery_1_4_4.fn.zTree.init(jQuery_1_4_4("#userOrgTree"), setting,data);
					 jQuery_1_4_4("#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 id="loadDIV" align="center" style="width: 230px;height:420px;">
	<img src="" id="loadIMG" style="margin-top:130px;"/>&nbsp;</br>用户树加载中...
</div>
<ul id="userOrgTree" class="ztree"></ul>
<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>