pengjun 9 hours ago
parent
commit
3b4082c07b
  1. 91
      src/components/common/PreviewCusGrant.vue

91
src/components/common/PreviewCusGrant.vue

@ -30,9 +30,10 @@
</div>
<div>
<!-- -->
<div style="height: 500px;width: 680px;overflow:auto;" v-show="isShow == 1 ? true : false" v-html="contentShow"
ref="refPreviewCusGrant"></div>
<iframe :src="curRow.src" style="height: 500px;width: 680px;" v-show="isShow == 0 ? true : false" />
<div id="id_div" style="height: 500px;width: 680px;overflow:auto;" v-show="isShow == 1 ? true : false"
v-html="contentShow" ref="refPreviewCusGrant"></div>
<iframe id="id_iframe" :src="curRow.src" style="height: 500px;width: 680px;"
v-show="isShow == 0 ? true : false" />
<div style="display: flex;justify-content: space-between;">
<div></div>
<div style="display: flex;">
@ -81,8 +82,11 @@ export default {
curRow: {
registerCheckId: '',
src: '',
apiurl: 'http://192.168.1.138:9527'
}
apiurl: 'http://192.168.1.138:9527',
type: 0,
},
};
},
@ -110,7 +114,9 @@ export default {
},
//
methods: {
printObj() {
},
getSignData() {
let body = {}
if (this.refParams.registerCheckId) {
@ -133,18 +139,46 @@ export default {
})
},
// imageToBase64(url) {
// return new Promise((resolve, reject) => {
// const img = new Image();
// // CORS
// img.crossOrigin = 'Anonymous';
// img.onload = () => {
// const canvas = document.createElement('canvas');
// canvas.width = img.width;
// canvas.height = img.height;
// const ctx = canvas.getContext('2d');
// ctx.drawImage(img, 0, 0);
// const base64 = canvas.toDataURL('image/png'); // 'image/jpeg'
// resolve(base64);
// };
// img.onerror = reject;
// img.src = url;
// });
// },
rowClick(row) {
this.curRow = Object.assign(this.curRow, row, { src: this.curRow.apiurl + row.informedConsentFile })
this.curRow = Object.assign(this.curRow, row, { type: 0, src: this.curRow.apiurl + row.informedConsentFile })
this.isShow = 0
console.log('this.curRow', this.curRow)
},
rowClick1(row) {
this.curRow = Object.assign(this.curRow, row, { src: this.curRow.apiurl + '/' + row.giveUpCheckSignFile })
this.contentShow = '<h2 style="font-size:32px;text-align:center;"><strong>项目放弃检查申明</strong></h2><p><br></p><p style="font-size:18px;">  本人因个人原因,自愿放弃【${asbitemName}】项目的检查。</p><p><br></p><p><br></p><p><br></p><p style="font-size:18px;"><strong>特此申明!</strong></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p style="font-size:24px;text-align:right;"><strong>弃检人签名:</strong>${signMan}</p><p><br></p><p style="font-size:20px;text-align:right;padding-right:40px;"></p>'
this.curRow = Object.assign(this.curRow, row, { type: 1, src: this.curRow.apiurl + '/' + row.giveUpCheckSignFile })
// this.imageToBase64(this.curRow.src)
// .then(base64 => {
// this.curRow.src = base64
// })
// .finally(() => {
this.contentShow = '<h2 style="font-size:32px;text-align:center;"><strong>项目放弃检查申明</strong></h2><p><br></p><p style="font-size:18px;">  本人因个人原因,自愿放弃【${asbitemName}】项目的检查。</p><p><br></p><p><br></p><p><br></p><p style="font-size:18px;"><strong>特此申明!</strong></p><p><br></p><p><br></p><p><br></p><p style="font-size:24px;text-align:right;"><strong>弃检人签名:</strong>${signMan}</p><p><br></p><p style="font-size:20px;text-align:right;padding-right:40px;"></p>'
this.contentShow = this.contentShow.replace('${signMan}', `<img width="100" height="50" src="${this.curRow.src}">`).replace('${asbitemName}', this.curRow.asbitemName)
this.isShow = 1
console.log('this.curRow', this.curRow)
// })
},
btnInit() {
@ -202,29 +236,38 @@ export default {
this.getSignFileContent()
.then(res => {
let width = 794; // A4
let cloneDom = this.$refs['refPreviewCusGrant'].cloneNode(true);
let imageDom = this.$refs['refPreviewCusGrant'];
cloneDom.style.position = "absolute";
cloneDom.style.top = "0px";
cloneDom.style.zIndex = "-1";
cloneDom.style.width = width;
cloneDom.style.width = "794px"; // A4
cloneDom.style.height = "1100px";
cloneDom.style.padding = "80px 50px";
console.log(cloneDom);
imageDom.appendChild(cloneDom);
html2canvas(cloneDom).then((canvas) => {
//
const url = canvas.toDataURL("image/png");
printJs({
printable: url,
type: "image",
documentTitle: "知情同意书", //
style: `@media print { @page {size: auto; margin: 0 0 0 0; } body{margin:0 5px}canvas{page-break-after: always;page-break-inside: avoid;
page-break-after: avoid;
page-break-before: avoid;}}`, // 去除页眉页脚
console.log('cloneDom', cloneDom.outerHTML);
// if (this.curRow.type == 1) {
// let newWin = window.open('', '_blank');
// newWin.document.write(cloneDom.outerHTML); // HTML innerHTML
// newWin.print(); //
// newWin.close(); //
// } else {
imageDom.appendChild(cloneDom);
html2canvas(cloneDom).then((canvas) => {
//
const url = canvas.toDataURL("image/png");
printJs({
printable: url,
type: "image",
documentTitle: "知情同意书", //
style: `@media print { @page {size: auto; margin: 0 0 0 0; } body{margin:0 5px}canvas{page-break-after: always;page-break-inside: avoid;page-break-after: avoid;page-break-before: avoid;}}`, //
});
});
});
cloneDom.style.display = "none";
cloneDom.style.display = "none";
// }
})
.catch(err => {
console.error('getSignFileContent', err)

Loading…
Cancel
Save