<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(8)

const operateList = ref([
  { label: '被用户关注', value: '0' },
  { label: '主页被点赞', value: '1' },
  { label: '主页被收藏', value: '2' },
  { label: '笔记被点赞', value: '3' },
  { label: '笔记被收藏', value: '4' },
  { label: '笔记被转发', value: '5' }
])
</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>
