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