From 17b583422095aff6bb91bd8ddff5faeb41c8edb2 Mon Sep 17 00:00:00 2001 From: wuyouming666 <2265557248@qq.com> Date: 星期六, 02 十二月 2023 09:06:24 +0800 Subject: [PATCH] 更新电气管理通讯逻辑 --- CanadaMes-ui/src/views/Electrical/Positioning2.vue | 45 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 39 insertions(+), 6 deletions(-) diff --git a/CanadaMes-ui/src/views/Electrical/Positioning2.vue b/CanadaMes-ui/src/views/Electrical/Positioning2.vue index 56a5093..d922fbf 100644 --- a/CanadaMes-ui/src/views/Electrical/Positioning2.vue +++ b/CanadaMes-ui/src/views/Electrical/Positioning2.vue @@ -80,11 +80,16 @@ jsonData: data // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData } }, - created () { - this.initWebSocket(); - // console.log('jsonData:', this.jsonData); - - }, + activated(){ + + this.initWebSocket (); + const language = this.$i18n.locale; + console.log(language); + if (language === 'en-US') { + this.replaceChineseWithEnglish(); + } + this.$forceUpdate(); + }, methods: { updateButtonValue (dataGroup, itemIndex) { this.$set(dataGroup[itemIndex].button, 'value', 1); // 鐐瑰嚮鎸夐挳鍚庡皢鍊兼敼涓�1 @@ -156,7 +161,7 @@ // this.submitDataToBackend() const parms = obj.params; - console.log(parms) + // console.log(parms) let index = 0; for (let i = 0; i < jsonData2.length; i++) { let arr = jsonData2[i]; @@ -186,9 +191,37 @@ socket.onerror = function () { console.log("websocket鍙戠敓浜嗛敊璇�"); }; + this.$router.afterEach(function(){ + socket.close(); + }) } }, + replaceChineseWithEnglish() { + + + const nameMap= this.$t('langPositioning2') + this.jsonData = this.jsonData.map((item) => { + return item.map((obj) => { + if (obj.name) { + const newName = nameMap[obj.name] || obj.name; + return { ...obj, name: newName }; + } else if (obj.button && obj.button.name) { + const newName = nameMap[obj.button.name] || obj.button.name; + return { ...obj, button: { ...obj.button, name: newName } }; + } else if (obj.title && obj.title.name) { + const newName = nameMap[obj.title.name] || obj.title.name; + return { ...obj, title: { ...obj.title, name: newName } }; + } else { + return obj; + } + }); +}); + + +// console.log(this.jsonData) + +}, send () { -- Gitblit v1.8.0