3c7384b32392ccfe3c284d2563422936a54b48a9.svn-base 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  6. <title>日常报表数据补录</title>
  7. <!--框架必需start-->
  8. <%@include file="../../../../include.jsp" %>
  9. <!--框架必需end-->
  10. <script type="text/javascript">
  11. function initComplete(){
  12. debugger;
  13. //加载报表
  14. getReportTemplete();
  15. //加载年份
  16. getYear();
  17. //加载季度
  18. getSeason();
  19. }
  20. function getReportTemplete(){
  21. var url = $.pathname() +"/ws/rcbaobiao/RcBbService/getReportTemplete";
  22. $.request.query(url,"",function(data){
  23. $("#sel_report").data("data",data);
  24. $("#sel_report").render();
  25. });
  26. }
  27. function getYear(){
  28. var current_year = new Date().getFullYear();
  29. var data = {"list":[]};
  30. for(var i=current_year;i>current_year-4;i--){
  31. var yearObj = {"key":i,"value":i};
  32. data.list.push(yearObj);
  33. }
  34. $("#sel_year").data("data",data);
  35. $("#sel_year").render();
  36. $("#sel_year").setValue(current_year);
  37. $("#sel_year").render();
  38. }
  39. function getSeason(){
  40. var current_month = new Date().getMonth()+1;
  41. var season = current_month<=3 ? "1" : current_month<=6 ? "2" : current_month<=9 ? "3" : current_month<=12 ? "4" : "0";
  42. var data = {"list":[{"key":"1","value":"1"},{"key":"2","value":"2"},{"key":"3","value":"3"},{"key":"4","value":"4"}]};
  43. $("#sel_season").data("data",data);
  44. $("#sel_season").render();
  45. $("#sel_season").setValue(season);
  46. $("#sel_season").render();
  47. }
  48. //导入表格数据
  49. function importExcelData(){
  50. debugger;
  51. var file = $("#file").val().trim();
  52. var file_suffix = file.substring(file.lastIndexOf(".")+1);
  53. if(file==""||file==null){
  54. top.Dialog.alert("请导入excel文件");
  55. return;
  56. }
  57. var $form = $("#fileForm");
  58. var year = $("#sel_year").val();
  59. var season = $("#sel_season").val();
  60. var report_type = $("#sel_report").attr("relValue");
  61. console.log(report_type);
  62. var report_name = $("#sel_report").attr("relText");
  63. console.log(report_name);
  64. if(report_type==""||report_type==null||report_type==undefined){
  65. top.Dialog.alert("请选择报表模板");
  66. return;
  67. }
  68. if(year==""||year==null){
  69. top.Dialog.alert("请选择年份信息");
  70. return;
  71. }
  72. if(season==""||season==null){
  73. top.Dialog.alert("请选择季度信息");
  74. return;
  75. }
  76. if(file_suffix=="xls"||file_suffix=="xlsx"){
  77. $form.ajaxSubmit({
  78. url : $.pathname() +"/ws/rcbaobiao/RcBbService/importFileData?fileExt="+file_suffix+"&year="+year+"&season="+season+"&report_type="+report_type+"&report_name="+encodeURI(encodeURI(report_name)),
  79. type : 'post',
  80. success : function(responseText, statusText, xhr, $form){
  81. console.log(responseText);
  82. top.Dialog.alert(responseText.Msg.info);
  83. },
  84. error : function(){
  85. top.Dialog.alert("导入数据失败!");
  86. }
  87. });
  88. }else{
  89. top.Dialog.alert("请导入正确的excel文件");
  90. return;
  91. }
  92. }
  93. //下载模板
  94. function download(){
  95. $(this).addClass("selectedButton");
  96. var diag = new top.Dialog();// 定义一个窗口对象
  97. diag.Title = "选择组织";// 窗口标题
  98. diag.URL = "/nwyj/page/business/em/report/selectDept.html";
  99. diag.Height = 450;
  100. diag.Width = 380;
  101. diag.ID = "ORG_IFRAME";
  102. diag.ShowButtonRow = true;
  103. diag.ShowCancelButton = false;// 不显示取消按钮
  104. diag.ButtonAlign = "center";// 按钮居中
  105. diag.OkButtonText=" 确 定 ";
  106. diag.OKEvent = function(){
  107. var selectedComp=diag.innerFrame.contentWindow.queDing2();
  108. diag.close();
  109. downloadModel(selectedComp);
  110. };
  111. diag.CancelEvent = function(){
  112. diag.close();
  113. };
  114. diag.show();// 显示窗口
  115. diag.OnLoad=function(){
  116. diag.innerFrame.contentWindow.showData2();
  117. };
  118. diag.addButton("testBtn5"," 清除 ",function(){
  119. diag.innerFrame.contentWindow.qingChu();
  120. });
  121. diag.addButton("testBtn6"," 全选 ",function(){
  122. diag.innerFrame.contentWindow.quanXuan();
  123. });
  124. }
  125. function downloadModel(selectComp){
  126. if(selectComp.length==0){
  127. top.Dialog.alert("请选择单位!");
  128. return;
  129. }
  130. var reportName = $("#sel_report").attr("relText");
  131. var report = $("#sel_report").val();
  132. console.log(report);
  133. if(""===report){
  134. top.Dialog.alert("请选择报表类型!");
  135. return;
  136. }
  137. var destFileName = reportName+"模板";
  138. $.ajax({
  139. url :$.pathname() + "/ws/excel/ExcelService/createExcelTemplete",
  140. type : "post",
  141. data : {"comp":selectComp.join(";"),"report_type":report},
  142. dataType : "json",
  143. success : function(data){
  144. console.log(data.Msg);
  145. if(data.Msg.sucsess){
  146. var url = "/nwyj/page/common/getExcel.jsp?exportContent="
  147. + data.Msg.info+ "&destFileName=" + encodeURI(encodeURI(destFileName));
  148. window.open(url);
  149. }else{
  150. top.Dialog.alert(data.Msg.info);
  151. }
  152. },
  153. error : function(){
  154. top.Dialog.alert("下载报表类型模版失败!");
  155. }
  156. });
  157. }
  158. </script>
  159. </head>
  160. <body>
  161. <div class="box1" panelWidth="100%" panelHeight="100%">
  162. <div>
  163. <form id="fileForm" method="post" >
  164. <table>
  165. <tr>
  166. <td>报表模板:</td>
  167. <td><select prompt="请选择" id="sel_report"></select></td>
  168. <td>年份:</td>
  169. <td><select prompt="请选择" id="sel_year"></select></td>
  170. <td>季度:</td>
  171. <td><select prompt="请选择" id="sel_season"></select></td>
  172. <td>选择导入文件:</td>
  173. <td><input type="file" id='file' name='file'/></td>
  174. <td><input type="button" value='上传' onclick="importExcelData()"/></td>
  175. <td><input type="button" value = "下载模板 " onclick="download()"/></td>
  176. </tr>
  177. </table>
  178. </form>
  179. </div>
  180. </div>
  181. </body>
  182. </html>