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

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

const role = inject('role') as string

const form = reactive({
  operate: '',
  connection_id: '',
  app_name: ''
})
watchEffect(() => {
  Object.assign(form, props.node.data[role])
})

const { connectionList } = useConnection(6)

const operateList = ref([
  { label: '用户发送文本私信', value: '0' },
  { label: '用户发送表情私信', value: '1' },
  { label: '用户发送卡片私信', value: '2' },
  { label: '在主页Tab提交预约', value: '3' }
])
</script>

<template>
  <ConfigTemplate :model="form" :node="node" :stepNum="2">
    <template #default="{ step }: { step: number }">
      <el-form-item>
        <template v-if="step === 0">
          <el-radio-group v-model="form.operate" v-if="step === 0">
            <el-radio v-for="item in operateList" :key="item.value" :value="item.value" style="width: 140px">
              {{ item.label }}
            </el-radio>
          </el-radio-group>
        </template>
        <template v-else-if="step === 1">
          <el-select placeholder="请选择" style="width: 100%" v-model="form.connection_id">
            <el-option v-for="item in connectionList" :key="item.id" :value="item.id" :label="item.name"></el-option>
          </el-select>
        </template>
        <template v-else-if="step === 2">
          <el-input v-model="form.app_name" placeholder="请输入APP名称"></el-input>
        </template>
      </el-form-item>
    </template>
  </ConfigTemplate>
</template>
