From a3f357e8a60443b74b64c7479113c68eb35ce1f5 Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期五, 15 七月 2022 19:44:57 +0800
Subject: [PATCH] 控制轮询

---
 src/pages/settings/components/AuthorizationSetting.vue |   62 +++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/src/pages/settings/components/AuthorizationSetting.vue b/src/pages/settings/components/AuthorizationSetting.vue
index 5c92711..c421140 100644
--- a/src/pages/settings/components/AuthorizationSetting.vue
+++ b/src/pages/settings/components/AuthorizationSetting.vue
@@ -9,12 +9,13 @@
         ref="joinForm"
         class="join-form"
       >
+        <!-- 鎺堟潈绠$悊鏂瑰紡 -->
         <el-form-item>
           <div class="row">
             <div class="item-title">璁惧鎺堟潈绠$悊鏂瑰紡</div>
             <div class="inputContain">
               <el-select
-                v-model="settingForm.authorizationType"
+                v-model="settingForm.need_auth_pwd"
                 placeholder="璇烽�夋嫨"
                 size="small"
                 :popper-append-to-body="false"
@@ -30,33 +31,40 @@
           </div>
         </el-form-item>
 
-        <el-form-item prop="password" v-if="settingForm.authorizationType == 1">
+        <!-- 鎺堟潈瀵嗙爜 -->
+        <el-form-item prop="auth_pwd" v-if="settingForm.need_auth_pwd == 1">
           <div class="row">
             <div class="item-title">鎺堟潈瀵嗛挜</div>
             <div class="inputContain">
               <el-input
-                v-model="settingForm.password"
+                v-model="settingForm.auth_pwd"
                 placeholder="璇疯緭鍏�6浣嶆巿鏉冨瘑閽�"
                 maxlength="6"
-                show-password
+                show-auth_pwd
               ></el-input>
             </div>
           </div>
         </el-form-item>
       </el-form>
 
-      <div class="save">淇濆瓨</div>
+      <div class="save" @click="submit">淇濆瓨</div>
     </div>
   </div>
 </template>
 
 <script>
+import { getAuthInfo, setAuthInfo } from "@/api/system";
+
 export default {
+  created() {
+    this.getAuth();
+  },
   data() {
     return {
       settingForm: {
-        authorizationType: 0,
-        password: "",
+        need_auth_pwd: 0, //鎺堟潈绠$悊鏂瑰紡
+        auth_pwd: "", //鎺堟潈瀵嗛挜
+        id: "", //璁惧id
       },
       typeOptions: [
         {
@@ -67,13 +75,43 @@
           label: "瀵嗙爜鏍¢獙",
           value: 1,
         },
-      ],
+      ], //鎺堟潈绠$悊鏂瑰紡閫夐」
       rules: {
-        password: [
+        auth_pwd: [
           { min: 6, max: 6, message: "闀垮害涓�6涓瓧绗�", trigger: "blur" },
         ],
-      },
+      }, //姝e垯鏍¢獙
     };
+  },
+  methods: {
+    //鑾峰彇鎺堟潈淇℃伅
+    async getAuth() {
+      const res = await getAuthInfo();
+      if (res.code === 200 && res.success) {
+        //鎺堟潈鏁版嵁鍥炲~
+        this.settingForm = res.data;
+      } else {
+        this.$notify.error({
+          title: "閿欒",
+          message: "鑾峰彇鎺堟潈淇℃伅澶辫触",
+        });
+      }
+    },
+    //鎻愪氦鎺堟潈閰嶇疆
+    async submit() {
+      const res = await setAuthInfo(this.settingForm);
+      if (res.code === 200 && res.success) {
+        this.$notify.success({
+          title: "鎴愬姛",
+          message: "淇敼鎴愬姛",
+        });
+      } else {
+        this.$notify.error({
+          title: "閿欒",
+          message: "淇敼澶辫触",
+        });
+      }
+    },
   },
 };
 </script>
@@ -83,7 +121,7 @@
   position: relative;
 
   .content {
-    width: 456px;
+    //  width: 456px;
     margin: 0 auto;
   }
 
@@ -187,7 +225,7 @@
     margin-left: -94px;
     width: 188px;
     height: 40px;
-    background: #4e94ff;
+    background: var(--colorCard);
     border-radius: 25px;
     font-weight: bold;
     font-size: 16px;

--
Gitblit v1.8.0