fix: 修复三级分类选择后积分和时效不显示的问题 - 将getTaskTypeInfo改为递归查找层级数据
This commit is contained in:
parent
0f5c77d73a
commit
6a1c54913e
2
frontend/src/types/components.d.ts
vendored
2
frontend/src/types/components.d.ts
vendored
@ -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']
|
||||
|
||||
@ -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
|
||||
|
||||
// 获取接单部门配置
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user