feat(score): 支持点击分数直接输入编辑
This commit is contained in:
@@ -31,28 +31,22 @@
|
|||||||
<view class="score-control">
|
<view class="score-control">
|
||||||
<view class="control-btn decrease" @click="decreaseScore">
|
<view class="control-btn decrease" @click="decreaseScore">
|
||||||
<text class="btn-symbol">-</text>
|
<text class="btn-symbol">-</text>
|
||||||
<!-- <text class="btn-value">-0.001</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="score-display">
|
<view class="score-display" @click="showScoreInput">
|
||||||
<text class="current-score">{{ currentScore.toFixed(3) }}</text>
|
<text class="current-score">{{ currentScore.toFixed(3) }}</text>
|
||||||
|
<text class="edit-hint">点击编辑</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="control-btn increase" @click="increaseScore">
|
<view class="control-btn increase" @click="increaseScore">
|
||||||
<text class="btn-symbol">+</text>
|
<text class="btn-symbol">+</text>
|
||||||
<!-- <text class="btn-value">+0.001</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <view class="judge-tip">
|
|
||||||
裁判评分:保留3位小数点,超过上限或下限时,按钮置灰
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<!-- 扣分项 -->
|
<!-- 扣分项 -->
|
||||||
<view class="deduction-section">
|
<view class="deduction-section">
|
||||||
<view class="deduction-header">
|
<view class="deduction-header">
|
||||||
<text class="deduction-label">扣分项:</text>
|
<text class="deduction-label">扣分项:</text>
|
||||||
<!-- <text class="deduction-hint">扣分项多选</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="deduction-list">
|
<view class="deduction-list">
|
||||||
@@ -82,12 +76,35 @@
|
|||||||
v-model="note"
|
v-model="note"
|
||||||
maxlength="200"
|
maxlength="200"
|
||||||
/>
|
/>
|
||||||
<!-- <text class="optional-text">可不填</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 提交按钮 -->
|
<!-- 提交按钮 -->
|
||||||
<button class="submit-btn" @click="handleSubmit">提交</button>
|
<button class="submit-btn" @click="handleSubmit">提交</button>
|
||||||
|
|
||||||
|
<!-- 分数输入弹窗 -->
|
||||||
|
<view v-if="showInputModal" class="modal-overlay" @click="hideScoreInput">
|
||||||
|
<view class="modal-content" @click.stop>
|
||||||
|
<view class="modal-header">
|
||||||
|
<text class="modal-title">输入分数</text>
|
||||||
|
</view>
|
||||||
|
<view class="modal-body">
|
||||||
|
<input
|
||||||
|
type="digit"
|
||||||
|
class="score-input"
|
||||||
|
v-model="inputScore"
|
||||||
|
placeholder="请输入5-10之间的分数"
|
||||||
|
:focus="showInputModal"
|
||||||
|
@confirm="confirmScoreInput"
|
||||||
|
/>
|
||||||
|
<text class="input-hint">分数范围:{{ minScore }} - {{ maxScore }},保留3位小数</text>
|
||||||
|
</view>
|
||||||
|
<view class="modal-footer">
|
||||||
|
<button class="modal-btn cancel" @click="hideScoreInput">取消</button>
|
||||||
|
<button class="modal-btn confirm" @click="confirmScoreInput">确定</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -113,16 +130,16 @@ export default {
|
|||||||
note: '',
|
note: '',
|
||||||
minScore: 5.0,
|
minScore: 5.0,
|
||||||
maxScore: 10.0,
|
maxScore: 10.0,
|
||||||
deductions: []
|
deductions: [],
|
||||||
|
showInputModal: false,
|
||||||
|
inputScore: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
// 获取全局数据
|
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
const globalData = app.globalData || {}
|
const globalData = app.globalData || {}
|
||||||
|
|
||||||
// 加载当前选手信息(从 score-list 页面传递)
|
|
||||||
const currentAthlete = globalData.currentAthlete || {}
|
const currentAthlete = globalData.currentAthlete || {}
|
||||||
this.player = {
|
this.player = {
|
||||||
athleteId: currentAthlete.athleteId || '',
|
athleteId: currentAthlete.athleteId || '',
|
||||||
@@ -132,18 +149,15 @@ export default {
|
|||||||
number: currentAthlete.number || ''
|
number: currentAthlete.number || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果选手已评分,加载其原有评分
|
|
||||||
if (currentAthlete.scored && currentAthlete.myScore) {
|
if (currentAthlete.scored && currentAthlete.myScore) {
|
||||||
this.currentScore = currentAthlete.myScore
|
this.currentScore = currentAthlete.myScore
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载评委ID和项目ID
|
|
||||||
this.judgeId = globalData.judgeId
|
this.judgeId = globalData.judgeId
|
||||||
this.projectId = globalData.currentProjectId || ''
|
this.projectId = globalData.currentProjectId || ''
|
||||||
this.competitionId = globalData.matchId || globalData.matchCode || ''
|
this.competitionId = globalData.matchId || globalData.matchCode || ''
|
||||||
this.venueId = globalData.currentVenueId || globalData.venueId || ''
|
this.venueId = globalData.currentVenueId || globalData.venueId || ''
|
||||||
|
|
||||||
// 调试信息
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('评分详情页加载:', {
|
console.log('评分详情页加载:', {
|
||||||
athlete: this.player,
|
athlete: this.player,
|
||||||
@@ -155,22 +169,17 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载扣分项列表
|
|
||||||
await this.loadDeductions()
|
await this.loadDeductions()
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async loadDeductions() {
|
async loadDeductions() {
|
||||||
try {
|
try {
|
||||||
// 🔥 关键改动:使用 dataAdapter 获取扣分项列表
|
|
||||||
// Mock模式:调用 mock/score.js 的 getDeductions 函数
|
|
||||||
// API模式:调用 api/score.js 的 getDeductions 函数(GET /martial/deductionItem/list)
|
|
||||||
const response = await dataAdapter.getData('getDeductions', {
|
const response = await dataAdapter.getData('getDeductions', {
|
||||||
projectId: this.projectId
|
projectId: this.projectId
|
||||||
})
|
})
|
||||||
|
|
||||||
// 为每个扣分项添加 checked 状态,并映射字段名
|
const records = response.data && response.data.records ? response.data.records : []
|
||||||
const records = response.data?.records || []
|
|
||||||
this.deductions = records.map(item => ({
|
this.deductions = records.map(item => ({
|
||||||
deductionId: item.id,
|
deductionId: item.id,
|
||||||
deductionName: item.itemName,
|
deductionName: item.itemName,
|
||||||
@@ -178,7 +187,6 @@ export default {
|
|||||||
checked: false
|
checked: false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// 调试信息
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('扣分项加载成功:', this.deductions)
|
console.log('扣分项加载成功:', this.deductions)
|
||||||
}
|
}
|
||||||
@@ -201,7 +209,6 @@ export default {
|
|||||||
delta: 1,
|
delta: 1,
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('返回失败:', err)
|
console.error('返回失败:', err)
|
||||||
// 如果返回失败,尝试跳转到评分列表页
|
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: '/pages/score-list/score-list'
|
url: '/pages/score-list/score-list'
|
||||||
})
|
})
|
||||||
@@ -221,12 +228,44 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showScoreInput() {
|
||||||
|
this.inputScore = this.currentScore.toFixed(3)
|
||||||
|
this.showInputModal = true
|
||||||
|
},
|
||||||
|
|
||||||
|
hideScoreInput() {
|
||||||
|
this.showInputModal = false
|
||||||
|
this.inputScore = ''
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmScoreInput() {
|
||||||
|
const score = parseFloat(this.inputScore)
|
||||||
|
|
||||||
|
if (isNaN(score)) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入有效的数字',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (score < this.minScore || score > this.maxScore) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `分数必须在${this.minScore}-${this.maxScore}之间`,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentScore = parseFloat(score.toFixed(3))
|
||||||
|
this.hideScoreInput()
|
||||||
|
},
|
||||||
|
|
||||||
toggleDeduction(index) {
|
toggleDeduction(index) {
|
||||||
this.deductions[index].checked = !this.deductions[index].checked
|
this.deductions[index].checked = !this.deductions[index].checked
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
// 验证评分范围
|
|
||||||
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
||||||
@@ -235,7 +274,6 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证必需字段
|
|
||||||
if (!this.competitionId) {
|
if (!this.competitionId) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '缺少比赛ID,请重新登录',
|
title: '缺少比赛ID,请重新登录',
|
||||||
@@ -252,7 +290,6 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收集选中的扣分项ID
|
|
||||||
const selectedDeductions = this.deductions
|
const selectedDeductions = this.deductions
|
||||||
.filter(item => item.checked)
|
.filter(item => item.checked)
|
||||||
.map(item => item.deductionId)
|
.map(item => item.deductionId)
|
||||||
@@ -263,7 +300,6 @@ export default {
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
|
|
||||||
// 准备提交数据
|
|
||||||
const submitData = {
|
const submitData = {
|
||||||
athleteId: this.player.athleteId,
|
athleteId: this.player.athleteId,
|
||||||
judgeId: this.judgeId,
|
judgeId: this.judgeId,
|
||||||
@@ -275,19 +311,14 @@ export default {
|
|||||||
note: this.note
|
note: this.note
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调试日志:打印提交数据
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('准备提交评分数据:', submitData)
|
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)
|
const response = await dataAdapter.getData('submitScore', submitData)
|
||||||
|
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|
||||||
// 调试信息
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('评分提交成功:', {
|
console.log('评分提交成功:', {
|
||||||
athleteId: this.player.athleteId,
|
athleteId: this.player.athleteId,
|
||||||
@@ -297,14 +328,12 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示成功提示
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '提交成功',
|
title: '提交成功',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
|
|
||||||
// 返回上一页
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 1500)
|
}, 1500)
|
||||||
@@ -485,6 +514,14 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 20rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-display:active {
|
||||||
|
background-color: rgba(27, 124, 94, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.current-score {
|
.current-score {
|
||||||
@@ -493,6 +530,12 @@ export default {
|
|||||||
color: #1B7C5E;
|
color: #1B7C5E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-hint {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999999;
|
||||||
|
margin-top: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.judge-tip {
|
.judge-tip {
|
||||||
padding: 0 30rpx;
|
padding: 0 30rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
@@ -628,4 +671,95 @@ export default {
|
|||||||
.submit-btn:active {
|
.submit-btn:active {
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 分数输入弹窗 */
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
width: 600rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
padding: 40rpx 30rpx 20rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-title {
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 20rpx 30rpx 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 90rpx;
|
||||||
|
border: 2rpx solid #E0E0E0;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
text-align: center;
|
||||||
|
color: #1B7C5E;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-input:focus {
|
||||||
|
border-color: #1B7C5E;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-hint {
|
||||||
|
display: block;
|
||||||
|
margin-top: 16rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999999;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer {
|
||||||
|
display: flex;
|
||||||
|
border-top: 1rpx solid #E0E0E0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn {
|
||||||
|
flex: 1;
|
||||||
|
height: 100rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn.cancel {
|
||||||
|
color: #666666;
|
||||||
|
border-right: 1rpx solid #E0E0E0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn.confirm {
|
||||||
|
color: #1B7C5E;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn:active {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -31,28 +31,22 @@
|
|||||||
<view class="score-control">
|
<view class="score-control">
|
||||||
<view class="control-btn decrease" @click="decreaseScore">
|
<view class="control-btn decrease" @click="decreaseScore">
|
||||||
<text class="btn-symbol">-</text>
|
<text class="btn-symbol">-</text>
|
||||||
<!-- <text class="btn-value">-0.001</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="score-display">
|
<view class="score-display" @click="showScoreInput">
|
||||||
<text class="current-score">{{ currentScore.toFixed(3) }}</text>
|
<text class="current-score">{{ currentScore.toFixed(3) }}</text>
|
||||||
|
<text class="edit-hint">点击编辑</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="control-btn increase" @click="increaseScore">
|
<view class="control-btn increase" @click="increaseScore">
|
||||||
<text class="btn-symbol">+</text>
|
<text class="btn-symbol">+</text>
|
||||||
<!-- <text class="btn-value">+0.001</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <view class="judge-tip">
|
|
||||||
裁判评分:保留3位小数点,超过上限或下限时,按钮置灰
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<!-- 扣分项 -->
|
<!-- 扣分项 -->
|
||||||
<view class="deduction-section">
|
<view class="deduction-section">
|
||||||
<view class="deduction-header">
|
<view class="deduction-header">
|
||||||
<text class="deduction-label">扣分项:</text>
|
<text class="deduction-label">扣分项:</text>
|
||||||
<!-- <text class="deduction-hint">扣分项多选</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="deduction-list">
|
<view class="deduction-list">
|
||||||
@@ -82,12 +76,35 @@
|
|||||||
v-model="note"
|
v-model="note"
|
||||||
maxlength="200"
|
maxlength="200"
|
||||||
/>
|
/>
|
||||||
<!-- <text class="optional-text">可不填</text> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 提交按钮 -->
|
<!-- 提交按钮 -->
|
||||||
<button class="submit-btn" @click="handleSubmit">提交</button>
|
<button class="submit-btn" @click="handleSubmit">提交</button>
|
||||||
|
|
||||||
|
<!-- 分数输入弹窗 -->
|
||||||
|
<view v-if="showInputModal" class="modal-overlay" @click="hideScoreInput">
|
||||||
|
<view class="modal-content" @click.stop>
|
||||||
|
<view class="modal-header">
|
||||||
|
<text class="modal-title">输入分数</text>
|
||||||
|
</view>
|
||||||
|
<view class="modal-body">
|
||||||
|
<input
|
||||||
|
type="digit"
|
||||||
|
class="score-input"
|
||||||
|
v-model="inputScore"
|
||||||
|
placeholder="请输入5-10之间的分数"
|
||||||
|
:focus="showInputModal"
|
||||||
|
@confirm="confirmScoreInput"
|
||||||
|
/>
|
||||||
|
<text class="input-hint">分数范围:{{ minScore }} - {{ maxScore }},保留3位小数</text>
|
||||||
|
</view>
|
||||||
|
<view class="modal-footer">
|
||||||
|
<button class="modal-btn cancel" @click="hideScoreInput">取消</button>
|
||||||
|
<button class="modal-btn confirm" @click="confirmScoreInput">确定</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -107,50 +124,22 @@ export default {
|
|||||||
},
|
},
|
||||||
judgeId: '',
|
judgeId: '',
|
||||||
projectId: '',
|
projectId: '',
|
||||||
|
competitionId: '',
|
||||||
|
venueId: '',
|
||||||
currentScore: 8.000,
|
currentScore: 8.000,
|
||||||
note: '',
|
note: '',
|
||||||
minScore: 5.0,
|
minScore: 5.0,
|
||||||
maxScore: 10.0,
|
maxScore: 10.0,
|
||||||
deductions: []
|
deductions: [],
|
||||||
|
showInputModal: false,
|
||||||
|
inputScore: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
// 获取全局数据
|
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
const globalData = app.globalData || {}
|
const globalData = app.globalData || {}
|
||||||
|
|
||||||
// 检查登录状态
|
|
||||||
if (!globalData.judgeId || !globalData.token) {
|
|
||||||
console.warn('用户未登录,跳转到登录页')
|
|
||||||
uni.showToast({
|
|
||||||
title: '请先登录',
|
|
||||||
icon: 'none',
|
|
||||||
duration: 1500
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/pages/login/login'
|
|
||||||
})
|
|
||||||
}, 1500)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否有选手信息
|
|
||||||
if (!globalData.currentAthlete || !globalData.currentAthlete.athleteId) {
|
|
||||||
console.warn('没有选手信息,返回列表页')
|
|
||||||
uni.showToast({
|
|
||||||
title: '请选择选手',
|
|
||||||
icon: 'none',
|
|
||||||
duration: 1500
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 1500)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载当前选手信息(从 score-list 页面传递)
|
|
||||||
const currentAthlete = globalData.currentAthlete || {}
|
const currentAthlete = globalData.currentAthlete || {}
|
||||||
this.player = {
|
this.player = {
|
||||||
athleteId: currentAthlete.athleteId || '',
|
athleteId: currentAthlete.athleteId || '',
|
||||||
@@ -160,57 +149,44 @@ export default {
|
|||||||
number: currentAthlete.number || ''
|
number: currentAthlete.number || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果选手已评分,加载其原有评分
|
|
||||||
if (currentAthlete.scored && currentAthlete.myScore) {
|
if (currentAthlete.scored && currentAthlete.myScore) {
|
||||||
this.currentScore = currentAthlete.myScore
|
this.currentScore = currentAthlete.myScore
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载评委ID和项目ID
|
|
||||||
this.judgeId = globalData.judgeId
|
this.judgeId = globalData.judgeId
|
||||||
const projects = globalData.projects || []
|
this.projectId = globalData.currentProjectId || ''
|
||||||
const currentIndex = globalData.currentProjectIndex || 0
|
this.competitionId = globalData.matchId || globalData.matchCode || ''
|
||||||
const currentProject = projects[currentIndex] || {}
|
this.venueId = globalData.currentVenueId || globalData.venueId || ''
|
||||||
this.projectId = currentProject.projectId
|
|
||||||
|
|
||||||
// 调试信息
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('评分详情页加载:', {
|
console.log('评分详情页加载:', {
|
||||||
athlete: this.player,
|
athlete: this.player,
|
||||||
judgeId: this.judgeId,
|
judgeId: this.judgeId,
|
||||||
projectId: this.projectId,
|
projectId: this.projectId,
|
||||||
|
competitionId: this.competitionId,
|
||||||
|
venueId: this.venueId,
|
||||||
initialScore: this.currentScore
|
initialScore: this.currentScore
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载扣分项列表
|
|
||||||
await this.loadDeductions()
|
await this.loadDeductions()
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async loadDeductions() {
|
async loadDeductions() {
|
||||||
try {
|
try {
|
||||||
// 🔥 关键改动:使用 dataAdapter 获取扣分项列表
|
|
||||||
// Mock模式:调用 mock/score.js 的 getDeductions 函数
|
|
||||||
// API模式:调用 api/score.js 的 getDeductions 函数(GET /blade-martial/deductionItem/list)
|
|
||||||
const response = await dataAdapter.getData('getDeductions', {
|
const response = await dataAdapter.getData('getDeductions', {
|
||||||
projectId: this.projectId
|
projectId: this.projectId
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取返回数据(兼容分页和非分页格式)
|
const records = response.data && response.data.records ? response.data.records : []
|
||||||
const responseData = response.data || {}
|
this.deductions = records.map(item => ({
|
||||||
const records = responseData.records || response.data || []
|
deductionId: item.id,
|
||||||
|
deductionName: item.itemName,
|
||||||
// 为每个扣分项添加 checked 状态,并映射字段名
|
deductionScore: parseFloat(item.deductionPoint || 0),
|
||||||
// 后端字段: id, itemName
|
|
||||||
// 前端字段: deductionId, deductionName
|
|
||||||
this.deductions = (Array.isArray(records) ? records : []).map(item => ({
|
|
||||||
deductionId: item.deductionId || item.id,
|
|
||||||
deductionName: item.deductionName || item.itemName,
|
|
||||||
deductionPoint: item.deductionPoint || 0,
|
|
||||||
checked: false
|
checked: false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// 调试信息
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('扣分项加载成功:', this.deductions)
|
console.log('扣分项加载成功:', this.deductions)
|
||||||
}
|
}
|
||||||
@@ -225,7 +201,19 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
goBack() {
|
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() {
|
decreaseScore() {
|
||||||
@@ -240,12 +228,44 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showScoreInput() {
|
||||||
|
this.inputScore = this.currentScore.toFixed(3)
|
||||||
|
this.showInputModal = true
|
||||||
|
},
|
||||||
|
|
||||||
|
hideScoreInput() {
|
||||||
|
this.showInputModal = false
|
||||||
|
this.inputScore = ''
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmScoreInput() {
|
||||||
|
const score = parseFloat(this.inputScore)
|
||||||
|
|
||||||
|
if (isNaN(score)) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入有效的数字',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (score < this.minScore || score > this.maxScore) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `分数必须在${this.minScore}-${this.maxScore}之间`,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentScore = parseFloat(score.toFixed(3))
|
||||||
|
this.hideScoreInput()
|
||||||
|
},
|
||||||
|
|
||||||
toggleDeduction(index) {
|
toggleDeduction(index) {
|
||||||
this.deductions[index].checked = !this.deductions[index].checked
|
this.deductions[index].checked = !this.deductions[index].checked
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
// 验证评分范围
|
|
||||||
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
||||||
@@ -254,10 +274,25 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收集选中的扣分项ID(转为数字类型,后端期望 List<Long>)
|
if (!this.competitionId) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '缺少比赛ID,请重新登录',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.projectId) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '缺少项目ID,请返回重新选择',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const selectedDeductions = this.deductions
|
const selectedDeductions = this.deductions
|
||||||
.filter(item => item.checked)
|
.filter(item => item.checked)
|
||||||
.map(item => String(item.deductionId))
|
.map(item => item.deductionId)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
@@ -265,26 +300,25 @@ export default {
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
|
|
||||||
// 🔥 关键改动:使用 dataAdapter 提交评分
|
const submitData = {
|
||||||
// Mock模式:调用 mock/score.js 的 submitScore 函数
|
athleteId: this.player.athleteId,
|
||||||
// API模式:调用 api/score.js 的 submitScore 函数(POST /mini/score/submit)
|
judgeId: this.judgeId,
|
||||||
const app = getApp()
|
projectId: this.projectId,
|
||||||
const globalData = app.globalData || {}
|
competitionId: this.competitionId,
|
||||||
const response = await dataAdapter.getData('submitScore', {
|
venueId: this.venueId,
|
||||||
athleteId: String(this.player.athleteId),
|
|
||||||
judgeId: String(this.judgeId),
|
|
||||||
score: this.currentScore,
|
score: this.currentScore,
|
||||||
projectId: String(this.projectId),
|
|
||||||
competitionId: globalData.matchId ? String(globalData.matchId) : null,
|
|
||||||
venueId: globalData.venueId ? String(globalData.venueId) : null,
|
|
||||||
scheduleId: globalData.scheduleId ? String(globalData.scheduleId) : null,
|
|
||||||
deductions: selectedDeductions,
|
deductions: selectedDeductions,
|
||||||
note: this.note || ''
|
note: this.note
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (config.debug) {
|
||||||
|
console.log('准备提交评分数据:', submitData)
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await dataAdapter.getData('submitScore', submitData)
|
||||||
|
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|
||||||
// 调试信息
|
|
||||||
if (config.debug) {
|
if (config.debug) {
|
||||||
console.log('评分提交成功:', {
|
console.log('评分提交成功:', {
|
||||||
athleteId: this.player.athleteId,
|
athleteId: this.player.athleteId,
|
||||||
@@ -294,14 +328,12 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示成功提示
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '提交成功',
|
title: '提交成功',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
|
|
||||||
// 返回上一页
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 1500)
|
}, 1500)
|
||||||
@@ -341,12 +373,19 @@ export default {
|
|||||||
|
|
||||||
.nav-left {
|
.nav-left {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 30rpx;
|
left: 0;
|
||||||
width: 60rpx;
|
top: 0;
|
||||||
height: 60rpx;
|
width: 120rpx;
|
||||||
|
height: 90rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
z-index: 10;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-left:active {
|
||||||
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.back-icon {
|
.back-icon {
|
||||||
@@ -475,6 +514,14 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 20rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-display:active {
|
||||||
|
background-color: rgba(27, 124, 94, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.current-score {
|
.current-score {
|
||||||
@@ -483,6 +530,12 @@ export default {
|
|||||||
color: #1B7C5E;
|
color: #1B7C5E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-hint {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999999;
|
||||||
|
margin-top: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.judge-tip {
|
.judge-tip {
|
||||||
padding: 0 30rpx;
|
padding: 0 30rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
@@ -618,4 +671,95 @@ export default {
|
|||||||
.submit-btn:active {
|
.submit-btn:active {
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 分数输入弹窗 */
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
width: 600rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
padding: 40rpx 30rpx 20rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-title {
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 20rpx 30rpx 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 90rpx;
|
||||||
|
border: 2rpx solid #E0E0E0;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
text-align: center;
|
||||||
|
color: #1B7C5E;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-input:focus {
|
||||||
|
border-color: #1B7C5E;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-hint {
|
||||||
|
display: block;
|
||||||
|
margin-top: 16rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999999;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer {
|
||||||
|
display: flex;
|
||||||
|
border-top: 1rpx solid #E0E0E0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn {
|
||||||
|
flex: 1;
|
||||||
|
height: 100rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn.cancel {
|
||||||
|
color: #666666;
|
||||||
|
border-right: 1rpx solid #E0E0E0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn.confirm {
|
||||||
|
color: #1B7C5E;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn:active {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user