From 6a1c54913ef5924c4b9daa3ac21d6f838ec1a126 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 5 Jan 2026 23:50:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=89=E7=BA=A7?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=80=89=E6=8B=A9=E5=90=8E=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=92=8C=E6=97=B6=E6=95=88=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20-=20=E5=B0=86getTaskTypeInfo=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E9=80=92=E5=BD=92=E6=9F=A5=E6=89=BE=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/types/components.d.ts | 2 ++ frontend/src/views/CreateTask.vue | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/frontend/src/types/components.d.ts b/frontend/src/types/components.d.ts index 600080b..4146928 100644 --- a/frontend/src/types/components.d.ts +++ b/frontend/src/types/components.d.ts @@ -12,6 +12,7 @@ declare module 'vue' { AButton: typeof import('ant-design-vue/es')['Button'] ACalendar: typeof import('ant-design-vue/es')['Calendar'] ACard: typeof import('ant-design-vue/es')['Card'] + ACascader: typeof import('ant-design-vue/es')['Cascader'] ACheckbox: typeof import('ant-design-vue/es')['Checkbox'] ACheckboxGroup: typeof import('ant-design-vue/es')['CheckboxGroup'] ACol: typeof import('ant-design-vue/es')['Col'] @@ -43,6 +44,7 @@ declare module 'vue' { ARate: typeof import('ant-design-vue/es')['Rate'] ARow: typeof import('ant-design-vue/es')['Row'] ASelect: typeof import('ant-design-vue/es')['Select'] + ASelectOptGroup: typeof import('ant-design-vue/es')['SelectOptGroup'] ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASlider: typeof import('ant-design-vue/es')['Slider'] ASpace: typeof import('ant-design-vue/es')['Space'] diff --git a/frontend/src/views/CreateTask.vue b/frontend/src/views/CreateTask.vue index d63717b..2f1e6ac 100644 --- a/frontend/src/views/CreateTask.vue +++ b/frontend/src/views/CreateTask.vue @@ -749,9 +749,12 @@ const onTaskTypeChange = (value: (string | number)[] | undefined, item: TaskType calculateScore() } -// 获取任务类型信息(根据ID从平铺的taskTypes中查找) +// 获取任务类型信息(根据ID递归查找层级数据) const getTaskTypeInfo = (taskTypeId: number) => { - // 从平铺列表中查找 + // 先从层级数据中查找(包含完整的分值信息) + const found = findTaskTypeById(taskTypeId, hierarchicalTaskTypes.value) + if (found) return found + // 兼容:如果层级数据中找不到,从平铺列表中查找 return taskTypes.value.find((t: any) => t.id === taskTypeId) } @@ -771,7 +774,7 @@ const findTaskTypeById = (id: number, items: any[] = hierarchicalTaskTypes.value const loadDesignersForItem = async (item: TaskTypeItem) => { if (!item.taskTypeId) return - const typeInfo = taskTypes.value.find(t => t.id === item.taskTypeId) + const typeInfo = getTaskTypeInfo(item.taskTypeId) if (!typeInfo || !typeInfo.allowedDeptIds) return // 简化处理:取第一个允许的部门ID @@ -796,7 +799,7 @@ const loadDesignersForItem = async (item: TaskTypeItem) => { const getDesignersForItem = (item: TaskTypeItem) => { if (!item.taskTypeId) return [] - const typeInfo = taskTypes.value.find(t => t.id === item.taskTypeId) + const typeInfo = getTaskTypeInfo(item.taskTypeId) if (!typeInfo || !typeInfo.allowedDeptIds) return [] const deptIds = typeInfo.allowedDeptIds.split(',') @@ -856,7 +859,7 @@ const generateTitle = () => { // 5. 需求类型(第一个任务类型名称) if (formData.taskTypes.length > 0 && formData.taskTypes[0].taskTypeId) { - const taskType = taskTypes.value.find((t: any) => t.id === formData.taskTypes[0].taskTypeId) + const taskType = getTaskTypeInfo(formData.taskTypes[0].taskTypeId) if (taskType) { parts.push(taskType.name) } @@ -890,7 +893,7 @@ const estimatedScore = computed(() => { for (const item of formData.taskTypes) { if (item.taskTypeId && item.quantity > 0) { - const selectedType = taskTypes.value.find(t => t.id === item.taskTypeId) + const selectedType = getTaskTypeInfo(item.taskTypeId) if (selectedType) { totalScore += (selectedType.unitScore || 0) * item.quantity } @@ -906,7 +909,7 @@ const estimatedTotalHours = computed(() => { for (const item of formData.taskTypes) { if (item.taskTypeId && item.quantity > 0) { - const selectedType = taskTypes.value.find(t => t.id === item.taskTypeId) + const selectedType = getTaskTypeInfo(item.taskTypeId) if (selectedType && selectedType.estimatedHours) { totalHours += selectedType.estimatedHours * item.quantity } @@ -994,7 +997,7 @@ const pipelineGroups = computed(() => { for (const taskType of formData.taskTypes) { if (!taskType.taskTypeId || !taskType.quantity) continue - const typeInfo = taskTypes.value.find(t => t.id === taskType.taskTypeId) + const typeInfo = getTaskTypeInfo(taskType.taskTypeId) if (!typeInfo) continue // 获取接单部门配置