<%@ 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"/>  
    <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 huiQianDeptIds="";
		try{
			var items = parent.parent.document.getElementsByName("huiQianDeptIds");
			//alert(items.length);
		    if (items.length > 0) {
		        for (var i = 0; i <items.length; i++) {
		            if (items[i].checked == true) {
		            	//alert(items[i].value);
		            	huiQianDeptIds+=items[i].value+"#";
		            }
		        }
		    }
		    
		}catch(e){}
		//alert(huiQianDeptIds);
		var zNodes;  
		var url="${ctx}/taskMgr/getNextActivityUserTree.do";
		$.ajaxSetup({ 
		    async : false 
		});
		$.post(url, {huiQianDeptIds:huiQianDeptIds,userId:"<%=userId%>",userOrgId:"<%=userOrgId%>",processDefinitionId:"<%=processDefinitionId%>",processInstId:"<%=procInstId%>",curActInstId:"<%=curActInstId%>",curActivityId:"<%=curActivityId%>",destActivityId:"<%=destActivityId%>"},
	
				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"
					}
				},callback: {
			    	beforeClick: beforeClick
				}

		};
		
		
		function filter(treeId, parentNode, childNodes) {
			//alert(childNodes);
			//默认加载第一个或者根节点
			//if(typeof(parentNode)=="undefined"||parentNode==null||parentNode==""){
			//	if (childNodes[0].isAccessTopMenu=="false") {
		//			parent.document.getElementById("rightFrame").src="../../pages/user/list.do?orgId="+childNodes[1].id+"&orgName="+encodeURIComponent(childNodes[1].name);
			//	}else{
			//		parent.document.getElementById("rightFrame").src="../../pages/user/list.do?orgId="+childNodes[0].id+"&orgName="+encodeURIComponent(childNodes[0].name);
			//	}
			//}
			//alert(childNodes.length);
				//var filterNodes=$("#filterNodes").attr("value").split(",");
				//alert($.inArray(childNodes[0].id,filterNodes));
			
			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+"^"+treeNode.pId);
					$("#treeNodeName").val(treeNode.name);
					$("#treeNodeType").val(treeNode.type);
				//}
			}
			
			parent.addNextActivityUser();
			return true;
		}
		$(document).ready(function(){
			$.fn.zTree.init($("#userOrgTree"), setting,zNodes);
			//当人员树只有一个人员可供选择时，默认将人员移到已选列表
			try{
				var treeObj = $.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){}
		});
		
		//-->
	</SCRIPT>

</HEAD>

<BODY  bgcolor="#FFFFFF">
<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>