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/AutomaticParameterSetting.vue |   80 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 26 deletions(-)

diff --git a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
index 9c16aa7..4be46c2 100644
--- a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
+++ b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -136,6 +136,23 @@
       </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>
 
@@ -152,7 +169,11 @@
   data () {
     return {
       jsonData: data ,
-      password: 1// 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
+      password: 1,// 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
+      password2:"" ,
+      jianju: "",
+      
+      isPromptVisible: false,
     }
   },
   activated () {
@@ -166,10 +187,37 @@
     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');
+    },
     load(){
 
 SelectPassword().then(res => {
@@ -186,6 +234,7 @@
       
 
 },
+
     closeSocket () {
       // 鍏抽棴 WebSocket 杩炴帴
       socket.close();
@@ -224,35 +273,14 @@
 
       // 鎻愪氦鏁版嵁鍒板悗绔�
       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);
       socket?.send(jsonString);
-    }
-
-   
    
 
-  }).catch(() => {
-    // 鍙栨秷鎿嶄綔
-    console.log('鍙栨秷1');
-  });
-
+   
+  
  // console.log("鎻愪氦浠ヤ笅鏁版嵁鍒板悗绔�:", jsonString);
       // socket?.send(jsonString);
       event.target.blur(); // 鍙栨秷杈撳叆妗嗙劍鐐�

--
Gitblit v1.8.0