<template>
  <el-form
    :label-position="'right'"
    label-width="120px"
    :model="platformPersonForm"
    :rules="platformPersonFormRules"
    ref="platformPersonFormRef"
    style="max-width: 66%"
  >
    <el-form-item label="姓名" prop="name">
      <el-input v-model="platformPersonForm.name" />
    </el-form-item>
    <el-form-item label="邮箱">
      <el-input v-model="platformPersonForm.email"/>
    </el-form-item>
     <el-form-item label="备注">
      <el-input type="textarea" :rows="3" v-model="platformPersonForm.remark" />
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive, ref, onMounted } from 'vue'

const platformPersonForm = reactive({
  name: '',
  email: '',
  remark: '',
})

const platformPersonFormRules = reactive({
 
})
const platformPersonFormRef = ref(null)
const emit = defineEmits(['action'])

const submitForm = async () => {
  if (!platformPersonFormRef) return
  await platformPersonFormRef.value.validate((valid, fields) => {
    if (valid) {
      emit('action', platformPersonForm)
    } else {
      emit('action',null)
    }
  })
}
const clearForm = () => {
  if (!platformPersonFormRef) return
  platformPersonFormRef.value.resetFields()
} 

const setForm = (data) => {
  platformPersonForm.value = Object.assign(platformPersonForm, data);
}

onMounted(() => {
   
})

defineExpose({ submitForm, clearForm, setForm })
</script>