"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 cpu = os.arch() === 'x64' ? '64' : '86'; var dll = ffi.Library(__dirname + '/dll/GetEasy.Node.Printer.' + cpu + '.dll', { designerReport: ['void', ['string', 'string', 'pointer']], reportShowPreview: ['void', ['string', 'string']], reportPrinter: ['void', ['string', 'string']] }); var ReportApi = /** @class */ (function () { function ReportApi() { } /** *设计模板 * * @param {string} fileName 模板 * @param {string} tempData 临时演示数据 * @memberof ReportApi */ ReportApi.designerReport = function (template, tempData, saveCallback) { var callbackPointer = ffi.Callback('void', ['string', 'pointer'], function (data, func) { var nativeCallback = ffi.ForeignFunction(func, 'void', ['bool']); try { saveCallback(data, function (result) { if (result) { nativeCallback(true); } else { nativeCallback(false); } }); } catch (e) { console.error(e); nativeCallback(false); } }); dll.designerReport(template, tempData, callbackPointer); }; /** *打印预览 * * @param {string} fileName 模板路径 * @param {string} jsonData 数据 * @memberof ReportApi */ ReportApi.reportShowPreview = function (fileName, jsonData) { dll.reportPrinter(fileName, jsonData); }; /** *打印 * * @param {string} fileName 模板路径 * @param {string} jsonData 数据 * @memberof ReportApi */ ReportApi.reportPrinter = function (fileName, jsonData) { dll.reportPrinter(fileName, jsonData); }; return ReportApi; }()); exports["default"] = ReportApi;