ZengTao
2023-09-07 36acd690614dd276428530a59f448c543bac52d4
CanadaMes-ui/src/views/Electrical/alarm.vue
@@ -3,7 +3,7 @@
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
      <router-link to="/home" tag="el-button" type="text">{{ $t('langHome') }}</router-link>
      <el-button type="text">设备管理</el-button>
      <el-button type="text">Electrical</el-button>
      <router-link to="/Electrical/Parameter" tag="el-button" type="text">Parameter</router-link>
      <router-link to="/Electrical/Action" tag="el-button" type="text">Action</router-link>
      <router-link to="/Electrical/Sign" tag="el-button" type="text">Sign</router-link>
@@ -18,7 +18,7 @@
        </div>
      </el-form> -->
    <el-table :data="tableData" style="width: 100%;" height="590">
    <el-table :data="localizedRoles" style="width: 100%;" height="590">
      <el-table-column prop="id" label="id" width="80">
      </el-table-column>
      <el-table-column prop="content" label="content">
@@ -33,9 +33,11 @@
<script >
import { setAll } from "../../api/alarm";
import LanguageMixin from '../../lang/LanguageMixin'
let socket;
export default {
  name: "alarm",
  mixins: [LanguageMixin],
  data () {
    return {
      record: {
@@ -44,8 +46,8 @@
        // xyData: [],
      },
      tableData: [],
      roles: [],
      localizedRoles: [],
      messagepack: {
        data: { taskname: "" }
      },
@@ -59,15 +61,28 @@
  created () {
    this.init();
    this.load();
  },
  methods: {
    load () {
      setAll().then(res => {
        this.tableData = res.data.list;
        //console.log(this.tableData);
        this.roles = res.data.list;
        const language = this.$i18n.locale;
        if (language === 'zh-CN') {
          this.replaceChineseWithEnglish();
        } else {
          this.localizedRoles = [...this.roles];
        }
        console.log(this.localizedRoles);
      });
    },
    replaceChineseWithEnglish () {
      const translation = this.$t('translation');
      this.localizedRoles = this.roles.map(role => ({
        ...role,
        content: translation[role.content] || role.content
      }));
    },
    init () {
      let viewname = "alarm";