From 4f3aa71ed602c1abbafa638591b20abc3c7be224 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期四, 18 一月 2024 10:03:45 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes

---
 CanadaMes-ui/src/views/Electrical/ServoManualone.vue | 1107 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 933 insertions(+), 174 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
index b9f65fc..956ea14 100644
--- a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
+++ b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -1,172 +1,702 @@
 <template>
-    <div class="app">
+  <div class="app">
     <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
-        <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
-        }}</router-link>
-        <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
-        }}</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/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')
-        }}</router-link>
-      </el-breadcrumb>
+      <router-link
+        to="/Electrical/alarm"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("Alarm") }}</router-link
+      >
+      <router-link
+        to="/Electrical/State"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("State") }}</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/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("Parameter") }}</router-link
+      >
+    </el-breadcrumb>
 
-      <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
-   
-        <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone')
-      }}</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/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>
+    <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
+      <router-link
+        to="/Electrical/Parameter2"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("Automatic State") }}</router-link
+      >
+      <!-- <router-link
+        to="/Electrical/ManualJog"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("ManualJog") }}</router-link
+      > -->
+
+      <router-link
+        to="/Electrical/ManualonePosition"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("ManualonePosition") }}</router-link
+      >
+
+      <router-link
+        to="/Electrical/Servomanualone"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("Servomanualone") }}</router-link
+      >
+      <!-- <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1')
+      }}</router-link> -->
+
+      <router-link
+        to="/Electrical/Positioning1"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("Address parameter settings") }}</router-link
+      >
+      <!-- <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
+        $t('Positioning2')
+      }}</router-link> -->
+
+      <!-- <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{
+        $t('ManualonePosition2')
+      }}</router-link> -->
+      <router-link
+        to="/Electrical/AutomaticParameterSetting"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("Speed parameter settings") }}</router-link
+      >
+
+      <router-link 
+        to="/Electrical/InteractionState"
+        tag="el-button"
+        type="text"
+        active-class="blue-button"
+        >{{ $t("InteractionState") }}</router-link
+      >
     </el-breadcrumb>
 
     <el-row :gutter="26">
-  <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex">
-    <el-card class="json-block"  style="width:auto;">
-      <el-row >
-        <el-col v-for="(item, itemIndex) in dataGroup" :key="itemIndex" :span="12">
-          <div class="item-container">
-            <div class="item-row">
-              <span class="name" style='width:230px;'>{{ item.name }}</span>
-              <el-input v-if="item.type === '0'" v-model="item.value"   class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1"  ></el-input>
+      <el-col
+        :span="12"
+        v-for="(dataGroup, groupIndex) in jsonData"
+        :key="groupIndex"
+        style="margin-bottom: -20px"
+      >
+        <el-card
+          class="json-block"
+          style="width: auto; margin-bottom: 10px; height: auto"
+        >
+          <el-row>
+            <el-col
+              v-for="(item, itemIndex) in dataGroup"
+              :key="itemIndex"
+              :span="12"
+            >
+              <div class="item-container">
+                <div class="item-row">
+                  <span class="name" style="width: 230px">{{ item.name }}</span>
+
+                  <el-input
+                    v-if="item.type === '0' && groupIndex === 0"
+                    v-model="item.value"
+                    @keyup.enter.native="zuhe1($event)"
+                    class="input-box"
+                    :class="{
+                      'special-class': groupIndex === 0,
+                      'special-class2': groupIndex === 1,
+                    }"
+                    v-show="groupIndex !== 0 && groupIndex !== 1"
+                  ></el-input>
+                  <el-input
+                    v-else-if="item.type === '0' && groupIndex === 1"
+                    v-model="item.value"
+                    @keyup.enter.native="zuhe2($event)"
+                    class="input-box"
+                    :class="{
+                      'special-class': groupIndex === 0,
+                      'special-class2': groupIndex === 1,
+                    }"
+                    v-show="groupIndex !== 0 && groupIndex !== 1"
+                  ></el-input>
+                  <el-input
+                    v-else-if="item.type === '0' && groupIndex === 2"
+                    v-model="item.value"
+                    readonly
+                    class="input-box"
+                  ></el-input>
+                  <el-input
+                    v-else-if="item.type === '0' && groupIndex === 3"
+                    v-model="item.value"
+                    readonly
+                    class="input-box"
+                  ></el-input>
+                  <el-input
+                    v-else-if="item.type === '0' && groupIndex === 4"
+                    v-model="item.value"
+                    readonly
+                    class="input-box"
+                  ></el-input>
+                  <el-input
+                    v-else-if="item.type === '0' && groupIndex === 5"
+                    v-model="item.value"
+                    readonly
+                    class="input-box"
+                  ></el-input>
+                  <el-input
+                    v-else-if="item.type === '0'"
+                    v-model="item.value"
+                    class="input-box"
+                    :class="{
+                      'special-class': groupIndex === 0,
+                      'special-class2': groupIndex === 1,
+                    }"
+                    v-show="groupIndex !== 0 && groupIndex !== 1"
+                  ></el-input>
+                </div>
+              </div>
+            </el-col>
+          </el-row>
+          <div
+            class="button-row"
+            style="display: flex; justify-content: space-between"
+          >
+            <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
+              <el-button
+                v-if="item.button && language === 'en-US'"
+                :name="item.button.name"
+                v-model="item.button.value"
+                :class="{
+                  'action-button': true,
+                  'error-button':
+                    item.button.name === 'Fault' && item.button.value === 1,
+                  'error-button2':
+                    item.button.name === 'NotZero' && item.button.value === 0,
+                  'error-button3':
+                    item.button.name === 'Zero' && item.button.value === 1,
+                  fuwei:
+                    item.button.name === 'Reset' && item.button.value === 1,
+                  huiling:
+                    item.button.name === 'Home' && item.button.value === 1,
+                  qidong:
+                    item.button.name === 'A01 Semi-Auto' &&
+                    item.button.value === 1,
+                  qidong2:
+                    item.button.name === 'A02 Semi-Auto' &&
+                    item.button.value === 1,
+                  qidong3:
+                    item.button.name === 'A01 Semi-Auto Start' &&
+                    item.button.value === 1,
+                  qidong4:
+                    item.button.name === 'A02 Semi-Auto Start' &&
+                    item.button.value === 1,
+                  qidong5:
+                    item.button.name === 'A02 Semi-Auto' &&
+                    item.button.value === 1,
+                  jiting:
+                    item.button.name === 'Abort/ResumeTasks' &&
+                    item.button.value === 1,
+                  yihuiling:
+                    item.button.name === 'Zero' && item.button.value === 1,
+                }"
+                @click="
+                  updateButtonValue(dataGroup, itemIndex);
+                  submitDataToBackend(item.button.name);
+                "
+                >{{ item.button.name }}</el-button
+              >
+              <el-button
+                v-if="item.button && language === 'zh-CN'"
+                :name="item.button.name"
+                v-model="item.button.value"
+                :class="{
+                  'action-button': true,
+                  'error-button':
+                    item.button.name === '鏁呴殰' && item.button.value === 1,
+                  'error-button3':
+                    item.button.name === '宸插洖闆�' && item.button.value === 1,
+                  'error-button2':
+                    item.button.name === '鏈洖闆�' && item.button.value === 0,
+                  fuwei: item.button.name === '澶嶄綅' && item.button.value === 1,
+                  huiling:
+                    item.button.name === '鍥為浂' && item.button.value === 1,
+                  qidong:
+                    item.button.name === 'A01鍗婅嚜鍔�' && item.button.value === 1,
+                  qidong2:
+                    item.button.name === 'A02鍗婅嚜鍔�' && item.button.value === 1,
+                  qidong3:
+                    item.button.name === 'A01鍗婅嚜鍔ㄥ惎鍔�' &&
+                    item.button.value === 1,
+                  qidong4:
+                    item.button.name === 'A02鍗婅嚜鍔ㄥ惎鍔�' &&
+                    item.button.value === 1,
+                  qidong5:
+                    item.button.name === 'A02鍗婅嚜鍔�' && item.button.value === 1,
+                  jiting:
+                    item.button.name === '鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨' &&
+                    item.button.value === 1,
+                  yihuiling:
+                    item.button.name === '宸插洖闆�' && item.button.value === 1,
+                }"
+                @click="
+                  updateButtonValue(dataGroup, itemIndex);
+                  submitDataToBackend(item.button.name);
+                "
+                >{{ item.button.name }}</el-button
+              >
             </div>
           </div>
-        </el-col>
-      </el-row>
-      <div class="button-row" style="display: flex; justify-content: space-between;">
-        <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
-          <el-button v-if="item.button" :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === '鏁呴殰' && item.button.value === 1}" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button>
-
-        </div>
-      </div>
-    </el-card>
-  </el-col>
-</el-row>
+        </el-card>
+      </el-col>
+    </el-row>
 
     <!-- <el-button @click="submitDataToBackend">鎻愪氦鏁版嵁鍒板悗绔�</el-button> -->
   </div>
 </template>
 
 <script>
-import LanguageMixin from '../../lang/LanguageMixin'
-import data from '../../configuration/ServoManualone'
-import { throttle } from 'lodash';
+import LanguageMixin from "../../lang/LanguageMixin";
+import data from "../../configuration/ServoManualone";
+
 let socket;
-  export default {
+export default {
   name: "ServoManualone",
   mixins: [LanguageMixin],
+
   data() {
     return {
-      jsonData: data ,
-
+      jsonData: data,
+      language: this.$i18n.locale,
+      zhi: "1",
+      zhi2: "1",
       // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
-    }
+    };
   },
-  created () {
+
+  activated() {
     this.initWebSocket();
-    // console.log('jsonData:', this.jsonData); 
-
+    const language = this.$i18n.locale;
+    // console.log(language);
+    if (language === "en-US") {
+      this.replaceChineseWithEnglish();
+    }
+    this.$forceUpdate();
   },
+  // destroyed(){
+  // this.close();
+  // this.$router.go(0);
+  // },
   methods: {
+    closeSocket() {
+      // 鍏抽棴 WebSocket 杩炴帴
+      socket.close();
+    },
+
     updateButtonValue(dataGroup, itemIndex) {
-  // 灏嗗綋鍓嶆寜閽殑鍊艰涓�1
+      if (dataGroup[itemIndex].button.value === 1) {
+        // 濡傛灉褰撳墠鎸夐挳鐨勫�兼槸 0锛屽皢鍏惰涓� 1
+        this.$set(dataGroup[itemIndex].button, "value", 0);
+      } else {
+        // 鍚﹀垯灏嗗叾璁句负 0
+        this.$set(dataGroup[itemIndex].button, "value", 1);
+      }
+    },
+    zuhe1(event) {
+      const data = [];
 
-    this.$set(dataGroup[itemIndex].button, 'value', 1);
-    
-  
+      for (let i = 0; i < 1; i++) {
+        const inputData = this.jsonData[i]
+          .filter((item) => item.type === "0" && item.read !== 9999)
+          .map((item) => {
+            return { value: item.value };
+          });
 
-},
-submitDataToBackend(currentButtonName) {
-  if (currentButtonName === '鍗婅嚜鍔ㄥ惎鍔�') {
-    const data = [];
+        const values = inputData.map((item) => item.value);
+        // console.log(values)
+        if (values.length > 0) {
 
-for (let i = 0; i < 2; i++) {
-  const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
-    return { value: item.value };
-  });
 
-  const values = inputData.map(item => item.value);
+if (!(values[1] == "1" || values[1] == "2")) {
+  values.shift();
+  this.$message.error("Out of range");
+  return false;
+}
+// if (!(values[2] < "380" ) ) {
+//   values.shift();
+//   this.$message.error("Out of range");
+//   return false;
+// }
 
-  data.push(values);
+
+
+if (!(values[4] >= "1" && values[4]  <= "210")  && values[4]  !== "1000") {
+  values.shift();
+  this.$message.error("Out of range");
+  return false;
+}
+if (!(values[5] >= "1" && values[5]  <= "210")  && values[5]  !== "1000") {
+  values.shift();
+  this.$message.error("Out of range");
+  return false;
+}
+
+}
+ 
+        data.push(values);
+      }
+
+      data.push([], [], []);
+
+      for (let i = 0; i < 1; i++) {
+        const inputData = this.jsonData[i]
+          .filter((item) => item.type === "0" && item.read == 9999)
+          .map((item) => {
+            return { value: item.value };
+          });
+
+        const values = inputData.map((item) => item.value);
+        const pattern = /^[\w ]{1,14}$/;   // 鍖归厤闀垮害涓�14鐨勬暟瀛椼�佸瓧姣嶃�佺┖鏍肩殑缁勫悎
+if (!pattern.test(values[0])) {
+  values.shift();
+  this.$message.error("Please enter a 14-character string.");
+  return false;
+}
+       data.push(values);
+      }
+      data.push([], [], []);
+
+      const jsonObject = { data };
+
+      // 鎻愪氦鏁版嵁鍒板悗绔�
+      const jsonString = JSON.stringify(jsonObject);
+      console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
+      socket?.send(jsonString);
+      event.target.blur(); // 鍙栨秷杈撳叆妗嗙劍鐐�
+    },
+    zuhe2(event) {
+      const data2 = [];
+
+      for (let i = 1; i < 2; i++) {
+        const inputData = this.jsonData[i]
+          .filter((item) => item.type === "0" && item.read !== 8888)
+          .map((item) => {
+            return { value: item.value };
+          });
+
+        const values2 = inputData.map((item) => item.value);
+
+        if (values2.length > 0) {
+
+
+
+if (!(values2[1] >= "1" && values2[1]  <= "210")  && values2[1]  !== "1000") {
+  values2.shift();
+  this.$message.error("Out of range");
+  return false;
+}
+if (!(values2[2] >= "1" && values2[2]  <= "210")  && values2[2]  !== "1000") {
+  values2.shift();
+  this.$message.error("Out of range");
+  return false;
+}
+if (!(values2[3] == "1" || values2[3] == "2")) {
+  values2.shift();
+  this.$message.error("Out of range");
+  return false;
 }
 
 
-
-const jsonObject = { data };
-
-// 鎻愪氦鏁版嵁鍒板悗绔�
-const jsonString = JSON.stringify(jsonObject);
-console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
-socket?.send(jsonString);
-
-  }
-
-  if (currentButtonName === '澶嶄綅') {
-
-    const data2 = [];
-    const resetButtonValues = this.jsonData.map(item => {
-  const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '澶嶄綅');
-  return buttonItem ? buttonItem.button.value : null;
-}).filter(value => value !== null);
-
-// 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
-data2.push(...resetButtonValues);
-const jsonObject2 = { data2 };
-
-// 鎻愪氦鏁版嵁鍒板悗绔�
-const jsonString2 = JSON.stringify(jsonObject2);
-console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString2);
-socket?.send(jsonString2);
-
-
 }
-  if (currentButtonName === 'A01鍗婅嚜鍔�') {
-    const elements = document.getElementsByClassName('special-class');
-    for (let i = 0; i < elements.length; i++) {
-      if (elements[i].style.display === 'none') {
-        elements[i].style.display = ''; // 鏄剧ず鍏冪礌
-      } 
-    }
-  }
 
-  if (currentButtonName === 'A02鍗婅嚜鍔�') {
-    const elements = document.getElementsByClassName('special-class2');
-    for (let i = 0; i < elements.length; i++) {
-      if (elements[i].style.display === 'none') {
-        elements[i].style.display = ''; // 鏄剧ず鍏冪礌
-      } 
-    }
-  }
+        data2.push(values2);
+      }
+      data2.unshift([]);
 
- 
+      data2.push([], [], []);
 
-  
-},
+      for (let i = 1; i < 2; i++) {
+        const inputData = this.jsonData[i]
+          .filter((item) => item.type === "0" && item.read == 8888)
+          .map((item) => {
+            return { value: item.value };
+          });
 
+        const values2 = inputData.map((item) => item.value);
+        const pattern = /^[\w ]{1,14}$/;  // 鍖归厤闀垮害涓�14鐨勬暟瀛椼�佸瓧姣嶃�佺┖鏍肩殑缁勫悎
+if (!pattern.test(values2[0])) {
+  values2.shift();
+  this.$message.error("Please enter a 14-character string.");
+  return false;
+}
+        data2.push(values2);
+        data2.push([], [], []);
+      }
 
-    initWebSocket () {
- 
+      const jsonObject = { data: data2 };
+
+      // 鎻愪氦鏁版嵁鍒板悗绔�
+      const jsonString = JSON.stringify(jsonObject);
+      console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
+      socket?.send(jsonString);
+      event.target.blur(); // 鍙栨秷杈撳叆妗嗙劍鐐�
+    },
+    submitDataToBackend(currentButtonName) {
+      const data = [];
+      let jsonObject;
+      if (currentButtonName === "鏁呴殰" || currentButtonName === "Fault") {
+        return false;
+      }
+
+      if (
+        currentButtonName === "A01鍗婅嚜鍔ㄥ惎鍔�" ||
+        currentButtonName === "A01 Semi-Auto Start"
+      ) {
+        const values = [this.jsonData[0][10].button.value];
+        data.push(values);
+        data.unshift([], [], [], [], [], [], [], []);
+        jsonObject = { data };
+      }
+
+      if (
+        currentButtonName === "A02鍗婅嚜鍔ㄥ惎鍔�" ||
+        currentButtonName === "A02 Semi-Auto Start"
+      ) {
+        const values2 = [this.jsonData[1][8].button.value];
+        data.push(values2);
+        data.unshift([], [], [], [], [], [], [], [], []);
+        jsonObject = { data };
+      }
+
+      if (currentButtonName === "澶嶄綅" || currentButtonName === "Reset") {
+        const resetButtonValues = this.jsonData
+          .map((item) =>
+            item.find(
+              (subItem) =>
+                subItem.button &&
+                ["澶嶄綅", "Reset"].includes(subItem.button.name)
+            )
+          )
+          .filter((value) => value !== null)
+          .map((item) => item.button.value);
+
+        data.push(resetButtonValues.flat());
+        data.unshift([], []);
+        data.push([], [], [], [], []);
+        jsonObject = { data };
+      }
+
+      if (currentButtonName === "鍥為浂" || currentButtonName === "Home") {
+       
+        const resetButtonValues3 = this.jsonData
+          .map((item) => {
+            const buttonItem3 = item.find(
+              (subItem) =>
+                subItem.button && ["鍥為浂", "Home"].includes(subItem.button.name)
+            );
+
+            return buttonItem3 ? buttonItem3.button.value : null;
+          })
+          .filter((value) => value !== null);
+
+        // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+        data.push(resetButtonValues3.flat());
+
+        // 鍦� data3 鏁扮粍鍓嶉潰娣诲姞涓や釜绌烘暟缁�
+        data.unshift([], [], []);
+        data.push([], [], [], []);
+
+        // 鍒涘缓 jsonObject3 瀵硅薄锛屽苟娣诲姞 data3 灞炴��
+        jsonObject = { data };
+      }
+      if (
+        currentButtonName === "A01鍗婅嚜鍔�" ||
+        currentButtonName === "A01 Semi-Auto"
+      ) {
+        const elements = document.getElementsByClassName("special-class");
+        const data = [];
+
+        for (let i = 0; i < elements.length; i++) {
+          if (elements[i].style.display === "none") {
+            elements[i].style.display = ""; // 鏄剧ず鍏冪礌
+            this.zhi = 1;
+            // if(this.jsonData[0].button.name==='A01鍗婅嚜鍔�' || this.jsonData[0].button.name === 'A01 Semi-Auto'){
+            //   this.jsonData[0].button.value=1
+            // }
+
+            for (let i = 0; i < this.jsonData.length; i++) {
+              let arr = this.jsonData[i];
+              for (let j = 0; j < arr.length; j++) {
+                let obj2 = arr[j];
+                if (
+                  obj2.button &&
+                  (obj2.button.name === "A01鍗婅嚜鍔�" ||
+                    obj2.button.name === "A01 Semi-Auto")
+                ) {
+                  obj2.button.value = 1;
+                  // console.log(obj2.button.value)
+                }
+              }
+            }
+          } else {
+            elements[i].style.display = "none";
+            this.zhi = 0;
+            //  if(this.jsonData[0].button.name==='A01鍗婅嚜鍔�' || this.jsonData[0].button.name === 'A01 Semi-Auto'){
+            //     this.jsonData[0].button.value=0
+            //   }
+
+            for (let i = 0; i < this.jsonData.length; i++) {
+              let arr = this.jsonData[i];
+              for (let j = 0; j < arr.length; j++) {
+                let obj2 = arr[j];
+                if (
+                  obj2.button &&
+                  (obj2.button.name === "A01鍗婅嚜鍔�" ||
+                    obj2.button.name === "A01 Semi-Auto")
+                ) {
+                  obj2.button.value = 0;
+                  //  console.log(obj2.button.value)
+                }
+              }
+            }
+          }
+        }
+
+        data.push([this.zhi]);
+
+        data.unshift([], [], [], [], [], []);
+        data.push([]);
+
+        jsonObject = { data };
+
+        // 鎻愪氦鏁版嵁鍒板悗绔�
+      }
+
+      if (
+        currentButtonName === "A02鍗婅嚜鍔�" ||
+        currentButtonName === "A02 Semi-Auto"
+      ) {
+        // 鑾峰彇鎵�鏈塩lass涓簊pecial-class2鐨勫厓绱�
+        const elements = document.getElementsByClassName("special-class2");
+
+        const data = [];
+        // 閬嶅巻鎵�鏈夊厓绱�
+        for (let i = 0; i < elements.length; i++) {
+          // 濡傛灉鍏冪礌闅愯棌
+          if (elements[i].style.display === "none") {
+            // 鏄剧ず鍏冪礌
+            elements[i].style.display = ""; // 鏄剧ず鍏冪礌
+            this.zhi2 = 1;
+            // 閬嶅巻jsonData
+            for (let i = 0; i < this.jsonData.length; i++) {
+              let arr = this.jsonData[i];
+              // 閬嶅巻arr
+              for (let j = 0; j < arr.length; j++) {
+                let obj2 = arr[j];
+                // 濡傛灉button鐨刵ame涓篈02鍗婅嚜鍔ㄦ垨鑰匒02 Semi-Auto
+                if (
+                  obj2.button &&
+                  (obj2.button.name === "A02鍗婅嚜鍔�" ||
+                    obj2.button.name === "A02 Semi-Auto")
+                ) {
+                  // 璁剧疆button鐨剉alue涓�1
+                  obj2.button.value = 1;
+                  // console.log(obj2.button.value)
+                }
+              }
+            }
+          } else {
+            // 濡傛灉鍏冪礌鏄剧ず
+            elements[i].style.display = "none";
+            this.zhi2 = 0;
+            // 閬嶅巻jsonData
+            for (let i = 0; i < this.jsonData.length; i++) {
+              let arr = this.jsonData[i];
+              // 閬嶅巻arr
+              for (let j = 0; j < arr.length; j++) {
+                let obj2 = arr[j];
+                // 濡傛灉button鐨刵ame涓篈02鍗婅嚜鍔ㄦ垨鑰匒02 Semi-Auto
+                if (
+                  obj2.button &&
+                  (obj2.button.name === "A02鍗婅嚜鍔�" ||
+                    obj2.button.name === "A02 Semi-Auto")
+                ) {
+                  // 璁剧疆button鐨剉alue涓�0
+                  obj2.button.value = 0;
+                  // console.log(obj2.button.value)
+                }
+              }
+            }
+          }
+        }
+
+        // 灏唞hi2娣诲姞鍒癲ata鏁扮粍涓�
+        data.push([this.zhi2]);
+
+        // 灏哾ata鏁扮粍娣诲姞鍒癹sonObject涓�
+        data.unshift([], [], [], [], [], [], []);
+
+        jsonObject = { data };
+      }
+
+      const jsonString = JSON.stringify(jsonObject);
+      console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
+      socket?.send(jsonString);
+
+      setTimeout(() => {
+    const reversedData = data.map(values => values.map(value => {
+      return   (!value || value === 0) ? 0 : 0 ;
+    }));
+
+    const reversedJsonObject = { data: reversedData };
+
+    // 鎻愪氦鏁版嵁鍒板悗绔�
+    const reversedJsonString = JSON.stringify(reversedJsonObject);
+    console.log('鍙嶈浆鍚�:', reversedJsonString);
+    socket?.send(reversedJsonString);
+  }, 1000);
+    },
+
+    initWebSocket() {
       let viewname = "ServoManualone";
 
       if (typeof WebSocket === "undefined") {
         console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
       } else {
-        let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
+        let socketUrl =
+          "ws://" +
+          this.$t("ip") +
+          ":8888" +
+          "/springboot-vue3/api/talk/" +
+          viewname;
 
         if (socket != null) {
           socket.close();
           socket = null;
         }
-
         // 寮�鍚竴涓獁ebsocket鏈嶅姟
         socket = new WebSocket(socketUrl);
 
@@ -175,65 +705,230 @@
           console.log("websocket宸叉墦寮�");
         };
 
-        // 鏀跺埌娑堟伅
+        // let 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) {
-    return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+          if (!msg.data) {
+            return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+          }
+          let obj = JSON.parse(msg.data);
+
+          // console.log(obj)
+          const weihuiling = obj.weihuiling;
+          const jsonData2 = this.jsonData;
+          if (document.activeElement.tagName.toLowerCase() === 'input') {
+    return;
   }
 
-  let obj = JSON.parse(msg.data);
-  // console.log(obj)
-  const jsonData2 = this.jsonData;
+          if (obj.zuhe1 ) {
+            //鍚姩鎸夐挳
 
-  const handleMouseMove = throttle(function(event) {
-  const inputBox = document.querySelectorAll('.el-card__body');
-  const target = event.target;
-  if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
-    // 鎵ц鏇存柊閫昏緫
-    for (let i = 0; i < 6; i++) {
-  jsonData2[i].forEach((item, index) => {
-    if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i+1}`][0][index] !== 'undefined') {
-      item.value = obj[`zuhe${i+1}`][0][index];
-    }
-  });
-}
+            // 鎵ц鏇存柊閫昏緫
+            for (let i = 0; i < 6; i++) {
+              jsonData2[i].forEach((item, index) => {
+                if (
+                  typeof item.value !== "undefined" &&
+                  typeof obj[`zuhe${i + 1}`][0][index] !== "undefined" &&
+                  item.read !== "9999" &&
+                  item.read !== "8888"
+                ) {
+                  item.value = obj[`zuhe${i + 1}`][0][index];
+                }
+              });
+            }
 
-// 閬嶅巻guzhang鏁扮粍
-for (let i = 0; i < obj.guzhang[0].length; i++) {
-  const guzhangValue = obj.guzhang[0][i];
-  
-  // 鏌ユ壘jsonData2涓甫鏈�"button"鐨勫璞★紝骞朵笖name绛変簬"鏁呴殰"
-  for (let j = 0; j < jsonData2.length; j++) {
-    const section = jsonData2[j];
-    
-    for (let k = 0; k < section.length; k++) {
-      const item = section[k];
-      
-      if (item.button && item.button.name === "鏁呴殰") {
-        // 鏇存柊value灞炴��
-        item.button.value = guzhangValue;
-        break;
-      }
-    }
-    
-  
-  }
-}
+            //杩涚墖id
+            jsonData2.forEach((item) => {
+              item.forEach((subItem) => {
+                if (subItem.read === 9999) {
+                  subItem.value = obj.jinpianid[0];
+                }
+              });
+            });
+            //鍙栫墖id
+            jsonData2.forEach((item) => {
+              item.forEach((subItem) => {
+                if (subItem.read === 8888) {
+                  subItem.value = obj.qupianid[0];
+                }
+              });
+            });
+          }
 
+          if (obj.qidong) {
+            jsonData2[0][9].button.value = obj.qidong[0][0]; // 绗竴涓瓙鏁扮粍涓涓�涓� type=66 鐨� button
+            jsonData2[0][10].button.value = obj.qidong[0][1]; // 绗竴涓瓙鏁扮粍涓浜屼釜 type=66 鐨� button
+            jsonData2[1][7].button.value = obj.qidong[0][2]; // 绗簩涓瓙鏁扮粍涓涓�涓� type=66 鐨� button
+            jsonData2[1][8].button.value = obj.qidong[0][3];
+            //鏁呴殰鏇存柊
 
+            for (let i = 0; i < jsonData2.length; i++) {
+              let arr = jsonData2[i];
+              for (let j = 0; j < arr.length; j++) {
+                let obj2 = arr[j];
+                if (
+                  obj2.button &&
+                  (obj2.button.name === "鏁呴殰" || obj2.button.name === "Fault")
+                ) {
+                  obj2.button.value = obj.guzhang[0][i];
+                  //  console.log(obj2.button.value)
+                }
+              }
+            }
 
+            // 澶嶄綅鏇存柊
+            for (let i = 0; i < jsonData2.length; i++) {
+              let arr = jsonData2[i];
+              for (let j = 0; j < arr.length; j++) {
+                let obj2 = arr[j];
+                if (
+                  obj2.button &&
+                  (obj2.button.name === "澶嶄綅" || obj2.button.name === "Reset")
+                ) {
+                  obj2.button.value = obj.fuwei[0][i];
+                  //  console.log(obj2.button.value)
+                }
+              }
+            }
 
+            //鏈洖闆舵洿鏂�
 
+            jsonData2[2][3].button.value = weihuiling[0][0];
+            jsonData2[3][3].button.value = weihuiling[0][1];
+            jsonData2[4][4].button.value = weihuiling[0][2];
+            jsonData2[5][4].button.value = weihuiling[0][3];
 
+            // if(jsonData2[2][3].button.value===1){
 
-  }
-}, 200);
+            //   jsonData2[2][3].button.name.replace("鏈洖闆�","鍥為浂") ;
+            // }
 
-  document.addEventListener('mouseover', handleMouseMove);
-};
+            // console.log(jsonData2[5][4].button.value)
+            if (
+              jsonData2[2][3].button.value === 1 &&
+              (jsonData2[2][3].button.name === "NotZero" ||
+                jsonData2[2][3].button.name === "鏈洖闆�")
+            ) {
+              jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+                "鏈洖闆�",
+                "宸插洖闆�"
+              );
+              jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+                "NotZero",
+                "Zero"
+              );
+            }
+            if (
+              jsonData2[3][3].button.value === 1 &&
+              (jsonData2[3][3].button.name === "NotZero" ||
+                jsonData2[3][3].button.name === "鏈洖闆�")
+            ) {
+              jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+                "鏈洖闆�",
+                "宸插洖闆�"
+              );
+              jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+                "NotZero",
+                "Zero"
+              );
+            }
+            if (
+              jsonData2[4][4].button.value === 1 &&
+              (jsonData2[4][4].button.name === "NotZero" ||
+                jsonData2[4][4].button.name === "鏈洖闆�")
+            ) {
+              jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+                "鏈洖闆�",
+                "宸插洖闆�"
+              );
+              jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+                "NotZero",
+                "Zero"
+              );
+            }
+            if (
+              jsonData2[5][4].button.value === 1 &&
+              (jsonData2[5][4].button.name === "NotZero" ||
+                jsonData2[5][4].button.name === "鏈洖闆�")
+            ) {
+              jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+                "鏈洖闆�",
+                "宸插洖闆�"
+              );
+              jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+                "NotZero",
+                "Zero"
+              );
+            }
 
-
-
+            if (
+              jsonData2[2][3].button.value === 0 &&
+              (jsonData2[2][3].button.name === "Zero" ||
+                jsonData2[2][3].button.name === "宸插洖闆�")
+            ) {
+              jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+                "宸插洖闆�",
+                "鏈洖闆�"
+              );
+              jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+                "Zero",
+                "NotZero"
+              );
+            }
+            if (
+              jsonData2[3][3].button.value === 0 &&
+              (jsonData2[3][3].button.name === "Zero" ||
+                jsonData2[3][3].button.name === "宸插洖闆�")
+            ) {
+              jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+                "宸插洖闆�",
+                "鏈洖闆�"
+              );
+              jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+                "Zero",
+                "NotZero"
+              );
+            }
+            if (
+              jsonData2[4][4].button.value === 0 &&
+              (jsonData2[4][4].button.name === "Zero" ||
+                jsonData2[4][4].button.name === "宸插洖闆�")
+            ) {
+              jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+                "宸插洖闆�",
+                "鏈洖闆�"
+              );
+              jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+                "Zero",
+                "NotZero"
+              );
+            }
+            if (
+              jsonData2[5][4].button.value === 0 &&
+              (jsonData2[5][4].button.name === "Zero" ||
+                jsonData2[5][4].button.name === "宸插洖闆�")
+            ) {
+              jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+                "宸插洖闆�",
+                "鏈洖闆�"
+              );
+              jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+                "Zero",
+                "NotZero"
+              );
+            }
+          }
+        };
 
         // 鍏抽棴浜嬩欢
         socket.onclose = function () {
@@ -244,21 +939,46 @@
         socket.onerror = function () {
           console.log("websocket鍙戠敓浜嗛敊璇�");
         };
-
+        this.$router.afterEach(function () {
+          socket.close();
+        });
       }
     },
-    send () {
-     
-     
+    send() {
       socket?.send(JSON.stringify(this.messagepack));
-    }
+    },
+    //鏇挎崲璇█
+    replaceChineseWithEnglish() {
+      const nameMap = this.$t("ServoManualone");
+      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)
+    },
+  },
+};
 </script>
 
 <style scoped>
-
+html,
+body {
+  width: 100%;
+  height: 85%;
+}
 
 .item-row {
   display: flex;
@@ -269,7 +989,7 @@
 .action-button {
   margin-right: 10px;
   background: #66b1ff;
-  color: #FFF;
+  color: #fff;
 }
 .blue-button {
   background-color: skyblue;
@@ -278,5 +998,44 @@
   background-color: red;
 }
 
+.error-button2 {
+  background-color: red;
+}
+.fuwei {
+  background-color: green;
+}
 
+.qidong {
+  background-color: green;
+}
+
+.qidong3 {
+  background-color: green;
+}
+.qidong {
+  background-color: green;
+}
+
+.qidong4 {
+  background-color: green;
+}
+
+.qidong5 {
+  background-color: green;
+}
+
+.huiling {
+  background-color: green;
+}
+.jiting {
+  background-color: green;
+}
+
+.error-button3 {
+  background-color: green;
+}
+
+.yihuiling {
+  background-color: green;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.8.0