如何实现在列表界面打开审批界面原创
金蝶云社区-wbshcy
wbshcy
10人赞赏了该文章 2127次浏览 未经作者许可,禁止转载编辑于2022年05月01日 22:07:56

关键字:列表、流程、审批界面

一、需求

客户为了能够快速处理业务,希望直接点击列表中的按钮就能打开审批界面进行任务处理,而不需要进入消息中心去操作。

二、思路与方案

可以在列表界面增加按钮,点击按钮则判断选中单据的当前审批处理人是不是登录用户,如果是则构造审批界面参数并打开审批界面。

三、实现过程

1.给单据列表的工具栏配置工具栏项,标识为kded_openapprovepage。

 

图片1.png

 

2.在点击前事件判断只能选中一条记录,且判断当前用户是否有该选中单据的审批任务,有则打开审批界面。

@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
// TODO Auto-generated method stub
super.beforeItemClick(evt);
if("kded_openapprovepage".equals(evt.getItemKey())) {
BillList billlist = this.getView().getControl("billlistap");
 ListSelectedRowCollection currentSelectedRowCollection= billlist.getSelectedRows();
 if(currentSelectedRowCollection.size()==0||currentSelectedRowCollection.size()>1) {
 this.getView().showMessage("至少选择一条数据且至多选择一条数据");
 return;
 }
WorkflowService wfService = ServiceFactory.getService(WorkflowService.class); 
String billId = billlist.getCurrentSelectedRowInfo().getPrimaryKeyValue().toString(); //选中单据行的id
Long currentUserId = RequestContext.get().getCurrUserId(); // 当前登录人
Long taskId = wfService.getTaskIdByBusinessKeyAndUserId(billId, currentUserId); // 查询当前单据当前用户是否有任务
boolean isShowErrorNotification = true; 
if(null != taskId && taskId.longValue() != 0){
TaskInfo taskInfo = wfService.findTaskById(taskId); // 获取任务数据  
if(null != taskInfo){ 
isShowErrorNotification = false; 
FormShowParameter parameter = new FormShowParameter();  
HashMap<String,Object> customParams = new HashMap<>(); // 组装参数  
customParams.put("taskId", taskId);  
customParams.put("type", "toHandle"); //待办任务 类型
parameter.setCustomParams(customParams);   
parameter.setFormId(taskInfo.getProcessingPage()); //设置审批处理的页面   
parameter.getOpenStyle().setShowType(ShowType.NewWindow);
this.getView().showForm(parameter);  
}
}
if (isShowErrorNotification ){
this.getView().showErrorNotification("当前选中单据没有你的审批任务,请重新选择单据或稍后再试。");
} 
}
}


四、效果图

1. 未选择单据或多选单据时提示“至少选择一条数据且至多选择一条数据”。

 

图片2.png

2.选择处理人不是自己的单据时提示“当前选中的单据没有你的对应任务,请重新选择或稍后再试”

 

图片3.png

3. 选择当前处理人是自己的单据,打开审批界面

 

图片4.png

五、开发环境版本

V4.0.0.14

、参考资料

【开发平台】指导手册

学习成长中心

 


赞 10