fix: 修复部门负责人切换接单部门视角后,进行中任务列表同时查询主任务和子任务
This commit is contained in:
parent
49d4fc57ff
commit
d9ae5e89d8
@ -59,13 +59,14 @@ public class TaskController {
|
||||
@Parameter(description = "任务状态") @RequestParam(required = false) String status,
|
||||
@Parameter(description = "任务类型ID") @RequestParam(required = false) Long taskTypeId,
|
||||
@Parameter(description = "发布者部门ID") @RequestParam(required = false) Long publisherDeptId,
|
||||
@Parameter(description = "接收部门ID") @RequestParam(required = false) Long receiverDeptId,
|
||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "20") Integer pageSize) {
|
||||
|
||||
log.info("查询任务列表: status={}, taskTypeId={}, publisherDeptId={}, page={}, pageSize={}",
|
||||
status, taskTypeId, publisherDeptId, page, pageSize);
|
||||
log.info("查询任务列表: status={}, taskTypeId={}, publisherDeptId={}, receiverDeptId={}, page={}, pageSize={}",
|
||||
status, taskTypeId, publisherDeptId, receiverDeptId, page, pageSize);
|
||||
|
||||
IPage<Task> taskPage = taskService.getTaskList(page, pageSize, status, taskTypeId, publisherDeptId);
|
||||
IPage<Task> taskPage = taskService.getTaskList(page, pageSize, status, taskTypeId, publisherDeptId, receiverDeptId);
|
||||
return Result.success(taskPage);
|
||||
}
|
||||
|
||||
|
||||
@ -578,7 +578,7 @@ public class TaskService {
|
||||
/**
|
||||
* 获取任务列表
|
||||
*/
|
||||
public IPage<Task> getTaskList(Integer page, Integer pageSize, String status, Long taskTypeId, Long publisherDeptId) {
|
||||
public IPage<Task> getTaskList(Integer page, Integer pageSize, String status, Long taskTypeId, Long publisherDeptId, Long receiverDeptId) {
|
||||
Page<Task> pageParam = new Page<>(page, pageSize);
|
||||
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@ -597,6 +597,13 @@ public class TaskService {
|
||||
wrapper.eq(Task::getPublisherDeptId, publisherDeptId);
|
||||
}
|
||||
|
||||
// 根据接收部门筛选(部门负责人视角切换时使用,支持部门ID列表)
|
||||
if (receiverDeptId != null) {
|
||||
// 获取该部门及其所有子部门
|
||||
List<Long> deptAndChildIds = getDeptAndChildIds(receiverDeptId);
|
||||
wrapper.in(Task::getReceiverDeptId, deptAndChildIds);
|
||||
}
|
||||
|
||||
// 按更新时间倒序
|
||||
wrapper.orderByDesc(Task::getUpdateTime);
|
||||
|
||||
|
||||
@ -4061,16 +4061,36 @@ const loadInProgressTasks = async () => {
|
||||
console.log('部门负责人视角切换,部门ID:', currentDeptView.value, '部门类型:', currentDeptType)
|
||||
|
||||
if (currentDeptType === 'receiving') {
|
||||
// 接单部门视角:看该部门成员的子任务
|
||||
console.log('接单部门负责人切换视角,调用getInProgressTaskItems,params:', params)
|
||||
const itemResponse = await taskApi.getInProgressTaskItems(params)
|
||||
// 接单部门视角:看该部门成员的子任务 + 主任务
|
||||
console.log('接单部门负责人切换视角,调用getInProgressTaskItems和getTasks,params:', params)
|
||||
const [itemResponse, taskResponse] = await Promise.all([
|
||||
taskApi.getInProgressTaskItems(params),
|
||||
taskApi.getTasks({
|
||||
...params,
|
||||
receiverDeptId: currentDeptView.value,
|
||||
status: 'in_progress'
|
||||
})
|
||||
])
|
||||
console.log('getInProgressTaskItems响应:', itemResponse)
|
||||
console.log('getTasks响应:', taskResponse)
|
||||
|
||||
// 处理子任务
|
||||
if (itemResponse.data && itemResponse.data.records) {
|
||||
const items = itemResponse.data.records.map((item: any) => mapTaskItemToTask(item))
|
||||
allTasks = [...allTasks, ...items]
|
||||
totalCount += itemResponse.data.total || 0
|
||||
} else {
|
||||
console.log('getInProgressTaskItems返回数据为空或records为空')
|
||||
}
|
||||
|
||||
// 处理主任务(排除流水线任务,因为流水线任务由子任务显示)
|
||||
if (taskResponse.data && taskResponse.data.records) {
|
||||
const normalTasks = taskResponse.data.records
|
||||
.filter((task: any) => task.isPipeline !== 1) // 排除流水线任务
|
||||
.map((task: any) => ({
|
||||
...task,
|
||||
isSubTask: false
|
||||
}))
|
||||
allTasks = [...allTasks, ...normalTasks]
|
||||
totalCount += normalTasks.length
|
||||
}
|
||||
} else {
|
||||
// 需求部门视角:看该部门发起的任务(通过 deptId 参数)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user