|
@@ -2,13 +2,14 @@ import dialog from '@/utils/dialog'
|
|
|
import Pdfh5 from "pdfh5";
|
|
import Pdfh5 from "pdfh5";
|
|
|
import "pdfh5/css/pdfh5.css";
|
|
import "pdfh5/css/pdfh5.css";
|
|
|
import { snapshoot } from '@/api/platform/file/attachment' //印章,快照
|
|
import { snapshoot } from '@/api/platform/file/attachment' //印章,快照
|
|
|
|
|
+import { download } from '@/api/platform/file/attachment'
|
|
|
|
|
+import ActionUtils from '@/utils/action'
|
|
|
|
|
|
|
|
const getPint = (tableForm, srcUrl) => {
|
|
const getPint = (tableForm, srcUrl) => {
|
|
|
var flag = true;
|
|
var flag = true;
|
|
|
if (/Mobi|Android|iPhone|iPad/i.test(navigator.userAgent)) {
|
|
if (/Mobi|Android|iPhone|iPad/i.test(navigator.userAgent)) {
|
|
|
flag = false
|
|
flag = false
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if (flag) {
|
|
if (flag) {
|
|
|
dialog(
|
|
dialog(
|
|
|
{
|
|
{
|
|
@@ -48,48 +49,76 @@ const getPint = (tableForm, srcUrl) => {
|
|
|
return {
|
|
return {
|
|
|
readonly: false,
|
|
readonly: false,
|
|
|
data: '',
|
|
data: '',
|
|
|
- pdfh5: null
|
|
|
|
|
|
|
+ pdfh5: null,
|
|
|
|
|
+ name: '',
|
|
|
|
|
+ url: ``
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.getYab()
|
|
this.getYab()
|
|
|
- this.getMet()
|
|
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- getYab(){
|
|
|
|
|
|
|
+ getYab() {
|
|
|
let srcUrl1 = srcUrl.split('rpx=')[1]
|
|
let srcUrl1 = srcUrl.split('rpx=')[1]
|
|
|
let srcUrlList = srcUrl1.split('.rpx&id_=')
|
|
let srcUrlList = srcUrl1.split('.rpx&id_=')
|
|
|
let name = srcUrlList[0].split('/')
|
|
let name = srcUrlList[0].split('/')
|
|
|
|
|
|
|
|
- let url = tableForm.$getReportFile(srcUrlList[0], `id_=${ srcUrlList[1] }`)
|
|
|
|
|
- console.log(url)
|
|
|
|
|
|
|
+ let url = tableForm.$getReportFile(srcUrlList[0], `id_=${srcUrlList[1]}`)
|
|
|
|
|
+ this.name = name[name.length - 1] + '.pdf'
|
|
|
let params = {
|
|
let params = {
|
|
|
url: url,
|
|
url: url,
|
|
|
name: name[name.length - 1] || '暂无',
|
|
name: name[name.length - 1] || '暂无',
|
|
|
type: 'pdf'
|
|
type: 'pdf'
|
|
|
}
|
|
}
|
|
|
snapshoot(params).then(res => {
|
|
snapshoot(params).then(res => {
|
|
|
- if(res.state == 200){
|
|
|
|
|
|
|
+ if (res.state == 200) {
|
|
|
const data = res.data
|
|
const data = res.data
|
|
|
- this.getMet(data.filePath)
|
|
|
|
|
|
|
+ this.getDownload(data.id)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ getDownload(id) {
|
|
|
|
|
+ download({
|
|
|
|
|
+ attachmentId: id
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ this.getMet(res.data)
|
|
|
|
|
+ this.url = res.data
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
getMet(url) {
|
|
getMet(url) {
|
|
|
let that = this
|
|
let that = this
|
|
|
// //实例化1
|
|
// //实例化1
|
|
|
that.$nextTick(() => {
|
|
that.$nextTick(() => {
|
|
|
that.pdfh5 = new Pdfh5("#demo", {
|
|
that.pdfh5 = new Pdfh5("#demo", {
|
|
|
- pdfurl: window.location.origin + '/'+url,
|
|
|
|
|
- lazy: true
|
|
|
|
|
|
|
+ // pdfurl: window.location.origin + '/' + url,
|
|
|
|
|
+ data: url,
|
|
|
|
|
+ // lazy: true
|
|
|
})
|
|
})
|
|
|
that.pdfh5.on("complete", function (status, msg, time) {
|
|
that.pdfh5.on("complete", function (status, msg, time) {
|
|
|
// console.log(status, msg, time)
|
|
// console.log(status, msg, time)
|
|
|
})
|
|
})
|
|
|
});
|
|
});
|
|
|
|
|
+ },
|
|
|
|
|
+ finish() {
|
|
|
|
|
+ this.visible = false
|
|
|
|
|
+ tableForm.dialogTemplate = null
|
|
|
|
|
+ },
|
|
|
|
|
+ xiazan() {
|
|
|
|
|
+ ActionUtils.exportFile(
|
|
|
|
|
+ this.url,
|
|
|
|
|
+ this.name
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- template: '<div style="height:100%"><div id="demo"></div></div>'
|
|
|
|
|
|
|
+ template:
|
|
|
|
|
+ `<div style="height:100%">
|
|
|
|
|
+ <div id="demo"></div>
|
|
|
|
|
+ <div style="position:absolute;right: 17px;top: 15px;" >
|
|
|
|
|
+ <i class="el-icon-download" style="font-size: 24px;margin-right:15px" @click="xiazan"></i>
|
|
|
|
|
+ <i class="el-icon-close" style="font-size: 24px;" @click="finish"></i>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>`
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
dialog: {
|
|
dialog: {
|
|
@@ -102,15 +131,6 @@ const getPint = (tableForm, srcUrl) => {
|
|
|
}
|
|
}
|
|
|
}, (tpl) => {
|
|
}, (tpl) => {
|
|
|
tableForm.dialogTemplate = tpl
|
|
tableForm.dialogTemplate = tpl
|
|
|
- setTimeout(() => {
|
|
|
|
|
-
|
|
|
|
|
- }, 2000);
|
|
|
|
|
- //监听完成事件
|
|
|
|
|
- // this.pdfh5.on("complete", function (status, msg, time) {
|
|
|
|
|
- // })
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
).catch((_this) => {
|
|
).catch((_this) => {
|
|
|
_this.visible = false
|
|
_this.visible = false
|
|
@@ -119,6 +139,4 @@ const getPint = (tableForm, srcUrl) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
export default getPint
|
|
export default getPint
|