From 82c2df0968b099bd589936adc5b28c1ac4827a05 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期一, 04 十二月 2023 08:20:07 +0800
Subject: [PATCH] 更新测试后电气管理

---
 CanadaMes-ui/src/views/Electrical/Positioning1.vue |  109 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/Positioning1.vue b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
index d44cc90..f04a1a7 100644
--- a/CanadaMes-ui/src/views/Electrical/Positioning1.vue
+++ b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
@@ -7,8 +7,8 @@
       }}</router-link>
       <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
       }}</router-link>
-      <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
-      }}</router-link>
+      <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
+      }}</router-link> -->
       <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
       }}</router-link>
       <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{
@@ -22,16 +22,16 @@
       }}</router-link>
       <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1')
       }}</router-link>
-      <!-- <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2')
-          }}</router-link> -->
+      <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2')
+      }}</router-link>
       <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{
         $t('Positioning1')
       }}</router-link>
       <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
         $t('Positioning2')
       }}</router-link>
-      <router-link to="/Electrical/Manualoneposition" tag="el-button" type="text" active-class="blue-button">{{
-        $t('Manualoneposition')
+      <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{
+        $t('ManualonePosition')
       }}</router-link>
       <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{
         $t('ManualonePosition2')
@@ -44,8 +44,8 @@
       }}</router-link>
     </el-breadcrumb>
 
-    <el-row :gutter="18">
-      <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex" class='card'>
+    <el-row :gutter="18" class='card'>
+      <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex">
         <el-card class="json-block">
           <div class="button-row" style="display: flex; justify-content: space-between;">
             <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
@@ -55,8 +55,13 @@
           <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container">
             <div class="item-row">
               <span class="name" style="width:250px;">{{ item.name }}</span>
-              <el-input v-if="item.type === '0'" v-model="item.value" class="input-box"></el-input>
-              <el-button v-if="item.type === '0'" class="input-box" @click="submitDataToBackend();">鍙栧湴鍧�</el-button>
+              <el-input v-if="item.type === '0'" v-model="item.value" class="input-box"      @keyup.enter.native="submitDataToBackend" ></el-input>
+
+
+
+              <!-- <el-button
+                v-if="item.type === '0' && item.name !== '鏍煎瓙闂磋窛' && item.name !== '鍑虹墖鎺ョ墖鍦板潃' && item.name !== '瀛樼墖鎺ョ墖鍦板潃'"
+                class="input-box" @click="submitDataToBackend();">鍙栧湴鍧�</el-button> -->
             </div>
           </div>
 
@@ -80,11 +85,16 @@
       jsonData: data // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
     }
   },
-  created () {
-    this.initWebSocket();
-    console.log('jsonData:', this.jsonData);
-
-  },
+  activated(){
+   
+   this.initWebSocket ();
+   const language = this.$i18n.locale;
+  console.log(language);
+  if (language === 'en-US') {
+    this.replaceChineseWithEnglish();
+  }
+  this.$forceUpdate();
+ },
   methods: {
     updateButtonValue (dataGroup, itemIndex) {
       this.$set(dataGroup[itemIndex].button, 'value', 1); // 鐐瑰嚮鎸夐挳鍚庡皢鍊兼敼涓�1
@@ -115,7 +125,7 @@
 
       // 鎻愪氦鏁版嵁鍒板悗绔�
       const jsonString = JSON.stringify(jsonObject);
-      console.log('鎻愪氦浠ヤ笅鏁版嵁鍒板悗绔�:', jsonString);
+      // console.log('鎻愪氦浠ヤ笅鏁版嵁鍒板悗绔�:', jsonString);
       socket?.send(jsonString);
     },
     initWebSocket () {
@@ -149,29 +159,32 @@
           let obj = JSON.parse(msg.data);
           const jsonData2 = this.jsonData;
           document.addEventListener('mouseover', function (event) {
-            const inputBox = document.querySelector('.card'); // 鏍规嵁浣犵殑瀹為檯鎯呭喌閫夋嫨姝g‘鐨勯�夋嫨鍣�
-            if (inputBox && !inputBox.contains(event.target)) {
+            const inputBox = document.querySelectorAll('.el-card__body');
+            const target = event.target;
+            if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
               // 濡傛灉榧犳爣涓嶅湪杈撳叆妗嗗唴锛屾洿鏂拌緭鍏ユ鐨勫��
               // this.submitDataToBackend()
-              const params = obj.params;
+              const parms = obj.params;
+              // console.log(parms)
 
 
-              // this.submitDataToBackend()
-              let currentIndex = 0;
-
-              jsonData2.forEach((group, groupIndex) => {
-                group.forEach((item) => {
-                  if (item.type !== '1') {
-                    if (params[groupIndex] && params[groupIndex][currentIndex] !== undefined) {
-                      item.value = params[groupIndex][currentIndex];
-                    }
-                    currentIndex++;
+              let index = 0;
+              for (let i = 0; i < jsonData2.length; i++) {
+                let arr = jsonData2[i];
+                for (let j = 0; j < arr.length; j++) {
+                  let obj = arr[j];
+                  if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) {
+                    obj.value = parms[0][index];
+                    index++;
                   }
-                });
-                currentIndex = 0; // 鎵嬪姩閲嶇疆绱㈠紩锛屽噯澶囧鐞嗕笅涓�涓垎缁�
-              });
+                }
+              }
 
-              console.log(jsonData2);
+
+
+
+
+              // console.log(jsonData2);
 
             }
           });
@@ -189,9 +202,37 @@
         socket.onerror = function () {
           console.log("websocket鍙戠敓浜嗛敊璇�");
         };
+        this.$router.afterEach(function(){
+          socket.close();
+        })
 
       }
     },
+    replaceChineseWithEnglish() {
+ 
+   
+ const nameMap=  this.$t('langPositioning1')
+ this.jsonData = this.jsonData.map((item) => {
+  return item.map((obj) => {
+    if (obj.name) {
+      const newName = nameMap[obj.name] || obj.name;
+      return { ...obj, name: newName };
+    } else if (obj.button && obj.button.name) {
+      const newName = nameMap[obj.button.name] || obj.button.name;
+      return { ...obj, button: { ...obj.button, name: newName } };
+    } else if (obj.title && obj.title.name) {
+      const newName = nameMap[obj.title.name] || obj.title.name;
+      return { ...obj, title: { ...obj.title, name: newName } };
+    } else {
+      return obj;
+    }
+  });
+});
+
+
+// console.log(this.jsonData)
+
+},
     send () {
 
 
@@ -219,4 +260,4 @@
 .blue-button {
   background-color: skyblue;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0