<template>
  <div class="accountSet-container">
    <div class="title-container">
      <h3 class="title">账号设置</h3>
    </div>
    <el-form
      ref="accountSetForm"
      :model="accountSetForm"
      :rules="accountSetRules"
      class="accountSet-form"
      autocomplete="on"
      label-position="top"
    >
      <el-form-item label="账号" prop="email">
        <el-input v-model="accountSetForm.email"></el-input>
      </el-form-item>
      <el-form-item label="名称" prop="name">
        <el-input v-model="accountSetForm.name"></el-input>
      </el-form-item>
      <el-form-item label="联系电话" prop="phone">
        <el-input v-model="accountSetForm.phone"></el-input>
      </el-form-item>
      <el-button type="primary" @click.native.prevent="handleaccountSet">保存</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'AccountSet',
  data() {
    return {
      accountSetForm: {
        email: '',
        name: '',
        phone: ''
      },
      accountSetRules: {
        email: [
          {
            required: true,
            trigger: 'blur',
            max: 128,
            message: '账号必填'
          }
        ],
        name: [
          {
            required: true,
            trigger: 'blur',
            max: 20,
            message: '名称输入字符最长为20位'
          }
        ],
        phone: [
          {
            required: true,
            trigger: 'blur',
            max: 20,
            message: '电话输入字符最长为20位'
          }
        ]
      }
    }
  },
  created() {},
  methods: {
    handleaccountSet() {
      this.$refs.accountSetForm.validate(valid => {
        console.log(this.accountSetForm)
        if (valid) {
          // this.$store
          //   .dispatch('user/accountSet', this.accountSetForm)
          //   .then(() => {})
          //   .catch(() => {
          //   })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss">
form {
  padding: 10px;
}
</style>
