Browse Source

修改常量及新增找回密码

yangg 10 months ago
parent
commit
5a1f49529b

+ 29 - 0
src/api/user.js

@@ -22,3 +22,32 @@ export function logout() {
     method: 'post'
   })
 }
+
+/* 获取验证码 */
+
+export function tailPhone(data) {
+  return request({
+    url: '/SMS/tailPhone',
+    method: 'post',
+    data
+  })
+}
+
+/* 校验验证码 */
+
+export function codeCheckout(data) {
+  return request({
+    url: 'SMS/codeCheckout',
+    method: 'post',
+    data
+  })
+}
+
+/* 提交找回 */
+export function updatePassword(data) {
+  return request({
+    url: 'SMS/updatePassword',
+    method: 'post',
+    data
+  })
+}

+ 18 - 0
src/router/index.js

@@ -296,6 +296,24 @@ export const asyncRoutes = [
       },
     ]
   },
+  {
+    path: '/knowledgeMenu',
+    component: Layout,
+    type:32,
+    meta: {
+      title: '知识库管理',
+      icon: '',
+      roles: ['admin']
+    },
+    children: [
+      {
+        path: 'knowledgeMenuList',
+        component: () => import('@/views/knowledgeMenu/knowledgeList'),
+        name: 'knowledgeMenuList',
+        meta: { title: '知识库管理',  noCache: true,roles: ['admin'] }
+      }
+    ]
+  },
   {
     path: '/system',
     component: Layout,

+ 12 - 4
src/views/dataCenter/components/dataInfo.vue

@@ -252,8 +252,8 @@ export default {
       let _this = this;
       _this.fileLoadStatus = false;
       if (
-        e.type ==
-        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+        e.type ===
+          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
       ) {
         _this.fileLoadStatus = true;
         _this.fileList = [e];
@@ -261,6 +261,11 @@ export default {
         LuckyExcel.transformExcelToLucky(
           e,
           (exportJson, luckysheetfile) => {
+            if (!exportJson || !exportJson.sheets) {
+              console.error("Invalid exportJson:", exportJson);
+              this.$message.error("无法解析Excel文件,请检查文件格式是否正确");
+              return;
+            }
             this.dataForm.sourceData = {
               exportJson: exportJson,
               luckysheetfile: luckysheetfile,
@@ -268,11 +273,14 @@ export default {
             this.initExcel();
           },
           (error) => {
-            this.$message.error(error);
+            console.error("LuckyExcel转换错误:", error);
+            this.$message.error(
+              `Excel文件处理失败: ${error.message || "未知错误"}`
+            );
           }
         );
       } else {
-        this.$message("请选择excel文件");
+        this.$message.error("请选择正确的Excel文件格式(.xlsx)");
       }
     },
   },

+ 1 - 0
src/views/document/com/components/Variable/dataInfo.vue

@@ -82,6 +82,7 @@ export default {
     },
     id: {
       handler(v) {
+        console.log(v);
         let _this = this;
         if (v == null || v <= 0) return;
         _this.getInfo(v);

+ 26 - 26
src/views/document/com/components/Variable/index.vue

@@ -7,15 +7,20 @@
       class="demo-form-inline"
     >
       <el-form-item label="类型:">
-            <el-select v-model="queryForm.type"  placeholder="请选择类型" size="large" style="width:100%;">
-                <el-option
-                  v-for="item in typeList"
-                  :key="item.value"
-                  :label="item.name"
-                  :value="item.value"
-                />
-              </el-select>
-          </el-form-item>
+        <el-select
+          v-model="queryForm.type"
+          placeholder="请选择类型"
+          size="large"
+          style="width: 100%"
+        >
+          <el-option
+            v-for="item in typeList"
+            :key="item.value"
+            :label="item.name"
+            :value="item.value"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item label="变名称:">
         <el-input
           v-model="queryForm.name"
@@ -68,7 +73,7 @@
       header-row-class-name="headerBg"
       empty-text="没有数据信息"
     >
-      <el-table-column prop="id" label="ID" align="center"  />
+      <el-table-column prop="id" label="ID" align="center" />
       <el-table-column prop="code" label="编码" align="left" />
       <el-table-column prop="name" label="名称" align="left" />
       <el-table-column
@@ -80,12 +85,7 @@
         min-width="150"
       />
       <!-- <el-table-column prop="intro" label="介绍" show-overflow-tooltip	 align="left" min-width="150"/> -->
-      <el-table-column
-        label="操作"
-        align="center"
-        :width="type == 1 ? 250 : 100"
-        
-      >
+      <el-table-column label="操作" align="center" width="250">
         <template #default="scope">
           <div class="btns">
             <el-button type="primary" size="mini" @click="btnPicked(scope.row)"
@@ -94,15 +94,13 @@
             <el-button
               type="primary"
               size="mini"
-              @click="btnOnEdit(scope.row.id)"
-              v-if="type == 1"
+              @click="btnOnEdit(scope.row.id, scope.row)"
               ><svg-icon icon-class="edit" />编辑</el-button
             >
             <el-button
               type="danger"
               size="mini"
               @click="btnOnDelete(scope.row.id)"
-              v-if="type == 1"
               ><svg-icon icon-class="delete" />删除</el-button
             >
           </div>
@@ -252,10 +250,12 @@ export default {
       _this.dialogVisible = true;
     },
 
-    btnOnEdit(id) {
-      this.title = "修改变量";
-      this.dataId = id;
-      this.dialogVisible = true;
+    btnOnEdit(id, row) {
+      this.title = row.type == 1 ? "修改变量" : "修改常量";
+      this.$nextTick(() => {
+        this.dataId = id;
+        this.dialogVisible = true;
+      });
     },
 
     onBtnSearch(e) {
@@ -283,13 +283,13 @@ export default {
       _this.search();
     },
     /* 新增常量 */
-    onBtnConst(){
+    onBtnConst() {
       let _this = this;
       _this.dataId = 0;
-      _this.type=2
+      _this.type = 2;
       _this.title = "创建常量";
       _this.dialogVisible = true;
-    }
+    },
   },
 };
 </script>

+ 31 - 0
src/views/knowledgeMenu/knowledgeList.vue

@@ -0,0 +1,31 @@
+<template>
+    <div class="dashboard-container">
+      
+    </div>
+  </template>
+  
+  <script>
+  import { mapGetters } from 'vuex'
+
+  
+  export default {
+    name: 'Dashboard',
+    components: { adminDashboard, editorDashboard },
+    data() {
+      return {
+        currentRole: 'adminDashboard'
+      }
+    },
+    computed: {
+      ...mapGetters([
+        'roles'
+      ])
+    },
+    created() {
+      if (!this.roles.includes('admin')) {
+        this.currentRole = 'editorDashboard'
+      }
+    }
+  }
+  </script>
+  

+ 1 - 1
src/views/login/index.scss

@@ -67,7 +67,7 @@ $light_gray:#eee;
     .login-form {
       position: relative;
       width: 350px;
-      height:300px;
+      
       margin: 0 auto;
       overflow: hidden;
       background:#FFF;

+ 197 - 25
src/views/login/index.vue

@@ -5,7 +5,7 @@
         <img src="../../assets/images/login-head.png" class="images" />
       </div>
       <el-form
-        v-if="loginOrRetrieve=='login'"
+        v-if="loginOrRetrieve == 'login'"
         ref="loginForm"
         :model="loginForm"
         :rules="loginRules"
@@ -66,33 +66,55 @@
           @click="handleLogin"
           >立即登录</el-button
         >
-       <!--  <div class="tips">
-          <div @click="Retrieve" style="cursor: pointer">找回密码</div>
-        </div> -->
+        <div class="tips">
+          <div @click="Retrieve('retrieve')" style="cursor: pointer">
+            找回密码
+          </div>
+        </div>
       </el-form>
-      <div v-if="loginOrRetrieve=='retrieve'">
+      <div v-if="loginOrRetrieve == 'retrieve'">
         <el-form
-          ref="loginForm"
-          :model="loginForm"
-          :rules="loginRules"
+          ref="RetrieveForm"
+          :model="RetrieveForm"
+          :rules="RetrieveRules"
           class="login-form"
           autocomplete="on"
           label-position="left"
         >
-          <el-form-item prop="username">
-            <span class="svg-container">
-              <svg-icon icon-class="user" />
-            </span>
+          <el-form-item prop="phone">
             <el-input
-              ref="username"
-              v-model="loginForm.username"
-              placeholder="登录用户名"
-              name="username"
+              ref="phone"
+              v-model="RetrieveForm.phone"
+              placeholder="请输入手机号"
+              name="phone"
               type="text"
               tabindex="1"
               autocomplete="on"
             />
           </el-form-item>
+          <el-tooltip
+            v-model="capsTooltip"
+            content="Caps lock is On"
+            placement="right"
+            manual
+          >
+            <el-form-item prop="verification_code">
+              <el-input
+                ref="verification_code"
+                v-model="RetrieveForm.verification_code"
+                type="text"
+                placeholder="请输入验证码"
+                name="text"
+                tabindex="2"
+                autocomplete="on"
+              />
+              <span class="show-pwd">
+                <el-button :disabled="isDisabled" @click="getCode">
+                  {{ buttonText }}
+                </el-button>
+              </span>
+            </el-form-item>
+          </el-tooltip>
 
           <el-tooltip
             v-model="capsTooltip"
@@ -100,22 +122,21 @@
             placement="right"
             manual
           >
-            <el-form-item prop="password">
+            <el-form-item prop="new_password1">
               <span class="svg-container">
                 <svg-icon icon-class="password" />
               </span>
               <el-input
                 :key="passwordType"
                 ref="password"
-                v-model="loginForm.password"
+                v-model="RetrieveForm.new_password1"
                 :type="passwordType"
-                placeholder="登录密码"
+                placeholder=""
                 name="password"
                 tabindex="2"
                 autocomplete="on"
                 @keyup.native="checkCapslock"
                 @blur="capsTooltip = false"
-                @keyup.enter.native="handleLogin"
               />
               <span class="show-pwd" @click="showPwd">
                 <svg-icon
@@ -124,16 +145,47 @@
               </span>
             </el-form-item>
           </el-tooltip>
+          <el-tooltip
+            v-model="capsTooltip"
+            content="Caps lock is On"
+            placement="right"
+            manual
+          >
+            <el-form-item prop="new_password2">
+              <span class="svg-container">
+                <svg-icon icon-class="password" />
+              </span>
+              <el-input
+                :key="passwordType"
+                ref="passwords"
+                v-model="RetrieveForm.new_password2"
+                :type="passwordTypes"
+                placeholder="确认新密码"
+                name="password"
+                tabindex="2"
+                autocomplete="on"
+                @keyup.native="checkCapslock"
+                @blur="capsTooltips = false"
+              />
+              <span class="show-pwd" @click="showPwds">
+                <svg-icon
+                  :icon-class="
+                    passwordTypes === 'password' ? 'eye' : 'eye-open'
+                  "
+                />
+              </span>
+            </el-form-item>
+          </el-tooltip>
 
           <el-button
             :loading="loading"
             type="primary"
             style="width: 100%; margin-bottom: 30px"
-            @click="handleLogin"
-            >立即登录</el-button
+            @click="retPass"
+            >重置密码</el-button
           >
           <div class="tips">
-            <div @click="Retrieve" style="cursor: pointer">找回密码</div>
+            <div @click="Retrieve('login')" style="cursor: pointer">去登陆</div>
           </div>
         </el-form>
       </div>
@@ -143,6 +195,7 @@
 
 <script>
 import { validUsername } from "@/utils/validate";
+import { tailPhone, codeCheckout, updatePassword, login } from "@/api/user";
 import SocialSign from "./components/SocialSignin";
 
 export default {
@@ -163,6 +216,37 @@ export default {
         callback();
       }
     };
+    const validatePhone = (rule, value, callback) => {
+      const phoneRegex = /^1[3-9]\d{9}$/;
+      if (value === "") {
+        callback(new Error("请输入手机号码"));
+      } else if (!phoneRegex.test(value)) {
+        callback(new Error("请输入正确的手机号码"));
+      } else {
+        callback();
+      }
+    };
+
+    const validateNewPassword = (rule, value, callback) => {
+      if (value.length < 6) {
+        callback(new Error("新密码不能少于6个字符"));
+      } else {
+        if (this.RetrieveForm.new_password2 !== "") {
+          this.$refs.RetrieveForm.validateField("new_password2");
+        }
+        callback();
+      }
+    };
+
+    const validateConfirmPassword = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("请再次输入密码"));
+      } else if (value !== this.RetrieveForm.new_password1) {
+        callback(new Error("两次输入的密码不一致"));
+      } else {
+        callback();
+      }
+    };
     return {
       loginForm: {
         username: "",
@@ -177,12 +261,38 @@ export default {
         ],
       },
       passwordType: "password",
+      passwordTypes: "password",
       capsTooltip: false,
       loading: false,
       showDialog: false,
       redirect: undefined,
       otherQuery: {},
-      loginOrRetrieve:'login'
+      loginOrRetrieve: "login",
+      RetrieveForm: {
+        phone: "",
+        verification_code: "",
+        new_password1: "",
+        new_password2: "",
+      },
+      RetrieveRules: {
+        phone: [{ required: true, trigger: "blur", validator: validatePhone }],
+        verification_code: [
+          { required: true, message: "请输入验证码", trigger: "blur" },
+        ],
+        new_password1: [
+          { required: true, trigger: "blur", validator: validateNewPassword },
+        ],
+        new_password2: [
+          {
+            required: true,
+            trigger: "blur",
+            validator: validateConfirmPassword,
+          },
+        ],
+      },
+      countdown: 60,
+      isDisabled: false,
+      buttonText: "获取验证码",
     };
   },
   watch: {
@@ -211,6 +321,66 @@ export default {
     // window.removeEventListener('storage', this.afterQRScan)
   },
   methods: {
+    /* 找回密码 */
+    retPass() {
+      this.$refs.RetrieveForm.validate((valid) => {
+        if (valid) {
+          codeCheckout({
+            phone: this.RetrieveForm.phone,
+            verification_code: this.RetrieveForm.verification_code,
+          })
+            .then((response) => {
+              if (response.status !== 200) return;
+              updatePassword(this.RetrieveForm).then((res) => {
+                this.loginOrRetrieve = "login";
+                this.$message.success("密码已成功重置");
+              });
+            })
+            .catch((error) => {
+              this.$message.error("验证码校验失败");
+            });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    /* 获取验证码 */
+    getCode() {
+      this.$refs.RetrieveForm.validateField("phone", (errorMessage) => {
+        if (errorMessage) {
+          this.$message.warning(errorMessage);
+        } else {
+          this.isDisabled = true;
+          this.buttonText = `${this.countdown}s`;
+          const timer = setInterval(() => {
+            if (this.countdown > 0) {
+              this.countdown--;
+              this.buttonText = `${this.countdown}s`;
+            } else {
+              clearInterval(timer);
+              this.isDisabled = false;
+              this.buttonText = "获取验证码";
+              this.countdown = 60;
+            }
+          }, 1000);
+
+          tailPhone({ phone: this.RetrieveForm.phone }).then((res) => {
+            console.log(res);
+          });
+        }
+      });
+    },
+    showPwds() {
+      if (this.passwordTypes === "password") {
+        this.passwordTypes = "";
+      } else {
+        this.passwordTypes = "password";
+      }
+      this.$nextTick(() => {
+        this.$refs.passwords.focus();
+      });
+    },
     checkCapslock(e) {
       const { key } = e;
       this.capsTooltip = key && key.length === 1 && key >= "A" && key <= "Z";
@@ -274,7 +444,9 @@ export default {
     //   }
     // }
     /* 找回密码 */
-    Retrieve() {},
+    Retrieve(val) {
+      this.loginOrRetrieve = val;
+    },
   },
 };
 </script>

+ 1 - 0
src/views/profile/index.vue

@@ -61,6 +61,7 @@ export default {
             this.$message(res.message);return;
           }
           this.$message("用户头像更新成功")
+          location.reload()
         })
     },
   }