UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

945 lines (938 loc) 28.2 kB
import { Injectable, ɵɵdefineInjectable, ɵɵinject, NgModule } from '@angular/core'; import { LazyService, OhayoConfigService, OhayoUtilModule } from '@ohayojp.com/util'; import { Subject, of } from 'rxjs'; /** * @fileoverview added by tsickle * Generated from: lodop.types.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function CLodop() { } if (false) { /** * 判断是否支持https协议的属性 * * - 0 不支持 * - 1 支持 * - 2 支持且已启动(https服务需单独启动) * @type {?} */ CLodop.prototype.HTTPS_STATUS; /** * 结果回调函数保留 * @type {?} */ CLodop.prototype.On_Return_Remain; /** * 结果回调函数 * @type {?} */ CLodop.prototype.On_Return; /** * 建立打印机名单 * @param {?} el * @return {?} */ CLodop.prototype.Create_Printer_List = function (el) { }; /** * 建立纸张类型名单 * @param {?} el * @param {?} iPrintIndex * @return {?} */ CLodop.prototype.Create_PageSize_List = function (el, iPrintIndex) { }; } /** * @record */ function Lodop() { } if (false) { /** * 获得软件版本号 * @type {?} */ Lodop.prototype.VERSION; /** @type {?} */ Lodop.prototype.webskt; /* Skipping unhandled member: [key: string]: any;*/ /** * 打印初始化。初始化运行环境,清理异常打印遗留的系统资源,设定打印任务名。 * * **建议或要求:**该函数与PRINT_INITA都有初始化功能,每个打印事务至少初始化一次,建议打印程序首先调用该函数。任务名要尽量区别于其它打印任务,譬如用“XX单位_XX管理信息系统_XX子系统_XX模块_XX打印作业”字样。 * 不希望最终用户更改打印布局时,则设strTaskName空。 * * @param {?} strTaskName 打印任务名 * @return {?} 返回逻辑真表示初始化成功,逻辑假表示初始化失败,失败原因有:前一个打印事务没有完成;操作系统没有添加打印机(驱动)等 */ Lodop.prototype.PRINT_INIT = function (strTaskName) { }; /** * 设定纸张大小 * @param {?} intOrient * @param {?} PageWidth * @param {?} PageHeight * @param {?} strPageName * @return {?} */ Lodop.prototype.SET_PRINT_PAGESIZE = function (intOrient, PageWidth, PageHeight, strPageName) { }; /** * 增加超文本打印项(普通模式) * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strHtmlContent * @return {?} */ Lodop.prototype.ADD_PRINT_HTM = function (Top, Left, Width, Height, strHtmlContent) { }; /** * 增加表格打印项(超文本模式) * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strHtml * @return {?} */ Lodop.prototype.ADD_PRINT_TABLE = function (Top, Left, Width, Height, strHtml) { }; /** * 增加表格打印项(超文本模式) * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strHtml * @return {?} */ Lodop.prototype.ADD_PRINT_TABLE = function (Top, Left, Width, Height, strHtml) { }; /** * 增加超文本打印项(URL模式) * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strURL * @return {?} */ Lodop.prototype.ADD_PRINT_URL = function (Top, Left, Width, Height, strURL) { }; /** * 增加纯文本打印项 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strContent * @return {?} */ Lodop.prototype.ADD_PRINT_TEXT = function (Top, Left, Width, Height, strContent) { }; /** * 增加图片打印项 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strHtmlContent * @return {?} */ Lodop.prototype.ADD_PRINT_IMAGE = function (Top, Left, Width, Height, strHtmlContent) { }; /** * 增加矩形线 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} intLineStyle * @param {?} intLineWidth * @return {?} */ Lodop.prototype.ADD_PRINT_RECT = function (Top, Left, Width, Height, intLineStyle, intLineWidth) { }; /** * 增加椭圆线 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} intLineStyle * @param {?} intLineWidth * @return {?} */ Lodop.prototype.ADD_PRINT_ELLIPSE = function (Top, Left, Width, Height, intLineStyle, intLineWidth) { }; /** * 增加直线 * @param {?} Top1 * @param {?} Left1 * @param {?} Top2 * @param {?} Left2 * @param {?} intLineStyle * @param {?} intLineWidth * @return {?} */ Lodop.prototype.ADD_PRINT_LINE = function (Top1, Left1, Top2, Left2, intLineStyle, intLineWidth) { }; /** * 增加条形码 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} CodeType * @param {?} CodeValue * @return {?} */ Lodop.prototype.ADD_PRINT_BARCODE = function (Top, Left, Width, Height, CodeType, CodeValue) { }; /** * 增加图表 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} ChartType * @param {?} strHtml * @return {?} */ Lodop.prototype.ADD_PRINT_CHART = function (Top, Left, Width, Height, ChartType, strHtml) { }; /** * 装载文档式模板 * @param {?} strDataStyle * @param {?} varDataValue * @return {?} */ Lodop.prototype.ADD_PRINT_DATA = function (strDataStyle, varDataValue) { }; /** * 设置打印项风格 * @param {?} strStyleName * @param {?} varStyleValue * @return {?} */ Lodop.prototype.SET_PRINT_STYLE = function (strStyleName, varStyleValue) { }; /** * 打印预览 * @return {?} */ Lodop.prototype.PREVIEW = function () { }; /** * 直接打印 * @return {?} */ Lodop.prototype.PRINT = function () { }; /** * 打印维护 * @return {?} */ Lodop.prototype.PRINT_SETUP = function () { }; /** * 打印设计 * @return {?} */ Lodop.prototype.PRINT_DESIGN = function () { }; /** * 强制分页 * @return {?} */ Lodop.prototype.NEWPAGE = function () { }; /** * 获得打印设备个数 * @return {?} */ Lodop.prototype.GET_PRINTER_COUNT = function () { }; /** * 获得打印设备名称 * @param {?} strPrinterIDandType * @return {?} */ Lodop.prototype.GET_PRINTER_NAME = function (strPrinterIDandType) { }; /** * 指定打印设备 * @param {?} oIndexOrName * @return {?} */ Lodop.prototype.SET_PRINTER_INDEX = function (oIndexOrName) { }; /** * 【CLodop】指定打印机 * @param {?} DriverIndex * @param {?} PrinterIDandName * @param {?} SubDevIndex * @return {?} */ Lodop.prototype.SET_PRINTER_INDEX = function (DriverIndex, PrinterIDandName, SubDevIndex) { }; /** * 选择打印设备 * @return {?} */ Lodop.prototype.SELECT_PRINTER = function () { }; /** * 设置显示模式 * @param {?} strModeType * @param {?} varModeValue * @return {?} */ Lodop.prototype.SET_SHOW_MODE = function (strModeType, varModeValue) { }; /** * 设置打印模式 * @param {?} strModeType * @param {?} varModeValue * @return {?} */ Lodop.prototype.SET_PRINT_MODE = function (strModeType, varModeValue) { }; /** * 设置打印份数 * @param {?} intCopies * @return {?} */ Lodop.prototype.SET_PRINT_COPIES = function (intCopies) { }; /** * 设置预览窗口 * @param {?} intDispMode * @param {?} intToolMode * @param {?} blDirectPrint * @param {?} inWidth * @param {?} intHeight * @param {?} strTitleButtonCaptoin * @return {?} */ Lodop.prototype.SET_PREVIEW_WINDOW = function (intDispMode, intToolMode, blDirectPrint, inWidth, intHeight, strTitleButtonCaptoin) { }; /** * 指定背景图 * @param {?} strImgHtml * @return {?} */ Lodop.prototype.ADD_PRINT_SETUP_BKIMG = function (strImgHtml) { }; /** * 发送原始数据 * @param {?} strRawData * @return {?} */ Lodop.prototype.SEND_PRINT_RAWDATA = function (strRawData) { }; /** * 写端口数据 * @param {?} strPortName * @param {?} strData * @return {?} */ Lodop.prototype.WRITE_PORT_DATA = function (strPortName, strData) { }; /** * 读端口数据 * @param {?} strPortName * @return {?} */ Lodop.prototype.READ_PORT_DATA = function (strPortName) { }; /** * 获得配置文件名 * @param {?} strPrintTask * @return {?} */ Lodop.prototype.GET_PRINT_INIFFNAME = function (strPrintTask) { }; /** * 获得纸张类型名清单 * @param {?} oPrinterName * @param {?} strSplit * @return {?} */ Lodop.prototype.GET_PAGESIZES_LIST = function (oPrinterName, strSplit) { }; /** * 写本地文件内容 * @param {?} intWriteMode * @param {?} strFileName * @param {?} strText * @return {?} */ Lodop.prototype.WRITE_FILE_TEXT = function (intWriteMode, strFileName, strText) { }; /** * 读本地文件内容 * @param {?} strFileName * @return {?} */ Lodop.prototype.GET_FILE_TEXT = function (strFileName) { }; /** * 读本地文件时间 * @param {?} strFileName * @return {?} */ Lodop.prototype.GET_FILE_TIME = function (strFileName) { }; /** * 判断本地文件是否存在 * @param {?} strFileName * @return {?} */ Lodop.prototype.IS_FILE_EXIST = function (strFileName) { }; /** * 获得系统信息 * @param {?} strInfoType * @return {?} */ Lodop.prototype.GET_SYSTEM_INFO = function (strInfoType) { }; /** * 获得数据值 * @param {?} ValueType * @param {?} ValueIndex * @return {?} */ Lodop.prototype.GET_VALUE = function (ValueType, ValueIndex) { }; /** * 数据格式转换 * @param {?} oType * @param {?} oValue * @return {?} */ Lodop.prototype.FORMAT = function (oType, oValue) { }; /** * 获得对话框结果值 * @param {?} oType * @param {?} oPreValue * @return {?} */ Lodop.prototype.GET_DIALOG_VALUE = function (oType, oPreValue) { }; /** * (增强型)打印初始化 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strPrintName * @return {?} */ Lodop.prototype.PRINT_INITA = function (Top, Left, Width, Height, strPrintName) { }; /** * (增强型)增加超文本打印项(图形模式) * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strHtmlContent * @return {?} */ Lodop.prototype.ADD_PRINT_HTML = function (Top, Left, Width, Height, strHtmlContent) { }; /** * (增强型)增加表格打印项(URL模式) * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strURL * @return {?} */ Lodop.prototype.ADD_PRINT_TBURL = function (Top, Left, Width, Height, strURL) { }; /** * (增强型)增加纯文本打印项 * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} strContent * @return {?} */ Lodop.prototype.ADD_PRINT_TEXTA = function (Top, Left, Width, Height, strContent) { }; /** * (增强型)设置打印项风格A, 继承 `SET_PRINT_STYLE` 的所有属性 * @param {?} varItemNameID * @param {?} strStyleName * @param {?} varStyleValue * @return {?} */ Lodop.prototype.SET_PRINT_STYLEA = function (varItemNameID, strStyleName, varStyleValue) { }; /** * (增强型)导出数据到文件 * @param {?} strFileName * @return {?} */ Lodop.prototype.SAVE_TO_FILE = function (strFileName) { }; /** * (增强型)设置保存模式 * @param {?} varModeName * @param {?} varModeValue * @return {?} */ Lodop.prototype.SET_SAVE_MODE = function (varModeName, varModeValue) { }; /** * (增强型)增加图形 * @param {?} intShapeType * @param {?} Top * @param {?} Left * @param {?} Width * @param {?} Height * @param {?} intLineStyle * @param {?} intLineWidth * @param {?} varColor * @return {?} */ Lodop.prototype.ADD_PRINT_SHAPE = function (intShapeType, Top, Left, Width, Height, intLineStyle, intLineWidth, varColor) { }; /** * (增强型)指定打印设备 * @param {?} oIndexOrName * @return {?} */ Lodop.prototype.SET_PRINTER_INDEXA = function (oIndexOrName) { }; /** * (增强型)强制分页 * @return {?} */ Lodop.prototype.NEWPAGEA = function () { }; /** * (增强型)打印预览A * @return {?} */ Lodop.prototype.PREVIEWA = function () { }; /** * (增强型)打印预览B * @return {?} */ Lodop.prototype.PREVIEWB = function () { }; /** * 直接打印A * @return {?} */ Lodop.prototype.PRINTA = function () { }; /** * 直接打印B * @return {?} */ Lodop.prototype.PRINTB = function () { }; /** * 显示图表 * @return {?} */ Lodop.prototype.SHOW_CHART = function () { }; /** * 控制界面动作 * @param {?} ActName * @param {?} ActValue * @return {?} */ Lodop.prototype.DO_ACTION = function (ActName, ActValue) { }; /** * 设置软件产品注册信息 * * @param {?} strCompanyName 注册单位名称,用途与控件参数CompanyName一样。 * @param {?} strLicense 主注册号,用途与控件参数License一样。 * @param {?=} strLicenseA 附加注册号A,用途与控件参数LicenseA一样。 * @param {?=} strLicenseB 附加注册号B,用途与控件参数LicenseB一样。 * @return {?} */ Lodop.prototype.SET_LICENSES = function (strCompanyName, strLicense, strLicenseA, strLicenseB) { }; } /** * @record */ function LodopResult() { } if (false) { /** * 是否成功 * @type {?} */ LodopResult.prototype.ok; /** * 错误码 * @type {?|undefined} */ LodopResult.prototype.status; /** * 成功时携带 LODOP 对象 * @type {?|undefined} */ LodopResult.prototype.lodop; /** * 错误信息 * @type {?|undefined} */ LodopResult.prototype.error; } /** * @record */ function LodopPrintResult() { } if (false) { /** * 是否成功 * @type {?} */ LodopPrintResult.prototype.ok; /** * 错误信息 * @type {?|undefined} */ LodopPrintResult.prototype.error; /** * 代码 * @type {?} */ LodopPrintResult.prototype.code; /** * 动态参数上下文对象 * @type {?} */ LodopPrintResult.prototype.item; /** * 代码解析表达式 * @type {?|undefined} */ LodopPrintResult.prototype.parser; } /** * @fileoverview added by tsickle * Generated from: lodop.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class LodopService { /** * @param {?} scriptSrv * @param {?} configSrv */ constructor(scriptSrv, configSrv) { this.scriptSrv = scriptSrv; this.pending = false; this._lodop = null; this._init = new Subject(); this._events = new Subject(); this.printBuffer = []; this.defaultConfig = (/** @type {?} */ (configSrv.merge('lodop', { url: '//localhost:8443/CLodopfuncs.js', name: 'CLODOP', companyName: '', checkMaxCount: 100, }))); this.cog = this.defaultConfig; } /** * 获取或重新设置配置 * * **注:**重新设置会倒置重新加载脚本资源 * @return {?} */ get cog() { return this._cog; } /** * @param {?} value * @return {?} */ set cog(value) { this._cog = Object.assign(Object.assign({}, this.defaultConfig), value); } /** * 事件变更通知 * @return {?} */ get events() { return this._events.asObservable(); } /** * 获取 lodop 对象 * @return {?} */ get lodop() { if (this._lodop) return of((/** @type {?} */ ({ ok: true, lodop: this._lodop }))); if (this.pending) return this._init.asObservable(); this.request(); return this._init.asObservable(); } /** * 获取打印机列表 * @return {?} */ get printer() { this.check(); /** @type {?} */ const ret = []; /** @type {?} */ const count = (/** @type {?} */ (this._lodop)).GET_PRINTER_COUNT(); for (let index = 0; index < count; index++) { ret.push((/** @type {?} */ (this._lodop)).GET_PRINTER_NAME(index)); } return ret; } /** * @private * @return {?} */ check() { if (!this._lodop) throw new Error(`请务必先调用 lodop 获取对象`); } /** * @private * @return {?} */ request() { this.pending = true; /** @type {?} */ const url = `${this.cog.url}?name=${this.cog.name}`; /** @type {?} */ let checkMaxCount = (/** @type {?} */ (this.cog.checkMaxCount)); /** @type {?} */ const onResolve = (/** * @param {?} status * @param {?=} error * @return {?} */ (status, error) => { this._init.next({ ok: status === 'ok', status, error, lodop: (/** @type {?} */ (this._lodop)), }); }); /** @type {?} */ const checkStatus = (/** * @return {?} */ () => { --checkMaxCount; if ((/** @type {?} */ (this._lodop)).webskt && (/** @type {?} */ (this._lodop)).webskt.readyState === 1) { onResolve('ok'); } else { if (checkMaxCount < 0) { onResolve('check-limit'); return; } setTimeout((/** * @return {?} */ () => checkStatus()), 100); } }); this.scriptSrv.loadScript(url).then((/** * @param {?} res * @return {?} */ (res) => { if (res.status !== 'ok') { this.pending = false; onResolve('script-load-error', res[0]); return; } /** @type {?} */ const win = (/** @type {?} */ (window)); if (win.hasOwnProperty((/** @type {?} */ (this.cog.name)))) { this._lodop = (/** @type {?} */ (win[(/** @type {?} */ (this.cog.name))])); } if (this._lodop === null) { onResolve('load-variable-name-error', { name: this.cog.name }); return; } this._lodop.SET_LICENSES((/** @type {?} */ (this.cog.companyName)), (/** @type {?} */ (this.cog.license)), this.cog.licenseA, this.cog.licenseB); checkStatus(); })); } /** * 重置 lodop 对象 * @return {?} */ reset() { this._lodop = null; this.pending = false; this.request(); } /** * 附加代码至 `lodop` 对象上,字符串类支持 `{{key}}` 的动态参数 * * **注:** 代码是指打印设计所产生字符串数据 * * @param {?} code 代码 * @param {?=} contextObj 动态参数上下文对象 * @param {?=} parser 自定义解析表达式,默认:`/LODOP\.([^(]+)\(([^\n]+)?\);/i` * @return {?} */ attachCode(code, contextObj, parser) { this.check(); if (!parser) parser = /LODOP\.([^(]+)\(([^\n]+)?\);/i; code.split('\n').forEach((/** * @param {?} line * @return {?} */ line => { /** @type {?} */ const res = (/** @type {?} */ (parser)).exec(line.trim()); if (!res) return; /** @type {?} */ const fn = (/** @type {?} */ (this._lodop))[res[1]]; if (fn) { /** @type {?} */ let arr = null; try { // tslint:disable-next-line: function-constructor /** @type {?} */ const fakeFn = new Function(`return [${res[2]}]`); arr = fakeFn(); } catch (_a) { } if (arr != null && Array.isArray(arr) && contextObj) { for (let i = 0; i < arr.length; i++) { if (typeof arr[i] === 'string') { arr[i] = ((/** @type {?} */ (arr[i]))).replace(/{{(.*?)}}/g, (/** * @param {?} _match * @param {?} key * @return {?} */ (_match, key) => contextObj[key.trim()] || '')); } } } fn.apply(this._lodop, (/** @type {?} */ (arr))); } })); } /** * 打开打印设计关闭后自动返回代码 * * **注:** 自动监听 `On_Return` 事件,运行后会移除 * @return {?} */ design() { this.check(); /** @type {?} */ const tid = (/** @type {?} */ (this._lodop)).PRINT_DESIGN(); return new Promise((/** * @param {?} resolve * @return {?} */ resolve => { (/** @type {?} */ (this._lodop)).On_Return = (/** * @param {?} taskID * @param {?} value * @return {?} */ (taskID, value) => { if (tid !== taskID) return; (/** @type {?} */ (this._lodop)).On_Return = null; resolve('' + value); }); })); } /** * @private * @return {?} */ printDo() { /** @type {?} */ const data = this.printBuffer.shift(); if (!data) return; this.attachCode(data.code, data.item, data.parser); /** @type {?} */ const tid = (/** @type {?} */ (this._lodop)).PRINT(); (/** @type {?} */ (this._lodop)).On_Return = (/** * @param {?} taskID * @param {?} value * @return {?} */ (taskID, value) => { if (tid !== taskID) return; (/** @type {?} */ (this._lodop)).On_Return = null; this._events.next(Object.assign({ ok: value === true, error: value === true ? null : value }, data)); this.printDo(); }); } /** * 立即打印,一般用于批量套打 * * @param {?} code 代码 * @param {?} contextObj 动态参数上下文对象 * @param {?=} parser 自定义解析表达式,默认:`/LODOP\.([^(]+)\(([^\n]+)?\);/i` * @return {?} */ print(code, contextObj, parser) { this.check(); if (contextObj) { this.printBuffer.push(...(Array.isArray(contextObj) ? contextObj : [contextObj]).map((/** * @param {?} item * @return {?} */ item => { return { code, parser, item }; }))); } this.printDo(); } /** * @return {?} */ ngOnDestroy() { this._init.unsubscribe(); this._events.unsubscribe(); } } LodopService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ LodopService.ctorParameters = () => [ { type: LazyService }, { type: OhayoConfigService } ]; /** @nocollapse */ LodopService.ɵprov = ɵɵdefineInjectable({ factory: function LodopService_Factory() { return new LodopService(ɵɵinject(LazyService), ɵɵinject(OhayoConfigService)); }, token: LodopService, providedIn: "root" }); if (false) { /** * @type {?} * @private */ LodopService.prototype.defaultConfig; /** * @type {?} * @private */ LodopService.prototype._cog; /** * @type {?} * @private */ LodopService.prototype.pending; /** * @type {?} * @private */ LodopService.prototype._lodop; /** * @type {?} * @private */ LodopService.prototype._init; /** * @type {?} * @private */ LodopService.prototype._events; /** * @type {?} * @private */ LodopService.prototype.printBuffer; /** * @type {?} * @private */ LodopService.prototype.scriptSrv; } /** * @fileoverview added by tsickle * Generated from: lodop.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class LodopModule { } LodopModule.decorators = [ { type: NgModule, args: [{ imports: [OhayoUtilModule], },] } ]; /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: lodop.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { LodopModule, LodopService }; //# sourceMappingURL=lodop.js.map