Kevin 6 lat temu
rodzic
commit
d475f1b432
2 zmienionych plików z 47 dodań i 9 usunięć
  1. 5 7
      index.d.ts
  2. 42 2
      index.js

+ 5 - 7
index.d.ts

@@ -1,13 +1,12 @@
-declare const dll: ReportApi;
-interface ReportApi {
+export default class ReportApi {
     /**
      *设计模板
      *
-     * @param {string} fileName 模板路径
+     * @param {string} fileName 模板
      * @param {string} tempData 临时演示数据
      * @memberof ReportApi
      */
-    designerReport(fileName: string, tempData: string): void;
+    static designerReport(template: string, tempData: string, saveCallback: (saveTemplate: string) => boolean): void;
     /**
      *打印预览
      *
@@ -15,7 +14,7 @@ interface ReportApi {
      * @param {string} jsonData 数据
      * @memberof ReportApi
      */
-    reportShowPreview(fileName: string, jsonData: string): void;
+    static reportShowPreview(fileName: string, jsonData: string): void;
     /**
      *打印
      *
@@ -23,6 +22,5 @@ interface ReportApi {
      * @param {string} jsonData 数据
      * @memberof ReportApi
      */
-    reportPrinter(fileName: string, jsonData: string): void;
+    static reportPrinter(fileName: string, jsonData: string): void;
 }
-export default dll;

+ 42 - 2
index.js

@@ -10,9 +10,49 @@ exports.__esModule = true;
 var ffi = require("ffi");
 var os = require("os");
 var cpu = os.arch() === "x64" ? "64" : "86";
+var callback = ffi.Callback('void', ['int', 'string'], function (id, name) {
+    console.log("id: ", id);
+    console.log("name: ", name);
+});
 var dll = ffi.Library(__dirname + "/dll/GetEasy.Node.Printer." + cpu + ".dll", {
-    designerReport: ["void", ["string", "string"]],
+    designerReport: ["void", ["string", "string", "pointer"]],
     reportShowPreview: ["void", ["string", "string"]],
     reportPrinter: ["void", ["string", "string"]]
 });
-exports["default"] = dll;
+var ReportApi = /** @class */ (function () {
+    function ReportApi() {
+    }
+    /**
+     *设计模板
+     *
+     * @param {string} fileName 模板
+     * @param {string} tempData 临时演示数据
+     * @memberof ReportApi
+     */
+    ReportApi.designerReport = function (template, tempData, saveCallback) {
+        var callbackPointer = ffi.Callback('bool', ['string'], saveCallback);
+        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;