流程详情页 90% - 接入审批通过、审批不通过的功能

pull/2/head
YunaiV 2022-01-17 12:53:43 +08:00
parent cf7a434f0c
commit c9b9eced07
12 changed files with 49 additions and 12 deletions

View File

@ -46,14 +46,14 @@ public class BpmTaskController {
@PutMapping("/approve")
@ApiOperation("通过任务")
public CommonResult<Boolean> approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
taskService.approveTask(reqVO);
taskService.approveTask(getLoginUserId(), reqVO);
return success(true);
}
@PutMapping("/reject")
@ApiOperation("不通过任务")
public CommonResult<Boolean> rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) {
taskService.rejectTask(reqVO);
taskService.rejectTask(getLoginUserId(), reqVO);
return success(true);
}

View File

@ -42,6 +42,7 @@ public interface BpmErrorCodeConstants {
// ========== 流程任务 1-009-005-000 ==========
ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "审批任务失败,原因:该任务不处于未审批");
ErrorCode TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1009004001, "审批任务失败,原因:该任务的审批人不是你");
// ========== 流程任务分配规则 1-009-006-000 ==========
ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1009006000, "流程({}) 的任务({}) 已经存在分配规则");

View File

@ -21,7 +21,6 @@ public interface BpmTaskService {
* Running
*
* @param processInstanceId
* @return
*/
List<Task> getRunningTaskListByProcessInstanceId(String processInstanceId);
@ -81,16 +80,18 @@ public interface BpmTaskService {
/**
*
*
* @param userId
* @param reqVO
*/
void approveTask(@Valid BpmTaskApproveReqVO reqVO);
void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO);
/**
*
*
* @param userId
* @param reqVO
*/
void rejectTask(@Valid BpmTaskRejectReqVO reqVO);
void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO);
/**
*

View File

@ -14,6 +14,7 @@ import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO
import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService;
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
@ -200,12 +201,15 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Override
@Transactional(rollbackFor = Exception.class)
public void approveTask(BpmTaskApproveReqVO reqVO) {
public void approveTask(Long userId, BpmTaskApproveReqVO reqVO) {
// 校验任务存在
Task task = getTask(reqVO.getId());
if (task == null) {
throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS);
}
if (!ActivitiUtils.equals(task.getAssignee(), userId)) {
throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF);
}
// 校验流程实例存在
ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
if (instance == null) {
@ -224,12 +228,15 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Override
@Transactional(rollbackFor = Exception.class)
public void rejectTask(@Valid BpmTaskRejectReqVO reqVO) {
public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) {
// 校验任务存在
Task task = getTask(reqVO.getId());
if (task == null) {
throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS);
}
if (!ActivitiUtils.equals(task.getAssignee(), userId)) {
throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF);
}
// 校验流程实例存在
ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
if (instance == null) {

View File

@ -32,6 +32,9 @@ public class SysAuthPermissionInfoRespVO {
@Builder
public static class UserVO {
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
private Long id;
@ApiModelProperty(value = "用户昵称", required = true, example = "芋道源码")
private String nickname;

View File

@ -31,7 +31,7 @@ public interface SysAuthConvert {
default SysAuthPermissionInfoRespVO convert(SysUserDO user, List<SysRoleDO> roleList, List<SysMenuDO> menuList) {
return SysAuthPermissionInfoRespVO.builder()
.user(SysAuthPermissionInfoRespVO.UserVO.builder().nickname(user.getNickname()).avatar(user.getAvatar()).build())
.user(SysAuthPermissionInfoRespVO.UserVO.builder().id(user.getId()).nickname(user.getNickname()).avatar(user.getAvatar()).build())
.roles(CollectionUtils.convertSet(roleList, SysRoleDO::getCode))
.permissions(CollectionUtils.convertSet(menuList, SysMenuDO::getPermission))
.build();

View File

@ -4,6 +4,7 @@ const getters = {
device: state => state.app.device,
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
userId: state => state.user.id,
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,

View File

@ -4,6 +4,7 @@ import { getToken, setToken, removeToken } from '@/utils/auth'
const user = {
state: {
token: getToken(),
id: 0, // 用户编号
name: '',
avatar: '',
roles: [],
@ -11,6 +12,9 @@ const user = {
},
mutations: {
SET_ID: (state, id) => {
state.id = id
},
SET_TOKEN: (state, token) => {
state.token = token
},
@ -96,6 +100,7 @@ const user = {
} else {
commit('SET_ROLES', ['ROLE_DEFAULT'])
}
commit('SET_ID', user.id)
commit('SET_NAME', user.userName)
commit('SET_AVATAR', avatar)
resolve(res)

View File

@ -21,7 +21,7 @@
<div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px;">
<el-button icon="el-icon-edit-outline" type="success" size="mini" @click="handleAudit(item, true)">通过</el-button>
<el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleAudit(item, false)">不通过</el-button>
<!-- <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleAssign"></el-button>-->
<!-- <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleAssign"></el-button>-->
<el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate(item)"></el-button>
<el-button icon="el-icon-refresh-left" type="warning" size="mini" @click="handleBack(item)">退</el-button>
</div>
@ -81,7 +81,7 @@
<script>
import {getProcessDefinitionBpmnXML, getProcessDefinitionList} from "@/api/bpm/definition";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import {getForm} from "@/api/bpm/form";
import store from "@/store";
import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser'
import {createProcessInstance, getMyProcessInstancePage, getProcessInstance} from "@/api/bpm/processInstance";
@ -196,10 +196,14 @@ export default {
});
//
const userId = store.getters.userId;
this.historicTasks.forEach(task => {
if (task.result !== 1) { //
return;
}
if (!task.assigneeUser || task.assigneeUser.id !== userId) { //
return;
}
this.tasks.push({...task});
this.auditForms.push({
comment: ''

View File

@ -106,6 +106,7 @@
<!-- TODO 芋艿权限 -->
<el-button type="text" size="small" icon="el-icon-delete" v-if="scope.row.result === 1"
@click="handleCancel(scope.row)">取消</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
@ -204,6 +205,10 @@ export default {
this.msgSuccess("取消成功");
})
},
/** 处理详情按钮 */
handleDetail(row) {
this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.id}});
},
}
};
</script>

View File

@ -60,7 +60,7 @@
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!-- TODO 权限颜色 -->
<el-button size="mini" type="text" icon="el-icon-edit">详情</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleAudit(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
@ -127,7 +127,11 @@ export default {
},
getDateStar(ms) {
return getDate(ms);
}
},
/** 处理审批按钮 */
handleAudit(row) {
this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstance.id}});
},
}
};
</script>

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.activiti.core.util;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import com.alibaba.ttl.TransmittableThreadLocal;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
@ -13,6 +14,7 @@ import org.activiti.engine.impl.util.io.BytesStreamSource;
import javax.xml.bind.Element;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
/**
@ -45,6 +47,10 @@ public class ActivitiUtils {
Authentication.setAuthenticatedUserId(null);
}
public static boolean equals(String userIdStr, Long userId) {
return Objects.equals(userId, NumberUtils.parseLong(userIdStr));
}
// ========== BPMN XML 相关 ==========
/**