From 9dd17569f69f6e93c94d1a8c7918f46fd1e21bb0 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Mon, 18 Oct 2021 15:51:34 +0800
Subject: [PATCH] 表单输入框组件,允许定义输入单位

---
 forms/input/CInput.vue |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue
index c6f16c8..171f765 100644
--- a/forms/input/CInput.vue
+++ b/forms/input/CInput.vue
@@ -4,18 +4,27 @@
  */
 
 <template>
-    <AtInput
-        :name="itemRes.name"
-        :title="itemRes.label"
-        :type="type"
-        :placeholder="placeholder"
-        :required="itemRes.required"
-        :error="itemRes.error"
-        :value="itemRes.formData[itemRes.name]"
-        :onChange="evt=>itemRes.onChange(evt)"
+    <view
+        class="c-input"
+        :class="unit?'c-input-unit':''"
     >
-        <slot />
-    </AtInput>
+        <AtInput
+            :name="itemRes.name"
+            :title="itemRes.label"
+            :type="type"
+            :placeholder="placeholder"
+            :required="itemRes.required"
+            :error="itemRes.error"
+            :value="itemRes.formData[itemRes.name]"
+            :onChange="evt=>itemRes.onChange(evt)"
+        >
+            <slot v-if="!unit" />
+            <text
+                class="c-input-unit-text"
+                v-if="unit"
+            >{{unit}}</text>
+        </AtInput>
+    </view>
 </template>
 
 <script>
@@ -34,6 +43,8 @@
         type: String,
         // 占位提示
         placeholder: String,
+        // 输入框单位
+        unit: String,
     },
     mounted() {},
 };

--
Gitblit v1.9.1