Commit fb03287d authored by 李苏's avatar 李苏 💬

多页预览pdf

parent b407e6b5
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
width="100%" width="100%"
> >
<div ref='show' v-if="show" style="height: 85vh;width: 100%"> <div ref='show' v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf> <pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> --> <!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" > <img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div> </div>
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
}, },
data() { data() {
return{ return{
numPages:1,
show:false, show:false,
isupLoad:false, isupLoad:false,
treeTitle: '文档目录', treeTitle: '文档目录',
...@@ -158,6 +159,15 @@ ...@@ -158,6 +159,15 @@
} }
}, },
methods:{ methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */ /* 预览 */
preview(row){ preview(row){
console.log(row) console.log(row)
...@@ -176,6 +186,7 @@ ...@@ -176,6 +186,7 @@
type: 'application/'+row.fileType+';charset=UTF-8', type: 'application/'+row.fileType+';charset=UTF-8',
}); });
this.url=URL.createObjectURL(blob) this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true this.show=true
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
width="100%" width="100%"
> >
<div ref='show' v-if="show" style="height: 85vh;width: 100%"> <div ref='show' v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf> <pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> --> <!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" > <img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div> </div>
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
}, },
data() { data() {
return{ return{
numPages:1,
show:false, show:false,
isupLoad:false, isupLoad:false,
treeTitle: '文档目录', treeTitle: '文档目录',
...@@ -156,6 +157,15 @@ ...@@ -156,6 +157,15 @@
} }
}, },
methods:{ methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */ /* 预览 */
preview(row){ preview(row){
console.log(row) console.log(row)
...@@ -174,6 +184,7 @@ ...@@ -174,6 +184,7 @@
type: 'application/'+row.fileType+';charset=UTF-8', type: 'application/'+row.fileType+';charset=UTF-8',
}); });
this.url=URL.createObjectURL(blob) this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true this.show=true
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
> >
<div v-if="show" style="height: 85vh;width: 100%"> <div v-if="show" style="height: 85vh;width: 100%">
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> --> <!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<pdf ref="show" v-if="showType=='pdf'" :src="url" ></pdf> <pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" > <img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div> </div>
</el-dialog> </el-dialog>
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
}, },
data() { data() {
return{ return{
numPages:1,
show:false, show:false,
isupLoad:false, isupLoad:false,
treeTitle: '目录', treeTitle: '目录',
...@@ -156,6 +157,16 @@ ...@@ -156,6 +157,16 @@
} }
}, },
methods:{ methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */ /* 预览 */
preview(row){ preview(row){
console.log(row) console.log(row)
...@@ -174,6 +185,7 @@ ...@@ -174,6 +185,7 @@
type: 'application/'+row.fileType+';charset=UTF-8', type: 'application/'+row.fileType+';charset=UTF-8',
}); });
this.url=URL.createObjectURL(blob) this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true this.show=true
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
width="100%" width="100%"
> >
<div ref="show" v-if="show" style="height: 85vh;width: 100%"> <div ref="show" v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf> <pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> --> <!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" > <img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div> </div>
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
}, },
data() { data() {
return{ return{
numPages:1,
show:false, show:false,
isupLoad:false, isupLoad:false,
treeTitle: '目录', treeTitle: '目录',
...@@ -158,6 +159,15 @@ ...@@ -158,6 +159,15 @@
} }
}, },
methods:{ methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */ /* 预览 */
preview(row){ preview(row){
console.log(row) console.log(row)
...@@ -176,6 +186,7 @@ ...@@ -176,6 +186,7 @@
type: 'application/'+row.fileType+';charset=UTF-8', type: 'application/'+row.fileType+';charset=UTF-8',
}); });
this.url=URL.createObjectURL(blob) this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true this.show=true
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
width="100%" width="100%"
> >
<div ref='show' v-if="show" style="height: 85vh;width: 100%"> <div ref='show' v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf> <pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> --> <!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" > <img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div> </div>
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
}, },
data() { data() {
return{ return{
numPages:1,
show:false, show:false,
isupLoad:false, isupLoad:false,
treeTitle: '目录', treeTitle: '目录',
...@@ -157,6 +158,15 @@ ...@@ -157,6 +158,15 @@
} }
}, },
methods:{ methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */ /* 预览 */
preview(row){ preview(row){
console.log(row) console.log(row)
...@@ -175,6 +185,7 @@ ...@@ -175,6 +185,7 @@
type: 'application/'+row.fileType+';charset=UTF-8', type: 'application/'+row.fileType+';charset=UTF-8',
}); });
this.url=URL.createObjectURL(blob) this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true this.show=true
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<div v-if="show" style="height: 85vh;width: 100%"> <div v-if="show" style="height: 85vh;width: 100%">
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> --> <!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<pdf ref="show" v-if="showType=='pdf'" :src="url" ></pdf> <pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" > <img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div> </div>
</el-dialog> </el-dialog>
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
}, },
data() { data() {
return{ return{
numPages:1,
show:false, show:false,
isupLoad:false, isupLoad:false,
treeTitle: '目录', treeTitle: '目录',
...@@ -159,6 +160,15 @@ ...@@ -159,6 +160,15 @@
} }
}, },
methods:{ methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */ /* 预览 */
preview(row){ preview(row){
console.log(row) console.log(row)
...@@ -177,6 +187,7 @@ ...@@ -177,6 +187,7 @@
type: 'application/'+row.fileType+';charset=UTF-8', type: 'application/'+row.fileType+';charset=UTF-8',
}); });
this.url=URL.createObjectURL(blob) this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true this.show=true
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
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