页面打印pdf格式文件
'<td><button type="button" class="btn btn-primary" data-loading-text="Loading..." onclick="printReports(\'' + task_ids + '\')">打印</button></td>'
function printReports(task_ids) { $.ajax({ url:"webVisual/printReport/admin/" + task_ids, async:false, dataTyoe:"json", success:function(json){ var printEntity = json.data; var poiIdsss = printEntity.poiIds; var oPop = window.open('','oPop'); var str = '<!DOCTYPE html>'; str +='<html>'; str +='<head>'; str +='<meta charset="utf-8">'; str += '<title>爬取错误poi打印</title>'; str +='</head>'; str +='<body>'; str += '<table border="1px" cellspacing="0" width="100%" align="center">'; str += '<tr>'+ '<th colspan="3">爬取错误poi打印</th>' '</tr>'; str += '<tr>'+ '<th>任务名</th>' + '<th>来源</th>' + '<th>总数</th>' + '</tr>'; str += '<tr>'+ '<td align="center">' + printEntity.taskName + '</td>' + '<td align="center">' + printEntity.source + '</td>' + '<td align="center">' + printEntity.geoNums.length + '</td>' + '</tr>'; $(printEntity.geoNums).each(function(index_num, errorGeoNum) { str += '<tr>'+ '<th align="center">网格编码: ' + errorGeoNum.geo_num + '</th>' + '<th align="center">创建时间: ' + errorGeoNum.create_time + '</th>' + '<td align="center">总计: ' + errorGeoNum.poi_ids.length + '</td>' + '</tr>'; $(errorGeoNum.poi_ids).each(function(num_index, errorPoi) { str += '<tr>'+ '<td align="center">(' + (num_index+1) + ')</td>' + '<td align="center" colspan="2">' + errorPoi + '</td>' + '</tr>'; }) }) str +='</table>'; str += '</body>' + '</html>'; oPop.document.write(str); oPop.print(); oPop.close(); } }); }