|
@@ -0,0 +1,127 @@
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ class="reset-pwd"
|
|
|
+ :visible.sync="modalIsShow"
|
|
|
+ title="修改密码"
|
|
|
+ top="10vh"
|
|
|
+ width="500px"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ append-to-body
|
|
|
+ @open="visibleChange"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="modalFormComp"
|
|
|
+ :model="resetModel"
|
|
|
+ :rules="resetRules"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-form-item prop="password" label="旧密码:">
|
|
|
+ <el-input
|
|
|
+ size="large"
|
|
|
+ type="password"
|
|
|
+ v-model="resetModel.password"
|
|
|
+ placeholder="请输入旧密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="newPassword" label="新密码:">
|
|
|
+ <el-input
|
|
|
+ size="large"
|
|
|
+ type="password"
|
|
|
+ v-model="resetModel.newPassword"
|
|
|
+ placeholder="请输入新密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="rePassword" label="再次密码:">
|
|
|
+ <el-input
|
|
|
+ size="large"
|
|
|
+ type="password"
|
|
|
+ v-model="resetModel.rePassword"
|
|
|
+ placeholder="请再次输入新密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="cancel">取消</el-button>
|
|
|
+ <el-button type="primary" :disabled="isSubmit" @click="submit"
|
|
|
+ >确认</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { updatePwd } from "../api";
|
|
|
+import { password } from "@/plugins/formRules";
|
|
|
+// import { AES } from "@/plugins/crypto";
|
|
|
+
|
|
|
+const initModalForm = {
|
|
|
+ id: "",
|
|
|
+ password: "",
|
|
|
+ newPassword: "",
|
|
|
+ rePassword: ""
|
|
|
+};
|
|
|
+export default {
|
|
|
+ name: "reset-pwd",
|
|
|
+ data() {
|
|
|
+ const equalToPswd = (rule, value, callback) => {
|
|
|
+ if (value !== this.resetModel.newPassword) {
|
|
|
+ callback(new Error("两次输入的密码不一致"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ modalIsShow: false,
|
|
|
+ isSubmit: false,
|
|
|
+ resetModel: { ...initModalForm },
|
|
|
+ resetRules: {
|
|
|
+ password,
|
|
|
+ newPassword: password,
|
|
|
+ rePassword: [
|
|
|
+ ...password,
|
|
|
+ {
|
|
|
+ validator: equalToPswd,
|
|
|
+ trigger: "blur"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initData(val) {
|
|
|
+ this.resetModel = { ...initModalForm };
|
|
|
+ this.resetModel.id = this.$ls.get("user", { id: "" }).id;
|
|
|
+ },
|
|
|
+ visibleChange() {
|
|
|
+ this.initData(this.instance);
|
|
|
+ },
|
|
|
+ cancel() {
|
|
|
+ this.modalIsShow = false;
|
|
|
+ },
|
|
|
+ open() {
|
|
|
+ this.modalIsShow = true;
|
|
|
+ },
|
|
|
+ async submit() {
|
|
|
+ const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ if (this.isSubmit) return;
|
|
|
+ this.isSubmit = true;
|
|
|
+ const data = await updatePwd(this.resetModel).catch(() => {
|
|
|
+ this.isSubmit = false;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!data) return;
|
|
|
+
|
|
|
+ this.isSubmit = false;
|
|
|
+ this.$message.success("修改成功,请重新登录!");
|
|
|
+ this.$emit("modified");
|
|
|
+ this.cancel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|