Commit c6135f30 authored by “lixuyan”'s avatar “lixuyan”

添加pdf下载

parent 7ed6b266
<template> <template>
<div class="task-detail-basicInfo-com"> <div class="task-detail-basicInfo-com">
<div class="download-btn">
<el-button
type="primary"
size="small"
@click="seePdf"
>下载pdf</el-button>
</div>
<div v-if="loading" class="detail-com"> <div v-if="loading" class="detail-com">
<dee-as-com <dee-as-com
:key="layConfig.typeName" :key="layConfig.typeName"
...@@ -11,6 +18,7 @@ ...@@ -11,6 +18,7 @@
</template> </template>
<script> <script>
import { downloadFile } from '@/utils/http'
import { post } from '@/utils/http' import { post } from '@/utils/http'
export default { export default {
name: 'AoProcessDetail', name: 'AoProcessDetail',
...@@ -26,7 +34,8 @@ export default { ...@@ -26,7 +34,8 @@ export default {
data() { data() {
return { return {
aoData: {}, aoData: {},
loading: false loading: false,
seePdfShow: false
} }
}, },
computed: { computed: {
...@@ -41,6 +50,41 @@ export default { ...@@ -41,6 +50,41 @@ export default {
this.getData() this.getData()
}, },
methods: { methods: {
seePdf() {
if (this.basicData.id) {
if (this.seePdfShow) {
return
}
const notify = this.$notify({
title: '提示',
message: 'PDF正在加载中...,请稍后!',
duration: 0
})
this.seePdfShow = true
downloadFile(`/ExtProcessPlan/createPDF?id=${this.basicData.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()
this.seePdfShow = false
})
} else {
this.$message({
message: '该AO没有PDF',
type: 'warning'
})
}
},
getData() { getData() {
const params = { const params = {
'searchItems': { 'searchItems': {
......
<template> <template>
<div class="task-detail-basicInfo-com"> <div class="task-detail-basicInfo-com">
<div class="download-btn" @click="seePdf"> <div class="download-btn">
<el-button <el-button
type="primary" type="primary"
plain
size="small" size="small"
@click="seePdf"
>下载pdf</el-button> >下载pdf</el-button>
</div> </div>
<div v-if="loading" class="detail-com"> <div v-if="loading" class="detail-com">
...@@ -51,7 +51,6 @@ export default { ...@@ -51,7 +51,6 @@ export default {
}, },
methods: { methods: {
seePdf() { seePdf() {
console.log(343434)
if (this.basicData.id) { if (this.basicData.id) {
if (this.seePdfShow) { if (this.seePdfShow) {
return return
......
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