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:
@@ -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,说明是编辑已有的场地
|
||||
|
||||
@@ -174,6 +174,11 @@
|
||||
{{ row.maxParticipants || 0 }}
|
||||
</template>
|
||||
</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
|
||||
prop="createTime"
|
||||
label="创建时间"
|
||||
@@ -493,6 +498,7 @@ const total = ref(0)
|
||||
const selection = ref([])
|
||||
const competitionList = ref([])
|
||||
const venueList = ref([])
|
||||
const allVenuesCache = ref(new Map()) // 全局场地缓存
|
||||
const dialogVisible = ref(false)
|
||||
const detailVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
@@ -617,6 +623,8 @@ const fetchData = async () => {
|
||||
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 '-'
|
||||
|
||||
@@ -123,10 +123,11 @@
|
||||
<div v-if="scope.row.hint" class="row-hint">{{ scope.row.hint }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="participantCategory" label="参人/单位" width="100"></el-table-column>
|
||||
<el-table-column prop="teamCount" label="队伍" width="80" align="center"></el-table-column>
|
||||
<el-table-column prop="singleTeamPeople" label="报名人数" width="120" align="center"></el-table-column>
|
||||
<el-table-column prop="estimatedDuration" label="预计时长(分钟)" width="150" align="center"></el-table-column>
|
||||
<el-table-column prop="projectType" label="单人/集体" width="100" align="center"></el-table-column>
|
||||
<el-table-column prop="athleteCount" label="人数/集体" width="100" 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="100" align="center"></el-table-column>
|
||||
<el-table-column prop="projectCode" label="项目编码" width="120" align="center"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
@@ -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 {
|
||||
// 如果缓存中没有(理论上<E8AEBA><E4B88A><EFBFBD>应该发生),添加基本信息
|
||||
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 {
|
||||
// 使用缓存的参赛者列表
|
||||
|
||||
Reference in New Issue
Block a user