fix bugs
This commit is contained in:
@@ -105,6 +105,7 @@ export default {
|
||||
const {
|
||||
token,
|
||||
userRole,
|
||||
refereeType,
|
||||
matchId,
|
||||
matchName,
|
||||
matchTime,
|
||||
@@ -121,6 +122,7 @@ export default {
|
||||
// 保存用户信息到全局数据
|
||||
getApp().globalData = {
|
||||
userRole, // 'pub' 或 'admin'
|
||||
refereeType, // 1-裁判长, 2-普通裁判
|
||||
matchCode: this.matchCode,
|
||||
matchId,
|
||||
matchName,
|
||||
@@ -129,7 +131,7 @@ export default {
|
||||
judgeName,
|
||||
venueId, // 普通评委有场地,裁判长为null
|
||||
venueName,
|
||||
projects, // 分配的项目列表
|
||||
projects, // 分配的项目列表(从登录接口返回)
|
||||
currentProjectIndex: 0 // 当前选中的项目索引
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@ export default {
|
||||
},
|
||||
judgeId: '',
|
||||
projectId: '',
|
||||
competitionId: '',
|
||||
venueId: '',
|
||||
currentScore: 8.000,
|
||||
note: '',
|
||||
minScore: 5.0,
|
||||
@@ -137,10 +139,9 @@ export default {
|
||||
|
||||
// 加载评委ID和项目ID
|
||||
this.judgeId = globalData.judgeId
|
||||
const projects = globalData.projects || []
|
||||
const currentIndex = globalData.currentProjectIndex || 0
|
||||
const currentProject = projects[currentIndex] || {}
|
||||
this.projectId = currentProject.projectId
|
||||
this.projectId = globalData.currentProjectId || ''
|
||||
this.competitionId = globalData.matchId || globalData.matchCode || ''
|
||||
this.venueId = globalData.currentVenueId || globalData.venueId || ''
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
@@ -148,6 +149,8 @@ export default {
|
||||
athlete: this.player,
|
||||
judgeId: this.judgeId,
|
||||
projectId: this.projectId,
|
||||
competitionId: this.competitionId,
|
||||
venueId: this.venueId,
|
||||
initialScore: this.currentScore
|
||||
})
|
||||
}
|
||||
@@ -166,9 +169,12 @@ export default {
|
||||
projectId: this.projectId
|
||||
})
|
||||
|
||||
// 为每个扣分项添加 checked 状态
|
||||
this.deductions = (response.data || []).map(item => ({
|
||||
...item,
|
||||
// 为每个扣分项添加 checked 状态,并映射字段名
|
||||
const records = response.data?.records || []
|
||||
this.deductions = records.map(item => ({
|
||||
deductionId: item.id,
|
||||
deductionName: item.itemName,
|
||||
deductionScore: parseFloat(item.deductionPoint || 0),
|
||||
checked: false
|
||||
}))
|
||||
|
||||
@@ -187,7 +193,20 @@ export default {
|
||||
},
|
||||
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
if (config.debug) {
|
||||
console.log('返回上一页')
|
||||
}
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: (err) => {
|
||||
console.error('返回失败:', err)
|
||||
// 如果返回失败,尝试跳转到评分列表页
|
||||
uni.redirectTo({
|
||||
url: '/pages/score-list/score-list'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
decreaseScore() {
|
||||
@@ -216,14 +235,27 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 收集选中的扣分项
|
||||
// 验证必需字段
|
||||
if (!this.competitionId) {
|
||||
uni.showToast({
|
||||
title: '缺少比赛ID,请重新登录',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.projectId) {
|
||||
uni.showToast({
|
||||
title: '缺少项目ID,请返回重新选择',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 收集选中的扣分项ID
|
||||
const selectedDeductions = this.deductions
|
||||
.filter(item => item.checked)
|
||||
.map(item => ({
|
||||
deductionId: item.deductionId,
|
||||
deductionName: item.deductionName,
|
||||
deductionScore: item.deductionScore
|
||||
}))
|
||||
.map(item => item.deductionId)
|
||||
|
||||
try {
|
||||
uni.showLoading({
|
||||
@@ -231,16 +263,27 @@ export default {
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 提交评分
|
||||
// Mock模式:调用 mock/score.js 的 submitScore 函数
|
||||
// API模式:调用 api/score.js 的 submitScore 函数(POST /martial/score/submit)
|
||||
const response = await dataAdapter.getData('submitScore', {
|
||||
// 准备提交数据
|
||||
const submitData = {
|
||||
athleteId: this.player.athleteId,
|
||||
judgeId: this.judgeId,
|
||||
projectId: this.projectId,
|
||||
competitionId: this.competitionId,
|
||||
venueId: this.venueId,
|
||||
score: this.currentScore,
|
||||
deductions: selectedDeductions,
|
||||
note: this.note
|
||||
})
|
||||
}
|
||||
|
||||
// 调试日志:打印提交数据
|
||||
if (config.debug) {
|
||||
console.log('准备提交评分数据:', submitData)
|
||||
}
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 提交评分
|
||||
// Mock模式:调用 mock/score.js 的 submitScore 函数
|
||||
// API模式:调用 api/score.js 的 submitScore 函数(POST /martial/score/submit)
|
||||
const response = await dataAdapter.getData('submitScore', submitData)
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
@@ -301,12 +344,19 @@ export default {
|
||||
|
||||
.nav-left {
|
||||
position: absolute;
|
||||
left: 30rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 120rpx;
|
||||
height: 90rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 10;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav-left:active {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.back-icon {
|
||||
|
||||
@@ -18,11 +18,27 @@
|
||||
<!-- 场地和项目选择 -->
|
||||
<view class="venue-section">
|
||||
<view class="venue-header">
|
||||
<view class="venue-tab active">{{ venueInfo.name }}</view>
|
||||
<view
|
||||
class="venue-tab"
|
||||
:class="{ active: index === currentVenueIndex }"
|
||||
v-for="(venue, index) in venues"
|
||||
:key="venue.id"
|
||||
@click="switchVenue(index)"
|
||||
>
|
||||
{{ venue.venueName }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="project-section">
|
||||
<view class="project-btn active">{{ projectInfo.name }}</view>
|
||||
<view
|
||||
class="project-btn"
|
||||
:class="{ active: index === currentProjectIndex }"
|
||||
v-for="(project, index) in projects"
|
||||
:key="project.id"
|
||||
@click="switchProject(index)"
|
||||
>
|
||||
{{ project.projectName }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -39,28 +55,29 @@
|
||||
class="player-card"
|
||||
v-for="player in players"
|
||||
:key="player.athleteId"
|
||||
@click="handlePlayerClick(player)"
|
||||
>
|
||||
<view class="player-header">
|
||||
<view class="player-name">{{ player.name }}</view>
|
||||
|
||||
<!-- 已评分:显示我的评分和总分 -->
|
||||
<view class="player-scores" v-if="player.scored">
|
||||
<text class="my-score">我的评分:{{ player.myScore }}</text>
|
||||
<text class="total-score">总分:{{ player.totalScore }}</text>
|
||||
<!-- 裁判长:显示总分和已评分裁判数 -->
|
||||
<view class="player-scores" v-if="refereeType === 1">
|
||||
<text class="total-score">总分:{{ player.totalScore || '未评分' }}</text>
|
||||
<text class="judge-count">已评分:{{ player.scoredJudgeCount || 0 }}人</text>
|
||||
</view>
|
||||
|
||||
<!-- 未评分:显示评分按钮 -->
|
||||
<!-- 普通裁判:显示评分按钮 -->
|
||||
<button
|
||||
class="score-btn"
|
||||
v-else
|
||||
@click="goToScoreDetail(player)"
|
||||
@click.stop="goToScoreDetail(player)"
|
||||
>
|
||||
评分
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:{{ player.idCard }}</view>
|
||||
<view class="info-item" v-if="player.idCard">身份证:{{ player.idCard }}</view>
|
||||
<view class="info-item">队伍:{{ player.team }}</view>
|
||||
<view class="info-item">编号:{{ player.number }}</view>
|
||||
</view>
|
||||
@@ -89,6 +106,12 @@ export default {
|
||||
name: ''
|
||||
},
|
||||
judgeId: '',
|
||||
matchId: '',
|
||||
refereeType: 2, // 裁判类型(1-裁判长, 2-普通裁判)
|
||||
venues: [], // 所有场地列表
|
||||
currentVenueIndex: 0, // 当前选中的场地索引
|
||||
projects: [], // 所有项目列表
|
||||
currentProjectIndex: 0, // 当前选中的项目索引
|
||||
players: [],
|
||||
scoredCount: 0,
|
||||
totalCount: 0
|
||||
@@ -96,44 +119,96 @@ export default {
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
// 获取全局数据
|
||||
const app = getApp()
|
||||
const globalData = app.globalData || {}
|
||||
try {
|
||||
// 获取全局数据
|
||||
const app = getApp()
|
||||
const globalData = app.globalData || {}
|
||||
|
||||
// 加载比赛信息
|
||||
this.matchInfo = {
|
||||
name: globalData.matchName || '比赛名称',
|
||||
time: globalData.matchTime || '比赛时间'
|
||||
}
|
||||
// 加载比赛信息
|
||||
this.matchInfo = {
|
||||
name: globalData.matchName || '比赛名称',
|
||||
time: globalData.matchTime || '比赛时间'
|
||||
}
|
||||
|
||||
// 加载场地信息
|
||||
this.venueInfo = {
|
||||
id: globalData.venueId,
|
||||
name: globalData.venueName || '场地'
|
||||
}
|
||||
this.judgeId = globalData.judgeId
|
||||
this.matchId = globalData.matchId || globalData.matchCode
|
||||
this.refereeType = globalData.refereeType || 2 // 默认为普通裁判
|
||||
|
||||
// 加载项目信息
|
||||
const projects = globalData.projects || []
|
||||
const currentIndex = globalData.currentProjectIndex || 0
|
||||
const currentProject = projects[currentIndex] || {}
|
||||
this.projectInfo = {
|
||||
id: currentProject.projectId,
|
||||
name: currentProject.projectName || '项目'
|
||||
}
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('初始化数据:', {
|
||||
judgeId: this.judgeId,
|
||||
matchId: this.matchId,
|
||||
matchCode: globalData.matchCode,
|
||||
refereeType: this.refereeType
|
||||
})
|
||||
}
|
||||
|
||||
this.judgeId = globalData.judgeId
|
||||
// 检查必要参数
|
||||
if (!this.matchId) {
|
||||
throw new Error('缺少比赛ID,请重新登录')
|
||||
}
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('评分列表页加载:', {
|
||||
judgeId: this.judgeId,
|
||||
venueId: this.venueInfo.id,
|
||||
projectId: this.projectInfo.id
|
||||
// 显示加载提示
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 1. 先获取场地列表
|
||||
const venuesResponse = await dataAdapter.getData('getVenues', {
|
||||
competitionId: this.matchId
|
||||
})
|
||||
this.venues = venuesResponse.data?.records || []
|
||||
this.currentVenueIndex = 0
|
||||
|
||||
// 设置当前场地信息(使用第一条数据的ID)
|
||||
if (this.venues.length > 0) {
|
||||
this.venueInfo = {
|
||||
id: this.venues[0].id,
|
||||
name: this.venues[0].name
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 再获取项目列表
|
||||
const projectsResponse = await dataAdapter.getData('getProjects', {
|
||||
competitionId: this.matchId
|
||||
})
|
||||
this.projects = projectsResponse.data?.records || []
|
||||
this.currentProjectIndex = 0
|
||||
|
||||
// 设置当前项目信息(使用第一条数据的ID)
|
||||
if (this.projects.length > 0) {
|
||||
this.projectInfo = {
|
||||
id: this.projects[0].id,
|
||||
name: this.projects[0].projectName
|
||||
}
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('评分列表页加载:', {
|
||||
judgeId: this.judgeId,
|
||||
venueId: this.venueInfo.id,
|
||||
projectId: this.projectInfo.id,
|
||||
venuesCount: this.venues.length,
|
||||
projectsCount: this.projects.length
|
||||
})
|
||||
}
|
||||
|
||||
// 3. 最后加载选手列表(使用场地和项目的第一条数据ID)
|
||||
await this.loadPlayers()
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('页面加载失败:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
// 加载选手列表
|
||||
await this.loadPlayers()
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -146,9 +221,10 @@ export default {
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 获取选手列表
|
||||
// Mock模式:调用 mock/athlete.js 的 getMyAthletes 函数
|
||||
// API模式:调用 api/athlete.js 的 getMyAthletes 函数(GET /api/mini/athletes)
|
||||
// API模式:调用 api/athlete.js 的 getMyAthletes 函数(GET /api/mini/score/athletes)
|
||||
const response = await dataAdapter.getData('getMyAthletes', {
|
||||
judgeId: this.judgeId,
|
||||
refereeType: this.refereeType, // 传递裁判类型
|
||||
venueId: this.venueInfo.id,
|
||||
projectId: this.projectInfo.id
|
||||
})
|
||||
@@ -182,14 +258,108 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理选手卡片点击
|
||||
* - 裁判长:跳转到查看详情页面
|
||||
* - 普通裁判:不处理(通过评分按钮跳转)
|
||||
*/
|
||||
handlePlayerClick(player) {
|
||||
if (this.refereeType === 1) {
|
||||
// 裁判长:查看评分详情
|
||||
this.goToScoreDetail(player)
|
||||
}
|
||||
// 普通裁判不处理卡片点击,只能通过评分按钮跳转
|
||||
},
|
||||
|
||||
goToScoreDetail(player) {
|
||||
// 保存当前选手信息到全局数据
|
||||
// 保存当前选手信息、项目ID和场地ID到全局数据
|
||||
const app = getApp()
|
||||
app.globalData.currentAthlete = player
|
||||
app.globalData.currentProjectId = this.projectInfo.id
|
||||
app.globalData.currentVenueId = this.venueInfo.id
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('进入评分详情:', {
|
||||
athleteId: player.athleteId,
|
||||
athleteName: player.name,
|
||||
projectId: this.projectInfo.id,
|
||||
projectName: this.projectInfo.name,
|
||||
venueId: this.venueInfo.id,
|
||||
venueName: this.venueInfo.name,
|
||||
refereeType: this.refereeType
|
||||
})
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/score-detail/score-detail'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换场地
|
||||
* @param {Number} index - 场地索引
|
||||
*/
|
||||
async switchVenue(index) {
|
||||
// 如果点击的是当前场地,不做处理
|
||||
if (index === this.currentVenueIndex) {
|
||||
return
|
||||
}
|
||||
|
||||
// 更新当前场地索引
|
||||
this.currentVenueIndex = index
|
||||
|
||||
// 更新当前场地信息
|
||||
const currentVenue = this.venues[index] || {}
|
||||
this.venueInfo = {
|
||||
id: currentVenue.id,
|
||||
name: currentVenue.name
|
||||
}
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('切换场地:', {
|
||||
index: index,
|
||||
venueId: this.venueInfo.id,
|
||||
venueName: this.venueInfo.name
|
||||
})
|
||||
}
|
||||
|
||||
// 重新加载选手列表
|
||||
await this.loadPlayers()
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换项目
|
||||
* @param {Number} index - 项目索引
|
||||
*/
|
||||
async switchProject(index) {
|
||||
// 如果点击的是当前项目,不做处理
|
||||
if (index === this.currentProjectIndex) {
|
||||
return
|
||||
}
|
||||
|
||||
// 更新当前项目索引
|
||||
this.currentProjectIndex = index
|
||||
|
||||
// 更新当前项目信息
|
||||
const currentProject = this.projects[index] || {}
|
||||
this.projectInfo = {
|
||||
id: currentProject.id,
|
||||
name: currentProject.projectName
|
||||
}
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('切换项目:', {
|
||||
index: index,
|
||||
projectId: this.projectInfo.id,
|
||||
projectName: this.projectInfo.name
|
||||
})
|
||||
}
|
||||
|
||||
// 重新加载选手列表
|
||||
await this.loadPlayers()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,26 +449,41 @@ export default {
|
||||
.venue-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 4rpx solid #1B7C5E;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
white-space: nowrap;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.venue-header::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.venue-tab {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
position: relative;
|
||||
padding: 20rpx 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: #666666;
|
||||
background-color: #F5F5F5;
|
||||
border-radius: 8rpx;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.venue-tab.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -24rpx;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 4rpx;
|
||||
.venue-tab:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.venue-tab.active {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #FFFFFF;
|
||||
background-color: #1B7C5E;
|
||||
}
|
||||
|
||||
@@ -310,7 +495,15 @@ export default {
|
||||
.project-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
white-space: nowrap;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.project-section::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.project-btn {
|
||||
@@ -321,6 +514,14 @@ export default {
|
||||
font-size: 28rpx;
|
||||
color: #1B7C5E;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.project-btn:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.project-btn.active {
|
||||
@@ -402,6 +603,12 @@ export default {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.judge-count {
|
||||
font-size: 24rpx;
|
||||
color: #1B7C5E;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.action-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user