gbformdesign 0.0.0-stage → 0.1.0

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,2952 @@
1
+ import { computed as H, onMounted as ot, resolveComponent as O, openBlock as m, createElementBlock as w, unref as k, createVNode as f, withCtx as y, Fragment as B, renderList as z, createBlock as V, createElementVNode as o, createTextVNode as Y, toDisplayString as ae, createCommentVNode as j, inject as qe, withModifiers as X, normalizeClass as $, ref as P, watch as Re, withDirectives as pe, vShow as he, vModelText as _t, reactive as Te, normalizeStyle as Rt, provide as ke, nextTick as Ct } from "vue";
2
+ import { ElMessage as oe } from "element-plus";
3
+ import { Delete as Je, Plus as Ye, Upload as Vt } from "@element-plus/icons-vue";
4
+ const d = {
5
+ INPUT: "input",
6
+ TEXTAREA: "textarea",
7
+ INPUT_NUMBER: "input-number",
8
+ RADIO_GROUP: "radio-group",
9
+ CHECKBOX_GROUP: "checkbox-group",
10
+ SELECT: "select",
11
+ SWITCH: "switch",
12
+ DATE_PICKER: "date-picker",
13
+ ROW: "row",
14
+ BUTTON: "button"
15
+ }, xt = {
16
+ [d.INPUT]: "文本输入框",
17
+ [d.TEXTAREA]: "多行文本",
18
+ [d.INPUT_NUMBER]: "数字输入框",
19
+ [d.RADIO_GROUP]: "单选框",
20
+ [d.CHECKBOX_GROUP]: "多选框",
21
+ [d.SELECT]: "下拉选择",
22
+ [d.SWITCH]: "开关",
23
+ [d.DATE_PICKER]: "日期选择器",
24
+ [d.ROW]: "分栏",
25
+ [d.BUTTON]: "按钮"
26
+ }, Ke = [
27
+ d.RADIO_GROUP,
28
+ d.CHECKBOX_GROUP,
29
+ d.SELECT
30
+ ], Ln = {
31
+ FULL: 100,
32
+ HALF: 50,
33
+ THIRD: 33.33,
34
+ QUARTER: 25
35
+ }, Mn = {
36
+ MIN_NUMBER: 1,
37
+ MAX_NUMBER: 100,
38
+ DEFAULT_GUTTER: 20,
39
+ DEFAULT_COLUMN_SPAN: 12,
40
+ MIN_COLUMN_SPAN: 1,
41
+ MAX_COLUMN_SPAN: 24,
42
+ MIN_WIDTH: 10,
43
+ MAX_WIDTH: 100,
44
+ WIDTH_STEP: 5
45
+ }, Qe = {
46
+ TODAY: "today",
47
+ TOMORROW: "tomorrow"
48
+ };
49
+ function Oe() {
50
+ return `component_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
51
+ }
52
+ function at(e) {
53
+ return e.id || (e.id = Oe()), e;
54
+ }
55
+ function De(e) {
56
+ if (e == null || e === "")
57
+ return null;
58
+ const l = Number(e);
59
+ return isNaN(l) ? null : l;
60
+ }
61
+ function rt(e) {
62
+ return e == null || e === "";
63
+ }
64
+ function kt(e) {
65
+ return Array.isArray(e) ? e.map((l) => typeof l == "string" ? { label: l, value: l } : { ...l }) : [];
66
+ }
67
+ function It(e, l = 100) {
68
+ if (e == null)
69
+ return l;
70
+ if (typeof e == "number")
71
+ return e;
72
+ const t = String(e).replace("%", ""), r = parseFloat(t);
73
+ return isNaN(r) ? l : r;
74
+ }
75
+ function Z(e) {
76
+ return e.props?.variableName || `field_${e.id || Date.now()}`;
77
+ }
78
+ const Xe = (e) => {
79
+ const l = e.defaultValue;
80
+ if (rt(l)) return null;
81
+ if (e.type === d.DATE_PICKER) {
82
+ if (l === Qe.TODAY)
83
+ return /* @__PURE__ */ new Date();
84
+ if (l === Qe.TOMORROW) {
85
+ const t = /* @__PURE__ */ new Date();
86
+ return t.setDate(t.getDate() + 1), t;
87
+ }
88
+ return null;
89
+ }
90
+ return e.type === d.INPUT_NUMBER ? De(l) : e.type === d.CHECKBOX_GROUP ? Array.isArray(l) ? [...l] : [] : l;
91
+ }, st = (e, l) => {
92
+ const t = e.__vccOpts || e;
93
+ for (const [r, u] of l)
94
+ t[r] = u;
95
+ return t;
96
+ }, Dt = { class: "form-viewer" }, St = {
97
+ key: 0,
98
+ class: "row-container"
99
+ }, Ut = { class: "column-wrapper" }, $t = /* @__PURE__ */ Object.assign({ name: "FormField" }, {
100
+ __name: "FormField",
101
+ props: {
102
+ component: {
103
+ type: Object,
104
+ required: !0
105
+ },
106
+ formData: {
107
+ type: Object,
108
+ required: !0
109
+ },
110
+ formRules: {
111
+ type: Object,
112
+ required: !0
113
+ },
114
+ readonly: {
115
+ type: Boolean,
116
+ default: !1
117
+ }
118
+ },
119
+ emits: ["update:value"],
120
+ setup(e, { emit: l }) {
121
+ const t = e, r = l, u = H(() => Z(t.component));
122
+ ot(() => {
123
+ if (!(u.value in t.formData)) {
124
+ const s = Xe(t.component);
125
+ s != null ? t.formData[u.value] = s : t.component.type === d.INPUT_NUMBER ? t.formData[u.value] = null : t.component.type === d.RADIO_GROUP || t.component.type === d.SELECT || t.component.type === d.TEXTAREA ? t.formData[u.value] = "" : t.component.type === d.DATE_PICKER ? t.formData[u.value] = null : t.component.type === d.CHECKBOX_GROUP ? t.formData[u.value] = [] : t.component.type === d.SWITCH ? t.formData[u.value] = !1 : t.formData[u.value] = "";
126
+ }
127
+ });
128
+ const i = H({
129
+ get() {
130
+ let s = t.formData[u.value];
131
+ if (t.component.type === d.INPUT_NUMBER)
132
+ return De(s);
133
+ if (rt(s) && t.component.defaultValue !== void 0 && t.component.defaultValue !== null) {
134
+ const h = Xe(t.component);
135
+ if (h != null)
136
+ return h;
137
+ }
138
+ return s;
139
+ },
140
+ set(s) {
141
+ t.component.type === d.INPUT_NUMBER ? t.formData[u.value] = De(s) : t.component.type === d.CHECKBOX_GROUP ? t.formData[u.value] = Array.isArray(s) ? [...s] : [] : t.component.type === d.SWITCH ? t.formData[u.value] = s === !0 : t.formData[u.value] = s, r("update:value", u.value, t.formData[u.value]);
142
+ }
143
+ }), p = (s) => {
144
+ r("update:value", u.value, s);
145
+ };
146
+ return (s, h) => {
147
+ const b = O("FormField", !0), N = O("el-col"), D = O("el-row"), _ = O("el-input"), x = O("el-form-item"), I = O("el-input-number"), A = O("el-radio"), C = O("el-radio-group"), U = O("el-option"), le = O("el-select"), re = O("el-checkbox"), K = O("el-checkbox-group"), q = O("el-switch"), E = O("el-date-picker");
148
+ return m(), w("div", Dt, [
149
+ e.component.type === k(d).ROW ? (m(), w("div", St, [
150
+ f(D, {
151
+ gutter: e.component.props?.gutter || 20
152
+ }, {
153
+ default: y(() => [
154
+ (m(!0), w(B, null, z(e.component.props?.columns || [], (n, Q) => (m(), V(N, {
155
+ key: Q,
156
+ span: n.span || 12
157
+ }, {
158
+ default: y(() => [
159
+ o("div", Ut, [
160
+ (m(!0), w(B, null, z(e.component.children?.[Q] || [], (F, ee) => (m(), V(b, {
161
+ key: ee,
162
+ component: F,
163
+ "form-data": e.formData,
164
+ "form-rules": e.formRules,
165
+ readonly: e.readonly
166
+ }, null, 8, ["component", "form-data", "form-rules", "readonly"]))), 128))
167
+ ])
168
+ ]),
169
+ _: 2
170
+ }, 1032, ["span"]))), 128))
171
+ ]),
172
+ _: 1
173
+ }, 8, ["gutter"])
174
+ ])) : e.component.type === k(d).INPUT ? (m(), V(x, {
175
+ key: 1,
176
+ label: e.component.props?.label || "",
177
+ prop: k(Z)(e.component),
178
+ required: e.component.required
179
+ }, {
180
+ default: y(() => [
181
+ f(_, {
182
+ modelValue: i.value,
183
+ "onUpdate:modelValue": h[0] || (h[0] = (n) => i.value = n),
184
+ placeholder: e.component.props?.placeholder || "请输入文本",
185
+ style: { width: "100%" },
186
+ disabled: e.readonly,
187
+ onInput: p
188
+ }, null, 8, ["modelValue", "placeholder", "disabled"])
189
+ ]),
190
+ _: 1
191
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).TEXTAREA ? (m(), V(x, {
192
+ key: 2,
193
+ label: e.component.props?.label || "",
194
+ prop: k(Z)(e.component),
195
+ required: e.component.required
196
+ }, {
197
+ default: y(() => [
198
+ f(_, {
199
+ modelValue: i.value,
200
+ "onUpdate:modelValue": h[1] || (h[1] = (n) => i.value = n),
201
+ type: "textarea",
202
+ rows: e.component.props?.rows || 3,
203
+ placeholder: e.component.props?.placeholder || "请输入内容",
204
+ style: { width: "100%" },
205
+ disabled: e.readonly,
206
+ onInput: p
207
+ }, null, 8, ["modelValue", "rows", "placeholder", "disabled"])
208
+ ]),
209
+ _: 1
210
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).INPUT_NUMBER ? (m(), V(x, {
211
+ key: 3,
212
+ label: e.component.props?.label || "",
213
+ prop: k(Z)(e.component),
214
+ required: e.component.required
215
+ }, {
216
+ default: y(() => [
217
+ f(I, {
218
+ modelValue: i.value,
219
+ "onUpdate:modelValue": h[2] || (h[2] = (n) => i.value = n),
220
+ min: e.component.min || 1,
221
+ max: e.component.max || 100,
222
+ style: { width: "100%" },
223
+ disabled: e.readonly,
224
+ onChange: p
225
+ }, null, 8, ["modelValue", "min", "max", "disabled"])
226
+ ]),
227
+ _: 1
228
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).RADIO_GROUP ? (m(), V(x, {
229
+ key: 4,
230
+ label: e.component.props?.label || "",
231
+ prop: k(Z)(e.component),
232
+ required: e.component.required
233
+ }, {
234
+ default: y(() => [
235
+ f(C, {
236
+ modelValue: i.value,
237
+ "onUpdate:modelValue": h[3] || (h[3] = (n) => i.value = n),
238
+ style: { width: "100%" },
239
+ disabled: e.readonly,
240
+ onChange: p
241
+ }, {
242
+ default: y(() => [
243
+ (m(!0), w(B, null, z(e.component.props?.options || ["选项1", "选项2", "选项3"], (n) => (m(), V(A, {
244
+ key: n.value || n,
245
+ value: n.value || n
246
+ }, {
247
+ default: y(() => [
248
+ Y(ae(n.label || n), 1)
249
+ ]),
250
+ _: 2
251
+ }, 1032, ["value"]))), 128))
252
+ ]),
253
+ _: 1
254
+ }, 8, ["modelValue", "disabled"])
255
+ ]),
256
+ _: 1
257
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).SELECT ? (m(), V(x, {
258
+ key: 5,
259
+ label: e.component.props?.label || "",
260
+ prop: k(Z)(e.component),
261
+ required: e.component.required
262
+ }, {
263
+ default: y(() => [
264
+ f(le, {
265
+ modelValue: i.value,
266
+ "onUpdate:modelValue": h[4] || (h[4] = (n) => i.value = n),
267
+ placeholder: e.component.props?.placeholder || "请选择",
268
+ style: { width: "100%" },
269
+ disabled: e.readonly,
270
+ onChange: p
271
+ }, {
272
+ default: y(() => [
273
+ (m(!0), w(B, null, z(e.component.props?.options || [], (n) => (m(), V(U, {
274
+ key: n.value || n,
275
+ label: n.label || n,
276
+ value: n.value || n
277
+ }, null, 8, ["label", "value"]))), 128))
278
+ ]),
279
+ _: 1
280
+ }, 8, ["modelValue", "placeholder", "disabled"])
281
+ ]),
282
+ _: 1
283
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).CHECKBOX_GROUP ? (m(), V(x, {
284
+ key: 6,
285
+ label: e.component.props?.label || "",
286
+ prop: k(Z)(e.component),
287
+ required: e.component.required
288
+ }, {
289
+ default: y(() => [
290
+ f(K, {
291
+ modelValue: i.value,
292
+ "onUpdate:modelValue": h[5] || (h[5] = (n) => i.value = n),
293
+ style: { width: "100%" },
294
+ disabled: e.readonly,
295
+ onChange: p
296
+ }, {
297
+ default: y(() => [
298
+ (m(!0), w(B, null, z(e.component.props?.options || [], (n) => (m(), V(re, {
299
+ key: n.value || n,
300
+ value: n.value || n
301
+ }, {
302
+ default: y(() => [
303
+ Y(ae(n.label || n), 1)
304
+ ]),
305
+ _: 2
306
+ }, 1032, ["value"]))), 128))
307
+ ]),
308
+ _: 1
309
+ }, 8, ["modelValue", "disabled"])
310
+ ]),
311
+ _: 1
312
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).SWITCH ? (m(), V(x, {
313
+ key: 7,
314
+ label: e.component.props?.label || "",
315
+ prop: k(Z)(e.component),
316
+ required: e.component.required
317
+ }, {
318
+ default: y(() => [
319
+ f(q, {
320
+ modelValue: i.value,
321
+ "onUpdate:modelValue": h[6] || (h[6] = (n) => i.value = n),
322
+ "active-text": e.component.props?.activeText || "",
323
+ "inactive-text": e.component.props?.inactiveText || "",
324
+ disabled: e.readonly,
325
+ onChange: p
326
+ }, null, 8, ["modelValue", "active-text", "inactive-text", "disabled"])
327
+ ]),
328
+ _: 1
329
+ }, 8, ["label", "prop", "required"])) : e.component.type === k(d).DATE_PICKER ? (m(), V(x, {
330
+ key: 8,
331
+ label: e.component.props?.label || "",
332
+ prop: k(Z)(e.component),
333
+ required: e.component.required
334
+ }, {
335
+ default: y(() => [
336
+ f(E, {
337
+ modelValue: i.value,
338
+ "onUpdate:modelValue": h[7] || (h[7] = (n) => i.value = n),
339
+ type: "date",
340
+ placeholder: e.component.props?.placeholder || "选择日期",
341
+ style: { width: "100%" },
342
+ disabled: e.readonly,
343
+ onChange: p
344
+ }, null, 8, ["modelValue", "placeholder", "disabled"])
345
+ ]),
346
+ _: 1
347
+ }, 8, ["label", "prop", "required"])) : j("", !0)
348
+ ]);
349
+ };
350
+ }
351
+ }), it = /* @__PURE__ */ st($t, [["__scopeId", "data-v-63b4f62f"]]), Pt = {
352
+ key: 0,
353
+ class: "_fd-draggable-drag _fd-drag-box gb-fc-row-box"
354
+ }, Lt = ["onDragover", "onDrop"], Mt = { class: "gb-fc-tools" }, Ft = ["title"], Bt = /* @__PURE__ */ Object.assign({ name: "FcCanvasField" }, {
355
+ __name: "FcCanvasField",
356
+ props: {
357
+ component: { type: Object, required: !0 },
358
+ path: { type: Array, required: !0 },
359
+ formData: { type: Object, required: !0 },
360
+ formRules: { type: Object, required: !0 },
361
+ activeId: { type: String, default: "" },
362
+ depth: { type: Number, default: 0 }
363
+ },
364
+ setup(e) {
365
+ const l = e, t = qe("fcCanvasOps"), r = qe("fcDragOver"), u = H(() => l.component.type === d.ROW), i = H(() => l.component.props?.columns?.length || 2);
366
+ H(
367
+ () => (l.component.children || []).every((A) => !A || A.length === 0)
368
+ );
369
+ const p = {
370
+ kind: "existing",
371
+ path: l.path
372
+ }, s = (A) => {
373
+ A.dataTransfer.effectAllowed = "move", A.dataTransfer.setData("application/x-gb-field", JSON.stringify(p)), A.dataTransfer.setData("text/plain", "gb-field"), t.startDrag(l.path);
374
+ }, h = () => {
375
+ t.endDrag();
376
+ }, b = (A) => {
377
+ A.preventDefault();
378
+ const C = A.currentTarget.getBoundingClientRect(), U = A.clientY - C.top < C.height / 2 ? "top" : "bottom";
379
+ r.value = l.path.join(".") + ":" + U, A.dataTransfer.dropEffect = "move";
380
+ }, N = () => {
381
+ r.value?.startsWith(l.path.join(".")) && (r.value = "");
382
+ }, D = (A) => {
383
+ A.preventDefault(), A.stopPropagation();
384
+ const C = r.value?.endsWith(":top") ? "top" : "bottom", U = I(A);
385
+ r.value = "", U && t.dropAt(U, { path: l.path, position: C });
386
+ }, _ = (A) => {
387
+ r.value = l.path.join(".") + ":col" + A;
388
+ }, x = (A, C) => {
389
+ const U = I(C);
390
+ r.value = "", U && t.dropAt(U, { path: l.path, column: A });
391
+ }, I = (A) => {
392
+ const C = A?.dataTransfer?.getData("application/x-gb-field");
393
+ if (C)
394
+ try {
395
+ return JSON.parse(C);
396
+ } catch {
397
+ return null;
398
+ }
399
+ return t.getDragPayload();
400
+ };
401
+ return (A, C) => {
402
+ const U = O("FcCanvasField", !0), le = O("el-col"), re = O("el-row");
403
+ return m(), w("div", {
404
+ class: $(["_fc-draggable-item _fd-drag-item gb-fc-item", {
405
+ "is-active": e.activeId === e.component.id,
406
+ "is-hidden": e.component.hidden,
407
+ "drag-over-top": k(r) === e.path.join(".") + ":top",
408
+ "drag-over-bottom": k(r) === e.path.join(".") + ":bottom"
409
+ }]),
410
+ onDragover: X(b, ["prevent"]),
411
+ onDragenter: C[3] || (C[3] = X(() => {
412
+ }, ["prevent"])),
413
+ onDragleave: N,
414
+ onDrop: X(D, ["stop", "prevent"])
415
+ }, [
416
+ u.value ? (m(), w("div", Pt, [
417
+ f(re, {
418
+ gutter: e.component.props?.gutter || 20
419
+ }, {
420
+ default: y(() => [
421
+ (m(!0), w(B, null, z(i.value, (K, q) => (m(), V(le, {
422
+ key: q,
423
+ span: e.component.props?.columns?.[q]?.span || 12
424
+ }, {
425
+ default: y(() => [
426
+ o("div", {
427
+ class: $(["gb-fc-column", {
428
+ "_fc-child-empty": !(e.component.children?.[q] || []).length,
429
+ "has-child": (e.component.children?.[q] || []).length
430
+ }]),
431
+ onDragover: X((E) => _(q), ["prevent", "stop"]),
432
+ onDrop: X((E) => x(q, E), ["stop", "prevent"])
433
+ }, [
434
+ (m(!0), w(B, null, z(e.component.children?.[q] || [], (E, n) => (m(), V(U, {
435
+ key: E.id || n,
436
+ component: E,
437
+ path: [...e.path, "children", q, n],
438
+ "form-data": e.formData,
439
+ "form-rules": e.formRules,
440
+ "active-id": e.activeId,
441
+ depth: e.depth + 1
442
+ }, null, 8, ["component", "path", "form-data", "form-rules", "active-id", "depth"]))), 128))
443
+ ], 42, Lt)
444
+ ]),
445
+ _: 2
446
+ }, 1032, ["span"]))), 128))
447
+ ]),
448
+ _: 1
449
+ }, 8, ["gutter"])
450
+ ])) : (m(), V(it, {
451
+ key: 1,
452
+ component: e.component,
453
+ "form-data": e.formData,
454
+ "form-rules": e.formRules,
455
+ readonly: !0
456
+ }, null, 8, ["component", "form-data", "form-rules"])),
457
+ o("div", {
458
+ class: "gb-fc-mask",
459
+ onClick: C[2] || (C[2] = X((K) => k(t).active(e.component, e.path), ["stop"]))
460
+ }, [
461
+ o("div", Mt, [
462
+ o("i", {
463
+ class: "gb-fc-tool gb-fc-tool--handle",
464
+ title: "拖拽" + (e.component.props?.label || e.component.type),
465
+ draggable: "true",
466
+ onDragstart: X(s, ["stop"]),
467
+ onDragend: h
468
+ }, [...C[4] || (C[4] = [
469
+ o("svg", {
470
+ viewBox: "0 0 1024 1024",
471
+ width: "14",
472
+ height: "14"
473
+ }, [
474
+ o("path", {
475
+ fill: "currentColor",
476
+ d: "M469.3 256a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zm0 170.7a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zm0 170.6a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zm0 170.7a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zM661.3 256a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zm0 170.7a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zm0 170.6a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0zm0 170.7a53.3 53.3 0 1 1-106.6 0 53.3 53.3 0 0 1 106.6 0z"
477
+ })
478
+ ], -1)
479
+ ])], 40, Ft),
480
+ o("i", {
481
+ class: "gb-fc-tool",
482
+ title: "复制",
483
+ onClick: C[0] || (C[0] = X((K) => k(t).copy(e.path), ["stop"]))
484
+ }, [...C[5] || (C[5] = [
485
+ o("svg", {
486
+ viewBox: "0 0 1024 1024",
487
+ width: "14",
488
+ height: "14"
489
+ }, [
490
+ o("path", {
491
+ fill: "currentColor",
492
+ d: "M768 832v-576H320v576h448zM320 192h448a64 64 0 0 1 64 64v576a64 64 0 0 1-64 64H320a64 64 0 0 1-64-64V256a64 64 0 0 1 64-64zm-128 64v640h64v64h-64a64 64 0 0 1-64-64V256h64z"
493
+ })
494
+ ], -1)
495
+ ])]),
496
+ o("i", {
497
+ class: "gb-fc-tool gb-fc-tool--danger",
498
+ title: "删除",
499
+ onClick: C[1] || (C[1] = X((K) => k(t).remove(e.path), ["stop"]))
500
+ }, [...C[6] || (C[6] = [
501
+ o("svg", {
502
+ viewBox: "0 0 1024 1024",
503
+ width: "14",
504
+ height: "14"
505
+ }, [
506
+ o("path", {
507
+ fill: "currentColor",
508
+ d: "M512 455.1L761 206a15 15 0 0 1 21.2 0l35.8 35.8a15 15 0 0 1 0 21.2L569 512l249 249a15 15 0 0 1 0 21.2l-35.8 35.8a15 15 0 0 1-21.2 0L512 569l-249 249a15 15 0 0 1-21.2 0l-35.8-35.8a15 15 0 0 1 0-21.2L455 512 206 263a15 15 0 0 1 0-21.2l35.8-35.8a15 15 0 0 1 21.2 0z"
509
+ })
510
+ ], -1)
511
+ ])])
512
+ ])
513
+ ])
514
+ ], 34);
515
+ };
516
+ }
517
+ }), Gt = {
518
+ class: "_fd-config-item",
519
+ style: { "margin-top": "12px" }
520
+ }, zt = { class: "_fd-ci-head" }, jt = { class: "_fd-ci-con" }, Ht = { class: "_fc-r-config" }, Wt = { style: { "grid-area": "base" } }, qt = {
521
+ key: 0,
522
+ class: "_fd-config-item"
523
+ }, Jt = { class: "_fd-ci-head" }, Yt = { class: "_fd-ci-con" }, Kt = {
524
+ key: 1,
525
+ class: "_fd-config-item"
526
+ }, Qt = { class: "_fd-ci-head" }, Xt = { class: "_fd-ci-con" }, Zt = {
527
+ key: 0,
528
+ style: { display: "flex", "justify-content": "flex-end", "margin-top": "6px" }
529
+ }, el = {
530
+ key: 2,
531
+ class: "_fd-config-item"
532
+ }, tl = { class: "_fd-ci-head" }, ll = { class: "_fd-ci-con" }, nl = { style: { "grid-area": "props" } }, ol = {
533
+ key: 0,
534
+ class: "_fd-config-item"
535
+ }, al = { class: "_fd-ci-head" }, rl = { class: "_fd-ci-con" }, sl = { class: "_fd-config-item" }, il = { class: "_fd-ci-head" }, ul = { class: "_fd-ci-con" }, dl = { class: "_fd-config-item" }, cl = { class: "_fd-ci-head" }, pl = { class: "_fd-ci-con" }, ml = {
536
+ key: 2,
537
+ class: "_fd-config-item"
538
+ }, fl = {
539
+ class: "_fd-ci-append",
540
+ style: { display: "block" }
541
+ }, vl = { class: "_fd-config-item" }, yl = { class: "_fd-ci-head" }, hl = { class: "_fd-ci-con" }, bl = { class: "_fd-config-item" }, gl = {
542
+ class: "_fd-ci-append",
543
+ style: { display: "block" }
544
+ }, Tl = { style: { "font-size": "12px", color: "#666", width: "60px" } }, El = { class: "_fc-r-config" }, Ol = { style: { "grid-area": "base" } }, Nl = { class: "_fd-config-item" }, Al = { class: "_fd-ci-head" }, wl = { class: "_fd-ci-con" }, _l = { class: "_fd-config-item" }, Rl = { class: "_fd-ci-head" }, Cl = { class: "_fd-ci-con" }, Vl = { class: "_fd-config-item" }, xl = { class: "_fd-ci-head" }, kl = { class: "_fd-ci-con" }, Il = { class: "_fd-config-item" }, Dl = { class: "_fd-ci-head" }, Sl = { class: "_fd-ci-con" }, Ul = /* @__PURE__ */ Object.assign({ name: "FcPropsPanel" }, {
545
+ __name: "FcPropsPanel",
546
+ props: {
547
+ component: { type: Object, default: null },
548
+ formOptions: { type: Object, required: !0 }
549
+ },
550
+ emits: ["close"],
551
+ setup(e, { emit: l }) {
552
+ const t = e, r = P("props"), u = H(() => t.component?.type === d.ROW), i = H(() => Ke.includes(t.component?.type)), p = H(() => t.component?.props ? (Array.isArray(t.component.props.options) || (t.component.props.options = []), t.component.props.options) : []), s = Object.entries(xt).filter(([E]) => E !== d.BUTTON).map(([E, n]) => ({ value: E, label: n })), h = H({
553
+ get: () => t.component?.type,
554
+ set: (E) => {
555
+ !E || !t.component || (t.component.type = E, t.component.props || (t.component.props = {}), Ke.includes(E) && !t.component.props.options?.length && (t.component.props.options = [
556
+ { label: "选项1", value: "1" },
557
+ { label: "选项2", value: "2" }
558
+ ]), E === d.ROW && (t.component.props.columns || (t.component.props.columns = [{ span: 12 }, { span: 12 }]), t.component.children || (t.component.children = [[], []]), t.component.props.gutter = t.component.props.gutter || 20, at(t.component)));
559
+ }
560
+ }), b = P("100%"), N = P(100), D = () => {
561
+ const E = t.component?.style?.width, n = ["100%", "50%", "33.33%", "25%"];
562
+ if (!E) {
563
+ b.value = "100%";
564
+ return;
565
+ }
566
+ b.value = n.includes(E) ? E : "custom", b.value === "custom" && (N.value = It(E));
567
+ };
568
+ D(), Re(() => t.component?.id, D);
569
+ const _ = (E) => {
570
+ t.component && (t.component.style || (t.component.style = {}), E === "custom" ? t.component.style.width = `${N.value}%` : t.component.style.width = E);
571
+ }, x = (E) => {
572
+ t.component && (t.component.style || (t.component.style = {}), t.component.style.width = `${E}%`);
573
+ }, I = (E) => typeof E == "string" ? E : E.label, A = (E) => typeof E == "string" ? E : E.value, C = () => {
574
+ p.value.push({ label: `选项${p.value.length + 1}`, value: `${p.value.length + 1}` });
575
+ }, U = (E) => {
576
+ p.value.splice(E, 1);
577
+ }, le = () => {
578
+ const E = t.component.props.columns;
579
+ E.push({ span: Math.max(1, Math.round(24 / (E.length + 1))) }), t.component.children || (t.component.children = []), t.component.children.push([]);
580
+ }, re = (E) => {
581
+ t.component.props.columns.splice(E, 1), t.component.children?.splice(E, 1);
582
+ }, K = async () => {
583
+ const E = t.component?.props?.variableName;
584
+ if (E)
585
+ try {
586
+ await navigator.clipboard.writeText(E), oe.success("字段名已复制");
587
+ } catch {
588
+ oe.warning("复制失败");
589
+ }
590
+ }, q = () => {
591
+ t.component && (t.component.props.variableName = `field_${Oe().split("_").pop()}`);
592
+ };
593
+ return (E, n) => {
594
+ const Q = O("el-header"), F = O("el-option"), ee = O("el-select"), ne = O("el-input"), me = O("el-switch"), fe = O("el-divider"), se = O("el-input-number"), ce = O("el-button"), be = O("el-main"), Ae = O("el-container");
595
+ return m(), V(Ae, { style: { height: "100%" } }, {
596
+ default: y(() => [
597
+ f(Q, {
598
+ height: "40px",
599
+ class: "_fc-r-tabs"
600
+ }, {
601
+ default: y(() => [
602
+ e.component ? (m(), w("div", {
603
+ key: 0,
604
+ class: $(["_fc-r-tab", { active: r.value === "props" }]),
605
+ onClick: n[0] || (n[0] = (v) => r.value = "props")
606
+ }, " 组件 ", 2)) : j("", !0),
607
+ o("div", {
608
+ class: $(["_fc-r-tab", { active: r.value === "form" || !e.component }]),
609
+ onClick: n[1] || (n[1] = (v) => r.value = "form")
610
+ }, " 表单 ", 2)
611
+ ]),
612
+ _: 1
613
+ }),
614
+ r.value === "props" && e.component ? (m(), V(be, {
615
+ key: 0,
616
+ class: "_fc-r-tab-props"
617
+ }, {
618
+ default: y(() => [
619
+ o("div", {
620
+ class: "_fc-r-tools-close",
621
+ onClick: n[2] || (n[2] = (v) => E.$emit("close"))
622
+ }, [...n[23] || (n[23] = [
623
+ o("i", { class: "fc-icon icon-add2" }, null, -1)
624
+ ])]),
625
+ n[38] || (n[38] = o("p", { class: "_fc-r-title" }, "组件类型", -1)),
626
+ f(ee, {
627
+ modelValue: h.value,
628
+ "onUpdate:modelValue": n[3] || (n[3] = (v) => h.value = v),
629
+ style: { width: "100%" }
630
+ }, {
631
+ default: y(() => [
632
+ (m(!0), w(B, null, z(k(s), (v) => (m(), V(F, {
633
+ key: v.value,
634
+ label: v.label,
635
+ value: v.value
636
+ }, null, 8, ["label", "value"]))), 128))
637
+ ]),
638
+ _: 1
639
+ }, 8, ["modelValue"]),
640
+ n[39] || (n[39] = o("p", { class: "_fc-r-title" }, "字段名", -1)),
641
+ f(ne, {
642
+ modelValue: e.component.props.variableName,
643
+ "onUpdate:modelValue": n[4] || (n[4] = (v) => e.component.props.variableName = v),
644
+ class: "_fc-r-name-input"
645
+ }, {
646
+ suffix: y(() => [
647
+ o("i", {
648
+ class: "fc-icon icon-group",
649
+ title: "复制字段名",
650
+ onClick: K
651
+ })
652
+ ]),
653
+ append: y(() => [
654
+ o("i", {
655
+ class: "fc-icon icon-auto",
656
+ title: "根据标题生成",
657
+ onClick: q
658
+ })
659
+ ]),
660
+ _: 1
661
+ }, 8, ["modelValue"]),
662
+ o("div", Gt, [
663
+ o("div", zt, [
664
+ n[24] || (n[24] = o("div", { class: "_fd-ci-label" }, "隐藏", -1)),
665
+ o("div", jt, [
666
+ f(me, {
667
+ modelValue: e.component.hidden,
668
+ "onUpdate:modelValue": n[5] || (n[5] = (v) => e.component.hidden = v),
669
+ size: "small"
670
+ }, null, 8, ["modelValue"])
671
+ ])
672
+ ])
673
+ ]),
674
+ o("div", Ht, [
675
+ o("div", Wt, [
676
+ f(fe, null, {
677
+ default: y(() => [...n[25] || (n[25] = [
678
+ Y("规则", -1)
679
+ ])]),
680
+ _: 1
681
+ }),
682
+ u.value ? j("", !0) : (m(), w("div", qt, [
683
+ o("div", Jt, [
684
+ n[26] || (n[26] = o("div", { class: "_fd-ci-label" }, [
685
+ o("span", null, "必填")
686
+ ], -1)),
687
+ o("div", Yt, [
688
+ f(me, {
689
+ modelValue: e.component.required,
690
+ "onUpdate:modelValue": n[6] || (n[6] = (v) => e.component.required = v),
691
+ size: "small"
692
+ }, null, 8, ["modelValue"])
693
+ ])
694
+ ])
695
+ ])),
696
+ u.value ? j("", !0) : (m(), w("div", Kt, [
697
+ o("div", Qt, [
698
+ n[27] || (n[27] = o("div", { class: "_fd-ci-label" }, [
699
+ o("span", null, "字段宽度")
700
+ ], -1)),
701
+ o("div", Xt, [
702
+ f(ee, {
703
+ modelValue: b.value,
704
+ "onUpdate:modelValue": n[7] || (n[7] = (v) => b.value = v),
705
+ size: "small",
706
+ style: { width: "120px" },
707
+ onChange: _
708
+ }, {
709
+ default: y(() => [
710
+ f(F, {
711
+ label: "整行",
712
+ value: "100%"
713
+ }),
714
+ f(F, {
715
+ label: "1/2",
716
+ value: "50%"
717
+ }),
718
+ f(F, {
719
+ label: "1/3",
720
+ value: "33.33%"
721
+ }),
722
+ f(F, {
723
+ label: "1/4",
724
+ value: "25%"
725
+ }),
726
+ f(F, {
727
+ label: "自定义",
728
+ value: "custom"
729
+ })
730
+ ]),
731
+ _: 1
732
+ }, 8, ["modelValue"])
733
+ ])
734
+ ]),
735
+ b.value === "custom" ? (m(), w("div", Zt, [
736
+ f(se, {
737
+ modelValue: N.value,
738
+ "onUpdate:modelValue": n[8] || (n[8] = (v) => N.value = v),
739
+ min: 10,
740
+ max: 100,
741
+ step: 5,
742
+ size: "small",
743
+ onChange: x
744
+ }, null, 8, ["modelValue"])
745
+ ])) : j("", !0)
746
+ ])),
747
+ u.value ? j("", !0) : (m(), w("div", el, [
748
+ o("div", tl, [
749
+ n[28] || (n[28] = o("div", { class: "_fd-ci-label" }, [
750
+ o("span", null, "默认值")
751
+ ], -1)),
752
+ o("div", ll, [
753
+ ["radio-group", "select"].includes(e.component.type) ? (m(), V(ee, {
754
+ key: 0,
755
+ modelValue: e.component.defaultValue,
756
+ "onUpdate:modelValue": n[9] || (n[9] = (v) => e.component.defaultValue = v),
757
+ size: "small",
758
+ clearable: "",
759
+ style: { width: "180px" }
760
+ }, {
761
+ default: y(() => [
762
+ (m(!0), w(B, null, z(p.value, (v) => (m(), V(F, {
763
+ key: A(v),
764
+ label: I(v),
765
+ value: A(v)
766
+ }, null, 8, ["label", "value"]))), 128))
767
+ ]),
768
+ _: 1
769
+ }, 8, ["modelValue"])) : e.component.type === "checkbox-group" ? (m(), V(ee, {
770
+ key: 1,
771
+ modelValue: e.component.defaultValue,
772
+ "onUpdate:modelValue": n[10] || (n[10] = (v) => e.component.defaultValue = v),
773
+ size: "small",
774
+ multiple: "",
775
+ clearable: "",
776
+ style: { width: "180px" }
777
+ }, {
778
+ default: y(() => [
779
+ (m(!0), w(B, null, z(p.value, (v) => (m(), V(F, {
780
+ key: A(v),
781
+ label: I(v),
782
+ value: A(v)
783
+ }, null, 8, ["label", "value"]))), 128))
784
+ ]),
785
+ _: 1
786
+ }, 8, ["modelValue"])) : e.component.type === "switch" ? (m(), V(me, {
787
+ key: 2,
788
+ modelValue: e.component.defaultValue,
789
+ "onUpdate:modelValue": n[11] || (n[11] = (v) => e.component.defaultValue = v),
790
+ size: "small"
791
+ }, null, 8, ["modelValue"])) : e.component.type === "date-picker" ? (m(), V(ee, {
792
+ key: 3,
793
+ modelValue: e.component.defaultValue,
794
+ "onUpdate:modelValue": n[12] || (n[12] = (v) => e.component.defaultValue = v),
795
+ size: "small",
796
+ clearable: "",
797
+ style: { width: "120px" }
798
+ }, {
799
+ default: y(() => [
800
+ f(F, {
801
+ label: "今天",
802
+ value: "today"
803
+ }),
804
+ f(F, {
805
+ label: "明天",
806
+ value: "tomorrow"
807
+ }),
808
+ f(F, {
809
+ label: "无",
810
+ value: ""
811
+ })
812
+ ]),
813
+ _: 1
814
+ }, 8, ["modelValue"])) : e.component.type === "input-number" ? (m(), V(se, {
815
+ key: 4,
816
+ modelValue: e.component.defaultValue,
817
+ "onUpdate:modelValue": n[13] || (n[13] = (v) => e.component.defaultValue = v),
818
+ size: "small",
819
+ style: { width: "140px" }
820
+ }, null, 8, ["modelValue"])) : (m(), V(ne, {
821
+ key: 5,
822
+ modelValue: e.component.defaultValue,
823
+ "onUpdate:modelValue": n[14] || (n[14] = (v) => e.component.defaultValue = v),
824
+ size: "small",
825
+ style: { width: "180px" }
826
+ }, null, 8, ["modelValue"]))
827
+ ])
828
+ ])
829
+ ]))
830
+ ]),
831
+ o("div", nl, [
832
+ f(fe, null, {
833
+ default: y(() => [...n[29] || (n[29] = [
834
+ Y("属性", -1)
835
+ ])]),
836
+ _: 1
837
+ }),
838
+ ["input", "textarea", "select"].includes(e.component.type) ? (m(), w("div", ol, [
839
+ o("div", al, [
840
+ n[30] || (n[30] = o("div", { class: "_fd-ci-label" }, [
841
+ o("span", null, "提示文字")
842
+ ], -1)),
843
+ o("div", rl, [
844
+ f(ne, {
845
+ modelValue: e.component.props.placeholder,
846
+ "onUpdate:modelValue": n[15] || (n[15] = (v) => e.component.props.placeholder = v),
847
+ size: "small",
848
+ style: { width: "180px" }
849
+ }, null, 8, ["modelValue"])
850
+ ])
851
+ ])
852
+ ])) : j("", !0),
853
+ e.component.type === "input-number" ? (m(), w(B, { key: 1 }, [
854
+ o("div", sl, [
855
+ o("div", il, [
856
+ n[31] || (n[31] = o("div", { class: "_fd-ci-label" }, [
857
+ o("span", null, "最小值")
858
+ ], -1)),
859
+ o("div", ul, [
860
+ f(se, {
861
+ modelValue: e.component.min,
862
+ "onUpdate:modelValue": n[16] || (n[16] = (v) => e.component.min = v),
863
+ size: "small",
864
+ style: { width: "140px" }
865
+ }, null, 8, ["modelValue"])
866
+ ])
867
+ ])
868
+ ]),
869
+ o("div", dl, [
870
+ o("div", cl, [
871
+ n[32] || (n[32] = o("div", { class: "_fd-ci-label" }, [
872
+ o("span", null, "最大值")
873
+ ], -1)),
874
+ o("div", pl, [
875
+ f(se, {
876
+ modelValue: e.component.max,
877
+ "onUpdate:modelValue": n[17] || (n[17] = (v) => e.component.max = v),
878
+ size: "small",
879
+ style: { width: "140px" }
880
+ }, null, 8, ["modelValue"])
881
+ ])
882
+ ])
883
+ ])
884
+ ], 64)) : j("", !0),
885
+ i.value ? (m(), w("div", ml, [
886
+ n[34] || (n[34] = o("div", { class: "_fd-ci-head" }, [
887
+ o("div", { class: "_fd-ci-label" }, [
888
+ o("span", null, "选项配置")
889
+ ])
890
+ ], -1)),
891
+ o("div", fl, [
892
+ (m(!0), w(B, null, z(p.value, (v, ue) => (m(), w("div", {
893
+ key: ue,
894
+ class: "gb-fc-option"
895
+ }, [
896
+ f(ne, {
897
+ modelValue: v.label,
898
+ "onUpdate:modelValue": (ie) => v.label = ie,
899
+ size: "small",
900
+ placeholder: "选项名称"
901
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
902
+ f(ne, {
903
+ modelValue: v.value,
904
+ "onUpdate:modelValue": (ie) => v.value = ie,
905
+ size: "small",
906
+ placeholder: "选项值"
907
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
908
+ f(ce, {
909
+ type: "danger",
910
+ plain: "",
911
+ size: "small",
912
+ icon: k(Je),
913
+ onClick: (ie) => U(ue)
914
+ }, null, 8, ["icon", "onClick"])
915
+ ]))), 128)),
916
+ f(ce, {
917
+ type: "primary",
918
+ plain: "",
919
+ size: "small",
920
+ icon: k(Ye),
921
+ style: { width: "100%" },
922
+ onClick: C
923
+ }, {
924
+ default: y(() => [...n[33] || (n[33] = [
925
+ Y(" 添加选项 ", -1)
926
+ ])]),
927
+ _: 1
928
+ }, 8, ["icon"])
929
+ ])
930
+ ])) : j("", !0),
931
+ u.value ? (m(), w(B, { key: 3 }, [
932
+ o("div", vl, [
933
+ o("div", yl, [
934
+ n[35] || (n[35] = o("div", { class: "_fd-ci-label" }, [
935
+ o("span", null, "列间距")
936
+ ], -1)),
937
+ o("div", hl, [
938
+ f(se, {
939
+ modelValue: e.component.props.gutter,
940
+ "onUpdate:modelValue": n[18] || (n[18] = (v) => e.component.props.gutter = v),
941
+ min: 0,
942
+ max: 100,
943
+ size: "small",
944
+ style: { width: "140px" }
945
+ }, null, 8, ["modelValue"])
946
+ ])
947
+ ])
948
+ ]),
949
+ o("div", bl, [
950
+ n[37] || (n[37] = o("div", { class: "_fd-ci-head" }, [
951
+ o("div", { class: "_fd-ci-label" }, [
952
+ o("span", null, "列配置")
953
+ ])
954
+ ], -1)),
955
+ o("div", gl, [
956
+ (m(!0), w(B, null, z(e.component.props.columns, (v, ue) => (m(), w("div", {
957
+ key: ue,
958
+ class: "gb-fc-option"
959
+ }, [
960
+ o("span", Tl, "第" + ae(ue + 1) + "列", 1),
961
+ f(se, {
962
+ modelValue: v.span,
963
+ "onUpdate:modelValue": (ie) => v.span = ie,
964
+ min: 1,
965
+ max: 24,
966
+ size: "small"
967
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
968
+ f(ce, {
969
+ type: "danger",
970
+ plain: "",
971
+ size: "small",
972
+ icon: k(Je),
973
+ disabled: (e.component.props.columns || []).length <= 1,
974
+ onClick: (ie) => re(ue)
975
+ }, null, 8, ["icon", "disabled", "onClick"])
976
+ ]))), 128)),
977
+ f(ce, {
978
+ type: "primary",
979
+ plain: "",
980
+ size: "small",
981
+ icon: k(Ye),
982
+ style: { width: "100%" },
983
+ onClick: le
984
+ }, {
985
+ default: y(() => [...n[36] || (n[36] = [
986
+ Y(" 添加列 ", -1)
987
+ ])]),
988
+ _: 1
989
+ }, 8, ["icon"])
990
+ ])
991
+ ])
992
+ ], 64)) : j("", !0)
993
+ ])
994
+ ])
995
+ ]),
996
+ _: 1
997
+ })) : j("", !0),
998
+ pe(f(be, { class: "_fc-r-tab-form" }, {
999
+ default: y(() => [
1000
+ o("div", El, [
1001
+ o("div", Ol, [
1002
+ f(fe, null, {
1003
+ default: y(() => [...n[40] || (n[40] = [
1004
+ Y("表单配置", -1)
1005
+ ])]),
1006
+ _: 1
1007
+ }),
1008
+ o("div", Nl, [
1009
+ o("div", Al, [
1010
+ n[41] || (n[41] = o("div", { class: "_fd-ci-label" }, [
1011
+ o("span", null, "表单名称")
1012
+ ], -1)),
1013
+ o("div", wl, [
1014
+ f(ne, {
1015
+ modelValue: e.formOptions.name,
1016
+ "onUpdate:modelValue": n[19] || (n[19] = (v) => e.formOptions.name = v),
1017
+ size: "small",
1018
+ style: { width: "180px" }
1019
+ }, null, 8, ["modelValue"])
1020
+ ])
1021
+ ])
1022
+ ]),
1023
+ o("div", _l, [
1024
+ o("div", Rl, [
1025
+ n[42] || (n[42] = o("div", { class: "_fd-ci-label" }, [
1026
+ o("span", null, "表单描述")
1027
+ ], -1)),
1028
+ o("div", Cl, [
1029
+ f(ne, {
1030
+ modelValue: e.formOptions.description,
1031
+ "onUpdate:modelValue": n[20] || (n[20] = (v) => e.formOptions.description = v),
1032
+ size: "small",
1033
+ style: { width: "180px" }
1034
+ }, null, 8, ["modelValue"])
1035
+ ])
1036
+ ])
1037
+ ]),
1038
+ o("div", Vl, [
1039
+ o("div", xl, [
1040
+ n[43] || (n[43] = o("div", { class: "_fd-ci-label" }, [
1041
+ o("span", null, "标签宽度")
1042
+ ], -1)),
1043
+ o("div", kl, [
1044
+ f(ne, {
1045
+ modelValue: e.formOptions.labelWidth,
1046
+ "onUpdate:modelValue": n[21] || (n[21] = (v) => e.formOptions.labelWidth = v),
1047
+ size: "small",
1048
+ style: { width: "120px" }
1049
+ }, null, 8, ["modelValue"])
1050
+ ])
1051
+ ])
1052
+ ]),
1053
+ o("div", Il, [
1054
+ o("div", Dl, [
1055
+ n[44] || (n[44] = o("div", { class: "_fd-ci-label" }, [
1056
+ o("span", null, "组件尺寸")
1057
+ ], -1)),
1058
+ o("div", Sl, [
1059
+ f(ee, {
1060
+ modelValue: e.formOptions.size,
1061
+ "onUpdate:modelValue": n[22] || (n[22] = (v) => e.formOptions.size = v),
1062
+ size: "small",
1063
+ style: { width: "120px" }
1064
+ }, {
1065
+ default: y(() => [
1066
+ f(F, {
1067
+ label: "较大",
1068
+ value: "large"
1069
+ }),
1070
+ f(F, {
1071
+ label: "默认",
1072
+ value: "default"
1073
+ }),
1074
+ f(F, {
1075
+ label: "较小",
1076
+ value: "small"
1077
+ })
1078
+ ]),
1079
+ _: 1
1080
+ }, 8, ["modelValue"])
1081
+ ])
1082
+ ])
1083
+ ])
1084
+ ])
1085
+ ])
1086
+ ]),
1087
+ _: 1
1088
+ }, 512), [
1089
+ [he, r.value === "form" || !e.component]
1090
+ ])
1091
+ ]),
1092
+ _: 1
1093
+ });
1094
+ };
1095
+ }
1096
+ }), $l = { class: "_fc-json-preview-down" }, Pl = {
1097
+ key: 0,
1098
+ class: "gb-fc-json-error"
1099
+ }, Ll = /* @__PURE__ */ Object.assign({ name: "FcJsonPanel" }, {
1100
+ __name: "FcJsonPanel",
1101
+ props: {
1102
+ components: { type: Array, required: !0 },
1103
+ formOptions: { type: Object, required: !0 },
1104
+ fileName: { type: String, default: "form" }
1105
+ },
1106
+ emits: ["update:components", "update:formOptions"],
1107
+ setup(e, { expose: l, emit: t }) {
1108
+ const r = e, u = t, i = P("rule"), p = P(JSON.stringify(r.components, null, 2)), s = P("");
1109
+ let h = "";
1110
+ const b = () => i.value === "rule" ? JSON.stringify(r.components, null, 2) : JSON.stringify(r.formOptions, null, 2), N = (I) => {
1111
+ i.value = I, p.value = b(), s.value = "";
1112
+ }, D = () => {
1113
+ h = b();
1114
+ }, _ = () => {
1115
+ if (s.value = "", p.value.trim() !== h.trim())
1116
+ try {
1117
+ const I = JSON.parse(p.value);
1118
+ if (i.value === "rule") {
1119
+ if (!Array.isArray(I)) throw new Error("表单规则必须是数组");
1120
+ u("update:components", I);
1121
+ } else
1122
+ u("update:formOptions", I || {});
1123
+ oe.success("JSON 已应用");
1124
+ } catch (I) {
1125
+ s.value = `JSON 解析失败:${I.message}`;
1126
+ }
1127
+ }, x = () => {
1128
+ const I = i.value === "rule" ? { rule: r.components, options: r.formOptions } : { options: r.formOptions, rule: r.components }, A = new Blob([JSON.stringify(I, null, 2)], { type: "application/json" }), C = URL.createObjectURL(A), U = document.createElement("a");
1129
+ U.href = C, U.download = `fc-json-${Date.now()}.json`, U.click(), setTimeout(() => URL.revokeObjectURL(C), 0);
1130
+ };
1131
+ return l({ refresh: () => p.value = b() }), (I, A) => {
1132
+ const C = O("el-tooltip"), U = O("el-header"), le = O("el-main"), re = O("el-container");
1133
+ return m(), V(re, { class: "_fc-json-preview" }, {
1134
+ default: y(() => [
1135
+ f(U, {
1136
+ height: "40px",
1137
+ class: "_fc-l-tabs"
1138
+ }, {
1139
+ default: y(() => [
1140
+ o("div", {
1141
+ class: $(["_fc-l-tab", { active: i.value === "rule" }]),
1142
+ onClick: A[0] || (A[0] = (K) => N("rule"))
1143
+ }, "表单规则", 2),
1144
+ o("div", {
1145
+ class: $(["_fc-l-tab", { active: i.value === "options" }]),
1146
+ onClick: A[1] || (A[1] = (K) => N("options"))
1147
+ }, "表单配置", 2),
1148
+ o("div", $l, [
1149
+ f(C, {
1150
+ effect: "dark",
1151
+ content: "导出 JSON",
1152
+ placement: "top",
1153
+ "hide-after": 0
1154
+ }, {
1155
+ default: y(() => [
1156
+ o("i", {
1157
+ class: "fc-icon icon-download",
1158
+ onClick: x
1159
+ })
1160
+ ]),
1161
+ _: 1
1162
+ })
1163
+ ])
1164
+ ]),
1165
+ _: 1
1166
+ }),
1167
+ f(le, { style: { padding: "8px" } }, {
1168
+ default: y(() => [
1169
+ pe(o("textarea", {
1170
+ "onUpdate:modelValue": A[2] || (A[2] = (K) => p.value = K),
1171
+ class: "gb-fc-json-editor",
1172
+ spellcheck: "false",
1173
+ onFocus: D,
1174
+ onBlur: _
1175
+ }, null, 544), [
1176
+ [_t, p.value]
1177
+ ]),
1178
+ s.value ? (m(), w("div", Pl, ae(s.value), 1)) : j("", !0)
1179
+ ]),
1180
+ _: 1
1181
+ })
1182
+ ]),
1183
+ _: 1
1184
+ });
1185
+ };
1186
+ }
1187
+ });
1188
+ function Ml() {
1189
+ const e = (i) => {
1190
+ Z(i);
1191
+ const p = [];
1192
+ if (i.required) {
1193
+ const s = i.type === d.CHECKBOX_GROUP, h = i.type === d.RADIO_GROUP || i.type === d.SELECT;
1194
+ p.push({
1195
+ required: !0,
1196
+ ...s ? { type: "array" } : {},
1197
+ message: s || h ? `请选择${i.props?.label || "该字段"}` : `请输入${i.props?.label || "该字段"}`,
1198
+ trigger: h || s ? "change" : "blur"
1199
+ });
1200
+ }
1201
+ return i.type === d.INPUT_NUMBER && (i.min !== void 0 && p.push({
1202
+ type: "number",
1203
+ min: i.min,
1204
+ message: `数值不能小于 ${i.min}`,
1205
+ trigger: "blur"
1206
+ }), i.max !== void 0 && p.push({
1207
+ type: "number",
1208
+ max: i.max,
1209
+ message: `数值不能大于 ${i.max}`,
1210
+ trigger: "blur"
1211
+ })), p.length > 0 ? p : void 0;
1212
+ };
1213
+ return {
1214
+ generateFormRules: (i) => {
1215
+ const p = {}, s = {}, h = (b) => {
1216
+ if (b.type === d.ROW) {
1217
+ b.children && b.children.forEach((_) => {
1218
+ Array.isArray(_) && _.forEach((x) => {
1219
+ h(x);
1220
+ });
1221
+ });
1222
+ return;
1223
+ }
1224
+ const N = Z(b), D = e(b);
1225
+ if (D && (s[N] = D), !(N in p))
1226
+ if (b.defaultValue !== void 0 && b.defaultValue !== null)
1227
+ if (b.type === d.DATE_PICKER) {
1228
+ const _ = b.defaultValue;
1229
+ if (_ === "today")
1230
+ p[N] = /* @__PURE__ */ new Date();
1231
+ else if (_ === "tomorrow") {
1232
+ const x = /* @__PURE__ */ new Date();
1233
+ x.setDate(x.getDate() + 1), p[N] = x;
1234
+ } else
1235
+ p[N] = _;
1236
+ } else
1237
+ p[N] = b.defaultValue;
1238
+ else
1239
+ b.type === d.INPUT_NUMBER ? p[N] = null : b.type === d.RADIO_GROUP || b.type === d.SELECT || b.type === d.TEXTAREA ? p[N] = "" : b.type === d.DATE_PICKER ? p[N] = null : b.type === d.CHECKBOX_GROUP ? p[N] = [] : b.type === d.SWITCH ? p[N] = !1 : p[N] = "";
1240
+ };
1241
+ return Array.isArray(i) && i.forEach((b) => {
1242
+ h(b);
1243
+ }), { data: p, rules: s };
1244
+ },
1245
+ validateForm: async (i) => {
1246
+ if (!i)
1247
+ throw new Error("表单引用不存在");
1248
+ return await i.validate();
1249
+ },
1250
+ resetForm: (i) => {
1251
+ i && i.resetFields();
1252
+ },
1253
+ getFormData: (i, p) => {
1254
+ const s = {}, h = (b) => {
1255
+ if (b.type === d.ROW) {
1256
+ b.children && b.children.forEach((D) => {
1257
+ Array.isArray(D) && D.forEach((_) => {
1258
+ h(_);
1259
+ });
1260
+ });
1261
+ return;
1262
+ }
1263
+ const N = Z(b);
1264
+ N in i && (s[N] = {
1265
+ name: b.props?.label || "",
1266
+ value: i[N],
1267
+ type: b.type
1268
+ });
1269
+ };
1270
+ return Array.isArray(p) && p.forEach((b) => {
1271
+ h(b);
1272
+ }), s;
1273
+ }
1274
+ };
1275
+ }
1276
+ const Fl = { class: "form-view-container" }, Bl = { class: "form-view-content" }, Gl = ["data-width"], zl = {
1277
+ key: 1,
1278
+ class: "empty-state"
1279
+ }, jl = {
1280
+ key: 0,
1281
+ class: "form-result"
1282
+ }, Hl = /* @__PURE__ */ Object.assign({ name: "GbFormViewer" }, {
1283
+ __name: "FormViewer",
1284
+ props: {
1285
+ formConfig: {
1286
+ type: Array,
1287
+ default: () => []
1288
+ },
1289
+ showActions: {
1290
+ type: Boolean,
1291
+ default: !0
1292
+ },
1293
+ readonly: {
1294
+ type: Boolean,
1295
+ default: !1
1296
+ }
1297
+ },
1298
+ setup(e, { expose: l }) {
1299
+ const t = e, r = P(null), u = Te({}), i = Te({}), p = P(!1), { generateFormRules: s } = Ml(), h = (D) => {
1300
+ if (D.type === d.ROW)
1301
+ return { width: "100%" };
1302
+ if (D.style?.width) {
1303
+ const _ = D.style.width;
1304
+ let x = _;
1305
+ return typeof _ == "string" && _.includes("%") ? x = _ : typeof _ == "number" && (x = `${_}%`), {
1306
+ width: x,
1307
+ "--item-width": x
1308
+ };
1309
+ }
1310
+ return { width: "100%" };
1311
+ }, b = () => {
1312
+ Object.keys(u).forEach((x) => delete u[x]), Object.keys(i).forEach((x) => delete i[x]);
1313
+ const { data: D, rules: _ } = s(t.formConfig);
1314
+ Object.assign(u, D), Object.assign(i, _);
1315
+ };
1316
+ Re(() => t.formConfig, () => {
1317
+ b();
1318
+ }, { immediate: !0, deep: !0 });
1319
+ const N = (D, _) => {
1320
+ u[D] = _;
1321
+ };
1322
+ return l({
1323
+ formData: u,
1324
+ formRef: r,
1325
+ formRules: i
1326
+ }), (D, _) => {
1327
+ const x = O("el-form"), I = O("el-empty"), A = O("el-divider");
1328
+ return m(), w("div", Fl, [
1329
+ o("div", Bl, [
1330
+ e.formConfig && e.formConfig.length > 0 ? (m(), V(x, {
1331
+ key: 0,
1332
+ ref_key: "formRef",
1333
+ ref: r,
1334
+ model: u,
1335
+ rules: i,
1336
+ disabled: e.readonly,
1337
+ "label-width": "120px",
1338
+ class: "form-wrapper"
1339
+ }, {
1340
+ default: y(() => [
1341
+ (m(!0), w(B, null, z(e.formConfig, (C, U) => (m(), w("div", {
1342
+ key: U,
1343
+ class: $(["form-item-wrapper", { "is-row": C.type === k(d).ROW }]),
1344
+ style: Rt(h(C)),
1345
+ "data-width": C.style?.width
1346
+ }, [
1347
+ f(it, {
1348
+ component: C,
1349
+ "form-data": u,
1350
+ "form-rules": i,
1351
+ readonly: e.readonly,
1352
+ "onUpdate:value": N
1353
+ }, null, 8, ["component", "form-data", "form-rules", "readonly"])
1354
+ ], 14, Gl))), 128))
1355
+ ]),
1356
+ _: 1
1357
+ }, 8, ["model", "rules", "disabled"])) : (m(), w("div", zl, [
1358
+ f(I, { description: "暂无表单配置,请先设计表单" })
1359
+ ]))
1360
+ ]),
1361
+ p.value ? (m(), w("div", jl, [
1362
+ f(A, null, {
1363
+ default: y(() => [..._[0] || (_[0] = [
1364
+ Y("提交结果", -1)
1365
+ ])]),
1366
+ _: 1
1367
+ }),
1368
+ o("pre", null, ae(JSON.stringify(u, null, 2)), 1)
1369
+ ])) : j("", !0)
1370
+ ]);
1371
+ };
1372
+ }
1373
+ }), ut = /* @__PURE__ */ st(Hl, [["__scopeId", "data-v-d4573d59"]]), J = (e) => String(e ?? "").replace(/"/g, "&quot;");
1374
+ function Wl(e) {
1375
+ const l = [], t = e.props?.label || "", r = e.props?.variableName || "";
1376
+ return t && l.push(`label="${J(t)}"`), r && l.push(`prop="${J(r)}"`), e.required && l.push("required"), l.join(" ");
1377
+ }
1378
+ function Ze(e, l) {
1379
+ const t = " ".repeat(l), r = Wl(e), u = e.props?.variableName || "", i = [];
1380
+ switch (e.type) {
1381
+ case d.INPUT:
1382
+ i.push(`${t} <el-input v-model="formData.${u}" placeholder="${J(e.props?.placeholder || "")}" />`);
1383
+ break;
1384
+ case d.TEXTAREA:
1385
+ i.push(`${t} <el-input v-model="formData.${u}" type="textarea" :rows="${e.props?.rows || 3}" placeholder="${J(e.props?.placeholder || "")}" />`);
1386
+ break;
1387
+ case d.INPUT_NUMBER:
1388
+ i.push(`${t} <el-input-number v-model="formData.${u}" :min="${e.min ?? 0}" :max="${e.max ?? 100}" />`);
1389
+ break;
1390
+ case d.RADIO_GROUP:
1391
+ (e.props?.options || []).forEach((p) => {
1392
+ i.push(`${t} <el-radio value="${J(p.value)}">${J(p.label)}</el-radio>`);
1393
+ }), i.unshift(`${t} <el-radio-group v-model="formData.${u}">`), i.push(`${t} </el-radio-group>`);
1394
+ break;
1395
+ case d.CHECKBOX_GROUP:
1396
+ (e.props?.options || []).forEach((p) => {
1397
+ i.push(`${t} <el-checkbox value="${J(p.value)}">${J(p.label)}</el-checkbox>`);
1398
+ }), i.unshift(`${t} <el-checkbox-group v-model="formData.${u}">`), i.push(`${t} </el-checkbox-group>`);
1399
+ break;
1400
+ case d.SELECT:
1401
+ (e.props?.options || []).forEach((p) => {
1402
+ i.push(`${t} <el-option label="${J(p.label)}" value="${J(p.value)}" />`);
1403
+ }), i.unshift(`${t} <el-select v-model="formData.${u}" placeholder="${J(e.props?.placeholder || "")}">`), i.push(`${t} </el-select>`);
1404
+ break;
1405
+ case d.SWITCH:
1406
+ i.push(`${t} <el-switch v-model="formData.${u}" />`);
1407
+ break;
1408
+ case d.DATE_PICKER:
1409
+ i.push(`${t} <el-date-picker v-model="formData.${u}" type="date" placeholder="${J(e.props?.placeholder || "")}" />`);
1410
+ break;
1411
+ default:
1412
+ i.push(`${t} <el-input v-model="formData.${u}" />`);
1413
+ }
1414
+ return `${t}<el-form-item ${r}>
1415
+ ${i.join(`
1416
+ `)}
1417
+ ${t}</el-form-item>`;
1418
+ }
1419
+ function ql(e, l = {}) {
1420
+ const t = [];
1421
+ return (e || []).forEach((r) => {
1422
+ if (r.type === d.ROW) {
1423
+ const u = r.props?.columns || [];
1424
+ t.push('<el-row :gutter="' + (r.props?.gutter || 20) + '">'), u.forEach((i, p) => {
1425
+ t.push(' <el-col :span="' + (i.span || 12) + '">'), (r.children?.[p] || []).forEach((s) => {
1426
+ t.push(Ze(s, 4));
1427
+ }), t.push(" </el-col>");
1428
+ }), t.push("</el-row>");
1429
+ } else
1430
+ t.push(Ze(r, 0));
1431
+ }), `<template>
1432
+ <el-form :model="formData" label-width="${l.labelWidth || "120px"}"${l.size && l.size !== "default" ? ` size="${l.size}"` : ""}>
1433
+ ${t.join(`
1434
+ `).split(`
1435
+ `).map((r) => " " + r).join(`
1436
+ `)}
1437
+ </el-form>
1438
+ </template>`;
1439
+ }
1440
+ function Jl(e, l = {}) {
1441
+ const t = [], r = (u, i) => {
1442
+ const p = " ".repeat(i), s = J(u.props?.label || ""), h = J(u.props?.variableName || "");
1443
+ if (u.type === d.ROW) {
1444
+ const b = u.props?.columns || [];
1445
+ t.push(`${p}<div class="row">`), b.forEach((N, D) => {
1446
+ t.push(`${p} <div class="col-${N.span || 12}">`), (u.children?.[D] || []).forEach((_) => r(_, i + 4)), t.push(`${p} </div>`);
1447
+ }), t.push(`${p}</div>`);
1448
+ return;
1449
+ }
1450
+ t.push(`${p}<div class="form-item">`), t.push(`${p} <label>${s}${u.required ? " <em>*</em>" : ""}</label>`), t.push(`${p} <div class="form-item-body" data-field="${h}" data-type="${u.type}"></div>`), t.push(`${p}</div>`);
1451
+ };
1452
+ return (e || []).forEach((u) => r(u, 0)), `<form class="gb-flow-form"${l.labelWidth ? ` style="--label-width:${l.labelWidth}"` : ""}>
1453
+ ${t.join(`
1454
+ `)}
1455
+ </form>`;
1456
+ }
1457
+ const Yl = { class: "_fd-preview-tabs el-tabs" }, Kl = { class: "el-tabs__header" }, Ql = { class: "el-tabs__nav-wrap" }, Xl = { class: "el-tabs__nav" }, Zl = ["onClick"], en = {
1458
+ key: 2,
1459
+ class: "_fd-preview-code"
1460
+ }, tn = /* @__PURE__ */ Object.assign({ name: "FcPreviewDialog" }, {
1461
+ __name: "FcPreviewDialog",
1462
+ props: {
1463
+ modelValue: { type: Boolean, default: !1 },
1464
+ components: { type: Array, default: () => [] },
1465
+ formOptions: { type: Object, default: () => ({}) }
1466
+ },
1467
+ emits: ["update:modelValue"],
1468
+ setup(e) {
1469
+ const l = e, t = [
1470
+ { label: "表单模式", value: "form" },
1471
+ { label: "组件模式", value: "component" },
1472
+ { label: "HTML 模式", value: "html" }
1473
+ ], r = P("form"), u = H(() => ql(l.components, l.formOptions)), i = H(() => Jl(l.components, l.formOptions)), p = async () => {
1474
+ const s = r.value === "component" ? u.value : i.value;
1475
+ try {
1476
+ await navigator.clipboard.writeText(s), oe.success("代码已复制");
1477
+ } catch {
1478
+ oe.warning("复制失败,请手动复制");
1479
+ }
1480
+ };
1481
+ return (s, h) => {
1482
+ const b = O("el-dialog");
1483
+ return m(), V(b, {
1484
+ "model-value": e.modelValue,
1485
+ width: "80%",
1486
+ class: "_fd-preview-dialog",
1487
+ "append-to-body": "",
1488
+ "onUpdate:modelValue": h[0] || (h[0] = (N) => s.$emit("update:modelValue", N))
1489
+ }, {
1490
+ default: y(() => [
1491
+ o("div", Yl, [
1492
+ o("div", Kl, [
1493
+ o("div", Ql, [
1494
+ o("div", Xl, [
1495
+ (m(), w(B, null, z(t, (N) => o("div", {
1496
+ key: N.value,
1497
+ class: $(["el-tabs__item", { "is-active": r.value === N.value }]),
1498
+ onClick: (D) => r.value = N.value
1499
+ }, ae(N.label), 11, Zl)), 64))
1500
+ ])
1501
+ ])
1502
+ ])
1503
+ ]),
1504
+ r.value !== "form" ? (m(), w("div", {
1505
+ key: 0,
1506
+ class: "_fd-preview-copy",
1507
+ onClick: p
1508
+ }, [...h[1] || (h[1] = [
1509
+ o("i", { class: "fc-icon icon-copy" }, null, -1)
1510
+ ])])) : j("", !0),
1511
+ r.value === "form" ? (m(), V(ut, {
1512
+ key: 1,
1513
+ "form-config": e.components
1514
+ }, null, 8, ["form-config"])) : (m(), w("pre", en, [
1515
+ o("code", null, ae(r.value === "component" ? u.value : i.value), 1)
1516
+ ]))
1517
+ ]),
1518
+ _: 1
1519
+ }, 8, ["model-value"]);
1520
+ };
1521
+ }
1522
+ }), ln = [
1523
+ {
1524
+ name: "文本输入框",
1525
+ type: d.INPUT,
1526
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="18" height="14" rx="2"/><line x1="7" y1="12" x2="17" y2="12"/><line x1="7" y1="9" x2="10" y2="9"/></svg>',
1527
+ value: "",
1528
+ required: !0,
1529
+ defaultValue: "",
1530
+ props: {
1531
+ label: "文本输入框",
1532
+ variableName: "",
1533
+ placeholder: "请输入文本"
1534
+ },
1535
+ style: {
1536
+ width: "100%"
1537
+ }
1538
+ },
1539
+ {
1540
+ name: "多行文本",
1541
+ type: d.TEXTAREA,
1542
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="7" y1="9" x2="17" y2="9"/><line x1="7" y1="12" x2="17" y2="12"/><line x1="7" y1="15" x2="13" y2="15"/></svg>',
1543
+ value: "",
1544
+ required: !0,
1545
+ defaultValue: "",
1546
+ props: {
1547
+ label: "多行文本",
1548
+ variableName: "",
1549
+ placeholder: "请输入内容",
1550
+ rows: 3
1551
+ },
1552
+ style: {
1553
+ width: "100%"
1554
+ }
1555
+ },
1556
+ {
1557
+ name: "数字输入框",
1558
+ type: d.INPUT_NUMBER,
1559
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="18" height="14" rx="2"/><line x1="7" y1="10" x2="7" y2="14"/><line x1="10" y1="10" x2="10" y2="14"/><line x1="13" y1="10" x2="13" y2="14"/></svg>',
1560
+ value: null,
1561
+ required: !0,
1562
+ min: 1,
1563
+ max: 100,
1564
+ defaultValue: 1,
1565
+ props: {
1566
+ label: "数字输入框",
1567
+ variableName: "",
1568
+ placeholder: "请输入数字"
1569
+ },
1570
+ style: {
1571
+ width: "100%"
1572
+ }
1573
+ },
1574
+ {
1575
+ name: "单选框",
1576
+ type: d.RADIO_GROUP,
1577
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',
1578
+ value: "",
1579
+ required: !0,
1580
+ defaultValue: "1",
1581
+ props: {
1582
+ label: "单选框",
1583
+ variableName: "",
1584
+ options: [
1585
+ { label: "选项1", value: "1" },
1586
+ { label: "选项2", value: "2" },
1587
+ { label: "选项3", value: "3" }
1588
+ ]
1589
+ },
1590
+ style: {
1591
+ width: "100%"
1592
+ }
1593
+ },
1594
+ {
1595
+ name: "下拉选择",
1596
+ type: d.SELECT,
1597
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="18" height="14" rx="2"/><polyline points="8 10 12 14 16 10"/></svg>',
1598
+ value: "",
1599
+ required: !0,
1600
+ defaultValue: "",
1601
+ props: {
1602
+ label: "下拉选择",
1603
+ variableName: "",
1604
+ placeholder: "请选择",
1605
+ options: [
1606
+ { label: "选项1", value: "1" },
1607
+ { label: "选项2", value: "2" },
1608
+ { label: "选项3", value: "3" }
1609
+ ]
1610
+ },
1611
+ style: {
1612
+ width: "100%"
1613
+ }
1614
+ },
1615
+ {
1616
+ name: "多选框",
1617
+ type: d.CHECKBOX_GROUP,
1618
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="7" height="7" rx="1"/><polyline points="4.5 7.5 6 9 9 6"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="4" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>',
1619
+ value: [],
1620
+ required: !0,
1621
+ defaultValue: [],
1622
+ props: {
1623
+ label: "多选框",
1624
+ variableName: "",
1625
+ options: [
1626
+ { label: "选项1", value: "1" },
1627
+ { label: "选项2", value: "2" },
1628
+ { label: "选项3", value: "3" }
1629
+ ]
1630
+ },
1631
+ style: {
1632
+ width: "100%"
1633
+ }
1634
+ },
1635
+ {
1636
+ name: "开关",
1637
+ type: d.SWITCH,
1638
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="7" width="20" height="10" rx="5"/><circle cx="16" cy="12" r="3" fill="currentColor"/></svg>',
1639
+ value: !1,
1640
+ required: !1,
1641
+ defaultValue: !1,
1642
+ props: {
1643
+ label: "开关",
1644
+ variableName: "",
1645
+ activeText: "是",
1646
+ inactiveText: "否"
1647
+ },
1648
+ style: {
1649
+ width: "100%"
1650
+ }
1651
+ },
1652
+ {
1653
+ name: "日期选择器",
1654
+ type: d.DATE_PICKER,
1655
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="16" y1="2" x2="16" y2="6"/><circle cx="12" cy="15" r="1.5" fill="currentColor"/></svg>',
1656
+ value: null,
1657
+ required: !0,
1658
+ defaultValue: null,
1659
+ props: {
1660
+ label: "日期选择器",
1661
+ variableName: "",
1662
+ placeholder: "请选择日期"
1663
+ },
1664
+ style: {
1665
+ width: "100%"
1666
+ }
1667
+ }
1668
+ ], nn = [
1669
+ {
1670
+ name: "分栏",
1671
+ type: d.ROW,
1672
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="9" height="16" rx="1"/><rect x="13" y="4" width="9" height="16" rx="1"/></svg>',
1673
+ value: null,
1674
+ required: !1,
1675
+ props: {
1676
+ gutter: 20,
1677
+ columns: [
1678
+ { span: 12 },
1679
+ { span: 12 }
1680
+ ]
1681
+ },
1682
+ style: {
1683
+ width: "100%"
1684
+ },
1685
+ children: []
1686
+ }
1687
+ ], et = [
1688
+ {
1689
+ name: "基础组件",
1690
+ key: "basic",
1691
+ templates: ln
1692
+ },
1693
+ {
1694
+ name: "布局组件",
1695
+ key: "layout",
1696
+ templates: nn
1697
+ }
1698
+ ], on = "1.0.0", an = "gbflow-form";
1699
+ function Ee(e) {
1700
+ return !!e && typeof e == "object" && !Array.isArray(e);
1701
+ }
1702
+ function rn(e) {
1703
+ if (e !== void 0)
1704
+ return JSON.parse(JSON.stringify(e));
1705
+ }
1706
+ function sn(e) {
1707
+ if (typeof e != "string") return e;
1708
+ const l = e.replace(/^\uFEFF/, "").trim();
1709
+ if (!l) throw new Error("导入内容为空");
1710
+ try {
1711
+ return JSON.parse(l);
1712
+ } catch (t) {
1713
+ throw new Error(`JSON 解析失败:${t.message}`);
1714
+ }
1715
+ }
1716
+ function Se(e) {
1717
+ const l = Array.isArray(e) ? e : e?.components, t = Array.isArray(e) ? {} : e?.options || {};
1718
+ if (!Array.isArray(l)) return { components: [], options: { ...t }, repairs: [] };
1719
+ const r = [], u = (i) => i.filter((p) => Ee(p) ? !0 : (r.push(`已忽略无效的表单组件配置:${JSON.stringify(p)}`), !1)).map((p) => {
1720
+ const s = rn(p);
1721
+ if (s.id || (s.id = Oe()), s.type || (s.type = d.INPUT, r.push("表单组件缺少 type,已按文本输入框处理")), Ee(s.props) || (s.props = {}), s.props.label === void 0 && (s.props.label = s.type), s.props.variableName === void 0 && (s.props.variableName = ""), s.props.options !== void 0 && (s.props.options = kt(s.props.options)), s.type === d.ROW) {
1722
+ const h = Array.isArray(s.children) ? s.children : [];
1723
+ s.children = h.map((b) => u(Array.isArray(b) ? b : [])), s.children.length || (s.children = [[], []]), s.props.columns || (s.props.columns = s.children.map(() => ({ span: 24 / s.children.length })));
1724
+ }
1725
+ return s;
1726
+ });
1727
+ return {
1728
+ components: u(l),
1729
+ options: {
1730
+ name: t.name || "",
1731
+ description: t.description || "",
1732
+ labelWidth: t.labelWidth || "120px",
1733
+ size: t.size || "default",
1734
+ ...t
1735
+ },
1736
+ repairs: r
1737
+ };
1738
+ }
1739
+ function Ue(e) {
1740
+ const l = Array.isArray(e) ? e : e?.components || [], t = [], r = [], u = /* @__PURE__ */ new Set(), i = (p) => {
1741
+ p.forEach((s) => {
1742
+ if (!s || typeof s != "object") return;
1743
+ if (s.type === d.ROW) {
1744
+ s.children?.forEach(i);
1745
+ return;
1746
+ }
1747
+ const h = s.props?.variableName;
1748
+ h ? (u.has(h) && t.push({
1749
+ code: "DUPLICATE_VARIABLE",
1750
+ message: `表单变量名重复:${h}`,
1751
+ componentId: s.id
1752
+ }), u.add(h)) : r.push({
1753
+ code: "MISSING_VARIABLE",
1754
+ message: `表单项「${s.props?.label || s.type}」尚未设置变量名`,
1755
+ componentId: s.id
1756
+ }), s.props?.label || r.push({
1757
+ code: "MISSING_LABEL",
1758
+ message: `表单项「${s.id}」尚未设置标签`,
1759
+ componentId: s.id
1760
+ }), ["select", "radio-group", "checkbox-group"].includes(s.type) && (!Array.isArray(s.props?.options) || s.props.options.length === 0) && r.push({
1761
+ code: "MISSING_OPTIONS",
1762
+ message: `选项组件「${s.props?.label || s.type}」还没有选项`,
1763
+ componentId: s.id
1764
+ });
1765
+ });
1766
+ };
1767
+ return i(l), { valid: t.length === 0, errors: t, warnings: r };
1768
+ }
1769
+ function un(e) {
1770
+ return Object.keys(e || {}).reduce((l, t) => (e[t] !== void 0 && e[t] !== null && (l[t] = e[t]), l), {});
1771
+ }
1772
+ function tt(e, l = {}, t = {}) {
1773
+ const r = Se(e), u = {
1774
+ schemaVersion: on,
1775
+ kind: an,
1776
+ meta: un(l),
1777
+ form: { components: r.components, options: r.options }
1778
+ };
1779
+ return t.raw ? u : JSON.stringify(u, null, t.space ?? 2);
1780
+ }
1781
+ function lt(e) {
1782
+ const l = sn(e);
1783
+ if (Array.isArray(l)) {
1784
+ const i = Se(l);
1785
+ return {
1786
+ components: i.components,
1787
+ options: i.options,
1788
+ repairs: i.repairs,
1789
+ validation: Ue({ components: i.components })
1790
+ };
1791
+ }
1792
+ if (!Ee(l)) throw new Error("无法识别的表单导入内容");
1793
+ const t = l.form || l.formStructure || l.formConfig || l.rule || (l.components ? l : null);
1794
+ if (!t) throw new Error("导入内容中未找到表单(components)");
1795
+ const r = Se(t), u = {
1796
+ ...r.options,
1797
+ ...Ee(l.options) ? l.options : {}
1798
+ };
1799
+ return {
1800
+ components: r.components,
1801
+ options: u,
1802
+ repairs: r.repairs,
1803
+ meta: Ee(l.meta) ? l.meta : void 0,
1804
+ validation: Ue({ components: r.components })
1805
+ };
1806
+ }
1807
+ function Fn(e, l = "flow") {
1808
+ return String(e || l).trim().replace(/[\\/:*?"<>|]/g, "-").replace(/\s+/g, "-") || l;
1809
+ }
1810
+ function dn(e, l, t = "application/json;charset=utf-8") {
1811
+ if (typeof document > "u")
1812
+ throw new Error("downloadText 只能在浏览器环境使用");
1813
+ const r = new Blob([e], { type: t }), u = URL.createObjectURL(r), i = document.createElement("a");
1814
+ i.href = u, i.download = l, i.style.display = "none", document.body.appendChild(i), i.click(), document.body.removeChild(i), setTimeout(() => URL.revokeObjectURL(u), 1e3);
1815
+ }
1816
+ function cn(e, l = "flow.json", t = 2) {
1817
+ const r = typeof e == "string" ? e : JSON.stringify(e, null, t), u = l.endsWith(".json") ? l : `${l}.json`;
1818
+ dn(r, u);
1819
+ }
1820
+ function pn(e) {
1821
+ return e ? typeof e.text == "function" ? e.text() : new Promise((l, t) => {
1822
+ const r = new FileReader();
1823
+ r.onload = () => l(String(r.result || "")), r.onerror = () => t(r.error || new Error("读取文件失败")), r.readAsText(e, "utf-8");
1824
+ }) : Promise.reject(new Error("未选择文件"));
1825
+ }
1826
+ function mn() {
1827
+ return new Promise((e) => {
1828
+ if (typeof document > "u") {
1829
+ fn();
1830
+ return;
1831
+ }
1832
+ const l = document.createElement("input");
1833
+ l.type = "file", l.accept = ".json,.gbflow,application/json", l.style.display = "none", document.body.appendChild(l);
1834
+ const t = () => {
1835
+ l.parentNode && l.parentNode.removeChild(l);
1836
+ };
1837
+ l.addEventListener("change", async () => {
1838
+ const r = l.files?.[0];
1839
+ if (!r) {
1840
+ t(), e(null);
1841
+ return;
1842
+ }
1843
+ try {
1844
+ const u = await pn(r);
1845
+ t(), e({ file: r, text: u });
1846
+ } catch (u) {
1847
+ t(), e({ file: r, text: "", error: u });
1848
+ }
1849
+ }), l.addEventListener("cancel", () => {
1850
+ t(), e(null);
1851
+ }), l.click();
1852
+ });
1853
+ }
1854
+ function fn() {
1855
+ throw new Error("pickJSONFile 只能在浏览器环境使用");
1856
+ }
1857
+ const vn = ["onClick"], yn = { class: "_fc-l-list" }, hn = ["onDragstart", "onClick"], bn = { class: "_fc-l-icon" }, gn = { class: "_fc-l-name" }, Tn = { class: "_fc-tree-label" }, En = { class: "_fc-m-tools-l" }, On = { class: "devices" }, Nn = { class: "_fc-m-tools-r" }, An = /* @__PURE__ */ Object.assign({ name: "GbFormDesigner" }, {
1858
+ __name: "FormDesigner",
1859
+ props: {
1860
+ modelValue: { type: Array, default: () => [] },
1861
+ options: { type: Object, default: null },
1862
+ meta: { type: Object, default: () => ({}) },
1863
+ fileName: { type: String, default: "form" }
1864
+ },
1865
+ emits: ["update:modelValue", "update:options", "import", "export", "validate", "change"],
1866
+ setup(e, { expose: l, emit: t }) {
1867
+ const r = e, u = t, i = (c) => JSON.parse(JSON.stringify(c ?? [])), p = Te({
1868
+ name: "",
1869
+ description: "",
1870
+ labelWidth: "120px",
1871
+ size: "default",
1872
+ ...r.options || {}
1873
+ }), s = r.options ? Te(r.options) : p;
1874
+ Re(
1875
+ () => r.options,
1876
+ (c) => {
1877
+ !c || c === s || Object.assign(s, c);
1878
+ },
1879
+ { deep: !0 }
1880
+ ), ke("fcFormOptions", s);
1881
+ const h = P("base"), b = P("menu"), N = P(!1), D = P(!1), _ = P("pc"), x = P(!1), I = P(""), A = P(""), C = P(null), U = {
1882
+ "--fc-drag-empty": "'拖拽左侧列表中的组件到此处'",
1883
+ "--fc-child-empty": "'点击右下角 + 按钮添加一列'"
1884
+ }, le = Te({}), re = {}, K = P(
1885
+ et.map((c) => ({ ...c, hidden: !1 }))
1886
+ ), q = {
1887
+ [d.INPUT]: "icon-input",
1888
+ [d.TEXTAREA]: "icon-textarea",
1889
+ [d.INPUT_NUMBER]: "icon-number",
1890
+ [d.RADIO_GROUP]: "icon-radio",
1891
+ [d.CHECKBOX_GROUP]: "icon-checkbox",
1892
+ [d.SELECT]: "icon-select",
1893
+ [d.SWITCH]: "icon-switch",
1894
+ [d.DATE_PICKER]: "icon-date",
1895
+ [d.ROW]: "icon-row"
1896
+ }, E = (c) => q[c] || "icon-input", n = P([]), Q = P(-1);
1897
+ let F = !1, ee = null;
1898
+ const ne = () => JSON.stringify({ components: r.modelValue, options: { ...s } }), me = () => {
1899
+ const c = ne();
1900
+ n.value[Q.value] !== c && (n.value = n.value.slice(0, Q.value + 1), n.value.push(c), n.value.length > 50 && n.value.shift(), Q.value = n.value.length - 1);
1901
+ }, fe = H(() => Q.value > 0), se = H(() => Q.value < n.value.length - 1), ce = () => {
1902
+ const { components: c, options: a } = JSON.parse(n.value[Q.value]);
1903
+ F = !0, u("update:modelValue", c), Object.assign(s, a), Ct(() => {
1904
+ F = !1;
1905
+ });
1906
+ }, be = () => {
1907
+ fe.value && (Q.value -= 1, ce());
1908
+ }, Ae = () => {
1909
+ se.value && (Q.value += 1, ce());
1910
+ };
1911
+ Re(
1912
+ () => [r.modelValue, { ...s }],
1913
+ () => {
1914
+ F || (clearTimeout(ee), ee = setTimeout(me, 300));
1915
+ },
1916
+ { deep: !0 }
1917
+ ), ot(() => {
1918
+ me();
1919
+ });
1920
+ const v = (c) => {
1921
+ u("update:modelValue", i(c));
1922
+ }, ue = (c) => {
1923
+ Object.assign(s, c || {}), u("update:options", { ...s });
1924
+ }, ie = (c) => {
1925
+ for (const a of et) {
1926
+ const R = a.templates.find((L) => L.type === c);
1927
+ if (R) return R;
1928
+ }
1929
+ return null;
1930
+ }, Pe = (c) => {
1931
+ const a = i(c);
1932
+ return delete a.name, delete a.icon, at(a), a.props = a.props || {}, a.props.variableName || (a.props.variableName = `field_${Oe().split("_").pop()}`), a.type === d.ROW && (a.children = [[], []], a.props.columns = a.props.columns || [{ span: 12 }, { span: 12 }]), a;
1933
+ }, dt = (c) => {
1934
+ const a = ie(c);
1935
+ return a ? Pe(a) : null;
1936
+ }, ct = (c) => {
1937
+ const a = Pe(c), R = [...r.modelValue, a];
1938
+ v(R), I.value = a.id;
1939
+ }, ve = (c) => {
1940
+ if (c.length === 1) return { list: r.modelValue, index: c[0], node: null };
1941
+ const [a, , R, L] = c, G = r.modelValue[a];
1942
+ return { list: G?.children?.[R] || [], index: L, node: G };
1943
+ }, Ce = (c, a) => {
1944
+ for (const R of c || []) {
1945
+ if (R.id === a) return R;
1946
+ if (R.type === d.ROW)
1947
+ for (const L of R.children || []) {
1948
+ const G = Ce(L, a);
1949
+ if (G) return G;
1950
+ }
1951
+ }
1952
+ return null;
1953
+ }, pt = H(() => I.value ? Ce(r.modelValue, I.value) : null), mt = (c) => {
1954
+ I.value = c.id;
1955
+ }, we = () => {
1956
+ I.value = "";
1957
+ }, Le = (c) => (c.id = Oe(), c.type === d.ROW && (c.children || []).forEach((a) => a.forEach(Le)), c), Me = (c) => {
1958
+ const a = ve(c), R = a.list[c[c.length - 1]];
1959
+ if (!R) return;
1960
+ const L = Le(i(R));
1961
+ a.list.splice(a.index + 1, 0, L), v(r.modelValue), I.value = L.id;
1962
+ }, Fe = (c) => {
1963
+ const a = ve(c);
1964
+ a.list.splice(a.index, 1), v(r.modelValue), I.value && (Ce(r.modelValue, I.value) || we());
1965
+ }, de = P(null), ft = () => de.value ? de.value : null, vt = (c, a) => {
1966
+ const R = { kind: "new", type: a.type };
1967
+ de.value = R, c.dataTransfer.effectAllowed = "copy", c.dataTransfer.setData("application/x-gb-field", JSON.stringify(R)), c.dataTransfer.setData("text/plain", a.type);
1968
+ }, yt = (c) => {
1969
+ de.value = { kind: "existing", path: [...c] };
1970
+ }, Be = () => {
1971
+ de.value = null, A.value = "";
1972
+ }, ht = (c) => {
1973
+ const a = c.dataTransfer?.getData("application/x-gb-field");
1974
+ let R = de.value;
1975
+ if (a)
1976
+ try {
1977
+ R = JSON.parse(a);
1978
+ } catch {
1979
+ R = de.value;
1980
+ }
1981
+ A.value = "", de.value = null, R && Ge(R, { path: null, position: "bottom" });
1982
+ }, Ge = (c, a) => {
1983
+ if (!c) return;
1984
+ let R = r.modelValue, L = r.modelValue.length;
1985
+ if (a.column !== void 0 && a.path) {
1986
+ const M = ve(a.path).list[a.path[a.path.length - 1]];
1987
+ if (!M?.children?.[a.column]) return;
1988
+ if (c.kind === "existing" && ve(c.path).list[c.path[c.path.length - 1]]?.type === d.ROW) {
1989
+ oe.warning("分栏组件不能放入分栏内");
1990
+ return;
1991
+ }
1992
+ R = M.children[a.column], L = R.length;
1993
+ } else if (a.path) {
1994
+ if (c.kind === "existing" && c.path.length <= a.path.length && c.path.every((ge, Ve) => ge === a.path[Ve]))
1995
+ return;
1996
+ const M = ve(a.path);
1997
+ R = M.list, L = a.position === "top" ? M.index : M.index + 1;
1998
+ }
1999
+ let G;
2000
+ if (c.kind === "new") {
2001
+ if (G = dt(c.type), !G) return;
2002
+ } else {
2003
+ const M = ve(c.path);
2004
+ if (G = M.list[M.index], !G) return;
2005
+ M.list === R && M.index < L && (L -= 1), M.list.splice(M.index, 1);
2006
+ }
2007
+ R.splice(L, 0, G), v(r.modelValue), I.value = G.id;
2008
+ };
2009
+ ke("fcDragOver", A), ke("fcCanvasOps", {
2010
+ active: mt,
2011
+ copy: Me,
2012
+ remove: Fe,
2013
+ startDrag: yt,
2014
+ endDrag: Be,
2015
+ getDragPayload: ft,
2016
+ dropAt: Ge
2017
+ });
2018
+ const ze = (c, a = []) => (c || []).map((R, L) => {
2019
+ const G = [...a, L], M = {
2020
+ id: R.id,
2021
+ label: R.props?.label || R.props?.variableName || R.type,
2022
+ icon: E(R.type),
2023
+ rule: R,
2024
+ path: G
2025
+ };
2026
+ return R.type === d.ROW && (M.children = (R.children || []).flatMap(
2027
+ (ye, ge) => ze(ye || [], [...a, L, "children", ge])
2028
+ )), M;
2029
+ }), bt = H(() => ze(r.modelValue)), gt = (c) => {
2030
+ c.rule && (I.value = c.rule.id);
2031
+ }, Tt = (c, a) => {
2032
+ a.path && (c === "copy" ? Me(a.path) : c === "delete" && Fe(a.path));
2033
+ }, Et = async () => {
2034
+ const c = await mn();
2035
+ if (c)
2036
+ try {
2037
+ const a = lt(c.text);
2038
+ u("update:modelValue", a.components), Object.assign(s, a.options || {}), u("import", { components: a.components, options: { ...s } }), oe.success("表单导入成功");
2039
+ } catch (a) {
2040
+ oe.error(`导入失败:${a.message}`);
2041
+ }
2042
+ }, je = () => {
2043
+ u("update:modelValue", []), we(), oe.success("表单已清空");
2044
+ }, Ot = () => {
2045
+ const c = Ue({ components: r.modelValue });
2046
+ return u("validate", c), c;
2047
+ }, He = () => i(r.modelValue);
2048
+ return l({
2049
+ getComponents: He,
2050
+ getForm: () => ({ components: He(), options: { ...s } }),
2051
+ importJSON: (c) => {
2052
+ const a = lt(c);
2053
+ return u("update:modelValue", a.components), Object.assign(s, a.options || {}), u("import", { components: a.components, options: { ...s } }), a;
2054
+ },
2055
+ exportJSON: (c = 2) => {
2056
+ const a = tt(r.modelValue, { ...r.meta, name: r.meta?.name || r.fileName }, { raw: !0 });
2057
+ return a.form.options = { ...s }, u("export", a), JSON.stringify(a, null, c);
2058
+ },
2059
+ downloadForm: () => {
2060
+ const c = tt(r.modelValue, { ...r.meta, name: r.meta?.name || r.fileName }, { raw: !0 });
2061
+ c.form.options = { ...s }, cn(c, `${r.meta?.name || r.fileName}-form.json`), u("export", c), oe.success("表单 JSON 已导出");
2062
+ },
2063
+ validate: Ot,
2064
+ clearForm: je,
2065
+ undo: be,
2066
+ redo: Ae,
2067
+ components: H(() => r.modelValue),
2068
+ formOptions: s
2069
+ }), (c, a) => {
2070
+ const R = O("el-tooltip"), L = O("el-aside"), G = O("el-header"), M = O("el-main"), ye = O("el-dropdown-item"), ge = O("el-dropdown-menu"), Ve = O("el-dropdown"), Nt = O("el-tree"), _e = O("el-container"), xe = O("el-button"), At = O("el-popconfirm"), wt = O("el-form");
2071
+ return m(), V(_e, {
2072
+ class: "_fc-designer gb-fc-designer",
2073
+ style: { height: "100%" }
2074
+ }, {
2075
+ default: y(() => [
2076
+ f(M, null, {
2077
+ default: y(() => [
2078
+ f(_e, { style: { height: "100%" } }, {
2079
+ default: y(() => [
2080
+ f(L, {
2081
+ class: "_fc-l-menu",
2082
+ width: "40px"
2083
+ }, {
2084
+ default: y(() => [
2085
+ f(R, {
2086
+ effect: "dark",
2087
+ content: "组件列表",
2088
+ placement: "right",
2089
+ "hide-after": 0
2090
+ }, {
2091
+ default: y(() => [
2092
+ o("div", {
2093
+ class: $(["_fc-l-menu-item", { active: h.value === "base" }]),
2094
+ onClick: a[0] || (a[0] = (S) => h.value = "base")
2095
+ }, [...a[15] || (a[15] = [
2096
+ o("i", { class: "fc-icon icon-menu" }, null, -1)
2097
+ ])], 2)
2098
+ ]),
2099
+ _: 1
2100
+ }),
2101
+ f(R, {
2102
+ effect: "dark",
2103
+ content: "JSON",
2104
+ placement: "right",
2105
+ "hide-after": 0
2106
+ }, {
2107
+ default: y(() => [
2108
+ o("div", {
2109
+ class: $(["_fc-l-menu-item", { active: h.value === "json" }]),
2110
+ onClick: a[1] || (a[1] = (S) => h.value = "json")
2111
+ }, [...a[16] || (a[16] = [
2112
+ o("i", { class: "fc-icon icon-script" }, null, -1)
2113
+ ])], 2)
2114
+ ]),
2115
+ _: 1
2116
+ })
2117
+ ]),
2118
+ _: 1
2119
+ }),
2120
+ pe(f(L, {
2121
+ class: "_fc-l",
2122
+ width: "266px"
2123
+ }, {
2124
+ default: y(() => [
2125
+ o("div", {
2126
+ class: "_fc-l-close",
2127
+ onClick: a[2] || (a[2] = (S) => N.value = !0)
2128
+ }, [...a[17] || (a[17] = [
2129
+ o("i", { class: "fc-icon icon-arrow" }, null, -1)
2130
+ ])]),
2131
+ h.value === "json" ? (m(), V(Ll, {
2132
+ key: 0,
2133
+ ref_key: "jsonPanelRef",
2134
+ ref: C,
2135
+ components: e.modelValue,
2136
+ "form-options": k(s),
2137
+ "onUpdate:components": v,
2138
+ "onUpdate:formOptions": ue
2139
+ }, null, 8, ["components", "form-options"])) : (m(), V(_e, {
2140
+ key: 1,
2141
+ style: { height: "100%" }
2142
+ }, {
2143
+ default: y(() => [
2144
+ f(G, {
2145
+ height: "40px",
2146
+ class: "_fc-l-tabs"
2147
+ }, {
2148
+ default: y(() => [
2149
+ o("div", {
2150
+ class: $(["_fc-l-tab", { active: b.value === "menu" }]),
2151
+ onClick: a[3] || (a[3] = (S) => b.value = "menu")
2152
+ }, " 组件 ", 2),
2153
+ o("div", {
2154
+ class: $(["_fc-l-tab", { active: b.value === "tree" }]),
2155
+ onClick: a[4] || (a[4] = (S) => b.value = "tree")
2156
+ }, " 大纲 ", 2)
2157
+ ]),
2158
+ _: 1
2159
+ }),
2160
+ pe(f(M, null, {
2161
+ default: y(() => [
2162
+ (m(!0), w(B, null, z(K.value, (S) => (m(), w("div", {
2163
+ key: S.key,
2164
+ class: "_fc-l-group"
2165
+ }, [
2166
+ o("h4", {
2167
+ class: "_fc-l-title",
2168
+ onClick: (te) => S.hidden = !S.hidden
2169
+ }, [
2170
+ Y(ae(S.name) + " ", 1),
2171
+ o("i", {
2172
+ class: $(["fc-icon icon-arrow", { down: !S.hidden }])
2173
+ }, null, 2)
2174
+ ], 8, vn),
2175
+ pe(o("div", yn, [
2176
+ (m(!0), w(B, null, z(S.templates, (te) => (m(), w("div", {
2177
+ key: te.type,
2178
+ class: "_fc-l-item",
2179
+ draggable: "true",
2180
+ onDragstart: (We) => vt(We, te),
2181
+ onDragend: Be,
2182
+ onClick: (We) => ct(te)
2183
+ }, [
2184
+ o("div", bn, [
2185
+ o("i", {
2186
+ class: $(["fc-icon", E(te.type)])
2187
+ }, null, 2)
2188
+ ]),
2189
+ o("span", gn, ae(te.name), 1)
2190
+ ], 40, hn))), 128))
2191
+ ], 512), [
2192
+ [he, !S.hidden]
2193
+ ])
2194
+ ]))), 128))
2195
+ ]),
2196
+ _: 1
2197
+ }, 512), [
2198
+ [he, b.value === "menu"]
2199
+ ]),
2200
+ pe(f(M, null, {
2201
+ default: y(() => [
2202
+ f(Nt, {
2203
+ data: bt.value,
2204
+ "node-key": "id",
2205
+ "expand-on-click-node": !1,
2206
+ "default-expand-all": "",
2207
+ onNodeClick: gt
2208
+ }, {
2209
+ default: y(({ data: S }) => [
2210
+ o("div", {
2211
+ class: $(["_fc-tree-node", { active: I.value === S.rule?.id }])
2212
+ }, [
2213
+ o("div", Tn, [
2214
+ o("i", {
2215
+ class: $(["fc-icon", S.icon || "icon-cell"])
2216
+ }, null, 2),
2217
+ o("span", null, ae(S.label), 1)
2218
+ ]),
2219
+ o("div", {
2220
+ class: "_fc-tree-more",
2221
+ onClick: a[5] || (a[5] = X(() => {
2222
+ }, ["stop"]))
2223
+ }, [
2224
+ f(Ve, {
2225
+ trigger: "click",
2226
+ size: "default",
2227
+ onCommand: (te) => Tt(te, S)
2228
+ }, {
2229
+ dropdown: y(() => [
2230
+ f(ge, null, {
2231
+ default: y(() => [
2232
+ f(ye, { command: "copy" }, {
2233
+ default: y(() => [...a[18] || (a[18] = [
2234
+ Y("复制", -1)
2235
+ ])]),
2236
+ _: 1
2237
+ }),
2238
+ f(ye, { command: "delete" }, {
2239
+ default: y(() => [...a[19] || (a[19] = [
2240
+ Y("删除", -1)
2241
+ ])]),
2242
+ _: 1
2243
+ })
2244
+ ]),
2245
+ _: 1
2246
+ })
2247
+ ]),
2248
+ default: y(() => [
2249
+ a[20] || (a[20] = o("i", { class: "fc-icon icon-more" }, null, -1))
2250
+ ]),
2251
+ _: 1
2252
+ }, 8, ["onCommand"])
2253
+ ])
2254
+ ], 2)
2255
+ ]),
2256
+ _: 1
2257
+ }, 8, ["data"])
2258
+ ]),
2259
+ _: 1
2260
+ }, 512), [
2261
+ [he, b.value === "tree"]
2262
+ ])
2263
+ ]),
2264
+ _: 1
2265
+ }))
2266
+ ]),
2267
+ _: 1
2268
+ }, 512), [
2269
+ [he, !N.value]
2270
+ ]),
2271
+ f(_e, { class: "_fc-m" }, {
2272
+ default: y(() => [
2273
+ f(G, {
2274
+ class: "_fc-m-tools",
2275
+ height: "45"
2276
+ }, {
2277
+ default: y(() => [
2278
+ o("div", En, [
2279
+ o("div", On, [
2280
+ o("i", {
2281
+ class: $(["fc-icon icon-pc", { active: _.value === "pc" }]),
2282
+ onClick: a[6] || (a[6] = (S) => _.value = "pc")
2283
+ }, null, 2),
2284
+ o("i", {
2285
+ class: $(["fc-icon icon-pad", { active: _.value === "pad" }]),
2286
+ onClick: a[7] || (a[7] = (S) => _.value = "pad")
2287
+ }, null, 2),
2288
+ o("i", {
2289
+ class: $(["fc-icon icon-mobile", { active: _.value === "mobile" }]),
2290
+ onClick: a[8] || (a[8] = (S) => _.value = "mobile")
2291
+ }, null, 2)
2292
+ ]),
2293
+ a[21] || (a[21] = o("div", { class: "line" }, null, -1)),
2294
+ o("div", null, [
2295
+ o("i", {
2296
+ class: $(["fc-icon icon-pre-step", { disabled: !fe.value }]),
2297
+ onClick: be
2298
+ }, null, 2),
2299
+ o("i", {
2300
+ class: $(["fc-icon icon-next-step", { disabled: !se.value }]),
2301
+ onClick: Ae
2302
+ }, null, 2)
2303
+ ])
2304
+ ]),
2305
+ o("div", Nn, [
2306
+ f(xe, {
2307
+ icon: k(Vt),
2308
+ plain: "",
2309
+ size: "small",
2310
+ onClick: Et
2311
+ }, {
2312
+ default: y(() => [...a[22] || (a[22] = [
2313
+ Y("导入", -1)
2314
+ ])]),
2315
+ _: 1
2316
+ }, 8, ["icon"]),
2317
+ f(xe, {
2318
+ type: "primary",
2319
+ plain: "",
2320
+ size: "small",
2321
+ onClick: a[9] || (a[9] = (S) => x.value = !0)
2322
+ }, {
2323
+ default: y(() => [...a[23] || (a[23] = [
2324
+ o("i", { class: "fc-icon icon-preview" }, null, -1),
2325
+ Y(" 预览 ", -1)
2326
+ ])]),
2327
+ _: 1
2328
+ }),
2329
+ f(At, {
2330
+ title: "确定清空所有组件?",
2331
+ width: "200px",
2332
+ "confirm-button-text": "清空",
2333
+ "cancel-button-text": "取消",
2334
+ onConfirm: je
2335
+ }, {
2336
+ reference: y(() => [
2337
+ f(xe, {
2338
+ type: "danger",
2339
+ plain: "",
2340
+ size: "small"
2341
+ }, {
2342
+ default: y(() => [...a[24] || (a[24] = [
2343
+ o("i", { class: "fc-icon icon-delete" }, null, -1),
2344
+ Y(" 清空", -1)
2345
+ ])]),
2346
+ _: 1
2347
+ })
2348
+ ]),
2349
+ _: 1
2350
+ })
2351
+ ])
2352
+ ]),
2353
+ _: 1
2354
+ }),
2355
+ f(M, { class: "_fc-m-con" }, {
2356
+ default: y(() => [
2357
+ a[25] || (a[25] = o("a", {
2358
+ class: "gb-fc-watermark",
2359
+ href: "javascript:void(0)"
2360
+ }, "GbFlowDesign", -1)),
2361
+ o("div", {
2362
+ ref: "dragCon",
2363
+ class: $(["_fc-m-drag", _.value]),
2364
+ style: U,
2365
+ onDragover: a[10] || (a[10] = X(() => {
2366
+ }, ["prevent"])),
2367
+ onDrop: X(ht, ["prevent"])
2368
+ }, [
2369
+ e.modelValue.length ? (m(), V(wt, {
2370
+ key: 0,
2371
+ model: le,
2372
+ "label-width": k(s).labelWidth || "120px",
2373
+ size: k(s).size === "default" ? void 0 : k(s).size
2374
+ }, {
2375
+ default: y(() => [
2376
+ (m(!0), w(B, null, z(e.modelValue, (S, te) => (m(), V(Bt, {
2377
+ key: S.id || te,
2378
+ component: S,
2379
+ path: [te],
2380
+ "form-data": le,
2381
+ "form-rules": re,
2382
+ "active-id": I.value
2383
+ }, null, 8, ["component", "path", "form-data", "active-id"]))), 128))
2384
+ ]),
2385
+ _: 1
2386
+ }, 8, ["model", "label-width", "size"])) : (m(), w("div", {
2387
+ key: 1,
2388
+ class: "_fd-draggable-drag _fd-drag-box drag-holder",
2389
+ onClick: we
2390
+ }))
2391
+ ], 34)
2392
+ ]),
2393
+ _: 1
2394
+ })
2395
+ ]),
2396
+ _: 1
2397
+ }),
2398
+ pe(f(L, {
2399
+ class: "_fc-r",
2400
+ width: "320px"
2401
+ }, {
2402
+ default: y(() => [
2403
+ o("div", {
2404
+ class: "_fc-r-close",
2405
+ onClick: a[11] || (a[11] = (S) => D.value = !0)
2406
+ }, [...a[26] || (a[26] = [
2407
+ o("i", { class: "fc-icon icon-arrow" }, null, -1)
2408
+ ])]),
2409
+ f(Ul, {
2410
+ component: pt.value,
2411
+ "form-options": k(s),
2412
+ onClose: we
2413
+ }, null, 8, ["component", "form-options"])
2414
+ ]),
2415
+ _: 1
2416
+ }, 512), [
2417
+ [he, !D.value]
2418
+ ]),
2419
+ N.value ? (m(), w("div", {
2420
+ key: 0,
2421
+ class: "_fc-l-open",
2422
+ onClick: a[12] || (a[12] = (S) => N.value = !1)
2423
+ }, [...a[27] || (a[27] = [
2424
+ o("i", { class: "fc-icon icon-arrow" }, null, -1)
2425
+ ])])) : j("", !0),
2426
+ D.value ? (m(), w("div", {
2427
+ key: 1,
2428
+ class: "_fc-r-open",
2429
+ onClick: a[13] || (a[13] = (S) => D.value = !1)
2430
+ }, [...a[28] || (a[28] = [
2431
+ o("i", { class: "fc-icon icon-arrow" }, null, -1)
2432
+ ])])) : j("", !0),
2433
+ f(tn, {
2434
+ modelValue: x.value,
2435
+ "onUpdate:modelValue": a[14] || (a[14] = (S) => x.value = S),
2436
+ components: e.modelValue,
2437
+ "form-options": k(s)
2438
+ }, null, 8, ["modelValue", "components", "form-options"])
2439
+ ]),
2440
+ _: 1
2441
+ })
2442
+ ]),
2443
+ _: 1
2444
+ })
2445
+ ]),
2446
+ _: 1
2447
+ });
2448
+ };
2449
+ }
2450
+ }), g = Object.freeze({
2451
+ STRING: "string",
2452
+ // 字符串类型(input, textarea, select, radio)
2453
+ INTEGER: "integer",
2454
+ // 整数类型
2455
+ DECIMAL: "decimal",
2456
+ // 小数类型
2457
+ DATE: "date",
2458
+ // 日期类型(YYYY-MM-DD)
2459
+ DATETIME: "datetime",
2460
+ // 日期时间类型(YYYY-MM-DD HH:mm)
2461
+ ARRAY: "array",
2462
+ // 数组类型(checkbox)
2463
+ BOOLEAN: "boolean"
2464
+ // 布尔类型(预留)
2465
+ }), W = Object.freeze({
2466
+ INPUT: "input",
2467
+ TEXTAREA: "textarea",
2468
+ INPUT_NUMBER: "input-number",
2469
+ RADIO_GROUP: "radio-group",
2470
+ CHECKBOX_GROUP: "checkbox-group",
2471
+ SELECT: "select",
2472
+ SWITCH: "switch",
2473
+ DATE_PICKER: "date-picker",
2474
+ ROW: "row"
2475
+ }), wn = Object.freeze({
2476
+ [W.INPUT]: g.STRING,
2477
+ [W.TEXTAREA]: g.STRING,
2478
+ [W.INPUT_NUMBER]: null,
2479
+ // 动态判断:默认为整数
2480
+ [W.RADIO_GROUP]: g.STRING,
2481
+ [W.SELECT]: g.STRING,
2482
+ [W.CHECKBOX_GROUP]: g.ARRAY,
2483
+ [W.SWITCH]: g.BOOLEAN,
2484
+ [W.DATE_PICKER]: g.DATE,
2485
+ [W.ROW]: null
2486
+ // 布局组件,不映射
2487
+ }), T = Object.freeze({
2488
+ EQUAL: "==",
2489
+ // 等于
2490
+ NOT_EQUAL: "!=",
2491
+ // 不等于
2492
+ GREATER_THAN: ">",
2493
+ // 大于
2494
+ LESS_THAN: "<",
2495
+ // 小于
2496
+ GREATER_THAN_OR_EQUAL: ">=",
2497
+ // 大于等于
2498
+ LESS_THAN_OR_EQUAL: "<=",
2499
+ // 小于等于
2500
+ CONTAINS: "contains",
2501
+ // 包含
2502
+ NOT_CONTAINS: "not_contains",
2503
+ // 不包含
2504
+ IS_EMPTY: "is_empty",
2505
+ // 为空
2506
+ IS_NOT_EMPTY: "is_not_empty"
2507
+ // 不为空
2508
+ }), _n = Object.freeze({
2509
+ [T.EQUAL]: "等于",
2510
+ [T.NOT_EQUAL]: "不等于",
2511
+ [T.GREATER_THAN]: "大于",
2512
+ [T.LESS_THAN]: "小于",
2513
+ [T.GREATER_THAN_OR_EQUAL]: "大于等于",
2514
+ [T.LESS_THAN_OR_EQUAL]: "小于等于",
2515
+ [T.CONTAINS]: "包含",
2516
+ [T.NOT_CONTAINS]: "不包含",
2517
+ [T.IS_EMPTY]: "为空",
2518
+ [T.IS_NOT_EMPTY]: "不为空"
2519
+ }), nt = Object.freeze({
2520
+ [g.STRING]: [
2521
+ T.EQUAL,
2522
+ T.NOT_EQUAL,
2523
+ T.CONTAINS,
2524
+ T.NOT_CONTAINS,
2525
+ T.IS_EMPTY,
2526
+ T.IS_NOT_EMPTY
2527
+ ],
2528
+ [g.INTEGER]: [
2529
+ T.EQUAL,
2530
+ T.NOT_EQUAL,
2531
+ T.GREATER_THAN,
2532
+ T.LESS_THAN,
2533
+ T.GREATER_THAN_OR_EQUAL,
2534
+ T.LESS_THAN_OR_EQUAL,
2535
+ T.IS_EMPTY,
2536
+ T.IS_NOT_EMPTY
2537
+ ],
2538
+ [g.DECIMAL]: [
2539
+ T.EQUAL,
2540
+ T.NOT_EQUAL,
2541
+ T.GREATER_THAN,
2542
+ T.LESS_THAN,
2543
+ T.GREATER_THAN_OR_EQUAL,
2544
+ T.LESS_THAN_OR_EQUAL,
2545
+ T.IS_EMPTY,
2546
+ T.IS_NOT_EMPTY
2547
+ ],
2548
+ [g.DATE]: [
2549
+ T.EQUAL,
2550
+ T.NOT_EQUAL,
2551
+ T.GREATER_THAN,
2552
+ T.LESS_THAN,
2553
+ T.GREATER_THAN_OR_EQUAL,
2554
+ T.LESS_THAN_OR_EQUAL,
2555
+ T.IS_EMPTY,
2556
+ T.IS_NOT_EMPTY
2557
+ ],
2558
+ [g.DATETIME]: [
2559
+ T.EQUAL,
2560
+ T.NOT_EQUAL,
2561
+ T.GREATER_THAN,
2562
+ T.LESS_THAN,
2563
+ T.GREATER_THAN_OR_EQUAL,
2564
+ T.LESS_THAN_OR_EQUAL,
2565
+ T.IS_EMPTY,
2566
+ T.IS_NOT_EMPTY
2567
+ ],
2568
+ [g.ARRAY]: [
2569
+ T.CONTAINS,
2570
+ T.NOT_CONTAINS,
2571
+ T.IS_EMPTY,
2572
+ T.IS_NOT_EMPTY
2573
+ ],
2574
+ [g.BOOLEAN]: [
2575
+ T.EQUAL,
2576
+ T.NOT_EQUAL
2577
+ ]
2578
+ });
2579
+ function Rn(e) {
2580
+ if (!e || !e.type)
2581
+ return console.warn("组件配置无效,无法计算数据类型", e), g.STRING;
2582
+ const l = e.type;
2583
+ if (e.props, l.startsWith("internal-") || l.startsWith("text/") || l.startsWith("application/"))
2584
+ return console.warn(`检测到非组件类型: ${l},默认使用STRING类型`, e), g.STRING;
2585
+ if (l === W.INPUT_NUMBER)
2586
+ return g.INTEGER;
2587
+ if (l === W.DATE_PICKER)
2588
+ return g.DATE;
2589
+ const t = wn[l];
2590
+ return t || (console.warn(`未知的组件类型: ${l},默认使用STRING类型`), g.STRING);
2591
+ }
2592
+ function Bn(e) {
2593
+ const l = nt[e];
2594
+ return l ? l.map((t) => ({
2595
+ label: _n[t],
2596
+ value: t
2597
+ })) : (console.warn(`未知的数据类型: ${e},返回默认操作符`), nt[g.STRING]);
2598
+ }
2599
+ function Gn(e) {
2600
+ return e !== T.IS_EMPTY && e !== T.IS_NOT_EMPTY;
2601
+ }
2602
+ function Ie(e) {
2603
+ switch (e) {
2604
+ case g.INTEGER:
2605
+ case g.DECIMAL:
2606
+ return null;
2607
+ case g.ARRAY:
2608
+ return [];
2609
+ case g.BOOLEAN:
2610
+ return !1;
2611
+ case g.DATE:
2612
+ case g.DATETIME:
2613
+ case g.STRING:
2614
+ default:
2615
+ return "";
2616
+ }
2617
+ }
2618
+ function Cn(e, l) {
2619
+ if (e == null || e === "")
2620
+ return !0;
2621
+ switch (l) {
2622
+ case g.INTEGER:
2623
+ return Number.isInteger(Number(e)) && isFinite(Number(e));
2624
+ case g.DECIMAL:
2625
+ return typeof e == "number" || !isNaN(Number(e)) && isFinite(Number(e));
2626
+ case g.ARRAY:
2627
+ return Array.isArray(e);
2628
+ case g.BOOLEAN:
2629
+ return typeof e == "boolean";
2630
+ case g.DATE:
2631
+ case g.DATETIME:
2632
+ return typeof e == "string" && /^\d{4}-\d{2}-\d{2}/.test(e);
2633
+ case g.STRING:
2634
+ return typeof e == "string" || typeof e == "number";
2635
+ default:
2636
+ return !0;
2637
+ }
2638
+ }
2639
+ function zn(e) {
2640
+ return {
2641
+ [g.STRING]: "字符串",
2642
+ [g.INTEGER]: "整数",
2643
+ [g.DECIMAL]: "小数",
2644
+ [g.DATE]: "日期",
2645
+ [g.DATETIME]: "日期时间",
2646
+ [g.ARRAY]: "数组",
2647
+ [g.BOOLEAN]: "布尔值"
2648
+ }[e] || e;
2649
+ }
2650
+ function jn(e) {
2651
+ return e === g.INTEGER || e === g.DECIMAL;
2652
+ }
2653
+ function Hn(e) {
2654
+ return e === g.DATE || e === g.DATETIME;
2655
+ }
2656
+ class Ne {
2657
+ /**
2658
+ * 构造函数
2659
+ *
2660
+ * @param {Object} component - 表单组件配置(新格式)
2661
+ */
2662
+ constructor(l) {
2663
+ if (!l)
2664
+ throw new Error("FormVariable: component参数不能为空");
2665
+ const t = l.props?.variableName;
2666
+ if (!t)
2667
+ throw new Error("FormVariable: 组件必须有props.variableName属性");
2668
+ this.id = l.id, this.variableName = t, this.label = l.props?.label || t, this.componentType = l.type, this.dataType = Rn(l), this.metadata = this._extractMetadata(l), this.defaultValue = this._normalizeDefaultValue(l), this.component = l;
2669
+ }
2670
+ /**
2671
+ * 提取组件元数据
2672
+ *
2673
+ * @private
2674
+ * @param {Object} component - 组件配置
2675
+ * @returns {Object} 元数据对象
2676
+ */
2677
+ _extractMetadata(l) {
2678
+ const t = l.props || {}, r = {
2679
+ placeholder: t.placeholder || "",
2680
+ required: l.required !== !1
2681
+ // 默认为true
2682
+ };
2683
+ switch (l.type) {
2684
+ case W.RADIO_GROUP:
2685
+ r.options = Array.isArray(t.options) ? t.options : [];
2686
+ break;
2687
+ case W.INPUT_NUMBER:
2688
+ r.min = l.min != null ? Number(l.min) : void 0, r.max = l.max != null ? Number(l.max) : void 0;
2689
+ break;
2690
+ case W.DATE_PICKER:
2691
+ r.dateFormat = "date";
2692
+ break;
2693
+ }
2694
+ return r;
2695
+ }
2696
+ /**
2697
+ * 标准化默认值
2698
+ *
2699
+ * @private
2700
+ * @param {Object} component - 组件配置
2701
+ * @returns {any} 标准化后的默认值
2702
+ */
2703
+ _normalizeDefaultValue(l) {
2704
+ const t = l.props?.defaultValue;
2705
+ return t == null || t === "" ? Ie(this.dataType) : Cn(t, this.dataType) ? this._convertValue(t, this.dataType) : (console.warn(
2706
+ `FormVariable: 默认值 "${t}" 不符合类型 "${this.dataType}",使用类型默认值`,
2707
+ l
2708
+ ), Ie(this.dataType));
2709
+ }
2710
+ /**
2711
+ * 转换值到正确的类型
2712
+ *
2713
+ * @private
2714
+ * @param {any} value - 原始值
2715
+ * @param {string} dataType - 目标数据类型
2716
+ * @returns {any} 转换后的值
2717
+ */
2718
+ _convertValue(l, t) {
2719
+ if (l == null || l === "")
2720
+ return Ie(t);
2721
+ switch (t) {
2722
+ case g.INTEGER:
2723
+ return parseInt(l, 10);
2724
+ case g.DECIMAL:
2725
+ return parseFloat(l);
2726
+ case g.ARRAY:
2727
+ return Array.isArray(l) ? l : [];
2728
+ case g.BOOLEAN:
2729
+ return !!l;
2730
+ case g.STRING:
2731
+ case g.DATE:
2732
+ case g.DATETIME:
2733
+ default:
2734
+ return String(l);
2735
+ }
2736
+ }
2737
+ /**
2738
+ * 获取用于条件判断的完整信息
2739
+ *
2740
+ * @returns {Object} 条件判断所需的信息
2741
+ */
2742
+ getConditionInfo() {
2743
+ return {
2744
+ variableName: this.variableName,
2745
+ label: this.label,
2746
+ dataType: this.dataType,
2747
+ componentType: this.componentType,
2748
+ options: this.metadata.options || null,
2749
+ dateFormat: this.metadata.dateFormat || null,
2750
+ isInteger: this.dataType === g.INTEGER
2751
+ };
2752
+ }
2753
+ /**
2754
+ * 判断是否有选项列表
2755
+ *
2756
+ * @returns {boolean} 是否有选项
2757
+ */
2758
+ hasOptions() {
2759
+ return Array.isArray(this.metadata.options) && this.metadata.options.length > 0;
2760
+ }
2761
+ /**
2762
+ * 获取选项列表
2763
+ *
2764
+ * @returns {Array} 选项列表
2765
+ */
2766
+ getOptions() {
2767
+ return this.metadata.options || [];
2768
+ }
2769
+ /**
2770
+ * 判断是否为数字类型
2771
+ *
2772
+ * @returns {boolean} 是否为数字类型
2773
+ */
2774
+ isNumeric() {
2775
+ return this.dataType === g.INTEGER || this.dataType === g.DECIMAL;
2776
+ }
2777
+ /**
2778
+ * 判断是否为日期类型
2779
+ *
2780
+ * @returns {boolean} 是否为日期类型
2781
+ */
2782
+ isDate() {
2783
+ return this.dataType === g.DATE || this.dataType === g.DATETIME;
2784
+ }
2785
+ /**
2786
+ * 判断是否为整数类型
2787
+ *
2788
+ * @returns {boolean} 是否为整数类型
2789
+ */
2790
+ isInteger() {
2791
+ return this.dataType === g.INTEGER;
2792
+ }
2793
+ /**
2794
+ * 获取日期格式
2795
+ *
2796
+ * @returns {string|null} 日期格式('date' 或 'datetime')
2797
+ */
2798
+ getDateFormat() {
2799
+ return this.metadata.dateFormat || null;
2800
+ }
2801
+ /**
2802
+ * 转换为简单对象(用于序列化)
2803
+ *
2804
+ * @returns {Object} 简单对象
2805
+ */
2806
+ toJSON() {
2807
+ return {
2808
+ id: this.id,
2809
+ variableName: this.variableName,
2810
+ label: this.label,
2811
+ componentType: this.componentType,
2812
+ dataType: this.dataType,
2813
+ metadata: this.metadata,
2814
+ defaultValue: this.defaultValue
2815
+ };
2816
+ }
2817
+ /**
2818
+ * 从简单对象创建FormVariable实例
2819
+ *
2820
+ * @static
2821
+ * @param {Object} json - 简单对象
2822
+ * @returns {FormVariable} FormVariable实例
2823
+ */
2824
+ static fromJSON(l) {
2825
+ const t = {
2826
+ id: l.id,
2827
+ type: l.componentType,
2828
+ field: l.variableName,
2829
+ name: l.label,
2830
+ props: {
2831
+ ...l.metadata
2832
+ }
2833
+ };
2834
+ return new Ne(t);
2835
+ }
2836
+ /**
2837
+ * 批量转换组件列表为FormVariable数组(新格式)
2838
+ *
2839
+ * @static
2840
+ * @param {Array} components - 组件配置数组(新格式)
2841
+ * @returns {Array<FormVariable>} FormVariable数组
2842
+ */
2843
+ static fromComponents(l) {
2844
+ return Array.isArray(l) ? l.filter((t) => !(!t || !t.props?.variableName || t.type === W.ROW)).map((t) => {
2845
+ try {
2846
+ return new Ne(t);
2847
+ } catch (r) {
2848
+ return console.error("FormVariable.fromComponents: 创建FormVariable失败", r, t), null;
2849
+ }
2850
+ }).filter((t) => t !== null) : (console.warn("FormVariable.fromComponents: components必须是数组"), []);
2851
+ }
2852
+ /**
2853
+ * 验证FormVariable对象的有效性
2854
+ *
2855
+ * @static
2856
+ * @param {any} obj - 要验证的对象
2857
+ * @returns {boolean} 是否为有效的FormVariable
2858
+ */
2859
+ static isValid(l) {
2860
+ return l ? typeof l.variableName == "string" && typeof l.label == "string" && typeof l.componentType == "string" && typeof l.dataType == "string" && typeof l.metadata == "object" : !1;
2861
+ }
2862
+ }
2863
+ function Wn(e) {
2864
+ return e?.components ? e.components.filter(
2865
+ (l) => l?.type === "row" || l?.props?.variableName && l?.props?.label
2866
+ ) : [];
2867
+ }
2868
+ function $e(e) {
2869
+ return Array.isArray(e) ? e.reduce((l, t) => (t && (t.type === "row" && t.children ? t.children.forEach((r) => {
2870
+ Array.isArray(r) && l.push(...$e(r));
2871
+ }) : t.props?.variableName && l.push(t)), l), []) : [];
2872
+ }
2873
+ function qn(e) {
2874
+ if (!Array.isArray(e)) return [];
2875
+ if (e.length > 0 && e[0] instanceof Ne)
2876
+ return e;
2877
+ const l = $e(e);
2878
+ return Ne.fromComponents(l);
2879
+ }
2880
+ function Jn(e, l) {
2881
+ return Array.isArray(e) && e.find((t) => t.variableName === l) || null;
2882
+ }
2883
+ function Yn(e) {
2884
+ const l = [];
2885
+ return e ? (e.type || l.push("组件类型不能为空"), e.props ? (e.props.variableName || l.push("变量名不能为空"), e.props.label || l.push("标签不能为空"), ["select", "radio", "checkbox"].includes(e.type) && (Array.isArray(e.props.options) && e.props.options.length > 0 || l.push(`${e.type}类型必须配置选项列表`))) : l.push("组件属性不能为空"), {
2886
+ valid: l.length === 0,
2887
+ errors: l
2888
+ }) : (l.push("组件配置不能为空"), { valid: !1, errors: l });
2889
+ }
2890
+ function Kn(e) {
2891
+ return $e(e).length;
2892
+ }
2893
+ const Vn = [An, ut], xn = "0.1.0", Qn = {
2894
+ version: xn,
2895
+ install(e) {
2896
+ Vn.forEach((l) => {
2897
+ l.name && e.component(l.name, l);
2898
+ });
2899
+ }
2900
+ };
2901
+ export {
2902
+ g as BaseDataType,
2903
+ et as COMPONENT_CATEGORIES,
2904
+ d as COMPONENT_TYPES,
2905
+ xt as COMPONENT_TYPE_LABELS,
2906
+ W as ComponentType,
2907
+ T as ConditionOperator,
2908
+ nt as DATA_TYPE_OPERATORS_MAP,
2909
+ Mn as DEFAULT_CONFIG,
2910
+ an as FORM_KIND,
2911
+ Bt as FcCanvasField,
2912
+ An as FormDesigner,
2913
+ Ne as FormVariable,
2914
+ ut as FormViewer,
2915
+ _n as OPERATOR_LABEL_MAP,
2916
+ Ke as OPTION_COMPONENT_TYPES,
2917
+ on as SCHEMA_VERSION,
2918
+ Ln as WIDTH_PRESETS,
2919
+ Rn as computeDataType,
2920
+ Kn as countFormComponents,
2921
+ Qn as default,
2922
+ cn as downloadJSON,
2923
+ dn as downloadText,
2924
+ qn as enrichFormVariables,
2925
+ at as ensureComponentId,
2926
+ tt as exportForm,
2927
+ Wn as filterValidComponents,
2928
+ Jn as findFormVariable,
2929
+ Oe as generateComponentId,
2930
+ $e as getAllFormComponents,
2931
+ zn as getDataTypeLabel,
2932
+ Z as getFieldName,
2933
+ Bn as getOperatorsForDataType,
2934
+ Ie as getTypeDefaultValue,
2935
+ lt as importForm,
2936
+ Hn as isDateType,
2937
+ rt as isEmpty,
2938
+ jn as isNumericType,
2939
+ Cn as isValidValueForType,
2940
+ Se as normalizeForm,
2941
+ De as normalizeNumberValue,
2942
+ kt as normalizeOptions,
2943
+ Gn as operatorNeedsValue,
2944
+ It as parseWidth,
2945
+ mn as pickJSONFile,
2946
+ pn as readTextFile,
2947
+ Fn as sanitizeFileName,
2948
+ Yn as validateComponentConfig,
2949
+ Ue as validateForm,
2950
+ xn as version
2951
+ };
2952
+ //# sourceMappingURL=gbformdesign.js.map