From a5a49ece3191bf8210c42b522503687cedb420c2 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期二, 26 十二月 2023 16:55:40 +0800
Subject: [PATCH] 修改input通过光标焦点是否在input内控制是否更新数据,回车下发参数让input失去焦点更新数据

---
 CanadaMes-ui/src/views/Electrical/ServoManualone.vue |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
index 8eb562a..e2acb21 100644
--- a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
+++ b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -116,7 +116,7 @@
                   <el-input
                     v-if="item.type === '0' && groupIndex === 0"
                     v-model="item.value"
-                    @keyup.enter.native="zuhe1"
+                    @keyup.enter.native="zuhe1($event)"
                     class="input-box"
                     :class="{
                       'special-class': groupIndex === 0,
@@ -127,7 +127,7 @@
                   <el-input
                     v-else-if="item.type === '0' && groupIndex === 1"
                     v-model="item.value"
-                    @keyup.enter.native="zuhe2"
+                    @keyup.enter.native="zuhe2($event)"
                     class="input-box"
                     :class="{
                       'special-class': groupIndex === 0,
@@ -317,7 +317,7 @@
         this.$set(dataGroup[itemIndex].button, "value", 1);
       }
     },
-    zuhe1() {
+    zuhe1(event) {
       const data = [];
 
       for (let i = 0; i < 1; i++) {
@@ -387,8 +387,9 @@
       const jsonString = JSON.stringify(jsonObject);
       console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
       socket?.send(jsonString);
+      event.target.blur(); // 鍙栨秷杈撳叆妗嗙劍鐐�
     },
-    zuhe2() {
+    zuhe2(event) {
       const data2 = [];
 
       for (let i = 1; i < 2; i++) {
@@ -453,6 +454,7 @@
       const jsonString = JSON.stringify(jsonObject);
       console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
       socket?.send(jsonString);
+      event.target.blur(); // 鍙栨秷杈撳叆妗嗙劍鐐�
     },
     submitDataToBackend(currentButtonName) {
       const data = [];
@@ -682,17 +684,17 @@
           console.log("websocket宸叉墦寮�");
         };
 
-        let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+        // let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
 
-        const inputBox = document.querySelectorAll(".input-box");
-        inputBox.forEach((box) => {
-          box.addEventListener("mouseenter", () => {
-            isMouseInInputBox = true;
-          });
-          box.addEventListener("mouseleave", () => {
-            isMouseInInputBox = false;
-          });
-        });
+        // const inputBox = document.querySelectorAll(".input-box");
+        // inputBox.forEach((box) => {
+        //   box.addEventListener("mouseenter", () => {
+        //     isMouseInInputBox = true;
+        //   });
+        //   box.addEventListener("mouseleave", () => {
+        //     isMouseInInputBox = false;
+        //   });
+        // });
 
         socket.onmessage = (msg) => {
           if (!msg.data) {
@@ -703,8 +705,11 @@
           // console.log(obj)
           const weihuiling = obj.weihuiling;
           const jsonData2 = this.jsonData;
+          if (document.activeElement.tagName.toLowerCase() === 'input') {
+    return;
+  }
 
-          if (obj.zuhe1 && !isMouseInInputBox) {
+          if (obj.zuhe1 ) {
             //鍚姩鎸夐挳
 
             // 鎵ц鏇存柊閫昏緫

--
Gitblit v1.8.0