fix: 修复接单部门负责人无法看到部门成员所有进行中任务的问题
This commit is contained in:
parent
ddb5e729b9
commit
0f2df8105d
@ -4054,37 +4054,71 @@ const loadInProgressTasks = async () => {
|
||||
let totalCount = 0
|
||||
|
||||
// 根据部门类型决定加载哪些任务
|
||||
// 优先判断是否是部门负责人切换视角
|
||||
if (isDeptLeader && currentDeptView.value !== undefined) {
|
||||
// 部门负责人切换到其他部门视角
|
||||
console.log('部门负责人视角切换,部门ID:', currentDeptView.value, '部门类型:', currentDeptType)
|
||||
|
||||
if (currentDeptType === 'receiving') {
|
||||
// 接单部门视角:看该部门成员的子任务
|
||||
const itemResponse = await taskApi.getInProgressTaskItems(params)
|
||||
if (itemResponse.data && itemResponse.data.records) {
|
||||
const items = itemResponse.data.records.map((item: any) => mapTaskItemToTask(item))
|
||||
allTasks = [...allTasks, ...items]
|
||||
totalCount += itemResponse.data.total || 0
|
||||
// 优先判断是否是部门负责人(包括切换视角和未切换视角的情况)
|
||||
if (isDeptLeader) {
|
||||
if (currentDeptView.value !== undefined) {
|
||||
// 部门负责人切换到其他部门视角
|
||||
console.log('部门负责人视角切换,部门ID:', currentDeptView.value, '部门类型:', currentDeptType)
|
||||
|
||||
if (currentDeptType === 'receiving') {
|
||||
// 接单部门视角:看该部门成员的子任务
|
||||
const itemResponse = await taskApi.getInProgressTaskItems(params)
|
||||
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 {
|
||||
// 需求部门视角:看该部门发起的任务(通过 deptId 参数)
|
||||
const taskResponse = await taskApi.getTasks({
|
||||
...params,
|
||||
publisherDeptId: currentDeptView.value // 按发布者部门过滤
|
||||
})
|
||||
if (taskResponse.data && taskResponse.data.records) {
|
||||
const tasksWithInProgress = taskResponse.data.records.filter((task: any) => {
|
||||
if (task.isPipeline === 1) {
|
||||
return (task.subTaskInProgress || 0) > 0 || task.status === 'in_progress'
|
||||
}
|
||||
return task.status === 'in_progress'
|
||||
})
|
||||
allTasks = tasksWithInProgress.map((task: any) => ({
|
||||
...task,
|
||||
isSubTask: false
|
||||
}))
|
||||
totalCount = allTasks.length
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 需求部门视角:看该部门发起的任务(通过 deptId 参数)
|
||||
const taskResponse = await taskApi.getTasks({
|
||||
...params,
|
||||
publisherDeptId: currentDeptView.value // 按发布者部门过滤
|
||||
})
|
||||
if (taskResponse.data && taskResponse.data.records) {
|
||||
const tasksWithInProgress = taskResponse.data.records.filter((task: any) => {
|
||||
if (task.isPipeline === 1) {
|
||||
return (task.subTaskInProgress || 0) > 0 || task.status === 'in_progress'
|
||||
}
|
||||
return task.status === 'in_progress'
|
||||
// 部门负责人未切换视角:根据用户自己的部门类型显示
|
||||
console.log('部门负责人未切换视角,用户部门类型:', userDeptType.value)
|
||||
|
||||
if (userDeptType.value === 'receiving') {
|
||||
// 接单部门负责人:看自己部门所有成员的子任务(不传deptId,后端会自动获取所有负责的部门)
|
||||
const itemResponse = await taskApi.getInProgressTaskItems(params)
|
||||
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 {
|
||||
// 需求部门负责人:看自己部门发起的任务
|
||||
const taskResponse = await taskApi.getTasks({
|
||||
...params,
|
||||
publisherDeptId: userDeptId.value // 按发布者部门过滤
|
||||
})
|
||||
allTasks = tasksWithInProgress.map((task: any) => ({
|
||||
...task,
|
||||
isSubTask: false
|
||||
}))
|
||||
totalCount = allTasks.length
|
||||
if (taskResponse.data && taskResponse.data.records) {
|
||||
const tasksWithInProgress = taskResponse.data.records.filter((task: any) => {
|
||||
if (task.isPipeline === 1) {
|
||||
return (task.subTaskInProgress || 0) > 0 || task.status === 'in_progress'
|
||||
}
|
||||
return task.status === 'in_progress'
|
||||
})
|
||||
allTasks = tasksWithInProgress.map((task: any) => ({
|
||||
...task,
|
||||
isSubTask: false
|
||||
}))
|
||||
totalCount = allTasks.length
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isAdmin) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user