Browse Source

重置密码改为自定义

wangzhuo 2 years ago
parent
commit
c051319fe5
2 changed files with 61 additions and 15 deletions
  1. 2 1
      src/api/system/user.js
  2. 59 14
      src/views/system/user.vue

+ 2 - 1
src/api/system/user.js

@@ -90,12 +90,13 @@ export const getUserInfo = () => {
   })
 }
 
-export const resetPassword = (userIds) => {
+export const resetPassword = (userIds, newPassword) => {
   return request({
     url: '/api/blade-user/reset-password',
     method: 'post',
     params: {
       userIds,
+      newPassword
     }
   })
 }

+ 59 - 14
src/views/system/user.vue

@@ -124,6 +124,26 @@
             </template>
           </avue-form>
         </el-dialog>
+
+        <!--    重置密码对话框    -->
+        <el-dialog
+          title="重置密码"
+          :visible.sync="dialogVisible"
+          width="30%"
+          :append-to-body="true">
+
+          <el-form :inline="true">
+            <el-form-item label="密码重置为:" prop="changeThePassword" >
+              <el-input v-model="newPassword" placeholder="请输入内容"></el-input>
+            </el-form-item>
+          </el-form>
+
+          <span slot="footer" class="dialog-footer">
+            <el-button @click="dialogVisible = false">取 消</el-button>
+            <el-button type="primary" @click="resetPasswordDiy()">确 定</el-button>
+          </span>
+        </el-dialog>
+
         <el-dialog title="用户平台配置"
                    append-to-body
                    :visible.sync="platformBox">
@@ -168,7 +188,8 @@
     updatePlatform,
     add,
     grant,
-    resetPassword
+    resetPassword,
+    resetYourPassword
   } from "@/api/system/user";
   import {getDeptTree, getDeptLazyTree} from "@/api/system/dept";
   import {getRoleTree} from "@/api/system/role";
@@ -198,10 +219,14 @@
       return {
         form: {},
         search:{},
+        // 密码重置框是否可见
+        dialogVisible: false,
         roleBox: false,
         excelBox: false,
         platformBox: false,
         initFlag: true,
+        // 需要重置的密码
+        newPassword: '123456',
         selectionList: [],
         query: {},
         loading: true,
@@ -850,21 +875,35 @@
           this.$message.warning("请选择至少一条数据");
           return;
         }
-        this.$confirm("确定将选择账号密码重置为123456?", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        })
-          .then(() => {
-            return resetPassword(this.ids);
-          })
-          .then(() => {
+        this.dialogVisible = true;
+        // this.$confirm("确定将选择账号密码重置为123456?", {
+        //   confirmButtonText: "确定",
+        //   cancelButtonText: "取消",
+        //   type: "warning"
+        // })
+        //   .then(() => {
+        //     return resetPassword(this.ids);
+        //   })
+        //   .then(() => {
+        //     this.$message({
+        //       type: "success",
+        //       message: "操作成功!"
+        //     });
+        //     this.$refs.crud.toggleSelection();
+        //   });
+      },
+      // 重置密码为指定内容
+      resetPasswordDiy() {
+        resetPassword(this.ids, this.newPassword).then(res => {
+          console.log(res)
+          if (res.data.code === 200) {
             this.$message({
-              type: "success",
-              message: "操作成功!"
+              message: '操作成功!',
+              type: 'success'
             });
-            this.$refs.crud.toggleSelection();
-          });
+            this.dialogVisible = false;
+          }
+        })
       },
       handleGrant() {
         if (this.selectionList.length === 0) {
@@ -1014,4 +1053,10 @@
   .box .el-scrollbar__wrap {
     overflow: scroll;
   }
+
+  .el-dialog .el-dialog__body{
+    display: flex;
+    justify-content: center;
+    align-items: center;
+  }
 </style>