ZengTao
2023-12-27 50122609dfab86da64df82396a30a30455e5bd67
CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
@@ -56,21 +56,21 @@
              <span class="name" style="width:300px;">{{ item.name }}</span>
                <el-input style="width:250px;"  v-if="item.state != 0 && item.type === '0' && groupIndex === 0 && (itemIndex === 2)"  readonly v-model="item.value"  
                class="input-box"></el-input>
                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+`}`"   ></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 "  v-model="item.value"  @keyup.enter.native="A01start"
                class="input-box"></el-input>
                <el-input style="width: 250px;" v-else-if="(item.state !== 0) && (item.type === '0') && (itemIndex === 2)" v-model="item.value" readonly class="input-box"></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 "  v-model="item.value"  @keyup.enter.native="A01start($event)"
                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+`}`"  ></el-input>
                <el-input style="width: 250px;" v-else-if="(item.state !== 0) && (item.type === '0') && (itemIndex === 2)" v-model="item.value" readonly class="input-box"   ></el-input>
                
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1" v-model="item.value"  @keyup.enter.native="A02start"
                class="input-box"></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 2" v-model="item.value"  @keyup.enter.native="B01start"
                class="input-box"></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 3" v-model="item.value"  @keyup.enter.native="B02start"
                class="input-box"></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1" v-model="item.value"  @keyup.enter.native="A02start($event)"
                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+`}`"  ></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 2" v-model="item.value"  @keyup.enter.native="B01start($event)"
                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+`}`"  ></el-input>
                <el-input style="width:250px;"  v-else-if="item.state != 0 && item.type === '0' && groupIndex === 3" v-model="item.value"  @keyup.enter.native="B02start($event)"
                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+`}`" ></el-input>
                <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0'" v-model="item.value"
                class="input-box"></el-input>
                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+`}`" ></el-input>
            </div>
          </div>
          <div class="button-row" style="display: flex; justify-content: space-between;">
@@ -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",
@@ -150,20 +151,36 @@
    },
    A01start(){
    A01start(event){
      const data = [];
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([], [], [],[],[],[]);
@@ -173,9 +190,9 @@
const jsonString = JSON.stringify(jsonObject);
console.log('所有Type为0的value:', jsonString);
socket?.send(jsonString);
event.target.blur(); // 取消输入框焦点
    },
    A02start(){
    A02start(event){
      const data = [];
for (let i = 1; i < 2; i++) {
@@ -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);
}
@@ -197,9 +223,9 @@
const jsonString = JSON.stringify(jsonObject);
console.log('所有Type为0的value:', jsonString);
socket?.send(jsonString);
event.target.blur(); // 取消输入框焦点
    },
    B01start(){
    B01start(event){
      const data = [];
for (let i = 2; i < 3; i++) {
@@ -222,9 +248,9 @@
const jsonString = JSON.stringify(jsonObject);
console.log('所有Type为0的value:', jsonString);
socket?.send(jsonString);
event.target.blur(); // 取消输入框焦点
    },
    B02start(){
    B02start(event){
      const data = [];
for (let i = 3; i < 4; i++) {
@@ -233,6 +259,16 @@
  });
  const values = inputData.map(item => item.value);
  if (values.length > 0) {
let firstValue = values[0];
if (!(firstValue >= "106" && firstValue <= "210")) {
  values.shift();
  this.$message.error("Out of range");
  return false;
}
}
  data.unshift([], [], []);
  data.push(values);
}
@@ -247,7 +283,7 @@
const jsonString = JSON.stringify(jsonObject);
console.log('所有Type为0的value:', jsonString);
socket?.send(jsonString);
event.target.blur(); // 取消输入框焦点
    },
    submitDataToBackend (currentButtonName) {
      if (currentButtonName === 'A01启动' || currentButtonName === 'A01 Start') {
@@ -404,7 +440,7 @@
      }
    },
@@ -431,21 +467,26 @@
        };
        // 收到消息
        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) {
    return; // 如果收到空数据,则直接返回,不执行后续逻辑
  }
   // 添加判断条件:如果光标在输入框内,则不执行后续逻辑
   if (document.activeElement.tagName.toLowerCase() === 'input') {
    return;
  }
          let obj = JSON.parse(msg.data);
@@ -453,7 +494,7 @@
          const weihuiling = obj.weihuiling;
  if(obj.zuhe1&& !isMouseInInputBox){
  if(obj.zuhe1){
// console.log(obj);