Commit 62ef049c authored by “lixuyan”'s avatar “lixuyan”

查看pdf文件

parent 19d99c23
<template>
<div class="viewPdf">
<div class="cell el-tooltip">
<span class="is-active-text" style="cursor: pointer;" @click="seePdf">{{ form.serialNumber }}</span>
</div>
</div>
</template>
<script>
import { downloadFile } from '@/utils/http'
export default {
name: 'ViewPdf',
componentName: '查看pdf',
props: {
form: {
type: Object,
default: () => null
}
},
data() {
return {
seePdfShow: false
}
},
methods: {
seePdf() {
if (this.form.id) {
if (this.seePdfShow) {
return
}
const notify = this.$notify({
title: '提示',
message: 'PDF正在加载中...,请稍后!',
duration: 0
})
this.seePdfShow = true
downloadFile(`/ExtProcessPlan/createPDF?id=${this.form.id}`, 'get').then(res => {
const blob = new Blob([res.data], {
type: 'application/pdf'
})
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob)
} else {
var openUrl = URL.createObjectURL(blob)
this.seePdfShow = false
notify.close()
window.open(openUrl, '_blank')
}
}).catch((error) => {
console.log(error)
notify.close()
})
} else {
this.$message({
message: '该AO没有PDF',
type: 'warning'
})
}
}
}
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment