<template>
  <a-spin :spinning="spinning" :delay="delayTime">
    <ViewerHome v-if="data.visible" :content="data.content" />
  </a-spin>
</template>

<script setup lang="ts">
  import { onMounted, reactive, ref, unref } from 'vue';
  import ViewerHome from './../viewer/components/Viewer.vue';
  import { useRouter } from 'vue-router';
  import { getProfessionalInfo } from '/@/api/system/report';

  const { currentRoute } = useRouter();
  const spinning = ref<boolean>(true);
  const delayTime = 500;
  const data = reactive({ visible: false, content: '' });
  onMounted(async () => {
    try {
      const { path } = unref(currentRoute);
      let paths = path.split('/');
      let id = paths.length > 0 ? paths[paths.length - 1] : '';
      if (id) {
        let res = await getProfessionalInfo(id);
        data.content = res.fileJson;
        data.visible = true;
      }
      spinning.value = false;
    } catch (error) {
      console.log('error: ', error);
      spinning.value = false;
    }
  });
</script>

<style scoped></style>
