@fcurd/naive-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.d.ts +70 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/controls/index.d.ts +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1094 -0
- package/dist/naive-ui.css +1 -0
- package/dist/render/cell/format.d.ts +31 -0
- package/dist/render/cell/index.d.ts +6 -0
- package/dist/render/cell/inspect.d.ts +18 -0
- package/dist/render/cell/media.d.ts +19 -0
- package/dist/render/cell/shared.d.ts +9 -0
- package/dist/render/cell/tag.d.ts +61 -0
- package/dist/render/cell/text.d.ts +22 -0
- package/dist/render/index.d.ts +1 -0
- package/package.json +36 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1094 @@
|
|
|
1
|
+
import { NDatePicker as he, NInputNumber as Fe, NSelect as Ve, NSwitch as Re, NInput as Te, createDiscreteApi as Ae, NModal as Be, NDrawer as $e, NDrawerContent as De, NForm as ge, NFormItem as ne, NSpace as Q, NButton as W, NDataTable as Ie, NPagination as xe, NCard as Ee, NPopover as Me, NCode as qe, NEllipsis as we, NImage as Ke, NTag as G } from "naive-ui";
|
|
2
|
+
import { defineComponent as B, mergeModels as L, useModel as j, computed as g, createBlock as C, openBlock as h, unref as c, mergeProps as F, useSlots as ie, ref as ae, createElementBlock as T, resolveDynamicComponent as q, withCtx as P, createVNode as A, h as S, reactive as ze, watch as Ue, withModifiers as Oe, createCommentVNode as K, Fragment as H, renderList as M, renderSlot as V, createTextVNode as me, createElementVNode as ke, createSlots as le, normalizeProps as _, guardReactiveProps as J, toDisplayString as Le } from "vue";
|
|
3
|
+
import { filterFieldsBySurface as je, useCrudList as Qe, useCrudSelection as We, useCrudForm as _e, useCrudRouteSync as Je, presetActions as Y, createColumnsFromFields as Ye } from "@fcurd/core";
|
|
4
|
+
import { useRouter as Ge, useRoute as He } from "vue-router";
|
|
5
|
+
const pe = /* @__PURE__ */ B({
|
|
6
|
+
__name: "DateField",
|
|
7
|
+
props: /* @__PURE__ */ L({
|
|
8
|
+
field: {},
|
|
9
|
+
surface: { default: "form" }
|
|
10
|
+
}, {
|
|
11
|
+
modelValue: {},
|
|
12
|
+
modelModifiers: {}
|
|
13
|
+
}),
|
|
14
|
+
emits: ["update:modelValue"],
|
|
15
|
+
setup(e) {
|
|
16
|
+
const r = e, t = j(e, "modelValue"), o = g(() => r.field ? x(r.field, r.surface) : {}), a = g(() => r.field?.type === "datetime" ? "datetime" : "date"), n = g(() => {
|
|
17
|
+
const l = o.value.placeholder;
|
|
18
|
+
if (typeof l == "string")
|
|
19
|
+
return l;
|
|
20
|
+
if (r.field)
|
|
21
|
+
return typeof r.field.label == "function" ? r.field.label() : r.field.label;
|
|
22
|
+
});
|
|
23
|
+
return (l, u) => (h(), C(c(he), F({
|
|
24
|
+
value: t.value,
|
|
25
|
+
"onUpdate:value": u[0] || (u[0] = (p) => t.value = p),
|
|
26
|
+
type: a.value,
|
|
27
|
+
placeholder: n.value
|
|
28
|
+
}, o.value), null, 16, ["value", "type", "placeholder"]));
|
|
29
|
+
}
|
|
30
|
+
}), ye = /* @__PURE__ */ B({
|
|
31
|
+
__name: "DateRangeField",
|
|
32
|
+
props: /* @__PURE__ */ L({
|
|
33
|
+
field: {},
|
|
34
|
+
surface: { default: "form" }
|
|
35
|
+
}, {
|
|
36
|
+
modelValue: {},
|
|
37
|
+
modelModifiers: {}
|
|
38
|
+
}),
|
|
39
|
+
emits: ["update:modelValue"],
|
|
40
|
+
setup(e) {
|
|
41
|
+
const r = e, t = j(e, "modelValue"), o = g(() => r.field ? x(r.field, r.surface) : {}), a = g(() => r.field?.type === "datetimeRange" ? "datetimerange" : "daterange");
|
|
42
|
+
return (n, l) => (h(), C(c(he), F({
|
|
43
|
+
value: t.value,
|
|
44
|
+
"onUpdate:value": l[0] || (l[0] = (u) => t.value = u),
|
|
45
|
+
type: a.value
|
|
46
|
+
}, o.value), null, 16, ["value", "type"]));
|
|
47
|
+
}
|
|
48
|
+
}), ve = /* @__PURE__ */ B({
|
|
49
|
+
__name: "NumberField",
|
|
50
|
+
props: /* @__PURE__ */ L({
|
|
51
|
+
field: {},
|
|
52
|
+
surface: { default: "form" }
|
|
53
|
+
}, {
|
|
54
|
+
modelValue: {},
|
|
55
|
+
modelModifiers: {}
|
|
56
|
+
}),
|
|
57
|
+
emits: ["update:modelValue"],
|
|
58
|
+
setup(e) {
|
|
59
|
+
const r = e, t = j(e, "modelValue"), o = g(() => r.field ? x(r.field, r.surface) : {}), a = g(() => {
|
|
60
|
+
const n = o.value.placeholder;
|
|
61
|
+
if (typeof n == "string")
|
|
62
|
+
return n;
|
|
63
|
+
if (r.field)
|
|
64
|
+
return typeof r.field.label == "function" ? r.field.label() : r.field.label;
|
|
65
|
+
});
|
|
66
|
+
return (n, l) => (h(), C(c(Fe), F({
|
|
67
|
+
value: t.value,
|
|
68
|
+
"onUpdate:value": l[0] || (l[0] = (u) => t.value = u),
|
|
69
|
+
placeholder: a.value
|
|
70
|
+
}, o.value), null, 16, ["value", "placeholder"]));
|
|
71
|
+
}
|
|
72
|
+
}), Xe = /* @__PURE__ */ B({
|
|
73
|
+
__name: "SelectField",
|
|
74
|
+
props: /* @__PURE__ */ L({
|
|
75
|
+
field: {},
|
|
76
|
+
surface: { default: "form" }
|
|
77
|
+
}, {
|
|
78
|
+
modelValue: {},
|
|
79
|
+
modelModifiers: {}
|
|
80
|
+
}),
|
|
81
|
+
emits: ["update:modelValue"],
|
|
82
|
+
setup(e) {
|
|
83
|
+
const r = e, t = j(e, "modelValue"), o = g(() => {
|
|
84
|
+
if (!r.field)
|
|
85
|
+
return {};
|
|
86
|
+
const n = x(r.field, r.surface), l = r.field.ui?.options ?? n.options;
|
|
87
|
+
return { ...n, options: l };
|
|
88
|
+
}), a = g(() => {
|
|
89
|
+
const n = o.value.placeholder;
|
|
90
|
+
if (typeof n == "string")
|
|
91
|
+
return n;
|
|
92
|
+
if (r.field)
|
|
93
|
+
return typeof r.field.label == "function" ? r.field.label() : r.field.label;
|
|
94
|
+
});
|
|
95
|
+
return (n, l) => (h(), C(c(Ve), F({
|
|
96
|
+
value: t.value,
|
|
97
|
+
"onUpdate:value": l[0] || (l[0] = (u) => t.value = u),
|
|
98
|
+
placeholder: a.value
|
|
99
|
+
}, o.value, { style: { "min-width": "140px" } }), null, 16, ["value", "placeholder"]));
|
|
100
|
+
}
|
|
101
|
+
}), Ze = /* @__PURE__ */ B({
|
|
102
|
+
__name: "SwitchField",
|
|
103
|
+
props: /* @__PURE__ */ L({
|
|
104
|
+
field: {},
|
|
105
|
+
surface: { default: "form" }
|
|
106
|
+
}, {
|
|
107
|
+
modelValue: { type: Boolean },
|
|
108
|
+
modelModifiers: {}
|
|
109
|
+
}),
|
|
110
|
+
emits: ["update:modelValue"],
|
|
111
|
+
setup(e) {
|
|
112
|
+
const r = e, t = j(e, "modelValue"), o = g(() => r.field ? x(r.field, r.surface) : {});
|
|
113
|
+
return (a, n) => (h(), C(c(Re), F({
|
|
114
|
+
value: t.value,
|
|
115
|
+
"onUpdate:value": n[0] || (n[0] = (l) => t.value = l)
|
|
116
|
+
}, o.value), null, 16, ["value"]));
|
|
117
|
+
}
|
|
118
|
+
}), be = /* @__PURE__ */ B({
|
|
119
|
+
__name: "TextField",
|
|
120
|
+
props: /* @__PURE__ */ L({
|
|
121
|
+
field: {},
|
|
122
|
+
surface: { default: "form" }
|
|
123
|
+
}, {
|
|
124
|
+
modelValue: {},
|
|
125
|
+
modelModifiers: {}
|
|
126
|
+
}),
|
|
127
|
+
emits: ["update:modelValue"],
|
|
128
|
+
setup(e) {
|
|
129
|
+
const r = e, t = j(e, "modelValue"), o = g(() => r.field ? x(r.field, r.surface) : {}), a = g(() => {
|
|
130
|
+
const l = o.value.placeholder;
|
|
131
|
+
if (typeof l == "string")
|
|
132
|
+
return l;
|
|
133
|
+
if (r.field)
|
|
134
|
+
return typeof r.field.label == "function" ? r.field.label() : r.field.label;
|
|
135
|
+
}), n = g(() => r.field?.type === "textarea");
|
|
136
|
+
return (l, u) => (h(), C(c(Te), F({
|
|
137
|
+
value: t.value,
|
|
138
|
+
"onUpdate:value": u[0] || (u[0] = (p) => t.value = p),
|
|
139
|
+
placeholder: a.value,
|
|
140
|
+
type: n.value ? "textarea" : "text",
|
|
141
|
+
autosize: n.value,
|
|
142
|
+
resizable: n.value
|
|
143
|
+
}, o.value), null, 16, ["value", "placeholder", "type", "autosize", "resizable"]));
|
|
144
|
+
}
|
|
145
|
+
}), X = {
|
|
146
|
+
text: be,
|
|
147
|
+
textarea: be,
|
|
148
|
+
number: ve,
|
|
149
|
+
money: ve,
|
|
150
|
+
select: Xe,
|
|
151
|
+
date: pe,
|
|
152
|
+
datetime: pe,
|
|
153
|
+
dateRange: ye,
|
|
154
|
+
datetimeRange: ye,
|
|
155
|
+
switch: Ze
|
|
156
|
+
};
|
|
157
|
+
function se(e) {
|
|
158
|
+
return typeof e.label == "function" ? e.label() : e.label;
|
|
159
|
+
}
|
|
160
|
+
function x(e, r) {
|
|
161
|
+
const o = (e.ui ?? {}).control ?? {}, a = o[r];
|
|
162
|
+
if (a && typeof a == "object") {
|
|
163
|
+
const { form: p, search: v, ...d } = o;
|
|
164
|
+
return { ...d, ...a };
|
|
165
|
+
}
|
|
166
|
+
const { form: n, search: l, ...u } = o;
|
|
167
|
+
return u;
|
|
168
|
+
}
|
|
169
|
+
function ue(e, r) {
|
|
170
|
+
return (e.ui?.formItem ?? {})[r] ?? {};
|
|
171
|
+
}
|
|
172
|
+
function et(e, r) {
|
|
173
|
+
return e.map((t) => {
|
|
174
|
+
const o = typeof t.label == "function" ? t.label() : t.label, a = [`cell-${t.key}`, `cell_${t.key}`];
|
|
175
|
+
let n = null;
|
|
176
|
+
if (r?.slots) {
|
|
177
|
+
for (const u of a)
|
|
178
|
+
if (r.slots[u]) {
|
|
179
|
+
n = r.slots[u];
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const l = t.ui && typeof t.ui == "object" && !Array.isArray(t.ui) ? t.ui : {};
|
|
184
|
+
return {
|
|
185
|
+
key: t.key,
|
|
186
|
+
title: o ?? t.key,
|
|
187
|
+
width: t.width,
|
|
188
|
+
minWidth: t.minWidth,
|
|
189
|
+
fixed: t.fixed,
|
|
190
|
+
sorter: t.sortable ? "default" : void 0,
|
|
191
|
+
render: n ? (u, p) => n({ row: u, value: u[t.key], rowIndex: p }) : t.render ? (u, p) => t.render({
|
|
192
|
+
row: u,
|
|
193
|
+
value: u[t.key],
|
|
194
|
+
rowIndex: p
|
|
195
|
+
}) : r?.renderCell ? (u, p) => r.renderCell(t, u, u[t.key], p) : void 0,
|
|
196
|
+
...l
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const tt = Ae(["dialog", "message", "notification"]);
|
|
201
|
+
async function rt(e, r) {
|
|
202
|
+
return new Promise((t) => {
|
|
203
|
+
let o = !1;
|
|
204
|
+
function a(n) {
|
|
205
|
+
o || (o = !0, t(n));
|
|
206
|
+
}
|
|
207
|
+
tt.dialog.warning({
|
|
208
|
+
title: r?.title ?? "确认",
|
|
209
|
+
content: e,
|
|
210
|
+
positiveText: "确定",
|
|
211
|
+
negativeText: "取消",
|
|
212
|
+
onPositiveClick: () => a(!0),
|
|
213
|
+
onNegativeClick: () => a(!1),
|
|
214
|
+
onClose: () => a(!1)
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function ot(e, r) {
|
|
219
|
+
if (typeof window > "u")
|
|
220
|
+
return;
|
|
221
|
+
function t(a, n) {
|
|
222
|
+
const l = document.createElement("a");
|
|
223
|
+
l.href = a, n && (l.download = n), l.rel = "noopener", l.target = "_blank", l.click();
|
|
224
|
+
}
|
|
225
|
+
function o(a, n) {
|
|
226
|
+
const l = URL.createObjectURL(a);
|
|
227
|
+
t(l, n ?? r ?? "export"), setTimeout(() => URL.revokeObjectURL(l), 3e3);
|
|
228
|
+
}
|
|
229
|
+
if (e instanceof Blob) {
|
|
230
|
+
o(e, r);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if ("blob" in e) {
|
|
234
|
+
o(e.blob, e.filename ?? r);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
"url" in e && t(e.url, e.filename ?? r);
|
|
238
|
+
}
|
|
239
|
+
function Vt(e) {
|
|
240
|
+
return e;
|
|
241
|
+
}
|
|
242
|
+
function Rt(e) {
|
|
243
|
+
return e;
|
|
244
|
+
}
|
|
245
|
+
function Tt(e) {
|
|
246
|
+
return e;
|
|
247
|
+
}
|
|
248
|
+
const lt = {
|
|
249
|
+
key: 0,
|
|
250
|
+
class: "crud-form crud-form--inline"
|
|
251
|
+
}, nt = /* @__PURE__ */ B({
|
|
252
|
+
__name: "CrudForm",
|
|
253
|
+
props: {
|
|
254
|
+
form: {},
|
|
255
|
+
fields: {},
|
|
256
|
+
displayMode: { default: "modal" },
|
|
257
|
+
visible: { type: Boolean, default: !1 },
|
|
258
|
+
title: {},
|
|
259
|
+
resetOnClose: { type: Boolean, default: !0 },
|
|
260
|
+
formProps: {},
|
|
261
|
+
modalProps: {},
|
|
262
|
+
drawerProps: {},
|
|
263
|
+
drawerContentProps: {}
|
|
264
|
+
},
|
|
265
|
+
emits: ["update:visible", "submit", "cancel"],
|
|
266
|
+
setup(e, { emit: r }) {
|
|
267
|
+
const t = e, o = r, a = ie(), n = ae(null), l = g({
|
|
268
|
+
get: () => t.visible,
|
|
269
|
+
set: (f) => o("update:visible", f)
|
|
270
|
+
}), u = g(() => typeof t.title == "function" ? t.title(t.form.mode.value) : t.title ? t.title : t.form.mode.value === "edit" ? "编辑" : "新增");
|
|
271
|
+
function p() {
|
|
272
|
+
l.value = !1, o("cancel"), t.resetOnClose && (t.form.reset(), n.value?.restoreValidation?.());
|
|
273
|
+
}
|
|
274
|
+
async function v() {
|
|
275
|
+
if (n.value)
|
|
276
|
+
try {
|
|
277
|
+
await n.value.validate();
|
|
278
|
+
} catch {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const f = t.form.getSubmitData();
|
|
282
|
+
o("submit", f);
|
|
283
|
+
}
|
|
284
|
+
function d(f) {
|
|
285
|
+
const w = ue(f, "form").rule;
|
|
286
|
+
if (!f.required)
|
|
287
|
+
return w;
|
|
288
|
+
const R = {
|
|
289
|
+
required: !0,
|
|
290
|
+
message: `${se(f)}不能为空`,
|
|
291
|
+
trigger: ["input", "blur", "change"]
|
|
292
|
+
};
|
|
293
|
+
if ((f.type === "number" || f.type === "money") && (R.type = "number"), !w)
|
|
294
|
+
return [R];
|
|
295
|
+
const D = Array.isArray(w) ? w : [w];
|
|
296
|
+
return D.some((ee) => ee?.required === !0) ? D : [R, ...D];
|
|
297
|
+
}
|
|
298
|
+
function i(f) {
|
|
299
|
+
const k = X[f.type] ?? X.text, w = x(f, "form"), $ = t.form.model;
|
|
300
|
+
return S(k, {
|
|
301
|
+
modelValue: $[f.key],
|
|
302
|
+
"onUpdate:modelValue": (R) => {
|
|
303
|
+
$[f.key] = R;
|
|
304
|
+
},
|
|
305
|
+
field: f,
|
|
306
|
+
surface: "form",
|
|
307
|
+
...w
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function b() {
|
|
311
|
+
return S(
|
|
312
|
+
ge,
|
|
313
|
+
{
|
|
314
|
+
ref: n,
|
|
315
|
+
model: t.form.model,
|
|
316
|
+
...t.formProps,
|
|
317
|
+
onSubmit: (f) => {
|
|
318
|
+
f.preventDefault(), v();
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
() => [
|
|
322
|
+
t.form.visibleFields.value.map((f) => {
|
|
323
|
+
const k = `field-${f.key}`, w = a[k], $ = t.form.model, R = ue(f, "form"), { rule: D, ...U } = R ?? {};
|
|
324
|
+
return S(
|
|
325
|
+
ne,
|
|
326
|
+
{
|
|
327
|
+
key: f.key,
|
|
328
|
+
label: se(f),
|
|
329
|
+
path: f.key,
|
|
330
|
+
required: !!f.required,
|
|
331
|
+
rule: d(f),
|
|
332
|
+
...U
|
|
333
|
+
},
|
|
334
|
+
() => w ? w({ field: f, model: $, mode: t.form.mode.value, value: $[f.key] }) : i(f)
|
|
335
|
+
);
|
|
336
|
+
}),
|
|
337
|
+
// Footer
|
|
338
|
+
S("div", { class: "crud-form__footer" }, [
|
|
339
|
+
a.footer ? a.footer({ mode: t.form.mode.value, dirty: t.form.dirty.value }) : S(Q, { justify: "end" }, () => [
|
|
340
|
+
S(W, { onClick: p }, () => "取消"),
|
|
341
|
+
S(W, { type: "primary", attrType: "submit" }, () => "保存")
|
|
342
|
+
])
|
|
343
|
+
])
|
|
344
|
+
]
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
return (f, k) => e.displayMode === "inline" ? (h(), T("div", lt, [
|
|
348
|
+
(h(), C(q(() => b())))
|
|
349
|
+
])) : e.displayMode === "modal" ? (h(), C(c(Be), F({
|
|
350
|
+
key: 1,
|
|
351
|
+
show: l.value,
|
|
352
|
+
"onUpdate:show": k[0] || (k[0] = (w) => l.value = w),
|
|
353
|
+
preset: "dialog",
|
|
354
|
+
title: u.value
|
|
355
|
+
}, e.modalProps, { onAfterLeave: p }), {
|
|
356
|
+
default: P(() => [
|
|
357
|
+
(h(), C(q(() => b())))
|
|
358
|
+
]),
|
|
359
|
+
_: 1
|
|
360
|
+
}, 16, ["show", "title"])) : (h(), C(c($e), F({
|
|
361
|
+
key: 2,
|
|
362
|
+
show: l.value,
|
|
363
|
+
"onUpdate:show": k[1] || (k[1] = (w) => l.value = w),
|
|
364
|
+
width: 420,
|
|
365
|
+
placement: "right"
|
|
366
|
+
}, e.drawerProps, { onAfterLeave: p }), {
|
|
367
|
+
default: P(() => [
|
|
368
|
+
A(c(De), F({ title: u.value }, e.drawerContentProps), {
|
|
369
|
+
default: P(() => [
|
|
370
|
+
(h(), C(q(() => b())))
|
|
371
|
+
]),
|
|
372
|
+
_: 1
|
|
373
|
+
}, 16, ["title"])
|
|
374
|
+
]),
|
|
375
|
+
_: 1
|
|
376
|
+
}, 16, ["show"]));
|
|
377
|
+
}
|
|
378
|
+
}), Z = (e, r) => {
|
|
379
|
+
const t = e.__vccOpts || e;
|
|
380
|
+
for (const [o, a] of r)
|
|
381
|
+
t[o] = a;
|
|
382
|
+
return t;
|
|
383
|
+
}, at = /* @__PURE__ */ Z(nt, [["__scopeId", "data-v-0bca27a9"]]), st = { class: "crud-search" }, ut = /* @__PURE__ */ B({
|
|
384
|
+
__name: "CrudSearch",
|
|
385
|
+
props: {
|
|
386
|
+
list: {},
|
|
387
|
+
fields: {},
|
|
388
|
+
queryKey: {},
|
|
389
|
+
formProps: {},
|
|
390
|
+
showReset: { type: Boolean, default: !0 },
|
|
391
|
+
showSearch: { type: Boolean, default: !0 }
|
|
392
|
+
},
|
|
393
|
+
setup(e) {
|
|
394
|
+
const r = e;
|
|
395
|
+
function t(d) {
|
|
396
|
+
return !!d && typeof d == "object" && !Array.isArray(d);
|
|
397
|
+
}
|
|
398
|
+
function o(d) {
|
|
399
|
+
if (!r.queryKey)
|
|
400
|
+
return d;
|
|
401
|
+
const i = d?.[r.queryKey];
|
|
402
|
+
return t(i) ? i : {};
|
|
403
|
+
}
|
|
404
|
+
const a = g(() => je(r.fields, "search", {
|
|
405
|
+
query: r.list.query.value
|
|
406
|
+
})), n = g(() => a.value.map((d) => d.key)), l = ze({});
|
|
407
|
+
Ue(
|
|
408
|
+
() => r.list.query.value,
|
|
409
|
+
(d) => {
|
|
410
|
+
Object.keys(l).forEach((b) => {
|
|
411
|
+
delete l[b];
|
|
412
|
+
});
|
|
413
|
+
const i = o(d);
|
|
414
|
+
for (const b of n.value)
|
|
415
|
+
b in i && (l[b] = i[b]);
|
|
416
|
+
},
|
|
417
|
+
{ immediate: !0, deep: !0 }
|
|
418
|
+
);
|
|
419
|
+
function u() {
|
|
420
|
+
if (!r.queryKey) {
|
|
421
|
+
r.list.setQuery(l, {
|
|
422
|
+
mode: "merge",
|
|
423
|
+
clearKeys: n.value,
|
|
424
|
+
pruneEmpty: !0
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
r.list.setQuery({
|
|
429
|
+
[r.queryKey]: { ...l }
|
|
430
|
+
}, {
|
|
431
|
+
mode: "merge",
|
|
432
|
+
pruneEmpty: !0
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function p() {
|
|
436
|
+
Object.keys(l).forEach((d) => {
|
|
437
|
+
delete l[d];
|
|
438
|
+
}), r.list.reset();
|
|
439
|
+
}
|
|
440
|
+
function v(d) {
|
|
441
|
+
const i = X[d.type] ?? X.text, b = x(d, "search");
|
|
442
|
+
return S(i, {
|
|
443
|
+
modelValue: l[d.key],
|
|
444
|
+
"onUpdate:modelValue": (f) => {
|
|
445
|
+
l[d.key] = f;
|
|
446
|
+
},
|
|
447
|
+
field: d,
|
|
448
|
+
surface: "search",
|
|
449
|
+
...b
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return (d, i) => (h(), T("div", st, [
|
|
453
|
+
A(c(ge), F({
|
|
454
|
+
inline: "",
|
|
455
|
+
"label-placement": "left"
|
|
456
|
+
}, e.formProps, {
|
|
457
|
+
onSubmit: Oe(u, ["prevent"])
|
|
458
|
+
}), {
|
|
459
|
+
default: P(() => [
|
|
460
|
+
(h(!0), T(H, null, M(a.value, (b) => (h(), C(c(ne), F({
|
|
461
|
+
key: b.key,
|
|
462
|
+
label: c(se)(b)
|
|
463
|
+
}, { ref_for: !0 }, c(ue)(b, "search")), {
|
|
464
|
+
default: P(() => [
|
|
465
|
+
V(d.$slots, `search-${b.key}`, {
|
|
466
|
+
field: b,
|
|
467
|
+
model: l
|
|
468
|
+
}, () => [
|
|
469
|
+
(h(), C(q(() => v(b))))
|
|
470
|
+
], !0)
|
|
471
|
+
]),
|
|
472
|
+
_: 2
|
|
473
|
+
}, 1040, ["label"]))), 128)),
|
|
474
|
+
e.showSearch || e.showReset ? (h(), C(c(ne), { key: 0 }, {
|
|
475
|
+
default: P(() => [
|
|
476
|
+
A(c(Q), null, {
|
|
477
|
+
default: P(() => [
|
|
478
|
+
e.showSearch ? (h(), C(c(W), {
|
|
479
|
+
key: 0,
|
|
480
|
+
type: "primary",
|
|
481
|
+
"attr-type": "submit"
|
|
482
|
+
}, {
|
|
483
|
+
default: P(() => [...i[0] || (i[0] = [
|
|
484
|
+
me(" 搜索 ", -1)
|
|
485
|
+
])]),
|
|
486
|
+
_: 1
|
|
487
|
+
})) : K("", !0),
|
|
488
|
+
e.showReset ? (h(), C(c(W), {
|
|
489
|
+
key: 1,
|
|
490
|
+
onClick: p
|
|
491
|
+
}, {
|
|
492
|
+
default: P(() => [...i[1] || (i[1] = [
|
|
493
|
+
me(" 重置 ", -1)
|
|
494
|
+
])]),
|
|
495
|
+
_: 1
|
|
496
|
+
})) : K("", !0)
|
|
497
|
+
]),
|
|
498
|
+
_: 1
|
|
499
|
+
})
|
|
500
|
+
]),
|
|
501
|
+
_: 1
|
|
502
|
+
})) : K("", !0)
|
|
503
|
+
]),
|
|
504
|
+
_: 3
|
|
505
|
+
}, 16)
|
|
506
|
+
]));
|
|
507
|
+
}
|
|
508
|
+
}), it = /* @__PURE__ */ Z(ut, [["__scopeId", "data-v-e009ac6b"]]), dt = { class: "crud-table" }, ct = {
|
|
509
|
+
key: 0,
|
|
510
|
+
class: "crud-table__header"
|
|
511
|
+
}, ft = { class: "crud-table__pagination" }, mt = /* @__PURE__ */ B({
|
|
512
|
+
__name: "CrudTable",
|
|
513
|
+
props: {
|
|
514
|
+
list: {},
|
|
515
|
+
columns: {},
|
|
516
|
+
selection: {},
|
|
517
|
+
rowKey: {},
|
|
518
|
+
showActionsColumn: { type: Boolean, default: !1 },
|
|
519
|
+
actionsColumnTitle: { default: "操作" },
|
|
520
|
+
actionsColumnWidth: { default: 120 },
|
|
521
|
+
tableProps: {},
|
|
522
|
+
paginationProps: {},
|
|
523
|
+
getRowActionsSlotProps: {}
|
|
524
|
+
},
|
|
525
|
+
emits: ["sort"],
|
|
526
|
+
setup(e, { emit: r }) {
|
|
527
|
+
const t = e, o = r, a = ie(), n = g(() => {
|
|
528
|
+
const i = et(t.columns, {
|
|
529
|
+
slots: a,
|
|
530
|
+
renderCell: (b, f, k) => k
|
|
531
|
+
});
|
|
532
|
+
return t.selection && i.unshift({
|
|
533
|
+
type: "selection"
|
|
534
|
+
}), t.showActionsColumn && a["row-actions"] && i.push({
|
|
535
|
+
key: "__actions",
|
|
536
|
+
title: t.actionsColumnTitle,
|
|
537
|
+
width: t.actionsColumnWidth,
|
|
538
|
+
fixed: "right",
|
|
539
|
+
render: (b, f) => {
|
|
540
|
+
const k = t.getRowActionsSlotProps?.(b) ?? {}, w = { row: b, rowIndex: f, ...k };
|
|
541
|
+
return S(Q, { size: 8 }, () => a["row-actions"](w));
|
|
542
|
+
}
|
|
543
|
+
}), i;
|
|
544
|
+
}), l = g(() => t.selection ? [...t.selection.selectedIds.value] : []);
|
|
545
|
+
function u(i) {
|
|
546
|
+
t.selection && t.selection.setSelectedIds(i);
|
|
547
|
+
}
|
|
548
|
+
function p(i) {
|
|
549
|
+
if (!i || Array.isArray(i)) {
|
|
550
|
+
t.list.setSort(null), o("sort", null);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (i.order === !1 || i.order === void 0) {
|
|
554
|
+
t.list.setSort(null), o("sort", null);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const b = {
|
|
558
|
+
field: String(i.columnKey),
|
|
559
|
+
order: i.order
|
|
560
|
+
};
|
|
561
|
+
t.list.setSort(b), o("sort", b);
|
|
562
|
+
}
|
|
563
|
+
function v(i) {
|
|
564
|
+
t.list.setPage(i);
|
|
565
|
+
}
|
|
566
|
+
function d(i) {
|
|
567
|
+
t.list.setPageSize(i);
|
|
568
|
+
}
|
|
569
|
+
return (i, b) => (h(), T("div", dt, [
|
|
570
|
+
i.$slots["table-header"] ? (h(), T("div", ct, [
|
|
571
|
+
V(i.$slots, "table-header", {
|
|
572
|
+
list: e.list,
|
|
573
|
+
selection: e.selection
|
|
574
|
+
}, void 0, !0)
|
|
575
|
+
])) : K("", !0),
|
|
576
|
+
A(c(Ie), F({
|
|
577
|
+
columns: n.value,
|
|
578
|
+
data: e.list.rows.value,
|
|
579
|
+
loading: e.list.loading.value,
|
|
580
|
+
"row-key": e.rowKey,
|
|
581
|
+
"checked-row-keys": l.value,
|
|
582
|
+
remote: ""
|
|
583
|
+
}, e.tableProps, {
|
|
584
|
+
"onUpdate:checkedRowKeys": u,
|
|
585
|
+
"onUpdate:sorter": p
|
|
586
|
+
}), null, 16, ["columns", "data", "loading", "row-key", "checked-row-keys"]),
|
|
587
|
+
ke("div", ft, [
|
|
588
|
+
A(c(xe), F({
|
|
589
|
+
page: e.list.page.value,
|
|
590
|
+
"page-size": e.list.pageSize.value,
|
|
591
|
+
"item-count": e.list.total.value,
|
|
592
|
+
"show-size-picker": "",
|
|
593
|
+
"page-sizes": [10, 20, 50, 100]
|
|
594
|
+
}, e.paginationProps, {
|
|
595
|
+
"onUpdate:page": v,
|
|
596
|
+
"onUpdate:pageSize": d
|
|
597
|
+
}), null, 16, ["page", "page-size", "item-count"])
|
|
598
|
+
])
|
|
599
|
+
]));
|
|
600
|
+
}
|
|
601
|
+
}), pt = /* @__PURE__ */ Z(mt, [["__scopeId", "data-v-0a031491"]]), yt = {
|
|
602
|
+
key: 1,
|
|
603
|
+
class: "auto-crud__before-table"
|
|
604
|
+
}, vt = {
|
|
605
|
+
key: 2,
|
|
606
|
+
class: "auto-crud__batch-actions"
|
|
607
|
+
}, bt = /* @__PURE__ */ B({
|
|
608
|
+
__name: "AutoCrud",
|
|
609
|
+
props: {
|
|
610
|
+
adapter: {},
|
|
611
|
+
fields: {},
|
|
612
|
+
columns: {},
|
|
613
|
+
searchFields: {},
|
|
614
|
+
searchQueryKey: {},
|
|
615
|
+
actions: {},
|
|
616
|
+
formMode: { default: "modal" },
|
|
617
|
+
showSelection: { type: Boolean, default: !1 },
|
|
618
|
+
showActionsColumn: { type: Boolean, default: !0 },
|
|
619
|
+
disableCreate: { type: Boolean, default: !1 },
|
|
620
|
+
disableEdit: { type: Boolean, default: !1 },
|
|
621
|
+
disableDelete: { type: Boolean, default: !1 },
|
|
622
|
+
disableExport: { type: Boolean, default: !1 },
|
|
623
|
+
title: { default: "列表" },
|
|
624
|
+
paginationProps: {},
|
|
625
|
+
routeSync: { type: Boolean, default: !1 },
|
|
626
|
+
routeQueryKey: { default: "q" }
|
|
627
|
+
},
|
|
628
|
+
emits: ["submit", "success", "error"],
|
|
629
|
+
setup(e, { expose: r, emit: t }) {
|
|
630
|
+
const o = e, a = t, n = ie();
|
|
631
|
+
function l(s) {
|
|
632
|
+
return {
|
|
633
|
+
openEdit: () => D(s),
|
|
634
|
+
actions: E.value,
|
|
635
|
+
defaultButtons: Pe
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
const u = /* @__PURE__ */ new Set([
|
|
639
|
+
"toolbar",
|
|
640
|
+
"before-table",
|
|
641
|
+
"batch-actions",
|
|
642
|
+
"row-actions",
|
|
643
|
+
"search",
|
|
644
|
+
"table",
|
|
645
|
+
"form",
|
|
646
|
+
"table-header",
|
|
647
|
+
"footer"
|
|
648
|
+
]), p = g(() => {
|
|
649
|
+
const s = {};
|
|
650
|
+
for (const m of Object.keys(n))
|
|
651
|
+
u.has(m) || (s[m] = n[m]);
|
|
652
|
+
return s;
|
|
653
|
+
}), v = Qe({
|
|
654
|
+
adapter: o.adapter,
|
|
655
|
+
onError: (s) => a("error", s)
|
|
656
|
+
}), d = We({
|
|
657
|
+
rows: v.rows,
|
|
658
|
+
getId: o.adapter.getId
|
|
659
|
+
}), i = _e({
|
|
660
|
+
fields: o.fields
|
|
661
|
+
});
|
|
662
|
+
let b = null, f = null;
|
|
663
|
+
try {
|
|
664
|
+
b = Ge(), f = He();
|
|
665
|
+
} catch {
|
|
666
|
+
}
|
|
667
|
+
o.routeSync && b && f && Je({
|
|
668
|
+
query: v.query,
|
|
669
|
+
setQuery: v.setQuery,
|
|
670
|
+
router: b,
|
|
671
|
+
route: f,
|
|
672
|
+
queryKey: o.routeQueryKey
|
|
673
|
+
});
|
|
674
|
+
const k = ae(!1), w = ae(null);
|
|
675
|
+
function $(s) {
|
|
676
|
+
k.value = s;
|
|
677
|
+
}
|
|
678
|
+
function R() {
|
|
679
|
+
w.value = null, i.reset(), i.setMode("create"), k.value = !0;
|
|
680
|
+
}
|
|
681
|
+
function D(s) {
|
|
682
|
+
w.value = s, i.reset(s), i.setMode("edit"), k.value = !0;
|
|
683
|
+
}
|
|
684
|
+
function U(s) {
|
|
685
|
+
return {
|
|
686
|
+
row: s,
|
|
687
|
+
selectedRows: d.selectedRows.value,
|
|
688
|
+
selectedIds: [...d.selectedIds.value],
|
|
689
|
+
query: v.query.value ?? {},
|
|
690
|
+
sort: v.sort.value,
|
|
691
|
+
page: v.page.value,
|
|
692
|
+
pageSize: v.pageSize.value,
|
|
693
|
+
refresh: v.refresh,
|
|
694
|
+
clearSelection: d.clear
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
async function ee(s, m) {
|
|
698
|
+
const y = U(m);
|
|
699
|
+
if (s.confirm) {
|
|
700
|
+
const N = typeof s.confirm == "string" ? s.confirm : "确定要执行此操作吗?";
|
|
701
|
+
if (!await rt(N))
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
await s.onClick(y);
|
|
705
|
+
}
|
|
706
|
+
const Ce = g(() => {
|
|
707
|
+
const s = [];
|
|
708
|
+
return !o.disableCreate && o.adapter.create && s.push(Y.create({ onClick: R })), !o.disableEdit && o.adapter.update && s.push(Y.edit({ onClick: D })), !o.disableDelete && o.adapter.remove && s.push(Y.delete({
|
|
709
|
+
adapter: o.adapter,
|
|
710
|
+
getId: o.adapter.getId,
|
|
711
|
+
onError: (m) => a("error", m)
|
|
712
|
+
})), !o.disableExport && o.adapter.export && s.push(Y.export({
|
|
713
|
+
adapter: o.adapter,
|
|
714
|
+
handleExport: ot,
|
|
715
|
+
onError: (m) => a("error", m)
|
|
716
|
+
})), s;
|
|
717
|
+
}), Se = g(() => o.actions ? o.actions : Ce.value);
|
|
718
|
+
function te(s) {
|
|
719
|
+
return Se.value.filter((m) => {
|
|
720
|
+
if (m.area !== s)
|
|
721
|
+
return !1;
|
|
722
|
+
const y = U();
|
|
723
|
+
return !(m.visible && !m.visible(y));
|
|
724
|
+
}).sort((m, y) => (m.order ?? 0) - (y.order ?? 0));
|
|
725
|
+
}
|
|
726
|
+
const E = g(() => te("row")), Ne = g(() => te("toolbar")), re = g(() => te("batch")), ce = g(() => o.columns ? o.columns : Ye(o.fields)), oe = g(() => o.adapter.getId ?? ((s) => s.id));
|
|
727
|
+
async function fe(s) {
|
|
728
|
+
const m = i.mode.value;
|
|
729
|
+
a("submit", { mode: m, data: s });
|
|
730
|
+
try {
|
|
731
|
+
if (m === "create" && o.adapter.create) {
|
|
732
|
+
const y = await o.adapter.create(s);
|
|
733
|
+
a("success", { mode: m, data: y });
|
|
734
|
+
} else if (m === "edit" && o.adapter.update && w.value) {
|
|
735
|
+
const y = oe.value(w.value), N = await o.adapter.update(y, s);
|
|
736
|
+
a("success", { mode: m, data: N });
|
|
737
|
+
}
|
|
738
|
+
k.value = !1, await v.refresh();
|
|
739
|
+
} catch (y) {
|
|
740
|
+
a("error", y);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
function I(s, m) {
|
|
744
|
+
const y = U(m), N = s.disabled?.(y) ?? !1;
|
|
745
|
+
return S(
|
|
746
|
+
W,
|
|
747
|
+
{
|
|
748
|
+
size: m ? "small" : void 0,
|
|
749
|
+
type: s.type === "primary" ? "primary" : s.type === "error" ? "error" : void 0,
|
|
750
|
+
disabled: N,
|
|
751
|
+
onClick: () => ee(s, m)
|
|
752
|
+
},
|
|
753
|
+
() => s.label
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
const Pe = {
|
|
757
|
+
Edit: (s) => {
|
|
758
|
+
const m = E.value.find((y) => y.id === "edit");
|
|
759
|
+
return m ? I(m, s.row) : null;
|
|
760
|
+
},
|
|
761
|
+
Delete: (s) => {
|
|
762
|
+
const m = E.value.find((y) => y.id === "delete");
|
|
763
|
+
return m ? I(m, s.row) : null;
|
|
764
|
+
},
|
|
765
|
+
View: (s) => {
|
|
766
|
+
const m = E.value.find((y) => y.id === "view");
|
|
767
|
+
return m ? I(m, s.row) : null;
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
return r({
|
|
771
|
+
list: v,
|
|
772
|
+
selection: d,
|
|
773
|
+
form: i,
|
|
774
|
+
refresh: v.refresh,
|
|
775
|
+
openCreate: R,
|
|
776
|
+
openEdit: D
|
|
777
|
+
}), (s, m) => (h(), C(c(Ee), { title: e.title }, {
|
|
778
|
+
"header-extra": P(() => [
|
|
779
|
+
A(c(Q), null, {
|
|
780
|
+
default: P(() => [
|
|
781
|
+
V(s.$slots, "toolbar", {
|
|
782
|
+
list: c(v),
|
|
783
|
+
selection: c(d),
|
|
784
|
+
openCreate: R
|
|
785
|
+
}, () => [
|
|
786
|
+
(h(!0), T(H, null, M(Ne.value, (y) => (h(), C(q(() => I(y)), {
|
|
787
|
+
key: y.id
|
|
788
|
+
}))), 128))
|
|
789
|
+
], !0)
|
|
790
|
+
]),
|
|
791
|
+
_: 3
|
|
792
|
+
})
|
|
793
|
+
]),
|
|
794
|
+
default: P(() => [
|
|
795
|
+
e.searchFields?.length || e.fields.some((y) => y.visibleIn?.search !== !1) ? V(s.$slots, "search", {
|
|
796
|
+
key: 0,
|
|
797
|
+
list: c(v),
|
|
798
|
+
fields: e.searchFields ?? e.fields
|
|
799
|
+
}, () => [
|
|
800
|
+
A(it, {
|
|
801
|
+
list: c(v),
|
|
802
|
+
fields: e.searchFields ?? e.fields,
|
|
803
|
+
"query-key": e.searchQueryKey
|
|
804
|
+
}, le({ _: 2 }, [
|
|
805
|
+
M(p.value, (y, N) => ({
|
|
806
|
+
name: N,
|
|
807
|
+
fn: P((O) => [
|
|
808
|
+
V(s.$slots, N, _(J(O)), void 0, !0)
|
|
809
|
+
])
|
|
810
|
+
}))
|
|
811
|
+
]), 1032, ["list", "fields", "query-key"])
|
|
812
|
+
], !0) : K("", !0),
|
|
813
|
+
s.$slots["before-table"] ? (h(), T("div", yt, [
|
|
814
|
+
V(s.$slots, "before-table", {
|
|
815
|
+
list: c(v),
|
|
816
|
+
selection: c(d)
|
|
817
|
+
}, void 0, !0)
|
|
818
|
+
])) : K("", !0),
|
|
819
|
+
re.value.length > 0 && c(d).selectedCount.value > 0 ? (h(), T("div", vt, [
|
|
820
|
+
V(s.$slots, "batch-actions", {
|
|
821
|
+
list: c(v),
|
|
822
|
+
selection: c(d),
|
|
823
|
+
actions: re.value,
|
|
824
|
+
renderActionButton: I
|
|
825
|
+
}, () => [
|
|
826
|
+
A(c(Q), null, {
|
|
827
|
+
default: P(() => [
|
|
828
|
+
ke("span", null, "已选择 " + Le(c(d).selectedCount.value) + " 项", 1),
|
|
829
|
+
(h(!0), T(H, null, M(re.value, (y) => (h(), C(q(() => I(y)), {
|
|
830
|
+
key: y.id
|
|
831
|
+
}))), 128))
|
|
832
|
+
]),
|
|
833
|
+
_: 1
|
|
834
|
+
})
|
|
835
|
+
], !0)
|
|
836
|
+
])) : K("", !0),
|
|
837
|
+
V(s.$slots, "table", {
|
|
838
|
+
list: c(v),
|
|
839
|
+
columns: ce.value,
|
|
840
|
+
selection: e.showSelection ? c(d) : void 0,
|
|
841
|
+
rowKey: oe.value,
|
|
842
|
+
rowActions: E.value,
|
|
843
|
+
renderActionButton: I,
|
|
844
|
+
getRowActionsSlotProps: l
|
|
845
|
+
}, () => [
|
|
846
|
+
A(pt, {
|
|
847
|
+
list: c(v),
|
|
848
|
+
columns: ce.value,
|
|
849
|
+
selection: e.showSelection ? c(d) : void 0,
|
|
850
|
+
"row-key": oe.value,
|
|
851
|
+
"show-actions-column": e.showActionsColumn && E.value.length > 0,
|
|
852
|
+
"pagination-props": e.paginationProps,
|
|
853
|
+
"get-row-actions-slot-props": l
|
|
854
|
+
}, le({
|
|
855
|
+
"row-actions": P((y) => [
|
|
856
|
+
V(s.$slots, "row-actions", _(J(y)), () => [
|
|
857
|
+
(h(!0), T(H, null, M(E.value, (N) => (h(), C(q(() => I(N, y.row)), {
|
|
858
|
+
key: N.id
|
|
859
|
+
}))), 128))
|
|
860
|
+
], !0)
|
|
861
|
+
]),
|
|
862
|
+
_: 2
|
|
863
|
+
}, [
|
|
864
|
+
M(p.value, (y, N) => ({
|
|
865
|
+
name: N,
|
|
866
|
+
fn: P((O) => [
|
|
867
|
+
V(s.$slots, N, _(J(O)), void 0, !0)
|
|
868
|
+
])
|
|
869
|
+
}))
|
|
870
|
+
]), 1032, ["list", "columns", "selection", "row-key", "show-actions-column", "pagination-props"])
|
|
871
|
+
], !0),
|
|
872
|
+
V(s.$slots, "form", {
|
|
873
|
+
form: c(i),
|
|
874
|
+
fields: e.fields,
|
|
875
|
+
visible: k.value,
|
|
876
|
+
setVisible: $,
|
|
877
|
+
mode: c(i).mode.value,
|
|
878
|
+
editingRow: w.value,
|
|
879
|
+
submit: fe
|
|
880
|
+
}, () => [
|
|
881
|
+
A(at, {
|
|
882
|
+
visible: k.value,
|
|
883
|
+
"onUpdate:visible": m[0] || (m[0] = (y) => k.value = y),
|
|
884
|
+
form: c(i),
|
|
885
|
+
fields: e.fields,
|
|
886
|
+
"display-mode": e.formMode,
|
|
887
|
+
onSubmit: fe
|
|
888
|
+
}, le({ _: 2 }, [
|
|
889
|
+
M(p.value, (y, N) => ({
|
|
890
|
+
name: N,
|
|
891
|
+
fn: P((O) => [
|
|
892
|
+
V(s.$slots, N, _(J(O)), void 0, !0)
|
|
893
|
+
])
|
|
894
|
+
}))
|
|
895
|
+
]), 1032, ["visible", "form", "fields", "display-mode"])
|
|
896
|
+
], !0)
|
|
897
|
+
]),
|
|
898
|
+
_: 3
|
|
899
|
+
}, 8, ["title"]));
|
|
900
|
+
}
|
|
901
|
+
}), At = /* @__PURE__ */ Z(bt, [["__scopeId", "data-v-299e1ff1"]]);
|
|
902
|
+
function z(e) {
|
|
903
|
+
return e == null || e === "";
|
|
904
|
+
}
|
|
905
|
+
function de(e) {
|
|
906
|
+
if (e == null)
|
|
907
|
+
return "";
|
|
908
|
+
if (typeof e == "string")
|
|
909
|
+
return e;
|
|
910
|
+
if (typeof e == "number" || typeof e == "bigint" || typeof e == "boolean")
|
|
911
|
+
return String(e);
|
|
912
|
+
try {
|
|
913
|
+
return JSON.stringify(e);
|
|
914
|
+
} catch {
|
|
915
|
+
return String(e);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function ht(e) {
|
|
919
|
+
if (e instanceof Date)
|
|
920
|
+
return Number.isNaN(e.getTime()) ? null : e;
|
|
921
|
+
if (typeof e == "number") {
|
|
922
|
+
const r = new Date(e);
|
|
923
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
924
|
+
}
|
|
925
|
+
if (typeof e == "string") {
|
|
926
|
+
const r = e.trim();
|
|
927
|
+
if (!r)
|
|
928
|
+
return null;
|
|
929
|
+
const t = Number(r);
|
|
930
|
+
if (!Number.isNaN(t)) {
|
|
931
|
+
const a = new Date(t);
|
|
932
|
+
return Number.isNaN(a.getTime()) ? null : a;
|
|
933
|
+
}
|
|
934
|
+
const o = new Date(r);
|
|
935
|
+
return Number.isNaN(o.getTime()) ? null : o;
|
|
936
|
+
}
|
|
937
|
+
return null;
|
|
938
|
+
}
|
|
939
|
+
function Bt(e = {}) {
|
|
940
|
+
const {
|
|
941
|
+
placeholder: r = "-",
|
|
942
|
+
parse: t = ht,
|
|
943
|
+
locale: o = "zh-CN",
|
|
944
|
+
formatOptions: a = { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }
|
|
945
|
+
} = e, n = new Intl.DateTimeFormat(o, a);
|
|
946
|
+
return (l) => {
|
|
947
|
+
if (z(l.value))
|
|
948
|
+
return r;
|
|
949
|
+
const u = t(l.value);
|
|
950
|
+
return u ? n.format(u) : r;
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function $t(e = {}) {
|
|
954
|
+
const {
|
|
955
|
+
placeholder: r = "-",
|
|
956
|
+
locale: t = "zh-CN",
|
|
957
|
+
currency: o = "CNY",
|
|
958
|
+
minimumFractionDigits: a = 2,
|
|
959
|
+
maximumFractionDigits: n = 2
|
|
960
|
+
} = e, l = new Intl.NumberFormat(t, {
|
|
961
|
+
style: "currency",
|
|
962
|
+
currency: o,
|
|
963
|
+
minimumFractionDigits: a,
|
|
964
|
+
maximumFractionDigits: n
|
|
965
|
+
});
|
|
966
|
+
return (u) => {
|
|
967
|
+
const p = u.value;
|
|
968
|
+
if (z(p))
|
|
969
|
+
return r;
|
|
970
|
+
const v = typeof p == "number" ? p : Number(p);
|
|
971
|
+
return Number.isNaN(v) ? r : l.format(v);
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
function Dt(e = {}) {
|
|
975
|
+
const { placeholder: r = "-", popoverProps: t, previewMaxLen: o = 60 } = e;
|
|
976
|
+
return (a) => {
|
|
977
|
+
if (z(a.value))
|
|
978
|
+
return r;
|
|
979
|
+
let n = "";
|
|
980
|
+
try {
|
|
981
|
+
n = typeof a.value == "string" ? a.value : JSON.stringify(a.value, null, 2);
|
|
982
|
+
} catch {
|
|
983
|
+
n = String(a.value);
|
|
984
|
+
}
|
|
985
|
+
const l = n.length > o ? `${n.slice(0, o)}…` : n;
|
|
986
|
+
return S(
|
|
987
|
+
Me,
|
|
988
|
+
{ trigger: "hover", placement: "top", ...t ?? {} },
|
|
989
|
+
{
|
|
990
|
+
trigger: () => S(we, { tooltip: !1, lineClamp: 1 }, { default: () => l }),
|
|
991
|
+
default: () => S(qe, { code: n, language: "json", wordWrap: !0 })
|
|
992
|
+
}
|
|
993
|
+
);
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
function It(e = {}) {
|
|
997
|
+
const {
|
|
998
|
+
placeholder: r = "-",
|
|
999
|
+
width: t = 32,
|
|
1000
|
+
height: o = 32,
|
|
1001
|
+
previewDisabled: a = !0,
|
|
1002
|
+
getUrl: n
|
|
1003
|
+
} = e;
|
|
1004
|
+
return (l) => {
|
|
1005
|
+
const u = n ? n(l) : typeof l.value == "string" ? l.value : null;
|
|
1006
|
+
return u ? S(Ke, { src: u, width: t, height: o, previewDisabled: a }) : r;
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
function xt(e = {}) {
|
|
1010
|
+
const {
|
|
1011
|
+
placeholder: r = "-",
|
|
1012
|
+
trueText: t = "是",
|
|
1013
|
+
falseText: o = "否",
|
|
1014
|
+
trueType: a = "success",
|
|
1015
|
+
falseType: n = "default",
|
|
1016
|
+
nullText: l = r,
|
|
1017
|
+
nullType: u = "default",
|
|
1018
|
+
size: p = "small"
|
|
1019
|
+
} = e;
|
|
1020
|
+
return (v) => {
|
|
1021
|
+
const d = v.value;
|
|
1022
|
+
return d === !0 ? S(G, { type: a, size: p }, { default: () => t }) : d === !1 ? S(G, { type: n, size: p }, { default: () => o }) : S(G, { type: u, size: p }, { default: () => l });
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
function gt(e) {
|
|
1026
|
+
const { placeholder: r = "-", map: t, options: o } = e, a = /* @__PURE__ */ new Map();
|
|
1027
|
+
for (const n of o ?? [])
|
|
1028
|
+
n.value === null || n.value === void 0 || (typeof n.value == "string" || typeof n.value == "number") && a.set(n.value, String(n.label ?? n.value));
|
|
1029
|
+
return (n) => {
|
|
1030
|
+
if (z(n.value))
|
|
1031
|
+
return r;
|
|
1032
|
+
const l = n.value, u = String(l), p = t ? t[u] ?? (typeof l == "number" ? t[l] : void 0) : void 0, v = typeof l == "string" || typeof l == "number" ? a.get(l) : void 0;
|
|
1033
|
+
return p ?? v ?? de(l);
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function Et(e) {
|
|
1037
|
+
const { placeholder: r = "-", typeMap: t, defaultType: o = "default", size: a = "small" } = e, n = gt(e);
|
|
1038
|
+
return (l) => {
|
|
1039
|
+
if (z(l.value))
|
|
1040
|
+
return r;
|
|
1041
|
+
const u = l.value, p = String(u), d = (t ? t[p] ?? (typeof u == "number" ? t[u] : void 0) : void 0) ?? o;
|
|
1042
|
+
return S(G, { type: d, size: a }, { default: () => n(l) });
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
function Mt(e = {}) {
|
|
1046
|
+
const { placeholder: r = "-" } = e;
|
|
1047
|
+
return (t) => z(t.value) ? r : de(t.value);
|
|
1048
|
+
}
|
|
1049
|
+
function qt(e = {}) {
|
|
1050
|
+
const { placeholder: r = "-", lineClamp: t = 1, tooltip: o = !0 } = e;
|
|
1051
|
+
return (a) => {
|
|
1052
|
+
if (z(a.value))
|
|
1053
|
+
return r;
|
|
1054
|
+
const n = de(a.value);
|
|
1055
|
+
return S(
|
|
1056
|
+
we,
|
|
1057
|
+
{ tooltip: o, lineClamp: t },
|
|
1058
|
+
{ default: () => n }
|
|
1059
|
+
);
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
export {
|
|
1063
|
+
At as AutoCrud,
|
|
1064
|
+
at as CrudForm,
|
|
1065
|
+
it as CrudSearch,
|
|
1066
|
+
pt as CrudTable,
|
|
1067
|
+
pe as DateField,
|
|
1068
|
+
ye as DateRangeField,
|
|
1069
|
+
ve as NumberField,
|
|
1070
|
+
Xe as SelectField,
|
|
1071
|
+
Ze as SwitchField,
|
|
1072
|
+
be as TextField,
|
|
1073
|
+
xt as cellBooleanTag,
|
|
1074
|
+
Bt as cellDateTime,
|
|
1075
|
+
qt as cellEllipsis,
|
|
1076
|
+
gt as cellEnumLabel,
|
|
1077
|
+
Et as cellEnumTag,
|
|
1078
|
+
It as cellImage,
|
|
1079
|
+
Dt as cellJsonPopover,
|
|
1080
|
+
$t as cellMoney,
|
|
1081
|
+
Mt as cellText,
|
|
1082
|
+
X as componentMap,
|
|
1083
|
+
rt as confirmAction,
|
|
1084
|
+
et as createTableColumns,
|
|
1085
|
+
Tt as defineColumns,
|
|
1086
|
+
Vt as defineField,
|
|
1087
|
+
Rt as defineFields,
|
|
1088
|
+
se as getFieldLabel,
|
|
1089
|
+
ot as handleExportResult,
|
|
1090
|
+
z as isEmptyValue,
|
|
1091
|
+
x as resolveControlProps,
|
|
1092
|
+
ue as resolveFormItemProps,
|
|
1093
|
+
de as toText
|
|
1094
|
+
};
|