12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- "use strict";
- // import * as edge from 'edge-js';
- exports.__esModule = true;
- // let designerReport = edge.func({
- // assemblyFile: 'lib/GetEasy.Node.Printer.dll',
- // typeName: 'GetEasy.Node.Printer.NodeReportDesigner',
- // methodName: 'DesignerReport'
- // });
- // designerReport('', true);
- var ffi = require("ffi");
- var os = require("os");
- var fs = require("fs");
- var path = require("path");
- var cpu = os.arch() === 'x64' ? '64' : '86';
- var dllName = 'GetEasy.Node.Printer.' + cpu + '.dll';
- var execDir = path.dirname(process.execPath);
- var dllPath = path.join(execDir, dllName);
- if (!fs.existsSync(dllPath)) {
- dllPath = path.join(__dirname, 'dll', dllName);
- }
- var callbackPointer;
- var dll = ffi.Library(dllPath, {
- designerReport: ['void', ['string', 'string']],
- reportShowPreview: ['void', ['string', 'string']],
- reportPrinter: ['void', ['string', 'string']],
- waitSaveOrClose: ['void', ['pointer']]
- });
- var ReportApi = /** @class */ (function () {
- function ReportApi() {
- }
- /**
- *设计模板
- *
- * @param {string} fileName 模板
- * @param {string} tempData 临时演示数据
- * @memberof ReportApi
- */
- ReportApi.designerReport = function (template, tempData, saveCallback) {
- callbackPointer = ffi.Callback('void', ['string', 'pointer'], function (data, func) {
- if (data) {
- var nativeCallback_1 = ffi.ForeignFunction(func, 'void', ['bool']);
- try {
- saveCallback(data, function (result) {
- if (result) {
- nativeCallback_1(true);
- }
- else {
- nativeCallback_1(false);
- }
- dll.waitSaveOrClose(callbackPointer);
- });
- }
- catch (e) {
- console.error(e);
- nativeCallback_1(false);
- dll.waitSaveOrClose(callbackPointer);
- }
- }
- });
- dll.designerReport(template, tempData);
- dll.waitSaveOrClose(callbackPointer);
- };
- /**
- *打印预览
- *
- * @param {string} fileName 模板路径
- * @param {string} jsonData 数据
- * @memberof ReportApi
- */
- ReportApi.reportShowPreview = function (fileName, jsonData) {
- dll.reportShowPreview(fileName, jsonData);
- };
- /**
- *打印
- *
- * @param {string} fileName 模板路径
- * @param {string} jsonData 数据
- * @memberof ReportApi
- */
- ReportApi.reportPrinter = function (fileName, jsonData) {
- dll.reportPrinter(fileName, jsonData);
- };
- return ReportApi;
- }());
- exports["default"] = ReportApi;
|