@icreate/ics-chromely-plugin-report-js-sdk
Advanced tools
Comparing version 0.0.8 to 0.0.9-beta.1
@@ -33,5 +33,4 @@ import icsChromelyRequest from '@icreate/ics-chromely-js-sdk'; | ||
} | ||
Report.prototype.OperateEx = function (url, data, method, headers) { | ||
Report.prototype.OperateEx = function (url, data, method) { | ||
if (method === void 0) { method = 'GET'; } | ||
if (headers === void 0) { headers = {}; } | ||
// let opts = | ||
@@ -42,3 +41,2 @@ return icsChromelyRequest.function({ | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }), | ||
headers: headers, | ||
}); | ||
@@ -50,5 +48,13 @@ }; | ||
}; | ||
// 注册数据源 | ||
Report.prototype.registerData = function (name, data) { | ||
return this.OperateEx('RegisterData', { name: name, data: JSON.stringify(data) }, 'POST'); | ||
/** | ||
* 注册数据源 | ||
* @param name 数据源名称 | ||
* @param data 数据 | ||
* @param field 指定字段对应类型 默认所有字段类型为string | ||
* 可指定 string|bool|date|datetime|decimal|double|float|int|long|object|short | ||
* 格式: {"id":"string","flag":"int","birthday":"date","total":"decimal"} | ||
* @returns | ||
*/ | ||
Report.prototype.registerData = function (name, data, field) { | ||
return this.OperateEx('RegisterData', { name: name, data: JSON.stringify(data), field: JSON.stringify(field || {}) }, 'POST'); | ||
}; | ||
@@ -70,3 +76,3 @@ // 设置双面打印 | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件地址或者文件流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
@@ -78,3 +84,3 @@ Report.prototype.ExportToPdf = function (fileName) { | ||
else { | ||
return this.OperateEx('ExportToPdfStream', null, "GET"); | ||
return this.OperateEx('ExportToPdfStream', null, 'GET'); | ||
} | ||
@@ -81,0 +87,0 @@ }; |
@@ -41,5 +41,4 @@ (function (global, factory) { | ||
} | ||
Report.prototype.OperateEx = function (url, data, method, headers) { | ||
Report.prototype.OperateEx = function (url, data, method) { | ||
if (method === void 0) { method = 'GET'; } | ||
if (headers === void 0) { headers = {}; } | ||
// let opts = | ||
@@ -50,3 +49,2 @@ return icsChromelyRequest__default["default"].function({ | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }), | ||
headers: headers, | ||
}); | ||
@@ -58,5 +56,13 @@ }; | ||
}; | ||
// 注册数据源 | ||
Report.prototype.registerData = function (name, data) { | ||
return this.OperateEx('RegisterData', { name: name, data: JSON.stringify(data) }, 'POST'); | ||
/** | ||
* 注册数据源 | ||
* @param name 数据源名称 | ||
* @param data 数据 | ||
* @param field 指定字段对应类型 默认所有字段类型为string | ||
* 可指定 string|bool|date|datetime|decimal|double|float|int|long|object|short | ||
* 格式: {"id":"string","flag":"int","birthday":"date","total":"decimal"} | ||
* @returns | ||
*/ | ||
Report.prototype.registerData = function (name, data, field) { | ||
return this.OperateEx('RegisterData', { name: name, data: JSON.stringify(data), field: JSON.stringify(field || {}) }, 'POST'); | ||
}; | ||
@@ -78,3 +84,3 @@ // 设置双面打印 | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件地址或者文件流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
@@ -86,3 +92,3 @@ Report.prototype.ExportToPdf = function (fileName) { | ||
else { | ||
return this.OperateEx('ExportToPdfStream', null, "GET"); | ||
return this.OperateEx('ExportToPdfStream', null, 'GET'); | ||
} | ||
@@ -89,0 +95,0 @@ }; |
@@ -18,3 +18,3 @@ "use strict"; | ||
* @LastEditors: 陶慧灵 | ||
* @LastEditTime: 2022-12-10 23:50:25 | ||
* @LastEditTime: 2022-12-13 11:37:27 | ||
* @Description: | ||
@@ -28,5 +28,4 @@ * @FilePath: \ics-chromely-plugin-report\src\core\report.ts | ||
} | ||
Report.prototype.OperateEx = function (url, data, method, headers) { | ||
Report.prototype.OperateEx = function (url, data, method) { | ||
if (method === void 0) { method = 'GET'; } | ||
if (headers === void 0) { headers = {}; } | ||
// let opts = | ||
@@ -37,3 +36,2 @@ return ics_chromely_js_sdk_1.default.function({ | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }), | ||
headers: headers, | ||
}); | ||
@@ -45,5 +43,13 @@ }; | ||
}; | ||
// 注册数据源 | ||
Report.prototype.registerData = function (name, data) { | ||
return this.OperateEx('RegisterData', { name: name, data: JSON.stringify(data) }, 'POST'); | ||
/** | ||
* 注册数据源 | ||
* @param name 数据源名称 | ||
* @param data 数据 | ||
* @param field 指定字段对应类型 默认所有字段类型为string | ||
* 可指定 string|bool|date|datetime|decimal|double|float|int|long|object|short | ||
* 格式: {"id":"string","flag":"int","birthday":"date","total":"decimal"} | ||
* @returns | ||
*/ | ||
Report.prototype.registerData = function (name, data, field) { | ||
return this.OperateEx('RegisterData', { name: name, data: JSON.stringify(data), field: JSON.stringify(field || {}) }, 'POST'); | ||
}; | ||
@@ -65,3 +71,3 @@ // 设置双面打印 | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件地址或者文件流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
@@ -73,3 +79,3 @@ Report.prototype.ExportToPdf = function (fileName) { | ||
else { | ||
return this.OperateEx('ExportToPdfStream', null, "GET"); | ||
return this.OperateEx('ExportToPdfStream', null, 'GET'); | ||
} | ||
@@ -76,0 +82,0 @@ }; |
@@ -6,3 +6,12 @@ export default class Report { | ||
clearData(): Promise<any>; | ||
registerData(name: string, data: Array<any>): Promise<any>; | ||
/** | ||
* 注册数据源 | ||
* @param name 数据源名称 | ||
* @param data 数据 | ||
* @param field 指定字段对应类型 默认所有字段类型为string | ||
* 可指定 string|bool|date|datetime|decimal|double|float|int|long|object|short | ||
* 格式: {"id":"string","flag":"int","birthday":"date","total":"decimal"} | ||
* @returns | ||
*/ | ||
registerData(name: string, data: Array<any>, field: object): Promise<any>; | ||
doublePass(value: Boolean): Promise<any>; | ||
@@ -14,3 +23,3 @@ load(fileName: string): Promise<any>; | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件地址或者文件流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
@@ -17,0 +26,0 @@ ExportToPdf(fileName: string): Promise<any>; |
{ | ||
"name": "@icreate/ics-chromely-plugin-report-js-sdk", | ||
"version": "0.0.8", | ||
"version": "0.0.9-beta.1", | ||
"description": "提供报表设计、清空、预览、打印、注册数据源等功能", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
<!-- | ||
* @Author: 文贝 | ||
* @Date: 2022-02-08 21:36:57 | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-09-15 13:25:42 | ||
* @LastEditors: 陶慧灵 | ||
* @LastEditTime: 2022-12-13 13:39:23 | ||
* @Descripttion: | ||
@@ -17,2 +17,6 @@ * @FilePath: \ics-chromely-plugin-report\README.md | ||
``` | ||
0.0.9-beta.1 注册数据源时允许指定字段类型 | ||
0.0.9 优化和完善导出pdf流 | ||
0.0.8-beta.1 增加导出pdf流示例 | ||
0.0.8 增加导出pdf流支持 | ||
0.0.7 修复打印和准备打印方法调用不传打印机名称时使用默认打印机 | ||
@@ -63,3 +67,3 @@ 0.0.6 修改print和printPrepared的printerName允许为空 | ||
printPrepared(printerName?: string): Promise<any> | ||
// 导出pdf | ||
// 导出pdf:文件名称,如果不传则返回流 | ||
ExportToPdf(fileName: string): Promise<any> | ||
@@ -76,4 +80,4 @@ // 导出html | ||
const reportHelper = new ReportHelper() | ||
await reportHelper.clearData() | ||
await reportHelper.load('xxxx.frx') | ||
await reportHelper.clearData() | ||
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}]) | ||
@@ -86,2 +90,35 @@ await reportHelper.design() //设计报表 | ||
### 指定字段类型示例 | ||
```javascript | ||
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 或 False | FALSE | | ||
| byte | 8 位无符号整数 | 0 到 255 | 0 | | ||
| char | 16 位 Unicode 字符 | U +0000 到 U +ffff | '\\0' | | ||
| decimal | 128 位精确的十进制值,28-29 有效位数 | (-7.9 x 1028 到 7.9 x 1028) / 100 到 28 | 0.0M | | ||
| double | 64 位双精度浮点型 | (+/-)5.0 x 10-324 到 (+/-)1.7 x 10308 | 0.0D | | ||
| float | 32 位单精度浮点型 | -3.4 x 1038 到 + 3.4 x 1038 | 0.0F | | ||
| int | 32 位有符号整数类型 | -2,147,483,648 到 2,147,483,647 | 0 | | ||
| long | 64 位有符号整数类型 | -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 | 0L | | ||
| sbyte | 8 位有符号整数类型 | -128 到 127 | 0 | | ||
| short | 16 位有符号整数类型 | -32,768 到 32,767 | 0 | | ||
| uint | 32 位无符号整数类型 | 0 到 4,294,967,295 | 0 | | ||
| ulong | 64 位无符号整数类型 | 0 到 18,446,744,073,709,551,615 | 0 | | ||
| ushort | 16 位无符号整数类型 | 0 到 65,535 | 0 | | ||
### 合并打印示例 | ||
@@ -92,9 +129,9 @@ | ||
//加载报表1 | ||
await reportHelper.clearData() | ||
await reportHelper.load('xxxx.frx') | ||
await reportHelper.clearData() | ||
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}]) | ||
await reportHelper.prepare(false) | ||
//加载报表2 | ||
await reportHelper.clearData() | ||
await reportHelper.load('xxxx.frx') | ||
await reportHelper.clearData() | ||
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"李四"}]) | ||
@@ -105,1 +142,19 @@ await reportHelper.prepare(true) | ||
``` | ||
### 导出pdf流示例 | ||
```javascript | ||
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') | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43866
423
155