From 46f29e79b43be98199d0727a71d85dddaa6e1fd4 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期五, 15 十二月 2023 10:00:23 +0800
Subject: [PATCH] 增加A01 A02行走伺服回零  输入密码才能点击

---
 CanadaMes-ui/src/views/Electrical/ManualJog.vue |   93 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/ManualJog.vue b/CanadaMes-ui/src/views/Electrical/ManualJog.vue
index 3cb9fc1..dab071b 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualJog.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualJog.vue
@@ -57,7 +57,7 @@
             <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" style="margin: 10px;">
               <el-button v-if="item.button"   v-model="item.button.value"   :name="item.button.name" style='width:200px;'
  :class="{ 'dow': item.button.value === 0, 'op': item.button.value === 1 }" class="action-button"
- @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend();">{{
+ @click="updateButtonValue(dataGroup, itemIndex);  submitDataToBackend(item.button.name);">{{
  item.button.name
  }}</el-button>
             </div>
@@ -72,16 +72,19 @@
 <script>
 import LanguageMixin from '../../lang/LanguageMixin'
 import data from '../../configuration/ManualJog'
+import {SelectPassword} from "../../api/home";
 let socket;
 export default {
   name: "ManualJog",
   mixins: [LanguageMixin],
   data () {
     return {
-      jsonData: data // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
+      jsonData: data, // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
+      password: 1,
     }
   },
   activated () {
+
 
     this.initWebSocket();
     const language = this.$i18n.locale;
@@ -91,7 +94,10 @@
     }
     // this.$forceUpdate();
 
-
+             SelectPassword().then(res => {
+                this.password = res.data.password;
+                console.log(this.password)
+            });
   },
   methods: {
     closeSocket () {
@@ -107,25 +113,69 @@
     this.$set(dataGroup[itemIndex].button, 'value2', 0);
   }
     },
-    submitDataToBackend () {
-      const inputData = this.jsonData.map(dataGroup => {
-        return dataGroup.map(item => {
-          if (item.type === '3') {
-            return { value: item.button.value2 };
+    submitDataToBackend (currentButtonName) {
+
+      if (currentButtonName === 'A01 SERVE TRAVEL Home' || currentButtonName === 'A02 SERVE TRAVEL Home' || currentButtonName === 'A01琛岃蛋浼烘湇鍥為浂' || currentButtonName === 'A02琛岃蛋浼烘湇鍥為浂') {
+        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',
           }
-          return null;
+        ).then(({ value }) => {
+          // 楠岃瘉瀵嗙爜鏄惁姝g‘
+          if (value !== this.password) {
+            this.$message.error(this.$t('Incorrect password'));
+            return;
+          }
+
+          // 瀵嗙爜姝g‘锛岀户缁彁浜ゆ暟鎹埌鍚庣
+          const inputData = this.jsonData.map(dataGroup => {
+            return dataGroup.map(item => {
+              if (item.type === '3') {
+                return { value: item.button.value2 };
+              }
+              return null;
+            });
+          });
+
+          const values = inputData.flat().filter(item => item !== null).map(item => item.value);
+
+          const jsonObject = { data: values };
+
+          // 鎻愪氦鏁版嵁鍒板悗绔�
+          const jsonString = JSON.stringify(jsonObject);
+          console.log('Type涓�3鐨剉alue:', jsonString);
+          socket?.send(jsonString);
+
+        }).catch(() => {
+          // 鍙栨秷鎿嶄綔
+          console.log('鍙栨秷');
         });
-      });
+      } else {
+        // 濡傛灉涓嶆槸 A01 SERVE TRAVEL Home 鎸夐挳锛岀户缁彁浜ゆ暟鎹埌鍚庣
+        const inputData = this.jsonData.map(dataGroup => {
+          return dataGroup.map(item => {
+            if (item.type === '3') {
+              return { value: item.button.value2 };
+            }
+            return null;
+          });
+        });
 
-      const values = inputData.flat().filter(item => item !== null).map(item => item.value);
+        const values = inputData.flat().filter(item => item !== null).map(item => item.value);
 
-      const jsonObject = { data: values };
+        const jsonObject = { data: values };
 
-      // 鎻愪氦鏁版嵁鍒板悗绔�
-      const jsonString = JSON.stringify(jsonObject);
-      console.log('Type涓�3鐨剉alue:', jsonString);
-      socket?.send(jsonString);
-
+        // 鎻愪氦鏁版嵁鍒板悗绔�
+        const jsonString = JSON.stringify(jsonObject);
+        console.log('Type涓�3鐨剉alue:', jsonString);
+        socket?.send(jsonString);
+      }
     },
     //鏍规嵁璇诲彇PLC鐨勫�硷紝鏍规嵁鍚嶇О鏀瑰彉棰滆壊1鎵撳紑锛�0鍏抽棴
 //     getStatusClass (zhuangtai) {
@@ -169,7 +219,8 @@
 
           const jsonData2 = this.jsonData;
           const parms = obj.params;
- console.log(obj)
+//  console.log(obj)
+//console.log(this.jsonData)
           if(parms){
           // 濡傛灉榧犳爣涓嶅湪杈撳叆妗嗗唴锛屾洿鏂拌緭鍏ユ鐨勫��
           // this.submitDataToBackend()
@@ -181,10 +232,16 @@
             for (let j = 0; j < arr.length; j++) {
               let obj = arr[j];
               obj.button.value = parms[0][j];
+              obj.button.value2 =obj.button.value;
+
 
             }
 
           }
+
+
+
+
         }
 
 

--
Gitblit v1.8.0