<template>
  <div class="node-config">
    <el-divider content-position="left">消息配置</el-divider>
    
    <el-form-item label="消息模板">
      <el-input v-model="config.message_template" type="textarea" :rows="3" @change="$emit('change')" placeholder="支持变量: {user_name}, {task_name}, {status}" />
    </el-form-item>
    
    <el-form-item label="目标用户">
      <el-input v-model="config.target" placeholder="@all 或用户ID" @change="$emit('change')" />
    </el-form-item>
    
    <el-form-item label="消息类型">
      <el-select v-model="config.message_type" @change="$emit('change')">
        <el-option label="文本消息" value="text" />
        <el-option label="Markdown消息" value="markdown" />
        <el-option label="卡片消息" value="card" />
      </el-select>
    </el-form-item>
    
    <el-divider content-position="left">发送选项</el-divider>
    
    <el-form-item label="异步发送">
      <el-switch v-model="config.async_send" @change="$emit('change')" />
    </el-form-item>
    
    <el-form-item label="发送失败处理">
      <el-select v-model="config.error_handling" @change="$emit('change')">
        <el-option label="抛出错误" value="throw" />
        <el-option label="记录日志" value="log" />
        <el-option label="重试" value="retry" />
      </el-select>
    </el-form-item>
  </div>
</template>

<script setup lang="ts">
const config = defineModel<any>({ 
  default: () => ({ 
    message_template: '',
    target: '',
    message_type: 'text',
    async_send: false,
    error_handling: 'throw'
  }) 
})

defineEmits(['change'])
</script>
