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