
<!-- 驳回原因用户姓名输入 -->
<template>
  <a-form
    ref="form"
    v-bind="formItemLayout"
    :form="form"
  >
    <a-form-item label="用户手机">
      <a-input
        v-decorator="[
          'mobile_no',
          {
            rules: [
              { required: true, message: `请添加用户手机!`, type: 'string' },
            ]
          }
        ]"
        :placeholder="`请添加用户手机!`"
      />
    </a-form-item>
    <a-form-item label="真实姓名">
      <a-input
        v-decorator="[
          'name',
          {
            rules: [
              { required: true, message: `请添加真实姓名!`, type: 'string' },
            ]
          }
        ]"
        :placeholder="`请添加真实姓名!`"
      />
    </a-form-item>
    <a-form-item label="推荐人信息">
      <a-input
        v-decorator="[
          'parent_mobile',
          {
            rules: [
              { required: true, message: `请添加推荐人手机号!`, type: 'string' },
            ]
          }
        ]"
        :placeholder="`请添加推荐人手机号!`"
      />
    </a-form-item>
  </a-form>
</template>

<script>
import { addMiddlesUser } from '@/api/user'
export default {
  name: 'AddUser',
  data: () => ({
    formItemLayout: {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 }
    },
    loading: false
  }),
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  methods: {
    onOk () {
      return new Promise(resolve => {
        this.form.validateFields((errors, values) => {
          if (!errors) {
            addMiddlesUser(values).then((res) => {
              this.$notification.success({
                message: '成功',
                description: '新增成功'
              })
              resolve(true)
            }).catch((err) => {
              this.$notification.error({
                message: '失败',
                description: err.message
              })
              resolve(false)
            })
          }
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
