apzl_leasing/WebContent/Common/WorkFlow/FlowSubmitDialog2.jsp
2018-06-03 22:26:41 +08:00

319 lines
12 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@page import="com.amarsoft.are.jbo.ql.Parser"%>
<%@page import="com.amarsoft.biz.workflow.*"%>
<%@page import="com.amarsoft.are.lang.StringX"%>
<%@page contentType="text/html; charset=GBK"%>
<%@include file="/Frame/resources/include/include_begin.jspf"%>
<%
String taskNo = CurPage.getParameter("TaskNo");
if(StringX.isSpace(taskNo)) taskNo = "";
String userID = CurUser.getUserID();
JBOTransaction tx = JBOFactory.createJBOTransaction();
FlowTask ft = new FlowTask(taskNo, tx);//使用jboTrans
String flowNo = ft.FlowNo;
String[] phaseOpinion = ft.getChoiceList();
int iNum = phaseOpinion.length;
tx.commit();
%>
<style>
.opinion-style{
width:100%;
overflow:hidden;
display:inline-block;
margin-bottom:2px;
outline:none;
}
.opinion-style2{
overflow:hidden;
display:inline-block;
margin-bottom:2px;
outline:none;
}
a.opinion-style:hover{
background-color:A8CAE5;
outline:none;
}
.opinion-focus{
background-color:A8CAE5;
}
</style>
<div>
<table>
<tr>
<td width="50%" align="right"><%=new Button("提交","确认提交","javascript:commitAction();","","btn_icon_Submit","").getHtmlText()%></td>
<td width="50%" align="center"><%=new Button("放弃","放弃提交","javascript:doCancel();","","btn_icon_delete","").getHtmlText()%></td>
</tr>
</table>
</div>
<div id="opinionset">
<div style="margin-top:10px;margin-left:15px;font-size:12px;">
<font color="#000000"><b>请选择下一阶段提交动作:</b></font>
</div>
<div style="margin-top:10px;margin-left:10px;font-size:12px;border:1px solid lightgray;padding:10px;">
<%
for(int i=0;i<iNum;i++){
out.println("<a class='opinion-style2' href='javascript:void(0)' onclick='doActionList(this)'>"+
"<input type='radio' name='phaseopinion' value='" + phaseOpinion[i] + "' >" + phaseOpinion[i]+ "</input></a>");
}
%>
</div>
</div>
<div id="actionset"></div>
<div>
<table width="100%" align="center">
<tr>
<td align="center"><b><span id="phaseinfo" style="color: #FF0000" ></span></b></td>
</tr>
</table>
</div>
<script type="text/javascript">
var taskNo = "<%=taskNo%>";
var actionSet = $("#actionset");
var phaseInfoSet = $("#phaseinfo");
var bActionReqiured = true; //是否需要选择动作如果为退回一类的就不需要选择下一步Action了)
var isPool = false;
var nextPhases;//提交到的阶段(1到N个阶段)
//提交动作选择
function doActionList(obj){
//var phaseOpinion = $(obj).val();//$("#PhaseOpinion").find("option:selected").val()
$(obj).siblings().removeClass("opinion-focus");
$(obj).addClass("opinion-focus");
var phaseOpinion = $(obj).find("input").val();
$(obj).find("input").prop("checked","true");
if(!phaseOpinion){
alert("请选择提交动作!");
actionSet.empty().hide();
phaseInfoSet.text("");
return;
}else{
getNextActionList(phaseOpinion);
}
}
function getNextActionList(phaseOpinion){
//获取下阶段的阶段属性(可能多个阶段)
var nextPhaseAttrs = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getNextPhaseAttr","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion);
nextPhases = nextPhaseAttrs.split("@");
//非并行阶段
if(nextPhases.length==1){
var nextPhaseDes = "";
nextPhaseDes = nextPhases[0].split(",")[2];
//如果节点类型为任务池或结束或补充资料则隐藏动作选择框
if(nextPhaseDes == "POOL" || nextPhaseDes == "END" || nextPhaseDes == "SUPPLY" || nextPhaseDes == "FORK&POOL"){
bActionReqiured = false;
if(nextPhaseDes == "POOL") isPool = true;
}else{
bActionReqiured = true;
}
}
if(bActionReqiured){
var actionList = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getActionList","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion);
//alert(actionList);
if(!actionList){
phaseInfoSet.text("所选阶段没有用户可以选择,请确认!");
return;
}
phaseInfoSet.text("");
actionSet.empty().show();
if(nextPhases.length>1){
for(var i = 0; i < nextPhases.length; i++){
var mPhaseName = nextPhases[i].split(",")[1];
var mPhaseNo = nextPhases[i].split(",")[0];
var mPhaseDes = nextPhases[i].split(",")[2];
if(mPhaseDes == "POOL" || mPhaseDes == "END"|| mPhaseDes == "SUPPLY" || mPhaseDes == "FORK&POOL"){}else{
actionSet.append("<div style='margin-top:10px;margin-left:15px;font-size:12px;'><font color='#000000'><b>请选择"+mPhaseName+"用户:</b></font></div><div id='phaseaction"+i+"' style='margin-top:10px;margin-left:10px;font-size:12px;border:1px solid lightgray;padding:5px;'></div>");
var phaseAction = $("#phaseaction"+i);
for(var j=0;j<actionList.split("@").length;j++){
var userIDStr = actionList.split("@")[j];
var userID = userIDStr.split(" ")[0];
if(userID.indexOf("|")>-1){
var phaseNo = userID.split("|")[0];
if(mPhaseNo == phaseNo){
userIDStr = userIDStr.replace(phaseNo+"|","");
phaseAction.append("<a class='opinion-style' href='javascript:void(0)' onclick='getNextPhaseInfo(this)'><input type='radio' name='phaseaction"+i+"' value='"+userIDStr+"'>"+userIDStr+"</input></a>");
}
}
}
}
}
if(actionSet.html()==""){//如果是提交多个阶段并行任务,且这些阶段都是任务池,展示下一阶段信息
isPool = true;
getNextPhaseInfo("");
}
}else{
var mPhaseName = nextPhases[0].split(",")[1];
var mPhaseNo = nextPhases[0].split(",")[0];
actionSet.append("<div style='margin-top:10px;margin-left:15px;font-size:12px;'><font color='#000000'><b>请选择"+mPhaseName+"用户:</b></font></div><div id='phaseaction' style='margin-top:10px;margin-left:10px;font-size:12px;border:1px solid lightgray;padding:5px;'></div>");
var phaseAction = $("#phaseaction");
var isMultiUsers = AsControl.RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","isMultiUsers","FlowNo=<%=flowNo%>,PhaseNo="+mPhaseNo);
var type = "radio";
if(isMultiUsers == "Y")type="checkbox";
for(var j=0;j<actionList.split("@").length;j++){
var userIDStr = actionList.split("@")[j];
phaseAction.append("<a class='opinion-style' href='javascript:void(0)' onclick='getNextPhaseInfo(this)'><input type='"+type+"' name='phaseaction' value='"+userIDStr+"'>"+userIDStr+"</input></a>");
}
}
}else{
actionSet.empty().hide();
getNextPhaseInfo("");
}
}
/*~[Describe=获取所选择的提交动作;InputParam=无;OutPutParam=无;]~*/
function getNextActionValue(nextPhases){
var phaseAction = "";
if(nextPhases.length==1){
var nextPhaseDes = "";
nextPhaseDes = nextPhases[0].split(",")[2];
if(nextPhaseDes == "POOL" || nextPhaseDes == "FORK&POOL"){
var phaseOpinion = $("input[name='phaseopinion']:checked").val();
//alert(phaseOpinion);
phaseAction = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getActionList","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion);
//alert(phaseAction);
}else if(nextPhaseDes == "END"){
phaseAction = "system";
}else{
var checkedbox = [];
$("input[name='phaseaction']:checked").each(function(){
checkedbox.push($(this).val());
});
phaseAction = checkedbox.join("@");
}
}else{
var phaseOpinion = $("input[name='phaseopinion']:checked").val();
//alert(phaseOpinion);
var actionList = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getActionList","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion);
//alert(actionList);
for(var i = 0; i < nextPhases.length; i++){
var mPhaseName = nextPhases[i].split(",")[1];
var mPhaseNo = nextPhases[i].split(",")[0];
var mPhaseDes = nextPhases[i].split(",")[2];
var mPhaseAction = "";
//var mPhaseAction = $("input[name='phaseaction"+i+"']:checked").val();
//alert(mPhaseAction+"---");
if(mPhaseDes == "POOL" || mPhaseDes == "FORK&POOL"){
for(var j=0;j<actionList.split("@").length;j++){
var userIDStr = actionList.split("@")[j];
var userID = userIDStr.split(" ")[0];
if(userID.indexOf("|")>-1){
var phaseNo = userID.split("|")[0];
if(mPhaseNo == phaseNo){
mPhaseAction = mPhaseAction + "@" + userIDStr;
}
}
}
if(mPhaseAction.indexOf("@")>-1) mPhaseAction = mPhaseAction.substring(1);
phaseAction +="@"+ mPhaseAction;
}else{
var mPhaseAction = $("input[name='phaseaction"+i+"']:checked").val();
phaseAction +="@" + mPhaseNo+"|"+ mPhaseAction;
}
if(!mPhaseAction){
alert("请选择"+mPhaseName+"用户!");
return;
}
}
if(phaseAction.indexOf("@")>-1) phaseAction = phaseAction.substring(1);
}
return phaseAction;
}
//获取下一阶段动作
function getNextPhaseInfo(obj){
//var phaseOpinion = $("#phaseopinion").val();
var phaseOpinion = $("input[name='phaseopinion']:checked").val();
$(obj).siblings().removeClass("opinion-focus");
$(obj).addClass("opinion-focus");
$(obj).find("input").each(function(){
//$(this).attr('checked',!this.checked);
if($(this).attr('checked')){
$(this).removeAttr('checked');
}else{
$(this).attr('checked','true');
}
});
var nextPhaseInfo = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getNextPhaseInfo","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion);
phaseInfoSet.text(nextPhaseInfo);
}
//提交动作
function commitAction(){
var isCommited = AsControl.RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction", "isCommited", "TaskNo="+taskNo);
if(isCommited=='yes'){
alert("此流程任务已提交!");
return;
}
//var phaseOpinion = $("#phaseopinion").val();
var phaseOpinion = $("input[name='phaseopinion']:checked").val();
var nextPhaseAttrs = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getNextPhaseAttr","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion);
var nextPhases = nextPhaseAttrs.split("@");
//alert(phaseOpinion);
if(!phaseOpinion){
alert("请选择提交动作!");
actionSet.empty().hide();
phaseInfoSet.text("");
return;
}
var phaseAction = "";
if(true){
phaseAction = getNextActionValue(nextPhases);
//alert(phaseAction);
if(!phaseAction){
alert("请选择提交用户信息!");
return;
};
}
var param = "TaskNo="+taskNo+",PhaseAction="+phaseAction+",PhaseOpinion="+phaseOpinion;
var joinNode = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","isJoinNode",param);
if(joinNode=="1"){//如果是join节点
var joinUserID = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","getJoinUser",param);
var curUserID = phaseAction.split(" ")[0];
//alert(joinUserID + " " +curUserID);
if(curUserID!=joinUserID && joinUserID!=""){
alert("先前分支的提交人为"+joinUserID+",请选择相同人员");
return;
};
}
var nextPhaseInfo = phaseInfoSet.text();
var commitPeopleTip = "";
if(isPool){//如果下一阶段是任务池,则提示 可以挑选任务的用户
var arr = phaseAction.split("@");
for(var i=0;i<arr.length;i++){
var userID = arr[i].split(" ")[0];
if(userID.indexOf("|")>-1){//并行任务
var phaseUser = userID.split("|");
userID = "阶段:"+phaseUser[0]+"-用户:"+phaseUser[1];
}
commitPeopleTip=commitPeopleTip+userID+" ";
}
}
/**
if(phaseAction.indexOf("@")<0 && phaseAction.split(" ")[0]=="<%=CurUser.getUserID()%>"){
alert("不能提交给自己审批!");return;
}*/
var confirmStr = "该笔业务的"+nextPhaseInfo+"\r\n你确定提交吗"+(commitPeopleTip.length>0?"\r\n(任务池阶段需要挑选任务,挑选任务的用户:"+commitPeopleTip+")":"");
if(<%=!StringX.isEmpty(ft.AssignedTaskNo)%>) confirmStr ="此任务为退回的任务,将按照要求在退回后重新提交给退回人!是否继续?";
if (!confirm(confirmStr)) return;
var returnValue = RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","submit","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion+",PhaseAction="+phaseAction);
//发送邮件
RunJavaMethodTrans("com.amarsoft.app.flow.FlowAction","dispatcher","TaskNo="+taskNo+",PhaseOpinion="+phaseOpinion+",PhaseAction="+phaseAction);
parent.AsDialog.ClosePage(returnValue);
}
function init(){
actionSet.empty().hide();
}
window.onload = function(){
init();
};
function doCancel(){
if(confirm("您确定要放弃此次提交吗?")){
parent.AsDialog.ClosePage("_CANCEL_");
}
}
</script>
<%@include file="/Frame/resources/include/include_end.jspf"%>