view.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>{% if 'farmInfo' in data['setting'] %}{{data['setting']['farmInfo']['name']}} - {% end %}{{data['setting']['name']}}</title>
  6. <style>
  7. body{ text-align:center}
  8. .div{position:absolute;
  9. top:50%;
  10. left:50%;
  11. margin:-200px 0 0 -200px;
  12. width:400px;
  13. height:300px;
  14. </style>
  15. </head>
  16. <body>
  17. <div class="div">
  18. <img src="{{data['qrcode']}}" />
  19. <p class="noprint" url="{{data['url']}}"><input type="button" value="打印" onclick="javascript:window.print();" /> </p>
  20. </div>
  21. <!--将不需要打印的部分,标记为 class="noprint" -->
  22. <style type="text/css" media=print>
  23. .noprint{display : none }
  24. </style>
  25. <script>
  26. function preview(oper)
  27. {
  28. if (oper < 10)
  29. {
  30. bdhtml=window.document.body.innerHTML;//获取当前页的html代码
  31. sprnstr="<!--startprint"+oper+"-->";//设置打印开始区域
  32. eprnstr="<!--endprint"+oper+"-->";//设置打印结束区域
  33. prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
  34. prnhtmlprnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
  35. window.document.body.innerHTML=prnhtml;
  36. window.print();
  37. window.document.body.innerHTML=bdhtml;
  38. } else {
  39. window.print();
  40. }
  41. }
  42. </script>
  43. </body>
  44. </html>