dform-designer 2.1.38 → 2.1.40

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.
@@ -0,0 +1,445 @@
1
+ var Q = Object.defineProperty;
2
+ var Z = (e, n, r) => n in e ? Q(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
3
+ var j = (e, n, r) => Z(e, typeof n != "symbol" ? n + "" : n, r);
4
+ import { defineComponent as P, createVNode as T, Fragment as p, h as d, nextTick as G, computed as I, inject as K, resolveComponent as V, openBlock as N, createElementBlock as C, renderList as B, createElementVNode as A, normalizeStyle as Y, toDisplayString as q, unref as X, createTextVNode as ee, renderSlot as te, withCtx as ne, createCommentVNode as re } from "vue";
5
+ import { ElTag as ae, ElImage as F, ElIcon as L } from "element-plus";
6
+ import { Download as H } from "@element-plus/icons-vue";
7
+ const oe = (e, n) => (e.install = (r) => {
8
+ for (const a of [e, ...Object.values({})])
9
+ r.component(a.name, a);
10
+ }, e), se = BigInt(16224768e5), J = 5n, E = 5n, $ = 12n, ie = -1n ^ -1n << J, le = -1n ^ -1n << E, ce = $ + J + E, ue = $ + E, de = $, fe = -1n ^ -1n << $;
11
+ class ge {
12
+ // 构造函数,接受数据中心 ID 和工作节点 ID 作为参数,同时初始化上一次的时间戳和序列号
13
+ constructor(n, r) {
14
+ j(this, "dataCenterId");
15
+ j(this, "workerId");
16
+ j(this, "lastTimestamp");
17
+ j(this, "sequence");
18
+ if (n < 0n || n > ie)
19
+ throw new Error("data center id is out of range");
20
+ if (r < 0n || r > le)
21
+ throw new Error("worker id is out of range");
22
+ this.dataCenterId = n, this.workerId = r, this.lastTimestamp = -1n, this.sequence = 0n;
23
+ }
24
+ // 生成 ID 的方法,返回一个 BigInt 类型的 ID
25
+ nextId() {
26
+ let n = BigInt(Date.now());
27
+ if (n < this.lastTimestamp)
28
+ throw new Error("clock moved backwards");
29
+ return n === this.lastTimestamp ? (this.sequence = this.sequence + 1n & fe, this.sequence === 0n && (n = this.waitNextMillisecond(n))) : this.sequence = 0n, this.lastTimestamp = n, (n - se << ce) + (this.dataCenterId << ue) + (this.workerId << de) + this.sequence;
30
+ }
31
+ // 等待下一毫秒的方法,返回一个 BigInt 类型的时间戳
32
+ waitNextMillisecond(n) {
33
+ for (; n <= this.lastTimestamp; )
34
+ n = BigInt(Date.now());
35
+ return n;
36
+ }
37
+ }
38
+ new ge(1n, 1n);
39
+ const me = /* @__PURE__ */ P({
40
+ props: {
41
+ attr: {
42
+ type: Object
43
+ },
44
+ type: {
45
+ type: String,
46
+ required: !0
47
+ },
48
+ value: {
49
+ type: null,
50
+ default: null
51
+ },
52
+ enum: {
53
+ type: Array,
54
+ default: () => []
55
+ },
56
+ isColor: Boolean,
57
+ row: {
58
+ type: Object,
59
+ required: !0
60
+ },
61
+ columnName: {
62
+ type: String,
63
+ required: !0
64
+ },
65
+ download: {
66
+ type: Boolean,
67
+ default: !0
68
+ },
69
+ showNull: {
70
+ type: Boolean,
71
+ default: !0
72
+ }
73
+ },
74
+ setup(e) {
75
+ const n = (t) => typeof t == "string" || typeof t == "number" || typeof t == "boolean", r = (t) => {
76
+ if (typeof t == "string" && t.trim().startsWith("[") && t.endsWith("]"))
77
+ try {
78
+ const o = JSON.parse(t);
79
+ if (Array.isArray(o))
80
+ return o.join("、");
81
+ } catch {
82
+ return t;
83
+ }
84
+ return Array.isArray(t) ? t.join("、") : n(t) ? t : JSON.stringify(t);
85
+ }, a = () => {
86
+ var t, o, i, f, x, D, l, h, b;
87
+ if (e.value === null || e.value === void 0 || e.value === "")
88
+ return e.showNull ? d("div", {
89
+ class: "no-txt"
90
+ }) : null;
91
+ if (["Radio", "Checkbox", "Select"].includes(e.type))
92
+ return v();
93
+ switch (e.type) {
94
+ case "Sign":
95
+ case "Qrcode":
96
+ case "Barcode":
97
+ return u(e.value);
98
+ case "Upload":
99
+ if (typeof e.value == "string" && z(e.value)) {
100
+ const k = JSON.parse(e.value);
101
+ return m(k);
102
+ }
103
+ return m(e.value);
104
+ case "Editor":
105
+ return d("div", {
106
+ innerHTML: e.value || "",
107
+ style: {
108
+ maxHeight: "220px",
109
+ overflowY: "auto"
110
+ },
111
+ class: "rich-text-content"
112
+ });
113
+ case "Number":
114
+ return w(e);
115
+ case "Amount":
116
+ return w(e);
117
+ case "Location":
118
+ return S(e.value ? c(e.value) : {});
119
+ case "SubTable":
120
+ return e.row[`${e.columnName}_ct`];
121
+ case "Related":
122
+ return g(e);
123
+ case "Formula":
124
+ return ye(e.value, e == null ? void 0 : e.attr);
125
+ case "Region":
126
+ return s(e.value, "/");
127
+ case "User":
128
+ return ve(e.value);
129
+ case "Role":
130
+ case "Dept":
131
+ return s(e.value, "、");
132
+ case "Cascader":
133
+ return e.row[`${(t = e == null ? void 0 : e.attr) == null ? void 0 : t.prop}_text`];
134
+ case "Date":
135
+ return (((i = (o = e == null ? void 0 : e.attr) == null ? void 0 : o.props) == null ? void 0 : i.type) === "daterange" || ((x = (f = e == null ? void 0 : e.attr) == null ? void 0 : f.props) == null ? void 0 : x.type) === "datetimerange") && Array.isArray(e.value) ? e.value.join(" - ") : we((l = (D = e == null ? void 0 : e.attr) == null ? void 0 : D.props) == null ? void 0 : l.type, e.value);
136
+ default:
137
+ return (b = (h = e == null ? void 0 : e.attr) == null ? void 0 : h.props) != null && b.showPassword ? "********" : r(e.value);
138
+ }
139
+ }, c = (t) => {
140
+ try {
141
+ return typeof t == "string" ? JSON.parse(t) : t;
142
+ } catch {
143
+ return {
144
+ district: "",
145
+ address: t || "",
146
+ name: ""
147
+ };
148
+ }
149
+ }, S = (t) => {
150
+ const o = [t.district, t.address, t.name].filter(Boolean);
151
+ return o.length ? o.join("") : "";
152
+ }, g = (t) => {
153
+ var o;
154
+ return t.row[`${t.columnName}_related`] ? t.row[`${t.columnName}_related`] : (o = t.row[`${t.columnName}_related_data`]) == null ? void 0 : o.map((i) => {
155
+ var f;
156
+ return i[((f = t.attr.props) == null ? void 0 : f.title) || t.attr.prop];
157
+ }).join("、");
158
+ }, w = (t) => {
159
+ var i, f, x, D, l;
160
+ let o = "";
161
+ return (i = t.attr.props) != null && i.showPassword ? o = o + "********" : ((f = t.attr) != null && f.prefix && (o = o + ((x = t.attr) == null ? void 0 : x.prefix)), o = o + t.value, (D = t.attr) != null && D.suffix && (o = o + ((l = t.attr) == null ? void 0 : l.suffix))), o;
162
+ }, s = (t, o) => Array.isArray(t) ? t.filter(Boolean).join(o) : t || "", u = (t) => d(F, {
163
+ style: {
164
+ height: "80px"
165
+ },
166
+ src: t,
167
+ previewSrcList: [t],
168
+ previewTeleported: !0,
169
+ onContextmenu: (o) => o.preventDefault(),
170
+ draggable: !1,
171
+ hideOnClickModal: !0
172
+ }), m = (t) => {
173
+ const o = (l) => {
174
+ const h = l.match(/\.([a-zA-Z0-9]+)$/);
175
+ return h ? h[1].toLowerCase() : "jpg";
176
+ }, i = async (l, h) => {
177
+ try {
178
+ const b = await fetch(l, {
179
+ mode: "cors",
180
+ headers: {
181
+ Accept: "image/*"
182
+ }
183
+ });
184
+ if (!b.ok) throw new Error("下载失败");
185
+ const k = await b.blob(), y = URL.createObjectURL(k), _ = document.createElement("a");
186
+ _.href = y, _.download = h, _.style.display = "none", document.body.appendChild(_), _.click(), setTimeout(() => {
187
+ document.body.removeChild(_), URL.revokeObjectURL(y);
188
+ }, 100);
189
+ } catch (b) {
190
+ console.error("下载失败:", b), window.open(l, "_blank");
191
+ }
192
+ }, f = (l) => /\.(jpg|jpeg|png|gif|bmp|svg|webp)$/i.test(l), D = (Array.isArray(t) ? t : t ? [{
193
+ url: typeof t == "string" ? t : t.url || "",
194
+ name: t.name || ""
195
+ }] : []).map((l, h) => {
196
+ const b = o(l.url), k = l.name || `image_${h + 1}.${b}`;
197
+ return f(l.url) ? d("div", {
198
+ class: "thumbnail-item image-item",
199
+ key: `thumb-${h}`
200
+ }, [d("div", {
201
+ class: "image-wrapper"
202
+ }, [
203
+ d(F, {
204
+ class: "preview-image",
205
+ style: {
206
+ height: "80px",
207
+ width: "auto",
208
+ cursor: "pointer",
209
+ "max-width": "120px",
210
+ "object-fit": "cover"
211
+ },
212
+ src: l.url,
213
+ // 小图禁用右键
214
+ onContextmenu: (y) => y.preventDefault(),
215
+ draggable: !1,
216
+ previewSrcList: [l.url],
217
+ previewTeleported: !0,
218
+ hideOnClickModal: !0,
219
+ // 🔥 关键:预览弹窗加载后,给预览图也禁用右键
220
+ onShow: () => {
221
+ G(() => {
222
+ if (e.download !== !1) return;
223
+ document.querySelectorAll(".el-image-viewer__img,.df-image-viewer__img").forEach((_) => {
224
+ _.oncontextmenu = (W) => W.preventDefault();
225
+ });
226
+ });
227
+ }
228
+ }),
229
+ // 下载按钮受控
230
+ e.download !== !1 && d("div", {
231
+ class: "image-overlay",
232
+ onMouseenter: (y) => y.currentTarget.style.opacity = "1",
233
+ onMouseleave: (y) => y.currentTarget.style.opacity = "0"
234
+ }, [d("div", {
235
+ class: "download-btn",
236
+ onClick: async (y) => {
237
+ y.stopPropagation(), await i(l.url, k);
238
+ }
239
+ }, [d(L, {
240
+ class: "download-icon"
241
+ }, [d(H)])])])
242
+ ])]) : d("div", {
243
+ class: "thumbnail-item file-item",
244
+ key: `file-${h}`
245
+ }, [
246
+ d("span", {
247
+ class: "file-name"
248
+ }, l.name || "未命名文件"),
249
+ // 文件下载按钮受控
250
+ e.download !== !1 && d(L, {
251
+ class: "file-download-btn",
252
+ onClick: async () => await i(l.url, k)
253
+ }, [d(H)])
254
+ ]);
255
+ });
256
+ return d("div", {
257
+ class: "upload-preview"
258
+ }, D);
259
+ }, v = () => {
260
+ if (e.value === null || e.value === void 0) return null;
261
+ let t;
262
+ return e.value.indexOf("[") !== -1 ? t = JSON.parse(e.value) : t = Array.isArray(e.value) ? e.value : [e.value], t.map((o) => {
263
+ var f;
264
+ const i = ((f = e.enum) == null ? void 0 : f.find((x) => String(x.value) === String(o))) || {
265
+ label: String(o)
266
+ };
267
+ return d(ae, {
268
+ class: "tagClass",
269
+ round: !0,
270
+ color: e.isColor ? i.color : void 0,
271
+ style: {
272
+ margin: "2px 5px 2px 0",
273
+ border: "none",
274
+ color: "#ffffff"
275
+ }
276
+ }, i.label);
277
+ });
278
+ };
279
+ return () => {
280
+ const t = a();
281
+ if (typeof t == "string" && t.includes("#~#")) {
282
+ const [o, i] = t.split("#~#");
283
+ return T(p, null, [T("div", {
284
+ class: "item-detail"
285
+ }, [o]), T("div", {
286
+ class: "item-add"
287
+ }, [i])]);
288
+ }
289
+ return t;
290
+ };
291
+ }
292
+ });
293
+ function we(e, n) {
294
+ const r = e.toLowerCase();
295
+ let a;
296
+ if (n instanceof Date)
297
+ a = n;
298
+ else if (typeof n == "string")
299
+ if (/^\d{1,2}:\d{2}(:\d{2})?$/.test(n)) {
300
+ const c = /* @__PURE__ */ new Date(), [S, g, w] = n.split(":").map(Number);
301
+ a = new Date(c.getFullYear(), c.getMonth(), c.getDate(), S, g, w || 0);
302
+ } else
303
+ a = new Date(n), isNaN(a.getTime()) && (a = /* @__PURE__ */ new Date());
304
+ else
305
+ a = /* @__PURE__ */ new Date();
306
+ if (r === "daterange") {
307
+ const c = new Date(a);
308
+ return c.setDate(a.getDate() - 1), [M(c), M(a)];
309
+ }
310
+ if (r === "datetimerange") {
311
+ const c = new Date(a);
312
+ return c.setHours(0, 0, 0, 0), [O(c), O(a)];
313
+ }
314
+ return r === "datetime" ? O(a) : r.includes("hh:mm:ss") ? U(a) : r.includes("hh:mm") ? he(a) : r === "month" ? `${a.getFullYear()}-${(a.getMonth() + 1).toString().padStart(2, "0")}` : r === "year" ? a.getFullYear().toString() : M(a);
315
+ }
316
+ function M(e) {
317
+ return [e.getFullYear(), (e.getMonth() + 1).toString().padStart(2, "0"), e.getDate().toString().padStart(2, "0")].join("-");
318
+ }
319
+ function he(e) {
320
+ return [e.getHours().toString().padStart(2, "0"), e.getMinutes().toString().padStart(2, "0")].join(":");
321
+ }
322
+ function U(e) {
323
+ return [e.getHours().toString().padStart(2, "0"), e.getMinutes().toString().padStart(2, "0"), e.getSeconds().toString().padStart(2, "0")].join(":");
324
+ }
325
+ function O(e) {
326
+ return `${M(e)} ${U(e)}`;
327
+ }
328
+ function z(e) {
329
+ if (typeof e != "string" || e.trim() === "")
330
+ return !1;
331
+ const n = e.trim();
332
+ if (!/^(?:\{[\s\S]*\}|\[[\s\S]*\])$/.test(n))
333
+ return !1;
334
+ try {
335
+ return JSON.parse(n), !0;
336
+ } catch {
337
+ return !1;
338
+ }
339
+ }
340
+ const ye = (e, n) => {
341
+ var a, c, S, g, w, s;
342
+ let r = e;
343
+ return ((a = n == null ? void 0 : n.config) == null ? void 0 : a.prepend) === "prefix" && (r = ((c = n == null ? void 0 : n.config) == null ? void 0 : c.unit) || "" + r), ((S = n == null ? void 0 : n.config) == null ? void 0 : S.format) === "subtract" && (r = Se(e, (g = n == null ? void 0 : n.subtract) == null ? void 0 : g.format)), ((w = n == null ? void 0 : n.config) == null ? void 0 : w.prepend) === "suffix" && (r = r + ((s = n == null ? void 0 : n.config) == null ? void 0 : s.unit) || ""), r;
344
+ }, Se = (e, n = "YYYY-MM-DD HH:mm:ss") => {
345
+ if (!e) return "";
346
+ const r = new Date(Number(e));
347
+ if (isNaN(r.getTime())) return "";
348
+ const a = r.getFullYear(), c = String(r.getMonth() + 1).padStart(2, "0"), S = String(r.getDate()).padStart(2, "0"), g = String(r.getHours()).padStart(2, "0"), w = String(r.getMinutes()).padStart(2, "0"), s = String(r.getSeconds()).padStart(2, "0");
349
+ return n.replace("YYYY", String(a)).replace("MM", c).replace("DD", S).replace("HH", g).replace("mm", w).replace("ss", s);
350
+ }, ve = (e) => {
351
+ const n = (r) => r.includes("_") ? r.split("_")[0] : r;
352
+ if (e) {
353
+ if (z(e) && (e = JSON.parse(e)), Array.isArray(e))
354
+ return e.map((r) => n(r)).join("、");
355
+ if (e != null)
356
+ return n(e);
357
+ }
358
+ return e;
359
+ }, be = {
360
+ class: "setp-box"
361
+ }, xe = {
362
+ class: "item-box"
363
+ }, _e = {
364
+ class: "title-txt"
365
+ }, De = {
366
+ class: "item-content"
367
+ }, ke = {
368
+ key: 0,
369
+ class: "link-box"
370
+ }, Ne = /* @__PURE__ */ P({
371
+ name: "SetpPlug",
372
+ __name: "index",
373
+ props: {
374
+ attr: {},
375
+ data: {}
376
+ },
377
+ setup(e) {
378
+ const n = e, r = I(() => {
379
+ var s, u;
380
+ return ((u = (s = n.attr) == null ? void 0 : s.props) == null ? void 0 : u.title) || "title";
381
+ }), a = I(() => {
382
+ var s, u;
383
+ return ((u = (s = n.attr) == null ? void 0 : s.props) == null ? void 0 : u.state) || "status";
384
+ }), c = I(() => {
385
+ var u, m;
386
+ const s = (m = (u = n.attr) == null ? void 0 : u.columns) == null ? void 0 : m.find((v) => v.prop === a.value);
387
+ return (s == null ? void 0 : s.enum) || [];
388
+ }), S = I(() => {
389
+ var s, u;
390
+ return ((u = (s = n.attr) == null ? void 0 : s.columns) == null ? void 0 : u.filter((m) => {
391
+ const v = m.columnName ?? m.prop;
392
+ return v && v !== r.value && v !== a.value;
393
+ })) || [];
394
+ }), g = (s) => c.value.find((m) => m.value === s) || {
395
+ color: "#909399",
396
+ label: ""
397
+ }, w = K("TableCellRenderer", me);
398
+ return (s, u) => {
399
+ const m = V("ArrowRight"), v = V("el-icon");
400
+ return N(), C("div", be, [(N(!0), C(p, null, B(e.data, (t, o) => (N(), C(p, {
401
+ key: t.id || o
402
+ }, [A("div", xe, [A("div", {
403
+ class: "title-box",
404
+ style: Y({
405
+ background: g(t[a.value]).color
406
+ })
407
+ }, [A("span", _e, q(t[r.value]), 1)], 4), A("div", {
408
+ class: "item-state mg",
409
+ style: Y({
410
+ color: g(t[a.value]).color
411
+ })
412
+ }, q(g(t[a.value]).label), 5), A("div", De, [(N(!0), C(p, null, B(S.value, (i) => (N(), C("div", {
413
+ key: i.prop,
414
+ class: "mg"
415
+ }, [T(X(w), {
416
+ attr: i,
417
+ type: i.type,
418
+ value: t[i.prop],
419
+ enum: i.enum,
420
+ "is-color": i.isColor,
421
+ row: t,
422
+ "column-name": i.prop,
423
+ showNull: !1
424
+ }, null, 8, ["attr", "type", "value", "enum", "is-color", "row", "column-name"]), u[0] || (u[0] = ee("   ", -1))]))), 128))])]), o < e.data.length - 1 ? (N(), C("div", ke, [te(s.$slots, "link-icon", {}, () => [T(v, {
425
+ size: "16"
426
+ }, {
427
+ default: ne(() => [T(m)]),
428
+ _: 1
429
+ })], !0)])) : re("", !0)], 64))), 128))]);
430
+ };
431
+ }
432
+ }), Ce = (e, n) => {
433
+ const r = e.__vccOpts || e;
434
+ for (const [a, c] of n)
435
+ r[a] = c;
436
+ return r;
437
+ }, Te = /* @__PURE__ */ Ce(Ne, [["__scopeId", "data-v-cc636f4a"]]), R = oe(Te), je = (e) => {
438
+ e.component(R.name, R);
439
+ }, $e = {
440
+ install: je,
441
+ SetpPlug: R
442
+ };
443
+ export {
444
+ $e as default
445
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dform-designer",
3
- "version": "2.1.38",
3
+ "version": "2.1.40",
4
4
  "description": "Vue3.0版本,基于element-plus 表单设计器 仿明道云设计器",
5
5
  "files": [
6
6
  "dist"
@@ -9,10 +9,12 @@
9
9
  "type": "gitee",
10
10
  "url": "https://gitee.com/owen_yang/vform-designer.git"
11
11
  },
12
- "main": "dist/form/FormDesign.umd.js",
12
+ "main": "dist/form/FormDesign.es.js",
13
+ "module": "dist/form/FormDesign.es.js",
14
+ "type": "module",
13
15
  "exports": {
14
- ".": "./dist/form/FormDesign.umd.js",
15
- "./SetpPlug": "./dist/plug/SetpPlug.umd.js",
16
+ ".": "./dist/form/FormDesign.es.js",
17
+ "./SetpPlug": "./dist/plug/SetpPlug.es.js",
16
18
  "./dist/*.css": "./dist/*.css"
17
19
  },
18
20
  "scripts": {
@@ -39,7 +41,7 @@
39
41
  "@wangeditor/editor-for-vue": "^5.1.12",
40
42
  "@wangeditor/plugin-upload-attachment": "^1.1.0",
41
43
  "axios": "^1.6.8",
42
- "element-plus": "^2.11.1",
44
+ "element-plus": "^2.14.2",
43
45
  "jsbarcode": "^3.11.6",
44
46
  "jsonpath-plus": "^10.3.0",
45
47
  "localforage": "^1.10.0",