dynamicformdjx 0.3.2 → 0.3.4
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/README.md +90 -0
- package/dist/elementPlus/index.cjs +1 -1
- package/dist/elementPlus/index.mjs +1 -1
- package/dist/hooks/useDyForm.d.ts +4 -1
- package/dist/index-CA3F2Lxo.cjs +1 -0
- package/dist/index-MF72-iEr.js +34 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +63 -60
- package/dist/naiveUi/hooks/decorateForm.d.ts +8 -0
- package/dist/naiveUi/hooks/renderForm.d.ts +1 -1
- package/dist/naiveUi/index.cjs +1 -1
- package/dist/naiveUi/index.d.ts +1 -0
- package/dist/naiveUi/index.mjs +324 -298
- package/dist/utils/tools.d.ts +3 -1
- package/package.json +1 -1
- package/dist/index-BWQjnQQF.cjs +0 -1
- package/dist/index-BqKRE4oH.js +0 -29
package/dist/naiveUi/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { NInput as N, NButton as
|
|
3
|
-
import { t as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as j, ref as A, watch as z, toRaw as S, createVNode as o, createTextVNode as C, Fragment as F, nextTick as $, isVNode as L, computed as I, mergeProps as G, h as b, shallowReactive as M } from "vue";
|
|
2
|
+
import { NInput as N, NButton as p, NForm as U, NGrid as B, NFormItemGridItem as H, NFormItem as q, NSelect as _, NPopselect as E, NTreeSelect as K, NRadioGroup as w, NRadio as J, NRadioButton as Q, NCheckboxGroup as W, NSpace as X, NCheckbox as Y, NSwitch as Z, NDatePicker as ee, NTimePicker as le } from "naive-ui";
|
|
3
|
+
import { t as R, r as P, f as O, p as te, s as ne, e as re } from "../index-MF72-iEr.js";
|
|
4
|
+
const Ce = /* @__PURE__ */ j({
|
|
5
5
|
name: "NaiDynamicInput",
|
|
6
6
|
props: {
|
|
7
7
|
size: {
|
|
@@ -15,7 +15,7 @@ const oe = /* @__PURE__ */ V({
|
|
|
15
15
|
},
|
|
16
16
|
randomFun: {
|
|
17
17
|
type: Function,
|
|
18
|
-
default: (
|
|
18
|
+
default: (l) => `${Date.now()}_${l ?? 0}`
|
|
19
19
|
},
|
|
20
20
|
btnConfigs: {
|
|
21
21
|
type: Object
|
|
@@ -32,153 +32,153 @@ const oe = /* @__PURE__ */ V({
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
emits: {
|
|
35
|
-
"update:modelValue": (
|
|
35
|
+
"update:modelValue": (l) => !0,
|
|
36
36
|
onReset: () => !0,
|
|
37
|
-
onMerge: (
|
|
37
|
+
onMerge: (l, s) => !0
|
|
38
38
|
},
|
|
39
|
-
setup(
|
|
40
|
-
emit:
|
|
39
|
+
setup(l, {
|
|
40
|
+
emit: s,
|
|
41
41
|
expose: d
|
|
42
42
|
}) {
|
|
43
|
-
const
|
|
43
|
+
const n = {
|
|
44
44
|
resetTxt: "重置",
|
|
45
45
|
newTxt: "添加项",
|
|
46
46
|
mergeTxt: "合并",
|
|
47
|
-
...
|
|
48
|
-
},
|
|
47
|
+
...l.btnConfigs
|
|
48
|
+
}, e = {
|
|
49
49
|
hideReset: !1,
|
|
50
50
|
maxHeight: "300px",
|
|
51
51
|
autoScroll: !0,
|
|
52
52
|
allowFilter: !0,
|
|
53
|
-
...
|
|
54
|
-
},
|
|
53
|
+
...l.configs
|
|
54
|
+
}, i = {
|
|
55
55
|
arraySplitSymbol: ",",
|
|
56
|
-
...
|
|
57
|
-
}, y =
|
|
58
|
-
return
|
|
59
|
-
if (!
|
|
60
|
-
const v =
|
|
61
|
-
|
|
56
|
+
...l.dyListConfigs
|
|
57
|
+
}, y = l.size, c = A(R(l.modelValue, l.randomFun, i.arraySplitSymbol)), m = A(null);
|
|
58
|
+
return z(c, (a) => {
|
|
59
|
+
if (!l.isController) return;
|
|
60
|
+
const v = P(a, i.arraySplitSymbol);
|
|
61
|
+
s("update:modelValue", v), s("onMerge", v, S(c.value));
|
|
62
62
|
}, {
|
|
63
63
|
deep: !0
|
|
64
64
|
}), d({
|
|
65
|
-
onSet: (
|
|
66
|
-
|
|
65
|
+
onSet: (a) => {
|
|
66
|
+
c.value = R(a ?? l.modelValue, l.randomFun, i.arraySplitSymbol);
|
|
67
67
|
},
|
|
68
|
-
getResult: (
|
|
69
|
-
}), () =>
|
|
70
|
-
class:
|
|
71
|
-
}, [
|
|
72
|
-
class: `dyFormList ${
|
|
68
|
+
getResult: (a = "res") => a === "ori" ? S(c.value) : P(c.value, i.arraySplitSymbol)
|
|
69
|
+
}), () => o("div", {
|
|
70
|
+
class: l.dyCls ?? `dynamicForm ${y}`
|
|
71
|
+
}, [o("div", {
|
|
72
|
+
class: `dyFormList ${c.value.length ? "" : "noList"}`,
|
|
73
73
|
ref: m,
|
|
74
74
|
style: {
|
|
75
|
-
maxHeight:
|
|
75
|
+
maxHeight: e.maxHeight
|
|
76
76
|
}
|
|
77
|
-
}, [
|
|
77
|
+
}, [c.value.map((a, v, t) => o("div", {
|
|
78
78
|
class: "dItem",
|
|
79
|
-
key:
|
|
80
|
-
}, [
|
|
79
|
+
key: a.rId
|
|
80
|
+
}, [o("div", {
|
|
81
81
|
class: "input"
|
|
82
|
-
}, [
|
|
82
|
+
}, [o(N, {
|
|
83
83
|
size: y,
|
|
84
|
-
value:
|
|
84
|
+
value: a.key,
|
|
85
85
|
class: "key",
|
|
86
|
-
onInput: (
|
|
87
|
-
|
|
86
|
+
onInput: (r) => {
|
|
87
|
+
a.key = r;
|
|
88
88
|
}
|
|
89
|
-
}, null), C(":"),
|
|
89
|
+
}, null), C(":"), o(N, {
|
|
90
90
|
size: y,
|
|
91
|
-
value:
|
|
91
|
+
value: a.value,
|
|
92
92
|
class: "value",
|
|
93
|
-
onInput: (
|
|
94
|
-
|
|
93
|
+
onInput: (r) => {
|
|
94
|
+
e.allowFilter && a.isNumber ? a.value = O(r, a.isArray, i.arraySplitSymbol) : a.value = r;
|
|
95
95
|
}
|
|
96
96
|
}, {
|
|
97
|
-
prefix: () =>
|
|
98
|
-
type:
|
|
97
|
+
prefix: () => o(F, null, [o(p, {
|
|
98
|
+
type: a.isArray ? "success" : "default",
|
|
99
99
|
size: "tiny",
|
|
100
100
|
onClick: () => {
|
|
101
|
-
|
|
101
|
+
a.isArray = !a.isArray;
|
|
102
102
|
}
|
|
103
103
|
}, {
|
|
104
104
|
default: () => [C("Array")]
|
|
105
|
-
}), C(" "),
|
|
106
|
-
type:
|
|
105
|
+
}), C(" "), o(p, {
|
|
106
|
+
type: a.isNumber ? "success" : "default",
|
|
107
107
|
size: "tiny",
|
|
108
108
|
onClick: () => {
|
|
109
|
-
|
|
109
|
+
a.isNumber = !a.isNumber;
|
|
110
110
|
}
|
|
111
111
|
}, {
|
|
112
112
|
default: () => [C("Number")]
|
|
113
113
|
})])
|
|
114
|
-
})]),
|
|
114
|
+
})]), o("div", {
|
|
115
115
|
class: "btn"
|
|
116
|
-
}, [
|
|
116
|
+
}, [o(p, {
|
|
117
117
|
type: "success",
|
|
118
118
|
size: y,
|
|
119
|
-
disabled: v !==
|
|
119
|
+
disabled: v !== t.length - 1,
|
|
120
120
|
onClick: () => {
|
|
121
|
-
|
|
122
|
-
rId:
|
|
121
|
+
c.value.push({
|
|
122
|
+
rId: l.randomFun(),
|
|
123
123
|
key: "",
|
|
124
124
|
value: ""
|
|
125
|
-
}),
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
top:
|
|
125
|
+
}), e.autoScroll && $(() => {
|
|
126
|
+
const r = m.value;
|
|
127
|
+
r?.scrollTo({
|
|
128
|
+
top: r.scrollHeight,
|
|
129
129
|
behavior: "smooth"
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
}, {
|
|
134
134
|
default: () => [C("+")]
|
|
135
|
-
}),
|
|
135
|
+
}), o(p, {
|
|
136
136
|
size: y,
|
|
137
137
|
type: "error",
|
|
138
138
|
onClick: () => {
|
|
139
|
-
|
|
139
|
+
c.value = c.value.filter((r) => r.rId !== a.rId);
|
|
140
140
|
}
|
|
141
141
|
}, {
|
|
142
142
|
default: () => [C("-")]
|
|
143
|
-
})])]))]),
|
|
144
|
-
class: `control ${
|
|
145
|
-
}, [!
|
|
143
|
+
})])]))]), o("div", {
|
|
144
|
+
class: `control ${c.value.length ? "" : "noList"}`
|
|
145
|
+
}, [!c.value.length && o(p, {
|
|
146
146
|
size: y,
|
|
147
147
|
type: "success",
|
|
148
148
|
onClick: () => {
|
|
149
|
-
|
|
150
|
-
rId:
|
|
149
|
+
c.value.push({
|
|
150
|
+
rId: l.randomFun(),
|
|
151
151
|
key: "",
|
|
152
152
|
value: ""
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
}, {
|
|
156
|
-
default: () => [
|
|
157
|
-
}), !
|
|
156
|
+
default: () => [n.newTxt]
|
|
157
|
+
}), !l.isController && o(F, null, [!e.hideReset && o(p, {
|
|
158
158
|
size: y,
|
|
159
159
|
type: "default",
|
|
160
160
|
onClick: () => {
|
|
161
|
-
|
|
161
|
+
c.value = R(l.modelValue, l.randomFun, i.arraySplitSymbol), s("onReset");
|
|
162
162
|
}
|
|
163
163
|
}, {
|
|
164
|
-
default: () => [
|
|
165
|
-
}),
|
|
164
|
+
default: () => [n.resetTxt]
|
|
165
|
+
}), o(p, {
|
|
166
166
|
size: y,
|
|
167
167
|
type: "info",
|
|
168
168
|
onClick: () => {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
169
|
+
c.value.sort((v, t) => +v.rId - +t.rId);
|
|
170
|
+
const a = P(c.value, i.arraySplitSymbol);
|
|
171
|
+
s("update:modelValue", a), s("onMerge", a, S(c.value)), c.value = R(a, l.randomFun, i.arraySplitSymbol);
|
|
172
172
|
}
|
|
173
173
|
}, {
|
|
174
|
-
default: () => [
|
|
174
|
+
default: () => [n.mergeTxt]
|
|
175
175
|
})])])]);
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
|
-
function ae(
|
|
179
|
-
return typeof
|
|
178
|
+
function ae(l) {
|
|
179
|
+
return typeof l == "function" || Object.prototype.toString.call(l) === "[object Object]" && !L(l);
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const he = /* @__PURE__ */ j({
|
|
182
182
|
name: "NaiveUiDynamicCascadeInput",
|
|
183
183
|
props: {
|
|
184
184
|
modelValue: {
|
|
@@ -193,7 +193,7 @@ const se = /* @__PURE__ */ V({
|
|
|
193
193
|
},
|
|
194
194
|
randomFun: {
|
|
195
195
|
type: Function,
|
|
196
|
-
default: (
|
|
196
|
+
default: (l) => `${Date.now()}_${l ?? 0}`
|
|
197
197
|
},
|
|
198
198
|
// 子层深度 (超过则不再出现添加选项)
|
|
199
199
|
depth: {
|
|
@@ -211,24 +211,24 @@ const se = /* @__PURE__ */ V({
|
|
|
211
211
|
},
|
|
212
212
|
newChildTxt: {
|
|
213
213
|
type: Function,
|
|
214
|
-
default: (
|
|
214
|
+
default: (l) => `添加 '${l.key}' 子项`
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
emits: {
|
|
218
|
-
"update:modelValue": (
|
|
218
|
+
"update:modelValue": (l) => !0,
|
|
219
219
|
onReset: () => !0,
|
|
220
|
-
onMerge: (
|
|
220
|
+
onMerge: (l, s) => !0
|
|
221
221
|
},
|
|
222
|
-
setup(
|
|
223
|
-
emit:
|
|
222
|
+
setup(l, {
|
|
223
|
+
emit: s,
|
|
224
224
|
expose: d
|
|
225
225
|
}) {
|
|
226
|
-
const
|
|
226
|
+
const n = {
|
|
227
227
|
resetTxt: "重置",
|
|
228
228
|
newTxt: "添加项",
|
|
229
229
|
mergeTxt: "合并",
|
|
230
|
-
...
|
|
231
|
-
},
|
|
230
|
+
...l.btnConfigs
|
|
231
|
+
}, e = {
|
|
232
232
|
hideReset: !1,
|
|
233
233
|
maxHeight: "600px",
|
|
234
234
|
allowFilter: !0,
|
|
@@ -236,108 +236,108 @@ const se = /* @__PURE__ */ V({
|
|
|
236
236
|
showPad: !0,
|
|
237
237
|
retractLen: 0,
|
|
238
238
|
borderColors: [],
|
|
239
|
-
...
|
|
240
|
-
},
|
|
239
|
+
...l.configs
|
|
240
|
+
}, i = {
|
|
241
241
|
arraySplitSymbol: ",",
|
|
242
|
-
...
|
|
243
|
-
}, y = (
|
|
244
|
-
let
|
|
245
|
-
const h = Array.isArray(
|
|
246
|
-
return y(typeof
|
|
247
|
-
rId:
|
|
248
|
-
key:
|
|
249
|
-
value: Object.prototype.toString.call(
|
|
242
|
+
...l.dyListConfigs
|
|
243
|
+
}, y = (t) => ["string", "number"].includes(t), c = (t) => Object.keys(t).map((r, f) => {
|
|
244
|
+
let u = t[r];
|
|
245
|
+
const h = Array.isArray(u), T = h ? u.every((x) => typeof x == "number") : typeof u == "number", k = u === null;
|
|
246
|
+
return y(typeof u) && (u = t[r]), k && (u = ""), {
|
|
247
|
+
rId: l.randomFun(f),
|
|
248
|
+
key: r,
|
|
249
|
+
value: Object.prototype.toString.call(u) === "[object Object]" ? c(t[r]) : h ? u.join(i.arraySplitSymbol) : u,
|
|
250
250
|
isArray: h || void 0,
|
|
251
251
|
isNumber: T || void 0
|
|
252
252
|
};
|
|
253
|
-
}), m = (
|
|
254
|
-
const
|
|
255
|
-
return f.key.trim().length && (
|
|
256
|
-
}, {}),
|
|
257
|
-
class: [`depth-${
|
|
253
|
+
}), m = (t) => t.reduce((r, f) => {
|
|
254
|
+
const u = f.value;
|
|
255
|
+
return f.key.trim().length && (r[f.key] = Array.isArray(u) ? m(u) : te(f.value, f.isArray, f.isNumber, i.arraySplitSymbol)), r;
|
|
256
|
+
}, {}), a = A(c(l.modelValue)), v = (t, r = 1, f) => o("div", {
|
|
257
|
+
class: [`depth-${r}`, e.showBorder ? "" : "no-border", e.showPad ? "" : "no-pad"],
|
|
258
258
|
style: {
|
|
259
|
-
"--depth":
|
|
260
|
-
["--c" + [
|
|
259
|
+
"--depth": r,
|
|
260
|
+
["--c" + [r]]: ne(e.borderColors, r)
|
|
261
261
|
}
|
|
262
|
-
}, [
|
|
263
|
-
const k = Array.isArray(
|
|
264
|
-
return
|
|
262
|
+
}, [t.map((u, h, T) => {
|
|
263
|
+
const k = Array.isArray(u.value), x = y(typeof u.value);
|
|
264
|
+
return o("div", {
|
|
265
265
|
class: "dItem",
|
|
266
|
-
key:
|
|
266
|
+
key: u.rId,
|
|
267
267
|
style: {
|
|
268
|
-
marginLeft:
|
|
268
|
+
marginLeft: r > 1 ? `${r * e.retractLen}px` : "0"
|
|
269
269
|
}
|
|
270
|
-
}, [
|
|
270
|
+
}, [o("div", {
|
|
271
271
|
class: "input"
|
|
272
|
-
}, [!k &&
|
|
273
|
-
value:
|
|
272
|
+
}, [!k && o(F, null, [o(N, {
|
|
273
|
+
value: u.key,
|
|
274
274
|
class: "key",
|
|
275
|
-
onInput: (g) =>
|
|
276
|
-
}, null), C(":")]),
|
|
275
|
+
onInput: (g) => u.key = g
|
|
276
|
+
}, null), C(":")]), o(N, {
|
|
277
277
|
class: `value ${k ? "isKey" : ""}`,
|
|
278
|
-
value: x ?
|
|
278
|
+
value: x ? u.value : u.key,
|
|
279
279
|
onInput: (g) => {
|
|
280
280
|
if (k) {
|
|
281
|
-
|
|
281
|
+
u.key = g;
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
|
|
284
|
+
e.allowFilter && u.isNumber ? u.value = O(g, u.isArray, i.arraySplitSymbol) : u.value = g;
|
|
285
285
|
}
|
|
286
286
|
}, {
|
|
287
|
-
prefix: Array.isArray(
|
|
288
|
-
type:
|
|
287
|
+
prefix: Array.isArray(u.value) ? void 0 : () => o(F, null, [o(p, {
|
|
288
|
+
type: u.isArray ? "success" : "default",
|
|
289
289
|
size: "tiny",
|
|
290
290
|
onClick: () => {
|
|
291
|
-
|
|
291
|
+
u.isArray = !u.isArray;
|
|
292
292
|
}
|
|
293
293
|
}, {
|
|
294
294
|
default: () => [C("Array")]
|
|
295
|
-
}), C(" "),
|
|
296
|
-
type:
|
|
295
|
+
}), C(" "), o(p, {
|
|
296
|
+
type: u.isNumber ? "success" : "default",
|
|
297
297
|
size: "tiny",
|
|
298
298
|
onClick: () => {
|
|
299
|
-
|
|
299
|
+
u.isNumber = !u.isNumber;
|
|
300
300
|
}
|
|
301
301
|
}, {
|
|
302
302
|
default: () => [C("Number")]
|
|
303
303
|
})]),
|
|
304
304
|
suffix: () => {
|
|
305
305
|
let g;
|
|
306
|
-
return
|
|
306
|
+
return r < l.depth ? !k && o(p, {
|
|
307
307
|
type: "success",
|
|
308
308
|
size: "tiny",
|
|
309
309
|
onClick: () => {
|
|
310
|
-
x && (
|
|
311
|
-
rId:
|
|
310
|
+
x && (u.value = [], u.isArray = void 0), u.value.push({
|
|
311
|
+
rId: l.randomFun(),
|
|
312
312
|
key: "",
|
|
313
313
|
value: ""
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
|
-
}, ae(g =
|
|
316
|
+
}, ae(g = l.newChildTxt(u)) ? g : {
|
|
317
317
|
default: () => [g]
|
|
318
318
|
}) : null;
|
|
319
319
|
}
|
|
320
|
-
})]),
|
|
320
|
+
})]), o("div", {
|
|
321
321
|
class: "btn"
|
|
322
|
-
}, [
|
|
322
|
+
}, [o(p, {
|
|
323
323
|
type: "success",
|
|
324
324
|
disabled: h !== T.length - 1,
|
|
325
325
|
onClick: () => {
|
|
326
|
-
|
|
327
|
-
rId:
|
|
326
|
+
t.push({
|
|
327
|
+
rId: l.randomFun(),
|
|
328
328
|
key: "",
|
|
329
329
|
value: ""
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
}, {
|
|
333
333
|
default: () => [C("+")]
|
|
334
|
-
}),
|
|
334
|
+
}), o(p, {
|
|
335
335
|
type: "error",
|
|
336
336
|
onClick: () => {
|
|
337
|
-
if (
|
|
337
|
+
if (t.splice(h, 1), t.length < 1) {
|
|
338
338
|
if (f === void 0) return m([]);
|
|
339
|
-
const g =
|
|
340
|
-
|
|
339
|
+
const g = a.value.findIndex((D) => D.rId === f?.rId);
|
|
340
|
+
r < 1 ? a.value.splice(g, 1, {
|
|
341
341
|
...f,
|
|
342
342
|
value: ""
|
|
343
343
|
}) : f.value = "";
|
|
@@ -345,57 +345,57 @@ const se = /* @__PURE__ */ V({
|
|
|
345
345
|
}
|
|
346
346
|
}, {
|
|
347
347
|
default: () => [C("-")]
|
|
348
|
-
})]), Array.isArray(
|
|
348
|
+
})]), Array.isArray(u.value) && v(u.value, r + 1, u)]);
|
|
349
349
|
})]);
|
|
350
|
-
return
|
|
351
|
-
if (!
|
|
352
|
-
const
|
|
353
|
-
|
|
350
|
+
return z(a, (t) => {
|
|
351
|
+
if (!l.isController) return;
|
|
352
|
+
const r = m(t);
|
|
353
|
+
s("update:modelValue", r), s("onMerge", r, S(a.value));
|
|
354
354
|
}, {
|
|
355
355
|
deep: !0
|
|
356
356
|
}), d({
|
|
357
|
-
onSet: (
|
|
358
|
-
|
|
357
|
+
onSet: (t) => {
|
|
358
|
+
a.value = c(t ?? l.modelValue);
|
|
359
359
|
},
|
|
360
|
-
getResult: (
|
|
361
|
-
}), () =>
|
|
362
|
-
class:
|
|
363
|
-
}, [
|
|
360
|
+
getResult: (t = "res") => t === "ori" ? S(a.value) : m(a.value)
|
|
361
|
+
}), () => o("div", {
|
|
362
|
+
class: l.dyCls ?? "dynamicCascadeForm"
|
|
363
|
+
}, [o("div", {
|
|
364
364
|
class: "dyFormList",
|
|
365
365
|
style: {
|
|
366
|
-
maxHeight:
|
|
366
|
+
maxHeight: e.maxHeight
|
|
367
367
|
}
|
|
368
|
-
}, [v(
|
|
368
|
+
}, [v(a.value)]), o("div", {
|
|
369
369
|
class: "control"
|
|
370
|
-
}, [!
|
|
370
|
+
}, [!a.value.length && o(p, {
|
|
371
371
|
type: "success",
|
|
372
372
|
onClick: () => {
|
|
373
|
-
|
|
374
|
-
rId:
|
|
373
|
+
a.value.push({
|
|
374
|
+
rId: l.randomFun(),
|
|
375
375
|
key: "",
|
|
376
376
|
value: ""
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
}, {
|
|
380
|
-
default: () => [
|
|
381
|
-
}), !
|
|
380
|
+
default: () => [n.newTxt]
|
|
381
|
+
}), !l.isController && o(F, null, [!e.hideReset && o(p, {
|
|
382
382
|
type: "default",
|
|
383
383
|
onClick: () => {
|
|
384
|
-
|
|
384
|
+
a.value = c(l.modelValue), s("onReset");
|
|
385
385
|
}
|
|
386
386
|
}, {
|
|
387
|
-
default: () => [
|
|
388
|
-
}),
|
|
387
|
+
default: () => [n.resetTxt]
|
|
388
|
+
}), o(p, {
|
|
389
389
|
type: "info",
|
|
390
390
|
onClick: () => {
|
|
391
|
-
const
|
|
392
|
-
|
|
391
|
+
const t = m(a.value);
|
|
392
|
+
s("update:modelValue", t), s("onMerge", t, S(a.value)), a.value = c(t);
|
|
393
393
|
}
|
|
394
394
|
}, {
|
|
395
|
-
default: () => [
|
|
395
|
+
default: () => [n.mergeTxt]
|
|
396
396
|
})])])]);
|
|
397
397
|
}
|
|
398
|
-
}),
|
|
398
|
+
}), ke = /* @__PURE__ */ j({
|
|
399
399
|
name: "NaiDynamicForm",
|
|
400
400
|
props: {
|
|
401
401
|
formConfig: {
|
|
@@ -419,217 +419,217 @@ const se = /* @__PURE__ */ V({
|
|
|
419
419
|
preset: {
|
|
420
420
|
type: String,
|
|
421
421
|
default: "fullRow",
|
|
422
|
-
validator: (
|
|
422
|
+
validator: (l) => ["fullRow", "grid"].includes(l) ? !0 : (console.error("preset value must be `fullRow` or `grid`, the default value is `fullRow`"), !1)
|
|
423
423
|
},
|
|
424
424
|
items: {
|
|
425
425
|
type: Array,
|
|
426
426
|
require: !0
|
|
427
427
|
}
|
|
428
428
|
},
|
|
429
|
-
setup(
|
|
430
|
-
emit:
|
|
429
|
+
setup(l, {
|
|
430
|
+
emit: s,
|
|
431
431
|
expose: d
|
|
432
432
|
}) {
|
|
433
|
-
const
|
|
434
|
-
...
|
|
435
|
-
let f =
|
|
436
|
-
return
|
|
433
|
+
const n = A(null), e = I(() => (l.items ?? []).filter((v) => !v.hidden)), i = I(() => e.value ? e.value.reduce((v, t) => (v[t.key] = t.value.value, v), {}) : {}), y = I(() => ({
|
|
434
|
+
...e.value?.reduce((t, r) => {
|
|
435
|
+
let f = r.rule;
|
|
436
|
+
return r.required && !r.rule && (f = {
|
|
437
437
|
required: !0,
|
|
438
|
-
message: `${
|
|
438
|
+
message: `${r.label}不能为空`,
|
|
439
439
|
trigger: ["blur"]
|
|
440
|
-
}),
|
|
440
|
+
}), t[r.key] = f, t;
|
|
441
441
|
}, {}),
|
|
442
|
-
...
|
|
443
|
-
})),
|
|
444
|
-
const f =
|
|
445
|
-
return Number(f) - Number(
|
|
442
|
+
...l.rules
|
|
443
|
+
})), c = I(() => [...e.value].sort((t, r) => {
|
|
444
|
+
const f = t.sort ?? 1 / 0, u = r.sort ?? 1 / 0;
|
|
445
|
+
return Number(f) - Number(u);
|
|
446
446
|
}));
|
|
447
447
|
function m(v = null) {
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
e.value && e.value.forEach((t) => {
|
|
449
|
+
t.reset ? t.reset(t) : t.value.value = v;
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
return new Promise((v,
|
|
454
|
-
|
|
455
|
-
|
|
452
|
+
function a() {
|
|
453
|
+
return new Promise((v, t) => {
|
|
454
|
+
n.value?.validate((r) => {
|
|
455
|
+
r ? t(r) : v(i.value);
|
|
456
456
|
});
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
459
|
if (d({
|
|
460
460
|
reset: m,
|
|
461
|
-
validator:
|
|
462
|
-
getResult: (v = "res") => v === "ori" ?
|
|
463
|
-
}), !
|
|
464
|
-
return () =>
|
|
461
|
+
validator: a,
|
|
462
|
+
getResult: (v = "res") => v === "ori" ? e.value : i.value
|
|
463
|
+
}), !l.items) throw new Error("prop items must be not null");
|
|
464
|
+
return () => o("div", {
|
|
465
465
|
class: "naiDynamicForm"
|
|
466
|
-
}, [
|
|
467
|
-
ref:
|
|
468
|
-
},
|
|
469
|
-
model:
|
|
466
|
+
}, [o(U, G({
|
|
467
|
+
ref: n
|
|
468
|
+
}, l.formConfig, {
|
|
469
|
+
model: i.value,
|
|
470
470
|
rules: y.value
|
|
471
471
|
}), {
|
|
472
472
|
default() {
|
|
473
|
-
const v =
|
|
474
|
-
return
|
|
475
|
-
...
|
|
473
|
+
const v = c.value;
|
|
474
|
+
return l.preset === "grid" ? b(B, {
|
|
475
|
+
...l.gridConfig
|
|
476
476
|
}, {
|
|
477
|
-
default: () => v?.map((
|
|
478
|
-
label:
|
|
479
|
-
path:
|
|
477
|
+
default: () => v?.map((t) => b(H, {
|
|
478
|
+
label: t.label,
|
|
479
|
+
path: t.path || t.key
|
|
480
480
|
}, {
|
|
481
|
-
default:
|
|
481
|
+
default: V(t)
|
|
482
482
|
}))
|
|
483
|
-
}) : v?.map((
|
|
484
|
-
label:
|
|
485
|
-
path:
|
|
483
|
+
}) : v?.map((t) => b(q, {
|
|
484
|
+
label: t.label,
|
|
485
|
+
path: t.path || t.key
|
|
486
486
|
}, {
|
|
487
|
-
default:
|
|
487
|
+
default: V(t)
|
|
488
488
|
}));
|
|
489
489
|
}
|
|
490
490
|
})]);
|
|
491
491
|
}
|
|
492
492
|
});
|
|
493
|
-
function
|
|
493
|
+
function V(l) {
|
|
494
494
|
return function() {
|
|
495
|
-
return
|
|
495
|
+
return l.render2 ? l.render2(l) : null;
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
return
|
|
498
|
+
function ue(l, s = {}, d) {
|
|
499
|
+
return b(N, {
|
|
500
500
|
...d,
|
|
501
|
-
value:
|
|
502
|
-
onUpdateValue: (
|
|
503
|
-
|
|
501
|
+
value: l.value,
|
|
502
|
+
onUpdateValue: (n) => {
|
|
503
|
+
l.value = n, d?.onChange?.(n, d);
|
|
504
504
|
},
|
|
505
|
-
...
|
|
505
|
+
...s
|
|
506
506
|
});
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
return
|
|
510
|
-
...
|
|
511
|
-
value:
|
|
512
|
-
options:
|
|
513
|
-
onUpdateValue: (
|
|
514
|
-
|
|
508
|
+
function oe(l, s, d = {}, n) {
|
|
509
|
+
return b(_, {
|
|
510
|
+
...n,
|
|
511
|
+
value: l.value,
|
|
512
|
+
options: s,
|
|
513
|
+
onUpdateValue: (e) => {
|
|
514
|
+
l.value = e, n?.onChange?.(e, n, s);
|
|
515
515
|
},
|
|
516
516
|
...d
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
const { value:
|
|
521
|
-
return
|
|
522
|
-
|
|
519
|
+
function se(l, s, d = {}, n, e) {
|
|
520
|
+
const { value: i, labelField: y, valueField: c, ...m } = n, a = y ?? "label", v = c ?? "value", t = m.options ?? s;
|
|
521
|
+
return o(
|
|
522
|
+
E,
|
|
523
523
|
{
|
|
524
524
|
...m,
|
|
525
|
-
value:
|
|
526
|
-
onUpdateValue: (
|
|
527
|
-
|
|
525
|
+
value: l.value,
|
|
526
|
+
onUpdateValue: (r) => {
|
|
527
|
+
l.value = r, n?.onChange?.(r, n, t);
|
|
528
528
|
},
|
|
529
|
-
options:
|
|
529
|
+
options: t.map((r) => ({ ...r, label: r[a], value: r[v] })),
|
|
530
530
|
...d
|
|
531
531
|
},
|
|
532
532
|
{
|
|
533
|
-
default: () =>
|
|
534
|
-
default: () =>
|
|
533
|
+
default: () => e ?? o(p, null, {
|
|
534
|
+
default: () => l.value || "请选择"
|
|
535
535
|
})
|
|
536
536
|
}
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
|
-
function
|
|
540
|
-
const { valueField:
|
|
541
|
-
return
|
|
542
|
-
...
|
|
543
|
-
value:
|
|
544
|
-
options:
|
|
539
|
+
function ie(l, s, d = {}, n) {
|
|
540
|
+
const { valueField: e = "value", ...i } = n;
|
|
541
|
+
return b(K, {
|
|
542
|
+
...i,
|
|
543
|
+
value: l.value,
|
|
544
|
+
options: s,
|
|
545
545
|
onUpdateValue: (y) => {
|
|
546
|
-
|
|
546
|
+
l.value = y, n?.onChange?.(y, n, s);
|
|
547
547
|
},
|
|
548
|
-
keyField:
|
|
548
|
+
keyField: e,
|
|
549
549
|
...d
|
|
550
550
|
});
|
|
551
551
|
}
|
|
552
|
-
function
|
|
553
|
-
return
|
|
554
|
-
|
|
552
|
+
function de(l, s, d = {}, n) {
|
|
553
|
+
return b(
|
|
554
|
+
w,
|
|
555
555
|
{
|
|
556
|
-
...
|
|
557
|
-
value:
|
|
558
|
-
onUpdateValue: (
|
|
559
|
-
|
|
556
|
+
...n,
|
|
557
|
+
value: l.value,
|
|
558
|
+
onUpdateValue: (e) => {
|
|
559
|
+
l.value = e, n?.onChange?.(e, n, s);
|
|
560
560
|
},
|
|
561
561
|
...d
|
|
562
562
|
},
|
|
563
563
|
{
|
|
564
|
-
default: () => (
|
|
565
|
-
const y =
|
|
566
|
-
return
|
|
567
|
-
|
|
564
|
+
default: () => (n?.options ?? s).map((i) => {
|
|
565
|
+
const y = n, c = i[y?.labelField ?? "label"], m = i[y?.valueField ?? "value"];
|
|
566
|
+
return b(
|
|
567
|
+
J,
|
|
568
568
|
{
|
|
569
|
-
...
|
|
570
|
-
label:
|
|
569
|
+
...i,
|
|
570
|
+
label: c,
|
|
571
571
|
value: m
|
|
572
572
|
},
|
|
573
573
|
{
|
|
574
|
-
default: () =>
|
|
574
|
+
default: () => i.label
|
|
575
575
|
}
|
|
576
576
|
);
|
|
577
577
|
})
|
|
578
578
|
}
|
|
579
579
|
);
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
return
|
|
583
|
-
|
|
581
|
+
function ce(l, s, d = {}, n) {
|
|
582
|
+
return o(
|
|
583
|
+
w,
|
|
584
584
|
{
|
|
585
|
-
...
|
|
586
|
-
value:
|
|
587
|
-
onUpdateValue: (
|
|
588
|
-
|
|
585
|
+
...n,
|
|
586
|
+
value: l.value,
|
|
587
|
+
onUpdateValue: (e) => {
|
|
588
|
+
l.value = e, n?.onChange?.(e, n, s);
|
|
589
589
|
},
|
|
590
590
|
...d
|
|
591
591
|
},
|
|
592
592
|
{
|
|
593
|
-
default: () => (
|
|
594
|
-
const y =
|
|
595
|
-
return
|
|
596
|
-
|
|
593
|
+
default: () => (n?.options ?? s).map((i) => {
|
|
594
|
+
const y = n, c = i[y?.labelField ?? "label"], m = i[y?.valueField ?? "value"];
|
|
595
|
+
return o(
|
|
596
|
+
Q,
|
|
597
597
|
{
|
|
598
|
-
...
|
|
599
|
-
label:
|
|
598
|
+
...i,
|
|
599
|
+
label: c,
|
|
600
600
|
value: m
|
|
601
601
|
},
|
|
602
602
|
{
|
|
603
|
-
default: () =>
|
|
603
|
+
default: () => i.label
|
|
604
604
|
}
|
|
605
605
|
);
|
|
606
606
|
})
|
|
607
607
|
}
|
|
608
608
|
);
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return
|
|
612
|
-
|
|
610
|
+
function ye(l, s, d = {}, n) {
|
|
611
|
+
return b(
|
|
612
|
+
W,
|
|
613
613
|
{
|
|
614
|
-
...
|
|
615
|
-
value:
|
|
616
|
-
onUpdateValue: (
|
|
617
|
-
|
|
614
|
+
...n,
|
|
615
|
+
value: l.value,
|
|
616
|
+
onUpdateValue: (e) => {
|
|
617
|
+
l.value = e, n?.onChange?.(e, n, s);
|
|
618
618
|
},
|
|
619
619
|
...d
|
|
620
620
|
},
|
|
621
621
|
{
|
|
622
|
-
default: () =>
|
|
623
|
-
|
|
622
|
+
default: () => b(
|
|
623
|
+
X,
|
|
624
624
|
{
|
|
625
625
|
itemStyle: "display: flex"
|
|
626
626
|
},
|
|
627
627
|
{
|
|
628
|
-
default: () => (
|
|
629
|
-
const y =
|
|
630
|
-
return
|
|
628
|
+
default: () => (n?.options ?? s).map((i) => {
|
|
629
|
+
const y = n, c = i[y?.labelField ?? "label"], m = i[y?.valueField ?? "value"];
|
|
630
|
+
return b(Y, {
|
|
631
631
|
value: m,
|
|
632
|
-
label:
|
|
632
|
+
label: c
|
|
633
633
|
});
|
|
634
634
|
})
|
|
635
635
|
}
|
|
@@ -637,48 +637,74 @@ function be(e, o, d = {}, t) {
|
|
|
637
637
|
}
|
|
638
638
|
);
|
|
639
639
|
}
|
|
640
|
-
function
|
|
641
|
-
return
|
|
640
|
+
function ve(l, s = {}, d) {
|
|
641
|
+
return b(Z, {
|
|
642
642
|
...d,
|
|
643
|
-
value:
|
|
644
|
-
onUpdateValue: (
|
|
645
|
-
|
|
643
|
+
value: l.value,
|
|
644
|
+
onUpdateValue: (n) => {
|
|
645
|
+
l.value = n, d?.onChange?.(n, d);
|
|
646
646
|
},
|
|
647
|
-
...
|
|
647
|
+
...s
|
|
648
648
|
});
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
return
|
|
650
|
+
function me(l, s = {}, d) {
|
|
651
|
+
return b(ee, {
|
|
652
652
|
...d,
|
|
653
|
-
value:
|
|
654
|
-
onUpdateValue: (
|
|
655
|
-
|
|
653
|
+
value: l.value,
|
|
654
|
+
onUpdateValue: (n) => {
|
|
655
|
+
l.value = n, d?.onChange?.(n, d);
|
|
656
656
|
},
|
|
657
|
-
...
|
|
657
|
+
...s
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
|
-
function
|
|
661
|
-
return
|
|
660
|
+
function fe(l, s = {}, d) {
|
|
661
|
+
return b(le, {
|
|
662
662
|
...d,
|
|
663
|
-
value:
|
|
664
|
-
onUpdateValue: (
|
|
665
|
-
|
|
663
|
+
value: l.value,
|
|
664
|
+
onUpdateValue: (n) => {
|
|
665
|
+
l.value = n, d?.onChange?.(n, d);
|
|
666
666
|
},
|
|
667
|
-
...
|
|
667
|
+
...s
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function Se(l, s = !0) {
|
|
671
|
+
const d = {
|
|
672
|
+
renderInput: (e) => ue(e.value, e.renderProps ?? {}, e),
|
|
673
|
+
renderSelect: (e) => oe(e.value, e.options ?? [], e.renderProps ?? {}, e),
|
|
674
|
+
renderPopSelect: (e) => se(e.value, e.options ?? [], e.renderProps ?? {}, e),
|
|
675
|
+
renderTreeSelect: (e) => ie(e.value, e.options ?? [], e.renderProps ?? {}, e),
|
|
676
|
+
renderRadioGroup: (e) => de(e.value, e.options ?? [], e.renderProps ?? {}, e),
|
|
677
|
+
renderRadioButtonGroup: (e) => ce(e.value, e.options ?? [], e.renderProps ?? {}, e),
|
|
678
|
+
renderCheckboxGroup: (e) => ye(e.value, e.options ?? [], e.renderProps ?? {}, e),
|
|
679
|
+
renderSwitch: (e) => ve(e.value, e.renderProps ?? {}, e),
|
|
680
|
+
renderDatePicker: (e) => me(e.value, e.renderProps ?? {}, e),
|
|
681
|
+
renderTimePicker: (e) => fe(e.value, e.renderProps ?? {}, e)
|
|
682
|
+
};
|
|
683
|
+
return l.map((e) => {
|
|
684
|
+
const i = e;
|
|
685
|
+
if (i.value = re(e.value), typeof e.render2 == "function")
|
|
686
|
+
i.render2 = e.render2;
|
|
687
|
+
else if (e.renderType) {
|
|
688
|
+
const y = d[e.renderType];
|
|
689
|
+
y ? i.render2 = () => y(i) : console.warn(`[useDecorateForm] unknown renderType: ${e.renderType}`);
|
|
690
|
+
} else
|
|
691
|
+
i.render2 = () => d.renderInput(i);
|
|
692
|
+
return s ? M(i) : i;
|
|
668
693
|
});
|
|
669
694
|
}
|
|
670
695
|
export {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
696
|
+
he as NaiDynamicCascadeInput,
|
|
697
|
+
ke as NaiDynamicForm,
|
|
698
|
+
Ce as NaiDynamicInput,
|
|
699
|
+
ye as renderCheckboxGroup,
|
|
700
|
+
me as renderDatePicker,
|
|
701
|
+
ue as renderInput,
|
|
702
|
+
se as renderPopSelect,
|
|
703
|
+
ce as renderRadioButtonGroup,
|
|
704
|
+
de as renderRadioGroup,
|
|
705
|
+
oe as renderSelect,
|
|
706
|
+
ve as renderSwitch,
|
|
707
|
+
fe as renderTimePicker,
|
|
708
|
+
ie as renderTreeSelect,
|
|
709
|
+
Se as useDecorateForm
|
|
684
710
|
};
|