wu
2023-12-18 37f7f87968cfd2c400283fbf83851c39c2c4d456
CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -5,8 +5,8 @@
      }}</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/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')
@@ -60,9 +60,23 @@
          <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container">
            <div class="item-row">
              <span class="name" style="width:250px;">{{ item.name }}</span>
              <el-input v-if="item.type === '0'" v-model="item.value" class="input-box"
                @keyup.enter.native="submitDataToBackend"></el-input>
                <span v-if="item.unit" :name="item.unit" >{{ item.unit }}</span>
              <!-- <el-input v-if="item.type === '0'"
            v-model="item.value"
            class="input-box"
            :oninput="`value=value.replace(/^0|[^0-9]/g,'');if(value<`+item.min+`){value=`+item.value+`}else if(value>`+item.max+`){value=`+item.value+`}`"
            @keyup.enter.native="submitDataToBackend">
  </el-input> -->
  <el-input v-if="item.type === '0'"
            v-model="item.value"
            class="input-box"
            @keyup.enter.native="submitDataToBackend">
  </el-input>
                <span v-if="item.unit" :name="item.unit"  >{{ item.unit }}</span>
            </div>
          </div>
@@ -77,7 +91,7 @@
<script>
import LanguageMixin from '../../lang/LanguageMixin'
import data from '../../configuration/AutomaticParameterSetting'
import { throttle } from 'lodash';
let socket;
export default {
@@ -107,6 +121,11 @@
    },
    updateButtonValue (dataGroup, itemIndex) {
      this.$set(dataGroup[itemIndex].button, 'value', 1); // 点击按钮后将值改为1
    },
    checkInputValue() {
      if (this.item.value < this.item.min || this.item.value > this.item.max) {
        this.item.value = ''; // 清空输入框的值
      }
    },
    submitDataToBackend () {
      const inputData = this.jsonData.map(dataGroup => {
@@ -163,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));
};
@@ -295,7 +304,7 @@
      });
      console.log(this.jsonData)
      //console.log(this.jsonData)
    }