diff --git a/frontend/src/views/CreateTask.vue b/frontend/src/views/CreateTask.vue index 0131291..100c32a 100644 --- a/frontend/src/views/CreateTask.vue +++ b/frontend/src/views/CreateTask.vue @@ -621,8 +621,8 @@ interface CascaderOption { estimatedHours?: number } -// 设计师列表缓存 { deptId: designers[] } -const designersCache = reactive>({}) +// 设计师列表缓存 { taskType_{id}: designers[] } +const designersCache = reactive>({}) // 表单数据 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] || [] } // 添加任务类型