wuyouming666
2024-05-09 92dab966727b26c69a8a1d5839b064f7942895e8
CanadaMes-ui/src/views/Electrical/Parameter2.vue
@@ -8,35 +8,20 @@
        active-class="blue-button"
        >{{ $t("Alarm") }}</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/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") }}</router-link
        >{{ $t("I/O") }}</router-link
      >
      <router-link
        to="/Electrical/Servomanual"
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("Parameter") }}</router-link
        >{{ $t("Manual/Automatic") }}</router-link
      >
    </el-breadcrumb>
@@ -46,54 +31,37 @@
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("Automatic State") }}</router-link
        >{{ $t("Glass Data") }}</router-link
      >
      <router-link
        to="/Electrical/ManualJog"
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("ManualJog") }}</router-link
      >
      <router-link
        to="/Electrical/ManualonePosition"
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("ManualonePosition") }}</router-link
        >{{ $t("Manual Control") }}</router-link
      >
      <router-link
        to="/Electrical/Servomanualone"
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("Servomanualone") }}</router-link
      >
      <!-- <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1')
      }}</router-link> -->
      <router-link v-show="false" v-if="hasPermission" to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">
    {{ $t('Servomanualone') }}
  </router-link>
      <router-link   v-if="hasPermission" to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{
        $t('Cage Positions')
      }}</router-link>
      <router-link   v-if="hasPermission" to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{
        $t('Speed parameter settings')
      }}</router-link>
      <router-link
        to="/Electrical/Positioning1"
<router-link  v-if="hasPermission"
        to="/Electrical/InteractionState"
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("Address parameter settings") }}</router-link
      >
      <!-- <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
        $t('Positioning2')
      }}</router-link> -->
      <!--
      <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{
        $t('ManualonePosition2')
      }}</router-link> -->
      <router-link
        to="/Electrical/AutomaticParameterSetting"
        tag="el-button"
        type="text"
        active-class="blue-button"
        >{{ $t("Speed parameter settings") }}</router-link
        >{{ $t("PLC-MES Info") }}</router-link
      >
    </el-breadcrumb>
@@ -140,8 +108,15 @@
                    item.button.value === 2 && item.button.name !== 'Clear ID',
                  'yellow-button':
                    item.button.value === 1 && item.button.name !== 'Clear ID',
                  id:
                  'id':
                    item.button.value === 1 && item.button.name === 'Clear ID',
                    'A01jiting':item.button.value === 0 && item.button.name === 'A01Abort/ResumeTasks',
                    'A02jiting':item.button.value === 0 && item.button.name === 'A02Abort/ResumeTasks',
                    'emgHMI':item.button.value === 0 && item.button.name === 'emgHMI',
                    'GA01jiting':item.button.value ===1 && item.button.name === 'A01Abort/ResumeTasks',
                    'GA02jiting':item.button.value === 1 && item.button.name === 'A02Abort/ResumeTasks',
                    'GemgHMI':item.button.value === 1 && item.button.name === 'emgHMI'
                }"
                >{{ item.button.name }}</el-button
              >
@@ -162,7 +137,14 @@
                    item.button.value === 2 && item.button.name !== '清除ID',
                  'yellow-button':
                    item.button.value === 1 && item.button.name !== '清除ID',
                  id: item.button.value === 1 && item.button.name === '清除ID',
                  'id': item.button.value === 1 && item.button.name === '清除ID',
                  'A01jiting':item.button.value === 0 && item.button.name === 'A01终止/继续',
                  'A02jiting':item.button.value === 0 && item.button.name === 'A02终止/继续',
                  'emgHMI':item.button.value === 0 && item.button.name === '软急停',
                  'GA01jiting':item.button.value === 1 && item.button.name === 'A01终止/继续',
                  'GA02jiting':item.button.value === 1 && item.button.name === 'A02终止/继续',
                  'GemgHMI':item.button.value === 1 && item.button.name === '软急停'
                }"
                >{{ item.button.name }}</el-button
              >
@@ -186,7 +168,7 @@
  <el-input
                v-if="item.type === '0' && groupIndex==15"
                v-model="item.value"
                @keyup.enter.native="timeout"
                @keyup.enter.native="timeout($event)"
                style="width: 300px"
                class="input-box2"
              ></el-input>
@@ -209,6 +191,9 @@
  <script>
import LanguageMixin from "../../lang/LanguageMixin";
import data from "../../configuration/parameter2";
import {
SelectPermissionByUserName, currentUsername
} from "../../api/home";
// import { throttle } from 'lodash';
let socket;
@@ -226,12 +211,16 @@
      jsonData: data,
      inputValue: "",
      language: this.$i18n.locale,
      hasPermission: false // 默认没有权限
      // 加载整个data.json文件作为jsonData
    };
  },
  activated() {
    document.body.style.zoom = "90%";
    this.initWebSocket();
    this.filteredData();
    const language = this.$i18n.locale;
@@ -240,6 +229,17 @@
      this.replaceChineseWithEnglish();
    }
    this.$forceUpdate();
    currentUsername().then(res => {
                SelectPermissionByUserName(res.data).then(res => {
                    res.data.permission.forEach(item => {
                        if (item.permissionId == "36" && item.state == 1) {
                            this.hasPermission = true;
                        }
                    });
                });
            });
  },
  computed: {},
@@ -265,16 +265,19 @@
    },
    updateButtonValue(dataGroup, itemIndex) {
      if (dataGroup[itemIndex].button.value === 1) {
      console.log(dataGroup)
      console.log(itemIndex)
      if (dataGroup[itemIndex].button.value2 === 1) {
        // 如果当前按钮的值是 0,将其设为 1
        this.$set(dataGroup[itemIndex].button, "value", 0);
        this.$set(dataGroup[itemIndex].button, "value2", 0);
      } else {
        // 否则将其设为 0
        this.$set(dataGroup[itemIndex].button, "value", 1);
        this.$set(dataGroup[itemIndex].button, "value2", 1);
      }
    },
    //范围 0-100
    timeout(){
    timeout(event){
    
        const data3 = [];
@@ -306,7 +309,7 @@
        // setTimeout(()=>
        //   window.location.reload(),2000
        // )
        event.target.blur(); // 取消输入框焦点
    },
@@ -322,13 +325,13 @@
                ["清除ID", "Clear ID"].includes(subItem.button.name)
            );
            return buttonItem ? buttonItem.button.value : null;
            return buttonItem ? buttonItem.button.value2 : null;
          })
          .filter((value) => value !== null);
          .filter((value2) => value2 !== null);
        // 将得到的值添加到 data 数组中
        data2.push(resetButtonValues.flat());
        data2.push([]);
        data2.push([],[]);
        // 在 data2 数组前面添加两个空数组
        // 创建 jsonObject2 对象,并添加 data2 属性
@@ -338,20 +341,32 @@
        const jsonString2 = JSON.stringify(jsonObject2);
        console.log("所有Type为0的value:", jsonString2);
        socket?.send(jsonString2);
        // 延迟2秒发送指定内容
setTimeout(() => {
  const jsonObject = { data: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [], []] };
  const jsonString = JSON.stringify(jsonObject);
  console.log("发送的内容:", jsonString);
  socket?.send(jsonString);
}, 1000);
      }
      if (
        currentButtonName === "A01Abort/ResumeTasks" ||
        currentButtonName === "A01终止/继续" ||
        currentButtonName === "A02Abort/ResumeTasks" ||
        currentButtonName === "A02终止/继续"
        currentButtonName === "A02终止/继续" ||
        currentButtonName === "软急停" ||
        currentButtonName === "emgHMI"
      ) {
        const data3 = [];
        const resetButtonValues3 = [this.jsonData[13][0].button.value,this.jsonData[14][0].button.value];
        const resetButtonValues3 = [this.jsonData[13][0].button.value2,this.jsonData[14][0].button.value2,this.jsonData[16][0].button.value2];
        // 将得到的值添加到 data 数组中
        data3.push(resetButtonValues3.flat());
        data3.unshift([]);
        data3.push([]);
        // 在 data3 数组前面添加两个空数组
        // 创建 jsonObject3 对象,并添加 data3 属性
@@ -361,6 +376,16 @@
        const jsonString3 = JSON.stringify(jsonObject3);
        console.log("急停后中止/继续选择:", jsonString3);
        socket?.send(jsonString3);
        setTimeout(() => {
  const jsonObject = { data: [ [],[0, 0, 0], []] };
  const jsonString = JSON.stringify(jsonObject);
  console.log("发送的回弹内容:", jsonString);
  socket?.send(jsonString);
}, 1000);
        // setTimeout(()=>
        //   window.location.reload(),2000
        // )
@@ -395,22 +420,25 @@
        socket.onopen = function () {
          console.log("websocket已打开");
        };
        let isMouseInInputBox = false; // 标记鼠标是否在输入框内
const inputBox = document.querySelectorAll('.input-box2');
inputBox.forEach(box => {
  box.addEventListener('mouseenter', () => {
    isMouseInInputBox = true;
  });
  box.addEventListener('mouseleave', () => {
    isMouseInInputBox = false;
  });
});
//         let isMouseInInputBox = false; // 标记鼠标是否在输入框内
        let isUpdated = false;  // 定义标志变量
// const inputBox = document.querySelectorAll('.input-box2');
// 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);
@@ -424,10 +452,11 @@
          // const inputBox = document.querySelectorAll('.id');
          // const target = event.target;
          if (parms && !isMouseInInputBox) {
          if (parms ) {
            //急停按钮
            jsonData2[13][0].button.value = obj.jiting[0][0];
            jsonData2[14][0].button.value = obj.jiting[0][1];
            jsonData2[16][0].button.value = obj.jiting[0][2];
            
           
@@ -504,6 +533,8 @@
                }
              }
            }
            this.$forceUpdate();
            //扫描枪扫码的ID
            jsonData2.forEach((item) => {
@@ -542,7 +573,18 @@
             
             jsonData2[15][0].value =  obj.timeout[0];
             if (!isUpdated) {
      for (let i = 0; i < jsonData2.length; i++) {
        for (let j = 0; j < jsonData2[i].length; j++) {
          if(jsonData2[i][j].button){
          jsonData2[i][j].button.value2 = jsonData2[i][j].button.value;
        }
        }
      }
      isUpdated = true;  // 更新标志变量的值
    }
                 
          }
@@ -629,4 +671,26 @@
.id {
  background-color: green;
}
.A02jiting{
  background-color: #66b1ff;
}
.A01jiting{
background-color: #66b1ff;
}
.emgHMI{
  background-color: #66b1ff;
}
.GA02jiting{
  background-color: green;
}
.GA01jiting{
  background-color: green;
}
.GemgHMI{
  background-color: green;
}
</style>