原创

若依集成积木报表


官方文档

http://report.jeecg.com

集成步骤

1、执行sql文件

https://gitee.com/jeecg/JimuReport/blob/master/db/jimureport.mysql5.7.create.sql

sql执行报错:

[ERR] 2013 - Lost connection to MySQL server during query [ERR]

修改my.inimax_allowed_packet属性,重启MySQL

max_allowed_packet = 500M

版本更新增量sql:

ALTER TABLE `jimu_report`
MODIFY COLUMN `json_str` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 'json字符串' AFTER `type`;

ALTER TABLE `jimu_report_link` 
ADD COLUMN `expression` varchar(255) NULL COMMENT '表达式' AFTER `link_chart_id`;

ALTER TABLE `jimu_report_db_field`
ADD COLUMN `search_format` varchar(50) NULL COMMENT '查询时间格式化表达式' AFTER `search_value`;

ALTER TABLE `jimu_report_db_param`
ADD COLUMN `search_format` varchar(50) NULL COMMENT '查询时间格式化表达式' AFTER `dict_code`;

UPDATE jimu_report SET json_str=replace(json_str,'"subtotal":"totalField"','"funcname":"SUM"');

ALTER TABLE `jimu_report`
ADD COLUMN `css_str` text NULL COMMENT 'css增强' AFTER `view_count`,
ADD COLUMN `js_str` text NULL COMMENT 'js增强' AFTER `css_str`;

ALTER TABLE `jimu_report_link` 
CHANGE COLUMN `expression` `requirement` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '条件' AFTER `link_chart_id`;

ALTER TABLE `jimu_report_db_field` 
ADD COLUMN `ext_json` text  NULL COMMENT '参数配置' AFTER `search_format`;

ALTER TABLE `jimu_report_db_param` 
ADD COLUMN `ext_json`  text  NULL COMMENT '参数配置' AFTER `search_format`;

2、引入依赖

ruoyi-admin模块pom文件中添加依赖:

<dependency>
  <groupId>org.jeecgframework.jimureport</groupId>
  <artifactId>jimureport-spring-boot-starter</artifactId>
  <version>1.3.78</version>
</dependency>

3、添加依赖扫描

ruoyi-admin模块启动类RuoYiApplication添加积木依赖扫描

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class },scanBasePackages = {"org.jeecg.modules.jmreport","com.ruoyi"})

4、SecurityConfig拦截排除

.antMatchers("/jmreport/**").anonymous()

5、yml中配置minidao

ruoyi-admin模块application.yml中增加配置

minidao :
  base-package: org.jeecg.modules.jmreport.desreport.dao*
  # 数据源类型
  db-type: mysql

6、注释devtools依赖

尝试删除pom文件中的devtools依赖,否则项目启动报AOP相关错误

<!-- spring-boot-devtools -->
        <!--<dependency>-->
        <!--    <groupId>org.springframework.boot</groupId>-->
        <!--    <artifactId>spring-boot-devtools</artifactId>-->
        <!--    <optional>true</optional> &lt;!&ndash; 表示依赖不会传递 &ndash;&gt;-->
        <!--</dependency>-->

7、访问地址

http://localhost:8080/jmreport/list

8、Vue前台打印PDF

//在main.js中增加引入
import VueResource from 'vue-resource'
Vue.use(VueResource)
/** 打印按钮操作 */
    testPrint(row) {
      let params = {};
      //必传id,配置的模板id
      params.excelConfigId = "602641040265347072";
      //参数对象,在数据源页面配置的参数,接受数组为queryParam
      params.queryParam = { caseId: row.caseId };
      //如果有token需要传递token
      let config = {
        headers: {
          // Authorization:
          //   "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjcyNmY4NDgzLWJmMTEtNDg2MC05MWYyLTJiY2I1NmNkNDU5MiJ9.qgaCMd1_mtOlkMaFQ0vQLHNS31Xpw0P4R30fOCFNCOLDUXhP6gGi2oRQVAZRjuDpVqG4nREKdjIkXbT6wJKmvA"
        }
      };
      this.$http.post(process.env.VUE_APP_BASE_API+"/jmreport/exportPdf", params, config).then(res => {
        //成功
        if (res.body.success) {
          //获取base64文件
          let file = res.body.result.file;
          // console.log('请求成功')
          let bstr = atob(file),
            n = bstr.length,
            u8arr = new Uint8Array(n);
          while (n--) {
            u8arr[n] = bstr.charCodeAt(n);
          }
          let blob = new Blob([u8arr], {
            type: "application/pdf;chartset=UTF-8"
          });
          //创建url
          let fileURL = URL.createObjectURL(blob);
          // console.log(fileURL)
          window.open(fileURL);
        }
      });
    }
正文到此结束