@icreate/ics-chromely-plugin-report-js-sdk
Advanced tools
Comparing version 0.0.9-beta.4 to 0.0.9-beta.5
@@ -0,1 +1,2 @@ | ||
import '@icreate/core'; | ||
import icsChromelyRequest from '@icreate/ics-chromely-js-sdk'; | ||
@@ -29,2 +30,115 @@ | ||
var Chromely$1 = /** @class */ (function () { | ||
function Chromely() { | ||
this._callbacks = {}; | ||
var isNode = typeof window === 'undefined'; | ||
this.isChromely = isNode ? false : !!window['CefSharp']; | ||
this.cefSharp = isNode ? { PostMessage: function () { } } : window['CefSharp']; | ||
this.baseUrl = isNode ? '' : window['Chromely'] ? window['Chromely']['baseUrl'] : ''; | ||
this.tokenId = isNode ? '' : window['Chromely'] ? window['Chromely']['tokenId'] : ''; | ||
this.headers = isNode ? '' : window['Chromely'] ? window['Chromely']['headers'] : {}; | ||
} | ||
/** | ||
* 获取 Chromely 实例 | ||
* @returns {IChromely} | ||
*/ | ||
Chromely.getInstance = function () { | ||
if (window['Chromely'] == null || window['Chromely']['cefSharp'] == null) { | ||
window['Chromely'] = new Chromely(); | ||
} | ||
return window['Chromely']; | ||
}; | ||
/** | ||
* 接受cef分发事件,触发容器中的该属性eventName的回调函数 | ||
* @param {*} eventName 事件名称 | ||
* @param {*} data 数据 | ||
*/ | ||
Chromely.prototype.$onReceive = function (message) { | ||
var _a = JSON.parse(message), eventName = _a.eventName, data = _a.data; | ||
var callbacks = this._callbacks[eventName]; | ||
if (!callbacks || !callbacks.length) { | ||
return; | ||
} | ||
for (var i = 0; i < callbacks.length; i++) { | ||
callbacks[i](data); | ||
} | ||
}; | ||
/** | ||
* @description:订阅C#事件 | ||
* @param {string} eventName | ||
* @param {Function} callback | ||
* @return {void} | ||
*/ | ||
Chromely.prototype.$on = function (eventName, callback) { | ||
if (!this._callbacks[eventName]) { | ||
this._callbacks[eventName] = []; | ||
} | ||
this._callbacks[eventName].push(callback); | ||
}; | ||
/** | ||
* @description: 取消C#订阅事件 | ||
* @param {string} eventName | ||
* @param {Function} callback | ||
* @return {void} | ||
*/ | ||
Chromely.prototype.$off = function (eventName, callback) { | ||
var callbacks = this._callbacks[eventName]; | ||
if (!callbacks) { | ||
return; | ||
} | ||
var index = -1; | ||
for (var i = 0; i < callbacks.length; i++) { | ||
if (callbacks[i] === callback) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
if (index < 0) { | ||
return; | ||
} | ||
this._callbacks[eventName].splice(index, 1); | ||
}; | ||
/** | ||
* @description: 触发C#事件 | ||
* @param {string} eventName | ||
* @return {void} | ||
*/ | ||
Chromely.prototype.$emit = function (eventName, data) { | ||
if (this.isChromely) { | ||
this.cefSharp.PostMessage(JSON.stringify({ eventName: eventName, data: data })); | ||
} | ||
}; | ||
return Chromely; | ||
}()); | ||
var Duplex; | ||
(function (Duplex) { | ||
// | ||
// 摘要: | ||
// The printer's default duplex setting. | ||
Duplex[Duplex["Default"] = -1] = "Default"; | ||
// | ||
// 摘要: | ||
// Single-sided printing. | ||
Duplex[Duplex["Simplex"] = 1] = "Simplex"; | ||
// | ||
// 摘要: | ||
// Double-sided, vertical printing. | ||
Duplex[Duplex["Vertical"] = 2] = "Vertical"; | ||
// | ||
// 摘要: | ||
// Double-sided, horizontal printing. | ||
Duplex[Duplex["Horizontal"] = 3] = "Horizontal"; | ||
})(Duplex || (Duplex = {})); | ||
/* | ||
* @Author: 文贝 | ||
* @Date: 2022-02-11 23:21:34 | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-10-30 21:33:43 | ||
* @Descripttion: | ||
* @FilePath: \ics-chromely-plugin-core\src\ics-chromely-plugin-core.ts | ||
*/ | ||
var Chromely = Chromely$1.getInstance(); | ||
var Report = /** @class */ (function () { | ||
@@ -97,6 +211,28 @@ function Report() { | ||
}; | ||
// 设计报表 | ||
Report.prototype.design = function () { | ||
return this.OperateEx('Design'); | ||
/** | ||
* 获取报表内容 | ||
* @returns 报表内容 | ||
*/ | ||
Report.prototype.content = function () { | ||
return this.OperateEx('Content'); | ||
}; | ||
/** | ||
* 设计报表 | ||
* @param saveAction 保存回调 | ||
* @returns | ||
*/ | ||
Report.prototype.design = function (saveAction) { | ||
var _this = this; | ||
if (saveAction) { | ||
Chromely.$on('on-report-save-click', function (data) { | ||
if (data.instanceId === _this.instanceId) { | ||
saveAction(data); | ||
} | ||
}); | ||
return this.OperateEx('Design', { customSave: true }); | ||
} | ||
else { | ||
return this.OperateEx('Design'); | ||
} | ||
}; | ||
// 预览报表 | ||
@@ -103,0 +239,0 @@ Report.prototype.show = function (printerName, showPrintSettings, closeAfterPrint) { |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@icreate/ics-chromely-js-sdk')) : | ||
typeof define === 'function' && define.amd ? define(['@icreate/ics-chromely-js-sdk'], factory) : | ||
(global.icsChromelyPluginReportJsSdk = factory(global.icsChromelyRequest)); | ||
}(this, (function (icsChromelyRequest) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@icreate/core'), require('@icreate/ics-chromely-js-sdk')) : | ||
typeof define === 'function' && define.amd ? define(['@icreate/core', '@icreate/ics-chromely-js-sdk'], factory) : | ||
(global.icsChromelyPluginReportJsSdk = factory(global.core,global.icsChromelyRequest)); | ||
}(this, (function (core,icsChromelyRequest) { 'use strict'; | ||
@@ -35,2 +35,115 @@ icsChromelyRequest = icsChromelyRequest && icsChromelyRequest.hasOwnProperty('default') ? icsChromelyRequest['default'] : icsChromelyRequest; | ||
var Chromely$1 = /** @class */ (function () { | ||
function Chromely() { | ||
this._callbacks = {}; | ||
var isNode = typeof window === 'undefined'; | ||
this.isChromely = isNode ? false : !!window['CefSharp']; | ||
this.cefSharp = isNode ? { PostMessage: function () { } } : window['CefSharp']; | ||
this.baseUrl = isNode ? '' : window['Chromely'] ? window['Chromely']['baseUrl'] : ''; | ||
this.tokenId = isNode ? '' : window['Chromely'] ? window['Chromely']['tokenId'] : ''; | ||
this.headers = isNode ? '' : window['Chromely'] ? window['Chromely']['headers'] : {}; | ||
} | ||
/** | ||
* 获取 Chromely 实例 | ||
* @returns {IChromely} | ||
*/ | ||
Chromely.getInstance = function () { | ||
if (window['Chromely'] == null || window['Chromely']['cefSharp'] == null) { | ||
window['Chromely'] = new Chromely(); | ||
} | ||
return window['Chromely']; | ||
}; | ||
/** | ||
* 接受cef分发事件,触发容器中的该属性eventName的回调函数 | ||
* @param {*} eventName 事件名称 | ||
* @param {*} data 数据 | ||
*/ | ||
Chromely.prototype.$onReceive = function (message) { | ||
var _a = JSON.parse(message), eventName = _a.eventName, data = _a.data; | ||
var callbacks = this._callbacks[eventName]; | ||
if (!callbacks || !callbacks.length) { | ||
return; | ||
} | ||
for (var i = 0; i < callbacks.length; i++) { | ||
callbacks[i](data); | ||
} | ||
}; | ||
/** | ||
* @description:订阅C#事件 | ||
* @param {string} eventName | ||
* @param {Function} callback | ||
* @return {void} | ||
*/ | ||
Chromely.prototype.$on = function (eventName, callback) { | ||
if (!this._callbacks[eventName]) { | ||
this._callbacks[eventName] = []; | ||
} | ||
this._callbacks[eventName].push(callback); | ||
}; | ||
/** | ||
* @description: 取消C#订阅事件 | ||
* @param {string} eventName | ||
* @param {Function} callback | ||
* @return {void} | ||
*/ | ||
Chromely.prototype.$off = function (eventName, callback) { | ||
var callbacks = this._callbacks[eventName]; | ||
if (!callbacks) { | ||
return; | ||
} | ||
var index = -1; | ||
for (var i = 0; i < callbacks.length; i++) { | ||
if (callbacks[i] === callback) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
if (index < 0) { | ||
return; | ||
} | ||
this._callbacks[eventName].splice(index, 1); | ||
}; | ||
/** | ||
* @description: 触发C#事件 | ||
* @param {string} eventName | ||
* @return {void} | ||
*/ | ||
Chromely.prototype.$emit = function (eventName, data) { | ||
if (this.isChromely) { | ||
this.cefSharp.PostMessage(JSON.stringify({ eventName: eventName, data: data })); | ||
} | ||
}; | ||
return Chromely; | ||
}()); | ||
var Duplex; | ||
(function (Duplex) { | ||
// | ||
// 摘要: | ||
// The printer's default duplex setting. | ||
Duplex[Duplex["Default"] = -1] = "Default"; | ||
// | ||
// 摘要: | ||
// Single-sided printing. | ||
Duplex[Duplex["Simplex"] = 1] = "Simplex"; | ||
// | ||
// 摘要: | ||
// Double-sided, vertical printing. | ||
Duplex[Duplex["Vertical"] = 2] = "Vertical"; | ||
// | ||
// 摘要: | ||
// Double-sided, horizontal printing. | ||
Duplex[Duplex["Horizontal"] = 3] = "Horizontal"; | ||
})(Duplex || (Duplex = {})); | ||
/* | ||
* @Author: 文贝 | ||
* @Date: 2022-02-11 23:21:34 | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-10-30 21:33:43 | ||
* @Descripttion: | ||
* @FilePath: \ics-chromely-plugin-core\src\ics-chromely-plugin-core.ts | ||
*/ | ||
var Chromely = Chromely$1.getInstance(); | ||
var Report = /** @class */ (function () { | ||
@@ -103,6 +216,28 @@ function Report() { | ||
}; | ||
// 设计报表 | ||
Report.prototype.design = function () { | ||
return this.OperateEx('Design'); | ||
/** | ||
* 获取报表内容 | ||
* @returns 报表内容 | ||
*/ | ||
Report.prototype.content = function () { | ||
return this.OperateEx('Content'); | ||
}; | ||
/** | ||
* 设计报表 | ||
* @param saveAction 保存回调 | ||
* @returns | ||
*/ | ||
Report.prototype.design = function (saveAction) { | ||
var _this = this; | ||
if (saveAction) { | ||
Chromely.$on('on-report-save-click', function (data) { | ||
if (data.instanceId === _this.instanceId) { | ||
saveAction(data); | ||
} | ||
}); | ||
return this.OperateEx('Design', { customSave: true }); | ||
} | ||
else { | ||
return this.OperateEx('Design'); | ||
} | ||
}; | ||
// 预览报表 | ||
@@ -109,0 +244,0 @@ Report.prototype.show = function (printerName, showPrintSettings, closeAfterPrint) { |
@@ -23,2 +23,3 @@ "use strict"; | ||
var ics_chromely_js_sdk_1 = require("@icreate/ics-chromely-js-sdk"); | ||
var ics_chromely_plugin_core_1 = require("@icreate/ics-chromely-plugin-core"); | ||
var Report = /** @class */ (function () { | ||
@@ -91,6 +92,28 @@ function Report() { | ||
}; | ||
// 设计报表 | ||
Report.prototype.design = function () { | ||
return this.OperateEx('Design'); | ||
/** | ||
* 获取报表内容 | ||
* @returns 报表内容 | ||
*/ | ||
Report.prototype.content = function () { | ||
return this.OperateEx('Content'); | ||
}; | ||
/** | ||
* 设计报表 | ||
* @param saveAction 保存回调 | ||
* @returns | ||
*/ | ||
Report.prototype.design = function (saveAction) { | ||
var _this = this; | ||
if (saveAction) { | ||
ics_chromely_plugin_core_1.Chromely.$on('on-report-save-click', function (data) { | ||
if (data.instanceId === _this.instanceId) { | ||
saveAction(data); | ||
} | ||
}); | ||
return this.OperateEx('Design', { customSave: true }); | ||
} | ||
else { | ||
return this.OperateEx('Design'); | ||
} | ||
}; | ||
// 预览报表 | ||
@@ -97,0 +120,0 @@ Report.prototype.show = function (printerName, showPrintSettings, closeAfterPrint) { |
@@ -28,3 +28,13 @@ export default class Report { | ||
addParameter(name: string, value: string): Promise<any>; | ||
design(): Promise<any>; | ||
/** | ||
* 获取报表内容 | ||
* @returns 报表内容 | ||
*/ | ||
content(): Promise<any>; | ||
/** | ||
* 设计报表 | ||
* @param saveAction 保存回调 | ||
* @returns | ||
*/ | ||
design(saveAction: Function): Promise<any>; | ||
show(printerName?: string, showPrintSettings?: boolean, closeAfterPrint?: boolean): Promise<any>; | ||
@@ -31,0 +41,0 @@ showPrepared(printerName?: string, showPrintSettings?: boolean, closeAfterPrint?: boolean): Promise<any>; |
{ | ||
"name": "@icreate/ics-chromely-plugin-report-js-sdk", | ||
"version": "0.0.9-beta.4", | ||
"version": "0.0.9-beta.5", | ||
"description": "提供报表设计、清空、预览、打印、注册数据源等功能", | ||
@@ -123,4 +123,4 @@ "keywords": [], | ||
"@icreate/core": "^0.0.15", | ||
"@icreate/ics-chromely-plugin-report-js-sdk": "^0.0.9-beta.3" | ||
"@icreate/ics-chromely-plugin-core": "^0.0.20-beta.11" | ||
} | ||
} |
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
82332
762