operp-print-designer 1.0.4 → 1.0.5
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.
- package/dist/{print-designer.es.js → operp-print-designer.es.js} +54 -53
- package/dist/operp-print-designer.umd.js +46 -0
- package/package.json +5 -5
- package/dist/components/PrintDesigner.d.ts +0 -14
- package/dist/index.d.ts +0 -26
- package/dist/print-designer.umd.js +0 -46
- package/dist/store/index.d.ts +0 -29
- package/dist/types/index.d.ts +0 -71
- package/dist/utils/dataHelper.d.ts +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import he, { useRef as He, useCallback as
|
|
1
|
+
import he, { useRef as He, useCallback as G, useState as Ce, useMemo as ee, useEffect as un } from "react";
|
|
2
2
|
import { Typography as fe, App as Be, Space as re, Input as ne, Button as H, Card as me, Select as Z, InputNumber as Q, Radio as Ne, List as $e, Tag as Le, Dropdown as hn, Popconfirm as zt, message as ue, Modal as Ue, Divider as se, Collapse as fn, Empty as jt, ColorPicker as Ve, Table as pn, Form as oe, Switch as We } from "antd";
|
|
3
|
-
import { PlusOutlined as
|
|
3
|
+
import { PlusOutlined as Ge, SaveOutlined as It, DownloadOutlined as gn, UploadOutlined as xn, SettingOutlined as mn, DeleteOutlined as Ke, PrinterOutlined as qe, EyeOutlined as yn, FontSizeOutlined as vn, PictureOutlined as bn, TableOutlined as jn, BarcodeOutlined as Sn, MinusOutlined as wn, DatabaseOutlined as Dt, MoreOutlined as Cn, EditOutlined as Tn, CaretRightOutlined as Rn } from "@ant-design/icons";
|
|
4
4
|
import { useReactToPrint as At } from "react-to-print";
|
|
5
5
|
import { create as En } from "zustand";
|
|
6
6
|
import Pn from "react-grid-layout";
|
|
@@ -239,29 +239,29 @@ function _n() {
|
|
|
239
239
|
}), typeof Reflect == "object" && Reflect.construct) {
|
|
240
240
|
try {
|
|
241
241
|
Reflect.construct(k, []);
|
|
242
|
-
} catch (
|
|
243
|
-
S =
|
|
242
|
+
} catch (K) {
|
|
243
|
+
S = K;
|
|
244
244
|
}
|
|
245
245
|
Reflect.construct(t, [], k);
|
|
246
246
|
} else {
|
|
247
247
|
try {
|
|
248
248
|
k.call();
|
|
249
|
-
} catch (
|
|
250
|
-
S =
|
|
249
|
+
} catch (K) {
|
|
250
|
+
S = K;
|
|
251
251
|
}
|
|
252
252
|
t.call(k.prototype);
|
|
253
253
|
}
|
|
254
254
|
} else {
|
|
255
255
|
try {
|
|
256
256
|
throw Error();
|
|
257
|
-
} catch (
|
|
258
|
-
S =
|
|
257
|
+
} catch (K) {
|
|
258
|
+
S = K;
|
|
259
259
|
}
|
|
260
260
|
t();
|
|
261
261
|
}
|
|
262
|
-
} catch (
|
|
263
|
-
if (
|
|
264
|
-
for (var R =
|
|
262
|
+
} catch (K) {
|
|
263
|
+
if (K && S && typeof K.stack == "string") {
|
|
264
|
+
for (var R = K.stack.split(`
|
|
265
265
|
`), U = S.stack.split(`
|
|
266
266
|
`), V = R.length - 1, W = U.length - 1; V >= 1 && W >= 0 && R[V] !== U[W]; )
|
|
267
267
|
W--;
|
|
@@ -385,7 +385,7 @@ function _n() {
|
|
|
385
385
|
}
|
|
386
386
|
return t.ref !== void 0;
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function Gt(t) {
|
|
389
389
|
if (pe.call(t, "key")) {
|
|
390
390
|
var l = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
391
391
|
if (l && l.isReactWarning)
|
|
@@ -393,7 +393,7 @@ function _n() {
|
|
|
393
393
|
}
|
|
394
394
|
return t.key !== void 0;
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function Kt(t, l) {
|
|
397
397
|
typeof t.ref == "string" && ut.current;
|
|
398
398
|
}
|
|
399
399
|
function qt(t, l) {
|
|
@@ -450,7 +450,7 @@ function _n() {
|
|
|
450
450
|
function Qt(t, l, f, S, O) {
|
|
451
451
|
{
|
|
452
452
|
var F, k = {}, R = null, U = null;
|
|
453
|
-
f !== void 0 && (ct(f), R = "" + f),
|
|
453
|
+
f !== void 0 && (ct(f), R = "" + f), Gt(l) && (ct(l.key), R = "" + l.key), Ut(l) && (U = l.ref, Kt(l, O));
|
|
454
454
|
for (F in l)
|
|
455
455
|
pe.call(l, F) && !Ht.hasOwnProperty(F) && (k[F] = l[F]);
|
|
456
456
|
if (t && t.defaultProps) {
|
|
@@ -604,11 +604,11 @@ Check the top-level render call using <` + f + ">.");
|
|
|
604
604
|
yt(X, t);
|
|
605
605
|
}
|
|
606
606
|
if (pe.call(l, "key")) {
|
|
607
|
-
var ie = M(t),
|
|
607
|
+
var ie = M(t), K = Object.keys(l).filter(function(cn) {
|
|
608
608
|
return cn !== "key";
|
|
609
|
-
}), Fe =
|
|
609
|
+
}), Fe = K.length > 0 ? "{key: someKey, " + K.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
610
610
|
if (!vt[ie + Fe]) {
|
|
611
|
-
var dn =
|
|
611
|
+
var dn = K.length > 0 ? "{" + K.join(": ..., ") + ": ...}" : "{}";
|
|
612
612
|
x(`A props object containing a "key" prop is being spread into JSX:
|
|
613
613
|
let props = %s;
|
|
614
614
|
<%s {...props} />
|
|
@@ -855,16 +855,16 @@ const w = En((o, d) => ({
|
|
|
855
855
|
activeDataSourceId: null
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
|
-
})), { Text:
|
|
859
|
-
const a = w((h) => h.templateName), r = w((h) => h.setTemplateName), s = w((h) => h.setPreviewVisible), i = w((h) => h.setHeaderFooterVisible), y = w((h) => h.selectedId), g = w((h) => h.removeComponent), c = w((h) => h.exportJSON), b = w((h) => h.importJSON), v = w((h) => h.reset), T = He(null), { message: p } = Be.useApp(), _ =
|
|
858
|
+
})), { Text: er } = fe, In = ({ onCustomSave: o, onCustomPrint: d }) => {
|
|
859
|
+
const a = w((h) => h.templateName), r = w((h) => h.setTemplateName), s = w((h) => h.setPreviewVisible), i = w((h) => h.setHeaderFooterVisible), y = w((h) => h.selectedId), g = w((h) => h.removeComponent), c = w((h) => h.exportJSON), b = w((h) => h.importJSON), v = w((h) => h.reset), T = He(null), { message: p } = Be.useApp(), _ = G(() => {
|
|
860
860
|
y && g(y);
|
|
861
|
-
}, [y, g]), I =
|
|
861
|
+
}, [y, g]), I = G(() => {
|
|
862
862
|
const h = c(), x = new Blob([h], { type: "application/json" }), E = URL.createObjectURL(x), u = document.createElement("a");
|
|
863
863
|
u.href = E, u.download = `${a || "模板"}.json`, u.click(), URL.revokeObjectURL(E), p.success("模板已导出");
|
|
864
|
-
}, [c, a, p]), m =
|
|
864
|
+
}, [c, a, p]), m = G(() => {
|
|
865
865
|
var h;
|
|
866
866
|
(h = T.current) == null || h.click();
|
|
867
|
-
}, []), P =
|
|
867
|
+
}, []), P = G(
|
|
868
868
|
(h) => {
|
|
869
869
|
var u;
|
|
870
870
|
const x = (u = h.target.files) == null ? void 0 : u[0];
|
|
@@ -876,7 +876,7 @@ const w = En((o, d) => ({
|
|
|
876
876
|
}, E.readAsText(x), h.target.value = "";
|
|
877
877
|
},
|
|
878
878
|
[b, p]
|
|
879
|
-
), n =
|
|
879
|
+
), n = G(() => {
|
|
880
880
|
v(), p.info("已新建空白模板");
|
|
881
881
|
}, [v, p]);
|
|
882
882
|
return /* @__PURE__ */ e.jsxs(
|
|
@@ -903,7 +903,7 @@ const w = En((o, d) => ({
|
|
|
903
903
|
}
|
|
904
904
|
) }),
|
|
905
905
|
/* @__PURE__ */ e.jsxs(re, { children: [
|
|
906
|
-
/* @__PURE__ */ e.jsx(H, { icon: /* @__PURE__ */ e.jsx(
|
|
906
|
+
/* @__PURE__ */ e.jsx(H, { icon: /* @__PURE__ */ e.jsx(Ge, {}), onClick: n, children: "新建" }),
|
|
907
907
|
/* @__PURE__ */ e.jsx(
|
|
908
908
|
"input",
|
|
909
909
|
{
|
|
@@ -928,7 +928,7 @@ const w = En((o, d) => ({
|
|
|
928
928
|
H,
|
|
929
929
|
{
|
|
930
930
|
danger: !0,
|
|
931
|
-
icon: /* @__PURE__ */ e.jsx(
|
|
931
|
+
icon: /* @__PURE__ */ e.jsx(Ke, {}),
|
|
932
932
|
disabled: !y,
|
|
933
933
|
onClick: _,
|
|
934
934
|
children: "删除"
|
|
@@ -956,12 +956,12 @@ const w = En((o, d) => ({
|
|
|
956
956
|
}
|
|
957
957
|
);
|
|
958
958
|
}, { Text: te } = fe, Dn = () => {
|
|
959
|
-
const o = w((i) => i.pageSettings), d = w((i) => i.setPageSettings), a = o.paperSize === "custom", r =
|
|
959
|
+
const o = w((i) => i.pageSettings), d = w((i) => i.setPageSettings), a = o.paperSize === "custom", r = G(
|
|
960
960
|
(i) => {
|
|
961
961
|
d({ paperSize: i });
|
|
962
962
|
},
|
|
963
963
|
[d]
|
|
964
|
-
), s =
|
|
964
|
+
), s = G(
|
|
965
965
|
(i) => {
|
|
966
966
|
d({ orientation: i });
|
|
967
967
|
},
|
|
@@ -1106,12 +1106,12 @@ const w = En((o, d) => ({
|
|
|
1106
1106
|
{ type: "barcode", icon: /* @__PURE__ */ e.jsx(Sn, {}), label: "条形码" },
|
|
1107
1107
|
{ type: "line", icon: /* @__PURE__ */ e.jsx(wn, {}), label: "分割线" }
|
|
1108
1108
|
], Nn = () => {
|
|
1109
|
-
const o = w((r) => r.addComponent), d =
|
|
1109
|
+
const o = w((r) => r.addComponent), d = G(
|
|
1110
1110
|
(r, s) => {
|
|
1111
1111
|
r.dataTransfer.setData("componentType", s), r.dataTransfer.effectAllowed = "copy";
|
|
1112
1112
|
},
|
|
1113
1113
|
[]
|
|
1114
|
-
), a =
|
|
1114
|
+
), a = G(
|
|
1115
1115
|
(r) => {
|
|
1116
1116
|
o(r);
|
|
1117
1117
|
},
|
|
@@ -1201,7 +1201,7 @@ function Ze(o) {
|
|
|
1201
1201
|
const d = Pe(o.data);
|
|
1202
1202
|
return o.type === "array" && Array.isArray(d) ? d : null;
|
|
1203
1203
|
}
|
|
1204
|
-
const { TextArea: $n } = ne, { Text: we, Title:
|
|
1204
|
+
const { TextArea: $n } = ne, { Text: we, Title: tr } = fe, Pt = JSON.stringify(
|
|
1205
1205
|
{
|
|
1206
1206
|
name: "张三",
|
|
1207
1207
|
age: 28,
|
|
@@ -1255,7 +1255,7 @@ const { TextArea: $n } = ne, { Text: we, Title: er } = fe, Pt = JSON.stringify(
|
|
|
1255
1255
|
{
|
|
1256
1256
|
type: "link",
|
|
1257
1257
|
size: "small",
|
|
1258
|
-
icon: /* @__PURE__ */ e.jsx(
|
|
1258
|
+
icon: /* @__PURE__ */ e.jsx(Ge, {}),
|
|
1259
1259
|
onClick: () => v(),
|
|
1260
1260
|
children: "添加"
|
|
1261
1261
|
}
|
|
@@ -1300,7 +1300,7 @@ const { TextArea: $n } = ne, { Text: we, Title: er } = fe, Pt = JSON.stringify(
|
|
|
1300
1300
|
children: /* @__PURE__ */ e.jsx("span", { style: { color: "#ff4d4f", cursor: "pointer" }, children: "删除" })
|
|
1301
1301
|
}
|
|
1302
1302
|
),
|
|
1303
|
-
icon: /* @__PURE__ */ e.jsx(
|
|
1303
|
+
icon: /* @__PURE__ */ e.jsx(Ke, { style: { color: "#ff4d4f" } })
|
|
1304
1304
|
}
|
|
1305
1305
|
]
|
|
1306
1306
|
},
|
|
@@ -1439,7 +1439,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1439
1439
|
),
|
|
1440
1440
|
/* @__PURE__ */ e.jsx("div", { style: { fontSize: 10, marginTop: 1, letterSpacing: 1 }, children: o })
|
|
1441
1441
|
] });
|
|
1442
|
-
}, _t = he.memo(
|
|
1442
|
+
}, Ln = Pn, _t = he.memo(
|
|
1443
1443
|
({ comp: o, selected: d, isPreview: a = !1, dataSources: r = [] }) => {
|
|
1444
1444
|
const s = {
|
|
1445
1445
|
width: "100%",
|
|
@@ -1498,7 +1498,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1498
1498
|
}
|
|
1499
1499
|
) });
|
|
1500
1500
|
case "table":
|
|
1501
|
-
return /* @__PURE__ */ e.jsx(
|
|
1501
|
+
return /* @__PURE__ */ e.jsx(Mn, { comp: o, style: s, dataSources: r });
|
|
1502
1502
|
case "barcode":
|
|
1503
1503
|
const g = i("value") || o.props.value || "123456";
|
|
1504
1504
|
return /* @__PURE__ */ e.jsx(
|
|
@@ -1548,7 +1548,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1548
1548
|
return /* @__PURE__ */ e.jsx("div", { style: s, children: o.type });
|
|
1549
1549
|
}
|
|
1550
1550
|
}
|
|
1551
|
-
),
|
|
1551
|
+
), Mn = ({ comp: o, style: d, dataSources: a = [] }) => {
|
|
1552
1552
|
const r = o.props.borderWidth || 1, s = o.props.borderColor || "#000", i = o.tableColumns || [], y = o.props.tableDataSourceId, g = y ? a.find((T) => T.id === y) : null, c = g ? Ze(g) : null;
|
|
1553
1553
|
if (c && c.length > 0)
|
|
1554
1554
|
return /* @__PURE__ */ e.jsxs(
|
|
@@ -1645,7 +1645,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1645
1645
|
h: n.h
|
|
1646
1646
|
})),
|
|
1647
1647
|
[d]
|
|
1648
|
-
), I =
|
|
1648
|
+
), I = G(
|
|
1649
1649
|
(n) => {
|
|
1650
1650
|
const h = d.map((x, E) => {
|
|
1651
1651
|
const u = n[E];
|
|
@@ -1654,7 +1654,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1654
1654
|
i(h);
|
|
1655
1655
|
},
|
|
1656
1656
|
[d, i]
|
|
1657
|
-
), m =
|
|
1657
|
+
), m = G(
|
|
1658
1658
|
(n, h, x) => {
|
|
1659
1659
|
var D, N;
|
|
1660
1660
|
const E = x, u = (D = E.dataTransfer) == null ? void 0 : D.getData("componentType");
|
|
@@ -1667,7 +1667,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1667
1667
|
y(u);
|
|
1668
1668
|
},
|
|
1669
1669
|
[y, T, g.cols]
|
|
1670
|
-
), P =
|
|
1670
|
+
), P = G(
|
|
1671
1671
|
(n) => {
|
|
1672
1672
|
s(n === a ? null : n);
|
|
1673
1673
|
},
|
|
@@ -1761,7 +1761,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1761
1761
|
};
|
|
1762
1762
|
return /* @__PURE__ */ e.jsx("div", { style: E, children: /* @__PURE__ */ e.jsx(_t, { comp: n, selected: !1, isPreview: !0, dataSources: c }) }, n.id);
|
|
1763
1763
|
}) }) : /* @__PURE__ */ e.jsx(
|
|
1764
|
-
|
|
1764
|
+
Ln,
|
|
1765
1765
|
{
|
|
1766
1766
|
className: "canvas-grid",
|
|
1767
1767
|
layout: _,
|
|
@@ -1798,7 +1798,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1798
1798
|
)
|
|
1799
1799
|
}
|
|
1800
1800
|
);
|
|
1801
|
-
}, { Text: B, Title:
|
|
1801
|
+
}, { Text: B, Title: nr } = fe, { TextArea: Jn } = ne, Yn = () => {
|
|
1802
1802
|
const o = w((n) => n.components), d = w((n) => n.selectedId), a = w((n) => n.dataSources), r = w((n) => n.updateComponent), s = w((n) => n.updateComponentTableColumns), i = ee(
|
|
1803
1803
|
() => o.find((n) => n.id === d) || null,
|
|
1804
1804
|
[o, d]
|
|
@@ -1812,14 +1812,14 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1812
1812
|
}))
|
|
1813
1813
|
],
|
|
1814
1814
|
[a]
|
|
1815
|
-
), b =
|
|
1815
|
+
), b = G(
|
|
1816
1816
|
(n, h) => {
|
|
1817
1817
|
d && r(d, {
|
|
1818
1818
|
props: { ...i == null ? void 0 : i.props, [n]: h }
|
|
1819
1819
|
});
|
|
1820
1820
|
},
|
|
1821
1821
|
[d, i, r]
|
|
1822
|
-
), v =
|
|
1822
|
+
), v = G(
|
|
1823
1823
|
(n, h, x, E) => {
|
|
1824
1824
|
if (!d) return;
|
|
1825
1825
|
let u = E;
|
|
@@ -1838,7 +1838,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1838
1838
|
});
|
|
1839
1839
|
},
|
|
1840
1840
|
[d, i, r]
|
|
1841
|
-
), T =
|
|
1841
|
+
), T = G((n) => {
|
|
1842
1842
|
const h = i == null ? void 0 : i.props[`${n}Binding`], x = String((i == null ? void 0 : i.props[n]) || "");
|
|
1843
1843
|
return h ? {
|
|
1844
1844
|
field: n,
|
|
@@ -1971,7 +1971,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
1971
1971
|
/* @__PURE__ */ e.jsx(Le, { color: "green", children: u.fieldPath })
|
|
1972
1972
|
] })
|
|
1973
1973
|
] }) : E ? /* @__PURE__ */ e.jsx(
|
|
1974
|
-
|
|
1974
|
+
Jn,
|
|
1975
1975
|
{
|
|
1976
1976
|
rows: 3,
|
|
1977
1977
|
placeholder: x,
|
|
@@ -2075,7 +2075,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
2075
2075
|
},
|
|
2076
2076
|
okText: "确定",
|
|
2077
2077
|
cancelText: "取消",
|
|
2078
|
-
children: /* @__PURE__ */ e.jsx(H, { type: "text", danger: !0, size: "small", icon: /* @__PURE__ */ e.jsx(
|
|
2078
|
+
children: /* @__PURE__ */ e.jsx(H, { type: "text", danger: !0, size: "small", icon: /* @__PURE__ */ e.jsx(Ke, {}) })
|
|
2079
2079
|
}
|
|
2080
2080
|
)
|
|
2081
2081
|
}
|
|
@@ -2102,7 +2102,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
2102
2102
|
/* @__PURE__ */ e.jsx(se, {}),
|
|
2103
2103
|
/* @__PURE__ */ e.jsxs(re, { style: { marginBottom: 8 }, children: [
|
|
2104
2104
|
/* @__PURE__ */ e.jsx(B, { style: { fontSize: 12 }, children: "列配置" }),
|
|
2105
|
-
/* @__PURE__ */ e.jsx(H, { size: "small", type: "dashed", icon: /* @__PURE__ */ e.jsx(
|
|
2105
|
+
/* @__PURE__ */ e.jsx(H, { size: "small", type: "dashed", icon: /* @__PURE__ */ e.jsx(Ge, {}), onClick: L }),
|
|
2106
2106
|
/* @__PURE__ */ e.jsx(H, { size: "small", type: "primary", onClick: N, icon: /* @__PURE__ */ e.jsx(It, {}) })
|
|
2107
2107
|
] }),
|
|
2108
2108
|
/* @__PURE__ */ e.jsx(
|
|
@@ -2329,7 +2329,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
2329
2329
|
] })
|
|
2330
2330
|
}
|
|
2331
2331
|
);
|
|
2332
|
-
}, { Text:
|
|
2332
|
+
}, { Text: rr } = fe, Hn = () => {
|
|
2333
2333
|
const o = w((m) => m.previewVisible), d = w((m) => m.setPreviewVisible), a = w((m) => m.components), r = w((m) => m.pageSettings), s = w((m) => m.gridSettings) || Re, i = w((m) => m.dataSources), y = He(null), g = ee(() => {
|
|
2334
2334
|
const m = Ee[r.paperSize];
|
|
2335
2335
|
if (!m)
|
|
@@ -2598,7 +2598,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
2598
2598
|
]
|
|
2599
2599
|
}
|
|
2600
2600
|
);
|
|
2601
|
-
},
|
|
2601
|
+
}, Un = () => {
|
|
2602
2602
|
const o = w((s) => s.headerFooterVisible), d = w((s) => s.pageSettings), a = w((s) => s.setPageSettings), r = w((s) => s.setHeaderFooterVisible);
|
|
2603
2603
|
return /* @__PURE__ */ e.jsx(
|
|
2604
2604
|
Ue,
|
|
@@ -2657,7 +2657,7 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
2657
2657
|
] })
|
|
2658
2658
|
}
|
|
2659
2659
|
);
|
|
2660
|
-
},
|
|
2660
|
+
}, ir = ({
|
|
2661
2661
|
isPreview: o = !1,
|
|
2662
2662
|
initialTemplateData: d,
|
|
2663
2663
|
onSave: a,
|
|
@@ -2947,14 +2947,15 @@ const Qe = ({ value: o, format: d }) => {
|
|
|
2947
2947
|
/* @__PURE__ */ e.jsxs("div", { className: "app-body", children: [
|
|
2948
2948
|
/* @__PURE__ */ e.jsx("div", { className: "app-left-panel", children: /* @__PURE__ */ e.jsx(Bn, {}) }),
|
|
2949
2949
|
/* @__PURE__ */ e.jsx(Ot, {}),
|
|
2950
|
-
/* @__PURE__ */ e.jsx("div", { className: "app-right-panel", children: /* @__PURE__ */ e.jsx(
|
|
2950
|
+
/* @__PURE__ */ e.jsx("div", { className: "app-right-panel", children: /* @__PURE__ */ e.jsx(Yn, {}) })
|
|
2951
2951
|
] }),
|
|
2952
|
-
/* @__PURE__ */ e.jsx(
|
|
2953
|
-
/* @__PURE__ */ e.jsx(
|
|
2952
|
+
/* @__PURE__ */ e.jsx(Hn, {}),
|
|
2953
|
+
/* @__PURE__ */ e.jsx(Un, {})
|
|
2954
2954
|
] }) });
|
|
2955
2955
|
};
|
|
2956
2956
|
export {
|
|
2957
|
-
|
|
2957
|
+
ir as PrintDesigner,
|
|
2958
|
+
ir as default,
|
|
2958
2959
|
Ze as getArrayFromDataSource,
|
|
2959
2960
|
Xe as getObjectFromDataSource,
|
|
2960
2961
|
Te as getRenderValue,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
(function(Y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("antd"),require("@ant-design/icons"),require("react-to-print"),require("zustand"),require("react-grid-layout")):typeof define=="function"&&define.amd?define(["exports","react","antd","@ant-design/icons","react-to-print","zustand","react-grid-layout"],w):(Y=typeof globalThis<"u"?globalThis:Y||self,w(Y.PrintDesigner={},Y.React,Y.antd,Y.icons,Y.ReactToPrint,Y.zustand,Y.GridLayout))})(this,(function(Y,w,o,B,De,ft,pt){"use strict";var ue={exports:{}},se={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Re;function gt(){if(Re)return se;Re=1;var s=w,d=Symbol.for("react.element"),a=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function v(m,u,j){var b,P={},g=null,z=null;j!==void 0&&(g=""+j),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(z=u.ref);for(b in u)n.call(u,b)&&!i.hasOwnProperty(b)&&(P[b]=u[b]);if(m&&m.defaultProps)for(b in u=m.defaultProps,u)P[b]===void 0&&(P[b]=u[b]);return{$$typeof:d,type:m,key:g,ref:z,props:P,_owner:l.current}}return se.Fragment=a,se.jsx=v,se.jsxs=v,se}var le={},Ae;function mt(){if(Ae)return le;Ae=1;var s={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/return s.NODE_ENV!=="production"&&(function(){var d=w,a=Symbol.for("react.element"),n=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),u=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),y=Symbol.iterator,O="@@iterator";function r(t){if(t===null||typeof t!="object")return null;var c=y&&t[y]||t[O];return typeof c=="function"?c:null}var f=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(t){{for(var c=arguments.length,p=new Array(c>1?c-1:0),C=1;C<c;C++)p[C-1]=arguments[C];_("error",t,p)}}function _(t,c,p){{var C=f.ReactDebugCurrentFrame,D=C.getStackAddendum();D!==""&&(c+="%s",p=p.concat([D]));var $=p.map(function(I){return String(I)});$.unshift("Warning: "+c),Function.prototype.apply.call(console[t],console,$)}}var h=!1,S=!1,F=!1,V=!1,H=!1,q;q=Symbol.for("react.module.reference");function W(t){return!!(typeof t=="string"||typeof t=="function"||t===l||t===v||H||t===i||t===b||t===P||V||t===N||h||S||F||typeof t=="object"&&t!==null&&(t.$$typeof===z||t.$$typeof===g||t.$$typeof===m||t.$$typeof===u||t.$$typeof===j||t.$$typeof===q||t.getModuleId!==void 0))}function re(t,c,p){var C=t.displayName;if(C)return C;var D=c.displayName||c.name||"";return D!==""?p+"("+D+")":p}function ne(t){return t.displayName||"Context"}function U(t){if(t==null)return null;if(typeof t.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case l:return"Fragment";case n:return"Portal";case v:return"Profiler";case i:return"StrictMode";case b:return"Suspense";case P:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case u:var c=t;return ne(c)+".Consumer";case m:var p=t;return ne(p._context)+".Provider";case j:return re(t,t.render,"ForwardRef");case g:var C=t.displayName||null;return C!==null?C:U(t.type)||"Memo";case z:{var D=t,$=D._payload,I=D._init;try{return U(I($))}catch{return null}}}return null}var k=Object.assign,R=0,G,Z,He,Ue,qe,Ge,Ke;function Xe(){}Xe.__reactDisabledLog=!0;function Rt(){{if(R===0){G=console.log,Z=console.info,He=console.warn,Ue=console.error,qe=console.group,Ge=console.groupCollapsed,Ke=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Xe,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}R++}}function At(){{if(R--,R===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},t,{value:G}),info:k({},t,{value:Z}),warn:k({},t,{value:He}),error:k({},t,{value:Ue}),group:k({},t,{value:qe}),groupCollapsed:k({},t,{value:Ge}),groupEnd:k({},t,{value:Ke})})}R<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=f.ReactCurrentDispatcher,ke;function ye(t,c,p){{if(ke===void 0)try{throw Error()}catch(D){var C=D.stack.trim().match(/\n( *(at )?)/);ke=C&&C[1]||""}return`
|
|
18
|
+
`+ke+t}}var Pe=!1,ve;{var Nt=typeof WeakMap=="function"?WeakMap:Map;ve=new Nt}function Ze(t,c){if(!t||Pe)return"";{var p=ve.get(t);if(p!==void 0)return p}var C;Pe=!0;var D=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $;$=Te.current,Te.current=null,Rt();try{if(c){var I=function(){throw Error()};if(Object.defineProperty(I.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(I,[])}catch(X){C=X}Reflect.construct(t,[],I)}else{try{I.call()}catch(X){C=X}t.call(I.prototype)}}else{try{throw Error()}catch(X){C=X}t()}}catch(X){if(X&&C&&typeof X.stack=="string"){for(var E=X.stack.split(`
|
|
19
|
+
`),K=C.stack.split(`
|
|
20
|
+
`),L=E.length-1,J=K.length-1;L>=1&&J>=0&&E[L]!==K[J];)J--;for(;L>=1&&J>=0;L--,J--)if(E[L]!==K[J]){if(L!==1||J!==1)do if(L--,J--,J<0||E[L]!==K[J]){var Q=`
|
|
21
|
+
`+E[L].replace(" at new "," at ");return t.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",t.displayName)),typeof t=="function"&&ve.set(t,Q),Q}while(L>=1&&J>=0);break}}}finally{Pe=!1,Te.current=$,At(),Error.prepareStackTrace=D}var oe=t?t.displayName||t.name:"",te=oe?ye(oe):"";return typeof t=="function"&&ve.set(t,te),te}function Ft(t,c,p){return Ze(t,!1)}function $t(t){var c=t.prototype;return!!(c&&c.isReactComponent)}function be(t,c,p){if(t==null)return"";if(typeof t=="function")return Ze(t,$t(t));if(typeof t=="string")return ye(t);switch(t){case b:return ye("Suspense");case P:return ye("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case j:return Ft(t.render);case g:return be(t.type,c,p);case z:{var C=t,D=C._payload,$=C._init;try{return be($(D),c,p)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,Qe={},et=f.ReactDebugCurrentFrame;function je(t){if(t){var c=t._owner,p=be(t.type,t._source,c?c.type:null);et.setExtraStackFrame(p)}else et.setExtraStackFrame(null)}function Bt(t,c,p,C,D){{var $=Function.call.bind(de);for(var I in t)if($(t,I)){var E=void 0;try{if(typeof t[I]!="function"){var K=Error((C||"React class")+": "+p+" type `"+I+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[I]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw K.name="Invariant Violation",K}E=t[I](c,I,C,p,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(L){E=L}E&&!(E instanceof Error)&&(je(D),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",p,I,typeof E),je(null)),E instanceof Error&&!(E.message in Qe)&&(Qe[E.message]=!0,je(D),x("Failed %s type: %s",p,E.message),je(null))}}}var Vt=Array.isArray;function Ee(t){return Vt(t)}function Wt(t){{var c=typeof Symbol=="function"&&Symbol.toStringTag,p=c&&t[Symbol.toStringTag]||t.constructor.name||"Object";return p}}function Lt(t){try{return tt(t),!1}catch{return!0}}function tt(t){return""+t}function rt(t){if(Lt(t))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Wt(t)),tt(t)}var nt=f.ReactCurrentOwner,Mt={key:!0,ref:!0,__self:!0,__source:!0},it,ot;function Jt(t){if(de.call(t,"ref")){var c=Object.getOwnPropertyDescriptor(t,"ref").get;if(c&&c.isReactWarning)return!1}return t.ref!==void 0}function Yt(t){if(de.call(t,"key")){var c=Object.getOwnPropertyDescriptor(t,"key").get;if(c&&c.isReactWarning)return!1}return t.key!==void 0}function Ht(t,c){typeof t.ref=="string"&&nt.current}function Ut(t,c){{var p=function(){it||(it=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};p.isReactWarning=!0,Object.defineProperty(t,"key",{get:p,configurable:!0})}}function qt(t,c){{var p=function(){ot||(ot=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};p.isReactWarning=!0,Object.defineProperty(t,"ref",{get:p,configurable:!0})}}var Gt=function(t,c,p,C,D,$,I){var E={$$typeof:a,type:t,key:c,ref:p,props:I,_owner:$};return E._store={},Object.defineProperty(E._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(E,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(E,"_source",{configurable:!1,enumerable:!1,writable:!1,value:D}),Object.freeze&&(Object.freeze(E.props),Object.freeze(E)),E};function Kt(t,c,p,C,D){{var $,I={},E=null,K=null;p!==void 0&&(rt(p),E=""+p),Yt(c)&&(rt(c.key),E=""+c.key),Jt(c)&&(K=c.ref,Ht(c,D));for($ in c)de.call(c,$)&&!Mt.hasOwnProperty($)&&(I[$]=c[$]);if(t&&t.defaultProps){var L=t.defaultProps;for($ in L)I[$]===void 0&&(I[$]=L[$])}if(E||K){var J=typeof t=="function"?t.displayName||t.name||"Unknown":t;E&&Ut(I,J),K&&qt(I,J)}return Gt(t,E,K,D,C,nt.current,I)}}var _e=f.ReactCurrentOwner,st=f.ReactDebugCurrentFrame;function ie(t){if(t){var c=t._owner,p=be(t.type,t._source,c?c.type:null);st.setExtraStackFrame(p)}else st.setExtraStackFrame(null)}var Oe;Oe=!1;function Ie(t){return typeof t=="object"&&t!==null&&t.$$typeof===a}function lt(){{if(_e.current){var t=U(_e.current.type);if(t)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+t+"`."}return""}}function Xt(t){return""}var at={};function Zt(t){{var c=lt();if(!c){var p=typeof t=="string"?t:t.displayName||t.name;p&&(c=`
|
|
24
|
+
|
|
25
|
+
Check the top-level render call using <`+p+">.")}return c}}function ct(t,c){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var p=Zt(c);if(at[p])return;at[p]=!0;var C="";t&&t._owner&&t._owner!==_e.current&&(C=" It was passed a child from "+U(t._owner.type)+"."),ie(t),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',p,C),ie(null)}}function dt(t,c){{if(typeof t!="object")return;if(Ee(t))for(var p=0;p<t.length;p++){var C=t[p];Ie(C)&&ct(C,c)}else if(Ie(t))t._store&&(t._store.validated=!0);else if(t){var D=r(t);if(typeof D=="function"&&D!==t.entries)for(var $=D.call(t),I;!(I=$.next()).done;)Ie(I.value)&&ct(I.value,c)}}}function Qt(t){{var c=t.type;if(c==null||typeof c=="string")return;var p;if(typeof c=="function")p=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===j||c.$$typeof===g))p=c.propTypes;else return;if(p){var C=U(c);Bt(p,t.props,"prop",C,t)}else if(c.PropTypes!==void 0&&!Oe){Oe=!0;var D=U(c);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",D||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function er(t){{for(var c=Object.keys(t.props),p=0;p<c.length;p++){var C=c[p];if(C!=="children"&&C!=="key"){ie(t),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),ie(null);break}}t.ref!==null&&(ie(t),x("Invalid attribute `ref` supplied to `React.Fragment`."),ie(null))}}var ut={};function ht(t,c,p,C,D,$){{var I=W(t);if(!I){var E="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var K=Xt();K?E+=K:E+=lt();var L;t===null?L="null":Ee(t)?L="array":t!==void 0&&t.$$typeof===a?(L="<"+(U(t.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):L=typeof t,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",L,E)}var J=Kt(t,c,p,D,$);if(J==null)return J;if(I){var Q=c.children;if(Q!==void 0)if(C)if(Ee(Q)){for(var oe=0;oe<Q.length;oe++)dt(Q[oe],t);Object.freeze&&Object.freeze(Q)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else dt(Q,t)}if(de.call(c,"key")){var te=U(t),X=Object.keys(c).filter(function(sr){return sr!=="key"}),ze=X.length>0?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}";if(!ut[te+ze]){var or=X.length>0?"{"+X.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
+
let props = %s;
|
|
27
|
+
<%s {...props} />
|
|
28
|
+
React keys must be passed directly to JSX without using spread:
|
|
29
|
+
let props = %s;
|
|
30
|
+
<%s key={someKey} {...props} />`,ze,te,or,te),ut[te+ze]=!0}}return t===l?er(J):Qt(J),J}}function tr(t,c,p){return ht(t,c,p,!0)}function rr(t,c,p){return ht(t,c,p,!1)}var nr=rr,ir=tr;le.Fragment=l,le.jsx=nr,le.jsxs=ir})(),le}var Ne;function xt(){if(Ne)return ue.exports;Ne=1;var s={};return s.NODE_ENV==="production"?ue.exports=gt():ue.exports=mt(),ue.exports}var e=xt();const he={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}},Fe={paperSize:"A4",customWidth:210,customHeight:297,orientation:"portrait",marginTop:10,marginRight:10,marginBottom:10,marginLeft:10,showHeader:!1,headerContent:"页眉文字",showFooter:!1,footerContent:"页脚文字",showPageNumber:!0,pageNumberFormat:"第 {page} 页"},A=3,fe={cellSize:1,cols:100},$e={text:"文本",image:"图片",table:"表格",barcode:"条形码",line:"分割线"},yt={text:{content:"双击编辑文字",fontSize:14,fontWeight:"normal",fontStyle:"normal",textAlign:"left",color:"#000000",backgroundColor:"transparent"},image:{src:"",fit:"contain",content:""},table:{rows:3,cols:3,borderWidth:1,borderColor:"#000000",content:""},barcode:{value:"1234567890",format:"CODE128",content:""},line:{color:"#000000",thickness:1,style:"solid",content:""}};let Se=0,Ce=0;function Be(){return`comp_${++Se}`}function Ve(){return`ds_${++Ce}`}const T=ft.create((s,d)=>({components:[],selectedId:null,pageSettings:{...Fe},gridSettings:{...fe},previewVisible:!1,templateName:"未命名模板",headerFooterVisible:!1,dataSources:[],activeDataSourceId:null,addComponent:(a,n,l)=>{const i=Be(),v=$e[a]||a,m={...yt[a]||{}};a==="text"&&(m.content=v);const u={id:i,type:a,x:n??0,y:l??0,w:a==="line"?20:15,h:a==="line"?1:8,props:m,...a==="table"?{tableColumns:[{title:"列1"},{title:"列2"},{title:"列3"}]}:{}};s(j=>({components:[...j.components,u],selectedId:i}))},updateComponent:(a,n)=>{s(l=>({components:l.components.map(i=>i.id===a?{...i,...n}:i)}))},selectComponent:a=>{s({selectedId:a})},removeComponent:a=>{s(n=>({components:n.components.filter(l=>l.id!==a),selectedId:n.selectedId===a?null:n.selectedId}))},setComponents:a=>{s({components:a})},setPageSettings:a=>{s(n=>({pageSettings:{...n.pageSettings,...a}}))},setPreviewVisible:a=>{s({previewVisible:a})},setTemplateName:a=>{s({templateName:a})},setHeaderFooterVisible:a=>{s({headerFooterVisible:a})},addDataSource:(a,n,l)=>{const v={id:Ve(),name:a,type:n,data:l,createdAt:Date.now()};s(m=>({dataSources:[...m.dataSources,v]}))},updateDataSource:(a,n)=>{s(l=>({dataSources:l.dataSources.map(i=>i.id===a?{...i,...n}:i)}))},removeDataSource:a=>{s(n=>({dataSources:n.dataSources.filter(l=>l.id!==a),activeDataSourceId:n.activeDataSourceId===a?null:n.activeDataSourceId}))},setActiveDataSourceId:a=>{s({activeDataSourceId:a})},updateComponentTableColumns:(a,n)=>{s(l=>({components:l.components.map(i=>i.id===a?{...i,tableColumns:n}:i)}))},exportJSON:()=>{const a=d(),n={version:"1.0",templateName:a.templateName,pageSettings:a.pageSettings,components:a.components.map(({id:l,...i})=>i),dataSources:a.dataSources.map(({id:l,...i})=>i)};return JSON.stringify(n,null,2)},importJSON:a=>{try{const n=JSON.parse(a);if(!n.version||!n.pageSettings||!Array.isArray(n.components))return"JSON 格式不正确,缺少必要字段";Se=0,Ce=0;const l=n.components.map(v=>({...v,id:Be()})),i=(n.dataSources||[]).map(v=>({...v,id:Ve()}));return s({components:l,dataSources:i,pageSettings:n.pageSettings,templateName:n.templateName||"导入的模板",selectedId:null,activeDataSourceId:null}),null}catch{return"JSON 解析失败,请检查文件内容"}},reset:()=>{Se=0,Ce=0,s({components:[],selectedId:null,pageSettings:{...Fe},gridSettings:{...fe},templateName:"未命名模板",headerFooterVisible:!1,previewVisible:!1,dataSources:[],activeDataSourceId:null})}})),{Text:lr}=o.Typography,vt=({onCustomSave:s,onCustomPrint:d})=>{const a=T(f=>f.templateName),n=T(f=>f.setTemplateName),l=T(f=>f.setPreviewVisible),i=T(f=>f.setHeaderFooterVisible),v=T(f=>f.selectedId),m=T(f=>f.removeComponent),u=T(f=>f.exportJSON),j=T(f=>f.importJSON),b=T(f=>f.reset),P=w.useRef(null),{message:g}=o.App.useApp(),z=w.useCallback(()=>{v&&m(v)},[v,m]),N=w.useCallback(()=>{const f=u(),x=new Blob([f],{type:"application/json"}),_=URL.createObjectURL(x),h=document.createElement("a");h.href=_,h.download=`${a||"模板"}.json`,h.click(),URL.revokeObjectURL(_),g.success("模板已导出")},[u,a,g]),y=w.useCallback(()=>{var f;(f=P.current)==null||f.click()},[]),O=w.useCallback(f=>{var h;const x=(h=f.target.files)==null?void 0:h[0];if(!x)return;const _=new FileReader;_.onload=()=>{const S=j(_.result);S?g.error(S):g.success("模板已导入")},_.readAsText(x),f.target.value=""},[j,g]),r=w.useCallback(()=>{b(),g.info("已新建空白模板")},[b,g]);return e.jsxs("div",{style:{height:48,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 16px",borderBottom:"1px solid #e8e8e8",background:"#fff"},children:[e.jsx(o.Space,{children:e.jsx(o.Input,{value:a,onChange:f=>n(f.target.value),variant:"borderless",style:{width:200,fontSize:16,fontWeight:600},placeholder:"模板名称"})}),e.jsxs(o.Space,{children:[e.jsx(o.Button,{icon:e.jsx(B.PlusOutlined,{}),onClick:r,children:"新建"}),e.jsx("input",{ref:P,type:"file",accept:".json",style:{display:"none"},onChange:O}),s?e.jsx(o.Button,{icon:e.jsx(B.SaveOutlined,{}),onClick:s,type:"primary",children:"保存"}):e.jsx(o.Button,{icon:e.jsx(B.DownloadOutlined,{}),onClick:N,children:"导出"}),e.jsx(o.Button,{icon:e.jsx(B.UploadOutlined,{}),onClick:y,children:"导入"}),e.jsx(o.Button,{icon:e.jsx(B.SettingOutlined,{}),onClick:()=>i(!0),children:"页眉页脚"}),e.jsx(o.Button,{danger:!0,icon:e.jsx(B.DeleteOutlined,{}),disabled:!v,onClick:z,children:"删除"}),d?e.jsx(o.Button,{type:"primary",icon:e.jsx(B.PrinterOutlined,{}),onClick:d,children:"打印"}):e.jsx(o.Button,{type:"primary",icon:e.jsx(B.EyeOutlined,{}),onClick:()=>l(!0),children:"预览"})]})]})},{Text:ee}=o.Typography,bt=()=>{const s=T(i=>i.pageSettings),d=T(i=>i.setPageSettings),a=s.paperSize==="custom",n=w.useCallback(i=>{d({paperSize:i})},[d]),l=w.useCallback(i=>{d({orientation:i})},[d]);return e.jsx(o.Card,{title:"页面设置",size:"small",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:12},children:"纸张大小"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:s.paperSize,onChange:n,options:[...Object.keys(he).map(i=>({value:i,label:i})),{value:"custom",label:"自定义"}]})]}),a&&e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(ee,{style:{fontSize:12},children:"宽度 (mm)"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:s.customWidth,min:10,max:2e3,onChange:i=>d({customWidth:i??210})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(ee,{style:{fontSize:12},children:"高度 (mm)"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:s.customHeight,min:10,max:2e3,onChange:i=>d({customHeight:i??297})})]})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:12},children:"方向"}),e.jsxs(o.Radio.Group,{value:s.orientation,onChange:i=>l(i.target.value),size:"small",style:{width:"100%",display:"flex"},children:[e.jsx(o.Radio.Button,{value:"portrait",style:{flex:1,textAlign:"center"},children:"纵向"}),e.jsx(o.Radio.Button,{value:"landscape",style:{flex:1,textAlign:"center"},children:"横向"})]})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:12},children:"页边距 (mm)"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"上"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:s.marginTop,min:0,max:100,onChange:i=>d({marginTop:i??10})})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"右"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:s.marginRight,min:0,max:100,onChange:i=>d({marginRight:i??10})})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"下"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:s.marginBottom,min:0,max:100,onChange:i=>d({marginBottom:i??10})})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"左"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:s.marginLeft,min:0,max:100,onChange:i=>d({marginLeft:i??10})})]})]})]})]})})},{Text:jt}=o.Typography,St=[{type:"text",icon:e.jsx(B.FontSizeOutlined,{}),label:"文本"},{type:"image",icon:e.jsx(B.PictureOutlined,{}),label:"图片"},{type:"table",icon:e.jsx(B.TableOutlined,{}),label:"表格"},{type:"barcode",icon:e.jsx(B.BarcodeOutlined,{}),label:"条形码"},{type:"line",icon:e.jsx(B.MinusOutlined,{}),label:"分割线"}],Ct=()=>{const s=T(n=>n.addComponent),d=w.useCallback((n,l)=>{n.dataTransfer.setData("componentType",l),n.dataTransfer.effectAllowed="copy"},[]),a=w.useCallback(n=>{s(n)},[s]);return e.jsx(o.Card,{title:"组件面板",size:"small",children:e.jsx(o.Space,{direction:"vertical",style:{width:"100%"},size:4,children:St.map(n=>e.jsxs("div",{draggable:!0,onDragStart:l=>d(l,n.type),onClick:()=>a(n.type),style:{cursor:"grab",padding:"8px 12px",border:"1px solid #d9d9d9",borderRadius:6,display:"flex",alignItems:"center",gap:8,background:"#fafafa",userSelect:"none",transition:"all 0.2s"},onMouseEnter:l=>{l.currentTarget.style.background="#e6f4ff",l.currentTarget.style.borderColor="#1677ff"},onMouseLeave:l=>{l.currentTarget.style.background="#fafafa",l.currentTarget.style.borderColor="#d9d9d9"},children:[n.icon,e.jsx(jt,{children:n.label})]},n.type))})})};function ae(s){try{return JSON.parse(s)}catch{return null}}function ce(s,d,a){const n=`${d}Binding`,l=s.props[n];if(l&&l.dataSourceId&&l.fieldPath){const v=a.find(m=>m.id===l.dataSourceId);if(v){const m=ge(v);if(m){const u=pe(m,l.fieldPath);if(u)return u}}}return s.props[d]||(l==null?void 0:l.staticValue)||""}function pe(s,d){if(!s||!d)return"";try{const a=d.split(".");let n=s;for(const l of a){if(typeof n!="object"||n===null)return"";n=n[l]}return n!=null?String(n):""}catch{return""}}function ge(s){const d=ae(s.data);return s.type==="object"&&d&&typeof d=="object"&&!Array.isArray(d)?d:null}function me(s){const d=ae(s.data);return s.type==="array"&&Array.isArray(d)?d:null}const{TextArea:wt}=o.Input,{Text:xe,Title:ar}=o.Typography,We=JSON.stringify({name:"张三",age:28,department:"技术部",email:"zhangsan@example.com"},null,2),Tt=JSON.stringify([{id:1,product:"商品A",quantity:2,price:100},{id:2,product:"商品B",quantity:5,price:80},{id:3,product:"商品C",quantity:1,price:200}],null,2),kt=()=>{const s=T(g=>g.dataSources),d=T(g=>g.addDataSource),a=T(g=>g.updateDataSource),n=T(g=>g.removeDataSource),[l,i]=w.useState(!1),[v,m]=w.useState(null),[u,j]=w.useState({name:"",type:"object",data:""}),b=g=>{g?(m(g.id),j({name:g.name,type:g.type,data:g.data})):(m(null),j({name:"新数据源",type:"object",data:We})),i(!0)},P=()=>{const g=ae(u.data);if(g===null){o.message.error("JSON 格式不正确");return}if(u.type==="object"&&(Array.isArray(g)||typeof g!="object")){o.message.error("对象类型数据源必须为对象格式");return}if(u.type==="array"&&!Array.isArray(g)){o.message.error("数组类型数据源必须为数组格式");return}v?(a(v,u),o.message.success("数据源已更新")):(d(u.name,u.type,u.data),o.message.success("数据源已添加")),i(!1)};return e.jsxs(o.Card,{title:"数据源",size:"small",extra:e.jsx(o.Button,{type:"link",size:"small",icon:e.jsx(B.PlusOutlined,{}),onClick:()=>b(),children:"添加"}),children:[e.jsx(o.List,{size:"small",dataSource:s,locale:{emptyText:"暂无数据源"},renderItem:g=>e.jsx(o.List.Item,{actions:[e.jsx(o.Dropdown,{menu:{items:[{key:"edit",label:"编辑",icon:e.jsx(B.EditOutlined,{}),onClick:()=>b(g)},{type:"divider"},{key:"delete",label:e.jsx(o.Popconfirm,{title:"确定要删除这个数据源吗?",onConfirm:z=>{z==null||z.stopPropagation(),n(g.id),o.message.success("已删除")},okText:"确定",cancelText:"取消",onCancel:z=>z==null?void 0:z.stopPropagation(),children:e.jsx("span",{style:{color:"#ff4d4f",cursor:"pointer"},children:"删除"})}),icon:e.jsx(B.DeleteOutlined,{style:{color:"#ff4d4f"}})}]},placement:"bottomRight",children:e.jsx(o.Button,{type:"text",size:"small",icon:e.jsx(B.MoreOutlined,{})})})],children:e.jsx(o.List.Item.Meta,{avatar:e.jsx(B.DatabaseOutlined,{}),title:e.jsx(xe,{strong:!0,children:g.name}),description:e.jsx(o.Space,{size:4,children:e.jsx(o.Tag,{color:g.type==="object"?"blue":"green",children:g.type==="object"?"对象":"数组"})})})})}),e.jsx(o.Modal,{title:v?"编辑数据源":"添加数据源",open:l,onOk:P,onCancel:()=>i(!1),okText:"保存",cancelText:"取消",children:e.jsxs(o.Space,{direction:"vertical",style:{width:"100%"},size:"middle",children:[e.jsxs("div",{children:[e.jsx(xe,{strong:!0,style:{display:"block",marginBottom:4},children:"名称"}),e.jsx(o.Input,{placeholder:"请输入数据源名称",value:u.name,onChange:g=>j({...u,name:g.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{strong:!0,style:{display:"block",marginBottom:4},children:"类型"}),e.jsx(o.Select,{options:[{label:"对象",value:"object"},{label:"数组",value:"array"}],style:{width:"100%"},value:u.type,onChange:g=>{j({...u,type:g,data:g==="object"?We:Tt})}})]}),e.jsx(o.Divider,{style:{margin:"8px 0"}}),e.jsxs("div",{children:[e.jsx(xe,{strong:!0,style:{display:"block",marginBottom:4},children:"JSON 数据"}),e.jsx(wt,{rows:12,placeholder:"请输入 JSON 数据",value:u.data,onChange:g=>j({...u,data:g.target.value})})]})]})})]})},Pt=()=>e.jsx(o.Collapse,{bordered:!1,defaultActiveKey:["1","2"],expandIcon:({isActive:s})=>e.jsx(B.CaretRightOutlined,{rotate:s?90:0}),style:{height:"100%",overflowY:"auto"},items:[{key:"1",label:"页面设置",children:e.jsx(bt,{})},{key:"2",label:"组件",children:e.jsx(Ct,{})},{key:"3",label:"数据源",children:e.jsx(kt,{})}]});function Le(s){const d=[];d.push(1,1,0,1,1,0,1,1);for(let a=0;a<s.length;a++){const l=(s.charCodeAt(a)%103).toString(2).padStart(7,"0");for(const i of l)d.push(i==="1"?1:0)}return d.push(1,1,0,0,0,1,1,0,0,0,1,1),d}const we=({value:s,format:d})=>{const a=w.useMemo(()=>Le(s),[s,d]);if(!s)return e.jsx("div",{style:{fontSize:11,color:"#999"},children:"请设置条形码值"});const n=2,l=44,i=a.length*n;return e.jsxs("div",{style:{textAlign:"center",overflow:"hidden",maxWidth:"100%"},children:[e.jsx("canvas",{ref:v=>{if(!v)return;const m=v.getContext("2d");m&&(v.width=i,v.height=l,m.clearRect(0,0,i,l),a.forEach((u,j)=>{m.fillStyle=u===1?"#000":"#fff",m.fillRect(j*n,0,n,l)}))},style:{width:"100%",maxWidth:i,height:l}}),e.jsx("div",{style:{fontSize:10,marginTop:1,letterSpacing:1},children:s})]})},Et=pt,Me=w.memo(({comp:s,selected:d,isPreview:a=!1,dataSources:n=[]})=>{const l={width:"100%",height:"100%",overflow:"hidden",boxSizing:"border-box",outline:a?"none":d?"2px solid #1677ff":"1px dashed #d9d9d9",outlineOffset:-1},i=v=>ce(s,v,n);switch(s.type){case"text":return e.jsx("div",{style:{...l,fontSize:s.props.fontSize||14,fontWeight:s.props.fontWeight||"normal",fontStyle:s.props.fontStyle||"normal",textAlign:s.props.textAlign||"left",color:s.props.color||"#000",backgroundColor:s.props.backgroundColor||"transparent",padding:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i("content")||""});case"image":const v=i("src")||s.props.src;return e.jsx("div",{style:l,children:v?e.jsx("img",{src:v,style:{width:"100%",height:"100%",objectFit:s.props.fit||"contain"},alt:""}):e.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#bbb",fontSize:12},children:"请在属性中设置图片地址"})});case"table":return e.jsx(_t,{comp:s,style:l,dataSources:n});case"barcode":const m=i("value")||s.props.value||"123456";return e.jsx("div",{style:{...l,display:"flex",alignItems:"center",justifyContent:"center",padding:4},children:e.jsx(we,{value:m,format:s.props.format||"CODE128"})});case"line":return e.jsx("div",{style:{...l,display:"flex",alignItems:"center",border:"none",outline:d?"2px solid #1677ff":"1px dashed transparent"},children:e.jsx("hr",{style:{width:"100%",border:"none",borderTop:`${s.props.thickness||1}px ${s.props.style||"solid"} ${s.props.color||"#000"}`,margin:0}})});default:return e.jsx("div",{style:l,children:s.type})}}),_t=({comp:s,style:d,dataSources:a=[]})=>{const n=s.props.borderWidth||1,l=s.props.borderColor||"#000",i=s.tableColumns||[],v=s.props.tableDataSourceId,m=v?a.find(P=>P.id===v):null,u=m?me(m):null;if(u&&u.length>0)return e.jsxs("table",{style:{...d,borderCollapse:"collapse",width:"100%",height:"100%"},children:[i.length>0&&e.jsx("thead",{children:e.jsx("tr",{style:{backgroundColor:"#f5f5f5"},children:i.map((P,g)=>e.jsx("th",{style:{border:`${n}px solid ${l}`,padding:4,fontSize:12,fontWeight:"bold",textAlign:"center"},children:P.title},g))})}),e.jsx("tbody",{children:u.map((P,g)=>e.jsx("tr",{children:i.map((z,N)=>e.jsx("td",{style:{border:`${n}px solid ${l}`,padding:4,fontSize:12,textAlign:"center"},children:z.fieldPath?P[z.fieldPath]:""},N))},g))})]});const j=s.props.rows||3,b=Math.max(s.props.cols||3,i.length||3);return e.jsx("table",{style:{...d,borderCollapse:"collapse",width:"100%",height:"100%"},children:e.jsx("tbody",{children:Array.from({length:j}).map((P,g)=>e.jsx("tr",{children:Array.from({length:b}).map((z,N)=>e.jsx("td",{style:{border:`${n}px solid ${l}`,padding:2,fontSize:12,textAlign:"center"},children:" "},N))},g))})})},Je=({isPreview:s=!1})=>{const d=T(r=>r.components),a=T(r=>r.selectedId),n=T(r=>r.pageSettings),l=T(r=>r.selectComponent);T(r=>r.updateComponent);const i=T(r=>r.setComponents),v=T(r=>r.addComponent),m=T(r=>r.gridSettings),u=T(r=>r.dataSources),j=w.useMemo(()=>{const r=he[n.paperSize];if(!r)return{width:n.customWidth*A,height:n.customHeight*A};const f=r.width*A,x=r.height*A;return n.orientation==="landscape"?{width:x,height:f}:{width:f,height:x}},[n]),b=w.useMemo(()=>({top:n.marginTop*A,right:n.marginRight*A,bottom:n.marginBottom*A,left:n.marginLeft*A}),[n]),P=j.width-b.left-b.right,g=j.height-b.top-b.bottom,z=w.useMemo(()=>d.map(r=>({i:r.id,x:r.x,y:r.y,w:r.w,h:r.h})),[d]),N=w.useCallback(r=>{const f=d.map((x,_)=>{const h=r[_];return h?{...x,x:h.x,y:h.y,w:h.w,h:h.h}:x});i(f)},[d,i]),y=w.useCallback((r,f,x)=>{var F,V;const _=x,h=(F=_.dataTransfer)==null?void 0:F.getData("componentType");if(!h)return;const S=(V=x.target.closest(".react-grid-layout"))==null?void 0:V.getBoundingClientRect();if(S){const H=Math.floor((_.clientX-S.left)/(P/m.cols)),q=Math.floor((_.clientY-S.top)/(P/m.cols));v(h,Math.max(0,H),Math.max(0,q))}else v(h)},[v,P,m.cols]),O=w.useCallback(r=>{l(r===a?null:r)},[l,a]);return e.jsx("div",{style:{flex:1,overflow:"auto",background:"#e8e8e8",display:"flex",justifyContent:"center",padding:"24px 0"},children:e.jsxs("div",{id:"print-paper",style:{width:j.width,height:j.height,background:"#fff",boxShadow:"0 2px 12px rgba(0,0,0,0.15)",position:"relative",flexShrink:0},children:[n.showHeader&&e.jsx("div",{style:{position:"absolute",top:0,left:b.left,right:b.right,height:b.top,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:"#999",borderBottom:"1px dashed #ddd",overflow:"hidden"},children:n.headerContent}),n.showFooter&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:b.left,right:b.right,height:b.bottom,display:"flex",alignItems:"center",justifyContent:n.showPageNumber?"space-between":"center",fontSize:12,color:"#999",borderTop:"1px dashed #ddd",overflow:"hidden",padding:"0 8px"},children:[e.jsx("span",{children:n.footerContent}),n.showPageNumber&&e.jsx("span",{children:n.pageNumberFormat.replace("{page}","1")})]}),e.jsx("div",{style:{position:"absolute",top:b.top,left:b.left,width:P,height:g},children:s?e.jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:d.map(r=>{const f=P/m.cols,x=P/m.cols,_={position:"absolute",left:r.x*f,top:r.y*x,width:r.w*f,height:r.h*x};return e.jsx("div",{style:_,children:e.jsx(Me,{comp:r,selected:!1,isPreview:!0,dataSources:u})},r.id)})}):e.jsx(Et,{className:"canvas-grid",layout:z,cols:m.cols,rowHeight:P/m.cols,width:P,margin:[0,0],containerPadding:[0,0],onLayoutChange:N,onDrop:y,isDroppable:!0,isResizable:!0,isDraggable:!0,compactType:null,preventCollision:!0,draggableHandle:".grid-item-drag-handle",style:{minHeight:g},children:d.map(r=>e.jsx("div",{className:"grid-item-drag-handle",onClick:()=>O(r.id),style:{cursor:"move"},children:e.jsx(Me,{comp:r,selected:r.id===a,dataSources:u})},r.id))})})]})})},{Text:M,Title:cr}=o.Typography,{TextArea:Ot}=o.Input,It=()=>{const s=T(r=>r.components),d=T(r=>r.selectedId),a=T(r=>r.dataSources),n=T(r=>r.updateComponent),l=T(r=>r.updateComponentTableColumns),i=w.useMemo(()=>s.find(r=>r.id===d)||null,[s,d]),[v,m]=w.useState([]),u=w.useMemo(()=>[{label:"无(使用静态值)",value:""},...a.map(r=>({label:r.name,value:r.id,type:r.type}))],[a]),j=w.useCallback((r,f)=>{d&&n(d,{props:{...i==null?void 0:i.props,[r]:f}})},[d,i,n]),b=w.useCallback((r,f,x,_)=>{if(!d)return;let h=_;f&&x&&(h=_);const S=`${r}Binding`;n(d,{props:{...i==null?void 0:i.props,[r]:h,[S]:{dataSourceId:f,fieldPath:x,staticValue:_}}})},[d,i,n]),P=w.useCallback(r=>{const f=i==null?void 0:i.props[`${r}Binding`],x=String((i==null?void 0:i.props[r])||"");return f?{field:r,dataSourceId:f.dataSourceId||null,fieldPath:f.fieldPath||"",staticValue:f.staticValue??x}:{field:r,dataSourceId:null,fieldPath:"",staticValue:x}},[i]);if(!i)return e.jsx(o.Card,{title:"属性面板",size:"small",style:{height:"100%",borderRadius:0,borderLeft:0},styles:{body:{padding:16}},children:e.jsx(o.Empty,{description:"请选择画布中的组件",image:o.Empty.PRESENTED_IMAGE_SIMPLE})});const g=$e[i.type]||i.type,z=e.jsxs(e.Fragment,{children:[e.jsx(M,{type:"secondary",style:{fontSize:12,display:"block",marginBottom:8},children:"位置和大小"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"X"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:i.x,onChange:r=>n(d,{x:r??0})})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"Y"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:i.y,onChange:r=>n(d,{y:r??0})})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"宽度"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:i.w,min:1,onChange:r=>n(d,{w:r??1})})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"高度"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:i.h,min:1,onChange:r=>n(d,{h:r??1})})]})]})]}),N=({field:r,label:f,placeholder:x,isTextarea:_=!1})=>{const h=P(r),S=a.find(W=>W.id===h.dataSourceId),F=S?ge(S):null,V=F?Object.keys(F):[],[H,q]=w.useState(h.staticValue);return w.useEffect(()=>{q(h.staticValue)},[h.staticValue,h.dataSourceId]),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12,display:"block",marginBottom:4},children:f}),e.jsx("div",{style:{marginBottom:4},children:e.jsx(o.Select,{size:"small",style:{width:"100%"},placeholder:"选择数据源",value:h.dataSourceId||"",onChange:W=>{b(r,W||null,W&&h.fieldPath||"",h.staticValue)},options:u})}),h.dataSourceId&&e.jsx("div",{style:{marginBottom:4},children:e.jsx(o.Select,{size:"small",style:{width:"100%"},placeholder:"选择字段",value:h.fieldPath,onChange:W=>{b(r,h.dataSourceId,W||"",h.staticValue)},options:[{label:"请选择字段",value:""},...V.map(W=>({label:W,value:W}))]})}),h.dataSourceId?e.jsxs("div",{style:{padding:6,background:"#f0f5ff",border:"1px solid #adc6ff",borderRadius:4,fontSize:12},children:[e.jsx(B.DatabaseOutlined,{style:{marginRight:4,color:"#1890ff"}}),e.jsx("span",{style:{fontWeight:500},children:"数据绑定已启用"}),S&&h.fieldPath&&e.jsxs("span",{style:{marginLeft:8},children:[e.jsx(o.Tag,{color:"blue",children:S.name}),e.jsx(o.Tag,{color:"green",children:h.fieldPath})]})]}):_?e.jsx(Ot,{rows:3,placeholder:x,value:H,onChange:W=>q(W.target.value),onBlur:()=>{b(r,null,"",H)}}):e.jsx(o.Input,{placeholder:x,value:H,onChange:W=>q(W.target.value),onBlur:()=>{b(r,null,"",H)}})]})},y=()=>{const r=i.tableColumns||[],f=a.filter(k=>k.type==="array"),x=i.props.tableDataSourceId||"",_=f.find(k=>k.id===x),h=v.length>0?v:r,[S,F]=w.useState({}),V=()=>{l(d,h)},H=()=>{const k=[...h,{title:`列${h.length+1}`}];m(k)},q=k=>{const R=h.filter((G,Z)=>Z!==k);m(R)},W=(k,R,G)=>{const Z=[...h];Z[k]={...Z[k],[R]:G},m(Z)};let re=[];if(_){const k=ae(_.data);Array.isArray(k)&&k.length>0&&typeof k[0]=="object"&&(re=Object.keys(k[0]))}const ne=[{title:"列标题",dataIndex:"title",width:100,render:(k,R)=>{const G=R.key in S?S[R.key]:R.title;return e.jsx(o.Input,{size:"small",value:G,placeholder:"列标题",onChange:Z=>{F({...S,[R.key]:Z.target.value})},onBlur:()=>{if(R.key in S){W(Number(R.key),"title",S[R.key]);const Z={...S};delete Z[R.key],F(Z),V()}}})}},{title:"绑定字段",dataIndex:"fieldPath",width:120,render:(k,R)=>e.jsx(o.Select,{size:"small",style:{width:"100%"},value:R.fieldPath||"",placeholder:_?"绑定字段":"选择数据源先",disabled:!_,onChange:G=>{W(Number(R.key),"fieldPath",G||""),V()},options:[{label:"无绑定",value:""},...re.map(G=>({label:G,value:G}))]})},{title:"操作",width:60,render:(k,R)=>e.jsx(o.Popconfirm,{title:"确定要删除吗?",onConfirm:()=>{q(Number(R.key)),V()},okText:"确定",cancelText:"取消",children:e.jsx(o.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(B.DeleteOutlined,{})})})}],U=h.map((k,R)=>({...k,key:String(R)}));return e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:e.jsx(M,{style:{fontSize:12},children:"表格数据源"})}),e.jsx(o.Select,{size:"small",style:{width:"100%",marginBottom:8},placeholder:"选择数组类型数据源",value:x,onChange:k=>j("tableDataSourceId",k||""),options:[{label:"无(仅静态展示)",value:""},...f.map(k=>({label:k.name,value:k.id}))]}),e.jsx(o.Divider,{}),e.jsxs(o.Space,{style:{marginBottom:8},children:[e.jsx(M,{style:{fontSize:12},children:"列配置"}),e.jsx(o.Button,{size:"small",type:"dashed",icon:e.jsx(B.PlusOutlined,{}),onClick:H}),e.jsx(o.Button,{size:"small",type:"primary",onClick:V,icon:e.jsx(B.SaveOutlined,{})})]}),e.jsx(o.Table,{dataSource:U,columns:ne,pagination:!1,size:"small",bordered:!0,rowKey:"key"})]})},O=()=>{switch(i.type){case"text":return e.jsxs(e.Fragment,{children:[e.jsx(N,{field:"content",label:"内容",placeholder:"请输入文本内容",isTextarea:!0}),e.jsx(o.Divider,{style:{margin:"4px 0"}}),e.jsx(M,{type:"secondary",style:{fontSize:12,display:"block",marginBottom:4},children:"文字样式"}),e.jsxs(o.Space,{style:{width:"100%"},direction:"vertical",size:4,children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"字号"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:i.props.fontSize||14,min:6,max:200,onChange:r=>j("fontSize",r??14)})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"对齐"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:i.props.textAlign||"left",onChange:r=>j("textAlign",r),options:[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"}]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"字重"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:i.props.fontWeight||"normal",onChange:r=>j("fontWeight",r),options:[{value:"normal",label:"常规"},{value:"bold",label:"加粗"}]})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"样式"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:i.props.fontStyle||"normal",onChange:r=>j("fontStyle",r),options:[{value:"normal",label:"常规"},{value:"italic",label:"斜体"}]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"字体颜色"}),e.jsx(o.ColorPicker,{size:"small",value:i.props.color||"#000000",onChange:(r,f)=>j("color",f)})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"背景色"}),e.jsx(o.ColorPicker,{size:"small",value:i.props.backgroundColor||"transparent",onChange:(r,f)=>j("backgroundColor",f)})]})]})]})]});case"image":return e.jsxs(e.Fragment,{children:[e.jsx(N,{field:"src",label:"图片地址",placeholder:"输入图片 URL"}),e.jsx(o.Divider,{style:{margin:"4px 0"}}),e.jsx(M,{style:{fontSize:12,marginTop:8,display:"block"},children:"适应方式"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:i.props.fit||"contain",onChange:r=>j("fit",r),options:[{value:"contain",label:"适应"},{value:"cover",label:"填充"},{value:"fill",label:"拉伸"}]})]});case"table":return e.jsx(y,{});case"barcode":return e.jsxs(e.Fragment,{children:[e.jsx(N,{field:"value",label:"条码值",placeholder:"输入条码内容"}),e.jsx(o.Divider,{style:{margin:"4px 0"}}),e.jsx(M,{style:{fontSize:12,marginTop:8,display:"block"},children:"格式"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:i.props.format||"CODE128",onChange:r=>j("format",r),options:[{value:"CODE128",label:"CODE128"}]})]});case"line":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"粗细"}),e.jsx(o.InputNumber,{size:"small",style:{width:"100%"},value:i.props.thickness||1,min:1,max:20,onChange:r=>j("thickness",r??1)})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"样式"}),e.jsx(o.Select,{size:"small",style:{width:"100%"},value:i.props.style||"solid",onChange:r=>j("style",r),options:[{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"}]})]})]}),e.jsxs("div",{style:{marginTop:8},children:[e.jsx(M,{style:{fontSize:12},children:"颜色"}),e.jsx(o.ColorPicker,{size:"small",value:i.props.color||"#000000",onChange:(r,f)=>j("color",f)})]})]});default:return null}};return e.jsx(o.Card,{title:`属性 - ${g}`,size:"small",style:{height:"100%",borderRadius:0,borderLeft:0},styles:{body:{padding:16,overflowY:"auto"}},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[z,e.jsx(o.Divider,{style:{margin:"4px 0"}}),O()]})})},{Text:dr}=o.Typography,zt=()=>{const s=T(y=>y.previewVisible),d=T(y=>y.setPreviewVisible),a=T(y=>y.components),n=T(y=>y.pageSettings),l=T(y=>y.gridSettings)||fe,i=T(y=>y.dataSources),v=w.useRef(null),m=w.useMemo(()=>{const y=he[n.paperSize];if(!y)return{width:n.customWidth*A,height:n.customHeight*A};const O=y.width*A,r=y.height*A;return n.orientation==="landscape"?{width:r,height:O}:{width:O,height:r}},[n]),u=w.useMemo(()=>({top:n.marginTop*A,right:n.marginRight*A,bottom:n.marginBottom*A,left:n.marginLeft*A}),[n]),j=m.width-u.left-u.right,b=j/l.cols,P=De.useReactToPrint({contentRef:v,documentTitle:"打印模板",pageStyle:`
|
|
31
|
+
@page {
|
|
32
|
+
size: ${m.width/A}mm ${m.height/A}mm;
|
|
33
|
+
margin: ${n.marginTop}mm ${n.marginRight}mm ${n.marginBottom}mm ${n.marginLeft}mm;
|
|
34
|
+
}
|
|
35
|
+
@media print {
|
|
36
|
+
html, body { margin: 0; padding: 0; }
|
|
37
|
+
}
|
|
38
|
+
`}),g=(y,O)=>{const r=y.props[`${O}Binding`];if(r&&r.dataSourceId&&r.fieldPath){const f=i.find(x=>x.id===r.dataSourceId);if(f&&f.type==="object"){const x=ge(f);if(x){const _=pe(x,r.fieldPath);if(_!=="")return _}}}return(r==null?void 0:r.staticValue)??String(y.props[O]||"")},z=y=>{const O=y.props.tableDataSourceId,r=O?i.find(F=>F.id===O):null,f=r?me(r):null,x=y.tableColumns||[],_=y.props.borderWidth||1,h=y.props.borderColor||"#000000",S=f||Array.from({length:y.props.rows||3}).map(()=>({}));return e.jsxs("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{children:x.map((F,V)=>e.jsx("th",{style:{border:`${_}px solid ${h}`,padding:4,textAlign:"center",fontSize:12,fontWeight:"bold",backgroundColor:"#f5f5f5"},children:F.title||`列${V+1}`},V))})}),e.jsx("tbody",{children:S.map((F,V)=>e.jsx("tr",{children:x.map((H,q)=>e.jsx("td",{style:{border:`${_}px solid ${h}`,padding:4,textAlign:"center",fontSize:12},children:H.fieldPath?pe(F,H.fieldPath):""},q))},V))})]})},N=y=>{const O=y.props,r={position:"absolute",left:y.x*b,top:y.y*b,width:y.w*b,height:y.h*b,overflow:"hidden"},f={width:"100%",height:"100%",overflow:"hidden",boxSizing:"border-box"};switch(y.type){case"text":return e.jsx("div",{style:r,children:e.jsx("div",{style:{...f,fontSize:O.fontSize||14,fontWeight:O.fontWeight||"normal",fontStyle:O.fontStyle||"normal",textAlign:O.textAlign||"left",color:O.color||"#000",backgroundColor:O.backgroundColor||"transparent",padding:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:g(y,"content")})},y.id);case"image":return e.jsx("div",{style:r,children:e.jsx("div",{style:f,children:O.src?e.jsx("img",{src:g(y,"src"),style:{width:"100%",height:"100%",objectFit:O.fit||"contain"},alt:""}):null})},y.id);case"table":return e.jsx("div",{style:r,children:z(y)},y.id);case"barcode":return e.jsx("div",{style:r,children:e.jsx("div",{style:{...f,display:"flex",alignItems:"center",justifyContent:"center",padding:4},children:e.jsx(we,{value:g(y,"value"),format:O.format||"CODE128"})})},y.id);case"line":return e.jsx("div",{style:r,children:e.jsx("div",{style:{...f,display:"flex",alignItems:"center",border:"none"},children:e.jsx("hr",{style:{width:"100%",border:"none",borderTop:`${O.thickness||1}px ${O.style||"solid"} ${O.color||"#000"}`,margin:0}})})},y.id);default:return null}};return e.jsxs(o.Modal,{title:"打印预览",open:s,onCancel:()=>d(!1),width:m.width+80,footer:e.jsxs(o.Space,{children:[e.jsx(o.Button,{onClick:()=>d(!1),children:"关闭"}),e.jsx(o.Button,{type:"primary",icon:e.jsx(B.PrinterOutlined,{}),onClick:()=>P(),children:"打印"})]}),styles:{body:{padding:16,display:"flex",flexDirection:"column",alignItems:"center"}},children:[e.jsx(o.Divider,{style:{margin:"4px 0 12px 0"}}),e.jsxs("div",{ref:v,style:{width:m.width,height:m.height,background:"#fff",border:"1px solid #d9d9d9",position:"relative",overflow:"hidden",flexShrink:0},children:[n.showHeader&&e.jsx("div",{style:{position:"absolute",top:0,left:u.left,right:u.right,height:u.top,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,overflow:"hidden"},children:n.headerContent}),n.showFooter&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:u.left,right:u.right,height:u.bottom,display:"flex",alignItems:"center",justifyContent:n.showPageNumber?"space-between":"center",fontSize:12,overflow:"hidden",padding:"0 8px"},children:[e.jsx("span",{children:n.footerContent}),n.showPageNumber&&e.jsx("span",{children:n.pageNumberFormat.replace("{page}","1")})]}),e.jsx("div",{style:{position:"absolute",top:u.top,left:u.left,width:j,height:m.height-u.top-u.bottom},children:a.map(N)})]})]})},Dt=()=>{const s=T(l=>l.headerFooterVisible),d=T(l=>l.pageSettings),a=T(l=>l.setPageSettings),n=T(l=>l.setHeaderFooterVisible);return e.jsx(o.Modal,{title:"页眉页脚设置",open:s,onCancel:()=>n(!1),onOk:()=>n(!1),width:480,children:e.jsxs(o.Form,{layout:"vertical",style:{marginTop:8},children:[e.jsx(o.Form.Item,{label:"显示页眉",children:e.jsx(o.Switch,{checked:d.showHeader,onChange:l=>a({showHeader:l})})}),d.showHeader&&e.jsx(o.Form.Item,{label:"页眉内容",children:e.jsx(o.Input,{value:d.headerContent,onChange:l=>a({headerContent:l.target.value})})}),e.jsx(o.Form.Item,{label:"显示页脚",children:e.jsx(o.Switch,{checked:d.showFooter,onChange:l=>a({showFooter:l})})}),d.showFooter&&e.jsxs(e.Fragment,{children:[e.jsx(o.Form.Item,{label:"页脚内容",children:e.jsx(o.Input,{value:d.footerContent,onChange:l=>a({footerContent:l.target.value})})}),e.jsx(o.Form.Item,{label:"显示页码",children:e.jsx(o.Switch,{checked:d.showPageNumber,onChange:l=>a({showPageNumber:l})})}),d.showPageNumber&&e.jsx(o.Form.Item,{label:"页码格式",children:e.jsx(o.Input,{value:d.pageNumberFormat,onChange:l=>a({pageNumberFormat:l.target.value}),placeholder:"第 {page} 页"})})]})]})})},Ye=({isPreview:s=!1,initialTemplateData:d,onSave:a,onPrint:n})=>{const{importJSON:l,exportJSON:i,reset:v,components:m,pageSettings:u,gridSettings:j,dataSources:b}=T(),P=w.useRef(null);w.useEffect(()=>{if(d){const h=JSON.stringify(d),S=l(h);S&&(console.error("导入失败:",S),v())}},[d,l,v]);const g=()=>{if(a)try{const h=i();a(JSON.parse(h))}catch(h){console.error("导出失败:",h)}},z=w.useMemo(()=>{const h=he[u.paperSize];if(!h)return{width:u.customWidth*A,height:u.customHeight*A};const S=h.width*A,F=h.height*A;return u.orientation==="landscape"?{width:F,height:S}:{width:S,height:F}},[u]),N=w.useMemo(()=>({top:u.marginTop*A,right:u.marginRight*A,bottom:u.marginBottom*A,left:u.marginLeft*A}),[u]),y=z.width-N.left-N.right,O=y/((j==null?void 0:j.cols)||fe.cols),r=De.useReactToPrint({contentRef:P,documentTitle:"打印模板",pageStyle:`
|
|
39
|
+
@page {
|
|
40
|
+
size: ${z.width/A}mm ${z.height/A}mm;
|
|
41
|
+
margin: ${u.marginTop}mm ${u.marginRight}mm ${u.marginBottom}mm ${u.marginLeft}mm;
|
|
42
|
+
}
|
|
43
|
+
@media print {
|
|
44
|
+
html, body { margin: 0; padding: 0; }
|
|
45
|
+
}
|
|
46
|
+
`}),f=()=>{n?n():r()},x=h=>{const S=h.props,F={position:"absolute",left:h.x*O,top:h.y*O,width:h.w*O,height:h.h*O,overflow:"hidden"},V={width:"100%",height:"100%",overflow:"hidden",boxSizing:"border-box"};switch(h.type){case"text":return e.jsx("div",{style:F,children:e.jsx("div",{style:{...V,fontSize:S.fontSize||14,fontWeight:S.fontWeight||"normal",fontStyle:S.fontStyle||"normal",textAlign:S.textAlign||"left",color:S.color||"#000",backgroundColor:S.backgroundColor||"transparent",padding:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:ce(h,"content",b)})},h.id);case"image":return e.jsx("div",{style:F,children:e.jsx("div",{style:V,children:S.src?e.jsx("img",{src:ce(h,"src",b),style:{width:"100%",height:"100%",objectFit:S.fit||"contain"},alt:""}):null})},h.id);case"table":return e.jsx("div",{style:F,children:_(h)},h.id);case"barcode":return e.jsx("div",{style:F,children:e.jsx("div",{style:{...V,display:"flex",alignItems:"center",justifyContent:"center",padding:4},children:e.jsx(we,{value:ce(h,"value",b),format:S.format||"CODE128"})})},h.id);case"line":return e.jsx("div",{style:F,children:e.jsx("div",{style:{...V,display:"flex",alignItems:"center",border:"none"},children:e.jsx("hr",{style:{width:"100%",border:"none",borderTop:`${S.thickness||1}px ${S.style||"solid"} ${S.color||"#000"}`,margin:0}})})},h.id);default:return null}},_=h=>{const S=h.props.tableDataSourceId,F=S?b.find(U=>U.id===S):null,V=F?me(F):null,H=h.tableColumns||[],q=h.props.borderWidth||1,W=h.props.borderColor||"#000000";if(V&&V.length>0)return e.jsxs("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse"},children:[H.length>0&&e.jsx("thead",{children:e.jsx("tr",{style:{backgroundColor:"#f5f5f5"},children:H.map((U,k)=>e.jsx("th",{style:{border:`${q}px solid ${W}`,padding:4,fontSize:12,fontWeight:"bold",textAlign:"center"},children:U.title},k))})}),e.jsx("tbody",{children:V.map((U,k)=>e.jsx("tr",{children:H.map((R,G)=>e.jsx("td",{style:{border:`${q}px solid ${W}`,padding:4,fontSize:12,textAlign:"center"},children:R.fieldPath?U[R.fieldPath]:""},G))},k))})]});const re=h.props.rows||3,ne=Math.max(h.props.cols||3,H.length||3);return e.jsx("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse"},children:e.jsx("tbody",{children:Array.from({length:re}).map((U,k)=>e.jsx("tr",{children:Array.from({length:ne}).map((R,G)=>e.jsx("td",{style:{border:`${q}px solid ${W}`,padding:2,fontSize:12,textAlign:"center"},children:" "},G))},k))})})};return s?e.jsx(o.App,{children:e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid #e8e8e8",background:"#fff"},children:e.jsx(o.Space,{children:e.jsx(o.Button,{type:"primary",icon:e.jsx(B.PrinterOutlined,{}),onClick:f,children:"打印"})})}),e.jsx("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"flex-start",padding:"16px",boxSizing:"border-box",overflowY:"auto",background:"#e8e8e8"},children:e.jsx("div",{style:{flexShrink:0},children:e.jsx(Je,{isPreview:!0})})}),e.jsx("div",{style:{position:"absolute",left:"-9999px",top:"-9999px"},children:e.jsxs("div",{ref:P,style:{width:z.width,height:z.height,background:"#fff",position:"relative",overflow:"hidden"},children:[u.showHeader&&e.jsx("div",{style:{position:"absolute",top:0,left:N.left,right:N.right,height:N.top,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,overflow:"hidden"},children:u.headerContent}),u.showFooter&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:N.left,right:N.right,height:N.bottom,display:"flex",alignItems:"center",justifyContent:u.showPageNumber?"space-between":"center",fontSize:12,overflow:"hidden",padding:"0 8px"},children:[e.jsx("span",{children:u.footerContent}),u.showPageNumber&&e.jsx("span",{children:u.pageNumberFormat.replace("{page}","1")})]}),e.jsx("div",{style:{position:"absolute",top:N.top,left:N.left,width:y,height:z.height-N.top-N.bottom},children:m.map(x)})]})})]})}):e.jsx(o.App,{children:e.jsxs("div",{className:"app-container",children:[e.jsx(vt,{onCustomSave:a?g:void 0,onCustomPrint:n}),e.jsxs("div",{className:"app-body",children:[e.jsx("div",{className:"app-left-panel",children:e.jsx(Pt,{})}),e.jsx(Je,{}),e.jsx("div",{className:"app-right-panel",children:e.jsx(It,{})})]}),e.jsx(zt,{}),e.jsx(Dt,{})]})})};Y.PrintDesigner=Ye,Y.default=Ye,Y.getArrayFromDataSource=me,Y.getObjectFromDataSource=ge,Y.getRenderValue=ce,Y.getValueByPath=pe,Y.safeParseJSON=ae,Y.useDesignerStore=T,Object.defineProperties(Y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "operp-print-designer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "一个功能强大的打印模板设计器组件,支持拖拽、数据绑定和打印预览",
|
|
7
|
-
"main": "./dist/print-designer.umd.js",
|
|
8
|
-
"module": "./dist/print-designer.es.js",
|
|
7
|
+
"main": "./dist/operp-print-designer.umd.js",
|
|
8
|
+
"module": "./dist/operp-print-designer.es.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"import": "./dist/print-designer.es.js",
|
|
16
|
-
"require": "./dist/print-designer.umd.js",
|
|
15
|
+
"import": "./dist/operp-print-designer.es.js",
|
|
16
|
+
"require": "./dist/operp-print-designer.umd.js",
|
|
17
17
|
"types": "./dist/index.d.ts"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TemplateData } from '../types';
|
|
3
|
-
export interface PrintDesignerProps {
|
|
4
|
-
/** 是否为预览模式(只读) */
|
|
5
|
-
isPreview?: boolean;
|
|
6
|
-
/** 初始模板数据 */
|
|
7
|
-
initialTemplateData?: TemplateData;
|
|
8
|
-
/** 保存回调 */
|
|
9
|
-
onSave?: (templateData: TemplateData) => void;
|
|
10
|
-
/** 打印回调 */
|
|
11
|
-
onPrint?: () => void;
|
|
12
|
-
}
|
|
13
|
-
declare const PrintDesigner: React.FC<PrintDesignerProps>;
|
|
14
|
-
export default PrintDesigner;
|
package/dist/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { default } from './components/PrintDesigner';
|
|
2
|
-
export { default as PrintDesigner } from './components/PrintDesigner';
|
|
3
|
-
export type { PrintDesignerProps } from './components/PrintDesigner';
|
|
4
|
-
|
|
5
|
-
export type {
|
|
6
|
-
CanvasComponent,
|
|
7
|
-
CanvasComponentType,
|
|
8
|
-
PageSettings,
|
|
9
|
-
GridSettings,
|
|
10
|
-
TemplateData,
|
|
11
|
-
DataSource,
|
|
12
|
-
DataSourceType,
|
|
13
|
-
TableColumnConfig,
|
|
14
|
-
DataBinding,
|
|
15
|
-
DataBindingConfig,
|
|
16
|
-
} from './types';
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
getRenderValue,
|
|
20
|
-
getObjectFromDataSource,
|
|
21
|
-
getArrayFromDataSource,
|
|
22
|
-
safeParseJSON,
|
|
23
|
-
getValueByPath,
|
|
24
|
-
} from './utils/dataHelper';
|
|
25
|
-
|
|
26
|
-
export { useDesignerStore } from './store';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
(function(Y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("antd"),require("@ant-design/icons"),require("react-to-print"),require("zustand"),require("react-grid-layout")):typeof define=="function"&&define.amd?define(["exports","react","antd","@ant-design/icons","react-to-print","zustand","react-grid-layout"],w):(Y=typeof globalThis<"u"?globalThis:Y||self,w(Y.PrintDesigner={},Y.React,Y.antd,Y.icons,Y.ReactToPrint,Y.zustand,Y.GridLayout))})(this,(function(Y,w,s,B,De,ht,ft){"use strict";var ue={exports:{}},oe={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Re;function pt(){if(Re)return oe;Re=1;var o=w,d=Symbol.for("react.element"),a=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,l=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function v(m,u,j){var b,P={},g=null,z=null;j!==void 0&&(g=""+j),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(z=u.ref);for(b in u)n.call(u,b)&&!i.hasOwnProperty(b)&&(P[b]=u[b]);if(m&&m.defaultProps)for(b in u=m.defaultProps,u)P[b]===void 0&&(P[b]=u[b]);return{$$typeof:d,type:m,key:g,ref:z,props:P,_owner:l.current}}return oe.Fragment=a,oe.jsx=v,oe.jsxs=v,oe}var le={},Ae;function gt(){if(Ae)return le;Ae=1;var o={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/return o.NODE_ENV!=="production"&&(function(){var d=w,a=Symbol.for("react.element"),n=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),u=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),y=Symbol.iterator,O="@@iterator";function r(t){if(t===null||typeof t!="object")return null;var c=y&&t[y]||t[O];return typeof c=="function"?c:null}var f=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(t){{for(var c=arguments.length,p=new Array(c>1?c-1:0),C=1;C<c;C++)p[C-1]=arguments[C];_("error",t,p)}}function _(t,c,p){{var C=f.ReactDebugCurrentFrame,D=C.getStackAddendum();D!==""&&(c+="%s",p=p.concat([D]));var $=p.map(function(I){return String(I)});$.unshift("Warning: "+c),Function.prototype.apply.call(console[t],console,$)}}var h=!1,S=!1,F=!1,V=!1,H=!1,q;q=Symbol.for("react.module.reference");function W(t){return!!(typeof t=="string"||typeof t=="function"||t===l||t===v||H||t===i||t===b||t===P||V||t===N||h||S||F||typeof t=="object"&&t!==null&&(t.$$typeof===z||t.$$typeof===g||t.$$typeof===m||t.$$typeof===u||t.$$typeof===j||t.$$typeof===q||t.getModuleId!==void 0))}function re(t,c,p){var C=t.displayName;if(C)return C;var D=c.displayName||c.name||"";return D!==""?p+"("+D+")":p}function ne(t){return t.displayName||"Context"}function U(t){if(t==null)return null;if(typeof t.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case l:return"Fragment";case n:return"Portal";case v:return"Profiler";case i:return"StrictMode";case b:return"Suspense";case P:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case u:var c=t;return ne(c)+".Consumer";case m:var p=t;return ne(p._context)+".Provider";case j:return re(t,t.render,"ForwardRef");case g:var C=t.displayName||null;return C!==null?C:U(t.type)||"Memo";case z:{var D=t,$=D._payload,I=D._init;try{return U(I($))}catch{return null}}}return null}var k=Object.assign,R=0,K,Z,Ye,He,Ue,qe,Ke;function Ge(){}Ge.__reactDisabledLog=!0;function Dt(){{if(R===0){K=console.log,Z=console.info,Ye=console.warn,He=console.error,Ue=console.group,qe=console.groupCollapsed,Ke=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Ge,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}R++}}function Rt(){{if(R--,R===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},t,{value:K}),info:k({},t,{value:Z}),warn:k({},t,{value:Ye}),error:k({},t,{value:He}),group:k({},t,{value:Ue}),groupCollapsed:k({},t,{value:qe}),groupEnd:k({},t,{value:Ke})})}R<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=f.ReactCurrentDispatcher,ke;function ye(t,c,p){{if(ke===void 0)try{throw Error()}catch(D){var C=D.stack.trim().match(/\n( *(at )?)/);ke=C&&C[1]||""}return`
|
|
18
|
-
`+ke+t}}var Pe=!1,ve;{var At=typeof WeakMap=="function"?WeakMap:Map;ve=new At}function Xe(t,c){if(!t||Pe)return"";{var p=ve.get(t);if(p!==void 0)return p}var C;Pe=!0;var D=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $;$=Te.current,Te.current=null,Dt();try{if(c){var I=function(){throw Error()};if(Object.defineProperty(I.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(I,[])}catch(X){C=X}Reflect.construct(t,[],I)}else{try{I.call()}catch(X){C=X}t.call(I.prototype)}}else{try{throw Error()}catch(X){C=X}t()}}catch(X){if(X&&C&&typeof X.stack=="string"){for(var E=X.stack.split(`
|
|
19
|
-
`),G=C.stack.split(`
|
|
20
|
-
`),L=E.length-1,J=G.length-1;L>=1&&J>=0&&E[L]!==G[J];)J--;for(;L>=1&&J>=0;L--,J--)if(E[L]!==G[J]){if(L!==1||J!==1)do if(L--,J--,J<0||E[L]!==G[J]){var Q=`
|
|
21
|
-
`+E[L].replace(" at new "," at ");return t.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",t.displayName)),typeof t=="function"&&ve.set(t,Q),Q}while(L>=1&&J>=0);break}}}finally{Pe=!1,Te.current=$,Rt(),Error.prepareStackTrace=D}var se=t?t.displayName||t.name:"",te=se?ye(se):"";return typeof t=="function"&&ve.set(t,te),te}function Nt(t,c,p){return Xe(t,!1)}function Ft(t){var c=t.prototype;return!!(c&&c.isReactComponent)}function be(t,c,p){if(t==null)return"";if(typeof t=="function")return Xe(t,Ft(t));if(typeof t=="string")return ye(t);switch(t){case b:return ye("Suspense");case P:return ye("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case j:return Nt(t.render);case g:return be(t.type,c,p);case z:{var C=t,D=C._payload,$=C._init;try{return be($(D),c,p)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,Ze={},Qe=f.ReactDebugCurrentFrame;function je(t){if(t){var c=t._owner,p=be(t.type,t._source,c?c.type:null);Qe.setExtraStackFrame(p)}else Qe.setExtraStackFrame(null)}function $t(t,c,p,C,D){{var $=Function.call.bind(de);for(var I in t)if($(t,I)){var E=void 0;try{if(typeof t[I]!="function"){var G=Error((C||"React class")+": "+p+" type `"+I+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[I]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw G.name="Invariant Violation",G}E=t[I](c,I,C,p,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(L){E=L}E&&!(E instanceof Error)&&(je(D),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",p,I,typeof E),je(null)),E instanceof Error&&!(E.message in Ze)&&(Ze[E.message]=!0,je(D),x("Failed %s type: %s",p,E.message),je(null))}}}var Bt=Array.isArray;function Ee(t){return Bt(t)}function Vt(t){{var c=typeof Symbol=="function"&&Symbol.toStringTag,p=c&&t[Symbol.toStringTag]||t.constructor.name||"Object";return p}}function Wt(t){try{return et(t),!1}catch{return!0}}function et(t){return""+t}function tt(t){if(Wt(t))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Vt(t)),et(t)}var rt=f.ReactCurrentOwner,Lt={key:!0,ref:!0,__self:!0,__source:!0},nt,it;function Mt(t){if(de.call(t,"ref")){var c=Object.getOwnPropertyDescriptor(t,"ref").get;if(c&&c.isReactWarning)return!1}return t.ref!==void 0}function Jt(t){if(de.call(t,"key")){var c=Object.getOwnPropertyDescriptor(t,"key").get;if(c&&c.isReactWarning)return!1}return t.key!==void 0}function Yt(t,c){typeof t.ref=="string"&&rt.current}function Ht(t,c){{var p=function(){nt||(nt=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};p.isReactWarning=!0,Object.defineProperty(t,"key",{get:p,configurable:!0})}}function Ut(t,c){{var p=function(){it||(it=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};p.isReactWarning=!0,Object.defineProperty(t,"ref",{get:p,configurable:!0})}}var qt=function(t,c,p,C,D,$,I){var E={$$typeof:a,type:t,key:c,ref:p,props:I,_owner:$};return E._store={},Object.defineProperty(E._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(E,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(E,"_source",{configurable:!1,enumerable:!1,writable:!1,value:D}),Object.freeze&&(Object.freeze(E.props),Object.freeze(E)),E};function Kt(t,c,p,C,D){{var $,I={},E=null,G=null;p!==void 0&&(tt(p),E=""+p),Jt(c)&&(tt(c.key),E=""+c.key),Mt(c)&&(G=c.ref,Yt(c,D));for($ in c)de.call(c,$)&&!Lt.hasOwnProperty($)&&(I[$]=c[$]);if(t&&t.defaultProps){var L=t.defaultProps;for($ in L)I[$]===void 0&&(I[$]=L[$])}if(E||G){var J=typeof t=="function"?t.displayName||t.name||"Unknown":t;E&&Ht(I,J),G&&Ut(I,J)}return qt(t,E,G,D,C,rt.current,I)}}var _e=f.ReactCurrentOwner,st=f.ReactDebugCurrentFrame;function ie(t){if(t){var c=t._owner,p=be(t.type,t._source,c?c.type:null);st.setExtraStackFrame(p)}else st.setExtraStackFrame(null)}var Oe;Oe=!1;function Ie(t){return typeof t=="object"&&t!==null&&t.$$typeof===a}function ot(){{if(_e.current){var t=U(_e.current.type);if(t)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+t+"`."}return""}}function Gt(t){return""}var lt={};function Xt(t){{var c=ot();if(!c){var p=typeof t=="string"?t:t.displayName||t.name;p&&(c=`
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+p+">.")}return c}}function at(t,c){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var p=Xt(c);if(lt[p])return;lt[p]=!0;var C="";t&&t._owner&&t._owner!==_e.current&&(C=" It was passed a child from "+U(t._owner.type)+"."),ie(t),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',p,C),ie(null)}}function ct(t,c){{if(typeof t!="object")return;if(Ee(t))for(var p=0;p<t.length;p++){var C=t[p];Ie(C)&&at(C,c)}else if(Ie(t))t._store&&(t._store.validated=!0);else if(t){var D=r(t);if(typeof D=="function"&&D!==t.entries)for(var $=D.call(t),I;!(I=$.next()).done;)Ie(I.value)&&at(I.value,c)}}}function Zt(t){{var c=t.type;if(c==null||typeof c=="string")return;var p;if(typeof c=="function")p=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===j||c.$$typeof===g))p=c.propTypes;else return;if(p){var C=U(c);$t(p,t.props,"prop",C,t)}else if(c.PropTypes!==void 0&&!Oe){Oe=!0;var D=U(c);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",D||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qt(t){{for(var c=Object.keys(t.props),p=0;p<c.length;p++){var C=c[p];if(C!=="children"&&C!=="key"){ie(t),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),ie(null);break}}t.ref!==null&&(ie(t),x("Invalid attribute `ref` supplied to `React.Fragment`."),ie(null))}}var dt={};function ut(t,c,p,C,D,$){{var I=W(t);if(!I){var E="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(E+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var G=Gt();G?E+=G:E+=ot();var L;t===null?L="null":Ee(t)?L="array":t!==void 0&&t.$$typeof===a?(L="<"+(U(t.type)||"Unknown")+" />",E=" Did you accidentally export a JSX literal instead of a component?"):L=typeof t,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",L,E)}var J=Kt(t,c,p,D,$);if(J==null)return J;if(I){var Q=c.children;if(Q!==void 0)if(C)if(Ee(Q)){for(var se=0;se<Q.length;se++)ct(Q[se],t);Object.freeze&&Object.freeze(Q)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ct(Q,t)}if(de.call(c,"key")){var te=U(t),X=Object.keys(c).filter(function(sr){return sr!=="key"}),ze=X.length>0?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}";if(!dt[te+ze]){var ir=X.length>0?"{"+X.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
-
let props = %s;
|
|
27
|
-
<%s {...props} />
|
|
28
|
-
React keys must be passed directly to JSX without using spread:
|
|
29
|
-
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,ze,te,ir,te),dt[te+ze]=!0}}return t===l?Qt(J):Zt(J),J}}function er(t,c,p){return ut(t,c,p,!0)}function tr(t,c,p){return ut(t,c,p,!1)}var rr=tr,nr=er;le.Fragment=l,le.jsx=rr,le.jsxs=nr})(),le}var Ne;function mt(){if(Ne)return ue.exports;Ne=1;var o={};return o.NODE_ENV==="production"?ue.exports=pt():ue.exports=gt(),ue.exports}var e=mt();const he={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}},Fe={paperSize:"A4",customWidth:210,customHeight:297,orientation:"portrait",marginTop:10,marginRight:10,marginBottom:10,marginLeft:10,showHeader:!1,headerContent:"页眉文字",showFooter:!1,footerContent:"页脚文字",showPageNumber:!0,pageNumberFormat:"第 {page} 页"},A=3,fe={cellSize:1,cols:100},$e={text:"文本",image:"图片",table:"表格",barcode:"条形码",line:"分割线"},xt={text:{content:"双击编辑文字",fontSize:14,fontWeight:"normal",fontStyle:"normal",textAlign:"left",color:"#000000",backgroundColor:"transparent"},image:{src:"",fit:"contain",content:""},table:{rows:3,cols:3,borderWidth:1,borderColor:"#000000",content:""},barcode:{value:"1234567890",format:"CODE128",content:""},line:{color:"#000000",thickness:1,style:"solid",content:""}};let Se=0,Ce=0;function Be(){return`comp_${++Se}`}function Ve(){return`ds_${++Ce}`}const T=ht.create((o,d)=>({components:[],selectedId:null,pageSettings:{...Fe},gridSettings:{...fe},previewVisible:!1,templateName:"未命名模板",headerFooterVisible:!1,dataSources:[],activeDataSourceId:null,addComponent:(a,n,l)=>{const i=Be(),v=$e[a]||a,m={...xt[a]||{}};a==="text"&&(m.content=v);const u={id:i,type:a,x:n??0,y:l??0,w:a==="line"?20:15,h:a==="line"?1:8,props:m,...a==="table"?{tableColumns:[{title:"列1"},{title:"列2"},{title:"列3"}]}:{}};o(j=>({components:[...j.components,u],selectedId:i}))},updateComponent:(a,n)=>{o(l=>({components:l.components.map(i=>i.id===a?{...i,...n}:i)}))},selectComponent:a=>{o({selectedId:a})},removeComponent:a=>{o(n=>({components:n.components.filter(l=>l.id!==a),selectedId:n.selectedId===a?null:n.selectedId}))},setComponents:a=>{o({components:a})},setPageSettings:a=>{o(n=>({pageSettings:{...n.pageSettings,...a}}))},setPreviewVisible:a=>{o({previewVisible:a})},setTemplateName:a=>{o({templateName:a})},setHeaderFooterVisible:a=>{o({headerFooterVisible:a})},addDataSource:(a,n,l)=>{const v={id:Ve(),name:a,type:n,data:l,createdAt:Date.now()};o(m=>({dataSources:[...m.dataSources,v]}))},updateDataSource:(a,n)=>{o(l=>({dataSources:l.dataSources.map(i=>i.id===a?{...i,...n}:i)}))},removeDataSource:a=>{o(n=>({dataSources:n.dataSources.filter(l=>l.id!==a),activeDataSourceId:n.activeDataSourceId===a?null:n.activeDataSourceId}))},setActiveDataSourceId:a=>{o({activeDataSourceId:a})},updateComponentTableColumns:(a,n)=>{o(l=>({components:l.components.map(i=>i.id===a?{...i,tableColumns:n}:i)}))},exportJSON:()=>{const a=d(),n={version:"1.0",templateName:a.templateName,pageSettings:a.pageSettings,components:a.components.map(({id:l,...i})=>i),dataSources:a.dataSources.map(({id:l,...i})=>i)};return JSON.stringify(n,null,2)},importJSON:a=>{try{const n=JSON.parse(a);if(!n.version||!n.pageSettings||!Array.isArray(n.components))return"JSON 格式不正确,缺少必要字段";Se=0,Ce=0;const l=n.components.map(v=>({...v,id:Be()})),i=(n.dataSources||[]).map(v=>({...v,id:Ve()}));return o({components:l,dataSources:i,pageSettings:n.pageSettings,templateName:n.templateName||"导入的模板",selectedId:null,activeDataSourceId:null}),null}catch{return"JSON 解析失败,请检查文件内容"}},reset:()=>{Se=0,Ce=0,o({components:[],selectedId:null,pageSettings:{...Fe},gridSettings:{...fe},templateName:"未命名模板",headerFooterVisible:!1,previewVisible:!1,dataSources:[],activeDataSourceId:null})}})),{Text:or}=s.Typography,yt=({onCustomSave:o,onCustomPrint:d})=>{const a=T(f=>f.templateName),n=T(f=>f.setTemplateName),l=T(f=>f.setPreviewVisible),i=T(f=>f.setHeaderFooterVisible),v=T(f=>f.selectedId),m=T(f=>f.removeComponent),u=T(f=>f.exportJSON),j=T(f=>f.importJSON),b=T(f=>f.reset),P=w.useRef(null),{message:g}=s.App.useApp(),z=w.useCallback(()=>{v&&m(v)},[v,m]),N=w.useCallback(()=>{const f=u(),x=new Blob([f],{type:"application/json"}),_=URL.createObjectURL(x),h=document.createElement("a");h.href=_,h.download=`${a||"模板"}.json`,h.click(),URL.revokeObjectURL(_),g.success("模板已导出")},[u,a,g]),y=w.useCallback(()=>{var f;(f=P.current)==null||f.click()},[]),O=w.useCallback(f=>{var h;const x=(h=f.target.files)==null?void 0:h[0];if(!x)return;const _=new FileReader;_.onload=()=>{const S=j(_.result);S?g.error(S):g.success("模板已导入")},_.readAsText(x),f.target.value=""},[j,g]),r=w.useCallback(()=>{b(),g.info("已新建空白模板")},[b,g]);return e.jsxs("div",{style:{height:48,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 16px",borderBottom:"1px solid #e8e8e8",background:"#fff"},children:[e.jsx(s.Space,{children:e.jsx(s.Input,{value:a,onChange:f=>n(f.target.value),variant:"borderless",style:{width:200,fontSize:16,fontWeight:600},placeholder:"模板名称"})}),e.jsxs(s.Space,{children:[e.jsx(s.Button,{icon:e.jsx(B.PlusOutlined,{}),onClick:r,children:"新建"}),e.jsx("input",{ref:P,type:"file",accept:".json",style:{display:"none"},onChange:O}),o?e.jsx(s.Button,{icon:e.jsx(B.SaveOutlined,{}),onClick:o,type:"primary",children:"保存"}):e.jsx(s.Button,{icon:e.jsx(B.DownloadOutlined,{}),onClick:N,children:"导出"}),e.jsx(s.Button,{icon:e.jsx(B.UploadOutlined,{}),onClick:y,children:"导入"}),e.jsx(s.Button,{icon:e.jsx(B.SettingOutlined,{}),onClick:()=>i(!0),children:"页眉页脚"}),e.jsx(s.Button,{danger:!0,icon:e.jsx(B.DeleteOutlined,{}),disabled:!v,onClick:z,children:"删除"}),d?e.jsx(s.Button,{type:"primary",icon:e.jsx(B.PrinterOutlined,{}),onClick:d,children:"打印"}):e.jsx(s.Button,{type:"primary",icon:e.jsx(B.EyeOutlined,{}),onClick:()=>l(!0),children:"预览"})]})]})},{Text:ee}=s.Typography,vt=()=>{const o=T(i=>i.pageSettings),d=T(i=>i.setPageSettings),a=o.paperSize==="custom",n=w.useCallback(i=>{d({paperSize:i})},[d]),l=w.useCallback(i=>{d({orientation:i})},[d]);return e.jsx(s.Card,{title:"页面设置",size:"small",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:12},children:"纸张大小"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:o.paperSize,onChange:n,options:[...Object.keys(he).map(i=>({value:i,label:i})),{value:"custom",label:"自定义"}]})]}),a&&e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(ee,{style:{fontSize:12},children:"宽度 (mm)"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:o.customWidth,min:10,max:2e3,onChange:i=>d({customWidth:i??210})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(ee,{style:{fontSize:12},children:"高度 (mm)"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:o.customHeight,min:10,max:2e3,onChange:i=>d({customHeight:i??297})})]})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:12},children:"方向"}),e.jsxs(s.Radio.Group,{value:o.orientation,onChange:i=>l(i.target.value),size:"small",style:{width:"100%",display:"flex"},children:[e.jsx(s.Radio.Button,{value:"portrait",style:{flex:1,textAlign:"center"},children:"纵向"}),e.jsx(s.Radio.Button,{value:"landscape",style:{flex:1,textAlign:"center"},children:"横向"})]})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:12},children:"页边距 (mm)"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"上"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:o.marginTop,min:0,max:100,onChange:i=>d({marginTop:i??10})})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"右"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:o.marginRight,min:0,max:100,onChange:i=>d({marginRight:i??10})})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"下"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:o.marginBottom,min:0,max:100,onChange:i=>d({marginBottom:i??10})})]}),e.jsxs("div",{children:[e.jsx(ee,{style:{fontSize:11},children:"左"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:o.marginLeft,min:0,max:100,onChange:i=>d({marginLeft:i??10})})]})]})]})]})})},{Text:bt}=s.Typography,jt=[{type:"text",icon:e.jsx(B.FontSizeOutlined,{}),label:"文本"},{type:"image",icon:e.jsx(B.PictureOutlined,{}),label:"图片"},{type:"table",icon:e.jsx(B.TableOutlined,{}),label:"表格"},{type:"barcode",icon:e.jsx(B.BarcodeOutlined,{}),label:"条形码"},{type:"line",icon:e.jsx(B.MinusOutlined,{}),label:"分割线"}],St=()=>{const o=T(n=>n.addComponent),d=w.useCallback((n,l)=>{n.dataTransfer.setData("componentType",l),n.dataTransfer.effectAllowed="copy"},[]),a=w.useCallback(n=>{o(n)},[o]);return e.jsx(s.Card,{title:"组件面板",size:"small",children:e.jsx(s.Space,{direction:"vertical",style:{width:"100%"},size:4,children:jt.map(n=>e.jsxs("div",{draggable:!0,onDragStart:l=>d(l,n.type),onClick:()=>a(n.type),style:{cursor:"grab",padding:"8px 12px",border:"1px solid #d9d9d9",borderRadius:6,display:"flex",alignItems:"center",gap:8,background:"#fafafa",userSelect:"none",transition:"all 0.2s"},onMouseEnter:l=>{l.currentTarget.style.background="#e6f4ff",l.currentTarget.style.borderColor="#1677ff"},onMouseLeave:l=>{l.currentTarget.style.background="#fafafa",l.currentTarget.style.borderColor="#d9d9d9"},children:[n.icon,e.jsx(bt,{children:n.label})]},n.type))})})};function ae(o){try{return JSON.parse(o)}catch{return null}}function ce(o,d,a){const n=`${d}Binding`,l=o.props[n];if(l&&l.dataSourceId&&l.fieldPath){const v=a.find(m=>m.id===l.dataSourceId);if(v){const m=ge(v);if(m){const u=pe(m,l.fieldPath);if(u)return u}}}return o.props[d]||(l==null?void 0:l.staticValue)||""}function pe(o,d){if(!o||!d)return"";try{const a=d.split(".");let n=o;for(const l of a){if(typeof n!="object"||n===null)return"";n=n[l]}return n!=null?String(n):""}catch{return""}}function ge(o){const d=ae(o.data);return o.type==="object"&&d&&typeof d=="object"&&!Array.isArray(d)?d:null}function me(o){const d=ae(o.data);return o.type==="array"&&Array.isArray(d)?d:null}const{TextArea:Ct}=s.Input,{Text:xe,Title:lr}=s.Typography,We=JSON.stringify({name:"张三",age:28,department:"技术部",email:"zhangsan@example.com"},null,2),wt=JSON.stringify([{id:1,product:"商品A",quantity:2,price:100},{id:2,product:"商品B",quantity:5,price:80},{id:3,product:"商品C",quantity:1,price:200}],null,2),Tt=()=>{const o=T(g=>g.dataSources),d=T(g=>g.addDataSource),a=T(g=>g.updateDataSource),n=T(g=>g.removeDataSource),[l,i]=w.useState(!1),[v,m]=w.useState(null),[u,j]=w.useState({name:"",type:"object",data:""}),b=g=>{g?(m(g.id),j({name:g.name,type:g.type,data:g.data})):(m(null),j({name:"新数据源",type:"object",data:We})),i(!0)},P=()=>{const g=ae(u.data);if(g===null){s.message.error("JSON 格式不正确");return}if(u.type==="object"&&(Array.isArray(g)||typeof g!="object")){s.message.error("对象类型数据源必须为对象格式");return}if(u.type==="array"&&!Array.isArray(g)){s.message.error("数组类型数据源必须为数组格式");return}v?(a(v,u),s.message.success("数据源已更新")):(d(u.name,u.type,u.data),s.message.success("数据源已添加")),i(!1)};return e.jsxs(s.Card,{title:"数据源",size:"small",extra:e.jsx(s.Button,{type:"link",size:"small",icon:e.jsx(B.PlusOutlined,{}),onClick:()=>b(),children:"添加"}),children:[e.jsx(s.List,{size:"small",dataSource:o,locale:{emptyText:"暂无数据源"},renderItem:g=>e.jsx(s.List.Item,{actions:[e.jsx(s.Dropdown,{menu:{items:[{key:"edit",label:"编辑",icon:e.jsx(B.EditOutlined,{}),onClick:()=>b(g)},{type:"divider"},{key:"delete",label:e.jsx(s.Popconfirm,{title:"确定要删除这个数据源吗?",onConfirm:z=>{z==null||z.stopPropagation(),n(g.id),s.message.success("已删除")},okText:"确定",cancelText:"取消",onCancel:z=>z==null?void 0:z.stopPropagation(),children:e.jsx("span",{style:{color:"#ff4d4f",cursor:"pointer"},children:"删除"})}),icon:e.jsx(B.DeleteOutlined,{style:{color:"#ff4d4f"}})}]},placement:"bottomRight",children:e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(B.MoreOutlined,{})})})],children:e.jsx(s.List.Item.Meta,{avatar:e.jsx(B.DatabaseOutlined,{}),title:e.jsx(xe,{strong:!0,children:g.name}),description:e.jsx(s.Space,{size:4,children:e.jsx(s.Tag,{color:g.type==="object"?"blue":"green",children:g.type==="object"?"对象":"数组"})})})})}),e.jsx(s.Modal,{title:v?"编辑数据源":"添加数据源",open:l,onOk:P,onCancel:()=>i(!1),okText:"保存",cancelText:"取消",children:e.jsxs(s.Space,{direction:"vertical",style:{width:"100%"},size:"middle",children:[e.jsxs("div",{children:[e.jsx(xe,{strong:!0,style:{display:"block",marginBottom:4},children:"名称"}),e.jsx(s.Input,{placeholder:"请输入数据源名称",value:u.name,onChange:g=>j({...u,name:g.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{strong:!0,style:{display:"block",marginBottom:4},children:"类型"}),e.jsx(s.Select,{options:[{label:"对象",value:"object"},{label:"数组",value:"array"}],style:{width:"100%"},value:u.type,onChange:g=>{j({...u,type:g,data:g==="object"?We:wt})}})]}),e.jsx(s.Divider,{style:{margin:"8px 0"}}),e.jsxs("div",{children:[e.jsx(xe,{strong:!0,style:{display:"block",marginBottom:4},children:"JSON 数据"}),e.jsx(Ct,{rows:12,placeholder:"请输入 JSON 数据",value:u.data,onChange:g=>j({...u,data:g.target.value})})]})]})})]})},kt=()=>e.jsx(s.Collapse,{bordered:!1,defaultActiveKey:["1","2"],expandIcon:({isActive:o})=>e.jsx(B.CaretRightOutlined,{rotate:o?90:0}),style:{height:"100%",overflowY:"auto"},items:[{key:"1",label:"页面设置",children:e.jsx(vt,{})},{key:"2",label:"组件",children:e.jsx(St,{})},{key:"3",label:"数据源",children:e.jsx(Tt,{})}]});function Le(o){const d=[];d.push(1,1,0,1,1,0,1,1);for(let a=0;a<o.length;a++){const l=(o.charCodeAt(a)%103).toString(2).padStart(7,"0");for(const i of l)d.push(i==="1"?1:0)}return d.push(1,1,0,0,0,1,1,0,0,0,1,1),d}const we=({value:o,format:d})=>{const a=w.useMemo(()=>Le(o),[o,d]);if(!o)return e.jsx("div",{style:{fontSize:11,color:"#999"},children:"请设置条形码值"});const n=2,l=44,i=a.length*n;return e.jsxs("div",{style:{textAlign:"center",overflow:"hidden",maxWidth:"100%"},children:[e.jsx("canvas",{ref:v=>{if(!v)return;const m=v.getContext("2d");m&&(v.width=i,v.height=l,m.clearRect(0,0,i,l),a.forEach((u,j)=>{m.fillStyle=u===1?"#000":"#fff",m.fillRect(j*n,0,n,l)}))},style:{width:"100%",maxWidth:i,height:l}}),e.jsx("div",{style:{fontSize:10,marginTop:1,letterSpacing:1},children:o})]})},Me=w.memo(({comp:o,selected:d,isPreview:a=!1,dataSources:n=[]})=>{const l={width:"100%",height:"100%",overflow:"hidden",boxSizing:"border-box",outline:a?"none":d?"2px solid #1677ff":"1px dashed #d9d9d9",outlineOffset:-1},i=v=>ce(o,v,n);switch(o.type){case"text":return e.jsx("div",{style:{...l,fontSize:o.props.fontSize||14,fontWeight:o.props.fontWeight||"normal",fontStyle:o.props.fontStyle||"normal",textAlign:o.props.textAlign||"left",color:o.props.color||"#000",backgroundColor:o.props.backgroundColor||"transparent",padding:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i("content")||""});case"image":const v=i("src")||o.props.src;return e.jsx("div",{style:l,children:v?e.jsx("img",{src:v,style:{width:"100%",height:"100%",objectFit:o.props.fit||"contain"},alt:""}):e.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#bbb",fontSize:12},children:"请在属性中设置图片地址"})});case"table":return e.jsx(Pt,{comp:o,style:l,dataSources:n});case"barcode":const m=i("value")||o.props.value||"123456";return e.jsx("div",{style:{...l,display:"flex",alignItems:"center",justifyContent:"center",padding:4},children:e.jsx(we,{value:m,format:o.props.format||"CODE128"})});case"line":return e.jsx("div",{style:{...l,display:"flex",alignItems:"center",border:"none",outline:d?"2px solid #1677ff":"1px dashed transparent"},children:e.jsx("hr",{style:{width:"100%",border:"none",borderTop:`${o.props.thickness||1}px ${o.props.style||"solid"} ${o.props.color||"#000"}`,margin:0}})});default:return e.jsx("div",{style:l,children:o.type})}}),Pt=({comp:o,style:d,dataSources:a=[]})=>{const n=o.props.borderWidth||1,l=o.props.borderColor||"#000",i=o.tableColumns||[],v=o.props.tableDataSourceId,m=v?a.find(P=>P.id===v):null,u=m?me(m):null;if(u&&u.length>0)return e.jsxs("table",{style:{...d,borderCollapse:"collapse",width:"100%",height:"100%"},children:[i.length>0&&e.jsx("thead",{children:e.jsx("tr",{style:{backgroundColor:"#f5f5f5"},children:i.map((P,g)=>e.jsx("th",{style:{border:`${n}px solid ${l}`,padding:4,fontSize:12,fontWeight:"bold",textAlign:"center"},children:P.title},g))})}),e.jsx("tbody",{children:u.map((P,g)=>e.jsx("tr",{children:i.map((z,N)=>e.jsx("td",{style:{border:`${n}px solid ${l}`,padding:4,fontSize:12,textAlign:"center"},children:z.fieldPath?P[z.fieldPath]:""},N))},g))})]});const j=o.props.rows||3,b=Math.max(o.props.cols||3,i.length||3);return e.jsx("table",{style:{...d,borderCollapse:"collapse",width:"100%",height:"100%"},children:e.jsx("tbody",{children:Array.from({length:j}).map((P,g)=>e.jsx("tr",{children:Array.from({length:b}).map((z,N)=>e.jsx("td",{style:{border:`${n}px solid ${l}`,padding:2,fontSize:12,textAlign:"center"},children:" "},N))},g))})})},Je=({isPreview:o=!1})=>{const d=T(r=>r.components),a=T(r=>r.selectedId),n=T(r=>r.pageSettings),l=T(r=>r.selectComponent);T(r=>r.updateComponent);const i=T(r=>r.setComponents),v=T(r=>r.addComponent),m=T(r=>r.gridSettings),u=T(r=>r.dataSources),j=w.useMemo(()=>{const r=he[n.paperSize];if(!r)return{width:n.customWidth*A,height:n.customHeight*A};const f=r.width*A,x=r.height*A;return n.orientation==="landscape"?{width:x,height:f}:{width:f,height:x}},[n]),b=w.useMemo(()=>({top:n.marginTop*A,right:n.marginRight*A,bottom:n.marginBottom*A,left:n.marginLeft*A}),[n]),P=j.width-b.left-b.right,g=j.height-b.top-b.bottom,z=w.useMemo(()=>d.map(r=>({i:r.id,x:r.x,y:r.y,w:r.w,h:r.h})),[d]),N=w.useCallback(r=>{const f=d.map((x,_)=>{const h=r[_];return h?{...x,x:h.x,y:h.y,w:h.w,h:h.h}:x});i(f)},[d,i]),y=w.useCallback((r,f,x)=>{var F,V;const _=x,h=(F=_.dataTransfer)==null?void 0:F.getData("componentType");if(!h)return;const S=(V=x.target.closest(".react-grid-layout"))==null?void 0:V.getBoundingClientRect();if(S){const H=Math.floor((_.clientX-S.left)/(P/m.cols)),q=Math.floor((_.clientY-S.top)/(P/m.cols));v(h,Math.max(0,H),Math.max(0,q))}else v(h)},[v,P,m.cols]),O=w.useCallback(r=>{l(r===a?null:r)},[l,a]);return e.jsx("div",{style:{flex:1,overflow:"auto",background:"#e8e8e8",display:"flex",justifyContent:"center",padding:"24px 0"},children:e.jsxs("div",{id:"print-paper",style:{width:j.width,height:j.height,background:"#fff",boxShadow:"0 2px 12px rgba(0,0,0,0.15)",position:"relative",flexShrink:0},children:[n.showHeader&&e.jsx("div",{style:{position:"absolute",top:0,left:b.left,right:b.right,height:b.top,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:"#999",borderBottom:"1px dashed #ddd",overflow:"hidden"},children:n.headerContent}),n.showFooter&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:b.left,right:b.right,height:b.bottom,display:"flex",alignItems:"center",justifyContent:n.showPageNumber?"space-between":"center",fontSize:12,color:"#999",borderTop:"1px dashed #ddd",overflow:"hidden",padding:"0 8px"},children:[e.jsx("span",{children:n.footerContent}),n.showPageNumber&&e.jsx("span",{children:n.pageNumberFormat.replace("{page}","1")})]}),e.jsx("div",{style:{position:"absolute",top:b.top,left:b.left,width:P,height:g},children:o?e.jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:d.map(r=>{const f=P/m.cols,x=P/m.cols,_={position:"absolute",left:r.x*f,top:r.y*x,width:r.w*f,height:r.h*x};return e.jsx("div",{style:_,children:e.jsx(Me,{comp:r,selected:!1,isPreview:!0,dataSources:u})},r.id)})}):e.jsx(ft,{className:"canvas-grid",layout:z,cols:m.cols,rowHeight:P/m.cols,width:P,margin:[0,0],containerPadding:[0,0],onLayoutChange:N,onDrop:y,isDroppable:!0,isResizable:!0,isDraggable:!0,compactType:null,preventCollision:!0,draggableHandle:".grid-item-drag-handle",style:{minHeight:g},children:d.map(r=>e.jsx("div",{className:"grid-item-drag-handle",onClick:()=>O(r.id),style:{cursor:"move"},children:e.jsx(Me,{comp:r,selected:r.id===a,dataSources:u})},r.id))})})]})})},{Text:M,Title:ar}=s.Typography,{TextArea:Et}=s.Input,_t=()=>{const o=T(r=>r.components),d=T(r=>r.selectedId),a=T(r=>r.dataSources),n=T(r=>r.updateComponent),l=T(r=>r.updateComponentTableColumns),i=w.useMemo(()=>o.find(r=>r.id===d)||null,[o,d]),[v,m]=w.useState([]),u=w.useMemo(()=>[{label:"无(使用静态值)",value:""},...a.map(r=>({label:r.name,value:r.id,type:r.type}))],[a]),j=w.useCallback((r,f)=>{d&&n(d,{props:{...i==null?void 0:i.props,[r]:f}})},[d,i,n]),b=w.useCallback((r,f,x,_)=>{if(!d)return;let h=_;f&&x&&(h=_);const S=`${r}Binding`;n(d,{props:{...i==null?void 0:i.props,[r]:h,[S]:{dataSourceId:f,fieldPath:x,staticValue:_}}})},[d,i,n]),P=w.useCallback(r=>{const f=i==null?void 0:i.props[`${r}Binding`],x=String((i==null?void 0:i.props[r])||"");return f?{field:r,dataSourceId:f.dataSourceId||null,fieldPath:f.fieldPath||"",staticValue:f.staticValue??x}:{field:r,dataSourceId:null,fieldPath:"",staticValue:x}},[i]);if(!i)return e.jsx(s.Card,{title:"属性面板",size:"small",style:{height:"100%",borderRadius:0,borderLeft:0},styles:{body:{padding:16}},children:e.jsx(s.Empty,{description:"请选择画布中的组件",image:s.Empty.PRESENTED_IMAGE_SIMPLE})});const g=$e[i.type]||i.type,z=e.jsxs(e.Fragment,{children:[e.jsx(M,{type:"secondary",style:{fontSize:12,display:"block",marginBottom:8},children:"位置和大小"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"X"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:i.x,onChange:r=>n(d,{x:r??0})})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"Y"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:i.y,onChange:r=>n(d,{y:r??0})})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"宽度"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:i.w,min:1,onChange:r=>n(d,{w:r??1})})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"高度"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:i.h,min:1,onChange:r=>n(d,{h:r??1})})]})]})]}),N=({field:r,label:f,placeholder:x,isTextarea:_=!1})=>{const h=P(r),S=a.find(W=>W.id===h.dataSourceId),F=S?ge(S):null,V=F?Object.keys(F):[],[H,q]=w.useState(h.staticValue);return w.useEffect(()=>{q(h.staticValue)},[h.staticValue,h.dataSourceId]),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12,display:"block",marginBottom:4},children:f}),e.jsx("div",{style:{marginBottom:4},children:e.jsx(s.Select,{size:"small",style:{width:"100%"},placeholder:"选择数据源",value:h.dataSourceId||"",onChange:W=>{b(r,W||null,W&&h.fieldPath||"",h.staticValue)},options:u})}),h.dataSourceId&&e.jsx("div",{style:{marginBottom:4},children:e.jsx(s.Select,{size:"small",style:{width:"100%"},placeholder:"选择字段",value:h.fieldPath,onChange:W=>{b(r,h.dataSourceId,W||"",h.staticValue)},options:[{label:"请选择字段",value:""},...V.map(W=>({label:W,value:W}))]})}),h.dataSourceId?e.jsxs("div",{style:{padding:6,background:"#f0f5ff",border:"1px solid #adc6ff",borderRadius:4,fontSize:12},children:[e.jsx(B.DatabaseOutlined,{style:{marginRight:4,color:"#1890ff"}}),e.jsx("span",{style:{fontWeight:500},children:"数据绑定已启用"}),S&&h.fieldPath&&e.jsxs("span",{style:{marginLeft:8},children:[e.jsx(s.Tag,{color:"blue",children:S.name}),e.jsx(s.Tag,{color:"green",children:h.fieldPath})]})]}):_?e.jsx(Et,{rows:3,placeholder:x,value:H,onChange:W=>q(W.target.value),onBlur:()=>{b(r,null,"",H)}}):e.jsx(s.Input,{placeholder:x,value:H,onChange:W=>q(W.target.value),onBlur:()=>{b(r,null,"",H)}})]})},y=()=>{const r=i.tableColumns||[],f=a.filter(k=>k.type==="array"),x=i.props.tableDataSourceId||"",_=f.find(k=>k.id===x),h=v.length>0?v:r,[S,F]=w.useState({}),V=()=>{l(d,h)},H=()=>{const k=[...h,{title:`列${h.length+1}`}];m(k)},q=k=>{const R=h.filter((K,Z)=>Z!==k);m(R)},W=(k,R,K)=>{const Z=[...h];Z[k]={...Z[k],[R]:K},m(Z)};let re=[];if(_){const k=ae(_.data);Array.isArray(k)&&k.length>0&&typeof k[0]=="object"&&(re=Object.keys(k[0]))}const ne=[{title:"列标题",dataIndex:"title",width:100,render:(k,R)=>{const K=R.key in S?S[R.key]:R.title;return e.jsx(s.Input,{size:"small",value:K,placeholder:"列标题",onChange:Z=>{F({...S,[R.key]:Z.target.value})},onBlur:()=>{if(R.key in S){W(Number(R.key),"title",S[R.key]);const Z={...S};delete Z[R.key],F(Z),V()}}})}},{title:"绑定字段",dataIndex:"fieldPath",width:120,render:(k,R)=>e.jsx(s.Select,{size:"small",style:{width:"100%"},value:R.fieldPath||"",placeholder:_?"绑定字段":"选择数据源先",disabled:!_,onChange:K=>{W(Number(R.key),"fieldPath",K||""),V()},options:[{label:"无绑定",value:""},...re.map(K=>({label:K,value:K}))]})},{title:"操作",width:60,render:(k,R)=>e.jsx(s.Popconfirm,{title:"确定要删除吗?",onConfirm:()=>{q(Number(R.key)),V()},okText:"确定",cancelText:"取消",children:e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(B.DeleteOutlined,{})})})}],U=h.map((k,R)=>({...k,key:String(R)}));return e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:e.jsx(M,{style:{fontSize:12},children:"表格数据源"})}),e.jsx(s.Select,{size:"small",style:{width:"100%",marginBottom:8},placeholder:"选择数组类型数据源",value:x,onChange:k=>j("tableDataSourceId",k||""),options:[{label:"无(仅静态展示)",value:""},...f.map(k=>({label:k.name,value:k.id}))]}),e.jsx(s.Divider,{}),e.jsxs(s.Space,{style:{marginBottom:8},children:[e.jsx(M,{style:{fontSize:12},children:"列配置"}),e.jsx(s.Button,{size:"small",type:"dashed",icon:e.jsx(B.PlusOutlined,{}),onClick:H}),e.jsx(s.Button,{size:"small",type:"primary",onClick:V,icon:e.jsx(B.SaveOutlined,{})})]}),e.jsx(s.Table,{dataSource:U,columns:ne,pagination:!1,size:"small",bordered:!0,rowKey:"key"})]})},O=()=>{switch(i.type){case"text":return e.jsxs(e.Fragment,{children:[e.jsx(N,{field:"content",label:"内容",placeholder:"请输入文本内容",isTextarea:!0}),e.jsx(s.Divider,{style:{margin:"4px 0"}}),e.jsx(M,{type:"secondary",style:{fontSize:12,display:"block",marginBottom:4},children:"文字样式"}),e.jsxs(s.Space,{style:{width:"100%"},direction:"vertical",size:4,children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"字号"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:i.props.fontSize||14,min:6,max:200,onChange:r=>j("fontSize",r??14)})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"对齐"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:i.props.textAlign||"left",onChange:r=>j("textAlign",r),options:[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"}]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"字重"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:i.props.fontWeight||"normal",onChange:r=>j("fontWeight",r),options:[{value:"normal",label:"常规"},{value:"bold",label:"加粗"}]})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"样式"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:i.props.fontStyle||"normal",onChange:r=>j("fontStyle",r),options:[{value:"normal",label:"常规"},{value:"italic",label:"斜体"}]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"字体颜色"}),e.jsx(s.ColorPicker,{size:"small",value:i.props.color||"#000000",onChange:(r,f)=>j("color",f)})]}),e.jsxs("div",{children:[e.jsx(M,{style:{fontSize:12},children:"背景色"}),e.jsx(s.ColorPicker,{size:"small",value:i.props.backgroundColor||"transparent",onChange:(r,f)=>j("backgroundColor",f)})]})]})]})]});case"image":return e.jsxs(e.Fragment,{children:[e.jsx(N,{field:"src",label:"图片地址",placeholder:"输入图片 URL"}),e.jsx(s.Divider,{style:{margin:"4px 0"}}),e.jsx(M,{style:{fontSize:12,marginTop:8,display:"block"},children:"适应方式"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:i.props.fit||"contain",onChange:r=>j("fit",r),options:[{value:"contain",label:"适应"},{value:"cover",label:"填充"},{value:"fill",label:"拉伸"}]})]});case"table":return e.jsx(y,{});case"barcode":return e.jsxs(e.Fragment,{children:[e.jsx(N,{field:"value",label:"条码值",placeholder:"输入条码内容"}),e.jsx(s.Divider,{style:{margin:"4px 0"}}),e.jsx(M,{style:{fontSize:12,marginTop:8,display:"block"},children:"格式"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:i.props.format||"CODE128",onChange:r=>j("format",r),options:[{value:"CODE128",label:"CODE128"}]})]});case"line":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"粗细"}),e.jsx(s.InputNumber,{size:"small",style:{width:"100%"},value:i.props.thickness||1,min:1,max:20,onChange:r=>j("thickness",r??1)})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx(M,{style:{fontSize:12},children:"样式"}),e.jsx(s.Select,{size:"small",style:{width:"100%"},value:i.props.style||"solid",onChange:r=>j("style",r),options:[{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"}]})]})]}),e.jsxs("div",{style:{marginTop:8},children:[e.jsx(M,{style:{fontSize:12},children:"颜色"}),e.jsx(s.ColorPicker,{size:"small",value:i.props.color||"#000000",onChange:(r,f)=>j("color",f)})]})]});default:return null}};return e.jsx(s.Card,{title:`属性 - ${g}`,size:"small",style:{height:"100%",borderRadius:0,borderLeft:0},styles:{body:{padding:16,overflowY:"auto"}},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[z,e.jsx(s.Divider,{style:{margin:"4px 0"}}),O()]})})},{Text:cr}=s.Typography,Ot=()=>{const o=T(y=>y.previewVisible),d=T(y=>y.setPreviewVisible),a=T(y=>y.components),n=T(y=>y.pageSettings),l=T(y=>y.gridSettings)||fe,i=T(y=>y.dataSources),v=w.useRef(null),m=w.useMemo(()=>{const y=he[n.paperSize];if(!y)return{width:n.customWidth*A,height:n.customHeight*A};const O=y.width*A,r=y.height*A;return n.orientation==="landscape"?{width:r,height:O}:{width:O,height:r}},[n]),u=w.useMemo(()=>({top:n.marginTop*A,right:n.marginRight*A,bottom:n.marginBottom*A,left:n.marginLeft*A}),[n]),j=m.width-u.left-u.right,b=j/l.cols,P=De.useReactToPrint({contentRef:v,documentTitle:"打印模板",pageStyle:`
|
|
31
|
-
@page {
|
|
32
|
-
size: ${m.width/A}mm ${m.height/A}mm;
|
|
33
|
-
margin: ${n.marginTop}mm ${n.marginRight}mm ${n.marginBottom}mm ${n.marginLeft}mm;
|
|
34
|
-
}
|
|
35
|
-
@media print {
|
|
36
|
-
html, body { margin: 0; padding: 0; }
|
|
37
|
-
}
|
|
38
|
-
`}),g=(y,O)=>{const r=y.props[`${O}Binding`];if(r&&r.dataSourceId&&r.fieldPath){const f=i.find(x=>x.id===r.dataSourceId);if(f&&f.type==="object"){const x=ge(f);if(x){const _=pe(x,r.fieldPath);if(_!=="")return _}}}return(r==null?void 0:r.staticValue)??String(y.props[O]||"")},z=y=>{const O=y.props.tableDataSourceId,r=O?i.find(F=>F.id===O):null,f=r?me(r):null,x=y.tableColumns||[],_=y.props.borderWidth||1,h=y.props.borderColor||"#000000",S=f||Array.from({length:y.props.rows||3}).map(()=>({}));return e.jsxs("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{children:x.map((F,V)=>e.jsx("th",{style:{border:`${_}px solid ${h}`,padding:4,textAlign:"center",fontSize:12,fontWeight:"bold",backgroundColor:"#f5f5f5"},children:F.title||`列${V+1}`},V))})}),e.jsx("tbody",{children:S.map((F,V)=>e.jsx("tr",{children:x.map((H,q)=>e.jsx("td",{style:{border:`${_}px solid ${h}`,padding:4,textAlign:"center",fontSize:12},children:H.fieldPath?pe(F,H.fieldPath):""},q))},V))})]})},N=y=>{const O=y.props,r={position:"absolute",left:y.x*b,top:y.y*b,width:y.w*b,height:y.h*b,overflow:"hidden"},f={width:"100%",height:"100%",overflow:"hidden",boxSizing:"border-box"};switch(y.type){case"text":return e.jsx("div",{style:r,children:e.jsx("div",{style:{...f,fontSize:O.fontSize||14,fontWeight:O.fontWeight||"normal",fontStyle:O.fontStyle||"normal",textAlign:O.textAlign||"left",color:O.color||"#000",backgroundColor:O.backgroundColor||"transparent",padding:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:g(y,"content")})},y.id);case"image":return e.jsx("div",{style:r,children:e.jsx("div",{style:f,children:O.src?e.jsx("img",{src:g(y,"src"),style:{width:"100%",height:"100%",objectFit:O.fit||"contain"},alt:""}):null})},y.id);case"table":return e.jsx("div",{style:r,children:z(y)},y.id);case"barcode":return e.jsx("div",{style:r,children:e.jsx("div",{style:{...f,display:"flex",alignItems:"center",justifyContent:"center",padding:4},children:e.jsx(we,{value:g(y,"value"),format:O.format||"CODE128"})})},y.id);case"line":return e.jsx("div",{style:r,children:e.jsx("div",{style:{...f,display:"flex",alignItems:"center",border:"none"},children:e.jsx("hr",{style:{width:"100%",border:"none",borderTop:`${O.thickness||1}px ${O.style||"solid"} ${O.color||"#000"}`,margin:0}})})},y.id);default:return null}};return e.jsxs(s.Modal,{title:"打印预览",open:o,onCancel:()=>d(!1),width:m.width+80,footer:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>d(!1),children:"关闭"}),e.jsx(s.Button,{type:"primary",icon:e.jsx(B.PrinterOutlined,{}),onClick:()=>P(),children:"打印"})]}),styles:{body:{padding:16,display:"flex",flexDirection:"column",alignItems:"center"}},children:[e.jsx(s.Divider,{style:{margin:"4px 0 12px 0"}}),e.jsxs("div",{ref:v,style:{width:m.width,height:m.height,background:"#fff",border:"1px solid #d9d9d9",position:"relative",overflow:"hidden",flexShrink:0},children:[n.showHeader&&e.jsx("div",{style:{position:"absolute",top:0,left:u.left,right:u.right,height:u.top,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,overflow:"hidden"},children:n.headerContent}),n.showFooter&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:u.left,right:u.right,height:u.bottom,display:"flex",alignItems:"center",justifyContent:n.showPageNumber?"space-between":"center",fontSize:12,overflow:"hidden",padding:"0 8px"},children:[e.jsx("span",{children:n.footerContent}),n.showPageNumber&&e.jsx("span",{children:n.pageNumberFormat.replace("{page}","1")})]}),e.jsx("div",{style:{position:"absolute",top:u.top,left:u.left,width:j,height:m.height-u.top-u.bottom},children:a.map(N)})]})]})},It=()=>{const o=T(l=>l.headerFooterVisible),d=T(l=>l.pageSettings),a=T(l=>l.setPageSettings),n=T(l=>l.setHeaderFooterVisible);return e.jsx(s.Modal,{title:"页眉页脚设置",open:o,onCancel:()=>n(!1),onOk:()=>n(!1),width:480,children:e.jsxs(s.Form,{layout:"vertical",style:{marginTop:8},children:[e.jsx(s.Form.Item,{label:"显示页眉",children:e.jsx(s.Switch,{checked:d.showHeader,onChange:l=>a({showHeader:l})})}),d.showHeader&&e.jsx(s.Form.Item,{label:"页眉内容",children:e.jsx(s.Input,{value:d.headerContent,onChange:l=>a({headerContent:l.target.value})})}),e.jsx(s.Form.Item,{label:"显示页脚",children:e.jsx(s.Switch,{checked:d.showFooter,onChange:l=>a({showFooter:l})})}),d.showFooter&&e.jsxs(e.Fragment,{children:[e.jsx(s.Form.Item,{label:"页脚内容",children:e.jsx(s.Input,{value:d.footerContent,onChange:l=>a({footerContent:l.target.value})})}),e.jsx(s.Form.Item,{label:"显示页码",children:e.jsx(s.Switch,{checked:d.showPageNumber,onChange:l=>a({showPageNumber:l})})}),d.showPageNumber&&e.jsx(s.Form.Item,{label:"页码格式",children:e.jsx(s.Input,{value:d.pageNumberFormat,onChange:l=>a({pageNumberFormat:l.target.value}),placeholder:"第 {page} 页"})})]})]})})},zt=({isPreview:o=!1,initialTemplateData:d,onSave:a,onPrint:n})=>{const{importJSON:l,exportJSON:i,reset:v,components:m,pageSettings:u,gridSettings:j,dataSources:b}=T(),P=w.useRef(null);w.useEffect(()=>{if(d){const h=JSON.stringify(d),S=l(h);S&&(console.error("导入失败:",S),v())}},[d,l,v]);const g=()=>{if(a)try{const h=i();a(JSON.parse(h))}catch(h){console.error("导出失败:",h)}},z=w.useMemo(()=>{const h=he[u.paperSize];if(!h)return{width:u.customWidth*A,height:u.customHeight*A};const S=h.width*A,F=h.height*A;return u.orientation==="landscape"?{width:F,height:S}:{width:S,height:F}},[u]),N=w.useMemo(()=>({top:u.marginTop*A,right:u.marginRight*A,bottom:u.marginBottom*A,left:u.marginLeft*A}),[u]),y=z.width-N.left-N.right,O=y/((j==null?void 0:j.cols)||fe.cols),r=De.useReactToPrint({contentRef:P,documentTitle:"打印模板",pageStyle:`
|
|
39
|
-
@page {
|
|
40
|
-
size: ${z.width/A}mm ${z.height/A}mm;
|
|
41
|
-
margin: ${u.marginTop}mm ${u.marginRight}mm ${u.marginBottom}mm ${u.marginLeft}mm;
|
|
42
|
-
}
|
|
43
|
-
@media print {
|
|
44
|
-
html, body { margin: 0; padding: 0; }
|
|
45
|
-
}
|
|
46
|
-
`}),f=()=>{n?n():r()},x=h=>{const S=h.props,F={position:"absolute",left:h.x*O,top:h.y*O,width:h.w*O,height:h.h*O,overflow:"hidden"},V={width:"100%",height:"100%",overflow:"hidden",boxSizing:"border-box"};switch(h.type){case"text":return e.jsx("div",{style:F,children:e.jsx("div",{style:{...V,fontSize:S.fontSize||14,fontWeight:S.fontWeight||"normal",fontStyle:S.fontStyle||"normal",textAlign:S.textAlign||"left",color:S.color||"#000",backgroundColor:S.backgroundColor||"transparent",padding:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:ce(h,"content",b)})},h.id);case"image":return e.jsx("div",{style:F,children:e.jsx("div",{style:V,children:S.src?e.jsx("img",{src:ce(h,"src",b),style:{width:"100%",height:"100%",objectFit:S.fit||"contain"},alt:""}):null})},h.id);case"table":return e.jsx("div",{style:F,children:_(h)},h.id);case"barcode":return e.jsx("div",{style:F,children:e.jsx("div",{style:{...V,display:"flex",alignItems:"center",justifyContent:"center",padding:4},children:e.jsx(we,{value:ce(h,"value",b),format:S.format||"CODE128"})})},h.id);case"line":return e.jsx("div",{style:F,children:e.jsx("div",{style:{...V,display:"flex",alignItems:"center",border:"none"},children:e.jsx("hr",{style:{width:"100%",border:"none",borderTop:`${S.thickness||1}px ${S.style||"solid"} ${S.color||"#000"}`,margin:0}})})},h.id);default:return null}},_=h=>{const S=h.props.tableDataSourceId,F=S?b.find(U=>U.id===S):null,V=F?me(F):null,H=h.tableColumns||[],q=h.props.borderWidth||1,W=h.props.borderColor||"#000000";if(V&&V.length>0)return e.jsxs("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse"},children:[H.length>0&&e.jsx("thead",{children:e.jsx("tr",{style:{backgroundColor:"#f5f5f5"},children:H.map((U,k)=>e.jsx("th",{style:{border:`${q}px solid ${W}`,padding:4,fontSize:12,fontWeight:"bold",textAlign:"center"},children:U.title},k))})}),e.jsx("tbody",{children:V.map((U,k)=>e.jsx("tr",{children:H.map((R,K)=>e.jsx("td",{style:{border:`${q}px solid ${W}`,padding:4,fontSize:12,textAlign:"center"},children:R.fieldPath?U[R.fieldPath]:""},K))},k))})]});const re=h.props.rows||3,ne=Math.max(h.props.cols||3,H.length||3);return e.jsx("table",{style:{width:"100%",height:"100%",borderCollapse:"collapse"},children:e.jsx("tbody",{children:Array.from({length:re}).map((U,k)=>e.jsx("tr",{children:Array.from({length:ne}).map((R,K)=>e.jsx("td",{style:{border:`${q}px solid ${W}`,padding:2,fontSize:12,textAlign:"center"},children:" "},K))},k))})})};return o?e.jsx(s.App,{children:e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid #e8e8e8",background:"#fff"},children:e.jsx(s.Space,{children:e.jsx(s.Button,{type:"primary",icon:e.jsx(B.PrinterOutlined,{}),onClick:f,children:"打印"})})}),e.jsx("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"flex-start",padding:"16px",boxSizing:"border-box",overflowY:"auto",background:"#e8e8e8"},children:e.jsx("div",{style:{flexShrink:0},children:e.jsx(Je,{isPreview:!0})})}),e.jsx("div",{style:{position:"absolute",left:"-9999px",top:"-9999px"},children:e.jsxs("div",{ref:P,style:{width:z.width,height:z.height,background:"#fff",position:"relative",overflow:"hidden"},children:[u.showHeader&&e.jsx("div",{style:{position:"absolute",top:0,left:N.left,right:N.right,height:N.top,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,overflow:"hidden"},children:u.headerContent}),u.showFooter&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:N.left,right:N.right,height:N.bottom,display:"flex",alignItems:"center",justifyContent:u.showPageNumber?"space-between":"center",fontSize:12,overflow:"hidden",padding:"0 8px"},children:[e.jsx("span",{children:u.footerContent}),u.showPageNumber&&e.jsx("span",{children:u.pageNumberFormat.replace("{page}","1")})]}),e.jsx("div",{style:{position:"absolute",top:N.top,left:N.left,width:y,height:z.height-N.top-N.bottom},children:m.map(x)})]})})]})}):e.jsx(s.App,{children:e.jsxs("div",{className:"app-container",children:[e.jsx(yt,{onCustomSave:a?g:void 0,onCustomPrint:n}),e.jsxs("div",{className:"app-body",children:[e.jsx("div",{className:"app-left-panel",children:e.jsx(kt,{})}),e.jsx(Je,{}),e.jsx("div",{className:"app-right-panel",children:e.jsx(_t,{})})]}),e.jsx(Ot,{}),e.jsx(It,{})]})})};Y.default=zt,Y.getArrayFromDataSource=me,Y.getObjectFromDataSource=ge,Y.getRenderValue=ce,Y.getValueByPath=pe,Y.safeParseJSON=ae,Y.useDesignerStore=T,Object.defineProperties(Y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/store/index.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CanvasComponent, PageSettings, GridSettings, DataSource, TemplateData } from '../types';
|
|
2
|
-
interface DesignerStore {
|
|
3
|
-
components: CanvasComponent[];
|
|
4
|
-
selectedId: string | null;
|
|
5
|
-
pageSettings: PageSettings;
|
|
6
|
-
gridSettings: GridSettings;
|
|
7
|
-
dataSources: DataSource[];
|
|
8
|
-
// Components actions
|
|
9
|
-
addComponent: (comp: Omit<CanvasComponent, 'id'>) => void;
|
|
10
|
-
updateComponent: (id: string, updates: Partial<CanvasComponent>) => void;
|
|
11
|
-
updateComponentProps: (id: string, props: Record<string, unknown>) => void;
|
|
12
|
-
updateComponentTableColumns: (id: string, columns: any[]) => void;
|
|
13
|
-
deleteComponent: (id: string) => void;
|
|
14
|
-
selectComponent: (id: string | null) => void;
|
|
15
|
-
moveComponent: (id: string, x: number, y: number) => void;
|
|
16
|
-
resizeComponent: (id: string, w: number, h: number) => void;
|
|
17
|
-
// Page settings actions
|
|
18
|
-
updatePageSettings: (settings: Partial<PageSettings>) => void;
|
|
19
|
-
// Grid settings actions
|
|
20
|
-
updateGridSettings: (settings: Partial<GridSettings>) => void;
|
|
21
|
-
// Data sources actions
|
|
22
|
-
addDataSource: (ds: Omit<DataSource, 'id'>) => void;
|
|
23
|
-
updateDataSource: (id: string, updates: Partial<DataSource>) => void;
|
|
24
|
-
deleteDataSource: (id: string) => void;
|
|
25
|
-
// Template actions
|
|
26
|
-
loadTemplate: (data: TemplateData) => void;
|
|
27
|
-
exportTemplate: () => TemplateData;
|
|
28
|
-
}
|
|
29
|
-
export declare const useDesignerStore: () => DesignerStore;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export type CanvasComponentType = 'text' | 'image' | 'table' | 'barcode' | 'line';
|
|
2
|
-
|
|
3
|
-
export interface DataBinding {
|
|
4
|
-
dataSourceId?: string;
|
|
5
|
-
fieldPath?: string;
|
|
6
|
-
staticValue: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type DataBindingConfig = DataBinding;
|
|
10
|
-
|
|
11
|
-
export interface TableColumnConfig {
|
|
12
|
-
title: string;
|
|
13
|
-
fieldPath?: string;
|
|
14
|
-
width?: number;
|
|
15
|
-
editable?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface CanvasComponent {
|
|
19
|
-
id: string;
|
|
20
|
-
type: CanvasComponentType;
|
|
21
|
-
x: number;
|
|
22
|
-
y: number;
|
|
23
|
-
w: number;
|
|
24
|
-
h: number;
|
|
25
|
-
props: Record<string, unknown>;
|
|
26
|
-
tableColumns?: TableColumnConfig[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type DataSourceType = 'object' | 'array';
|
|
30
|
-
|
|
31
|
-
export interface DataSource {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
type: DataSourceType;
|
|
35
|
-
data: string;
|
|
36
|
-
createdAt: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type PaperSizePreset = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'custom';
|
|
40
|
-
|
|
41
|
-
export type Orientation = 'portrait' | 'landscape';
|
|
42
|
-
|
|
43
|
-
export interface PageSettings {
|
|
44
|
-
paperSize: PaperSizePreset;
|
|
45
|
-
customWidth: number;
|
|
46
|
-
customHeight: number;
|
|
47
|
-
orientation: Orientation;
|
|
48
|
-
marginTop: number;
|
|
49
|
-
marginRight: number;
|
|
50
|
-
marginBottom: number;
|
|
51
|
-
marginLeft: number;
|
|
52
|
-
showHeader: boolean;
|
|
53
|
-
headerContent: string;
|
|
54
|
-
showFooter: boolean;
|
|
55
|
-
footerContent: string;
|
|
56
|
-
showPageNumber: boolean;
|
|
57
|
-
pageNumberFormat: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface GridSettings {
|
|
61
|
-
cellSize: number;
|
|
62
|
-
cols: number;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface TemplateData {
|
|
66
|
-
version: string;
|
|
67
|
-
templateName: string;
|
|
68
|
-
pageSettings: PageSettings;
|
|
69
|
-
components: Omit<CanvasComponent, 'id'>[];
|
|
70
|
-
dataSources: Omit<DataSource, 'id'>[];
|
|
71
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CanvasComponent, DataSource } from '../types';
|
|
2
|
-
export declare function safeParseJSON(str: string): any;
|
|
3
|
-
export declare function getValueByPath(obj: any, path: string): any;
|
|
4
|
-
export declare function getObjectFromDataSource(ds: DataSource): any;
|
|
5
|
-
export declare function getArrayFromDataSource(ds: DataSource): any[];
|
|
6
|
-
export declare function getRenderValue(comp: CanvasComponent, propName: string, dataSources: DataSource[]): string;
|