@@ -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 = '
项目放弃检查申明
本人因个人原因,自愿放弃【${asbitemName}】项目的检查。
特此申明!
弃检人签名:${signMan}
'
+ 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 = '
项目放弃检查申明
本人因个人原因,自愿放弃【${asbitemName}】项目的检查。
特此申明!
弃检人签名:${signMan}
'
this.contentShow = this.contentShow.replace('${signMan}', `

`).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)