<script setup lang="ts">
import RuleTemplate from '../../RuleTemplate.vue'
import { useConnection, useMetaEvent } from '../../../composables/useAllData'

const props = defineProps<{ node: any }>()

const { getConnection } = useConnection()
const { metaEventList } = useMetaEvent()

const config = computed(() => {
  return props.node.data.teacher || {}
})

const connection = computed(() => getConnection(config.value.connection_id))

function paramsParse(data: any, form: any) {
  return { event_id: form.event_id }
}
</script>

<template>
  <RuleTemplate :node="node" step :paramsParse="paramsParse">
    <template #header-answer>
      <span class="is-answer">{{ config.operate }} &nbsp;&nbsp; {{ connection?.name }}</span>
    </template>
    <template v-slot:header-form-append="{ model }: { model: any }">
      <el-form-item label="事件">
        <el-select v-model="model.event_id">
          <el-option v-for="item in metaEventList" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
    </template>
  </RuleTemplate>
</template>
