This commit is contained in:
2025-12-12 01:44:41 +08:00
parent 21abcaff53
commit 2f1d732a36
46 changed files with 7756 additions and 484 deletions

View File

@@ -9,7 +9,7 @@
:class="{ active: currentCategory === index }"
@click="currentCategory = index"
>
{{ category }}
{{ category.name }}
</view>
</view>
@@ -38,33 +38,94 @@
</template>
<script>
import resultAPI from '@/api/result.js'
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
eventId: '',
currentCategory: 0,
categories: ['男子散打', '男子套路', '女子散打', '女子套路'],
scores: {
0: [
{ rank: 1, name: '张三', team: '北京队', score: '9.85' },
{ rank: 2, name: '李四', team: '上海队', score: '9.72' },
{ rank: 3, name: '王五', team: '广东队', score: '9.68' },
{ rank: 4, name: '赵六', team: '天津队', score: '9.55' },
{ rank: 5, name: '刘七', team: '江苏队', score: '9.48' }
],
1: [
{ rank: 1, name: '孙八', team: '浙江队', score: '9.90' },
{ rank: 2, name: '周九', team: '湖北队', score: '9.75' },
{ rank: 3, name: '吴十', team: '河北队', score: '9.60' }
],
2: [],
3: []
}
categories: [],
scores: {}
};
},
computed: {
currentScores() {
return this.scores[this.currentCategory] || [];
}
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadCategories(options.eventId)
}
},
watch: {
currentCategory(newVal) {
if (this.categories[newVal] && this.categories[newVal].id) {
this.loadScoresByCategory(this.eventId, this.categories[newVal].id)
}
}
},
methods: {
/**
* 加载项目分类
*/
async loadCategories(eventId) {
try {
const res = await competitionAPI.getProjectList({ competitionId: eventId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 提取项目分类
this.categories = list.map(item => ({
id: item.id,
name: item.name || item.projectName
}))
// 加载第一个分类的成绩
if (this.categories.length > 0) {
this.loadScoresByCategory(eventId, this.categories[0].id)
}
} catch (err) {
console.error('加载项目分类失败:', err)
}
},
/**
* 加载指定分类的成绩
*/
async loadScoresByCategory(eventId, projectId) {
try {
const res = await resultAPI.getResultList(eventId, { projectId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
const categoryIndex = this.currentCategory
this.scores[categoryIndex] = list.map((item, index) => ({
rank: item.rank || item.ranking || (index + 1),
name: item.athleteName || item.name,
team: item.teamName || item.team,
score: item.score || item.finalScore || '0.00'
}))
// 触发视图更新
this.$forceUpdate()
} catch (err) {
console.error('加载成绩失败:', err)
}
}
}
};
</script>