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>
              <!-- <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 => {
@@ -169,12 +188,17 @@
          let obj = JSON.parse(msg.data);
          const jsonData2 = this.jsonData;
          // console.log(obj);
          const handleMouseMove = throttle(function (event) {
  const handleMouseMove = (event) => {
    if (!event || !event.target) {
      return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑
    }
            const inputBox = document.querySelectorAll('.input-box');
            const target = event.target;
            if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
    const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
    if (!isMouseInInput) {
              const parms = obj.params;
              const fanzhuan = obj.fanzhuan;
              const xiaoche = obj.xiaoche;
@@ -183,11 +207,6 @@
              const parms2 = obj.params2;
              const fanzhuan2 = obj.fanzhuan2;
              const xiaoche2 = obj.xiaoche2;
              // console.log('parms:', parms);
              // console.log('fanzhuan:', fanzhuan);
              // console.log('xiaoche:', xiaoche);
              // console.log('dache:', dache);
              let index = 0;
              for (let i = 0; i < jsonData2.length - 1; i++) {
@@ -213,10 +232,6 @@
                jsonData2[2][0]['value'] = dache[0][0];
              }
           
            let index2 = 0;
              for (let i =5; i < jsonData2.length; i++) {
                let arr = jsonData2[i];
@@ -237,19 +252,13 @@
              if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) {
                jsonData2[9][0]['value'] = xiaoche2[0][0];
              }
            }
          }, 50);
          document.addEventListener('mouseover', handleMouseMove);
        };
  setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置
document.addEventListener('mousemove', event => handleMouseMove(event));
};
@@ -295,7 +304,7 @@
      });
      console.log(this.jsonData)
      //console.log(this.jsonData)
    }