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