fix: 子任务分组显示真实部门名称

This commit is contained in:
Your Name 2026-01-06 20:55:38 +08:00
parent acec519086
commit 2084dfe1fc

View File

@ -522,6 +522,7 @@ import * as userApi from '@/api/user'
import * as taskApi from '@/api/task'
import * as configApi from '@/api/config'
import * as uploadApi from '@/api/upload'
import * as departmentApi from '@/api/department'
import { getSystemConfigsMapByGroup } from '@/api/system'
import { uploadFilesToS3 } from '@/api/file'
import type { FormInstance } from 'ant-design-vue'
@ -731,6 +732,9 @@ const categories = computed(() => configStore.categories)
// 层级任务类型数据
const hierarchicalTaskTypes = ref<any[]>([])
// 部门列表数据
const departmentList = ref<departmentApi.DepartmentOverview[]>([])
// 加载层级任务类型数据
const loadHierarchicalTaskTypes = async () => {
try {
@ -743,6 +747,18 @@ const loadHierarchicalTaskTypes = async () => {
}
}
// 加载部门列表数据
const loadDepartmentList = async () => {
try {
const response = await departmentApi.getDepartmentList()
if (response && response.data) {
departmentList.value = response.data
}
} catch (error) {
console.error('加载部门列表失败:', error)
}
}
// 构建级联选择器选项(三级结构)
const taskTypeCascaderOptions = computed<CascaderOption[]>(() => {
const buildOptions = (items: any[]): CascaderOption[] => {
@ -1114,13 +1130,25 @@ const pipelineGroups = computed(() => {
const getDeptNameFromIds = (deptIds: string): string => {
if (!deptIds) return '所有部门'
// 这里可以从部门列表中查找,暂时简化处理
// TODO: 从系统中获取部门名称
const ids = deptIds.split(',')
if (ids.length === 1) {
return `部门 ${ids[0]}`
const ids = deptIds.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id))
if (ids.length === 0) return '所有部门'
// 从部门列表中查找名称
const deptNames = ids.map(id => {
const dept = departmentList.value.find(d => d.id === id)
return dept ? dept.deptName : `部门${id}`
})
// 如果只有一个部门,显示部门名称
if (deptNames.length === 1) {
return deptNames[0]
}
return `${ids.length}个部门`
// 如果有多个部门,显示全部名称(用逗号分隔)
if (deptNames.length <= 3) {
return deptNames.join('、')
}
// 如果部门太多,显示前2个加省略
return `${deptNames.slice(0, 2).join('、')}等${deptNames.length}个部门`
}
// 流水线总积分
@ -1676,7 +1704,8 @@ onMounted(async () => {
loadTeamScore(),
loadTaskSubTypes(),
loadReleaseTypeConfig(),
loadHierarchicalTaskTypes()
loadHierarchicalTaskTypes(),
loadDepartmentList()
])
// 检查是否是编辑模式