|
楼主 |
发表于 2016-6-20 10:56:59
|
显示全部楼层
本帖最后由 shuaigej 于 2016-6-20 11:00 编辑
标红的都是旧版本的,还有一些我不知道的,我看在帖子的回复中也是大家都在问新版的调用问题,但是没有回复。
实现步骤:
1. 使用第个待办任务执行流转查询
function batchAdvanceProcess(processID){
var p = justep.xbl(processID);
//使用其中的一条待办执行流转查询,并弹出流转对话框给用户修改,以得到control信息
p.advanceQueryExt(tasks[0]);
}
2. 用户可以看到流转对话框,修改其中的执行者信息
3. 在process组件的onBeforeAdvance事件中,获取编辑后的流转信息,取消后续操作,调用后台的自定义的批流转动作(batchAdvanceProcessAction)
mainActivity.processBeforeAdvance = function(event){
event.cancel = true; //取消后续操作
//所有的待办按得到的control中的执行人进行流转
var options = {};
options.process = justep.Context.getCurrentProcess();
options.activity = justep.Context.getCurrentActivity();
options.action = "batchAdvanceProcessAction";
options.directExecute = true;
options.parameters = new justep.Request.ActionParam();
var taskParam = new justep.Request.ListParam();
for (var i=0; i<tasks.length; i++){
taskParam.add(tasks);
}
options.parameters.setList("tasks", taskParam);
var controlData = null;
if (event.processControl.getDataType != undefined){
//2000 sp2及之后的版本
if (event.processControl.getDataType() == "json"){
options.contentType = "json";
controlData = event.processControl.getData();
}else{
options.contentType = "xml";
controlData = event.processControl.getXMLString();
}
}else{
//2000 sp2之前的版本
options.contentType = "xml";
controlData = event.processControl.getXMLString();
}
var controlParam = new justep.Request.ObjectParam(controlData, "com.justep.system.process.ProcessControl");
options.parameters.setObject("control", controlParam);
justep.Request.sendBizRequest2(options);
justep.Portal.closeWindow();
};
4. batchAdvanceProcessAction的定义可以参考附件中的内容,关键实现如下:
public static void batchAdvanceProcess(List<String> tasks, ProcessControl control){
for (String task : tasks){
ProcessControl cur = ProcessUtils.advanceProcessQuery(task);
modifyFlowToExecutor(cur, control);
modifyNoticeExecutor(cur, control);
ProcessUtils.advanceProcess(task, cur);
}
}
private static void modifyNoticeExecutor(ProcessControl cur, ProcessControl control){
Iterator<ProcessControlItem> it = cur.getNotices().iterator();
while (it.hasNext()){
ProcessControlItem item = it.next();
ProcessControlItem template = control.getNotice(item.getUnit());
if (template == null){
it.remove();
}else{
item.clearExecutors();
item.addExecutors(template.getExecutors());
}
}
}
private static void modifyFlowToExecutor(ProcessControl cur, ProcessControl control){
Iterator<ProcessControlItem> it = cur.getFlowTos().iterator();
while (it.hasNext()){
ProcessControlItem item = it.next();
ProcessControlItem template = control.getFlowTo(item.getUnit());
if (template == null){
it.remove();
}else{
item.clearExecutors();
item.addExecutors(template.getExecutors());
}
}
} |
|