增加4张报表的打印功能
This commit is contained in:
21
src/main/webapp/js/print/print.html
Normal file
21
src/main/webapp/js/print/print.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>数据打印</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body{background:white;margin:0px;padding:0px;font-size:13px;text-align:left;}
|
||||||
|
.div-title{font-size: 16pt;}
|
||||||
|
.div-time{font-size: 11pt;}
|
||||||
|
.pb{font-size:13px;border-collapse:collapse;}
|
||||||
|
.pb th{font-weight:bold;text-align:center;border:1px solid #333333;padding:2px;}
|
||||||
|
.pb td{border:1px solid #333333;padding:2px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var tableString = localStorage.getItem("tableString");
|
||||||
|
document.write(tableString);
|
||||||
|
window.print();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
79
src/main/webapp/js/print/print.js
Normal file
79
src/main/webapp/js/print/print.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// strPrintName 打印任务名
|
||||||
|
// printDatagrid 要打印的datagrid
|
||||||
|
function CreateFormPage(strPrintName, printDatagrid) {
|
||||||
|
var beginDate= $("#searchBeginTime").val();
|
||||||
|
var endDate= $("#searchEndTime").val();
|
||||||
|
var tableString = '<div class="div-title">上海某某某某有限责任公司\n</div>' +
|
||||||
|
'\n<div class="div-time">日期:' + beginDate + ' 至 ' + endDate + ' \n</div>' +
|
||||||
|
'\n<table cellspacing="0" class="pb">';
|
||||||
|
var frozenColumns = printDatagrid.datagrid("options").frozenColumns; // 得到frozenColumns对象
|
||||||
|
var columns = printDatagrid.datagrid("options").columns; // 得到columns对象
|
||||||
|
var nameList = '';
|
||||||
|
|
||||||
|
// 载入title
|
||||||
|
if (typeof columns != 'undefined' && columns != '') {
|
||||||
|
$(columns).each(function (index) {
|
||||||
|
tableString += '\n<tr>';
|
||||||
|
if (typeof frozenColumns != 'undefined' && typeof frozenColumns[index] != 'undefined') {
|
||||||
|
for (var i = 0; i < frozenColumns[index].length; ++i) {
|
||||||
|
if (!frozenColumns[index][i].hidden) {
|
||||||
|
tableString += '\n<th width="' + frozenColumns[index][i].width + '"';
|
||||||
|
if (typeof frozenColumns[index][i].rowspan != 'undefined' && frozenColumns[index][i].rowspan > 1) {
|
||||||
|
tableString += ' rowspan="' + frozenColumns[index][i].rowspan + '"';
|
||||||
|
}
|
||||||
|
if (typeof frozenColumns[index][i].colspan != 'undefined' && frozenColumns[index][i].colspan > 1) {
|
||||||
|
tableString += ' colspan="' + frozenColumns[index][i].colspan + '"';
|
||||||
|
}
|
||||||
|
if (typeof frozenColumns[index][i].field != 'undefined' && frozenColumns[index][i].field != '') {
|
||||||
|
nameList += ',{"f":"' + frozenColumns[index][i].field + '", "a":"' + frozenColumns[index][i].align + '"}';
|
||||||
|
}
|
||||||
|
tableString += '>' + frozenColumns[0][i].title + '</th>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i = 0; i < columns[index].length; ++i) {
|
||||||
|
if (!columns[index][i].hidden) {
|
||||||
|
tableString += '\n<th width="' + columns[index][i].width + '"';
|
||||||
|
if (typeof columns[index][i].rowspan != 'undefined' && columns[index][i].rowspan > 1) {
|
||||||
|
tableString += ' rowspan="' + columns[index][i].rowspan + '"';
|
||||||
|
}
|
||||||
|
if (typeof columns[index][i].colspan != 'undefined' && columns[index][i].colspan > 1) {
|
||||||
|
tableString += ' colspan="' + columns[index][i].colspan + '"';
|
||||||
|
}
|
||||||
|
if (typeof columns[index][i].field != 'undefined' && columns[index][i].field != '') {
|
||||||
|
nameList += ',{"f":"' + columns[index][i].field + '", "a":"' + columns[index][i].align + '"}';
|
||||||
|
}
|
||||||
|
tableString += '>' + columns[index][i].title + '</th>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tableString += '\n</tr>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 载入内容
|
||||||
|
var rows = printDatagrid.datagrid("getRows"); // 这段代码是获取当前页的所有行
|
||||||
|
var nl = eval('([' + nameList.substring(1) + '])');
|
||||||
|
for (var i = 0; i < rows.length; ++i) {
|
||||||
|
tableString += '\n<tr>';
|
||||||
|
$(nl).each(function (j) {
|
||||||
|
var e = nl[j].f.lastIndexOf('_0');
|
||||||
|
|
||||||
|
tableString += '\n<td';
|
||||||
|
if (nl[j].a != 'undefined' && nl[j].a != '') {
|
||||||
|
tableString += ' style="text-align:' + nl[j].a + ';"';
|
||||||
|
}
|
||||||
|
tableString += '>';
|
||||||
|
if (e + 2 == nl[j].f.length) {
|
||||||
|
tableString += rows[i][nl[j].f.substring(0, e)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tableString += rows[i][nl[j].f];
|
||||||
|
tableString += '</td>';
|
||||||
|
});
|
||||||
|
tableString += '\n</tr>';
|
||||||
|
}
|
||||||
|
tableString += '\n</table>';
|
||||||
|
|
||||||
|
localStorage.setItem("tableString",tableString);
|
||||||
|
|
||||||
|
window.open("../../js/print/print.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
||||||
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
||||||
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
||||||
|
<script type="text/javascript" src="<%=path %>/js/print/print.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
||||||
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
||||||
@@ -45,7 +46,8 @@
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
||||||
<span class="total-count"></span>
|
|
||||||
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -76,6 +78,7 @@
|
|||||||
initTableData();
|
initTableData();
|
||||||
ininPager();
|
ininPager();
|
||||||
search();
|
search();
|
||||||
|
print();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -305,6 +308,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//报表打印
|
||||||
|
function print() {
|
||||||
|
$("#printBtn").off("click").on("click",function(){
|
||||||
|
CreateFormPage('打印报表', $('#tableData'));
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
||||||
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
||||||
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
||||||
|
<script type="text/javascript" src="<%=path %>/js/print/print.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
||||||
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
||||||
@@ -45,7 +46,8 @@
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
||||||
<span class="total-count"></span>
|
|
||||||
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -76,10 +78,10 @@
|
|||||||
initTableData();
|
initTableData();
|
||||||
ininPager();
|
ininPager();
|
||||||
search();
|
search();
|
||||||
|
print();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//初始化系统基础信息
|
//初始化系统基础信息
|
||||||
function initSystemData_UB(){
|
function initSystemData_UB(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -300,6 +302,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//报表打印
|
||||||
|
function print() {
|
||||||
|
$("#printBtn").off("click").on("click",function(){
|
||||||
|
CreateFormPage('打印报表', $('#tableData'));
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
||||||
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
||||||
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
||||||
|
<script type="text/javascript" src="<%=path %>/js/print/print.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
||||||
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
||||||
@@ -45,7 +46,8 @@
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
||||||
<span class="total-count"></span>
|
|
||||||
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -76,10 +78,10 @@
|
|||||||
initTableData();
|
initTableData();
|
||||||
ininPager();
|
ininPager();
|
||||||
search();
|
search();
|
||||||
|
print();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//初始化系统基础信息
|
//初始化系统基础信息
|
||||||
function initSystemData_UB(){
|
function initSystemData_UB(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -305,6 +307,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//报表打印
|
||||||
|
function print() {
|
||||||
|
$("#printBtn").off("click").on("click",function(){
|
||||||
|
CreateFormPage('打印报表', $('#tableData'));
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
||||||
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<%=path%>/images/favicon.ico" type="image/x-icon" />
|
||||||
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
|
||||||
|
<script type="text/javascript" src="<%=path %>/js/print/print.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/default/easyui.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
<link rel="stylesheet" type="text/css" href="<%=path %>/js/easyui-1.3.5/themes/icon.css"/>
|
||||||
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
<link type="text/css" rel="stylesheet" href="<%=path %>/css/common.css" />
|
||||||
@@ -45,7 +46,8 @@
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>
|
||||||
<span class="total-count"></span>
|
|
||||||
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -76,10 +78,10 @@
|
|||||||
initTableData();
|
initTableData();
|
||||||
ininPager();
|
ininPager();
|
||||||
search();
|
search();
|
||||||
|
print();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//初始化系统基础信息
|
//初始化系统基础信息
|
||||||
function initSystemData_UB(){
|
function initSystemData_UB(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -300,6 +302,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//报表打印
|
||||||
|
function print() {
|
||||||
|
$("#printBtn").off("click").on("click",function(){
|
||||||
|
CreateFormPage('打印报表', $('#tableData'));
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user