<template>
  <div class="temp">
    <ReportView
      v-if="reportFileId"
      type="approve"
      :reportFileId="reportFileId"
      :reportUuid="reportUuid"
    />
    <div v-else>暂无报告</div>
  </div>
</template>

<script lang="ts" setup>
import { computed } from 'vue';
import ReportView from '@/components/common/report/reportView.vue';

interface Props {
  data: any;
}

const props = withDefaults(defineProps<Props>(), {
  data: {},
});

// fileId
const reportFileId = computed(() => {
  try {
    if (!props.data.approveContents) return '';
    const parsed = JSON.parse(props.data.approveContents);
    if (!parsed.reportTemplate) return '';
    const template = JSON.parse(parsed.reportTemplate);
    return template.fileId || '';
  } catch {
    return 0;
  }
});

// uuid
const reportUuid = computed(() => {
  try {
    if (!props.data.approveContents) return '';
    const parsed = JSON.parse(props.data.approveContents);
    return parsed.reportUuid || '';
  } catch {
    return '';
  }
});
</script>

<style lang="scss" scoped>
.temp {
  width: 100%;
  height: 100%;
}
</style>
