0.0.10 • Published 28 days ago

@icreate/ics-chromely-plugin-report-js-sdk v0.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
28 days ago

Usage

npm i @icreate/ics-chromely-plugin-report-js-sdk

Features

0.0.9-beta.1 注册数据源时允许指定字段类型
0.0.9 优化和完善导出pdf流
0.0.8-beta.1 增加导出pdf流示例
0.0.8 增加导出pdf流支持
0.0.7 修复打印和准备打印方法调用不传打印机名称时使用默认打印机
0.0.6 修改print和printPrepared的printerName允许为空
0.0.5 增加打印准备报表printPrepared
0.0.4 增加预览准备报表showPrepared
0.0.3  将注册数据源数据转为为json字符串
  • ReportHelper:报表

Importing library

You can import the generated bundle to use the whole library generated by this starter:

import ReportHelper from '@icreate/ics-chromely-plugin-report-js-sdk'

ReportHelper

  // 指定文件加载报表
   load(fileName: string): Promise<any> 
  // 根据Id加载报表
   loadFromId(reportId: string): Promise<any> 
 // 清空数据源
   clearData(): Promise<any> 
  // 注册数据源
   registerData(name: string, data: Array<any>): Promise<any>
  // 设置双面打印
   doublePass(value: Boolean): Promise<any>
  // 准备报表
   prepare(append: Boolean): Promise<any>
  // 添加参数
   addParameter(name: string, value: string): Promise<any>
  // 设计报表
   design(): Promise<any> 
  // 预览报表
   show(): Promise<any>
  // 预览准备报表
   showPrepared(): Promise<any>
  // 打印报表
   print(printerName?: string): Promise<any>
  // 打印准备报表
   printPrepared(printerName?: string): Promise<any>
  //  导出pdf:文件名称,如果不传则返回流
   ExportToPdf(fileName: string): Promise<any> 
  //  导出html
   exportToHtml(fileName: string): Promise<any> 
  // 释放报表
   dispose(): Promise<any>

一般设计打印示例

  const reportHelper = new ReportHelper()
  await reportHelper.clearData()
  await reportHelper.load('xxxx.frx')
  await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}])
  await reportHelper.design() //设计报表
  await reportHelper.show() //预览报表
  await reportHelper.print() //打印报表

指定字段类型示例

  const reportHelper = new ReportHelper()
  await reportHelper.clearData()
  await reportHelper.load('xxxx.frx')
  //指定数据源中字段对应的类型,{id:"string",name:"string", birthday: "date"}
  //可指定 string|bool|date|datetime|decimal|double|float|int|long|object|short
  //格式: {"id":"string","flag":"int","birthday":"date","total":"decimal"}
  await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三",birthday:"1988-05-26"}],{id:"string",name:"string", birthday: "date"})
  await reportHelper.design() //设计报表
  await reportHelper.show() //预览报表
  await reportHelper.print() //打印报表

字段类型说明

类型描述范围默认值
bool布尔值True 或 FalseFALSE
byte8 位无符号整数0 到 2550
char16 位 Unicode 字符U +0000 到 U +ffff'\0'
decimal128 位精确的十进制值,28-29 有效位数(-7.9 x 1028 到 7.9 x 1028) / 100 到 280.0M
double64 位双精度浮点型(+/-)5.0 x 10-324 到 (+/-)1.7 x 103080.0D
float32 位单精度浮点型-3.4 x 1038 到 + 3.4 x 10380.0F
int32 位有符号整数类型-2,147,483,648 到 2,147,483,6470
long64 位有符号整数类型-9,223,372,036,854,775,808 到 9,223,372,036,854,775,8070L
sbyte8 位有符号整数类型-128 到 1270
short16 位有符号整数类型-32,768 到 32,7670
uint32 位无符号整数类型0 到 4,294,967,2950
ulong64 位无符号整数类型0 到 18,446,744,073,709,551,6150
ushort16 位无符号整数类型0 到 65,5350
date日期0001/1/1 00:00:00到9999/12/31 00:00:00之间0001/1/1 0:00:00
datetime日期时间0001/1/1 00:00:00到9999/12/31 23:59:59之间0001/1/1 0:00:00

合并打印示例

  const reportHelper = new ReportHelper()
  //加载报表1
  await reportHelper.clearData()
  await reportHelper.load('xxxx.frx')
  await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}])
  await reportHelper.prepare(false)
  //加载报表2
  await reportHelper.clearData()
  await reportHelper.load('xxxx.frx')
  await reportHelper.registerData('患者基本信息',[{ id:"1",name:"李四"}])
  await reportHelper.prepare(true)
  await reportHelper.showPrepared() //预览准备报表
  await reportHelper.printPrepared() //打印准备报表

导出pdf流示例

  const reportHelper = new ReportHelper()
  await reportHelper.clearData()
  await reportHelper.load('xxxx.frx')
  await reportHelper.registerData('患者基本信息', [
    { id: '1', name: '张三' }
  ])
  await reportHelper.prepare(true)
  const blob = await reportHelper.ExportToPdf() // 设计报表
  //直接使用blob展示[vue-pdf-embed](https://github.com/hrynko/vue-pdf-embed)  
  const source = await blob.arrayBuffer()
  console.log(source, 'arrayBuffer')
  //生成pdf内存url
  const source = URL.createObjectURL(blob)
  console.log(source, 'url')
0.0.10

28 days ago

0.0.9-beta.7

4 months ago

0.0.9-beta.6

4 months ago

0.0.9-beta.5

4 months ago

0.0.9-beta.4

4 months ago

0.0.9-beta.3

4 months ago

0.0.9-beta.2

5 months ago

0.0.9-beta.1

1 year ago

0.0.9

1 year ago

0.0.8-beta.1

1 year ago

0.0.8

1 year ago

0.0.3

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago