<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: '',
  message: ''
})
watchEffect(() => {
  Object.assign(form, props.node.data[role])
})

const { connectionList } = useConnection(3)

const operateList = ref([{ label: '新用户注册', value: '0' }])
</script>

<template>
  <ConfigTemplate :model="form" :node="node" :stepNum="1">
    <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: 130px">
              {{ 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>
      </el-form-item>
    </template>
  </ConfigTemplate>
</template>
