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 |   54 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/src/components/wordInput.vue b/src/components/wordInput.vue
index fe0a4a4..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
@@ -25,8 +26,8 @@
         style="
           height: 100%;
           display: inline-block;
-          line-height: 24px;
-          width: 24px;
+          line-height: 22px;
+          width: 22px;
           text-align: center;
         "
         class="el-icon-minus"
@@ -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() {
@@ -277,14 +312,15 @@
     // justify-content: space-between;
     display: inline-block;
     margin-right: 0px;
+    line-height:28px;
     input {
       color: inherit;
       font-family: inherit;
       border: 0;
       outline: 0;
       border-bottom: 1px solid #919191;
-      height: 24px;
-      width: 24px;
+      height: 22px;
+      width: 22px;
       font-size:18px;
       text-align: center;
       border: #919191 1px solid;

--
Gitblit v1.8.0