|
@@ -0,0 +1,64 @@
|
|
|
+<template>
|
|
|
+ <hc-pdf :src="pdfUrl" :download="isDownload" :print="isPrint" />
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { isNullES } from 'js-fast-way'
|
|
|
+import {onMounted, ref, watch} from 'vue'
|
|
|
+import { btnAuth, decode } from '~uti/btn-auth'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ url: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ code: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+defineOptions({
|
|
|
+ name: 'HcPdfs',
|
|
|
+})
|
|
|
+
|
|
|
+//监听
|
|
|
+const queryUrl = ref(props.url)
|
|
|
+const queryCode = ref(props.code)
|
|
|
+watch(() => [props.url, props.code], ([url, code]) => {
|
|
|
+ queryUrl.value = url
|
|
|
+ queryCode.value = code
|
|
|
+ setPdfSrcData()
|
|
|
+})
|
|
|
+
|
|
|
+//渲染完成
|
|
|
+const isDownload = ref(false)
|
|
|
+const isPrint = ref(false)
|
|
|
+onMounted(() => {
|
|
|
+ isDownload.value = btnAuth('archives-pdf-download')
|
|
|
+ isPrint.value = btnAuth('archives-pdf-print')
|
|
|
+ setPdfSrcData()
|
|
|
+})
|
|
|
+
|
|
|
+//设置PDF地址
|
|
|
+const pdfUrl = ref('')
|
|
|
+const setPdfSrcData = () => {
|
|
|
+ const url = queryUrl.value, code = queryCode.value
|
|
|
+ //如果url和code都为空,不做处理
|
|
|
+ if (isNullES(url) && isNullES(code)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果url不为空,code为空,以url为准
|
|
|
+ if (!isNullES(url) && isNullES(code)) {
|
|
|
+ pdfUrl.value = url
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果url为空,code不为空,以code为准
|
|
|
+ if (isNullES(url) && !isNullES(code)) {
|
|
|
+ pdfUrl.value = decode(code ?? '')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //两个都有的情况下,以code为准
|
|
|
+ pdfUrl.value = decode(code ?? '')
|
|
|
+}
|
|
|
+</script>
|