<!-- 文件预览组件 -->
<script lang="ts" setup name="FilePreview">
import VuePdfEmbed from 'vue-pdf-embed'
import * as pdfjsLib from 'pdfjs-dist'
import { getPhotoUrl } from '@/api/file'
// 打印文件url
const props = defineProps({
  printFileName: {
    type: String,
    require: true,
  },
})
const pdfUrl = ref('')

/**
 * 初始化审批弹窗
 * @param printFileName 文件名
 */
function init() {
  getPhotoUrl(props.printFileName!).then((res) => {
    pdfUrl.value = res.data
    pdfjsLib.GlobalWorkerOptions.workerSrc = '/pdf.worker.js'
  })
}

onMounted(() => {
  init()
})
</script>

<template>
  <!-- pdf预览 -->
  <vue-pdf-embed ref="pdf" :source="pdfUrl" class="vue-pdf-embed" />
</template>

<style lang="scss" scoped>
// 样式
</style>
