userInfo.vue 2.12 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2
<template>
  <el-form ref="form" :model="user" :rules="rules" label-width="80px">
Marcus's avatar
Marcus committed
3
    <el-form-item :label="$t('用户昵称')" prop="nickName">
sunhongwei's avatar
sunhongwei committed
4 5
      <el-input v-model="user.nickname" />
    </el-form-item>
Marcus's avatar
Marcus committed
6
    <el-form-item :label="$t('手机号码')" prop="mobile">
sunhongwei's avatar
sunhongwei committed
7 8
      <el-input v-model="user.mobile" maxlength="11" />
    </el-form-item>
Marcus's avatar
Marcus committed
9
    <el-form-item :label="$t('邮箱')" prop="email">
sunhongwei's avatar
sunhongwei committed
10 11
      <el-input v-model="user.email" maxlength="50" />
    </el-form-item>
Marcus's avatar
Marcus committed
12
    <el-form-item :label="$t('性别')">
sunhongwei's avatar
sunhongwei committed
13
      <el-radio-group v-model="user.sex">
Marcus's avatar
Marcus committed
14 15
        <el-radio :label="1">{{ $t('') }}</el-radio>
        <el-radio :label="2">{{ $t('') }}</el-radio>
sunhongwei's avatar
sunhongwei committed
16 17 18
      </el-radio-group>
    </el-form-item>
    <el-form-item>
Marcus's avatar
Marcus committed
19 20
      <el-button type="primary" size="mini" @click="submit">{{ $t('保存') }}</el-button>
      <el-button type="danger" size="mini" @click="close">{{ $t('关闭') }}</el-button>
sunhongwei's avatar
sunhongwei committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    </el-form-item>
  </el-form>
</template>

<script>
import { updateUserProfile } from "@/api/system/user";

export default {
  props: {
    user: {
      type: Object
    }
  },
  data() {
    return {
      // 表单校验
      rules: {
        nickname: [
Marcus's avatar
Marcus committed
39
          { required: true, message: this.$t("用户昵称不能为空"), trigger: "blur" }
sunhongwei's avatar
sunhongwei committed
40 41
        ],
        email: [
Marcus's avatar
Marcus committed
42
          { required: true, message: this.$t("邮箱地址不能为空"), trigger: "blur" },
sunhongwei's avatar
sunhongwei committed
43 44
          {
            type: "email",
Marcus's avatar
Marcus committed
45
            message: this.$t("请输入正确的邮箱地址"),
sunhongwei's avatar
sunhongwei committed
46 47 48 49
            trigger: ["blur", "change"]
          }
        ],
        mobile: [
Marcus's avatar
Marcus committed
50
          { required: true, message: this.$t("手机号码不能为空"), trigger: "blur" },
sunhongwei's avatar
sunhongwei committed
51 52
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
Marcus's avatar
Marcus committed
53
            message: this.$t("请输入正确的手机号码"),
sunhongwei's avatar
sunhongwei committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
            trigger: "blur"
          }
        ]
      }
    };
  },
  methods: {
    submit() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateUserProfile(this.user).then(response => {
            this.$modal.msgSuccess("修改成功");
          });
        }
      });
    },
    close() {
      this.$tab.closePage();
    }
  }
};
</script>