From 9276cfcae04d9dd01541210491c04544aa4f06f5 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Wed, 21 Apr 2021 15:46:02 +0800
Subject: [PATCH] 修复数值阀的问题

---
 forms/numberValve/CNumberValve.vue  |   27 +++++++++++++++++----------
 forms/numberValve/cNumberValve.scss |    2 +-
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/forms/numberValve/CNumberValve.vue b/forms/numberValve/CNumberValve.vue
index e19731e..394d8c4 100644
--- a/forms/numberValve/CNumberValve.vue
+++ b/forms/numberValve/CNumberValve.vue
@@ -21,12 +21,6 @@
                 <view class="at-icon at-icon-chevron-right"></view>
             </AtInput>
         </view>
-        <AtRange
-            :min="range[0]"
-            :max="range[1]"
-            :value="[0, itemRes.formData[itemRes.name]]"
-            :onChange="evt => evt && itemRes.onChange(evt[1])"
-        />
         <AtFloatLayout
             :isOpened="opened"
             :onClose="evt => handleClose()"
@@ -74,7 +68,7 @@
 <script>
 import Taro from '@tarojs/taro';
 import { $ } from '@tarojs/extend';
-import { AtInput, AtFloatLayout, AtButton, AtRange } from 'taro-ui-vue';
+import { AtInput, AtFloatLayout, AtButton } from 'taro-ui-vue';
 import './cNumberValve.scss';
 
 export default {
@@ -83,7 +77,6 @@
         AtInput,
         AtFloatLayout,
         AtButton,
-        AtRange,
     },
     props: {
         // 表单数据资源(表单组件内部机制专用)
@@ -158,12 +151,26 @@
             this.updateRect();
             let currentNext = 0;
             if (type === 'left') {
-                currentNext = this.current - this.step;
+                const gap = this.current % this.step;
+                if (gap === 0) {
+                    currentNext = this.current - this.step;
+                } else {
+                    currentNext = this.current - gap;
+                }
             } else if (type === 'right') {
-                currentNext = this.current + this.step;
+                const gap = this.current % this.step;
+                if (gap === 0) {
+                    currentNext = this.current + this.step;
+                } else {
+                    currentNext = this.current + (this.step - gap);
+                }
             } else if (type === 'change') {
                 currentNext = value;
             }
+            // 范围限制
+            currentNext = Math.max(currentNext, this.range[0]);
+            currentNext = Math.min(currentNext, this.range[1]);
+            // 设置
             const sliderLeft = Math.round(
                 ((currentNext - this.range[0]) / (this.range[1] - this.range[0])) * 100
             );
diff --git a/forms/numberValve/cNumberValve.scss b/forms/numberValve/cNumberValve.scss
index 82afead..7fc9ff5 100644
--- a/forms/numberValve/cNumberValve.scss
+++ b/forms/numberValve/cNumberValve.scss
@@ -113,7 +113,7 @@
                 .current {
                     @include position(absolute, n 0 0 n, 1);
                     height: 46PX;
-                    border-left: #eee 1PX solid;
+                    border-left: #e2e2e2 1PX solid;
                     .text {
                         @include position(absolute, -24PX 0 n n);
                         transform: translateX(-50%);

--
Gitblit v1.9.1