@icreate/ics-chromely-plugin-report-js-sdk
Advanced tools
Comparing version 0.0.7 to 0.0.8-beta.1
@@ -33,4 +33,5 @@ import icsChromelyRequest from '@icreate/ics-chromely-js-sdk'; | ||
} | ||
Report.prototype.OperateEx = function (url, data, method) { | ||
Report.prototype.OperateEx = function (url, data, method, headers) { | ||
if (method === void 0) { method = 'GET'; } | ||
if (headers === void 0) { headers = {}; } | ||
// let opts = | ||
@@ -40,3 +41,4 @@ return icsChromelyRequest.function({ | ||
method: method, | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }) | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }), | ||
headers: headers, | ||
}); | ||
@@ -64,5 +66,14 @@ }; | ||
}; | ||
// 导出pdf | ||
/** | ||
* 导出pdf | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
Report.prototype.ExportToPdf = function (fileName) { | ||
return this.OperateEx('ExportToPdf', { fileName: fileName }); | ||
if (fileName) { | ||
return this.OperateEx('ExportToPdf', { fileName: fileName }); | ||
} | ||
else { | ||
return this.OperateEx('ExportToPdfStream', null, "GET"); | ||
} | ||
}; | ||
@@ -69,0 +80,0 @@ // 导出html |
@@ -41,4 +41,5 @@ (function (global, factory) { | ||
} | ||
Report.prototype.OperateEx = function (url, data, method) { | ||
Report.prototype.OperateEx = function (url, data, method, headers) { | ||
if (method === void 0) { method = 'GET'; } | ||
if (headers === void 0) { headers = {}; } | ||
// let opts = | ||
@@ -48,3 +49,4 @@ return icsChromelyRequest__default["default"].function({ | ||
method: method, | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }) | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }), | ||
headers: headers, | ||
}); | ||
@@ -72,5 +74,14 @@ }; | ||
}; | ||
// 导出pdf | ||
/** | ||
* 导出pdf | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
Report.prototype.ExportToPdf = function (fileName) { | ||
return this.OperateEx('ExportToPdf', { fileName: fileName }); | ||
if (fileName) { | ||
return this.OperateEx('ExportToPdf', { fileName: fileName }); | ||
} | ||
else { | ||
return this.OperateEx('ExportToPdfStream', null, "GET"); | ||
} | ||
}; | ||
@@ -77,0 +88,0 @@ // 导出html |
@@ -17,4 +17,4 @@ "use strict"; | ||
* @Date: 2022-05-06 15:04:22 | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-09-15 13:19:05 | ||
* @LastEditors: 陶慧灵 | ||
* @LastEditTime: 2022-12-12 13:56:11 | ||
* @Description: | ||
@@ -28,4 +28,5 @@ * @FilePath: \ics-chromely-plugin-report\src\core\report.ts | ||
} | ||
Report.prototype.OperateEx = function (url, data, method) { | ||
Report.prototype.OperateEx = function (url, data, method, headers) { | ||
if (method === void 0) { method = 'GET'; } | ||
if (headers === void 0) { headers = {}; } | ||
// let opts = | ||
@@ -35,3 +36,4 @@ return ics_chromely_js_sdk_1.default.function({ | ||
method: method, | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }) | ||
data: __assign(__assign({}, data), { instanceId: this.instanceId }), | ||
headers: headers, | ||
}); | ||
@@ -59,5 +61,14 @@ }; | ||
}; | ||
// 导出pdf | ||
/** | ||
* 导出pdf | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
Report.prototype.ExportToPdf = function (fileName) { | ||
return this.OperateEx('ExportToPdf', { fileName: fileName }); | ||
if (fileName) { | ||
return this.OperateEx('ExportToPdf', { fileName: fileName }); | ||
} | ||
else { | ||
return this.OperateEx('ExportToPdfStream', null, "GET"); | ||
} | ||
}; | ||
@@ -64,0 +75,0 @@ // 导出html |
@@ -10,2 +10,7 @@ export default class Report { | ||
loadFromId(reportId: string): Promise<any>; | ||
/** | ||
* 导出pdf | ||
* @param fileName 文件名称,如果不传则返回流 | ||
* @returns 文件或者文件流 | ||
*/ | ||
ExportToPdf(fileName: string): Promise<any>; | ||
@@ -12,0 +17,0 @@ exportToHtml(fileName: string): Promise<any>; |
{ | ||
"name": "@icreate/ics-chromely-plugin-report-js-sdk", | ||
"version": "0.0.7", | ||
"version": "0.0.8-beta.1", | ||
"description": "提供报表设计、清空、预览、打印、注册数据源等功能", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
<!-- | ||
* @Author: 文贝 | ||
* @Date: 2022-02-08 21:36:57 | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-09-08 18:31:40 | ||
* @LastEditors: 陶慧灵 | ||
* @LastEditTime: 2022-12-12 14:14:20 | ||
* @Descripttion: | ||
@@ -17,2 +17,5 @@ * @FilePath: \ics-chromely-plugin-report\README.md | ||
``` | ||
0.0.8-beta.1 增加导出pdf流示例 | ||
0.0.8 增加导出pdf流支持 | ||
0.0.7 修复打印和准备打印方法调用不传打印机名称时使用默认打印机 | ||
0.0.6 修改print和printPrepared的printerName允许为空 | ||
@@ -62,3 +65,3 @@ 0.0.5 增加打印准备报表printPrepared | ||
printPrepared(printerName?: string): Promise<any> | ||
// 导出pdf | ||
// 导出pdf:文件名称,如果不传则返回流 | ||
ExportToPdf(fileName: string): Promise<any> | ||
@@ -75,4 +78,4 @@ // 导出html | ||
const reportHelper = new ReportHelper() | ||
await reportHelper.clearData() | ||
await reportHelper.load('xxxx.frx') | ||
await reportHelper.clearData() | ||
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}]) | ||
@@ -90,9 +93,9 @@ await reportHelper.design() //设计报表 | ||
//加载报表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:"李四"}]) | ||
@@ -103,1 +106,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
39999
396
120