feat(score): 分数支持直接编辑输入

This commit is contained in:
DevOps
2025-12-31 17:12:20 +08:00
parent a780ee6b2c
commit 1b305fc2bd

View File

@@ -24,7 +24,7 @@
<!-- 评分提示 -->
<view class="score-tip">
点击分数填写或拖动滑块打分5-10
直接输入分数或使用加减按钮调整5-10
</view>
<!-- 分数调整 -->
@@ -33,9 +33,16 @@
<text class="btn-symbol"></text>
</view>
<view class="score-display" @click="showScoreInput">
<text class="current-score">{{ currentScore.toFixed(3) }}</text>
<text class="edit-hint">点击编辑</text>
<view class="score-display">
<input
type="digit"
class="score-input-inline"
:value="scoreInputValue"
@input="onScoreInput"
@blur="onScoreBlur"
@confirm="onScoreConfirm"
placeholder="8.000"
/>
</view>
<view class="control-btn increase" @click="increaseScore">
@@ -136,6 +143,12 @@ export default {
}
},
computed: {
scoreInputValue() {
return this.currentScore.toFixed(3)
}
},
async onLoad() {
const app = getApp()
const globalData = app.globalData || {}
@@ -173,6 +186,42 @@ export default {
},
methods: {
onScoreInput(e) {
// Allow typing, validation happens on blur
},
onScoreBlur(e) {
this.validateAndSetScore(e.detail.value)
},
onScoreConfirm(e) {
this.validateAndSetScore(e.detail.value)
},
validateAndSetScore(value) {
const score = parseFloat(value)
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'
})
// Reset to valid range
this.currentScore = Math.max(this.minScore, Math.min(this.maxScore, score))
return
}
this.currentScore = parseFloat(score.toFixed(3))
},
async loadDeductions() {
try {
const response = await dataAdapter.getData('getDeductions', {
@@ -514,26 +563,26 @@ export default {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
padding: 20rpx;
justify-content: center;
padding: 10rpx;
border-radius: 16rpx;
transition: background-color 0.2s;
min-width: 240rpx;
}
.score-display:active {
background-color: rgba(27, 124, 94, 0.1);
}
.current-score {
font-size: 80rpx;
.score-input-inline {
width: 200rpx;
height: 100rpx;
font-size: 64rpx;
font-weight: 600;
color: #1B7C5E;
text-align: center;
border: 2rpx solid #E0E0E0;
border-radius: 12rpx;
background-color: #FFFFFF;
}
.edit-hint {
font-size: 22rpx;
color: #999999;
margin-top: 8rpx;
.score-input-inline:focus {
border-color: #1B7C5E;
}
.judge-tip {