print.jsp 2.4 KB

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