fix: 修复场地类型(venueType)加载和保存问题

- 在loadVenues中添加venueType字段映射,确保从后端加载时正确回显
- 在saveVenues中添加venueType字段,确保保存时正确提交
- 修复附件上传headers认证问题

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
DevOps
2026-01-06 15:17:28 +08:00
parent 6385acd43b
commit e5b028f084
3 changed files with 64 additions and 30 deletions

View File

@@ -1003,7 +1003,7 @@ export default {
propsHttp: { propsHttp: {
res: 'data', res: 'data',
}, },
headers: { 'Blade-Auth': 'bearer ' + getToken() },
action: '/blade-resource/oss/endpoint/put-file' action: '/blade-resource/oss/endpoint/put-file'
} }
] ]
@@ -1335,7 +1335,8 @@ export default {
venueCode: item.venueCode, venueCode: item.venueCode,
capacity: item.capacity, capacity: item.capacity,
location: item.location, location: item.location,
remark: item.facilities || '' remark: item.facilities || '',
venueType: item.venueType || 'indoor'
})); }));
console.log('✅ 加载的场地列表:', this.formData.venues); console.log('✅ 加载的场地列表:', this.formData.venues);
console.log('✅ 场地数量:', this.formData.venues.length); console.log('✅ 场地数量:', this.formData.venues.length);
@@ -1407,6 +1408,7 @@ export default {
handleOpenAttachmentUpload(type) { handleOpenAttachmentUpload(type) {
this.currentAttachmentType = type; this.currentAttachmentType = type;
this.attachmentUploadForm = {}; this.attachmentUploadForm = {};
this.attachmentUploadOption.column[0].headers = { "Blade-Auth": "bearer " + getToken() };
this.attachmentUploadDialogVisible = true; this.attachmentUploadDialogVisible = true;
}, },
@@ -1862,7 +1864,8 @@ export default {
venueCode: venue.venueCode, venueCode: venue.venueCode,
capacity: venue.capacity || 100, capacity: venue.capacity || 100,
location: venue.location || '', location: venue.location || '',
facilities: venue.remark || '' facilities: venue.remark || '',
venueType: venue.venueType || 'indoor'
}; };
// 如果有 id说明是编辑已有的场地 // 如果有 id说明是编辑已有的场地

View File

@@ -174,6 +174,11 @@
{{ row.maxParticipants || 0 }} {{ row.maxParticipants || 0 }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="所属场地" width="120" align="center">
<template #default="{ row }">
<span>{{ getVenueName(row.venueId) }}</span>
</template>
</el-table-column>
<el-table-column <el-table-column
prop="createTime" prop="createTime"
label="创建时间" label="创建时间"
@@ -493,6 +498,7 @@ const total = ref(0)
const selection = ref([]) const selection = ref([])
const competitionList = ref([]) const competitionList = ref([])
const venueList = ref([]) const venueList = ref([])
const allVenuesCache = ref(new Map()) // 全局场地缓存
const dialogVisible = ref(false) const dialogVisible = ref(false)
const detailVisible = ref(false) const detailVisible = ref(false)
const dialogTitle = ref('') const dialogTitle = ref('')
@@ -617,6 +623,8 @@ const fetchData = async () => {
if (res.data && res.data.data) { if (res.data && res.data.data) {
tableData.value = res.data.data.records || [] tableData.value = res.data.data.records || []
total.value = res.data.data.total || 0 total.value = res.data.data.total || 0
// 加载项目对应的场地信息
await loadVenuesForProjects(tableData.value)
} }
} catch (error) { } catch (error) {
ElMessage.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 = () => { const handleSearch = () => {
queryParams.current = 1 queryParams.current = 1
@@ -844,6 +870,18 @@ const getCompetitionName = (competitionId) => {
return competition ? competition.competitionName : '-' 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) => { const formatDate = (date) => {
if (!date) return '-' if (!date) return '-'

View File

@@ -123,10 +123,11 @@
<div v-if="scope.row.hint" class="row-hint">{{ scope.row.hint }}</div> <div v-if="scope.row.hint" class="row-hint">{{ scope.row.hint }}</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="participantCategory" label="人/单位" width="100"></el-table-column> <el-table-column prop="projectType" label="人/集体" width="100" align="center"></el-table-column>
<el-table-column prop="teamCount" label="队伍" width="80" align="center"></el-table-column> <el-table-column prop="athleteCount" label="人数/集体" width="100" align="center"></el-table-column>
<el-table-column prop="singleTeamPeople" label="报名人数" width="120" align="center"></el-table-column> <el-table-column prop="groupCount" label="数" width="80" align="center"></el-table-column>
<el-table-column prop="estimatedDuration" label="预计时长(分)" width="150" align="center"></el-table-column> <el-table-column prop="estimatedDuration" label="时长(分)" width="100" align="center"></el-table-column>
<el-table-column prop="projectCode" label="项目编码" width="120" align="center"></el-table-column>
</el-table> </el-table>
</div> </div>
@@ -387,39 +388,31 @@ export default {
// 使用缓存的参赛者列表 // 使用缓存的参赛者列表
const participants = await this.getParticipants() const participants = await this.getParticipants()
// 2. 按项目ID分组 // 预加载项目信息
const projectMap = new Map() await this.preloadProjectInfo(participants)
// 按项目ID分组统计人数
const projectAthleteCount = new Map()
participants.forEach(athlete => { participants.forEach(athlete => {
// 兼容驼峰和下划线命名
const projectId = athlete.projectId || athlete.project_id const projectId = athlete.projectId || athlete.project_id
if (projectId) { if (projectId) {
if (!projectMap.has(projectId)) { projectAthleteCount.set(projectId, (projectAthleteCount.get(projectId) || 0) + 1)
projectMap.set(projectId, [])
}
projectMap.get(projectId).push(athlete)
} }
}) })
// 3. 从缓存中获取项目信息并统计(项目信息已经在 loadRegistrationStats 中预加载) // 从缓存中获取项目信息并构建统计数据
const projectStats = [] const projectStats = []
for (const [projectId, athleteList] of projectMap) { for (const [projectId, count] of projectAthleteCount) {
const project = this.projectCache.get(projectId) const project = this.projectCache.get(projectId)
if (project) { if (project) {
const projectType = project.type || 1 // 1=单人, 2=集体
projectStats.push({ projectStats.push({
projectName: project.projectName || project.project_name || '未知项目', projectName: project.projectName || project.project_name || '未知项目',
participantCategory: project.category || '', projectType: projectType === 1 ? '单人' : '集体',
teamCount: 1, // 简化处理设为1 athleteCount: count,
singleTeamPeople: athleteList.length, groupCount: projectType === 2 ? count : '-', // 集体项目显示组数,单人显示-
estimatedDuration: project.estimatedDuration || project.estimated_duration || 0 estimatedDuration: project.estimatedDuration || project.estimated_duration || 0,
}) projectCode: project.projectCode || project.project_code || ''
} else {
// 如果缓存中没有理论上<E8AEBA><E4B88A><EFBFBD>应该发生添加基本信息
projectStats.push({
projectName: `项目ID:${projectId}`,
participantCategory: '',
teamCount: 1,
singleTeamPeople: athleteList.length,
estimatedDuration: 0
}) })
} }
} }
@@ -432,7 +425,7 @@ export default {
} }
}, },
// 加载金额统计(该赛事所有单位的报名金额) // 加载金额统计(该赛事所有单位的报名金额)
async loadAmountStats() { async loadAmountStats() {
try { try {
// 使用缓存的参赛者列表 // 使用缓存的参赛者列表