ZengTao
2023-12-27 50122609dfab86da64df82396a30a30455e5bd67
CanadaMes-ui/src/layout/index.vue
@@ -66,23 +66,24 @@
              <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="修改密码" :visible.sync="dialogVisible" width="30%">
              <el-form ref="form" :model="formData" label-width="100px">
                <el-form-item label="旧密码">
            <el-dialog :title="$t('changePassword')" :visible.sync="dialogVisible" width="30%">
              <el-form ref="form" :model="formData" label-width="200px">
                <el-form-item :label="$t('Old password')">
                  <el-input v-model="formData.oldPassword" type="password" show-password></el-input>
                </el-form-item>
                <el-form-item label="新密码">
                <el-form-item :label="$t('New password')">
                  <el-input v-model="formData.newPassword" type="password" show-password></el-input>
                </el-form-item>
                <el-form-item label="确认新密码">
                <el-form-item :label="$t('Confirm password')">
                  <el-input v-model="formData.confirmPassword" type="password" show-password></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="savePassword">保存</el-button>
                <el-button @click="dialogVisible = false">{{ $t('cancel') }}</el-button>
                <el-button type="primary" @click="savePassword">{{ $t('confirm') }}</el-button>
              </div>
            </el-dialog>
          </template>
@@ -101,6 +102,13 @@
        <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>
  </el-container>
</template>
@@ -109,6 +117,7 @@
import { changePassword } from '../api/user'
import { removeToken } from "../utils/auth";
import LanguageMixin from '../lang/LanguageMixin'
import { MessageBox } from 'element-ui';
// import { mapState, mapMutations } from 'vuex';
// import Tag from '../layout/tag.vue';
// import store from '../store';
@@ -122,6 +131,8 @@
    return {
      activeTag: '', // 当前激活的标签
      dialogVisible: false,
      receivedData:0,
      receivedData2:0,
      formData: {
        oldPassword: '',
        newPassword: '',
@@ -136,6 +147,7 @@
        pageNum: -1
      },
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      alarm: [],
      alarm2: []
    }
@@ -144,6 +156,9 @@
  //   Tag
  // },
  created() {
    selectList(this.menuListForm).then(res => {
      this.menuList = res.data
@@ -160,6 +175,48 @@
    // ...mapState('tags', ['tags'])
  },
  methods: {
    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)
        const data3 = [];
        const resetButtonValues3 = [this.receivedData,this.receivedData2];
        // 将得到的值添加到 data 数组中
        data3.push(resetButtonValues3.flat());
        // 在 data3 数组前面添加两个空数组
        // 创建 jsonObject3 对象,并添加 data3 属性
        const jsonObject3 = { data: data3 };
        // 提交数据到后端
        const jsonString3 = JSON.stringify(jsonObject3);
        console.log("急停后中止/继续选择:", jsonString3);
        socket?.send(jsonString3);
        setTimeout(() => {
      this.dialogFormVisible3 = false;
    }, 1000); // 延迟时间为1秒(1000毫秒)
      }).catch(() => {
    // 点击取消按钮后执行的操作
  });
    },
    init() {
      let viewname = "Home";
      if (typeof (WebSocket) == "undefined") {
@@ -181,7 +238,9 @@
        socket.onmessage = function (msg) {
          //console.log("收到数据====" + msg.data);
          let obj = JSON.parse(msg.data);
          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) {
@@ -192,9 +251,27 @@
              this.alarm = obj.alarmmg[0];
              this.dialogFormVisible2 = true;
            }
          }else{
              this.alarm = obj.alarmmg[0];
              this.dialogFormVisible2 = false;
          }
        }
          
          this.$forceUpdate();
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();
        }.bind(this);
        //关闭事件
@@ -227,7 +304,6 @@
      //   this.$store.commit('tags/addTag', tag);
      // }
    },
    removeTag() {
      // this.$store.commit('tags/removeTag', index); // 从 Vuex Store 中移除标签
@@ -360,7 +436,10 @@
    margin-left: 10px;
  }
}
.blue-button {
  background-color: green;
  color: white;
}
.el-header {
  background-color: #576574;