Commit 470036ca authored by dragondean@qq.com's avatar dragondean@qq.com

重新适配订单详情的查看提单

parent a16d9863
...@@ -231,7 +231,7 @@ export function downloadByOrderId(orderId) { ...@@ -231,7 +231,7 @@ export function downloadByOrderId(orderId) {
url: "/shipment/make-bill-of-lading/downloadByOrderId", url: "/shipment/make-bill-of-lading/downloadByOrderId",
method: "get", method: "get",
params: { orderId }, params: { orderId },
responseType: "arraybuffer", /* responseType: "arraybuffer", */
}); });
} }
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
<i class="el-icon-loading" slot="icon" style="font-size: 40px" /> <i class="el-icon-loading" slot="icon" style="font-size: 40px" />
</el-result> </el-result>
<pdf-viewer id="pdfViewer" ref="viewer" v-if="pdfData" :url="pdfData" style="display:block; margin: 0 auto; max-height: 80vh; overflow:auto;" /> <pdf-viewer id="pdfViewer" ref="viewer" v-if="pdfData" :url="pdfData" style="display:block; margin: 0 auto; max-height: 80vh; overflow:auto;" />
<!-- <div v-if="detail" class="billcontent" v-html="detail.billContent"></div> -->
<p class="subs" style="text-align:center"> <p class="subs" style="text-align:center">
<el-button type="primary" @click="download" :disabled="!pdfData">{{$t('下载')}}</el-button> <el-button type="primary" @click="download" :disabled="!detail">{{$t('下载')}}</el-button>
<el-button type="primary" @click="print" :disabled="!pdfData">{{$t('打印')}}</el-button> <el-button type="primary" @click="print" :disabled="!detail">{{$t('打印')}}</el-button>
</p> </p>
</el-dialog> </el-dialog>
</template> </template>
...@@ -17,7 +18,7 @@ import lodop from '@/utils/lodop' ...@@ -17,7 +18,7 @@ import lodop from '@/utils/lodop'
import PdfViewer from '@/components/PdfViewer' import PdfViewer from '@/components/PdfViewer'
import FileSaver from 'file-saver' import FileSaver from 'file-saver'
import {downloadByOrderId} from '@/api/ecw/box' import {downloadByOrderId} from '@/api/ecw/box'
import html2canvas from 'html2canvas'
export default { export default {
components: {PdfViewer}, components: {PdfViewer},
filters: {parseTime}, filters: {parseTime},
...@@ -34,9 +35,19 @@ export default { ...@@ -34,9 +35,19 @@ export default {
billLadingNo: 'TD20220717', billLadingNo: 'TD20220717',
type: 1, */ type: 1, */
pdfData: null, pdfData: null,
detail: null,
loading: false loading: false
} }
}, },
watch:{
detail(){
/* this.pdfData = this.detail.imgUrl */
fetch(this.detail.imgUrl).then(async response => {
console.log(response)
this.pdfData = await response.arrayBuffer()
})
}
},
computed:{ computed:{
title(){ title(){
let t = this.$t('提货单') let t = this.$t('提货单')
...@@ -59,9 +70,9 @@ export default { ...@@ -59,9 +70,9 @@ export default {
loadData(){ loadData(){
this.loading = true this.loading = true
downloadByOrderId(this.orderId) downloadByOrderId(this.orderId)
.then(arrayBuffer => { .then(res => {
console.log({arrayBuffer}) this.detail = res.data
this.pdfData = arrayBuffer /* this.pdfData = arrayBuffer */
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false
...@@ -71,9 +82,10 @@ export default { ...@@ -71,9 +82,10 @@ export default {
this.show = false this.show = false
this.$emit('close'); this.$emit('close');
}, },
download(){ download(){
let blob = new Blob([this.pdfData], {type: "application/pdf"}) let blob = new Blob([this.pdfData], {type: "application/pdf"})
FileSaver.saveAs(blob, this.title + '.pdf'); FileSaver.saveAs(blob, this.title + '.pdf');
}, },
print(){ print(){
lodop().then(LODOP => { lodop().then(LODOP => {
...@@ -82,6 +94,7 @@ export default { ...@@ -82,6 +94,7 @@ export default {
LODOP.SET_PRINT_STYLE("Bold",1); LODOP.SET_PRINT_STYLE("Bold",1);
LODOP.SET_PRINT_PAGESIZE(0); LODOP.SET_PRINT_PAGESIZE(0);
LODOP.SET_PRINT_PAGESIZE(0,2100,2970,"A4"); LODOP.SET_PRINT_PAGESIZE(0,2100,2970,"A4");
// html2canvas(document.querySelector('.billcontent'))
let dataURLs = this.$refs.viewer.getDataURLs() let dataURLs = this.$refs.viewer.getDataURLs()
console.log(dataURLs) console.log(dataURLs)
for(let page in dataURLs){ for(let page in dataURLs){
......
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