ZengTao
2023-12-20 aff3977ee493cfa7554792285100c7b6407e1d74
CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
@@ -106,6 +106,7 @@
import data from '../../configuration/Manualoneposition'
import ManualonePosition2 from './ManualonePosition2.vue';
// import { createWebSocket } from '../../api/websocket.js';
let socket;
export default {
  name: "ManualonePosition",
@@ -156,14 +157,30 @@
for (let i = 0; i < 1; i++) {
  const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
    return { value: item.value };
  });
  const values = inputData.map(item => item.value);
  console.log(values);
if (values.length > 0) {
  let firstValue = values[0];
  if (!(firstValue >= "1" && firstValue <= "210") && firstValue !== "888" && firstValue !== "1000") {
    values.shift();
    this.$message.error("Out of range");
    return false;
  }
}
  data.push(values);
}
data.push([], [], [],[],[],[]);
@@ -184,6 +201,15 @@
  });
  const values = inputData.map(item => item.value);
  if (values.length > 0) {
let firstValue = values[0];
if (!(firstValue >= "1" && firstValue <= "210") && firstValue !== "888" && firstValue !== "1000") {
  values.shift();
  this.$message.error("Out of range");
  return false;
}
}
  data.unshift([]);
  data.push(values);
}
@@ -431,6 +457,18 @@
        };
        // 收到消息
        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; // 如果收到空数据,则直接返回,不执行后续逻辑
@@ -439,23 +477,11 @@
          let obj = JSON.parse(msg.data);
          const jsonData2 = this.jsonData;
          const weihuiling = obj.weihuiling;
          const handleMouseMove = (event) => {
    if (!event || !event.target) {
      return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑
    }
    const inputBox = document.querySelectorAll('.input-box');
    const target = event.target;
  if(obj.zuhe1&& !isMouseInInputBox){
    // console.log(obj);
    const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
    if (!isMouseInInput) {
  if(obj.zuhe1){
  
              // 执行更新逻辑
              for (let i = 0; i < 4; i++) {
@@ -467,13 +493,7 @@
              }
            }
            }
        }
              // console.log(jsonData2);
              setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置
document.addEventListener('mousemove', event => handleMouseMove(event));