<template>
  <el-dialog v-model="visible" title="新增关怀纪实" width="500px">
    <el-form label-width="80px">
      <el-form-item label="关怀对象">
        <strong>{{ currentStudent?.studentName }}</strong>
      </el-form-item>
      <el-form-item label="关怀方式">
        <el-radio-group v-model="form.method">
          <el-radio label="talk">谈心谈话</el-radio>
          <el-radio label="visit">走访寝室</el-radio>
          <el-radio label="phone">电话联系</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="纪实内容">
        <el-input v-model="form.content" type="textarea" rows="4" placeholder="记录谈话要点及学生反馈..." />
      </el-form-item>
      <el-form-item label="后续跟进">
        <el-checkbox v-model="form.followUp">需要持续关注</el-checkbox>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="confirm">提交记录</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'

const emit = defineEmits(['success'])

const visible = ref(false)
const currentStudent = ref(null)

const form = reactive({
  method: 'talk',
  content: '',
  followUp: true
})

const open = (student) => {
  currentStudent.value = student
  form.method = 'talk'
  form.content = ''
  form.followUp = true
  visible.value = true
}

const confirm = () => {
  visible.value = false
  ElMessage.success('关怀纪实已保存')
  emit('success')
}

defineExpose({
  open
})
</script>
