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/Parameter2.vue |   84 +++++++++++++++++++++++++++---------------
 1 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/Parameter2.vue b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
index 986805b..bfb3046 100644
--- a/CanadaMes-ui/src/views/Electrical/Parameter2.vue
+++ b/CanadaMes-ui/src/views/Electrical/Parameter2.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">{{ $t('Servo Manual')
@@ -141,37 +141,44 @@
     });
   },
   
-    updateButtonValue(dataGroup, itemIndex) {
-  // 灏嗗綋鍓嶆寜閽殑鍊艰涓�1
-  
+  updateButtonValue(dataGroup, itemIndex) {
+  if (dataGroup[itemIndex].button.value === 1) {
+    // 濡傛灉褰撳墠鎸夐挳鐨勫�兼槸 0锛屽皢鍏惰涓� 1
+    this.$set(dataGroup[itemIndex].button, 'value', 0);
+  } else {
+    // 鍚﹀垯灏嗗叾璁句负 0
     this.$set(dataGroup[itemIndex].button, 'value', 1);
-  
-
-  // 灏嗗叾浠栨寜閽殑鍊煎叏閮ㄨ涓�0
-
+  }
 },
     submitDataToBackend(currentButtonName) {
-  if (currentButtonName === '娓呴櫎ID'  || currentButtonName === 'Clear ID' ) {
-    const inputData = this.jsonData.map(dataGroup => {
-      return dataGroup.map(item => {
-        if (item.type === '3') {
-          return { value: item.button.value };
-        } 
-        return null;
-      });
-    });
 
-    const values = inputData.flat().filter(item => item !== null).map(item => item.value);
-    const jsonObject = { data: values };
+
+
+  if (currentButtonName === '娓呴櫎ID'  || currentButtonName === 'Clear ID' ) {
+  const data2 = [];
+  const resetButtonValues = this.jsonData.map(item => {
+    const buttonItem = item.find(subItem => subItem.button && ['娓呴櫎ID', 'Clear ID'].includes(subItem.button.name));
+
+    
+    return buttonItem ? buttonItem.button.value : null;
+  }).filter(value => value !== null);
+
+  // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+  data2.push(resetButtonValues.flat());
  
- // 鎻愪氦鏁版嵁鍒板悗绔�
- const jsonString = JSON.stringify(jsonObject);
-   console.log('Type涓�3鐨剉alue:', jsonString);
-     socket?.send(jsonString);
-     setTimeout(()=>
-    window.location.reload(),2000
-  )
-  }
+  // 鍦� data2 鏁扮粍鍓嶉潰娣诲姞涓や釜绌烘暟缁�
+ 
+
+  // 鍒涘缓 jsonObject2 瀵硅薄锛屽苟娣诲姞 data2 灞炴��
+  const jsonObject2 = { data: data2 };
+
+  // 鎻愪氦鏁版嵁鍒板悗绔�
+  const jsonString2 = JSON.stringify(jsonObject2);
+  console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString2);
+  socket?.send(jsonString2);
+ 
+ 
+}
 },
     initWebSocket () {
  
@@ -204,13 +211,13 @@
   let obj = JSON.parse(msg.data);
  
   const jsonData2 = this.jsonData;
- 
+  // console.log(jsonData2);
       // 濡傛灉榧犳爣涓嶅湪杈撳叆妗嗗唴锛屾洿鏂拌緭鍏ユ鐨勫��
       // this.submitDataToBackend()
       const parms = obj.params;
       // const xiaoche = obj.params[3];
    
-  // console.log(parms);
+  //  console.log(obj);
 //娓呴櫎id
       for (let i = 0; i < jsonData2.length; i++) {
   let arr = jsonData2[i];
@@ -218,6 +225,7 @@
     let obj = arr[j];
     if (obj.type === '3') {
       obj.button.value = parms[0][i];
+      // console.log(obj.button.value);
     }
   }
 
@@ -236,6 +244,21 @@
     obj.value = parms[1][i].replace(specialChars, '');
     // console.log(obj.value);
   }
+  if (obj.name === 'ID2') {
+        obj.value = parms[1][7].replace(specialChars, ''); // 灏咺D2瀵瑰簲鐨勫�艰祴涓簆arms[1][6]
+      }
+
+      if (obj.name === 'A02ID') {
+        obj.value = parms[1][8].replace(specialChars, ''); // 灏咺D2瀵瑰簲鐨勫�艰祴涓簆arms[1][6]
+      }
+      if (obj.name === 'B01ID') {
+        obj.value = parms[1][9].replace(specialChars, ''); // 灏咺D2瀵瑰簲鐨勫�艰祴涓簆arms[1][6]
+      }
+      if (obj.name === 'B02ID') {
+        obj.value = parms[1][10].replace(specialChars, ''); // 灏咺D2瀵瑰簲鐨勫�艰祴涓簆arms[1][6]
+      }
+
+
 }
 
   }
@@ -262,6 +285,7 @@
     }
   });
 });
+
 jsonData2.forEach((item) => {
   item.forEach((subItem) => {
     if (subItem.read === 666) {

--
Gitblit v1.8.0