ZengTao
2023-12-27 50122609dfab86da64df82396a30a30455e5bd67
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++) {
@@ -328,7 +328,36 @@
          });
        const values = inputData.map((item) => item.value);
        // console.log(values)
        if (values.length > 0) {
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;
// }
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);
      }
@@ -342,8 +371,13 @@
          });
        const values = inputData.map((item) => item.value);
        data.push(values);
        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([], [], []);
@@ -353,8 +387,9 @@
      const jsonString = JSON.stringify(jsonObject);
      console.log("所有Type为0的value:", jsonString);
      socket?.send(jsonString);
      event.target.blur(); // 取消输入框焦点
    },
    zuhe2() {
    zuhe2(event) {
      const data2 = [];
      for (let i = 1; i < 2; i++) {
@@ -365,6 +400,29 @@
          });
        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;
}
}
        data2.push(values2);
      }
@@ -380,7 +438,12 @@
          });
        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([], [], []);
      }
@@ -391,6 +454,7 @@
      const jsonString = JSON.stringify(jsonObject);
      console.log("所有Type为0的value:", jsonString);
      socket?.send(jsonString);
      event.target.blur(); // 取消输入框焦点
    },
    submitDataToBackend(currentButtonName) {
      const data = [];
@@ -620,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) {
@@ -641,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 ) {
            //启动按钮
            // 执行更新逻辑