wu
2023-12-08 31101f632c27c05d15f30ca3084e3ed3da2a29af
CanadaMes-ui/src/views/Electrical/Sign.vue
@@ -2,18 +2,26 @@
  <div class="app">
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
      <router-link to="/Electrical/alarm" tag="el-button" type="text" 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>
      <router-link to="/Electrical/alarm" tag="el-button" type="text" 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>
 <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
        }}</router-link>
    </el-breadcrumb>
    <div>Sign</div>
    <div>{{ $t('Sign') }}</div>
    <div style="padding-right: 30px;display: flex;flex-wrap: wrap;" class="neir">
      <div class="kuai_sb" v-for="item in record.xyData" :key="item.name">
        <el-col class="deng" :class="getStatusClass(item.value)">
        </el-col>
        <el-input v-model="item.name" style="width: 280px;" class="in_mc"></el-input>
        <el-col class="deng" :class="getStatusClass(item.value)"></el-col>
        <el-input v-model="item.name" style="width: 100%;" class="in_mc"></el-input>
      </div>
@@ -24,112 +32,19 @@
<script >
import LanguageMixin from '../../lang/LanguageMixin'
import data from '../../configuration/Sign'
let socket;
export default {
  name: "Sign",
  mixins: [LanguageMixin],
  data () {
    return {
      jsonData: data,
      activeButton: '',
      record: {
        //定义数组,并添加默认值
        params: [1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
          1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,],
        xyData: [
          { name: 'D01.SR dec', value: 1 },
          { name: "D01.SR in pos", value: 1 },
          { name: "D02.SR dec", value: 1 },
          { name: "D02.SR in pos", value: 1 },
          { name: "D03.SR into", value: 1 },
          { name: "D03.SR dec", value: 1 },
          { name: 'D03.SR in pos', value: 1 },
          { name: "D04.SR dec", value: 1 },
          { name: "D04.SR in pos", value: 1 },
          { name: "D05.SR dec", value: 1 },
          { name: "D05.SR in pos", value: 1 },
          { name: "D06.SR dec", value: 1 },
          { name: 'D06.SR in pos', value: 1 },
          { name: "B01.SR out dec", value: 1 },
          { name: "B01.SR out in pos", value: 1 },
          { name: "B01.SR in dec", value: 1 },
          { name: "B01.SR in in pos", value: 1 },
          { name: "B01.SR turn on", value: 1 },
          { name: 'B01.SR turn off', value: 1 },
          { name: "B01.SR up", value: 1 },
          { name: "B01.SR down", value: 1 },
          { name: "B02.SR out dec", value: 1 },
          { name: "B02.SR out in pos", value: 1 },
          { name: "B02.SR in dec", value: 1 },
          { name: 'B02.SR in in pos', value: 1 },
          { name: "B02.SR turn on", value: 1 },
          { name: "B02.SR turn off", value: 1 },
          { name: "B02.SR up", value: 1 },
          { name: "B02.SR down", value: 1 },
          { name: "B01.SR out safety", value: 1 },
          { name: "B01.SR in safety", value: 1 },
          { name: "B02.SR out safety", value: 1 },
          { name: "SB.start(+)", value: 1 },
          { name: "SB.stop(1)", value: 1 },
          { name: "SB.reset", value: 1 },
          { name: "SB.auto/manul", value: 1 },
          { name: "SB.pause", value: 1 },
          { name: "SB.emg", value: 1 },
          { name: "D01.SB.start", value: 1 },
          { name: "D06.SB.start", value: 1 },
          { name: "B02.SR in safety", value: 1 },
          { name: "SAFETYDOOR.requset", value: 1 },
          { name: "SAFETYDOOR.confirm", value: 1 },
          { name: "SAFETYDOOR.reset", value: 1 },
          { name: "LED.red", value: 1 },
          { name: "LED.green", value: 1 },
          { name: "LED.yellow", value: 1 },
          { name: "D01.LED.green", value: 1 },
          { name: "D06.LED.green", value: 1 },
          { name: "B01.YV.turn", value: 1 },
          { name: "B01.YV.up down", value: 1 },
          { name: "B01.YV.gassing", value: 1 },
          { name: "B02.YV.turn", value: 1 },
          { name: "B02.YV.up down", value: 1 },
          { name: "B02.YV.gassing", value: 1 },
          { name: "SAFETYDOOR.led", value: 1 },
          { name: "SAFETYDOOR.open", value: 1 },
        ],
        canshu: [
          'D01.SR dec',
          'D01.SR in pos',
          'D02.SR dec',
          'D02.SR in pos',
          'D03.SR into',
          'D03.SR dec',
          'D03.SR in pos',
          'D04.SR dec',
          'D04.SR in pos',
          'D05.SR dec',
          'D05.SR in pos',
          'D06.SR dec',
          'D06.SR in pos',
          'B01.SR out dec',
          'B01.SR out in pos',
          'B01.SR in dec',
          'B01.SR in in pos',
          'B01.SR turn on',
          'B01.SR turn off',
          'B01.SR up',
          'B01.SR down',
          'B02.SR out dec',
          'B02.SR out in pos',
          'B02.SR in dec',
          'B02.SR in in pos',
          'B02.SR turn on',
          'B02.SR turn off',
          'B02.SR up',
          'B02.SR down',
          'LED.red',
          'LED.green',
          'LED.yellow',
        ],
        //定义数组
        params: [],
        xyData: [],
      },
@@ -144,10 +59,22 @@
    }
  },
  created () {
    this.init();
    //this.showdata();
  },
  activated(){
    this.init();
 },
  methods: {
    onButtonClick() {
    showdata () {
      console.log(1111);
      console.log(this.jsonData.sign[0].name);
      // console.log(this.record.xyData);
    },
    onButtonClick () {
      this.isButtonClicked = true; // 将按钮颜色设置为蓝色
      setTimeout(() => {
        this.isButtonClicked = false; // 重置按钮颜色
@@ -155,6 +82,7 @@
    },
    //根据读取PLC的值,根据名称改变颜色
    getStatusClass (zhuangtai) {
      // console.log(this.record.xyData);
      if (zhuangtai === 0) {
        return "op";
      }
@@ -171,7 +99,7 @@
      } else {
        //console.log("您的浏览器支持WebSocket");
        let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
        let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname;
        if (socket != null) {
          socket.close();
          socket = null;
@@ -188,18 +116,29 @@
          //console.log("收到数据====" + msg.data);
          let obj = JSON.parse(msg.data);
          this.record.params[0] = obj.sig[0];
          for (let a = 0; a < this.record.params[0].length; a++) {
            if (!this.record.xyData[a]) {
              this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
            } else {
              this.record.xyData[a].value = this.record.params[0][a];
            }
          this.record.xyData = this.jsonData.sign;
          console.log(this.jsonData.sign)
          for (let a = 0; a < this.record.xyData.length; a++) {
            this.record.xyData[a].value = this.record.params[0][a];
          }
          this.record.xyData = this.jsonData.sign.filter(item => {
            return item.state != 0;
          }
          );
          const language = this.$i18n.locale;
          if (language === 'en-US') {
            this.replaceChineseWithEnglish();
          } else {
            this.localizedRoles = [...this.record.xyData];
          }
          this.$forceUpdate();
          this.replaceChineseWithEnglish();
        }.bind(this);
        //关闭事件
@@ -212,6 +151,17 @@
        }
      }
    },
    //语言转换
    replaceChineseWithEnglish () {
      const translation = this.$t('Signlang');
      if (translation != null) {
        this.record.xyData = this.record.xyData.map(item => { return { name: translation[item.name] || item.name, value: item.value }; });
        //console.log(translation);
      }
    }
  }
}
@@ -222,7 +172,7 @@
</script>
<style>
<style >
* {
  margin: 0;
  padding: 0;
@@ -245,7 +195,7 @@
.kuai_sb {
  text-align: center;
  width: 25%;
  width: 15%;
  margin-bottom: 15px;
}
@@ -270,8 +220,8 @@
  background: #A0A0A0;
  border: 0.1875em solid white;
  border-radius: 50%;
  height: 5em;
  width: 5em;
  height: 4em;
  width: 4em;
  box-shadow: 0.375em 0.375em 0 0 rgba(214, 214, 214, 0.125);
}
@@ -294,7 +244,12 @@
.yellow {
  background-color: yellow;
}
.blue-button {
  background-color: skyblue;
}
.dark-theme {
  display: none;
}
</style>