From 432178df70dcd0bc26fcc25cf188064a1fed2ced Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Tue, 14 May 2024 19:23:23 +0800
Subject: [PATCH] 删除无用代码

---
 forms/input/CInput.vue |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue
index 74d986e..211d760 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"
@@ -17,7 +17,7 @@
             :error="itemRes.error"
             :cursorSpacing="0"
             :value="value"
-            :onChange="evt => hanldeChange(evt)"
+            :onChange="evt => handleChange(evt)"
         >
             <slot v-if="!unit" />
             <text
@@ -46,19 +46,26 @@
         placeholder: String,
         // 输入框单位
         unit: String,
+        // 只读模式
+        readOnly: {
+            type: Boolean,
+            default: false,
+        },
     },
     computed: {
         value() {
-            return (this.itemRes.formData[this.itemRes.name] || '').replace(
+            return ((this.itemRes.formData[this.itemRes.name] || '') + '').replace(
                 /[\n\r]/g,
                 ''
             );
         },
     },
     methods: {
-        hanldeChange(evt) {
-            // 小程序中,可以粘贴换行符进来
-            const changeValue = (evt || '').replace(/[\n\r]/g, '');
+        handleChange(evt) {
+            // 去除首尾空格,小程序中还可以粘贴换行符进来
+            const changeValue = ((evt || '') + '')
+                .replace(/^\s+|\s+$/g, '')
+                .replace(/[\n\r\t]/g, '');
             this.itemRes.onChange(changeValue);
         },
     },

--
Gitblit v1.9.1