password-edit.vue 3.29 KB
<template>
  <div class="content">
    <div class="user-info">
      <el-form
        ref="form"
        label-width="100px"
        :model="form"
        class="form-wrapper"
        :rules="rules"
      >
        <el-form-item label="旧密码:" required prop="oldPassword">
          <el-input
            v-model="form.oldPassword"
            clearable
            type="password"
            show-password
          />
        </el-form-item>
        <el-form-item label="新密码:" required prop="newPassword">
          <el-input
            v-model="form.newPassword"
            clearable
            type="password"
            show-password
          />
        </el-form-item>
        <el-form-item label="确认密码:" required prop="confirmPassword">
          <el-input
            v-model="form.confirmPassword"
            clearable
            type="password"
            show-password
          />
        </el-form-item>
      </el-form>
      <div class="bottom-wrapper">
        <el-button type="primary" @click="updatePassword">确认修改</el-button>
      </div>
    </div>
  </div>
</template>

<script>
// import { updateUserPassword } from '@api/organizationManage'
export default {
  props: {
    // userInfo: {
    //   type: Object,
    //   default: null
    // }
  },
  data() {
    return {
      form: {},
      sexList: [],
      userId: '',
      rules: {
        oldPassword: [
          { required: true, message: '旧密码不能为空', trigger: 'blur' }
        ],
        newPassword: [
          { required: true, message: '新密码不能为空', trigger: 'blur' }
        ],
        confirmPassword: [
          { required: true, message: '确认密码不能为空', trigger: 'blur' },
          { validator: this.validatorConfirmPassword, trigger: 'blur' }
        ]
      }
    }
  },
  computed: {},
  watch: {
    // userInfo: {
    //   handler: function(val) {
    //     if (val) {
    //       this.userId = val.id
    //     }
    //   }
    // }
  },
  mounted() {},
  // methods: {
  //   validatorConfirmPassword(rule, value, callback) {
  //     const { newPassword } = this.form
  //     if (value !== newPassword) {
  //       callback('两次输入密码不一致')
  //     } else {
  //       callback()
  //     }
  //   },
  //   updatePassword() {
  //     this.$refs.form.validate((valid) => {
  //       if (valid) {
  //         const params = Object.assign({}, this.form, { id: this.userId })
  //         updateUserPassword(params).then((res) => {
  //           if (res.status === 1) {
  //             this.$message.success({ message: res.message, showClose: true })
  //           } else {
  //             this.$message.error({ message: res.message, showClose: true })
  //           }
  //         })
  //       }
  //     })
  //   }
  // }
}
</script>

<style scoped lang="scss">
.user-info {
  margin: 36px 200px;
  background: #ffffff;
  max-height: 90%;
  overflow-y: auto;
  .form-wrapper {
    padding: 24px 120px 0px;
    .el-form-item {
      margin-bottom: 24px;
      .el-form-item__label {
        color: #747e8c;
      }
      ::v-deep .el-input .el-input__inner {
        padding: 0 8px;
        height: 40px;
        line-height: 40px;
        border: 1px solid #dfe7f3;
      }
    }
  }
  .bottom-wrapper {
    padding: 32px 120px 24px;
    text-align: right;
  }
}
</style>