更多nbcio-boot功能请看演示系统
gitee源代码地址
后端代码: https://gitee.com/nbacheng/nbcio-boot
前端代码:https://gitee.com/nbacheng/nbcio-vue.git
在线演示(包括H5) : http://122.227.135.243:9888
因为有时候需要审批时指定下一个审批人,所以增加这个功能
1、前端
这个比较简单,增加选择人员就可以了,如下:
<el-form-item label="附件" prop="commentFileDto.fileurl"><j-upload v-model="taskForm.commentFileDto.fileurl" ></j-upload></el-form-item><el-form-item label="选择抄送人" prop="ccUsers"><j-select-user-by-dep v-model="taskForm.ccUsers" /></el-form-item><el-form-item label="选择下一审批人" prop="nextUsers"><j-select-user-by-dep v-model="taskForm.nextUsers" /><el-tag type="danger">注意: 多实例目前仅支持选择下一个审批人数要与原先设置的人数一致</el-tag></el-form-item></el-form>
2、后端
下面对下个节点是多实例的会签要做特殊处理,包括并发与循序流转,对于循序流转需要递归传递下去参数,以便一个一个审批都能把人工设置的人员设置进去。
/*** 人工设置下一个审批人** @param task,taskVo, nextFlowNode* @return */private void setNextUsersAndComplete(Task task, FlowTaskVo taskVo, FlowNextDto nextFlowNode, List<String> manualSetNextUser) {if(Objects.nonNull(nextFlowNode)) {taskFormComplete(taskVo); manualSetAssignee(task, taskVo, nextFlowNode, manualSetNextUser); }else { //下一个节点是空taskFormComplete(taskVo);}}/*** 人工设置审批人** @param task,taskVo, nextFlowNode* @return */private void manualSetAssignee(Task task, FlowTaskVo taskVo, FlowNextDto nextFlowNode, List<String> manualSetNextUser) {List<String> nextusers = new ArrayList<String>();if (StringUtils.isNotBlank(taskVo.getNextUsers())){nextusers = CollUtil.newLinkedList(taskVo.getNextUsers().split(","));}if(nextusers.size() == 0 && ObjectUtil.isNotEmpty(manualSetNextUser)) {//若是人工串行会签传递过来参数Task nexttask = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().singleResult();taskService.setAssignee(nexttask.getId(),manualSetNextUser.get(0));manualSetNextUser.remove(0);if(manualSetNextUser.size()>0) {taskService.setVariable(nexttask.getId(), "ManualSetNextUser", manualSetNextUser);}return;}List<SysUser> sysuserlist = nextFlowNode.getUserList();if(nextusers.size() > 0) { if(nextFlowNode.getType().equals(ProcessConstants.PROCESS_MULTI_INSTANCE) && sysuserlist.size() == nextusers.size()) {//若下个节点是会签节点,且指定审核人数与原先设置的人数相同List<Task> nexttasklist = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().list();if(!nextFlowNode.isBisSequential()){//对并发会签进行assignee单独赋值int i = 0;for (Task nexttask : nexttasklist) {String assignee = nextusers.get(i).toString(); taskService.setAssignee(nexttask.getId(), assignee);i++;}}else {//串行的话,第一个也直接赋值,后面也需要带上参数值,以便传递下去Task nexttask = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().singleResult();taskService.setAssignee(nexttask.getId(), nextusers.get(0));if(nextusers.size()>1) {nextusers.remove(0);taskService.setVariable(nexttask.getId(), "ManualSetNextUser", nextusers);//设置人工设置串行会签人员}} }else {Task nexttask = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().singleResult();taskService.setAssignee(nexttask.getId(), nextusers.get(0));}}}
3、效果图