<template>
  <span @click.stop="restart"
    ><slot></slot>
    <LaunchProcess
      v-if="visible"
      :schemaId="schemaId"
      :taskId="taskId"
      :processId="processId"
      @close="close"
    />
  </span>
</template>

<script setup lang="ts">
  import { ref } from 'vue';
  import LaunchProcess from './LaunchProcess.vue';
  const props = defineProps({
    schemaId: {
      type: String,
      required: true,
    },
    taskId: {
      type: String,
    },
    processId: {
      type: String,
    },
  });

  let emits = defineEmits(['close']);
  let visible = ref(false);
  function restart() {
    if (props.taskId) {
      visible.value = true;
    } else {
      // 只能选一个
      visible.value = false;
    }
  }
  function close() {
    visible.value = false;
    emits('close');
  }
</script>
