ZengTao
2023-12-15 a6eb7e9a101b007adfa9b2f7a719dfd6f9e7f259
CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -91,7 +91,7 @@
<script>
import LanguageMixin from '../../lang/LanguageMixin'
import data from '../../configuration/AutomaticParameterSetting'
import { throttle } from 'lodash';
let socket;
export default {
@@ -182,93 +182,83 @@
        // 收到消息
        socket.onmessage = (msg) => {
          if (!msg.data) {
            return; // 如果收到空数据,则直接返回,不执行后续逻辑
          }
  if (!msg.data) {
    return; // 如果收到空数据,则直接返回,不执行后续逻辑
  }
          let obj = JSON.parse(msg.data);
          const jsonData2 = this.jsonData;
          // console.log(obj);
          const handleMouseMove = throttle(function (event) {
  let obj = JSON.parse(msg.data);
  const jsonData2 = this.jsonData;
            const inputBox = document.querySelectorAll('.input-box');
            const target = event.target;
            if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
              const parms = obj.params;
              const fanzhuan = obj.fanzhuan;
              const xiaoche = obj.xiaoche;
              const dache = obj.dache1;
  const handleMouseMove = (event) => {
    if (!event || !event.target) {
      return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑
    }
              const parms2 = obj.params2;
              const fanzhuan2 = obj.fanzhuan2;
              const xiaoche2 = obj.xiaoche2;
    const inputBox = document.querySelectorAll('.input-box');
    const target = event.target;
    const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
              // console.log('parms:', parms);
              // console.log('fanzhuan:', fanzhuan);
              // console.log('xiaoche:', xiaoche);
              // console.log('dache:', dache);
    if (!isMouseInInput) {
      const parms = obj.params;
      const fanzhuan = obj.fanzhuan;
      const xiaoche = obj.xiaoche;
      const dache = obj.dache1;
              let index = 0;
              for (let i = 0; i < jsonData2.length - 1; i++) {
                let arr = jsonData2[i];
      const parms2 = obj.params2;
      const fanzhuan2 = obj.fanzhuan2;
      const xiaoche2 = obj.xiaoche2;
                for (let j = 0; j < arr.length; j++) {
                  let obj = arr[j];
                  if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) {
                    if (Array.isArray(parms) && Array.isArray(parms[0]) && parms[0][index] !== undefined) {
                      obj.value = parms[0][index];
                      index++;
                    }
                  }
                }
              }
              if (Array.isArray(fanzhuan) && Array.isArray(fanzhuan[0]) && fanzhuan[0][0] !== undefined) {
                jsonData2[4][0]['value'] = fanzhuan[0][0];
              }
              if (Array.isArray(xiaoche) && Array.isArray(xiaoche[0]) && xiaoche[0][0] !== undefined) {
                jsonData2[3][0]['value'] = xiaoche[0][0];
              }
              if (Array.isArray(dache) && Array.isArray(dache[0]) && dache[0][0] !== undefined) {
                jsonData2[2][0]['value'] = dache[0][0];
              }
      let index = 0;
      for (let i = 0; i < jsonData2.length - 1; i++) {
        let arr = jsonData2[i];
            let index2 = 0;
              for (let i =5; i < jsonData2.length; i++) {
                let arr = jsonData2[i];
                for (let j = 0; j < arr.length; j++) {
                  let obj2 = arr[j];
                  if (obj2.type === '0' && Object.prototype.hasOwnProperty.call(obj2, 'value')) {
                    if (Array.isArray(parms2) && Array.isArray(parms2[0]) && parms2[0][index2] !== undefined) {
                      obj2.value = parms2[0][index2];
                      index2++;
                    }
                  }
                }
              }
              if (Array.isArray(fanzhuan2) && Array.isArray(fanzhuan2[0]) && fanzhuan2[0][0] !== undefined) {
                jsonData2[8][0]['value'] = fanzhuan2[0][0];
              }
              if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) {
                jsonData2[9][0]['value'] = xiaoche2[0][0];
              }
        for (let j = 0; j < arr.length; j++) {
          let obj = arr[j];
          if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) {
            if (Array.isArray(parms) && Array.isArray(parms[0]) && parms[0][index] !== undefined) {
              obj.value = parms[0][index];
              index++;
            }
          }
        }
      }
      if (Array.isArray(fanzhuan) && Array.isArray(fanzhuan[0]) && fanzhuan[0][0] !== undefined) {
        jsonData2[4][0]['value'] = fanzhuan[0][0];
      }
      if (Array.isArray(xiaoche) && Array.isArray(xiaoche[0]) && xiaoche[0][0] !== undefined) {
        jsonData2[3][0]['value'] = xiaoche[0][0];
      }
      if (Array.isArray(dache) && Array.isArray(dache[0]) && dache[0][0] !== undefined) {
        jsonData2[2][0]['value'] = dache[0][0];
      }
      let index2 = 0;
      for (let i = 5; i < jsonData2.length; i++) {
        let arr = jsonData2[i];
        for (let j = 0; j < arr.length; j++) {
          let obj2 = arr[j];
          if (obj2.type === '0' && Object.prototype.hasOwnProperty.call(obj2, 'value')) {
            if (Array.isArray(parms2) && Array.isArray(parms2[0]) && parms2[0][index2] !== undefined) {
              obj2.value = parms2[0][index2];
              index2++;
            }
          }
        }
      }
      if (Array.isArray(fanzhuan2) && Array.isArray(fanzhuan2[0]) && fanzhuan2[0][0] !== undefined) {
        jsonData2[8][0]['value'] = fanzhuan2[0][0];
      }
      if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) {
        jsonData2[9][0]['value'] = xiaoche2[0][0];
      }
    }
  };
  setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置
          }, 50);
          document.addEventListener('mouseover', handleMouseMove);
        };
document.addEventListener('mousemove', event => handleMouseMove(event));
};
@@ -314,7 +304,7 @@
      });
      console.log(this.jsonData)
      //console.log(this.jsonData)
    }