print.jsp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <%@ page language="java" contentType="text/html; charset=utf-8"
  2. pageEncoding="utf-8"%>
  3. <%
  4. String path = request.getContextPath();
  5. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  6. %>
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  11. <link rel="stylesheet" type="text/css" href="<%=basePath %>resource/ext/resources/css/ext-all-gray.css"/>
  12. <link rel="stylesheet" href="<%=basePath %>resource/css/main.css" type="text/css"></link>
  13. <script type="text/javascript" src="<%=basePath %>resource/ext/ext-all.js"></script>
  14. <script type="text/javascript">
  15. var bodystr=window.opener.document.body.innerHTML;
  16. Ext.onReady(function(){
  17. var headerstr='',bottomstr='',basePath='<%=basePath %>';
  18. document.title=getUrlParam('title');
  19. Ext.Ajax.request({
  20. url :basePath+ 'common/getPrintSet.action',
  21. method : 'get',
  22. sync:'false',
  23. callback : function(options,success,response){
  24. var res = new Ext.decode(response.responseText);
  25. if(res.success){
  26. headerstr=res.data.header;
  27. bottomstr=res.data.bottom;
  28. var div_header=document.getElementById('headerdiv');
  29. var logo=document.getElementById('logo');
  30. var div_headertext=document.getElementById('textdiv');
  31. var div_body=document.getElementById('bodydiv');
  32. var div_bottom=document.getElementById('bottomdiv');
  33. div_body.innerHTML=bodystr;
  34. div_headertext.innerHTML=headerstr;
  35. div_bottom.innerHTML=bottomstr;
  36. if(res.data.img){
  37. imgid=res.data.img.split(";")[0];
  38. logo.src=basePath + 'common/downloadbyId.action?id='+imgid;
  39. }
  40. var w=document.getElementById('form').style.width;
  41. div_header.style.width=w;
  42. div_bottom.style.width=w;
  43. setTimeout(function(){
  44. window.print();
  45. window.close();
  46. },1000);
  47. }
  48. }
  49. });
  50. });
  51. window.onunload =function(){
  52. window.opener.location.reload();
  53. }
  54. function getUrlParam(name){
  55. var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
  56. var r=window.location.search.substr(1).match(reg);
  57. if (r!=null) return decodeURI(r[2]);
  58. return null;
  59. }
  60. function print_f(){
  61. /* setTimeout(function(){
  62. window.print();
  63. window.close();
  64. },1000); */
  65. };
  66. </script>
  67. </head>
  68. <body>
  69. <div id='headerdiv' style="width:auto;">
  70. <span id='imgdiv' style="display:inline-block;">
  71. <img id='logo' src="" /><!-- style="width:80px;height:50px;vertical-middle;" -->
  72. </span>
  73. <span id='textdiv' style="display:inline-block" align="center"></span>
  74. </div>
  75. <div id='bodydiv'></div>
  76. <br />
  77. <div id='bottomdiv' style="width:auto;height:auto" align='center'></div>
  78. <br />
  79. </body>
  80. </html>