diff --git a/src/pages/score-detail/score-detail.vue b/src/pages/score-detail/score-detail.vue index d4aa58c..1e110b1 100644 --- a/src/pages/score-detail/score-detail.vue +++ b/src/pages/score-detail/score-detail.vue @@ -24,7 +24,7 @@ - 点击分数填写或拖动滑块打分(5-10分) + 直接输入分数或使用加减按钮调整(5-10分) @@ -33,9 +33,16 @@ - - {{ currentScore.toFixed(3) }} - 点击编辑 + + @@ -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 {