API 基础

稳定

reportOptions

稳定性:stable。mount 的模板只把 builderProps.props 中存在的键传给 Builder;下表默认值来自当前 builderProps.ts 和 Builder 的有效默认处理。

调用方式与方法签名

api.mount({ reportOptions }, container, Vue): Promise<unknown>
api.print({ reportOptions, printOptions? }, Vue): Promise<unknown>

参数与默认值

参数 类型 必填 默认值 说明
reportCode String 是 "" 报表标识,例如 sales-summary
reportVersion String 是 "" 报表版本,例如 1.0.0
serviceInputs Object 否 null 报表数据服务入参
injectReportScope Object 否 {} 注入报表作用域;未注册属性是否生效由报表模板决定
reportData Object | Array 否 null 直接提供报表数据
mode Number 否 1 当前注释:1 打印预览、2 常规、3 设计、4 打印
headerOptions Object 否 {} 顶部操作区,空对象会触发 Builder 有效默认值,见下表
contextPath String 否 "" 请求上下文前缀
readOnly Boolean 否 false 只读状态
enableWebWorker Boolean 否 true 是否开启 Web Worker;iframe src 以 webWorker=1/0 传递
reportParseMode String 否 "" 解析模式;源码注释中 node 交由后端链路解析,使用前需部署确认
noLoading Boolean 否 false 初始或作用域更新时抑制 loading 的相关开关
reportConfig Object 否 内置结构 直接报表配置;通常由服务返回,不建议业务手工构造
reportReference Object 否 内置空引用 直接报表引用数据;通常由服务返回
reportInfo Object 否 内置信息对象 报表描述信息;普通按 code/version 加载无需传入
isPrintSilent Boolean 否 false 打印链内部标记,不作为普通挂载首选参数
subMode Boolean 否 false 子报表内部模式,使用前需研发确认
isExportExcel Boolean 否 false exportExcel 内部设置,不应由业务依赖

当 headerOptions 为空时,Builder 当前使用以下有效默认值:

参数 类型 默认值 说明
show Boolean true 显示顶部操作区
print Boolean true 显示打印全部按钮
printCurrent Boolean true 显示打印当前页按钮
pdf Boolean true 显示 PDF 按钮
excel Boolean true 显示 Excel 按钮
pagination Boolean true 显示分页
showPrintConf Boolean true 打印前显示页码配置
servicePagination Object { pageNo: "", pageSize: "", total: "" } 服务端分页字段映射

传入非空 headerOptions 时当前 Builder 可能直接采用该对象,而不是逐项合并默认值,因此请显式给出所需字段。

返回值与异常

reportOptions 本身没有返回值;它影响调用方法。缺少或无法解析报表标识可能对应 401/402,数据获取失败对应 405。

最小示例

const reportOptions = {
  reportCode: "sales-summary",
  reportVersion: "1.0.0",
  serviceInputs: { period: "2026-Q1" },
  injectReportScope: { tenantId: "YOUR_TENANT_ID" },
  mode: 2,
  headerOptions: {
    show: true,
    print: true,
    printCurrent: true,
    pdf: true,
    excel: true,
    pagination: true,
    showPrintConf: true,
  },
};

iframe 模式差异

reportOptions.url 不是 Builder prop,但 iframe mount 会读取它作为入口地址;其余参数与 printOptions 合并写入 contentWindow.$$BEEREPORT_PARAMS。当前源码还通过 contentWindow.document 注入样式,因此入口必须与宿主页同源,例如 /bee-report/index.html;跨域需改造为纯 postMessage 协议。

相关 API

mount 与 unmount、printOptions。

常见错误

不要假定空字符串版本会自动补成某个版本;显式传 1.0.0。reportData 与 serviceInputs 的取舍由报表模板的数据来源决定。