| | |
| | | :required="itemRes.required" |
| | | :disabled="itemRes.disabled" |
| | | :error="itemRes.error" |
| | | :value="itemRes.formData[itemRes.name]" |
| | | :value="itemRes.formData[itemRes.name] + unit" |
| | | :placeholder="placeholder" |
| | | > |
| | | <view class="at-icon at-icon-chevron-right"></view> |
| | | </AtInput> |
| | | </view> |
| | | <AtFloatLayout |
| | | :class="placeholder?'on-title':''" |
| | | :title="placeholder" |
| | | :isOpened="opened" |
| | | :onClose="evt => handleClose()" |
| | | > |
| | |
| | | type: Number, |
| | | default: 1, |
| | | }, |
| | | // 数值单位(仅显示) |
| | | unit: { |
| | | type: String, |
| | | default: '', |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | const targetValue = clientX - this.rect.left; |
| | | const distance = Math.min(Math.max(targetValue, 0), this.rect.width); |
| | | const sliderLeft = Math.floor((distance / this.rect.width) * 100); |
| | | const sliderValue = |
| | | // 实际值 |
| | | let sliderValue = |
| | | Math.round((sliderLeft / 100) * (this.range[1] - this.range[0])) + |
| | | this.range[0]; |
| | | if (this.range[0] < sliderValue && sliderValue < this.range[1]) { |
| | | sliderValue -= sliderValue % this.step; |
| | | } |
| | | // 范围限制 |
| | | sliderValue = Math.max(sliderValue, this.range[0]); |
| | | sliderValue = Math.min(sliderValue, this.range[1]); |
| | | // 设置 |
| | | this.sliderLeft = sliderLeft; |
| | | this.current = sliderValue; |
| | | this.itemRes.onChange(sliderValue); |