<!-- 弹窗查看流程信息 -->
<script setup lang="ts">
import type { TaskInfo } from '#/api/workflow/task/model';

import { ref } from 'vue';

import { useVbenDrawer } from '@vben/common-ui';



import { getTaskByBusinessId } from '#/api/workflow/instance';

import { ApprovalPanel } from '.';

interface ModalProps {
  businessId: string;
}

const taskInfo = ref<TaskInfo>();

const [BasicDrawer, drawerApi] = useVbenDrawer({
  title: '流程信息',
  class: 'w-[1000px]',
  footer: false,
  onClosed: () => {
    taskInfo.value = undefined;
  },
  onOpenChange: async (isOpen) => {
    if (!isOpen) {
      return null;
    }
    const { businessId } = drawerApi.getData() as ModalProps;
    const taskResp = await getTaskByBusinessId(businessId);
    taskInfo.value = taskResp;
  },
});
</script>

<template>
  <BasicDrawer>
    <ApprovalPanel :task="taskInfo" type="readonly">
      <template #empty>
        <el-spin
          class="flex h-[200px] w-full items-center justify-center"
          size="large"
        />
      </template>
    </ApprovalPanel>
  </BasicDrawer>
</template>
