Newer
Older
xc-metering-front / src / views / tested / MeasurementBusiness / review / components / fileView.vue
liyaguang on 27 Sep 2023 834 bytes feat(*): 文件流预览打印功能
<!-- 文件预览组件 -->
<script lang="ts" setup name="FilePreview">
import VuePdfEmbed from 'vue-pdf-embed'
import * as pdfjsLib from 'pdfjs-dist'
// import { getPhotoUrl } from '@/api/file'
import { printPage } from '@/api/eqpt/MeasurementBusiness/review'
// 打印文件url
const props = defineProps({
  id: {
    type: String,
    require: true,
  },
})
const pdfUrl = ref('')
/**
 * 初始化审批弹窗
 * @param printFileName 文件名
 */
function init() {
  printPage({ id: props.id, pdf: true }).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>