From 3f98ccf49e7ffc098689c37237bd1dceed651ca1 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期一, 27 十一月 2023 09:14:39 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes

---
 CanadaMes-ui/src/views/Electrical/Action.vue |   59 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/Action.vue b/CanadaMes-ui/src/views/Electrical/Action.vue
index db3b8da..1afd13b 100644
--- a/CanadaMes-ui/src/views/Electrical/Action.vue
+++ b/CanadaMes-ui/src/views/Electrical/Action.vue
@@ -2,11 +2,16 @@
   <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>
     </el-breadcrumb>
     <div>Action</div>
     <el-form label-width="100px" style="display: flex;flex-wrap: wrap;" :model="{ messagepack }">
@@ -19,20 +24,24 @@
         <el-input v-model="item.name" style="width: 240px;" class="in_mc" readonly></el-input>
         <el-switch v-model="item.value" active-value="1" inactive-value="0" @change="send()"></el-switch>
       </div>
+
+
     </el-form>
 
 
   </div>
 </template>
  
-<script > 
+<script >
 import LanguageMixin from '../../lang/LanguageMixin'
+import data from '../../configuration/Action'
 let socket;
 export default {
   name: "Action",
   mixins: [LanguageMixin],
   data () {
     return {
+      jsonData: data,
       activeButton: '',
       record: {
         params: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -107,12 +116,13 @@
     }
   },
   created () {
-    this.init(); 
+    this.init();
   },
   methods: {
-    setActiveButton(buttonName) {
-    this.activeButton = buttonName;
-  },
+
+    setActiveButton (buttonName) {
+      this.activeButton = buttonName;
+    },
     init () {
       let viewname = "action";
 
@@ -134,24 +144,28 @@
         };
         //  娴忚鍣ㄧ鏀舵秷鎭紝鑾峰緱浠庢湇鍔$鍙戦�佽繃鏉ョ殑鏂囨湰娑堟伅
         socket.onmessage = (msg) => {
+          //console.log("鏀跺埌鏁版嵁====" + msg.data);
           if (!msg.data) {
             return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
           }
 
           let obj = JSON.parse(msg.data);
-          if (obj.params ){
-          this.record.params[0] = obj.params[0];
 
-          for (let a = 0; a <= this.record.params[0].length - 1; a++) {
-            if (!this.record.xyData[a]) {
-              this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a].toString() };
-            } else {
+          if (obj.params) {
+            this.record.params[0] = obj.params[0];
+            for (let a = 0; a <= this.record.params[0].length - 1; a++) {
+              this.record.xyData[a].name = this.jsonData.action[a].name;
               this.record.xyData[a].value = this.record.params[0][a].toString();
             }
+            const language = this.$i18n.locale;
+            if (language === 'en-US') {
+              this.replaceChineseWithEnglish();
+            } else {
+              this.localizedRoles = [...this.record.xyData];
+            }
           }
-        }
-          // console.log(this.record.xyData);
           this.$forceUpdate();
+          this.replaceChineseWithEnglish();
         };
 
         //鍏抽棴浜嬩欢
@@ -169,7 +183,13 @@
       this.messagepack.data = this.record.xyData.map(item => parseInt(item.value)); // 杞崲涓烘暣鏁版暟缁�
       //console.log(this.messagepack);
       socket?.send(JSON.stringify(this.messagepack));
-    }
+    },
+    //璇█杞崲
+    replaceChineseWithEnglish () {
+      const translation = this.$t('langActions');
+      this.record.xyData = this.record.xyData.map(item => { return { name: translation[item.name] || item.name, value: item.value }; });
+      console.log(translation);
+    },
 
   }
 
@@ -206,6 +226,7 @@
 .el-input__inner {
   border: none;
 }
+
 .blue-button {
   background-color: skyblue;
 }

--
Gitblit v1.8.0