Commit 10e0337b authored by dragondean@qq.com's avatar dragondean@qq.com

已审核提单增加刷新按钮

parent a1427266
...@@ -49,6 +49,8 @@ import { getToken } from "@/utils/auth"; ...@@ -49,6 +49,8 @@ import { getToken } from "@/utils/auth";
import html2canvas from 'html2canvas'; import html2canvas from 'html2canvas';
import { jsPDF } from "jspdf"; import { jsPDF } from "jspdf";
import {uploadFile} from '@/api/infra/file' import {uploadFile} from '@/api/infra/file'
import FileSaver from 'file-saver'
window.html2canvas = html2canvas
export default { export default {
name: "makeLadingBill", name: "makeLadingBill",
components: { components: {
...@@ -194,6 +196,10 @@ export default { ...@@ -194,6 +196,10 @@ export default {
let file = this.selfNo + '-' + this.currRow.tidanNo + '.pdf' let file = this.selfNo + '-' + this.currRow.tidanNo + '.pdf'
form.append('file', new File([doc.output('arraybuffer')], file, {type: 'application/pdf'})) form.append('file', new File([doc.output('arraybuffer')], file, {type: 'application/pdf'}))
form.append('path', file) form.append('path', file)
/* let blob = new Blob([doc.output('arraybuffer')], {type: "application/pdf"})
FileSaver.saveAs(blob, file);
return */
return uploadFile(form) return uploadFile(form)
}).then(res => { }).then(res => {
return this.submit(res.data) return this.submit(res.data)
......
<template> <template>
<el-row> <el-row>
<div v-html="contentHtml" class="contentHtml"></div> <div v-html="contentHtml" id="html2canvas-container" class="contentHtml"></div>
<el-row v-if="currRow.status === 2 && type === 'previewBill'" style="text-align: center;"> <el-row v-if="currRow.status === 2 && type === 'previewBill'" style="text-align: center;">
<el-button type="primary" @click="download">{{$t('下载')}}</el-button> <el-button type="primary" @click="download">{{$t('下载')}}</el-button>
<el-button type="primary" @click="print">{{$t('打印')}}</el-button> <el-button type="primary" @click="print">{{$t('打印')}}</el-button>
<el-button type="primary" @click="createPdf">{{$t('刷新')}}</el-button>
</el-row> </el-row>
</el-row> </el-row>
</template> </template>
...@@ -12,6 +13,9 @@ ...@@ -12,6 +13,9 @@
import lodop from "@/utils/lodop"; import lodop from "@/utils/lodop";
import * as _BOX from "@/api/ecw/box"; import * as _BOX from "@/api/ecw/box";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import html2canvas from 'html2canvas';
import { jsPDF } from "jspdf";
import {uploadFile} from '@/api/infra/file'
export default { export default {
name: "previewBill", name: "previewBill",
...@@ -28,6 +32,34 @@ export default { ...@@ -28,6 +32,34 @@ export default {
} }
}); });
}, },
createPdf(){
let loading = this.$loading()
const doc = new jsPDF('p','pt','a4',true);
html2canvas(document.querySelector("#html2canvas-container"), {dpi:144, useCORS: true}).then(canvas => {
const imgWidth = canvas.width
const imgHeight = canvas.height
let _w = 595.28;
let _h = 595.28/imgWidth*imgHeight;
if(_h>841.89){
_h = 841.89;
_w = _h/imgHeight*imgWidth
}
const _left = (595.28-_w)/2;
doc.addImage(canvas, 'PNG', _left, 0, _w,_h, '', 'FAST');
return _BOX["downloadBillService"]({ id: this.currRow.id })
}).then(res => {
let form = new FormData()
let file = (new URL(res.data.imgUrl)).pathname.replace(/^(\/)[a-zA-Z0-9]/, '') // 替换掉最前面的/
form.append('file', new File([doc.output('arraybuffer')], file, {type: 'application/pdf'}))
form.append('path', file)
return uploadFile(form)
}).finally(res => {
loading.close()
})
},
print() { print() {
lodop() lodop()
.then((LODOP) => { .then((LODOP) => {
......
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