luowei před 1 rokem
rodič
revize
692f3ef330
1 změnil soubory, kde provedl 88 přidání a 19 odebrání
  1. 88 19
      src/views/system/user/index.vue

+ 88 - 19
src/views/system/user/index.vue

@@ -327,7 +327,7 @@
                     type="text"
                     icon="el-icon-key"
                     v-if="scope.row.source == 0"
-                    @click="handleResetPwd(scope.row)"
+                    @click="handleRestPassword(scope.row)"
                     v-hasPermi="['system:user:resetPwd']"
                     >重置密码</el-button
                   >
@@ -344,6 +344,32 @@
         </div>
       </el-col>
     </el-row>
+  <!-- 重置密码对话框 -->
+    <DialogCom :title="title" :visible.sync="close" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-row>
+       
+          <el-col :span="10">
+            <el-form-item  label="密码" prop="password" >
+              <el-input
+              style="width: 317px;"
+                v-model="form.password"
+                placeholder="请输入密码"
+                autocomplete="off"
+                type="password"
+                maxlength="20"
+                show-password
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitRest">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </DialogCom>
+
 
     <!-- 添加或编辑配置对话框 -->
     <DialogCom :title="title" :visible.sync="open" width="800px" append-to-body>
@@ -591,6 +617,7 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      close:false,
       // 机构名称
       deptName: null,
       isRoleIdsChanged: false,
@@ -875,6 +902,7 @@ export default {
     // 取消按钮
     cancel() {
       this.open = false;
+      this.close=false;
       this.reset();
     },
     // 表单重置
@@ -931,6 +959,15 @@ export default {
         this.form.password = this.initPassword;
       });
     },
+    handleRestPassword(row) {
+      this.reset();
+      const userId = row.id || this.ids;
+      getUser(userId).then((response) => {
+        this.form.id = response.data.id;
+        this.close = true;
+        this.title = "重置密码";
+      });
+    },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.isRoleIdsChanged = false;
@@ -955,31 +992,63 @@ export default {
 
     /** 重置密码按钮操作 */
     handleResetPwd(row) {
-      console.log(row, "row");
-      this.$prompt('请输入"' + row.name + '"的新密码', "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        closeOnClickModal: false,
-        inputPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z0-9_]{8,16}$/,
-        inputErrorMessage:
-          "用户密码长度介于8和16之间,只能输入字母、数字及_,必须包含大小写字母和数字",
-      })
-        .then(({ value }) => {
-          let data = {
-            id: row.userId,
-            password: value,
-          };
-          resetUserPwd(data).then((response) => {
-            this.$modal.msgSuccess("修改成功,新密码是:" + value);
+      // console.log(row, "row");
+      // this.$prompt('请输入"' + row.name + '"的新密码', "提示", {
+      //   confirmButtonText: "确定",
+      //   cancelButtonText: "取消",
+      //   closeOnClickModal: false,
+      //   inputPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z0-9_]{8,16}$/,
+      //   inputErrorMessage:
+      //     "用户密码长度介于8和16之间,只能输入字母、数字及_,必须包含大小写字母和数字",
+      // })
+      //   .then(({ value }) => {
+      //     let data = {
+      //       id: row.userId,
+      //       password: value,
+      //     };
+      //     resetUserPwd(data).then((response) => {
+      //       this.$modal.msgSuccess("修改成功,新密码是:" + value);
+      //     });
+      //   })
+      //   .catch(() => {});
+      console.log(this.form.id, "row");
+      let data = {
+             id: this.form.id,
+             password: this.form.password,
+           };
+      resetUserPwd(data).then((response) => {
+             this.$modal.msgSuccess("修改成功,新密码是:" + value);
           });
-        })
-        .catch(() => {});
     },
     /** 分配角色操作 */
     handleAuthRole: function (row) {
       const userId = row.id;
       this.$router.push("/system/user-auth/role/" + userId);
     },
+    submitRest:function (){
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          console.log(this.form, "this.form");
+          if (this.form.id != undefined) {
+            // console.log(this.form, "this.form");
+            // updateUser(this.form).then((response) => {
+            //   this.$modal.msgSuccess("修改成功");
+            //   this.close = false;
+            //   this.getList();
+            // });
+         
+            let data = {
+             id: this.form.id,
+             password: this.form.password,
+           };
+            resetUserPwd(data).then((response) => {
+             this.$modal.msgSuccess("修改成功,新密码是:" + this.form.password);
+             this.close = false;
+          });
+          } 
+        }
+      });
+    },
     /** 提交按钮 */
     submitForm: function () {
       this.$refs["form"].validate((valid) => {