<%@page import="com.blueland.bpm.engine.config.model.*"%>
<%@page import="com.blueland.bpm.common.page.*"%>
<%@page import="com.blueland.bpm.common.util.*"%>
<%@page import="com.blueland.bpm.manage.util.*"%>
<%@page import="java.util.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<%@ include file="/commons/taglibs.jsp"%>
<%
	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>
<%@ include file="/commons/meta.jsp"%>
<base href="<%=basePath%>">
<title>环节配置</title>

	<style>
			/* some elements used in demo only */
			.spinner-preview {
				width: 100px;
				height: 100px;
				text-align: center;
				margin-top: 60px;
			}
			
			.dropdown-preview {
				margin: 0 5px;
				display: inline-block;
			}
			.dropdown-preview  > .dropdown-menu {
				display: block;
				position: static;
				margin-bottom: 5px;
			}
		</style>

	<link href="${ctx }/resource/js/plugins/jquery.qtip.css" rel="stylesheet" type="text/css" media="screen" />
	<script src="${ctx }/resource/js/plugins/easyTemplate.js" type="text/javascript"></script>
	<script src="${ctx }/resource/js/plugins/jquery.qtip.js" type="text/javascript"></script>

	<script type="text/javascript">
    		var defId ="";
    		var actDefId ="";
    		var deployId= "";
            var menu;
            //判断参数是否加载
            var isOtherParamFrm=false;
            var currentObj=null;
            $(function (){
            	
            	//setContainerHeightWidth();
            	
                 $("div.flowNode").each(function(){                	
                	$(this).bind({mouseenter:function(){
                		currentObj=$(this);
                	}});
                	currentObj=$(this);     
                	var nodeId =currentObj.attr('id');
                	var type=currentObj.attr("type"),title=currentObj.attr("title");
                	//alert(type);
                	var id=currentObj.attr("id"),oldtitle=currentObj.attr("oldtitle");
                	if(oldtitle=="null"){
                		oldtitle="(暂未设置名称)";
                	}else{
                		oldtitle=oldtitle.replace(/\"/g,"”");
                	}    			        
		                var html=["<div class='dropdown dropdown-preview'><ul class='dropdown-menu dropdown-info dropdown-menu-right'>"];
		                if(type=="serviceTask"){
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/otherTask/editServiceTaskView.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'服务任务设置','980px','600px');\">服务任务设置</a></li>");
		            	}else if(type=="scriptTask"){
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/otherTask/editScriptTaskView.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'脚本任务设置','980px','600px');\">脚本任务设置</a></li>");
		            	}else if(type=='receiveTask'){//接收任务
		            		html.push("<li><a  id='actDefInfo' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/activityInfo/edit.do?activityDefId="+id+"&processDefId=${query.processDefId }");
		                	html.push("' ,'环节属性设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节属性设置</a></li>");
		                	
		                	html.push("<li><a  id='actSequenceFlow' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/sequenceFlow/list.do?actId="+id+"&procDefId=${query.processDefId}");
		                	html.push("' ,'环节输出线设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节输出线设置</a></li>");
		                	
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/activityInfo/actOperatePowerList.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'环节操作权限设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节操作权限设置</a></li>");
		                	
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/dataObjectRelation/activityList.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'环节扩展属性设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节扩展属性设置</a></li>");
		                		         
		            	}else if(type=='manualTask'){//线下任务
		            		html.push("<li><a  id='actDefInfo' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/activityInfo/edit.do?activityDefId="+id+"&processDefId=${query.processDefId }");
		                	html.push("' ,'环节属性设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节属性设置</a></li>");
		                	
		            	}else if(type=="callActivity"){
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/otherTask/editCallActivityView.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'子流程设置','980px','600px');\">子流程设置</a></li>");
		                	var callActivityProcKey=currentObj.attr("callActivity");
		                	if(callActivityProcKey!=""){
		                		html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
			                	html.push(" onclick=\"showDiaLog('");
			                	html.push("${ctx}/procDefMgr/callactivityconfig.do?callActivityProcKey="+callActivityProcKey+"&isSubProcess=1&sys=${appId}&mAppId=${mAppId}");
			                	html.push("' ,'关联子流程设置','980px','600px');\">关联子流程设置</a></li>");
		                	}
		                	html.push("<li><a  id='actSequenceFlow' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/sequenceFlow/list.do?actId="+id+"&procDefId=${query.processDefId}");
		                	html.push("' ,'环节输出线设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节输出线设置</a></li>");
		                	
		            	}else if(type=="exclusiveGateway"){
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/gateway/editGatewayByCd.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'条件网关','980px','600px');\">条件网关设置</a></li>");
		            	}else if(type=="inclusiveGateway"){
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/gateway/editGatewayByIc.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'包容网关','980px','600px');\">包容网关设置</a></li>");
		            	}else if(type=="parallelGateway"){
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/gateway/editGatewayByIc.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'并行网关','980px','600px');\">并行网关设置</a></li>");
		            	}else{
		            	
		                	html.push("<li><a  id='actDefInfo' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/activityInfo/edit.do?activityDefId="+id+"&processDefId=${query.processDefId }&sys=${appId}&mAppId=${mAppId}");
		                	html.push("' ,'环节属性设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节属性设置</a></li>");
		                	
		                	html.push("<li><a  id='actDefUser' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/setActResource/list.do?actId="+id+"&procDefId=${query.processDefId}");
		                	html.push("' ,'环节人员设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节人员设置</a></li>");
		                	
		                	html.push("<li><a  id='actSequenceFlow' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/actInfo/sequenceFlow/list.do?actId="+id+"&procDefId=${query.processDefId}");
		                	html.push("' ,'环节输出线设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节输出线设置</a></li>");
		                	
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/activityInfo/actOperatePowerList.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'环节操作权限设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节操作权限设置</a></li>");
		                	
		                	html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("${ctx}/dataObjectRelation/activityList.do?activityDefId="+id+"&processDefId=${query.processDefId}");
		                	html.push("' ,'环节扩展属性设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节扩展属性设置</a></li>");
		                	
		                <%-- 	html.push("<li><a  id='actDefRoelOperate' href='javascript:void(0)'");
		                	html.push(" onclick=\"showDiaLog('");
		                	html.push("<%=MyContants.KSKF_PAHT%>"+"/dev-plateform-web/#/roleFormField?formId=${formId}&procDefKey=${procDefKey}&appId=${appId}&actDefId="+id+"&formCode=${formCode}&modelId=${modelId}&processDefId=${query.processDefId}");
		                	html.push("' ,'环节表单设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节表单设置</a></li>"); --%>			               
		                	if(currentObj.attr("isMulti") == 'true'){
		                		html.push("<li><a  id='actDefOperate' href='javascript:void(0)'");
		                		html.push(" onclick=\"showDiaLog('");
		                		html.push("${ctx}/actInfo/activityFinishRule/create.do?sourceActId="+id+"&procDefId=${query.processDefId}&sourceActName=" + oldtitle);
		                		html.push("' ,'环节完成条件设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前环节->"+oldtitle+"','980px','600px');\">环节完成条件设置</a></li>");
		                	}
		            	}
                		html.push('</ul></div>');
                	//alert(html.join(''));          
   			      $(this).qtip({  
   			        content:{   			    
   			        	text : function() { 			        
							if(type=="description"){
								return  getTaskDefinitionDescriptionHtml(nodeId);
							}else{
								return html.join('');
							}
						},
   			        	title:{
   			        		text:type=="description"?"环节输出线说明":oldtitle
   			        		}
   			        	},  
   			        position: {
   			        	at:'center',
   			        	target:'event',
   			        	adjust: {
   			        		x:-15,
   			        		y:-15
   		   				},  
   		   				viewport: $(window)
   			        },
   			        show:{   			        	
	   			     	effect: function(offset) {
	   						$(this).slideDown(200);
	   					}
   			        },   			     	
   			        hide: {
   			        	event:'click mouseleave',
   			        	leave: false,
   			        	fixed:true,
   			        	delay:300
   			        	},  
   			        style: {
   			          width : type=="description"?270:180,
   			       	  classes:'ui-tooltip-light ui-tooltip-shadow'
   			        } 			    
   			      });
   			    }); 
              
                 //调整父页面高度
                 var height = "${imageHeight}";
                 if(height>800){
                 	$("#imgHeight",window.parent.document).val(parseInt(height)+80);
                 	$("#imgdiv").height(parseInt(height)+78);
                 }else{
                	$("#imgdiv").height(800);
                 }      
            });
          //显示输出线描述
    		function getTaskDefinitionDescriptionHtml(nodeId){
    			var html = new Array();
    			var procDefId="${query.processDefId }";
    			var url="${ctx}/actInfo/sequenceFlow/viewDescription.do";
    			 $.ajax({
    	                url : url,
    	                data:{"procDefId":procDefId,"sequenceFlowId":nodeId},
    	                cache : false, 
    	                async : false,
    	                type : "POST",
    	                success : function (data){
    	                	 var sequenceFlow = eval(data.sequenceFlow);
    	                	 html.push('<div class="panel-body"><div  id="txtTaskDefHmtl1" style="max-height:310px;width=110px;overflow:auto;">');
    	                	 html.push('<textarea rows="10" cols="30">');
    	                	 html.push(sequenceFlow.name);
    	                	 html.push('</textarea>');
    	                	 html.push('</div>');
    	                }
    	            });
    			return  html.join('');
    		};
     </script> 
	<style type="text/css"> 
	     
	    div.flowNode{cursor:pointer;}
	</style>
</head>
<body>
	<%@ include file="/commons/messages.jsp"%>
	<form id="queryForm" name="queryForm"
		action="${ctx}/activityInfo/list.do" method="get"
		style="display: inline;">
		<input name="processDefId" id="processDefId"
			value="${query.processDefId }" type="hidden" />
			<!-- <div class="panel panel-primary" style="width:${imageWidth+20}px; height:${imageHeight+30}px;"> -->
			<div class="panel panel-primary" id="imgdiv" style="width:100%; min-height:800px; overflow: auto;">
				<div class="panel-body" style="padding: 3px;">
							<div style="padding-left: 30px; display: inline; float: left; margin:20px auto 0;position: relative;background:url('${ctx}/procDefMgr/resource.do?resourceType=image&procDefId=${query.processDefId }')  no-repeat;width:${imageWidth+30}px; height:${imageHeight+30}px;">
								${processDefinitionDiv}
								</div>
				</div>
				
			</div>    
			
		</div>
	</form>
</body>
</html>
