wu
2023-09-20 8304fc43850daba13cfbec989e554d720ab62ca4
CanadaMes-ui/src/views/Electrical/Parameter.vue
@@ -13,7 +13,7 @@
    <el-form label-width="100px" style="display: flex; flex-wrap: wrap;" :model="messagepack.data">
      <div id="btn_div">
        <el-button type="primary" @click="send()" id="xiafa" :disabled="isButtonDisabled">下发参数</el-button>
        <el-button type="primary" @click="send()" id="xiafa" :disabled="isButtonDisabled">{{ $t('Distribute parameters') }}</el-button>
      </div>
      <div class="kuai_div" v-for="(item, index) in record.xyData" :key="index">
@@ -39,6 +39,7 @@
let socket;
import LanguageMixin from '../../lang/LanguageMixin'
import { SelectPassword } from "../../api/home";
export default {
  name: "Parameter",
  mixins: [LanguageMixin],
@@ -78,7 +79,9 @@
  created () {
    this.initWebSocket();
    this.isButtonDisabled = true; 
  },
  methods: {
   
@@ -158,9 +161,32 @@
      }
    },
    send () {
      SelectPassword().then(res => {
 this.password = res.data.password;
});
    this.$prompt(this.$t('Are you sure to perform this operation?'), this.$t('prompt'), {
    inputType: 'password',
    inputPlaceholder: this.$t('Please enter the password'),
    confirmButtonText: this.$t('Yes'),
    cancelButtonText: this.$t('No'),
    type: 'warning'
  }).then(({ value }) => {
    if (this.password === value) {
      // 密码正确,执行相应操作
      this.messagepack.data = this.record.xyData.map((item) => parseInt(item.value2)); // 转换为整数数组
      //console.log(this.messagepack);
      socket?.send(JSON.stringify(this.messagepack));
    } else {
      this.$message.success(this.$t('Password error')); // 密码错误
    }
  }).catch(() => {
    this.$message({
      type: 'info',
      message: this.$t('Operation canceled')
    });
  });
    },
    handleChange (index, value) {
      this.record.xyData[index].value = value;