From e5b028f084074c16a90cd682f7cb12a011dbbcfe Mon Sep 17 00:00:00 2001 From: DevOps Date: Tue, 6 Jan 2026 15:17:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=BA=E5=9C=B0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B(venueType)=E5=8A=A0=E8=BD=BD=E5=92=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在loadVenues中添加venueType字段映射,确保从后端加载时正确回显 - 在saveVenues中添加venueType字段,确保保存时正确提交 - 修复附件上传headers认证问题 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- src/views/martial/competition/index.vue | 9 +++-- src/views/martial/project/index.vue | 38 +++++++++++++++++++ src/views/martial/registration/index.vue | 47 ++++++++++-------------- 3 files changed, 64 insertions(+), 30 deletions(-) diff --git a/src/views/martial/competition/index.vue b/src/views/martial/competition/index.vue index 44bb8e9..4f13a04 100644 --- a/src/views/martial/competition/index.vue +++ b/src/views/martial/competition/index.vue @@ -1003,7 +1003,7 @@ export default { propsHttp: { res: 'data', }, - headers: { 'Blade-Auth': 'bearer ' + getToken() }, + action: '/blade-resource/oss/endpoint/put-file' } ] @@ -1335,7 +1335,8 @@ export default { venueCode: item.venueCode, capacity: item.capacity, location: item.location, - remark: item.facilities || '' + remark: item.facilities || '', + venueType: item.venueType || 'indoor' })); console.log('✅ 加载的场地列表:', this.formData.venues); console.log('✅ 场地数量:', this.formData.venues.length); @@ -1407,6 +1408,7 @@ export default { handleOpenAttachmentUpload(type) { this.currentAttachmentType = type; this.attachmentUploadForm = {}; + this.attachmentUploadOption.column[0].headers = { "Blade-Auth": "bearer " + getToken() }; this.attachmentUploadDialogVisible = true; }, @@ -1862,7 +1864,8 @@ export default { venueCode: venue.venueCode, capacity: venue.capacity || 100, location: venue.location || '', - facilities: venue.remark || '' + facilities: venue.remark || '', + venueType: venue.venueType || 'indoor' }; // 如果有 id,说明是编辑已有的场地 diff --git a/src/views/martial/project/index.vue b/src/views/martial/project/index.vue index e6a440a..cd15df7 100644 --- a/src/views/martial/project/index.vue +++ b/src/views/martial/project/index.vue @@ -174,6 +174,11 @@ {{ row.maxParticipants || 0 }} + + + { if (res.data && res.data.data) { tableData.value = res.data.data.records || [] total.value = res.data.data.total || 0 + // 加载项目对应的场地信息 + await loadVenuesForProjects(tableData.value) } } catch (error) { ElMessage.error('获取数据失败') @@ -626,6 +634,24 @@ const fetchData = async () => { } } +// 加载项目对应的场地信息 +const loadVenuesForProjects = async (projects) => { + // 获取所有不同的赛事ID + const competitionIds = [...new Set(projects.map(p => p.competitionId).filter(Boolean))] + for (const compId of competitionIds) { + try { + const res = await getVenuesByCompetition(compId) + const venues = res.data?.data?.records || [] + // 缓存场地信息 + venues.forEach(v => { + allVenuesCache.value.set(v.id, v.venueName) + }) + } catch (err) { + console.error('加载场地失败:', err) + } + } +} + // 搜索 const handleSearch = () => { queryParams.current = 1 @@ -844,6 +870,18 @@ const getCompetitionName = (competitionId) => { return competition ? competition.competitionName : '-' } +const getVenueName = (venueId) => { + if (!venueId) return '-' + // 先从当前场地列表查找 + let venue = venueList.value.find(item => item.id === venueId) + if (venue) return venue.venueName + // 再从全局缓存查找 + if (allVenuesCache.value.has(venueId)) { + return allVenuesCache.value.get(venueId) + } + return '-' +} + // 格式化日期 const formatDate = (date) => { if (!date) return '-' diff --git a/src/views/martial/registration/index.vue b/src/views/martial/registration/index.vue index 9774158..8009c42 100644 --- a/src/views/martial/registration/index.vue +++ b/src/views/martial/registration/index.vue @@ -123,10 +123,11 @@
{{ scope.row.hint }}
- - - - + + + + + @@ -387,39 +388,31 @@ export default { // 使用缓存的参赛者列表 const participants = await this.getParticipants() - // 2. 按项目ID分组 - const projectMap = new Map() + // 预加载项目信息 + await this.preloadProjectInfo(participants) + + // 按项目ID分组统计人数 + const projectAthleteCount = new Map() participants.forEach(athlete => { - // 兼容驼峰和下划线命名 const projectId = athlete.projectId || athlete.project_id if (projectId) { - if (!projectMap.has(projectId)) { - projectMap.set(projectId, []) - } - projectMap.get(projectId).push(athlete) + projectAthleteCount.set(projectId, (projectAthleteCount.get(projectId) || 0) + 1) } }) - // 3. 从缓存中获取项目信息并统计(项目信息已经在 loadRegistrationStats 中预加载) + // 从缓存中获取项目信息并构建统计数据 const projectStats = [] - for (const [projectId, athleteList] of projectMap) { + for (const [projectId, count] of projectAthleteCount) { const project = this.projectCache.get(projectId) if (project) { + const projectType = project.type || 1 // 1=单人, 2=集体 projectStats.push({ projectName: project.projectName || project.project_name || '未知项目', - participantCategory: project.category || '', - teamCount: 1, // 简化处理,设为1 - singleTeamPeople: athleteList.length, - estimatedDuration: project.estimatedDuration || project.estimated_duration || 0 - }) - } else { - // 如果缓存中没有(理论上���应该发生),添加基本信息 - projectStats.push({ - projectName: `项目ID:${projectId}`, - participantCategory: '', - teamCount: 1, - singleTeamPeople: athleteList.length, - estimatedDuration: 0 + projectType: projectType === 1 ? '单人' : '集体', + athleteCount: count, + groupCount: projectType === 2 ? count : '-', // 集体项目显示组数,单人显示- + estimatedDuration: project.estimatedDuration || project.estimated_duration || 0, + projectCode: project.projectCode || project.project_code || '' }) } } @@ -432,7 +425,7 @@ export default { } }, - // 加载金额统计(该赛事所有单位的报名金额) + // 加载金额统计(该赛事所有单位的报名金额) async loadAmountStats() { try { // 使用缓存的参赛者列表