<template>
    <OutcomeList
      v-if="!outcomeId"
      :task_id="task_id"
      :draft="draft"
      :account-list="accountList"
    />
    <OutcomeDetail v-else :outcome-id="outcomeId" :draft="draft" />
  </template>
  
  <script lang="ts" setup>
  import { PropType, ref } from 'vue'
  import { useEmitt } from '@/logics/mitt/useEmitt'
  import OutcomeList from './outcome-list.vue'
  import OutcomeDetail from './outcome-detail.vue'
  
  const outcomeId = ref()
  defineProps({
    draft: {
      type: Boolean,
      required: true,
      default: () => {
        return false
      }
    },
    task_id: {
      type: String,
      required: true
    },
    accountList: {
      type: Array as PropType<{ id: string; name: string }[]>,
      required: true
    }
  })
  
  // 监听子组件
  useEmitt({
    name: 'redirectOutcomeDetailPage',
    callback: (id: string) => {
      outcomeId.value = id
    }
  })
  // 监听子组件
  useEmitt({
    name: 'redirectOutcomeListPage',
    callback: () => {
      outcomeId.value = undefined
    }
  })
 
  </script>
  
  
  <style scoped lang="less"></style>
  