@ningboyz/vue 1.0.101 → 1.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  import e from "lodash";
2
- import { Stimulsoft as i } from "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.engine.js";
2
+ import { Stimulsoft as a } from "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.engine.js";
3
3
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.chart.js";
4
4
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.export.js";
5
5
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.import.xlsx.js";
6
6
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.maps.js";
7
- class m {
7
+ class g {
8
8
  static url = "";
9
9
  // 创建字体配置对象
10
10
  static fonts = [
@@ -32,44 +32,62 @@ class m {
32
32
  /**
33
33
  * 加载字体
34
34
  */
35
- static loadFonts = (o) => {
36
- let t = "/printer/fonts/";
37
- e.isEmpty(o) || (t = `${o}/upload` + t), this.fonts.forEach((a) => {
38
- switch (a.fontType) {
35
+ static loadFonts = (t) => {
36
+ let o = "/printer/fonts/";
37
+ e.isEmpty(this.url) || (o = `${this.url}/upload` + o), e.isNil(t) && (t = this.fonts), t.forEach((i) => {
38
+ switch (i.fontType) {
39
39
  case "ttf":
40
- i.Base.StiFontCollection.addFontFile(t + a.fontPath, a.fontName);
40
+ a.Base.StiFontCollection.addFontFile(o + i.fontPath, i.fontName);
41
41
  break;
42
42
  case "otf":
43
- i.Base.StiFontCollection.addOpentypeFontFile(t + a.fontPath, a.fontName);
43
+ a.Base.StiFontCollection.addOpentypeFontFile(o + i.fontPath, i.fontName);
44
44
  break;
45
45
  }
46
46
  });
47
- const n = i.Base.StiFontCollection.getBinFonts();
47
+ const n = a.Base.StiFontCollection.getBinFonts();
48
48
  console.log("已注册字体 =>", n);
49
49
  };
50
50
  /**
51
51
  * 加载授权
52
52
  */
53
53
  static loadLicense = () => {
54
- i.Base.StiLicense.key = "6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkVaUjYnRU/wphl9h6TkK9UtvGvwIZ/qCzU7vjHmM5RWbvCAfAhZhn+eMayEo4PRtUFJINrdMkfnVj1/HeyPgSgAKdpQpP1wzGj2ri5UgGNU8p7Pi59UAegRyUxjTI96rT+khTJIcSoTTPkqZwt0uC+IGtEdehlDchk7madvSLA9guSEZZuSHsc+adQ93NZogak6uo7LbqRh2xC23iGH4sValMR9CBxAsjWUYJH0yrcXODeYrX6ARDlVCW40MGOMrYnx/2W3O8L26oTyAFEdQ1TN1KzYjP4zenjvu4KBAWIopWG6Gk2ydffI0zldxHaPeEl0Lt6U77ykFtsXqW5fN/9t040SfeZfzMAq2ZoVGXPXKCjBo+asFZHrxn7iLpsxF7zwWkYIto8ObpimosoY0on8aLx7At7Qo3VaUOST48gIdqBabUpVz3O9h8UULJa23nlwMVMXheIMMmp6ACD9Bupla/giERFXIYIfpE4eFCD93sR2Cq2f8jdm5Z9B/faB8j4iz0IugVhK4BYhw2q9jAufdWTIx3nsE2Qw7ah0jNsgkR9kWWnHQ3qI/lwFLcFr81SVgyNpFzZ/zcV6vM+xaqbuEMivQx5uFx9WLOMU/ZYkyV8Hi/IEmU+O72NObJtWDxnhUkl4iV0WsYT2V2EU8t0NZP9SBCrLU+rd0SERAdGnRUfoJrm8mXPgcN6+FGNyTgiw0Do8oLU/Skqa/TohVeT";
54
+ a.Base.StiLicense.key = "6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkVaUjYnRU/wphl9h6TkK9UtvGvwIZ/qCzU7vjHmM5RWbvCAfAhZhn+eMayEo4PRtUFJINrdMkfnVj1/HeyPgSgAKdpQpP1wzGj2ri5UgGNU8p7Pi59UAegRyUxjTI96rT+khTJIcSoTTPkqZwt0uC+IGtEdehlDchk7madvSLA9guSEZZuSHsc+adQ93NZogak6uo7LbqRh2xC23iGH4sValMR9CBxAsjWUYJH0yrcXODeYrX6ARDlVCW40MGOMrYnx/2W3O8L26oTyAFEdQ1TN1KzYjP4zenjvu4KBAWIopWG6Gk2ydffI0zldxHaPeEl0Lt6U77ykFtsXqW5fN/9t040SfeZfzMAq2ZoVGXPXKCjBo+asFZHrxn7iLpsxF7zwWkYIto8ObpimosoY0on8aLx7At7Qo3VaUOST48gIdqBabUpVz3O9h8UULJa23nlwMVMXheIMMmp6ACD9Bupla/giERFXIYIfpE4eFCD93sR2Cq2f8jdm5Z9B/faB8j4iz0IugVhK4BYhw2q9jAufdWTIx3nsE2Qw7ah0jNsgkR9kWWnHQ3qI/lwFLcFr81SVgyNpFzZ/zcV6vM+xaqbuEMivQx5uFx9WLOMU/ZYkyV8Hi/IEmU+O72NObJtWDxnhUkl4iV0WsYT2V2EU8t0NZP9SBCrLU+rd0SERAdGnRUfoJrm8mXPgcN6+FGNyTgiw0Do8oLU/Skqa/TohVeT";
55
55
  };
56
56
  /**
57
57
  * 加载语言
58
58
  */
59
- static loadLanguage = (o) => {
59
+ static loadLanguage = () => {
60
60
  let t = "/printer/localizations/";
61
- e.isEmpty(o) || (t = `${o}/upload` + t), i.Base.Localization.StiLocalization.addLocalizationFile(`${t}zh.xml`, !1, "中文"), i.Base.Localization.StiLocalization.cultureName = "中文";
61
+ e.isEmpty(this.url) || (t = `${this.url}/upload` + t), a.Base.Localization.StiLocalization.addLocalizationFile(`${t}zh.xml`, !1, "中文"), a.Base.Localization.StiLocalization.cultureName = "中文";
62
62
  };
63
- static setUrl = (o) => {
64
- this.url = o;
63
+ static setUrl = (t) => {
64
+ this.url = t;
65
65
  };
66
66
  /**
67
67
  * 初始化
68
68
  */
69
- static initialize = () => {
70
- console.info("打印控件初始化, url:=>", this.url), this.loadLicense(), this.loadLanguage(this.url), this.loadFonts(this.url);
69
+ static initialize = (t) => {
70
+ console.info("打印控件初始化, url:=>", this.url), this.loadLicense(), this.loadLanguage(), t && this.loadFonts();
71
+ };
72
+ /**
73
+ * 获取report内所有使用的自定义字体
74
+ * @param reports
75
+ * @returns
76
+ */
77
+ static getAllUsedFonts = (t) => {
78
+ const o = /* @__PURE__ */ new Set();
79
+ return t.forEach((n) => {
80
+ n.pages.list.forEach((i) => {
81
+ i.components.list.forEach((l) => {
82
+ l.getFonts().forEach((f) => {
83
+ const s = this.fonts.find((r) => r.fontName === f.name);
84
+ e.isNil(s) || o.add(s);
85
+ });
86
+ });
87
+ });
88
+ }), Array.from(o);
71
89
  };
72
90
  }
73
91
  export {
74
- m as default
92
+ g as default
75
93
  };
@@ -13,11 +13,11 @@ const N = /* @__PURE__ */ d({
13
13
  listData: {}
14
14
  },
15
15
  emits: ["saveReport"],
16
- setup(c, { expose: m, emit: f }) {
17
- y.initialize();
16
+ setup(c, { expose: m, emit: u }) {
17
+ y.initialize(!0);
18
18
  const s = c, n = a(), i = a(!1), r = new b.Designer.StiDesignerOptions();
19
19
  r.appearance.fullScreenMode = !0, r.toolbar.showFileMenu = !1;
20
- const u = f;
20
+ const f = u;
21
21
  D(
22
22
  () => [s.templateJson, s.listData],
23
23
  async (e) => {
@@ -31,7 +31,7 @@ const N = /* @__PURE__ */ d({
31
31
  const v = (e) => {
32
32
  e.preventDefault = !0;
33
33
  const o = e.report.saveToJsonString(), t = e.fileName;
34
- u("saveReport", t, o);
34
+ f("saveReport", t, o);
35
35
  }, p = async (e, o) => {
36
36
  try {
37
37
  const t = new _(e, o);
@@ -1,11 +1,11 @@
1
- import { Stimulsoft as s } from "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.engine.js";
1
+ import { Stimulsoft as o } from "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.engine.js";
2
2
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.chart.js";
3
3
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.export.js";
4
4
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.import.xlsx.js";
5
5
  import "../../node_modules/stimulsoft-reports-js-vuejs/stimulsoft.reports.maps.js";
6
- import a from "../dataUtils/stimulsoftData.js";
7
- import o from "lodash";
8
- import n from "../dataUtils/stimulsoftUtil.js";
6
+ import p from "../dataUtils/stimulsoftData.js";
7
+ import n from "lodash";
8
+ import a from "../dataUtils/stimulsoftUtil.js";
9
9
  class g {
10
10
  reports = [];
11
11
  report;
@@ -17,7 +17,7 @@ class g {
17
17
  * @param listData
18
18
  */
19
19
  constructor(t) {
20
- this.printDatas = t, this.report = new s.Report.StiReport();
20
+ this.printDatas = t, this.report = new o.Report.StiReport();
21
21
  }
22
22
  /**
23
23
  * 初始化报表
@@ -26,31 +26,42 @@ class g {
26
26
  initReport = () => {
27
27
  for (let t = 0; t < this.printDatas.length; t++) {
28
28
  const r = this.printDatas[t];
29
- for (let i = 0; i < r.listData.length; i++) {
30
- const p = r.listData[i], e = new s.Report.StiReport();
31
- e.load(r.jsonTemplate), a.createDataSet(e, p), this.reports.push(e);
29
+ for (let e = 0; e < r.listData.length; e++) {
30
+ const i = r.listData[e], s = new o.Report.StiReport();
31
+ s.load(r.jsonTemplate), p.createDataSet(s, i), this.reports.push(s);
32
32
  }
33
33
  }
34
34
  return this;
35
35
  };
36
+ renderReport = (t) => new Promise((r) => {
37
+ t.renderAsync((e) => {
38
+ r(e);
39
+ });
40
+ });
36
41
  /**
37
42
  * 合并报表
38
43
  * @returns
39
44
  */
40
45
  mergeReport = async () => {
41
46
  for (let t = 0; t < this.reports.length; t++) {
42
- const r = this.reports[t];
43
- r.render(), t === 0 ? this.report = r : r.renderedPages.toList().forEach((i) => {
47
+ const r = this.reports[t], e = await this.renderReport(r);
48
+ t === 0 ? this.report = e : e.renderedPages.toList().forEach((i) => {
44
49
  this.report.renderedPages.add(i.clone());
45
50
  });
46
51
  }
47
52
  return this;
48
53
  };
49
- print() {
50
- o.isNil(this.printDatas) || this.printDatas.length === 0 || (this.printDatas.forEach((t) => {
51
- o.isEmpty(t.jsonTemplate) || o.isNil(t.listData) || t.listData.length;
52
- }), n.initialize(), this.report = new s.Report.StiReport(), this.initReport(), this.mergeReport(), this.report.print());
53
- }
54
+ print = async () => {
55
+ if (n.isNil(this.printDatas) || this.printDatas.length === 0)
56
+ return;
57
+ this.printDatas.forEach((r) => {
58
+ n.isEmpty(r.jsonTemplate) || n.isNil(r.listData) || r.listData.length;
59
+ }), a.initialize(!1), this.report = new o.Report.StiReport(), this.initReport(), await this.mergeReport();
60
+ const t = a.getAllUsedFonts(this.reports);
61
+ a.loadFonts(t), this.report.renderAsync((r) => {
62
+ r.print();
63
+ });
64
+ };
54
65
  }
55
66
  export {
56
67
  g as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ningboyz/vue",
3
- "version": "1.0.101",
3
+ "version": "1.0.103",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "宁波甬政vue-ui库",
@@ -1,7 +1,10 @@
1
1
  import StimulsoftData from "./stimulsoftData";
2
2
  import StimulsoftUtil from "./StimulsoftUtil";
3
+ import { IFontList } from "./StimulsoftUtil";
3
4
 
4
5
  export const StimulsoftCommon = {
5
6
  StimulsoftData,
6
7
  StimulsoftUtil
7
8
  };
9
+
10
+ export type { IFontList };
@@ -1,5 +1,6 @@
1
1
  import { TWldy } from "@ningboyz/types";
2
2
  import { Stimulsoft } from "stimulsoft-reports-js-vuejs/designer";
3
+
3
4
  declare class StimulsoftData {
4
5
  private static DATA_SET_NAME: string;
5
6
  public createDataSet: (report: Stimulsoft.Report.StiReport, listData: TWldy.IWldyDataResponse[]) => void;
@@ -1,8 +1,14 @@
1
+ export interface IFontList {
2
+ fontName: string;
3
+ fontPath: string;
4
+ fontType: "ttf" | "otf";
5
+ }
6
+
1
7
  declare class StimulsoftUtil {
2
8
  private static loadLicense: () => void;
3
- private static loadLanguage: (url: string) => void;
4
- private static loadFonts: (url: string) => void;
9
+ private static loadLanguage: () => void;
10
+ private static loadFonts: (fonts: IFontList) => void;
5
11
  public static setUrl: (url: string) => void;
6
- public static initialize: () => Promise<boolean>;
12
+ public static initialize: (loadFont: boolean) => Promise<boolean>;
7
13
  }
8
14
  export default StimulsoftUtil;