123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>日常报表数据补录</title>
- <!--框架必需start-->
- <%@include file="../../../../include.jsp" %>
- <!--框架必需end-->
- <script type="text/javascript">
- function initComplete(){
- debugger;
- //加载报表
- getReportTemplete();
- //加载年份
- getYear();
- //加载季度
- getSeason();
- }
-
- function getReportTemplete(){
- var url = $.pathname() +"/ws/rcbaobiao/RcBbService/getReportTemplete";
- $.request.query(url,"",function(data){
- $("#sel_report").data("data",data);
- $("#sel_report").render();
- });
- }
-
- function getYear(){
- var current_year = new Date().getFullYear();
- var data = {"list":[]};
- for(var i=current_year;i>current_year-4;i--){
- var yearObj = {"key":i,"value":i};
- data.list.push(yearObj);
- }
- $("#sel_year").data("data",data);
- $("#sel_year").render();
- $("#sel_year").setValue(current_year);
- $("#sel_year").render();
- }
-
- function getSeason(){
- var current_month = new Date().getMonth()+1;
- var season = current_month<=3 ? "1" : current_month<=6 ? "2" : current_month<=9 ? "3" : current_month<=12 ? "4" : "0";
- var data = {"list":[{"key":"1","value":"1"},{"key":"2","value":"2"},{"key":"3","value":"3"},{"key":"4","value":"4"}]};
- $("#sel_season").data("data",data);
- $("#sel_season").render();
- $("#sel_season").setValue(season);
- $("#sel_season").render();
- }
-
- //导入表格数据
- function importExcelData(){
- debugger;
- var file = $("#file").val().trim();
- var file_suffix = file.substring(file.lastIndexOf(".")+1);
- if(file==""||file==null){
- top.Dialog.alert("请导入excel文件");
- return;
- }
- var $form = $("#fileForm");
- var year = $("#sel_year").val();
- var season = $("#sel_season").val();
- var report_type = $("#sel_report").attr("relValue");
- console.log(report_type);
- var report_name = $("#sel_report").attr("relText");
- console.log(report_name);
- if(report_type==""||report_type==null||report_type==undefined){
- top.Dialog.alert("请选择报表模板");
- return;
- }
- if(year==""||year==null){
- top.Dialog.alert("请选择年份信息");
- return;
- }
- if(season==""||season==null){
- top.Dialog.alert("请选择季度信息");
- return;
- }
- if(file_suffix=="xls"||file_suffix=="xlsx"){
- $form.ajaxSubmit({
- url : $.pathname() +"/ws/rcbaobiao/RcBbService/importFileData?fileExt="+file_suffix+"&year="+year+"&season="+season+"&report_type="+report_type+"&report_name="+encodeURI(encodeURI(report_name)),
- type : 'post',
- success : function(responseText, statusText, xhr, $form){
- console.log(responseText);
- top.Dialog.alert(responseText.Msg.info);
- },
- error : function(){
- top.Dialog.alert("导入数据失败!");
- }
- });
- }else{
- top.Dialog.alert("请导入正确的excel文件");
- return;
- }
- }
- //下载模板
- function download(){
- $(this).addClass("selectedButton");
- var diag = new top.Dialog();// 定义一个窗口对象
- diag.Title = "选择组织";// 窗口标题
- diag.URL = "/nwyj/page/business/em/report/selectDept.html";
- diag.Height = 450;
- diag.Width = 380;
- diag.ID = "ORG_IFRAME";
- diag.ShowButtonRow = true;
- diag.ShowCancelButton = false;// 不显示取消按钮
- diag.ButtonAlign = "center";// 按钮居中
- diag.OkButtonText=" 确 定 ";
- diag.OKEvent = function(){
- var selectedComp=diag.innerFrame.contentWindow.queDing2();
- diag.close();
- downloadModel(selectedComp);
- };
- diag.CancelEvent = function(){
- diag.close();
- };
- diag.show();// 显示窗口
- diag.OnLoad=function(){
- diag.innerFrame.contentWindow.showData2();
- };
- diag.addButton("testBtn5"," 清除 ",function(){
- diag.innerFrame.contentWindow.qingChu();
- });
- diag.addButton("testBtn6"," 全选 ",function(){
- diag.innerFrame.contentWindow.quanXuan();
- });
- }
- function downloadModel(selectComp){
- if(selectComp.length==0){
- top.Dialog.alert("请选择单位!");
- return;
- }
- var reportName = $("#sel_report").attr("relText");
- var report = $("#sel_report").val();
- console.log(report);
- if(""===report){
- top.Dialog.alert("请选择报表类型!");
- return;
- }
- var destFileName = reportName+"模板";
- $.ajax({
- url :$.pathname() + "/ws/excel/ExcelService/createExcelTemplete",
- type : "post",
- data : {"comp":selectComp.join(";"),"report_type":report},
- dataType : "json",
- success : function(data){
- console.log(data.Msg);
- if(data.Msg.sucsess){
- var url = "/nwyj/page/common/getExcel.jsp?exportContent="
- + data.Msg.info+ "&destFileName=" + encodeURI(encodeURI(destFileName));
- window.open(url);
- }else{
- top.Dialog.alert(data.Msg.info);
- }
- },
- error : function(){
- top.Dialog.alert("下载报表类型模版失败!");
- }
- });
- }
- </script>
- </head>
- <body>
- <div class="box1" panelWidth="100%" panelHeight="100%">
- <div>
- <form id="fileForm" method="post" >
- <table>
- <tr>
- <td>报表模板:</td>
- <td><select prompt="请选择" id="sel_report"></select></td>
- <td>年份:</td>
- <td><select prompt="请选择" id="sel_year"></select></td>
- <td>季度:</td>
- <td><select prompt="请选择" id="sel_season"></select></td>
- <td>选择导入文件:</td>
- <td><input type="file" id='file' name='file'/></td>
- <td><input type="button" value='上传' onclick="importExcelData()"/></td>
- <td><input type="button" value = "下载模板 " onclick="download()"/></td>
- </tr>
- </table>
- </form>
- </div>
- </div>
- </body>
- </html>
|