|
@@ -1,5 +1,13 @@
|
|
|
<template>
|
|
|
- <hc-pdf v-if="isPdfDom" :src="pdfUrl" :download="isDownload" :print="isPrint" :is-https="isHttps" :file-name="fileName" />
|
|
|
+ <hc-pdf
|
|
|
+ v-if="isPdfDom"
|
|
|
+ :src="pdfUrl"
|
|
|
+ :download="isDownload"
|
|
|
+ :print="isPrint"
|
|
|
+ :is-https="isHttps"
|
|
|
+ :file-name="fileName"
|
|
|
+ @download-click="handleDownloadClick"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
@@ -7,6 +15,8 @@ import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
import { btnAuth, decode } from '~uti/btn-auth'
|
|
|
import { isNullES } from 'js-fast-way'
|
|
|
import website from '~src/config'
|
|
|
+import { downloadBlob } from 'js-fast-way'
|
|
|
+import queryApi from '~api/data-fill/query'
|
|
|
|
|
|
const props = defineProps({
|
|
|
url: {
|
|
@@ -21,6 +31,10 @@ const props = defineProps({
|
|
|
type: String,
|
|
|
default: '',
|
|
|
},
|
|
|
+ pdfId: {
|
|
|
+ type: [String, Number],
|
|
|
+ default: '',
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
defineOptions({
|
|
@@ -31,11 +45,13 @@ defineOptions({
|
|
|
const queryUrl = ref(props.url)
|
|
|
const queryCode = ref(props.code)
|
|
|
const fileName = ref(props.fileName)
|
|
|
-watch(() => [props.url, props.code, props.fileName], ([url, code, name]) => {
|
|
|
+const pdfId = ref(props.pdfId)
|
|
|
+watch(() => [props.url, props.code, props.fileName, props.pdfId], ([url, code, name, idVal]) => {
|
|
|
|
|
|
queryUrl.value = url
|
|
|
queryCode.value = code
|
|
|
fileName.value = name
|
|
|
+ pdfId.value = idVal
|
|
|
setPdfSrcData()
|
|
|
})
|
|
|
|
|
@@ -80,4 +96,21 @@ const setPdfSrcData = () => {
|
|
|
onUnmounted(() => {
|
|
|
isPdfDom.value = false
|
|
|
})
|
|
|
+
|
|
|
+//下载按钮点击
|
|
|
+const downLoadTemplateLoading = ref(false)
|
|
|
+const handleDownloadClick = async ()=>{
|
|
|
+
|
|
|
+
|
|
|
+ downLoadTemplateLoading.value = true
|
|
|
+ const { error, disposition, res, msg } = await queryApi.downBussPdf({ id: pdfId.value })
|
|
|
+ downLoadTemplateLoading.value = false
|
|
|
+ if (!error) {
|
|
|
+ if (disposition) {
|
|
|
+ downloadBlob(res, disposition)
|
|
|
+ } else {
|
|
|
+ window.$message?.error(msg || '数据异常')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|