多个环节and合并时有些操作是需要最后一个环节流转时才执行,可以在onAfterAdvaneQuery或者onAfterAdvance中判断是否是and的最后一个环节
本案例中是在首页的.w中process组件事件和process文件中的全局的事件中判断的,当然也可以在and合并的几个环节的.w中process组件的事件或process文件中and合并的几个环节上的事件中判断,只是需要写多次比较麻烦
流程图下:活动环节5和活动环节6通过and合并(多个环节直接输出都一个环节默认就是and,也可以在活动环节7上面加一个and)
.w中process组件的事件中处理如下:
Model.prototype.processAfterAdvanceQuery = function(event){ var context = this.getContext(); var activity = context.getActivity();//如果按照activitylabel判断可以用context.getActivityLabel(); if(activity == "businessActivity6" || activity == "businessActivity5"){ var processControl = event.processControl;//获取ProcessControl var flowTos = processControl.getToItems(); if(flowTos.length>0){////判断是否有flowTos alert("onAfterAdvanceQuery事件中and前的最后一个环节"); } } }; Model.prototype.processAfterAdvance = function(event){ var context = this.getContext(); var activity = context.getActivity();//如果按照activitylabel判断可以用context.getActivityLabel(); if(activity == "businessActivity6" || activity == "businessActivity5"){ var processControl = event.processControl;//获取ProcessControl var flowTos = processControl.getToItems(); if(flowTos.length>0){////判断是否有flowTos alert("onAfterAdvance事件中and前的最后一个环节"); } } };
后端process文件中的事件处理如下:
public static void andProcessAfterAdvance() { String activity = ProcessUtils.getActivityInProcessContext().getName();//如果按照activitylabel判断可以用ProcessUtils.getCurrentActivityLabel(); if(activity.equals("businessActivity6")|| activity.equals("businessActivity5")){ ProcessControl flowControl = (ProcessControl) ContextHelper.getActionContext().getParameter("control");//获取ProcessControl List<ProcessControlItem> flowTos = flowControl.getFlowTos(); if(flowTos.size()>0){//判断是否有flowTos System.out.println("onAfterAdvance事件中and前最后一个环节"); } } } public static void andProcessAfterAdvanceQuery() { String activity = ProcessUtils.getActivityInProcessContext().getName();//如果按照activitylabel判断可以用ProcessUtils.getCurrentActivityLabel(); if(activity.equals("businessActivity6")|| activity.equals("businessActivity5")){ ProcessControl flowControl = (ProcessControl) ContextHelper.getActionContext().getActionResult();//获取ProcessControl List<ProcessControlItem> flowTos = flowControl.getFlowTos(); if(flowTos.size()>0){//判断是否有flowTos System.out.println("onAfterAdvanceQuery事件中and前最后一个环节"); } } }
评一波