copyImage.zml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <style>
  2. body{ text-align:center}
  3. .div{ margin:0 auto; width:600px; height:300px; border:5px solid #F00}
  4. </style>
  5. <script>
  6. function doCancel()
  7. {//取消
  8. Z("#divImg").remove()
  9. }
  10. function doSubmit(type)
  11. {
  12. var data = Z("#imgData").text()
  13. if (Z.Validates.isEmpty(data))
  14. {
  15. Z.alert("请截图后,在提交")
  16. return;
  17. }
  18. parent.doUploadOcrImage(data, "png", function(){parent.Z.Dialog.close();});
  19. }
  20. (function(){
  21. var imgReader = function( item ){
  22. var blob = item.getAsFile(),
  23. reader = new FileReader();
  24. // 读取文件后将其显示在网页中
  25. reader.onload = function(e){
  26. var img = new Image();
  27. var result = e.target.result;
  28. Z("#imgData").text(result);
  29. img.src = result;
  30. img.id = "divImg";
  31. Z("#imgSrc").append(img);
  32. };
  33. // 读取文件
  34. reader.readAsDataURL(blob);
  35. };
  36. window.addEventListener( 'paste', function(e){
  37. // 添加到事件对象中的访问系统剪贴板的接口
  38. var clipboardData = e.clipboardData,
  39. i = 0,
  40. items, item, types;
  41. if(clipboardData){
  42. items = clipboardData.items;
  43. if( !items ){
  44. return;
  45. }
  46. item = items[0];
  47. // 保存在剪贴板中的数据类型
  48. types = clipboardData.types || [];
  49. for( ; i < types.length; i++ ){
  50. if( types[i] === 'Files' ){
  51. item = items[i];
  52. break;
  53. }
  54. }
  55. // 判断是否为图片数据
  56. if( item && item.kind === 'file' && item.type.match(/^image\//i) ){
  57. imgReader( item );
  58. }
  59. }
  60. });
  61. })();
  62. </script>
  63. ${zhiqim_manager_content()}
  64. <div style="display:none" id="imgData"></div>
  65. <div id="imgSrc"></div>
  66. <div style="position:fixed;bottom:0px;height:50px;width:100%;background-color:#EFEFEF;border-top: solid 1px #ededed">
  67. <div style="margin-top:10px">
  68. <button type="button" class="z-button z-w100 ${zmr_color_class}" id="designOrderDraft" onclick="doSubmit('${type}');">提交</button>&nbsp;&nbsp;&nbsp;
  69. <button type="button" class="z-button z-red" onclick="doCancel();">清空</button>&nbsp;
  70. </div>
  71. </div>
  72. <br><br>
  73. ${zhiqim_manager_content_end()}
  74. </html>