Commit 5fd11876 authored by 何波's avatar 何波

打印

parent d3eed6cf
......@@ -1204,6 +1204,7 @@
</div>
</body>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<script>
function onAccount(number){
if(number == 1){
......@@ -1421,27 +1422,40 @@ function downloadTXT(data) {
var content = data.map(row => row.join('\t')).join('\n');
downloadFile(content, '活期账户列表下载.txt', 'text/plain');
}
function downloadExcel(data) {
var html = `
<table border="1">
${data.map(row =>
`<tr>${row.map(cell => `<td>${cell}</td>`).join('')}</tr>`
).join('')}
</table>
`;
downloadFile(html, '活期账户列表下载.xls', 'application/vnd.ms-excel');
}
function downloadCSV(data) {
var content = data.map(row => row.join(',')).join('\n');
downloadFile(content, '活期账户列表下载.csv', 'text/csv');
}
function downloadPDF(data) {
var win = window.open('', '_blank');
var html = `
<html>
<head><title>PDF</title></head>
<body>
<table border="1" cellspacing="0" cellpadding="5">
var container = document.createElement('div');
container.innerHTML = `
<h3 style="text-align:center;">活期账户列表</h3>
<table border="1" cellspacing="0" cellpadding="5" style="width:100%;border-collapse:collapse;">
${data.map(row =>
`<tr>${row.map(cell => `<td>${cell}</td>`).join('')}</tr>`
).join('')}
</table>
</body>
</html>
`;
win.document.write(html);
win.document.close();
win.print();
html2pdf()
.set({
margin: 10,
filename: '活期账户列表下载.pdf',
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'landscape' }
})
.from(container)
.save();
}
function printPage(type) {
......
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