ZengTao
2023-12-28 ec14c7c0b9a5d8240cfc3f2c80a48dfe1176f13e
CanadaMes-ui/src/layout/index.vue
@@ -66,7 +66,7 @@
              <el-menu-item index="1-1" @click="logout">{{ $t('exit') }}</el-menu-item>
              <el-menu-item index="1-2" @click="showChangePasswordDialog">{{ $t('changePassword') }}</el-menu-item>
            </el-submenu>
          </template>
          <template>
            <el-dialog :title="$t('changePassword')" :visible.sync="dialogVisible" width="30%">
@@ -102,11 +102,19 @@
        <el-table-column prop="timeons" :label="$t('timeon')"></el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible3" >
      <el-button :class="{ 'blue-button': receivedData === 1 }" @click="toggleButtonValue(1)">{{ $t('A01Abort/ResumeTasks') }}</el-button>
    <el-button :class="{ 'blue-button': receivedData2 === 1 }" @click="toggleButtonValue(2)">{{ $t('A02Abort/ResumeTasks') }}</el-button>
    <el-dialog :visible.sync="dialogFormCountDown" :title="$t('Approximately resettable time')" top="5vh">
            <div :style="'font-size: ' + PromptSize + 'px;text-align: center;'">
                <!-- {{ this.CountDowns }} -->
                {{ this.CountDowns }}
            </div>
        </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible3">
      <el-button :class="{ 'blue-button': receivedData === 1 }" @click="toggleButtonValue(1)">{{
        $t('A01Abort/ResumeTasks') }}</el-button>
      <el-button :class="{ 'blue-button': receivedData2 === 1 }" @click="toggleButtonValue(2)">{{
        $t('A02Abort/ResumeTasks') }}</el-button>
    </el-dialog>
  </el-container>
@@ -131,8 +139,8 @@
    return {
      activeTag: '', // 当前激活的标签
      dialogVisible: false,
      receivedData:0,
      receivedData2:0,
      receivedData: 0,
      receivedData2: 0,
      formData: {
        oldPassword: '',
        newPassword: '',
@@ -149,7 +157,12 @@
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      alarm: [],
      alarm2: []
      alarm2: [],
      CountDowns: "0",
      EmergencyStop: false,
      PromptSize: 250,
      dialogFormCountDown:false
    }
  },
  // components: {
@@ -157,8 +170,8 @@
  // },
  created() {
    selectList(this.menuListForm).then(res => {
      this.menuList = res.data
@@ -178,25 +191,25 @@
    toggleButtonValue(buttonNumber) {
      MessageBox.confirm(this.$t('Are you sure to perform this operation?'), this.$t('prompt'), {
    confirmButtonText: this.$t('confirm'),
    cancelButtonText: this.$t('cancel'),
    type: 'warning'
  }).then(() => {
    // 点击确认按钮后执行的操作
      if (buttonNumber === 1) {
        this.receivedData = this.receivedData === 0 ? 1 : 0;
      } else if (buttonNumber === 2) {
        this.receivedData2 = this.receivedData2 === 0 ? 1 : 0;
      }
console.log(this.receivedData,this.receivedData2)
        confirmButtonText: this.$t('confirm'),
        cancelButtonText: this.$t('cancel'),
        type: 'warning'
      }).then(() => {
        // 点击确认按钮后执行的操作
        if (buttonNumber === 1) {
          this.receivedData = this.receivedData === 0 ? 1 : 0;
        } else if (buttonNumber === 2) {
          this.receivedData2 = this.receivedData2 === 0 ? 1 : 0;
        }
        console.log(this.receivedData, this.receivedData2)
        const data3 = [];
        const resetButtonValues3 = [this.receivedData,this.receivedData2];
        const resetButtonValues3 = [this.receivedData, this.receivedData2];
        // 将得到的值添加到 data 数组中
        data3.push(resetButtonValues3.flat());
        // 在 data3 数组前面添加两个空数组
        // 创建 jsonObject3 对象,并添加 data3 属性
@@ -207,13 +220,13 @@
        console.log("急停后中止/继续选择:", jsonString3);
        socket?.send(jsonString3);
        setTimeout(() => {
      this.dialogFormVisible3 = false;
    }, 1000); // 延迟时间为1秒(1000毫秒)
          this.dialogFormVisible3 = false;
        }, 1000); // 延迟时间为1秒(1000毫秒)
      }).catch(() => {
    // 点击取消按钮后执行的操作
  });
        // 点击取消按钮后执行的操作
      });
    },
@@ -238,40 +251,57 @@
        socket.onmessage = function (msg) {
          //console.log("收到数据====" + msg.data);
          let obj = JSON.parse(msg.data);
          if(obj.alarmmg){
          if (obj.alarmmg) {
          if (obj.alarmmg[0].length > 0) {
            if (this.alarm.length > 0) {
              if (this.alarm[this.alarm.length - 1].id != obj.alarmmg[0][obj.alarmmg[0].length-1].id) {
            if (obj.alarmmg[0].length > 0) {
              if (this.alarm.length > 0) {
                if (this.alarm[this.alarm.length - 1].id != obj.alarmmg[0][obj.alarmmg[0].length - 1].id) {
                  this.alarm = obj.alarmmg[0];
                  this.dialogFormVisible2 = true;
                }
              } else {
                this.alarm = obj.alarmmg[0];
                this.dialogFormVisible2 = true;
              }
            } else {
              this.alarm = obj.alarmmg[0];
              this.dialogFormVisible2 = true;
            }
          }else{
              this.alarm = obj.alarmmg[0];
              this.dialogFormVisible2 = false;
            }
            //是否急停
            if (obj.emergencystop != null) {
              this.EmergencyStop = obj.emergencystop[0];
            }
            //复位倒计时
            console.log(obj.countdown);
            if (obj.countdown != null) {
              if ((obj.countdown[0] == true && this.CountDowns == 0) || this.EmergencyStop == true) {
                this.CountDown();
              }
            }
            //复位完成信号
            if (obj.reset != null) {
              this.reset = obj.reset[0];
            }
          }
        }
if(obj.Abort){
          if (obj.Abort[0].length > 0) {
            this.receivedData=obj.Abort[0][0];
            this.receivedData2=obj.Abort[0][1];
           this.dialogFormVisible3 = true;
          if (obj.Abort) {
            if (obj.Abort[0].length > 0) {
              this.receivedData = obj.Abort[0][0];
              this.receivedData2 = obj.Abort[0][1];
              this.dialogFormVisible3 = true;
            }
          }
        }
        this.$forceUpdate();
          this.$forceUpdate();
        }.bind(this);
        //关闭事件
@@ -283,6 +313,36 @@
          console.log("websocket发生了错误");
        }
      }
    },
    //45秒复位倒数计时
    CountDown() {
      let count = 45;
      let timer = setInterval(
        () => {
          if (this.EmergencyStop == true) {
            this.dialogFormCountDown = false;
            clearInterval(timer);
            this.CountDowns = "0";
          } else {
            if (count > 0) {
              this.PromptSize = 500;
              this.CountDowns = count;
              count--;
              this.dialogFormCountDown = true;
            }
            else {
              this.PromptSize = 200;
              this.CountDowns = "Waiting for reset";
              if (this.reset == true) {
                clearInterval(timer);
                this.dialogFormCountDown = false;
              }
            }
          }
        },
        1000
      );
    },
    logout: function () {
      removeToken()
@@ -436,10 +496,12 @@
    margin-left: 10px;
  }
}
.blue-button {
  background-color: green;
  color: white;
}
.el-header {
  background-color: #576574;