<script setup lang="ts">
import Task from './Task.vue'
import TaskTemplate from './TaskTemplate/index.vue'
import { nextTick, ref } from 'vue'

const taskRef = ref<{ currentTaskID: string }>()
const taskTemplateRef = ref<{ changeTask: () => void; clear: () => void }>()

function handleSearch() {
  nextTick(() => {
    taskTemplateRef.value?.changeTask()
  })
}

// 获取当前任务的 TaskID
function getTaskID(): string {
  return taskRef.value?.currentTaskID || ''
}

defineExpose({
  getTaskID
})
</script>

<template>
  <div class="p-[24px] h-[calc(100%-60px)]">
    <Task ref="taskRef" @search="handleSearch" @search-start="taskTemplateRef?.clear" />
    <TaskTemplate ref="taskTemplateRef" :TaskID="taskRef?.currentTaskID" />
  </div>
</template>

<style scoped lang="scss"></style>
