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

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

const role = inject('role') as string

const form = reactive({
  in_group: '',
  in_group_name: '',
  group_id: '',
  group_name: ''
})
watchEffect(() => {
  Object.assign(form, props.node.data[role])
})

const { groupList } = useGroup()

watchEffect(() => {
  form.group_name = groupList.value.find(item => item.id === form.group_id)?.name || ''
})
</script>

<template>
  <ConfigTemplate :model="form" :node="node">
    <el-form-item>
      <el-radio-group v-model="form.in_group">
        <el-radio value="0">在群组中</el-radio>
        <el-radio value="1">不在群组中</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <el-select v-model="form.group_id">
        <el-option v-for="item in groupList" :key="item.id" :value="item.id" :label="item.name"></el-option>
      </el-select>
    </el-form-item>
  </ConfigTemplate>
</template>
