帆軟報表和jeecg的進一步整合--ajax給后臺傳遞map類型的參數

下面是頁面代碼:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<%
String deptIds = (String)request.getAttribute("departIds");String dic="t_s_depart";
if(!"".equals(deptIds)){dic="t_s_depart where ID in ("+deptIds+")";
}%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<html><head><title>FineReport Demo</title><script src = "webpage/xiaohaojiao/date.js"></script>    <script type="text/javascript">$(document).ready(function(){$("#dept").change(function(){$("#department").val($(this).val());});//給時間控件加上樣式
        $("#dates").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});$("#datez").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});getFineReport();});function getFineReport() {var value="";var key="";var map = {};var str ="";map["url"]=window.frames[0].location.toString();$('.searchParams').each(function () {value = $(this).val().toString();key=$(this).attr("id");map[key] = value;//主要:map轉json字符串放入data
            str = JSON.stringify(map); });$.ajax({type:"POST",url:"fineReportController.do?getFineUrl",data:{strMap:str}, success:function(data){var d = $.parseJSON($.parseJSON(data).msg)[0];//姓名name是真實姓名_工號拼出來的,例如:張賽梅_160707302X
                window.frames[0].location=encodeURI(encodeURI(d.fineUrl));}});}
</script></head><body>
<div style="height:50px;">開始時間:<input id="dates" class="searchParams Wdate" type="text" value="${dates}" />結束時間:<input id="datez" class="searchParams Wdate" type="text"  value="${datez}"/>部門:<t:dictSelect id="dept" field="dept" type="list" dictTable="<%=dic%>" dictField="departname" dictText="departname" defaultVal="" hasLabel="false"  title="部門" ></t:dictSelect>     <input id="department" class="searchParams" value="" type="hidden" />姓名:<input id="name" class="searchParams" value="" type="text" />     <a class="l-btn" onclick="getFineReport()" href="#"><span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left">查詢</span></span></a>
</div><iframe id="reportFrame" width="100%" height="100%" src="${fineReport}" ></iframe></body>
</html>

下面是后臺代碼:

package com.jeecg.xiaohaojiao.controller;import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Validator;import org.apache.log4j.Logger;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.web.system.service.SystemService;
import org.jeecgframework.web.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;import com.jeecg.xiaohaojiao.service.XhjUserDepartServiceI;
import com.jeecg.xiaohaojiao.util.RoleUtil;import freemarker.template.SimpleDate;
import net.sf.json.JSONObject;/**   * @Title: Controller  * @Description: 帆軟報表頁面跳轉action* @author liuf* @date 2017-10-02 10:49:19* @version V1.0   **/
@Controller
@RequestMapping("/fineReportController")
public class FineReportController extends BaseController{/*** Logger for this class*/private static final Logger logger = Logger.getLogger(FineReportController.class);//不同角色對應的部門idsprivate String departIds = "";@Autowiredprivate SystemService systemService;@Autowiredprivate UserService userService;@Autowiredprivate XhjUserDepartServiceI xhjUserDepartService;/*** 無查詢條件帆軟報表頁面跳轉方法* @param req* @return*/@RequestMapping(params = "goFineReport")public ModelAndView goFineReport(HttpServletRequest req) {String id = req.getParameter("id");String fineReportPath = "../WebReport/ReportServer?reportlet="+id+".cpt";req.setAttribute("fineReport", fineReportPath);return new ModelAndView("xiaohaojiao/fineReport");}/*** 有查詢條件需要控制頁面權限帆軟報表頁面跳轉方法* @param req* @return* @throws ParseException */@RequestMapping(params = "goFineReportForParams")public ModelAndView goFineReportForParams(HttpServletRequest req) throws ParseException {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM");Date date = new Date();String beginTime = sd.format(date);String endTime = sdf.format(date);req.setAttribute("dates", beginTime+"-01");req.setAttribute("datez", endTime);try {departIds = RoleUtil.getDeptIds(req,systemService,userService,xhjUserDepartService);} catch (Exception e) {e.printStackTrace();}String id = req.getParameter("id");String fineReportPath = "../WebReport/ReportServer?reportlet="+id+".cpt";req.setAttribute("fineReport", fineReportPath);req.setAttribute("departIds", departIds);return new ModelAndView("xiaohaojiao/fineReportForParams");}/*** 頁面點擊查詢的時候重新拼接的url,用于重新加載iframe* @param request* @param response* @return* @throws Exception*/@RequestMapping(params = "getFineUrl")@ResponseBodypublic AjaxJson getFineUrl(HttpServletRequest request, HttpServletResponse response) throws Exception{String fineUrl = "";AjaxJson j = new AjaxJson();Map<String,Object> map = new HashMap<String ,Object>();String strMap = request.getParameter("strMap");JSONObject jb = JSONObject.fromObject(strMap);Map filterMap = (Map)jb;fineUrl = ((String) filterMap.get("url")).split("&")[0];Iterator<String> iter = filterMap.keySet().iterator();while (iter.hasNext()) {String key = iter.next();String value = (String) filterMap.get(key);if (!"url".equals(key)) {fineUrl = fineUrl + "&" + key + "=" + (value==null?"":value); }               }map.put("fineUrl", fineUrl);net.sf.json.JSONArray jsonArray = net.sf.json.JSONArray.fromObject(map);j.setMsg(jsonArray.toString());return j;}
}

?

轉載于:https://www.cnblogs.com/shuilangyizu/p/7788100.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/390905.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390905.shtml
英文地址,請注明出處:http://en.pswp.cn/news/390905.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

@Nullable 注解的用法

問題&#xff1a;Nullable 注解的用法 我看到java中的一些方法聲明為: void foo(Nullable Object obj){…}在這里Nullable是什么意思?這是不是意味著輸入可以為空? 沒有這個注解&#xff0c;輸入仍然可以是null&#xff0c;所以我猜這不是它的用法? 回答一 它清楚地說明…

WebLogic調用WebService提示Failed to localize、Failed to create WsdlDefinitionFeature

在本地Tomcat環境下調用WebService正常&#xff0c;但是部署到WebLogic環境中&#xff0c;則提示警告&#xff1a;[Failed to localize] MEX0008.PARSING_MDATA_FAILURE<SOAP_1_2 ......警告&#xff1a;[Failed to localize] MEX0008.PARSING_MDATA_FAILURE<SOAP_1_1 ..…

呼吁開放外網_服裝數據集:呼吁采取行動

呼吁開放外網Getting a dataset with images is not easy if you want to use it for a course or a book. Yes, there are many datasets with images, but few of them are suitable for commercial or educational use.如果您想將其用于課程或書籍&#xff0c;則獲取帶有圖像…

git push命令_Git Push命令解釋

git push命令The git push command allows you to send (or push) the commits from your local branch in your local Git repository to the remote repository.git push命令允許您將提交(或推送 )從本地Git存儲庫中的本地分支發送到遠程存儲庫。 To be able to push to you…

在Java里面使用Pairs或者二元組

問題&#xff1a;在Java里面使用Pairs或者二元組 在Java里面&#xff0c;我的Hashtable要用到一個元組結構。在Java里面&#xff0c;我可以使用的什么數據結構呢&#xff1f; Hashtable<Long, Tuple<Set<Long>,Set<Long>>> table ...回答一 我不認…

github 搜索技巧

1、關鍵詞 指定開發語言 bitcoin language:javascript 2、關鍵詞 stars 數量 forks 數量 bitcoin stars:>100 forks:>50

React JS 組件間溝通的一些方法

剛入門React可能會因為React的單向數據流的特性而遇到組件間溝通的麻煩&#xff0c;這篇文章主要就說一說如何解決組件間溝通的問題。 1.組件間的關系 1.1 父子組件 ReactJS中數據的流動是單向的&#xff0c;父組件的數據可以通過設置子組件的props傳遞數據給子組件。如果想讓子…

數據可視化分析票房數據報告_票房收入分析和可視化

數據可視化分析票房數據報告Welcome back to my 100 Days of Data Science Challenge Journey. On day 4 and 5, I work on TMDB Box Office Prediction Dataset available on Kaggle.歡迎回到我的100天數據科學挑戰之旅。 在第4天和第5天&#xff0c;我將研究Kaggle上提供的TM…

sql limit子句_SQL子句解釋的位置:之間,之間,類似和其他示例

sql limit子句什么是SQL Where子句&#xff1f; (What is a SQL Where Clause?) WHERE子句(和/或IN &#xff0c; BETWEEN和LIKE ) (The WHERE Clause (and/or, IN , BETWEEN , and LIKE )) The WHERE clause is used to limit the number of rows returned.WHERE子句用…

在Java里面使用instanceof的性能影響

問題&#xff1a;在Java里面使用instanceof的性能影響 我正在寫一個應用程序&#xff0c;其中一種設計方案包含了instanceof操作的大量使用。雖然我知道面向對象設計通常試圖避免使用instanceof&#xff0c;但那是另一回事了&#xff0c;這個問題純粹只是討論與性能有關。我想…

Soot生成控制流圖

1.將soot.jar文件復制到工程bin目錄下&#xff1b;2.在cmd中執行如下命令java -cp soot-trunck.jar soot.tools.CFGViewer --soot-classpath .;"%JAVA_HOME%"\jre\lib\rt.jar com.wauoen.paper.classes.Activity其中&#xff0c;JAVA_HOME是jdk目錄&#xff1b;com.w…

Centos 6.5安裝MySQL-python

報錯信息&#xff1a;Using cached MySQL-python-1.2.5.zip Complete output from command python setup.py egg_info: sh: mysql_config: command not found Traceback (most recent call last): File "<string>", line 1, in <module&g…

react 最佳實踐_最佳React教程

react 最佳實踐React is a JavaScript library for building user interfaces. It was voted the most loved in the “Frameworks, Libraries, and Other Technologies” category of Stack Overflow’s 2017 Developer Survey.React是一個用于構建用戶界面JavaScript庫。 在S…

先知模型 facebook_Facebook先知

先知模型 facebook什么是先知&#xff1f; (What is Prophet?) “Prophet” is an open-sourced library available on R or Python which helps users analyze and forecast time-series values released in 2017. With developers’ great efforts to make the time-series …

Java里面的靜態代碼塊

問題&#xff1a;Java里面的靜態代碼塊 I was looking over some code the other day and I came across: 前幾天我在看一些代碼時發現&#xff1a; static {... }我是c轉來的&#xff0c;我不知道為啥要這樣干。這個代碼也編譯成功了&#xff0c;沒出錯誤。這里的"stat…

搭建Maven私服那點事

摘要&#xff1a;本文主要介紹在CentOS7.1下使用nexus3.6.0搭建maven私服&#xff0c;以及maven私服的使用&#xff08;將自己的Maven項目指定到私服地址、將第三方項目jar上傳到私服供其他項目組使用&#xff09; 一、簡介 Maven是一個采用純Java編寫的開源項目管理工具, Mave…

lee最短路算法_Lee算法的解釋:迷宮運行并找到最短路徑

lee最短路算法Lee算法是什么&#xff1f; (What is the Lee Algorithm?) The Lee algorithm is one possible solution for maze routing problems. It always gives an optimal solution, if one exists, but is slow and requires large memory for dense layout.Lee算法是迷…

gan訓練失敗_我嘗試過(但失敗了)使用GAN來創作藝術品,但這仍然值得。

gan訓練失敗This work borrows heavily from the Pytorch DCGAN Tutorial and the NVIDA paper on progressive GANs.這項工作大量借鑒了Pytorch DCGAN教程 和 有關漸進式GAN 的 NVIDA論文 。 One area of computer vision I’ve been wanting to explore are GANs. So when m…

怎么樣實現對一個對象的深拷貝

問題&#xff1a;怎么樣實現對一個對象的深拷貝 使用深拷貝的方法有點難實現啊。要保證原來的對象和克隆對象不是共享同一個引用的步驟是什么啊&#xff1f; 回答一 一種安全的方法是先序列化對象&#xff0c;然后反序列化。這保證了所有東西都是一個新的引用。 這里有一篇…

19.7 主動模式和被動模式 19.8 添加監控主機 19.9 添加自定義模板 19.10 處理圖形中的亂碼 19.11 自動發現...

2019獨角獸企業重金招聘Python工程師標準>>> 19.7 主動模式和被動模式 ? 主動或者被動是相對客戶端來講的 ? 被動模式&#xff0c;服務端會主動連接客戶端獲取監控項目數據&#xff0c;客戶端被動地接受連接&#xff0c;并把監控信息傳遞給服務端 服務端請求以后&…