|
|
|
@ -23,6 +23,9 @@ |
|
|
|
<i class="iconfont iconpdf"></i>导出pdf |
|
|
|
</el-button> |
|
|
|
</a> |
|
|
|
<el-button type="text" @click="print('gaea_template_pdf')"> |
|
|
|
<i class="iconfont iconpdf"></i>打印 |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
<el-form class=""> |
|
|
|
<h2>表格查询</h2> |
|
|
|
@ -173,6 +176,36 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
async print(val) { |
|
|
|
let extend = '.pdf'; |
|
|
|
const result = {}; |
|
|
|
result["reportCode"] = this.reportCode; |
|
|
|
result["setParam"] = JSON.stringify(this.params.setParam); |
|
|
|
if (val != "") { |
|
|
|
result["exportType"] = val; |
|
|
|
if (val === "gaea_template_pdf") { |
|
|
|
extend = '.pdf'; |
|
|
|
} |
|
|
|
} |
|
|
|
this.getCellStyleData(result); |
|
|
|
exportExcel(result).then(res=>{ |
|
|
|
this.printBlobInIframe(res); |
|
|
|
}) |
|
|
|
}, |
|
|
|
printBlobInIframe(res) { |
|
|
|
const blob = new Blob([res], { type: 'application/pdf' }); |
|
|
|
const pdfUrl = URL.createObjectURL(blob); |
|
|
|
const iframe = document.createElement('iframe'); |
|
|
|
iframe.src = pdfUrl; |
|
|
|
iframe.style.display = 'none'; |
|
|
|
document.body.appendChild(iframe); |
|
|
|
iframe.onload = () => { |
|
|
|
iframe.contentWindow.print(); |
|
|
|
URL.revokeObjectURL(pdfUrl); // 清理资源 |
|
|
|
// document.body.removeChild(iframe); |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
// 表单封装json |
|
|
|
toObject(val) { |
|
|
|
const objfirst = {}; |
|
|
|
@ -234,9 +267,13 @@ export default { |
|
|
|
zoomRatio: 1, // 缩放比例 |
|
|
|
image: [], //图片 |
|
|
|
showGridLines: 1, //是否显示网格线 |
|
|
|
dataVerification: {} //数据验证配置 |
|
|
|
dataVerification: {}, //数据验证配置 |
|
|
|
} |
|
|
|
] |
|
|
|
], |
|
|
|
showtoolbar: true, // 默认就是true,可以不设置 |
|
|
|
showtoolbarConfig:{ |
|
|
|
print: false, |
|
|
|
} |
|
|
|
}; |
|
|
|
options.data = this.sheetData; |
|
|
|
// console.log(this.sheetData) |
|
|
|
|