fix: 修复创建任务时设计师列表不显示的问题 - 使用taskTypeId调用API获取设计师
This commit is contained in:
parent
c3bdf4e2f6
commit
e55b30e10f
@ -621,8 +621,8 @@ interface CascaderOption {
|
||||
estimatedHours?: number
|
||||
}
|
||||
|
||||
// 设计师列表缓存 { deptId: designers[] }
|
||||
const designersCache = reactive<Record<number, any[]>>({})
|
||||
// 设计师列表缓存 { taskType_{id}: designers[] }
|
||||
const designersCache = reactive<Record<string, any[]>>({})
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
@ -853,25 +853,17 @@ const findTaskTypeById = (id: number, items: any[] = hierarchicalTaskTypes.value
|
||||
return null
|
||||
}
|
||||
|
||||
// 加载设计师列表
|
||||
// 加载设计师列表(根据任务类型ID)
|
||||
const loadDesignersForItem = async (item: TaskTypeItem) => {
|
||||
if (!item.taskTypeId) return
|
||||
|
||||
const typeInfo = getTaskTypeInfo(item.taskTypeId)
|
||||
if (!typeInfo || !typeInfo.allowedDeptIds) return
|
||||
const cacheKey = `taskType_${item.taskTypeId}`
|
||||
|
||||
// 简化处理:取第一个允许的部门ID
|
||||
const deptIds = typeInfo.allowedDeptIds.split(',')
|
||||
if (deptIds.length === 0) return
|
||||
|
||||
const deptId = Number(deptIds[0])
|
||||
|
||||
if (!designersCache[deptId]) {
|
||||
if (!designersCache[cacheKey]) {
|
||||
try {
|
||||
const res = await userApi.getDesignersWithWorkload(deptId)
|
||||
if (res.code === 200) {
|
||||
designersCache[deptId] = res.data
|
||||
}
|
||||
// 使用 taskTypeId 调用后端 API,后端会处理接单部门配置
|
||||
const designers = await userApi.getDesignersWithWorkload(undefined, item.taskTypeId)
|
||||
designersCache[cacheKey] = designers
|
||||
} catch (error) {
|
||||
console.error('加载设计师失败:', error)
|
||||
}
|
||||
@ -882,14 +874,8 @@ const loadDesignersForItem = async (item: TaskTypeItem) => {
|
||||
const getDesignersForItem = (item: TaskTypeItem) => {
|
||||
if (!item.taskTypeId) return []
|
||||
|
||||
const typeInfo = getTaskTypeInfo(item.taskTypeId)
|
||||
if (!typeInfo || !typeInfo.allowedDeptIds) return []
|
||||
|
||||
const deptIds = typeInfo.allowedDeptIds.split(',')
|
||||
if (deptIds.length === 0) return []
|
||||
|
||||
const deptId = Number(deptIds[0])
|
||||
return designersCache[deptId] || []
|
||||
const cacheKey = `taskType_${item.taskTypeId}`
|
||||
return designersCache[cacheKey] || []
|
||||
}
|
||||
|
||||
// 添加任务类型
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user