From 10d08bead7b128db3cf0ed8e0977e65a1b188b6e Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期五, 10 五月 2024 09:37:27 +0800
Subject: [PATCH] 增加页面进入密码弹框

---
 CanadaMes-ui/src/views/Electrical/Positioning1.vue |  134 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 104 insertions(+), 30 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/Positioning1.vue b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
index 07727a9..d8276e4 100644
--- a/CanadaMes-ui/src/views/Electrical/Positioning1.vue
+++ b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
@@ -184,8 +184,35 @@
       </el-col>
     </el-row>
     <!-- <el-button @click="submitDataToBackend">鎻愪氦鏁版嵁鍒板悗绔�</el-button> -->
+
+
+
+    <div>
+   
+    <el-dialog
+      :visible="isPromptVisible"
+      title="Prompt"
+      width="30%"
+      :close-on-click-modal="false" 
+      @close="handleCloseDialog"
+    >
+      <el-input v-model="password2" type="password" :placeholder="$t('Please enter the password')"></el-input>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="handleCancel">{{ $t('Home') }}</el-button>
+        <el-button type="primary" @click="handleConfirm">{{ $t('Confirm') }}</el-button>
+      </span>
+    </el-dialog>
   </div>
+  </div>
+
+
+  
+
+
 </template>
+
+
+
   
 <script>
 let socket;
@@ -203,8 +230,12 @@
       A02: "",
       B01: "",
       B02: "",
-      password: 1,
+      password:"" ,
+      password2:"" ,
       jianju: "",
+      
+      isPromptVisible: false,
+     
     };
   },
   activated() {
@@ -217,9 +248,78 @@
     }
     this.$forceUpdate();
     this.load();
+   
+// 璋冪敤鍑芥暟锛屾樉绀哄瘑鐮佽緭鍏ュ璇濇
+this.showPasswordPrompt();
     
   },
   methods: {
+
+    showPasswordPrompt() {
+      this.isPromptVisible = true;
+    },
+    handleCancel() {
+      this.$router.push('/home');
+      this.isPromptVisible = false;
+    },
+    handleConfirm() {
+      // 楠岃瘉瀵嗙爜骞舵墽琛岀浉搴旀搷浣�
+      if (this.password === this.password2) {
+        // 瀵嗙爜姝g‘锛屾墽琛屾搷浣�
+        console.log('Password correct, perform operation');
+        this.$message.success(this.$t('success password'));
+        this.isPromptVisible = false;
+        this.password2="";
+     
+        // 鍦ㄨ繖閲屾墽琛屼綘鐨勬搷浣�
+      } else {
+        this.$message.error(this.$t('Incorrect password'));
+        this.showPasswordPrompt();
+      }
+     
+    },
+    handleCloseDialog() {
+      // 鍦ㄨ繖閲屽鐞嗗脊妗嗗叧闂簨浠讹紝濡傛灉闇�瑕佺殑璇�
+      console.log('Dialog closed');
+    },
+
+
+  //   showPasswordPrompt() {
+  //   // 鏄剧ず閬僵灞�
+  //   this.isPromptVisible = true;
+
+  //   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'),
+  //       showClose: false, // 涓嶆樉绀哄彸涓婅鐨勫叧闂寜閽�
+  //       showCancelButton: false, // 涓嶆樉绀哄彇娑堟寜閽�
+  //       type: 'warning',
+  //     }
+  //   ).then(({ value }) => {
+  //     // 楠岃瘉瀵嗙爜鏄惁姝g‘
+  //     if (value !== this.password) {
+  //       this.$message.error(this.$t('Incorrect password'));
+  //       // 涓嶅叧闂璇濇锛岄噸鏂拌Е鍙戝瘑鐮佽緭鍏ュ璇濇
+  //       this.showPasswordPrompt();
+  //     } else {
+  //       // 瀵嗙爜姝g‘锛屾墽琛屾搷浣�
+  //       // 杩欓噷鍙互娣诲姞浣犳兂瑕佹墽琛岀殑鎿嶄綔
+  //       // 濡傛灉娌℃湁鎿嶄綔锛屽彲浠ョ渷鐣ヨ繖涓� else 浠g爜鍧�
+  //     }
+  //   }).catch(() => {
+  //     // 濡傛灉鐢ㄦ埛鍙栨秷鎿嶄綔锛屼篃涓嶅仛浠讳綍澶勭悊
+  //     console.log('鍙栨秷1');
+  //   }).finally(() => {
+  //     // 鍏抽棴閬僵灞�
+  //     this.isPromptVisible = false;
+  //   });
+  // },
+
+
     load(){
 
 SelectPassword().then(res => {
@@ -310,36 +410,10 @@
       // 鎻愪氦鏁版嵁鍒板悗绔�
       const jsonString = JSON.stringify(jsonObject);
 
-      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 }) => {
-    // 楠岃瘉瀵嗙爜鏄惁姝g‘
-    if (value !== this.password) {
-      this.$message.error(this.$t('Incorrect password'));
-      return ;
-    }else{
-      console.log("鎻愪氦浠ヤ笅鏁版嵁鍒板悗绔�:", jsonString);
+      
+
+  console.log("鎻愪氦浠ヤ笅鏁版嵁鍒板悗绔�:", jsonString);
       socket?.send(jsonString);
-      
-    }
-
-   
-   
-
-  }).catch(() => {
-    // 鍙栨秷鎿嶄綔
-    console.log('鍙栨秷1');
-  });
-
-      
       
       event.target.blur(); // 鍙栨秷杈撳叆妗嗙劍鐐�
     },

--
Gitblit v1.8.0