如何实现在列表快速审批单据原创
金蝶云社区-wbshcy
wbshcy
5人赞赏了该文章 1890次浏览 未经作者许可,禁止转载编辑于2022年04月25日 16:00:28

关键字:列表、流程、快速审批

一、需求

有些用户在列表看到关键字段信息就可以决定该流程审批通过,所以希望能在列表界面实现快速审批流程,而不需要进入消息中心去操作。

二、思路与方案

WorkflowServiceHelper工作流工具类有提供审批通过的接口,所以可以在列表界面直接调用该接口进行快速审批。在审批之前需要判断用户选择的单据的流程当前处理人是不是有当前用户,如果不是则不能审批。

三、实现过程

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

 

图片1.png

 

2.在点击前事件判断选择的单据是否包含有当前处理人不是当前登录用户的单据,有则提示重新选择,没有则提示是否继续确认框。

@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
// TODO Auto-generated method stub
super.beforeItemClick(evt);
if("kded_quickapprove".equals(evt.getItemKey())) {
BillList billlist = this.getView().getControl("billlistap");
 ListSelectedRowCollection currentSelectedRowCollection= billlist.getSelectedRows();
 if(currentSelectedRowCollection.size()==0) {
 this.getView().showMessage("至少选择一条数据");
 return;
 }
 Long currentUserId = RequestContext.get().getCurrUserId();
 for(ListSelectedRow row:currentSelectedRowCollection) {
 List<Long> approverByBusinessKey = WorkflowServiceHelper.getApproverByBusinessKey(row.getPrimaryKeyValue().toString());
 if(approverByBusinessKey.contains(currentUserId)) {
 continue;
 }else {
 this.getView().showMessage("你并不是所选择单据的当前处理人,请重新选择单据");
 return;
 }
 }
 this.getView().showConfirm("快速审批代表你同意这些单据,是否继续", MessageBoxOptions.OKCancel,new ConfirmCallBackListener("kded_quickapprove"));
}


3.在confirmCallBack调用审批通过的接口。

 

@Override
public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
// TODO Auto-generated method stub
super.confirmCallBack(messageBoxClosedEvent);
if("kded_quickapprove".equals(messageBoxClosedEvent.getCallBackId())){
if(messageBoxClosedEvent.getResult().name().equals("Yes")) {
BillList billlist =  this.getView().getControl("billlistap");
 ListSelectedRowCollection currentSelectedRowCollection= billlist.getSelectedRows();
 Long currentUserId = RequestContext.get().getCurrUserId();
 StringBuffer billNos = new StringBuffer();
 for(ListSelectedRow row:currentSelectedRowCollection) {
 List<Long> approverByBusinessKey = WorkflowServiceHelper.getApproverByBusinessKey(row.getPrimaryKeyValue().toString());
 if(approverByBusinessKey.contains(currentUserId)) {
 long taskId=WorkflowServiceHelper.getTaskIdByBusinessKeyAndUserId(row.getPrimaryKeyValue().toString(),currentUserId);
 WorkflowServiceHelper.completeTask(taskId, currentUserId, "Consent", "已同意");
 }else {
 billNos.append("“").append(row.getBillNo()).append("” ");    
 }
 
 }
 if(billNos.length()>0) {
 this.getView().showMessage("单据编号为:"+billNos+"的这些单据的流程当前处理人并不是你,审批失败,其他单据已完成快速审批");
 
 
 }
}
}
}
 
}


四、效果图

 

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

图片2.png

2.选择处理人不是自己的单据时提示重新选择单据。

 图片3.png

3. 选择当前处理人是自己的单据,提示是否继续。

图片4.png


4. 上一步骤点确定后,过几秒刷新列表(因为流程任务处理是异步的),发现单据已审批通过流转到下一个节点了。

 

图片5.png

五、开发环境版本

V4.0.0.14

、参考资料

【开发平台】指导手册

学习成长中心

 


赞 5