From dfc319b1ca9bdde32e0a40256b17f6d59aa7e894 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Mon, 30 May 2022 18:03:37 +0800
Subject: [PATCH] 文字提示,取消遮罩遮挡

---
 forms/input/CInput.vue |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue
index 0ca5c07..d23c616 100644
--- a/forms/input/CInput.vue
+++ b/forms/input/CInput.vue
@@ -6,7 +6,7 @@
 <template>
     <view
         class="c-input"
-        :class="unit?'c-input-unit':''"
+        :class="[unit?'c-input-unit':'', readOnly ? 'read-only':'']"
     >
         <AtInput
             :name="itemRes.name"
@@ -16,8 +16,8 @@
             :required="itemRes.required"
             :error="itemRes.error"
             :cursorSpacing="0"
-            :value="itemRes.formData[itemRes.name]"
-            :onChange="evt=>itemRes.onChange(evt)"
+            :value="value"
+            :onChange="evt => hanldeChange(evt)"
         >
             <slot v-if="!unit" />
             <text
@@ -46,6 +46,26 @@
         placeholder: String,
         // 输入框单位
         unit: String,
+        // 只读模式
+        readOnly: {
+            type: Boolean,
+            default: false,
+        },
+    },
+    computed: {
+        value() {
+            return ((this.itemRes.formData[this.itemRes.name] || '') + '').replace(
+                /[\n\r]/g,
+                ''
+            );
+        },
+    },
+    methods: {
+        hanldeChange(evt) {
+            // 小程序中,可以粘贴换行符进来
+            const changeValue = ((evt || '') + '').replace(/[\n\r]/g, '');
+            this.itemRes.onChange(changeValue);
+        },
     },
     mounted() {},
 };

--
Gitblit v1.9.1