From 01cea4bc73210e43f748d82a02a432cce615be2d Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 24 十月 2023 17:52:04 +0800
Subject: [PATCH] Merge branch 'dev' of http://192.168.5.5:10010/r/web/crm-web into wn

---
 src/components/wordInput.vue |   45 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/components/wordInput.vue b/src/components/wordInput.vue
index 8e9408a..852d6f2 100644
--- a/src/components/wordInput.vue
+++ b/src/components/wordInput.vue
@@ -9,6 +9,7 @@
       @paste="paste"
       @mousewheel="mousewheel"
       @input="inputEvent"
+      @compositionend="compositionend"
       v-for="(item, index) in codeList"
     >
       <input
@@ -94,6 +95,10 @@
     // },
   },
   methods: {
+    compositionend(e){
+      e.preventDefault()
+      this.batchInsert(e.data,e.target)
+    },
     // 瑙e喅涓�涓緭鍏ユ杈撳叆澶氫釜瀛楃
     inputEvent(e) {
       var index = e.target.dataset.index * 1;
@@ -147,6 +152,14 @@
       }
     },
     keyup(e) {
+      if (e.ctrlKey || e.shiftKey){
+        // 蹇界暐缁勫悎閿椂鐨勫瓧绗﹁緭鍏�
+        return;
+      }
+      if (e.isComposing || e.keyCode === 229) {
+        // 蹇界暐杈撳叆娉曞悎鎴愪簨浠� 蹇界暐IME鍔犲伐杩囩殑鍊�
+        return;
+      }
       var index = e.target.dataset.index * 1;
       var el = e.target;
       // console.log(this.input);
@@ -175,6 +188,8 @@
       }
     },
     mousewheel(e) {
+      // 闃叉瑙﹀彂澶栭儴婊氬姩鏉�
+      e.preventDefault()
       var index = e.target.dataset.index;
       if (e.wheelDelta > 0) {
         if (this.input[index] * 1 < 9) {
@@ -191,14 +206,34 @@
         }
       }
     },
+    /**
+     * 鎵归噺娣诲姞瀛楃
+     * @param str 瀛楃涓�
+     * @param currentInputElement 褰撳墠杈撳叆鐨刬nput鍏冪礌
+     */
+    batchInsert(str,currentInputElement){
+      const charList = str.split('');
+
+      let currentIndex = currentInputElement.dataset.index * 1;
+
+      let activeInputElement =currentInputElement
+      charList.forEach((ele,idx)=>{
+        this.$set(this.input, currentIndex+idx, ele);
+        activeInputElement = activeInputElement?.nextElementSibling
+      })
+      activeInputElement?.focus()
+    },
     paste(e) {
       // 褰撹繘琛岀矘璐存椂
       e.clipboardData.items[0].getAsString((str) => {
-        if (str.toString().length === 6) {
-          this.pasteResult = str.split("");
-          document.activeElement.blur();
-          this.$emit("complete", this.input);
-        }
+        // if (str.toString().length === 6) {
+        //   this.pasteResult = str.split("");
+        //   document.activeElement.blur();
+        //   this.$emit("complete", this.input);
+        // }
+
+        this.batchInsert(str,e.target)
+        this.$emit("complete", this.input);
       });
     },
     save() {

--
Gitblit v1.8.0