|
@@ -1,20 +1,20 @@
|
|
|
<template>
|
|
|
- <hc-pdf :src="pdfUrl" :download="isDownload" :print="isPrint" />
|
|
|
+ <hc-pdf v-if="isPdfDom" :src="pdfUrl" :download="isDownload" :print="isPrint" />
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref, watch } from 'vue'
|
|
|
+import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
import { btnAuth, decode } from '~uti/btn-auth'
|
|
|
import { isNullES } from 'js-fast-way'
|
|
|
|
|
|
const props = defineProps({
|
|
|
url: {
|
|
|
type: String,
|
|
|
- default: ''
|
|
|
+ default: '',
|
|
|
},
|
|
|
code: {
|
|
|
type: String,
|
|
|
- default: ''
|
|
|
+ default: '',
|
|
|
},
|
|
|
})
|
|
|
|
|
@@ -32,12 +32,16 @@ watch(() => [props.url, props.code], ([url, code]) => {
|
|
|
})
|
|
|
|
|
|
//渲染完成
|
|
|
+const isPdfDom = ref(false)
|
|
|
const isDownload = ref(false)
|
|
|
const isPrint = ref(false)
|
|
|
onMounted(() => {
|
|
|
isDownload.value = btnAuth('measure-pdf-download')
|
|
|
isPrint.value = btnAuth('measure-pdf-print')
|
|
|
setPdfSrcData()
|
|
|
+ nextTick(() => {
|
|
|
+ isPdfDom.value = true
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
//设置PDF地址
|
|
@@ -61,4 +65,9 @@ const setPdfSrcData = () => {
|
|
|
//两个都有的情况下,以code为准
|
|
|
pdfUrl.value = decode(code ?? '')
|
|
|
}
|
|
|
+
|
|
|
+//页面被卸载
|
|
|
+onUnmounted(() => {
|
|
|
+ isPdfDom.value = false
|
|
|
+})
|
|
|
</script>
|