<%@ page language="java" pageEncoding="UTF-8"%>
<%@ 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>
<link href="${ctx}/resource/js/plugins/loadmask/jquery.loadmask.css"
	rel="stylesheet" type="text/css" />
<script type='text/javascript'
	src='${ctx}/resource/js/plugins/loadmask/jquery.loadmask.js'></script>
<script>
	$(document).ready(function() {
		var key = $("#key").val();
	});

	function changeHref(id, srcStr) {
		var currentId = $(".active").find("a").attr("id");
		var isChange = $("#isChange").val();
		var isRedirect = true;//是否跳转页面
		if("UserContract"==currentId){//当前是基础配置，点击别的菜单会出现提示是否保存的按钮
			if("1"==isChange){//内容有更改
				//提示是否保存前面的操作
				if(confirm("是否保存当前数据？")){
					document.getElementById(id).contentWindow.save();
					isRedirect = false;//当选择确认保存后  留在当前页面
					$("#"+currentId).parent().addClass("active");
				}else{
					$("#isChange").val("0");//保存完毕后把是否已修改还原成未修改
				}
			}
		}
		//if(isRedirect){
			//返回时跳转步数+1
			var backSteps = $("#backSteps").val();
			$("#backSteps").val(parseInt(backSteps)+1);
			
			document.getElementById(id).src = srcStr;
		//}
		//$("#myTab3").find('li').removeClass("active");
	}
	function iframeHeight(down){
		var height = "";
		var imgHeight = $("#imgHeight").val();
		if(imgHeight==""){
			height = $("#"+down).contents().find("body").height();
			if(height==0){
				height=800;
			}
		}else{
			height = imgHeight;
		}
		if(height==0){
			height=$("#"+down).height();
		}
		$("#"+down).height(height+20);
	}
	
	function gobacktolist(){
		var isRedirect = true;//是否跳转页面
		var isChange = $("#isChange").val();
		if("1"==isChange){//内容有更改
			//提示是否保存前面的操作
			if(confirm("是否保存当前数据？")){
				document.getElementById(id).contentWindow.save();
				isRedirect = false;//当选择确认保存后  留在当前页面
			}else{
				$("#isChange").val("0");//保存完毕后把是否已修改还原成未修改
			}
		}
		document.getElementById(id).src = srcStr;
	}
	
	function goback(){
		var backSteps = $("#backSteps").val();
		history.go(-parseInt(backSteps));
	}
	
	function publishProcess(url){	
		postAjax(url,'发布成功!',false,true);
	}
</script>
</head>
<body>
	<input type="hidden" id="imgHeight" value="" />
	<input type="hidden" id="backSteps" value="1" />
	<input type="hidden" id="formName" value="${formName }" />
	<input type="hidden" id="formId" value="${formId }" />
	<input type="hidden" id="key" value="${key }" />
	<input type="hidden" id="modelId" value="${modelId }" />
	<input type="hidden" id="procDefIdFlag" value="${processDefinition.procDefId }" />
	<input type="hidden" id="modelPath" value="${modelPath }" />
	<input type="hidden" id="appId" value="${appId }" />
	<input type="hidden" id="mAppId" value="${mAppId }" />
	<div class="main-container" id="main-container">
		<div class="panel-heading"
			style="color: #FFF; background-color: #428BCA; border-color: #428BCA;">
			<span style="font-size: 14px;">流程名称：${formName}</span>
		</div>
		<div class="row" style="margin-right: 0;">
			<div class="col-xs-12">

				<div class="tabbable">
					<input type="hidden" id="isChange" value="0" />

					<ul class="nav nav-tabs padding-12 tab-color-blue background-blue"
						id="myTab3">
						<li class="active"><a id="createModel" data-toggle="tab"
							onclick="changeHref('frmrightChild','${modelPath}');"
							href="" target="frmrightChild" class="current">流程建模</a></li>
						<c:if test="${processDefinition!=null}">
							<li><a id="UserContract" data-toggle="tab"
								onclick="changeHref('frmrightChild','${ctx}/processInfo/edit.do?userId=&procDefId=${processDefinition.procDefId }&sys=${appId}');"
								href="" target="frmrightChild">基础配置</a></li>
							<li><a id="UserEvent" href="" data-toggle="tab"
								onclick="changeHref('frmrightChild','${ctx}/activityInfo/actSet.do?processDefId=${processDefinition.procDefId }&formId=${formId}&procDefKey=${key}&modelId=${modelId}&appId=${appId }&formCode=${key}&mAppId=${mAppId}');"
								target="frmrightChild">环节配置</a></li>
							<li><a id="UserEducation" href="" data-toggle="tab"
								onclick="changeHref('frmrightChild','${ctx}/dataObjectRelation/processList.do?processDefId=${processDefinition.procDefId }')"
								target="frmrightChild">扩展属性配置</a></li>
							<li><a id="UserPersonn" href="" data-toggle="tab"
								onclick="changeHref('frmrightChild','${ctx}/actInfo/setActResource/setAllResourcelist.do?processDefId=${processDefinition.procDefId}')"
								target="frmrightChild">环节人员配置</a></li>
							<!-- 
							<li><a id="NoticeRemind" href="" data-toggle="tab"
								onclick="changeHref('frmrightChild','${ctx}/noticeRemindConfig/edit.do?procDefId=${processDefinition.procDefId}')"
								target="frmrightChild">通知提醒规则配置</a></li>
							 -->
							<li><a id="UserPersonn" href="" data-toggle="tab"
								style="background-color: #87B97F;"
								onclick="publishProcess('${ctx}/procDefModelMgr/releaseProcess.do?procDefId=${processDefinition.procDefId}');"
								target="frmrightChild"> <i
									class="ace-icon fa fa-check-square-o bigger-110"></i>发布流程
							</a></li>
						</c:if>
					</ul>


					<div class="tab-content" style="width: 100%; height: 100%;">
						<IFRAME style="width: 100%; height: 800px;" scrolling="no" src="${modelPath}"
							frameBorder="0" id="frmrightChild" name="frmrightChild"
							onload="iframeHeight('frmrightChild')" allowTransparency="true"></IFRAME>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>