<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ 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" %>
	<script type="text/javascript" src="${ctx }/script/jquery-1.8.3.min.js"></script>
	<base href="<%=basePath%>"/>
	<title>流程详细页面</title>
	<script type="text/javascript" >
		$(document).ready(function() {
			baseOnload();
		});
		function baseOnload(){
			var data;
			try{
				data=$("#wf_fields").attr("value");
				var fieldsXml = $.parseXML(data);
				$(fieldsXml).find("fields >*").each(function(i){
					try{
						var fieldValue=$(this).text();
						if (fieldValue == null || typeof (fieldValue) == "undefined" || fieldValue == 'null') {
							fieldValue = "";
						}
						var inputObj=$("#"+this.nodeName);
						//取得控件类型
						var type = inputObj.attr("type");
						/* if(this.nodeName=="huiQianDeptIds"){
                            alert(fieldValue);
                        } */
						//特殊处理 radio
						if(type=="radio"){
							$("input[name="+this.nodeName+"][value=" + fieldValue + "]").attr(
									"checked", true);
						} else if(type=="checkbox"){
							if(fieldValue.indexOf(",")!=-1){
								var fieldValues=fieldValue.split(",");
								for(var i=0;i<fieldValues.length;i++){
									$("input[name="+this.nodeName+"][value=" + fieldValues[i] + "]").attr(
											"checked", true);
								}
							}else{
								$("input[name="+this.nodeName+"][value=" + fieldValue + "]").attr(
										"checked", true);
							}
						} else {
							inputObj.val(fieldValue);
						}
					}catch(e){alert("系统加载控件名为["+this.nodeName+"],值为["+$(this).text()+"]的数据失败,请您联系管理员排查问题！");}
				});
			}catch(e){alert("系统解析wf_fields数据失败,请您联系管理员排查问题！wf_fields["+data+"]");}
			try{
				selfOnload();
			}catch(e){
			}
		}

		function baseValidate(){
			var validateFlag=true;
			if($("#wf_procTitle").val()==""){
				alert("流程标题[wf_procTitle]不能为空!");
				return false;
			}else if($("#wf_procDefId").val()==""){
				alert("流程定义ID[wf_procDefId]不能为空!");
				return false;
			}else if($("#wf_curActDefId").val()==""){
				alert("流程当前环节ID[wf_curActDefId]不能为空!");
				return false;
			}else if($("#wf_sender").val()==""){
				alert("流程发送人[wf_sender]不能为空!");
				return false;
			}
			return validateFlag;
		}
		function baseListReload(){
			art.dialog.opener.location.reload();
			art.dialog.close();
		}
		function traceProcess(){
			var procInstId=$("#wf_procInstId").val();
			showDiaLog('${ctx}/workflow/trace/processTraceText.do?processInstanceId='+procInstId,'流程监控','1000px','100%');
		}



		function baseOnSubmit(title){
			var selfOnSubmitFlag=false;
			try{
				selfOnSubmitFlag=selfOnSubmit();
				if(!selfOnSubmitFlag)
					return selfOnSubmitFlag;
			}catch(e){
			}

			try{
				selfOnSubmitFlag=baseValidate();
				if(!selfOnSubmitFlag)
					return selfOnSubmitFlag;
			}catch(e){

			}
			try{
				//if($("#wf_nextActDefId").val()=="end"){
				//showDiaLog('${ctx}/pages/flowfile/selectArchives.jsp','选择归档类型','500px','50%');
				//return false;
				//}

			}catch(e){}

			if (typeof(title) == "undefined") {
				var nextActDefName=$('#wf_nextActDefName').val();
				if(nextActDefName==""){
					title="您确认送下一办理吗?";
				}else{
					title="您确认送["+nextActDefName+"]办理吗?";
				}
			}
			if(confirm(title)){
				jQuery.ajax({
					url: '${ctx}/taskMgr/jumpAnyTask.do',
					data: $('#nextExecuteForm',document).serialize(),
					type: "POST",
					beforeSend: function()
					{
					},
					success: function(resp)
					{
						if(resp.executeStatus=='SUCCESS'){
							alert("操作成功!");
							baseListReload();
						}else{
							alert("操作失败！");
						}

					}
				});
			}

		}

	</script>
</head>
<body class="white-page">
<div class="main-container" id="main-container">
	<div class="panel panel-primary" style="box-shadow: none !important;">
		<div class="panel-body">

			<form id="nextExecuteForm">
				<jsp:include page="/pages/taskMgr/params.jsp" flush="true"/>
				<%--		<jsp:include page="/pages/taskMgr/topButton.jsp" flush="true"/>--%>

				<iframe style="width: 100%; height:360px;" scrolling="no"
						src="${ctx}/pages/taskMgr/nextActivityUserMain.jsp"
						frameBorder="0" id="nextActivityTreeFrame" name="nextActivityTreeFrame" allowTransparency="true"></iframe>

			</form>
		</div></div></div>
</body>
</html>	
