<template>
  <CheckGroup
    :list="infoList"
    @change="handleChange"
    :default-value="defaultInfo"
    value-key="id"
    label-key="name"
  />
</template>

<script lang="ts" setup>
import { getUniversityType } from '@/service/index/api'
import CheckGroup from '@/pages-evaluation-sub/components/check-group/CheckGroup.vue'

const infoList = ref()
getUniversityType().then((res) => {
  if (res.code === 200) {
    infoList.value = res.result as { id: number; name: string }[]
  }
})

const defaultInfo = ref<string[]>([])

const emits = defineEmits(['change', 'changeName'])

const handleChange = (val: any) => {
  const names = infoList.value.filter((item) => val.includes(item.id)).map((item) => item.name)
  emits('changeName', names)
  emits('change', val)
}
</script>
