fix(flow-query): show final operator for completed tasks
This commit is contained in:
parent
1f4e312339
commit
cc7435012b
@ -4727,6 +4727,16 @@ public class TaskService {
|
||||
info.setStatus(approvalStatus != null ? approvalStatus : status);
|
||||
info.setStatusName(getApprovalStatusName(approvalStatus, status, isPrimaryTask));
|
||||
info.setDescription(getApprovalStatusDescription(approvalStatus, status, isPrimaryTask));
|
||||
|
||||
// 任务终态:不再使用 currentApprover,避免显示历史审批人导致“当前节点”误导
|
||||
if ("completed".equals(status) || "cancelled".equals(status)) {
|
||||
com.designhub.vo.TaskFlowStatusVO.WaitingUser finalOperator = buildFinalOperator(task);
|
||||
if (finalOperator != null) {
|
||||
finalOperator.setRoleName("最后操作人");
|
||||
info.setWaitingFor(finalOperator);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
// 设置等待操作人
|
||||
if (task.getCurrentApproverId() != null) {
|
||||
@ -4820,6 +4830,41 @@ public class TaskService {
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private com.designhub.vo.TaskFlowStatusVO.WaitingUser buildFinalOperator(Task task) {
|
||||
com.designhub.vo.TaskFlowStatusVO.WaitingUser waitingUser = new com.designhub.vo.TaskFlowStatusVO.WaitingUser();
|
||||
|
||||
Long userId = null;
|
||||
if (task.getIsPipeline() != null && task.getIsPipeline() == 1) {
|
||||
TaskItem lastCompletedItem = taskItemMapper.selectOne(
|
||||
new LambdaQueryWrapper<TaskItem>()
|
||||
.eq(TaskItem::getTaskId, task.getId())
|
||||
.eq(TaskItem::getStatus, "completed")
|
||||
.isNotNull(TaskItem::getReceiverId)
|
||||
.orderByDesc(TaskItem::getCompleteTime)
|
||||
.orderByDesc(TaskItem::getUpdateTime)
|
||||
.orderByDesc(TaskItem::getId)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (lastCompletedItem != null) {
|
||||
userId = lastCompletedItem.getReceiverId();
|
||||
}
|
||||
} else {
|
||||
userId = task.getReceiverId();
|
||||
}
|
||||
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
waitingUser.setUserId(userId);
|
||||
User user = userMapper.selectById(userId);
|
||||
if (user != null) {
|
||||
waitingUser.setUserName(user.getRealName());
|
||||
waitingUser.setDeptName(user.getDeptName());
|
||||
}
|
||||
return waitingUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建流程时间线
|
||||
@ -5271,4 +5316,3 @@ public class TaskService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
<div class="node-status">当前节点:{{ result.currentNode.statusName }}</div>
|
||||
<div class="node-waiting" v-if="result.currentNode.waitingFor">
|
||||
<span v-if="result.currentNode.waitingFor.userName">
|
||||
等待操作人:<strong>{{ result.currentNode.waitingFor.userName }}</strong>
|
||||
{{ getCurrentNodeActorLabel(result) }}:<strong>{{ result.currentNode.waitingFor.userName }}</strong>
|
||||
<span v-if="result.currentNode.waitingFor.deptName">({{ result.currentNode.waitingFor.deptName }})</span>
|
||||
</span>
|
||||
<span v-else-if="result.currentNode.waitingFor.roleName">
|
||||
@ -252,6 +252,14 @@ const formatTime = (time: string | undefined) => {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
const getCurrentNodeActorLabel = (data: TaskFlowStatusVO | null) => {
|
||||
const status = data?.task?.status
|
||||
if (status === 'completed' || status === 'cancelled') {
|
||||
return '最后操作人'
|
||||
}
|
||||
return '等待操作人'
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
search: (taskNo: string) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user