Browse Source

照片预览+pdf预览,组件封装修改

faster_develop
安虹睿 2 years ago
parent
commit
5a8aa7f9ae
  1. 36
      fe/PC/src/components/pdf/index.vue
  2. 2
      fe/PC/src/utils/tableColumns/index.js
  3. 5
      fe/PC/src/views/rawMaterialManage/quality/InspectRequest.vue

36
fe/PC/src/components/pdf/index.vue

@ -22,6 +22,7 @@
></pdf>
</div>
<span slot="footer" class="dialog-footer">
<el-button v-if="showDownLoad && !loadingPDF" type="success" @click="downLoad"> </el-button>
<el-button @click="close"> </el-button>
</span>
</el-dialog>
@ -44,14 +45,25 @@ export default {
}
},
props: {
// data:application/pdf;base64,
urlPDF: {
type: String,
default: '',
},
// base64data:application/pdf;base64,
base64PDF:{
type: String,
default: '',
},
title: {
type: String,
default: '',
},
//
showDownLoad: {
type: Boolean,
default: false
},
isShowPDF: {
type: Boolean,
default: false
@ -76,6 +88,30 @@ export default {
},
close(){
this.$emit('closePDF')
},
// base64
base64ToArrayBuffer (base64) {
var binaryString = window.atob(base64)
var binaryLen = binaryString.length
var bytes = new Uint8Array(binaryLen)
for (var i = 0; i < binaryLen; i++) {
var ascii = binaryString.charCodeAt(i)
bytes[i] = ascii
}
return bytes
},
downLoad(){
console.log(this.base64PDF)
let byte = this.base64ToArrayBuffer(this.base64PDF)
const link = document.createElement('a') // a
const blob = new Blob([byte], {
type: 'application/vnd.ms-excel;charset=utf-8',
}) // response
const objectUrl = URL.createObjectURL(blob)
link.href = objectUrl
link.download = this.title
link.click() //
URL.revokeObjectURL(objectUrl)
}
}
}

2
fe/PC/src/utils/tableColumns/index.js

@ -1261,7 +1261,7 @@ export const unqualifiedInfo = [
{ label: "质量缺陷", prop: "massDefect" },
{ label: "到货日期", prop: "arriveDate",type: "dateTime" },
{ label: "过期时间", prop: "expireDate",type: "dateTime" },
{ label:"查看照片",type:"button", fixed: "right",tableAlign:"center",tableHeaderAlign:"center" },
{ label:"查看照片",prop: 'inspectPhotoJson',type:"button", fixed: "right",tableAlign:"center",tableHeaderAlign:"center" },
{ label: "创建时间", prop: "creationTime",type: "dateTime" },
{ label: "上次修改时间", prop: 'lastModificationTime', type: "dateTime" },
{ label: "订单号", prop: "poNumber" },

5
fe/PC/src/views/rawMaterialManage/quality/InspectRequest.vue

@ -213,11 +213,13 @@
</el-dialog>
<pdf
:urlPDF="urlPDF"
:base64PDF="base64PDF"
:title="titlePDF"
v-if="isShowPDF"
:isShowPDF="isShowPDF"
:loadingPDF="loadingPDF"
@closePDF="closePDF"
:showDownLoad="true"
></pdf>
</div>
@ -267,6 +269,8 @@ export default {
rowId: '',
// pdf
urlPDF: '',
// base64data:application/pdf;base64,
base64PDF:'',
// titlePDF
titlePDF: '',
//
@ -531,6 +535,7 @@ export default {
this.loadingPDF = true
getFilestore({blobName:_file_id}).then(res=>{
this.urlPDF = 'data:application/pdf;base64,'+res.bytes
this.base64PDF=res.bytes
this.titlePDF = res.fileName
this.loadingPDF = false
}).catch(res=>{

Loading…
Cancel
Save