export.html.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php if($mode == 'preview') include $app->getModuleRoot() . 'common/view/header.html.php';?>
  2. <?php js::set('emptyLang', $emptyLang);?>
  3. <?php js::set('errorNoChart', $lang->report->errorNoChart);?>
  4. <?php js::set('errorExportChart', $lang->report->errorExportChart);?>
  5. <?php js::set('mode', $mode);?>
  6. <style>
  7. .modal-title-name {font-weight: 700;}
  8. #main {min-width: 580px;}
  9. </style>
  10. <?php if($mode == 'preview'):?>
  11. <div class='modal-title-name'><?php echo $lang->export;?></div>
  12. <?php endif;?>
  13. <form method='post' action='<?php echo $this->createLink('chart', 'export')?>' target='hiddenwin' style="margin:15px 20px;" id='exportForm'>
  14. <table class='table table-form' style='padding:30px'>
  15. <tr>
  16. <th class='w-100px'><?php echo $lang->setFileName;?></th>
  17. <td class='required'><input type="text" name="fileName" id="fileName" class="form-control"></td>
  18. <td>
  19. <?php
  20. echo html::select('fileType', array('docx' => 'docx'), '', 'class="form-control"');
  21. ?>
  22. </td>
  23. <td><?php echo html::submitButton($lang->save, '', 'btn btn-primary upload-btn') . html::hidden('items', $chartID) . html::hidden('datas');?></td>
  24. </tr>
  25. </table>
  26. </form>
  27. <script>
  28. $(function()
  29. {
  30. $('#exportForm #submit').click(function()
  31. {
  32. if($('#fileName').val() == '')
  33. {
  34. bootbox.alert(emptyLang);
  35. return false;
  36. }
  37. if($('#datas').size() == 0) return true;
  38. if(mode == 'design')
  39. {
  40. $(":checkbox:checked[name^='charts']").each(function()
  41. {
  42. items = $('#exportForm #items').val();
  43. items += $(this).val() + ',';
  44. $('#exportForm #items').val(items);
  45. });
  46. }
  47. else
  48. {
  49. var moduleMenu = parent.$('#moduleMenu menu').zui('tree');
  50. var checkedList = moduleMenu.$.getChecks();
  51. var checkedMap = moduleMenu.$._itemMap;
  52. var valueList = [];
  53. for (var i = 0; i < checkedList.length; i++)
  54. {
  55. var key = checkedList[i];
  56. if(checkedMap.get(key).level == 0) continue;
  57. var value = checkedMap.get(key).key;
  58. valueList.push(value);
  59. }
  60. $('#exportForm #items').val(valueList.join(','));
  61. }
  62. var dataBox = "<input type='hidden' name='%name%' id='%id%' />";
  63. var echartDivs = mode == 'design' ? $('.echart-content') : parent.$('.echart-content');
  64. var canvasSize = echartDivs.length;
  65. if(canvasSize == 0)
  66. {
  67. bootbox.alert(errorNoChart);
  68. return false;
  69. }
  70. echartDivs.each(function(i)
  71. {
  72. var $canvas = $(this).find('canvas');
  73. var canvas = $canvas[0];
  74. if($canvas.length > 0 && typeof(canvas.toDataURL) == 'undefined')
  75. {
  76. bootbox.alert(errorExportChart);
  77. return false;
  78. }
  79. var dataURL = $canvas.length > 0 ? canvas.toDataURL("image/png") : '';
  80. var dataID = $(this).data('id');
  81. var groupID = $(this).data('group');
  82. var chartID = groupID + '_' + dataID;
  83. var thisDataBox = dataBox.replace('%name%', chartID);
  84. thisDataBox = thisDataBox.replace('%id%', chartID);
  85. $('#exportForm #submit').after(thisDataBox);
  86. if($canvas.length > 0) $('#exportForm #' + chartID).val(dataURL);
  87. if(i == canvasSize - 1) $('#datas').remove();
  88. });
  89. mode == 'design' ? $('.close').click() : parent.$('.close')[0].click();
  90. });
  91. })
  92. </script>
  93. <?php if($mode == 'preview') include $app->getModuleRoot() . 'common/view/footer.html.php';?>