<template>
  <div >
       <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="会员昵称" prop="nickname">
          <el-input v-model="form.nickname" placeholder="请输入用户昵称" />
        </el-form-item>
        <el-form-item label="手机号码" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入手机号码" />
        </el-form-item>
        <el-form-item label="状态">
            <el-radio-group v-model="form.status">
              <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
            </el-radio-group>
        </el-form-item>
      </el-form>
      <div    style="text-align:right;">
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
  </div>
</template>

<script>
import { listUser, getUser, delUser, addUser, updateUser, exportUser } from "@/api/hisStore/user";

export default {
  name: "add",
  data() {
    return {
      statusOptions:[],
      // 表单参数
      form: {
        status:"1"
      },
      // 表单校验
      rules: {
        phone: [
          { required: true, message: "手机号不能为空", trigger: "blur" }
        ],
        nickname: [
          { required: true, message: "会员昵称不能为空", trigger: "blur" }
        ],

      }
    };
  },
  created() {
    this.getDicts("user_status").then((response) => {
      this.statusOptions = response.data;
    });
  },

  methods: {
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          addUser(this.form).then(response => {
            if (response.code === 200) {
              this.msgSuccess("新增成功");
              this.$emit("addUser")

            }
          });
        }
      });
    },

  }
};
</script>
<style scoped>

</style>
