From fdeb869c386da95150a087bc22bcebc4e57d0f76 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Tue, 18 Mar 2025 18:16:32 +0800
Subject: [PATCH] 更新所有表单组件文档和头注释

---
 forms/numberValve/CNumberValve.vue |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/forms/numberValve/CNumberValve.vue b/forms/numberValve/CNumberValve.vue
index 98e7af5..777778b 100644
--- a/forms/numberValve/CNumberValve.vue
+++ b/forms/numberValve/CNumberValve.vue
@@ -1,5 +1,8 @@
 /**
  * CNumberValve
+ * 数值滑块组件,用于在表单中通过滑块选择数值
+ * 提供了滑动条和增减按钮两种方式来调整数值
+ * 支持设置数值范围、步长和单位显示
  * @author Tevin
  */
 
@@ -16,7 +19,7 @@
                 :required="itemRes.required"
                 :disabled="itemRes.disabled"
                 :error="itemRes.error"
-                :value="itemRes.formData[itemRes.name] + unit"
+                :value="valueStr"
                 :placeholder="placeholder"
             >
                 <view class="at-icon at-icon-chevron-right"></view>
@@ -49,7 +52,16 @@
                             @touchstart="evt => handleTouchStart()"
                             @touchmove="evt => handleTouchMove(evt)"
                         ></view>
-                        <view class="current"><text class="text">{{current}}</text></view>
+                        <view class="current">
+                            <text
+                                class="text m-text-ignore"
+                                v-if="current===''"
+                            >(请拖动)</text>
+                            <text
+                                class="text"
+                                v-else
+                            >{{current}}</text>
+                        </view>
                     </view>
                 </view>
                 <view class="btn">
@@ -106,11 +118,22 @@
         return {
             opened: false,
             rect: { width: 0, left: 0 },
-            current: 0,
+            current: '',
             sliderLeft: 0,
         };
     },
-    computed: {},
+    computed: {
+        valueStr() {
+            if (
+                this.itemRes.formData[this.itemRes.name] ||
+                this.itemRes.formData[this.itemRes.name] === 0
+            ) {
+                return this.itemRes.formData[this.itemRes.name] + ' ' + this.unit;
+            } else {
+                return '';
+            }
+        },
+    },
     methods: {
         handleOpen() {
             this.opened = true;
@@ -152,16 +175,18 @@
             let $slider = null;
             if (process.env.TARO_ENV === 'h5') {
                 $slider = $(this.$refs.slider.$el);
+                const rect = $slider[0].getBoundingClientRect();
+                this.rect.width = rect.width;
+                this.rect.left = rect.left;
             } else if (process.env.TARO_ENV === 'weapp') {
-                $slider = $(this.$refs.slider);
+                Taro.createSelectorQuery()
+                    .select('#' + this.$refs.slider.uid)
+                    .boundingClientRect(rect => {
+                        this.rect.width = rect.width;
+                        this.rect.left = rect.left;
+                    })
+                    .exec();
             }
-            Taro.createSelectorQuery()
-                .select('#' + this.$refs.slider.uid)
-                .boundingClientRect(rect => {
-                    this.rect.width = rect.width;
-                    this.rect.left = rect.left;
-                })
-                .exec();
         },
         handleChangeVal(type, value) {
             this.updateRect();
@@ -188,7 +213,7 @@
             currentNext = Math.min(currentNext, this.range[1]);
             // 设置
             const sliderLeft = Math.round(
-                ((currentNext - this.range[0]) / (this.range[1] - this.range[0])) * 100
+                ((currentNext - this.range[0]) / (this.range[1] - this.range[0])) * 100,
             );
             this.sliderLeft = sliderLeft;
             this.current = currentNext;

--
Gitblit v1.9.1