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> ></pdf>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button v-if="showDownLoad && !loadingPDF" type="success" @click="downLoad"> </el-button>
<el-button @click="close"> </el-button> <el-button @click="close"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -44,14 +45,25 @@ export default {
} }
}, },
props: { props: {
// data:application/pdf;base64,
urlPDF: { urlPDF: {
type: String, type: String,
default: '', default: '',
}, },
// base64data:application/pdf;base64,
base64PDF:{
type: String,
default: '',
},
title: { title: {
type: String, type: String,
default: '', default: '',
}, },
//
showDownLoad: {
type: Boolean,
default: false
},
isShowPDF: { isShowPDF: {
type: Boolean, type: Boolean,
default: false default: false
@ -76,6 +88,30 @@ export default {
}, },
close(){ close(){
this.$emit('closePDF') 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: "massDefect" },
{ label: "到货日期", prop: "arriveDate",type: "dateTime" }, { label: "到货日期", prop: "arriveDate",type: "dateTime" },
{ label: "过期时间", prop: "expireDate",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: "creationTime",type: "dateTime" },
{ label: "上次修改时间", prop: 'lastModificationTime', type: "dateTime" }, { label: "上次修改时间", prop: 'lastModificationTime', type: "dateTime" },
{ label: "订单号", prop: "poNumber" }, { label: "订单号", prop: "poNumber" },

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

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

Loading…
Cancel
Save