auto-gen-crud 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/API.md +130 -0
- package/README.md +234 -0
- package/dist/adapters/ant-design-vue.d.ts +8 -0
- package/dist/adapters/element-plus.d.ts +8 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +7 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/naive.d.ts +8 -0
- package/dist/adapters/types.d.ts +162 -0
- package/dist/components/AutoCrud.vue.d.ts +398 -0
- package/dist/components/CopyText.vue.d.ts +6 -0
- package/dist/components/CrudModal.vue.d.ts +47 -0
- package/dist/components/DecodeText.vue.d.ts +8 -0
- package/dist/components/DynamicForm.vue.d.ts +63 -0
- package/dist/components/DynamicFormItem.vue.d.ts +20 -0
- package/dist/components/DynamicTable.vue.d.ts +30 -0
- package/dist/context.d.ts +36 -0
- package/dist/core/date-format-utils.d.ts +8 -0
- package/dist/core/form-runtime-cache.d.ts +27 -0
- package/dist/core/form-utils.d.ts +51 -0
- package/dist/core/object-utils.d.ts +43 -0
- package/dist/core/table-utils.d.ts +19 -0
- package/dist/core/types.d.ts +443 -0
- package/dist/generator/fields.d.ts +27 -0
- package/dist/generator/index.d.ts +14 -0
- package/dist/generator/index.js +740 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/openapi.d.ts +10 -0
- package/dist/generator/operations.d.ts +8 -0
- package/dist/generator/schema.d.ts +32 -0
- package/dist/generator/string-utils.d.ts +11 -0
- package/dist/generator/templates.d.ts +6 -0
- package/dist/generator/types.d.ts +185 -0
- package/dist/generator/writer.d.ts +8 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useModalForm.d.ts +11 -0
- package/dist/hooks/useSearchForm.d.ts +10 -0
- package/dist/hooks/useTable.d.ts +11 -0
- package/dist/index-Dc-solHn.js +299 -0
- package/dist/index-Dc-solHn.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +985 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +17 -0
- package/dist/style.css +1 -0
- package/dist/useTable-BwDSqD1q.js +214 -0
- package/dist/useTable-BwDSqD1q.js.map +1 -0
- package/dist/utils/clipboard.d.ts +16 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +532 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/message.d.ts +9 -0
- package/dist/utils/request.d.ts +8 -0
- package/dist/utils/sm4-core.d.ts +12 -0
- package/dist/utils/sm4.d.ts +29 -0
- package/docs/AI_AGENT_GUIDE.md +210 -0
- package/mcp/auto-crud-mcp.mjs +502 -0
- package/mcp/auto-gen-crud-mcp.mjs +586 -0
- package/package.json +93 -0
- package/skills/auto-gen-crud-agent/SKILL.md +114 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,985 @@
|
|
|
1
|
+
import { inject as He, defineComponent as U, useSlots as Ae, computed as m, h as K, resolveComponent as fe, openBlock as p, createBlock as F, resolveDynamicComponent as V, normalizeProps as ee, mergeProps as Y, withCtx as S, createElementVNode as C, renderSlot as G, createVNode as X, unref as x, guardReactiveProps as pe, createElementBlock as $, Fragment as Z, renderList as ae, createTextVNode as re, toDisplayString as B, createCommentVNode as N, ref as D, normalizeStyle as oe, onMounted as ve, onBeforeUnmount as ke, watch as $e, normalizeClass as ue, toHandlers as Me, Teleport as Re, nextTick as Oe, createSlots as De } from "vue";
|
|
2
|
+
import { g as W, c as Ee, d as ze, n as Ne, e as Ue, s as Ie, f as Ye, h as ge, i as ie, r as le } from "./useTable-BwDSqD1q.js";
|
|
3
|
+
import { u as Et, a as zt, b as Nt } from "./useTable-BwDSqD1q.js";
|
|
4
|
+
import { e as be, n as se, a as je, b as Ke } from "./index-Dc-solHn.js";
|
|
5
|
+
import Le from "dayjs";
|
|
6
|
+
import { copyText as Ge } from "./utils/index.js";
|
|
7
|
+
import { createRequest as It, showCrudMessage as Yt, sm4Decrypt as jt, sm4Encrypt as Kt } from "./utils/index.js";
|
|
8
|
+
const he = /* @__PURE__ */ Symbol("AUTO_CRUD_CONTEXT_KEY");
|
|
9
|
+
let ye = {
|
|
10
|
+
adapter: be
|
|
11
|
+
};
|
|
12
|
+
function qe(e) {
|
|
13
|
+
ye = e;
|
|
14
|
+
}
|
|
15
|
+
function q() {
|
|
16
|
+
return He(he, ye);
|
|
17
|
+
}
|
|
18
|
+
function We(e = {}, n) {
|
|
19
|
+
return {
|
|
20
|
+
adapter: n,
|
|
21
|
+
request: e.request,
|
|
22
|
+
decode: e.decode,
|
|
23
|
+
decodeLog: e.decodeLog,
|
|
24
|
+
sm4Key: e.sm4Key
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const Xe = { class: "vac-modal-body" }, Je = { class: "vac-modal-body" }, Qe = /* @__PURE__ */ U({
|
|
28
|
+
__name: "CrudModal",
|
|
29
|
+
props: {
|
|
30
|
+
visible: { type: Boolean },
|
|
31
|
+
title: {},
|
|
32
|
+
mode: {},
|
|
33
|
+
modalType: { default: "drawer" },
|
|
34
|
+
width: {},
|
|
35
|
+
submitText: { default: "提交" },
|
|
36
|
+
cancelText: { default: "关闭" }
|
|
37
|
+
},
|
|
38
|
+
emits: ["update:visible", "submit", "close"],
|
|
39
|
+
setup(e, { emit: n }) {
|
|
40
|
+
const t = e, d = n, { adapter: u } = q(), r = Ae(), a = m(() => t.modalType === "drawer" ? u.components.drawer : u.components.modal), i = m(() => t.modalType === "drawer" ? u.components.drawerContent : void 0), f = m(
|
|
41
|
+
() => u.modal.getModalProps({
|
|
42
|
+
visible: t.visible,
|
|
43
|
+
title: t.title,
|
|
44
|
+
width: t.width,
|
|
45
|
+
onUpdateVisible: (w) => d("update:visible", w)
|
|
46
|
+
})
|
|
47
|
+
), T = U({
|
|
48
|
+
setup() {
|
|
49
|
+
return () => K("div", { class: "vac-modal-footer" }, r.footer?.() ?? [
|
|
50
|
+
t.mode !== "view" ? K(
|
|
51
|
+
A(u.components.button),
|
|
52
|
+
{ ...u.render.getButtonProps({ type: "primary" }), onClick: () => d("submit") },
|
|
53
|
+
() => t.submitText
|
|
54
|
+
) : null,
|
|
55
|
+
K(
|
|
56
|
+
A(u.components.button),
|
|
57
|
+
{ ...u.render.getButtonProps({ type: "default" }), onClick: () => d("close") },
|
|
58
|
+
() => t.cancelText
|
|
59
|
+
)
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
function R(w) {
|
|
64
|
+
return w;
|
|
65
|
+
}
|
|
66
|
+
function A(w) {
|
|
67
|
+
return typeof w == "string" ? fe(w) : w;
|
|
68
|
+
}
|
|
69
|
+
return (w, E) => i.value ? (p(), F(V(a.value), ee(Y({ key: 0 }, f.value)), {
|
|
70
|
+
default: S(() => [
|
|
71
|
+
(p(), F(V(i.value), { title: e.title }, {
|
|
72
|
+
footer: S(() => [
|
|
73
|
+
X(x(T))
|
|
74
|
+
]),
|
|
75
|
+
default: S(() => [
|
|
76
|
+
C("div", Xe, [
|
|
77
|
+
G(w.$slots, "default")
|
|
78
|
+
])
|
|
79
|
+
]),
|
|
80
|
+
_: 3
|
|
81
|
+
}, 8, ["title"]))
|
|
82
|
+
]),
|
|
83
|
+
_: 3
|
|
84
|
+
}, 16)) : (p(), F(V(a.value), ee(Y({ key: 1 }, f.value)), {
|
|
85
|
+
footer: S(() => [
|
|
86
|
+
X(x(T))
|
|
87
|
+
]),
|
|
88
|
+
default: S(() => [
|
|
89
|
+
C("div", Je, [
|
|
90
|
+
G(w.$slots, "default")
|
|
91
|
+
])
|
|
92
|
+
]),
|
|
93
|
+
_: 3
|
|
94
|
+
}, 16));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
function de(e) {
|
|
98
|
+
return Array.isArray(e.deps) && e.deps.length > 0;
|
|
99
|
+
}
|
|
100
|
+
function j(e) {
|
|
101
|
+
return typeof e == "function";
|
|
102
|
+
}
|
|
103
|
+
function Ze() {
|
|
104
|
+
const e = import.meta;
|
|
105
|
+
return e.env?.DEV === !0 || e.env?.MODE === "development";
|
|
106
|
+
}
|
|
107
|
+
function Ce() {
|
|
108
|
+
if (!(typeof window > "u"))
|
|
109
|
+
return window;
|
|
110
|
+
}
|
|
111
|
+
function et() {
|
|
112
|
+
const e = Ce();
|
|
113
|
+
if (!e) return !1;
|
|
114
|
+
const n = e.__VAC_PERF__;
|
|
115
|
+
if (n === !0 || typeof n == "object" && n.enabled !== !1) return !0;
|
|
116
|
+
try {
|
|
117
|
+
return e.localStorage?.getItem("VAC_DEBUG_PERF") === "1";
|
|
118
|
+
} catch {
|
|
119
|
+
return !1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function tt() {
|
|
123
|
+
if (!et()) return;
|
|
124
|
+
const e = Ce();
|
|
125
|
+
if (e) {
|
|
126
|
+
if (typeof e.__VAC_PERF__ != "object" || e.__VAC_PERF__ === null) {
|
|
127
|
+
const n = {
|
|
128
|
+
enabled: !0,
|
|
129
|
+
fields: {},
|
|
130
|
+
reset() {
|
|
131
|
+
n.fields = {};
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
e.__VAC_PERF__ = n;
|
|
135
|
+
}
|
|
136
|
+
return e.__VAC_PERF__;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function nt(e, n) {
|
|
140
|
+
return `${e}:${n.prop || "__unknown__"}`;
|
|
141
|
+
}
|
|
142
|
+
function Q(e, n, t, d) {
|
|
143
|
+
const u = tt();
|
|
144
|
+
if (!u) return;
|
|
145
|
+
const r = nt(e, t), a = u.fields[r] || (u.fields[r] = {
|
|
146
|
+
calls: {},
|
|
147
|
+
cacheHit: 0,
|
|
148
|
+
cacheMiss: 0,
|
|
149
|
+
noDeps: 0
|
|
150
|
+
});
|
|
151
|
+
if (d === "call") {
|
|
152
|
+
a.calls[n] = (a.calls[n] || 0) + 1;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
a[d] += 1;
|
|
156
|
+
}
|
|
157
|
+
function ot(e) {
|
|
158
|
+
if (e === null) return "null";
|
|
159
|
+
if (e === void 0) return "undefined";
|
|
160
|
+
if (["string", "number", "boolean", "bigint"].includes(typeof e)) return `${typeof e}:${String(e)}`;
|
|
161
|
+
if (e instanceof Date) return `date:${e.getTime()}`;
|
|
162
|
+
try {
|
|
163
|
+
return `json:${JSON.stringify(e)}`;
|
|
164
|
+
} catch {
|
|
165
|
+
return `object:${Object.prototype.toString.call(e)}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function at(e, n) {
|
|
169
|
+
return (e.deps || []).map((t) => {
|
|
170
|
+
const d = W(n, t);
|
|
171
|
+
return `${t}:${ot(d)}`;
|
|
172
|
+
}).join("|");
|
|
173
|
+
}
|
|
174
|
+
function rt(e, n, t) {
|
|
175
|
+
return `${e}:${n}:${t.prop}`;
|
|
176
|
+
}
|
|
177
|
+
function lt(e, n) {
|
|
178
|
+
return e === "show" ? j(n.show) : e === "disabled" ? j(n.disabled) : e === "rules" ? j(n.required) || j(n.isReq) || j(n.rules) : e === "options" ? j(n.options) : e === "label" ? j(n.label) : e === "placeholder" ? j(n.placeholder) : !1;
|
|
179
|
+
}
|
|
180
|
+
function ut(e = "default") {
|
|
181
|
+
const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
182
|
+
function d(r, a) {
|
|
183
|
+
if (!Ze() || !lt(r, a) || de(a)) return;
|
|
184
|
+
const i = `${e}:${r}:${a.prop}`;
|
|
185
|
+
t.has(i) || (t.add(i), console.warn(
|
|
186
|
+
`[auto-gen-crud] 字段 ${a.prop} 使用了动态 ${r} 配置,但没有声明 deps,无法启用缓存优化。`
|
|
187
|
+
));
|
|
188
|
+
}
|
|
189
|
+
function u(r, a, i, f) {
|
|
190
|
+
if (!de(a))
|
|
191
|
+
return d(r, a), Q(e, r, a, "noDeps"), Q(e, r, a, "call"), f();
|
|
192
|
+
const T = rt(e, r, a), R = at(a, i), A = n.get(T);
|
|
193
|
+
if (A && A.depsSnapshot === R)
|
|
194
|
+
return Q(e, r, a, "cacheHit"), A.value;
|
|
195
|
+
Q(e, r, a, "cacheMiss"), Q(e, r, a, "call");
|
|
196
|
+
const w = f();
|
|
197
|
+
return n.set(T, { depsSnapshot: R, value: w }), w;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
/** 获取字段是否显示。 */
|
|
201
|
+
getShow(r, a) {
|
|
202
|
+
return u("show", r, a, () => Ye(r, a));
|
|
203
|
+
},
|
|
204
|
+
/** 获取字段是否禁用。 */
|
|
205
|
+
getDisabled(r, a, i = !1) {
|
|
206
|
+
return i ? !0 : u("disabled", r, a, () => Ie(r, a, !1));
|
|
207
|
+
},
|
|
208
|
+
/** 获取字段校验规则。 */
|
|
209
|
+
getRules(r, a) {
|
|
210
|
+
return u("rules", r, a, () => Ue(r, a));
|
|
211
|
+
},
|
|
212
|
+
/** 获取字段选项。 */
|
|
213
|
+
getOptions(r, a) {
|
|
214
|
+
return u("options", r, a, () => Ne(r.options, a, r));
|
|
215
|
+
},
|
|
216
|
+
/** 获取字段标题。 */
|
|
217
|
+
getLabel(r, a) {
|
|
218
|
+
return u("label", r, a, () => ze(r, a));
|
|
219
|
+
},
|
|
220
|
+
/** 获取字段占位文案。 */
|
|
221
|
+
getPlaceholder(r, a) {
|
|
222
|
+
return u("placeholder", r, a, () => Ee(r, a));
|
|
223
|
+
},
|
|
224
|
+
/** 清空运行时缓存和已提示记录,通常用于 columns 重建或调试时手动重置。 */
|
|
225
|
+
clear() {
|
|
226
|
+
n.clear(), t.clear();
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const it = /* @__PURE__ */ U({
|
|
231
|
+
__name: "DynamicFormItem",
|
|
232
|
+
props: {
|
|
233
|
+
item: {},
|
|
234
|
+
modelValue: {},
|
|
235
|
+
runtimeCache: {},
|
|
236
|
+
rules: {},
|
|
237
|
+
disabled: { type: Boolean }
|
|
238
|
+
},
|
|
239
|
+
emits: ["update:modelValue"],
|
|
240
|
+
setup(e, { emit: n }) {
|
|
241
|
+
const t = e, d = n, { adapter: u } = q(), r = U({
|
|
242
|
+
props: {
|
|
243
|
+
renderer: {
|
|
244
|
+
type: Function,
|
|
245
|
+
required: !0
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
setup(h) {
|
|
249
|
+
return () => h.renderer();
|
|
250
|
+
}
|
|
251
|
+
}), a = m(() => ge(t.item)), i = m(() => u.components.fields[a.value] || u.components.fields.input), f = m(() => t.runtimeCache.getOptions(t.item, t.modelValue)), T = m(() => a.value === "radio" ? u.components.radio || "option" : a.value === "checkbox" ? u.components.checkbox || "option" : u.components.option || "option"), R = m(() => ["radio", "checkbox"].includes(a.value) ? !0 : u.name === "element-plus" && ["select", "multipleSelect"].includes(a.value)), A = m(
|
|
252
|
+
() => u.form.getFormItemProps(t.item, {
|
|
253
|
+
prop: t.item.prop,
|
|
254
|
+
label: t.runtimeCache.getLabel(t.item, t.modelValue),
|
|
255
|
+
rules: t.rules
|
|
256
|
+
})
|
|
257
|
+
), w = m(() => {
|
|
258
|
+
const h = u.form.getModelBinding(a.value, t.item), I = W(t.modelValue, t.item.prop), P = u.form.getFieldProps(t.item, {
|
|
259
|
+
value: I,
|
|
260
|
+
placeholder: t.runtimeCache.getPlaceholder(t.item, t.modelValue),
|
|
261
|
+
disabled: t.runtimeCache.getDisabled(t.item, t.modelValue, t.disabled),
|
|
262
|
+
options: f.value
|
|
263
|
+
}), M = O(P), s = z(M[h.event]), y = z(M.onChange), v = z(M.onBlur), _ = z(M.onFocus);
|
|
264
|
+
return {
|
|
265
|
+
...M,
|
|
266
|
+
[h.prop]: I,
|
|
267
|
+
[h.event]: (b) => {
|
|
268
|
+
const k = W(t.modelValue, t.item.prop);
|
|
269
|
+
ie(t.modelValue, t.item.prop, b), d("update:modelValue", t.modelValue), s?.(b), y?.(b), t.item.onChange?.(b, E(k));
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* props.onChange 已经在模型更新链路里执行。
|
|
273
|
+
* 这里吞掉原生 change 事件,避免部分 UI 同时触发 update/change 时重复调用业务回调。
|
|
274
|
+
*/
|
|
275
|
+
onChange: void 0,
|
|
276
|
+
onBlur: (b) => {
|
|
277
|
+
const k = W(t.modelValue, t.item.prop);
|
|
278
|
+
v?.(b), t.item.onBlur?.(b, E(k));
|
|
279
|
+
},
|
|
280
|
+
onFocus: (b) => {
|
|
281
|
+
const k = W(t.modelValue, t.item.prop);
|
|
282
|
+
_?.(b), t.item.onFocus?.(b, E(k));
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
function E(h) {
|
|
287
|
+
return {
|
|
288
|
+
prop: t.item.prop,
|
|
289
|
+
item: t.item,
|
|
290
|
+
component: a.value,
|
|
291
|
+
formData: t.modelValue,
|
|
292
|
+
oldValue: h,
|
|
293
|
+
setFieldValue: (I, P) => {
|
|
294
|
+
ie(t.modelValue, I, P), d("update:modelValue", t.modelValue);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function z(h) {
|
|
299
|
+
return typeof h == "function" ? h : void 0;
|
|
300
|
+
}
|
|
301
|
+
function O(h) {
|
|
302
|
+
return u.name !== "naive" || a.value !== "datePicker" && a.value !== "timePicker" ? h : {
|
|
303
|
+
...h,
|
|
304
|
+
format: se(h.format),
|
|
305
|
+
valueFormat: se(h.valueFormat)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function L(h) {
|
|
309
|
+
return h;
|
|
310
|
+
}
|
|
311
|
+
return (h, I) => (p(), F(V(x(u).components.formItem), ee(pe(A.value)), {
|
|
312
|
+
default: S(() => [
|
|
313
|
+
e.item.render ? (p(), F(V(x(r)), {
|
|
314
|
+
key: 0,
|
|
315
|
+
renderer: () => e.item.render?.(e.modelValue, e.item)
|
|
316
|
+
}, null, 8, ["renderer"])) : (p(), F(V(i.value), ee(Y({ key: 1 }, w.value)), {
|
|
317
|
+
default: S(() => [
|
|
318
|
+
R.value ? (p(!0), $(Z, { key: 0 }, ae(f.value, (P) => (p(), F(V(T.value), {
|
|
319
|
+
key: String(P.value),
|
|
320
|
+
label: P.label,
|
|
321
|
+
value: P.value,
|
|
322
|
+
disabled: P.disabled
|
|
323
|
+
}, {
|
|
324
|
+
default: S(() => [
|
|
325
|
+
re(B(P.label), 1)
|
|
326
|
+
]),
|
|
327
|
+
_: 2
|
|
328
|
+
}, 1032, ["label", "value", "disabled"]))), 128)) : N("", !0)
|
|
329
|
+
]),
|
|
330
|
+
_: 1
|
|
331
|
+
}, 16))
|
|
332
|
+
]),
|
|
333
|
+
_: 1
|
|
334
|
+
}, 16));
|
|
335
|
+
}
|
|
336
|
+
}), ce = /* @__PURE__ */ U({
|
|
337
|
+
__name: "DynamicForm",
|
|
338
|
+
props: {
|
|
339
|
+
formType: { default: "search" },
|
|
340
|
+
columns: {},
|
|
341
|
+
modelValue: {},
|
|
342
|
+
layout: {},
|
|
343
|
+
disabled: { type: Boolean, default: !1 }
|
|
344
|
+
},
|
|
345
|
+
emits: ["update:modelValue", "submit", "reset"],
|
|
346
|
+
setup(e, { expose: n, emit: t }) {
|
|
347
|
+
const d = e, u = t, { adapter: r } = q(), a = D(null), i = ut(d.formType), f = m({
|
|
348
|
+
get: () => d.modelValue,
|
|
349
|
+
set: (v) => u("update:modelValue", v)
|
|
350
|
+
}), T = m(() => d.columns.filter((v) => i.getShow(v, f.value))), R = m(
|
|
351
|
+
() => T.value.reduce((v, _) => {
|
|
352
|
+
const b = i.getRules(_, f.value);
|
|
353
|
+
return _.prop && b.length > 0 && (v[_.prop] = b), v;
|
|
354
|
+
}, {})
|
|
355
|
+
), A = m(() => r.form.getFormProps({ model: f.value, rules: R.value, disabled: d.disabled })), w = m(() => r.form.getLayoutStyle(O(), d.formType)), E = m(() => {
|
|
356
|
+
const v = z(), _ = T.value.reduce((k, J) => k + L(J), 0) % v;
|
|
357
|
+
return {
|
|
358
|
+
gridColumn: `${_ === 0 ? v : _ + 1} / ${v + 1}`
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
function z() {
|
|
362
|
+
return Math.max(Number(O().columns || 1), 1);
|
|
363
|
+
}
|
|
364
|
+
function O() {
|
|
365
|
+
return {
|
|
366
|
+
...d.layout,
|
|
367
|
+
columns: d.layout?.columns || (d.formType === "modal" ? 1 : 4)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function L(v) {
|
|
371
|
+
const _ = z(), b = Number(v.colSpan || 1);
|
|
372
|
+
return Number.isFinite(b) ? Math.min(Math.max(Math.floor(b), 1), _) : 1;
|
|
373
|
+
}
|
|
374
|
+
function h(v) {
|
|
375
|
+
return {
|
|
376
|
+
gridColumn: `span ${L(v)}`
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function I(v) {
|
|
380
|
+
return v;
|
|
381
|
+
}
|
|
382
|
+
async function P() {
|
|
383
|
+
return r.form.validate(a.value);
|
|
384
|
+
}
|
|
385
|
+
function M() {
|
|
386
|
+
r.form.clearValidate(a.value);
|
|
387
|
+
}
|
|
388
|
+
async function s() {
|
|
389
|
+
await P() && u("submit", f.value);
|
|
390
|
+
}
|
|
391
|
+
function y() {
|
|
392
|
+
M(), u("reset");
|
|
393
|
+
}
|
|
394
|
+
return n({
|
|
395
|
+
validate: P,
|
|
396
|
+
clearValidate: M,
|
|
397
|
+
submit: s,
|
|
398
|
+
reset: y
|
|
399
|
+
}), (v, _) => (p(), F(V(x(r).components.form), Y({
|
|
400
|
+
ref_key: "formRef",
|
|
401
|
+
ref: a
|
|
402
|
+
}, A.value), {
|
|
403
|
+
default: S(() => [
|
|
404
|
+
C("div", {
|
|
405
|
+
class: "vac-form-grid",
|
|
406
|
+
style: oe(w.value)
|
|
407
|
+
}, [
|
|
408
|
+
(p(!0), $(Z, null, ae(T.value, (b) => (p(), $("div", {
|
|
409
|
+
key: b.prop,
|
|
410
|
+
class: "vac-form-grid-item",
|
|
411
|
+
style: oe(h(b))
|
|
412
|
+
}, [
|
|
413
|
+
X(it, {
|
|
414
|
+
item: b,
|
|
415
|
+
"model-value": f.value,
|
|
416
|
+
"runtime-cache": x(i),
|
|
417
|
+
rules: R.value[b.prop],
|
|
418
|
+
disabled: e.disabled,
|
|
419
|
+
"onUpdate:modelValue": _[0] || (_[0] = (k) => f.value = k)
|
|
420
|
+
}, null, 8, ["item", "model-value", "runtime-cache", "rules", "disabled"])
|
|
421
|
+
], 4))), 128)),
|
|
422
|
+
e.formType === "search" ? (p(), $("div", {
|
|
423
|
+
key: 0,
|
|
424
|
+
class: "vac-form-actions",
|
|
425
|
+
style: oe(E.value)
|
|
426
|
+
}, [
|
|
427
|
+
(p(), F(V(x(r).components.button), Y(x(r).render.getButtonProps({ type: "primary" }), { onClick: s }), {
|
|
428
|
+
default: S(() => [..._[1] || (_[1] = [
|
|
429
|
+
re(" 搜索 ", -1)
|
|
430
|
+
])]),
|
|
431
|
+
_: 1
|
|
432
|
+
}, 16)),
|
|
433
|
+
(p(), F(V(x(r).components.button), Y(x(r).render.getButtonProps({ type: "default" }), { onClick: y }), {
|
|
434
|
+
default: S(() => [..._[2] || (_[2] = [
|
|
435
|
+
re(" 重置 ", -1)
|
|
436
|
+
])]),
|
|
437
|
+
_: 1
|
|
438
|
+
}, 16)),
|
|
439
|
+
G(v.$slots, "searchButtonToolbar")
|
|
440
|
+
], 4)) : N("", !0)
|
|
441
|
+
], 4)
|
|
442
|
+
]),
|
|
443
|
+
_: 3
|
|
444
|
+
}, 16));
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
function we(e) {
|
|
448
|
+
return e.field ? String(e.field) : typeof e.key == "function" ? "" : e.key ? String(e.key) : "";
|
|
449
|
+
}
|
|
450
|
+
function st(e, n) {
|
|
451
|
+
const t = we(n);
|
|
452
|
+
return t ? W(e, t) : void 0;
|
|
453
|
+
}
|
|
454
|
+
function dt(e, n, t) {
|
|
455
|
+
return "show" in e ? !!le(e.show, e, n, t) : !0;
|
|
456
|
+
}
|
|
457
|
+
function me(e) {
|
|
458
|
+
return e.actions || e.buttons || [];
|
|
459
|
+
}
|
|
460
|
+
function ct(e, n) {
|
|
461
|
+
return "show" in n ? !!le(n.show, e, n) : !0;
|
|
462
|
+
}
|
|
463
|
+
function mt(e, n) {
|
|
464
|
+
return String(le(n.label, e, n));
|
|
465
|
+
}
|
|
466
|
+
function ft(e, n) {
|
|
467
|
+
return n.confirmText ? String(le(n.confirmText, e, n)) : "请确认是否继续操作?";
|
|
468
|
+
}
|
|
469
|
+
function pt(e, n = !0) {
|
|
470
|
+
if (e == null || e === "") return "";
|
|
471
|
+
const t = typeof n == "string" ? n : "YYYY-MM-DD HH:mm:ss";
|
|
472
|
+
return Le(e).format(t);
|
|
473
|
+
}
|
|
474
|
+
function vt(e) {
|
|
475
|
+
const n = typeof e == "object" ? e : {};
|
|
476
|
+
return {
|
|
477
|
+
width: n.width ?? 40,
|
|
478
|
+
height: n.height ?? 40,
|
|
479
|
+
objectFit: n.objectFit ?? "cover",
|
|
480
|
+
preview: n.preview ?? !0
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
const gt = { class: "vac-copy-text" }, bt = /* @__PURE__ */ U({
|
|
484
|
+
__name: "CopyText",
|
|
485
|
+
props: {
|
|
486
|
+
value: {}
|
|
487
|
+
},
|
|
488
|
+
setup(e) {
|
|
489
|
+
const n = e, { adapter: t } = q(), d = m(() => n.value === null || n.value === void 0 ? "" : String(n.value));
|
|
490
|
+
async function u() {
|
|
491
|
+
try {
|
|
492
|
+
await Ge(d.value), t.feedback.success("复制成功");
|
|
493
|
+
} catch {
|
|
494
|
+
t.feedback.error("复制失败");
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return (r, a) => (p(), $("span", gt, [
|
|
498
|
+
C("span", null, B(d.value), 1),
|
|
499
|
+
C("button", {
|
|
500
|
+
class: "vac-link-button",
|
|
501
|
+
type: "button",
|
|
502
|
+
onClick: u
|
|
503
|
+
}, "复制")
|
|
504
|
+
]));
|
|
505
|
+
}
|
|
506
|
+
}), ht = { class: "vac-decode-text" }, yt = /* @__PURE__ */ U({
|
|
507
|
+
__name: "DecodeText",
|
|
508
|
+
props: {
|
|
509
|
+
value: {},
|
|
510
|
+
row: {}
|
|
511
|
+
},
|
|
512
|
+
setup(e) {
|
|
513
|
+
const n = e, t = q(), d = D(!1), u = D(""), r = m(() => n.value === null || n.value === void 0 ? "" : String(n.value)), a = m(() => r.value ? "******" : "");
|
|
514
|
+
async function i() {
|
|
515
|
+
if (d.value) {
|
|
516
|
+
d.value = !1;
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
try {
|
|
520
|
+
u.value = t.decode ? await t.decode(n.value, n.row) : r.value, await t.decodeLog?.(n.value, n.row), d.value = !0;
|
|
521
|
+
} catch {
|
|
522
|
+
t.adapter.feedback.error("查看失败");
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return (f, T) => (p(), $("span", ht, [
|
|
526
|
+
C("span", null, B(d.value ? u.value : a.value), 1),
|
|
527
|
+
C("button", {
|
|
528
|
+
class: "vac-link-button",
|
|
529
|
+
type: "button",
|
|
530
|
+
onClick: i
|
|
531
|
+
}, B(d.value ? "隐藏" : "查看"), 1)
|
|
532
|
+
]));
|
|
533
|
+
}
|
|
534
|
+
}), Ct = {
|
|
535
|
+
key: 0,
|
|
536
|
+
class: "vac-tabs"
|
|
537
|
+
}, wt = ["disabled", "onClick"], _t = { class: "vac-table-toolbar" }, Tt = {
|
|
538
|
+
key: 0,
|
|
539
|
+
class: "vac-table-height-debug"
|
|
540
|
+
}, St = /* @__PURE__ */ U({
|
|
541
|
+
__name: "DynamicTable",
|
|
542
|
+
props: {
|
|
543
|
+
tableConfig: {}
|
|
544
|
+
},
|
|
545
|
+
setup(e) {
|
|
546
|
+
const n = e, { adapter: t } = q(), d = D(null), u = D(null), r = D(null), a = D(), i = D(0), f = D({
|
|
547
|
+
visible: !1,
|
|
548
|
+
adapter: t.name,
|
|
549
|
+
boundaryBottom: 0,
|
|
550
|
+
bodyTop: 0,
|
|
551
|
+
paginationHeight: 0,
|
|
552
|
+
bottomGap: 0,
|
|
553
|
+
adapterOffset: 0,
|
|
554
|
+
rawHeight: 0,
|
|
555
|
+
tableBoxHeight: 0,
|
|
556
|
+
headerHeight: 0,
|
|
557
|
+
scrollY: 0,
|
|
558
|
+
pageOverflow: 0
|
|
559
|
+
});
|
|
560
|
+
let T;
|
|
561
|
+
const R = U({
|
|
562
|
+
props: {
|
|
563
|
+
renderer: {
|
|
564
|
+
type: Function,
|
|
565
|
+
required: !0
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
setup(o) {
|
|
569
|
+
return () => o.renderer();
|
|
570
|
+
}
|
|
571
|
+
}), A = m(() => n.tableConfig.columns.filter((o, l) => dt(o, n.tableConfig.data, l))), w = m(() => A.value.map((o, l) => s(o, l))), E = m(
|
|
572
|
+
() => t.table.getTableProps({
|
|
573
|
+
columns: w.value,
|
|
574
|
+
data: n.tableConfig.data,
|
|
575
|
+
loading: n.tableConfig.loading,
|
|
576
|
+
rowKey: n.tableConfig.rowKey,
|
|
577
|
+
scrollY: O.value,
|
|
578
|
+
scrollX: n.tableConfig.scroll.x
|
|
579
|
+
})
|
|
580
|
+
), z = m(() => {
|
|
581
|
+
const o = n.tableConfig.scroll.height;
|
|
582
|
+
if (!(o !== !0 && o !== void 0) && a.value && t.name !== "element-plus")
|
|
583
|
+
return {
|
|
584
|
+
height: `${a.value}px`,
|
|
585
|
+
overflow: "hidden"
|
|
586
|
+
};
|
|
587
|
+
}), O = m(() => {
|
|
588
|
+
const o = n.tableConfig.scroll.height;
|
|
589
|
+
if (o !== !1)
|
|
590
|
+
return o === !0 || o === void 0 ? a.value ? t.name === "element-plus" ? a.value : Math.max(a.value - i.value - Pe(), 180) : void 0 : o;
|
|
591
|
+
}), L = m(() => t.table.getPaginationProps(n.tableConfig.pagination)), h = m(
|
|
592
|
+
() => t.table.getPaginationEvents({
|
|
593
|
+
onPageChange: (o) => {
|
|
594
|
+
n.tableConfig.setPage(o);
|
|
595
|
+
},
|
|
596
|
+
onPageSizeChange: (o) => {
|
|
597
|
+
n.tableConfig.setPageSize(o);
|
|
598
|
+
}
|
|
599
|
+
})
|
|
600
|
+
);
|
|
601
|
+
function I(o) {
|
|
602
|
+
return o;
|
|
603
|
+
}
|
|
604
|
+
function P(o) {
|
|
605
|
+
return typeof o == "string" ? fe(o) : o;
|
|
606
|
+
}
|
|
607
|
+
function M(o, l) {
|
|
608
|
+
return we(o) || String(l);
|
|
609
|
+
}
|
|
610
|
+
function s(o, l) {
|
|
611
|
+
const g = t.table.getTableColumnProps(o);
|
|
612
|
+
return t.name === "ant-design-vue" ? {
|
|
613
|
+
...g,
|
|
614
|
+
customRender: ({ record: c, index: H }) => y(c, o, H)
|
|
615
|
+
} : {
|
|
616
|
+
...g,
|
|
617
|
+
render: (c, H) => y(c, o, H ?? l)
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function y(o, l, g) {
|
|
621
|
+
const c = st(o, l);
|
|
622
|
+
return l.render ? l.render(o, l, g) : me(l).length > 0 ? v(o, l) : l.decode ? K(yt, { value: c, row: o }) : l.copy ? K(bt, { value: c }) : l.image ? _(c, l) : l.dateTime ? pt(c, l.dateTime) : c == null ? "" : String(c);
|
|
623
|
+
}
|
|
624
|
+
function v(o, l) {
|
|
625
|
+
const g = me(l).filter((c) => ct(o, c));
|
|
626
|
+
return K(
|
|
627
|
+
"span",
|
|
628
|
+
{ class: "vac-actions" },
|
|
629
|
+
g.map((c) => {
|
|
630
|
+
const H = t.render.getButtonProps({ type: t.render.normalizeActionType(c), size: c.size }), te = async (ne) => {
|
|
631
|
+
(c.confirm ?? c.isConfirm) && !window.confirm(ft(o, c)) || await c.onClick(o, ne);
|
|
632
|
+
};
|
|
633
|
+
return K(P(t.components.button), { ...H, onClick: te }, () => mt(o, c));
|
|
634
|
+
})
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
function _(o, l) {
|
|
638
|
+
const g = o == null ? "" : String(o), c = vt(l.image), H = t.render.getImageProps({ src: g, ...c });
|
|
639
|
+
return K(P(t.components.image), { ...H, class: "vac-image" });
|
|
640
|
+
}
|
|
641
|
+
async function b(o) {
|
|
642
|
+
await n.tableConfig.setTabsValue(o);
|
|
643
|
+
}
|
|
644
|
+
function k() {
|
|
645
|
+
if (n.tableConfig.scroll.height !== !0 && n.tableConfig.scroll.height !== void 0 || typeof window > "u") return;
|
|
646
|
+
const o = u.value;
|
|
647
|
+
if (!o) return;
|
|
648
|
+
i.value = Be(o);
|
|
649
|
+
const l = o.getBoundingClientRect().top, g = n.tableConfig.showPagination ? Te(r.value) : 0, c = Se(o), H = xe(o), te = Fe(), ne = Math.floor(c - l - g - H - te);
|
|
650
|
+
a.value = _e(ne), Ve({
|
|
651
|
+
boundaryBottom: c,
|
|
652
|
+
bodyTop: l,
|
|
653
|
+
paginationHeight: g,
|
|
654
|
+
bottomGap: H,
|
|
655
|
+
adapterOffset: te,
|
|
656
|
+
rawHeight: ne,
|
|
657
|
+
tableBoxHeight: a.value,
|
|
658
|
+
headerHeight: i.value
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
function J() {
|
|
662
|
+
Oe(() => {
|
|
663
|
+
k(), requestAnimationFrame(() => {
|
|
664
|
+
k(), requestAnimationFrame(k);
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function _e(o) {
|
|
669
|
+
const l = t.name === "element-plus" ? 360 : 240;
|
|
670
|
+
return o >= l ? o : a.value && a.value > l ? a.value : l;
|
|
671
|
+
}
|
|
672
|
+
function Te(o) {
|
|
673
|
+
if (!o) return 0;
|
|
674
|
+
const l = window.getComputedStyle(o);
|
|
675
|
+
return o.offsetHeight + Number.parseFloat(l.marginTop || "0") + Number.parseFloat(l.marginBottom || "0");
|
|
676
|
+
}
|
|
677
|
+
function Se(o) {
|
|
678
|
+
if (t.name === "element-plus") return window.innerHeight;
|
|
679
|
+
let l = o.parentElement;
|
|
680
|
+
for (; l && l !== document.body && l !== document.documentElement; ) {
|
|
681
|
+
const g = window.getComputedStyle(l), c = l.scrollHeight > l.clientHeight + 1;
|
|
682
|
+
if (/(auto|scroll|overlay)/.test(g.overflowY) && c && l.clientHeight > 0)
|
|
683
|
+
return l.getBoundingClientRect().bottom;
|
|
684
|
+
l = l.parentElement;
|
|
685
|
+
}
|
|
686
|
+
return window.innerHeight;
|
|
687
|
+
}
|
|
688
|
+
function xe(o) {
|
|
689
|
+
const l = o.closest(".el-card__body, .n-card__content, .ant-card-body"), g = o.closest(".demo-content, main, .page-content"), c = l ? Number.parseFloat(window.getComputedStyle(l).paddingBottom || "0") : 0, H = g ? Number.parseFloat(window.getComputedStyle(g).paddingBottom || "0") : 0;
|
|
690
|
+
return t.name === "element-plus" ? Math.max(16, c + H + 1) : Math.max(16, c + H);
|
|
691
|
+
}
|
|
692
|
+
function Fe() {
|
|
693
|
+
return t.name === "naive" ? 21 : t.name === "ant-design-vue" ? 2 : 0;
|
|
694
|
+
}
|
|
695
|
+
function Pe() {
|
|
696
|
+
return t.name === "naive" ? 21 : t.name === "ant-design-vue" ? 2 : 0;
|
|
697
|
+
}
|
|
698
|
+
function Be(o) {
|
|
699
|
+
if (t.name === "element-plus") return 0;
|
|
700
|
+
const l = o.querySelector(".n-data-table-thead, .ant-table-thead");
|
|
701
|
+
return l ? Math.ceil(l.getBoundingClientRect().height) : 0;
|
|
702
|
+
}
|
|
703
|
+
function Ve(o) {
|
|
704
|
+
const l = typeof O.value == "number" ? O.value : Number.parseFloat(String(O.value || 0)), g = Math.max(document.documentElement.scrollHeight - window.innerHeight, document.body.scrollHeight - window.innerHeight, 0);
|
|
705
|
+
f.value = {
|
|
706
|
+
visible: !0,
|
|
707
|
+
adapter: t.name,
|
|
708
|
+
boundaryBottom: Math.round(o.boundaryBottom),
|
|
709
|
+
bodyTop: Math.round(o.bodyTop),
|
|
710
|
+
paginationHeight: Math.round(o.paginationHeight),
|
|
711
|
+
bottomGap: Math.round(o.bottomGap),
|
|
712
|
+
adapterOffset: Math.round(o.adapterOffset),
|
|
713
|
+
rawHeight: Math.round(o.rawHeight),
|
|
714
|
+
tableBoxHeight: Math.round(o.tableBoxHeight),
|
|
715
|
+
headerHeight: Math.round(o.headerHeight),
|
|
716
|
+
scrollY: Math.round(l),
|
|
717
|
+
pageOverflow: Math.round(g)
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
return ve(() => {
|
|
721
|
+
J(), window.addEventListener("resize", k), typeof ResizeObserver < "u" && (T = new ResizeObserver(J), d.value && T.observe(d.value), u.value && T.observe(u.value), r.value && T.observe(r.value));
|
|
722
|
+
}), ke(() => {
|
|
723
|
+
window.removeEventListener("resize", k), T?.disconnect();
|
|
724
|
+
}), $e(
|
|
725
|
+
() => [n.tableConfig.showPagination, n.tableConfig.data.length, n.tableConfig.scroll.height],
|
|
726
|
+
J
|
|
727
|
+
), (o, l) => (p(), $(Z, null, [
|
|
728
|
+
C("div", {
|
|
729
|
+
ref_key: "tableRootRef",
|
|
730
|
+
ref: d,
|
|
731
|
+
class: "vac-table-root"
|
|
732
|
+
}, [
|
|
733
|
+
e.tableConfig.tabs ? (p(), $("div", Ct, [
|
|
734
|
+
(p(!0), $(Z, null, ae(e.tableConfig.tabs.options, (g) => (p(), $("button", {
|
|
735
|
+
key: String(g.value),
|
|
736
|
+
class: ue(["vac-tab", { "is-active": g.value === e.tableConfig.tabs.value }]),
|
|
737
|
+
type: "button",
|
|
738
|
+
disabled: g.disabled,
|
|
739
|
+
onClick: (c) => b(g.value)
|
|
740
|
+
}, B(g.label), 11, wt))), 128))
|
|
741
|
+
])) : N("", !0),
|
|
742
|
+
C("div", _t, [
|
|
743
|
+
l[0] || (l[0] = C("div", null, null, -1)),
|
|
744
|
+
G(o.$slots, "tableToolbar")
|
|
745
|
+
]),
|
|
746
|
+
C("div", {
|
|
747
|
+
ref_key: "tableBodyRef",
|
|
748
|
+
ref: u,
|
|
749
|
+
class: "vac-table-body",
|
|
750
|
+
style: oe(z.value)
|
|
751
|
+
}, [
|
|
752
|
+
(p(), F(V(x(t).components.table), ee(pe(E.value)), {
|
|
753
|
+
default: S(() => [
|
|
754
|
+
x(t).table.useColumnConfig ? N("", !0) : (p(!0), $(Z, { key: 0 }, ae(A.value, (g, c) => (p(), F(V(x(t).components.tableColumn || "div"), Y({
|
|
755
|
+
key: M(g, c)
|
|
756
|
+
}, { ref_for: !0 }, x(t).table.getTableColumnProps(g)), {
|
|
757
|
+
default: S((H) => [
|
|
758
|
+
(p(), F(V(x(R)), {
|
|
759
|
+
renderer: () => y(H.row, g, H.$index ?? c)
|
|
760
|
+
}, null, 8, ["renderer"]))
|
|
761
|
+
]),
|
|
762
|
+
_: 2
|
|
763
|
+
}, 1040))), 128))
|
|
764
|
+
]),
|
|
765
|
+
_: 1
|
|
766
|
+
}, 16))
|
|
767
|
+
], 4),
|
|
768
|
+
e.tableConfig.showPagination ? (p(), $("div", {
|
|
769
|
+
key: 1,
|
|
770
|
+
ref_key: "paginationRef",
|
|
771
|
+
ref: r,
|
|
772
|
+
class: "vac-pagination"
|
|
773
|
+
}, [
|
|
774
|
+
(p(), F(V(x(t).components.pagination), Y(L.value, Me(h.value)), null, 16))
|
|
775
|
+
], 512)) : N("", !0)
|
|
776
|
+
], 512),
|
|
777
|
+
(p(), F(Re, { to: "body" }, [
|
|
778
|
+
f.value.visible ? (p(), $("div", Tt, [
|
|
779
|
+
C("span", null, "adapter: " + B(f.value.adapter), 1),
|
|
780
|
+
C("span", null, "边界底部: " + B(f.value.boundaryBottom) + "px", 1),
|
|
781
|
+
C("span", null, "表格top: " + B(f.value.bodyTop) + "px", 1),
|
|
782
|
+
C("span", null, "分页占位: " + B(f.value.paginationHeight) + "px", 1),
|
|
783
|
+
C("span", null, "底部预留: " + B(f.value.bottomGap) + "px", 1),
|
|
784
|
+
C("span", null, "UI回收: " + B(f.value.adapterOffset) + "px", 1),
|
|
785
|
+
C("span", null, "原始高度: " + B(f.value.rawHeight) + "px", 1),
|
|
786
|
+
C("span", null, "表格盒子: " + B(f.value.tableBoxHeight) + "px", 1),
|
|
787
|
+
C("span", null, "表头: " + B(f.value.headerHeight) + "px", 1),
|
|
788
|
+
C("span", null, "scrollY: " + B(f.value.scrollY) + "px", 1),
|
|
789
|
+
C("span", {
|
|
790
|
+
class: ue({ "is-warning": f.value.pageOverflow > 0 })
|
|
791
|
+
}, "页面溢出: " + B(f.value.pageOverflow) + "px", 3)
|
|
792
|
+
])) : N("", !0)
|
|
793
|
+
]))
|
|
794
|
+
], 64));
|
|
795
|
+
}
|
|
796
|
+
}), xt = { class: "vac-root" }, Mt = /* @__PURE__ */ U({
|
|
797
|
+
__name: "AutoCrud",
|
|
798
|
+
props: {
|
|
799
|
+
title: {},
|
|
800
|
+
rowKey: { type: [String, Function] },
|
|
801
|
+
searchFormConfig: {},
|
|
802
|
+
tableConfig: {},
|
|
803
|
+
modalFormConfig: {}
|
|
804
|
+
},
|
|
805
|
+
setup(e) {
|
|
806
|
+
const n = e, { adapter: t } = q(), d = D(null), u = D(null), r = m(() => n.searchFormConfig), a = m(() => n.tableConfig), i = m(() => n.modalFormConfig), f = m(() => {
|
|
807
|
+
const s = r.value;
|
|
808
|
+
return s ? s.columns.map((y) => {
|
|
809
|
+
if (!h(y)) return y;
|
|
810
|
+
const v = y.onChange;
|
|
811
|
+
return {
|
|
812
|
+
...y,
|
|
813
|
+
async onChange(_, b) {
|
|
814
|
+
await v?.(_, b), await O(b.formData);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
}) : [];
|
|
818
|
+
}), T = {
|
|
819
|
+
add: "新增",
|
|
820
|
+
edit: "编辑",
|
|
821
|
+
view: "查看"
|
|
822
|
+
}, R = m(() => {
|
|
823
|
+
const s = i.value;
|
|
824
|
+
if (!s) return "";
|
|
825
|
+
const y = s.titleMap?.[s.mode];
|
|
826
|
+
return y || `${T[s.mode]}${n.title || ""}`;
|
|
827
|
+
}), A = m(() => {
|
|
828
|
+
const s = i.value;
|
|
829
|
+
return s?.buttonTextMap?.[s.mode]?.submit || "提交";
|
|
830
|
+
}), w = m(() => {
|
|
831
|
+
const s = i.value;
|
|
832
|
+
return s?.buttonTextMap?.[s.mode]?.cancel || "关闭";
|
|
833
|
+
}), E = m(() => {
|
|
834
|
+
const s = i.value;
|
|
835
|
+
return s ? s.mode !== "view" ? s.columns : s.columns.map((y) => ({ ...y, disabled: !0 })) : [];
|
|
836
|
+
});
|
|
837
|
+
ve(() => {
|
|
838
|
+
a.value?.immediate && a.value.load();
|
|
839
|
+
});
|
|
840
|
+
function z(s) {
|
|
841
|
+
return s;
|
|
842
|
+
}
|
|
843
|
+
async function O(s) {
|
|
844
|
+
await r.value?.submit(s), await a.value?.reset();
|
|
845
|
+
}
|
|
846
|
+
async function L() {
|
|
847
|
+
await r.value?.reset(), await a.value?.reset();
|
|
848
|
+
}
|
|
849
|
+
function h(s) {
|
|
850
|
+
return ["select", "multipleSelect"].includes(ge(s));
|
|
851
|
+
}
|
|
852
|
+
function I() {
|
|
853
|
+
const s = i.value;
|
|
854
|
+
s ? s.openAdd() : t.feedback.warning("请先配置弹窗表单 modalFormConfig"), r.value?.onAddClick?.();
|
|
855
|
+
}
|
|
856
|
+
function P(s) {
|
|
857
|
+
i.value && (i.value.visible = s);
|
|
858
|
+
}
|
|
859
|
+
async function M() {
|
|
860
|
+
await u.value?.submit();
|
|
861
|
+
}
|
|
862
|
+
return (s, y) => (p(), $("div", xt, [
|
|
863
|
+
r.value ? (p(), F(V(x(t).components.card), {
|
|
864
|
+
key: 0,
|
|
865
|
+
class: "vac-search-card"
|
|
866
|
+
}, {
|
|
867
|
+
default: S(() => [
|
|
868
|
+
X(ce, {
|
|
869
|
+
ref_key: "searchFormRef",
|
|
870
|
+
ref: d,
|
|
871
|
+
"form-type": "search",
|
|
872
|
+
columns: f.value,
|
|
873
|
+
modelValue: r.value.data,
|
|
874
|
+
"onUpdate:modelValue": y[0] || (y[0] = (v) => r.value.data = v),
|
|
875
|
+
layout: r.value.layout,
|
|
876
|
+
onSubmit: O,
|
|
877
|
+
onReset: L
|
|
878
|
+
}, {
|
|
879
|
+
searchButtonToolbar: S(() => [
|
|
880
|
+
r.value.addButton ? (p(), F(V(x(t).components.button), Y({ key: 0 }, x(t).render.getButtonProps({ type: "primary" }), { onClick: I }), {
|
|
881
|
+
default: S(() => [
|
|
882
|
+
re(B(r.value.addButtonText), 1)
|
|
883
|
+
]),
|
|
884
|
+
_: 1
|
|
885
|
+
}, 16)) : N("", !0),
|
|
886
|
+
G(s.$slots, "searchButtonToolbar")
|
|
887
|
+
]),
|
|
888
|
+
_: 3
|
|
889
|
+
}, 8, ["columns", "modelValue", "layout"])
|
|
890
|
+
]),
|
|
891
|
+
_: 3
|
|
892
|
+
})) : N("", !0),
|
|
893
|
+
a.value ? (p(), F(V(x(t).components.card), {
|
|
894
|
+
key: 1,
|
|
895
|
+
class: "vac-table-card"
|
|
896
|
+
}, {
|
|
897
|
+
default: S(() => [
|
|
898
|
+
X(St, { "table-config": a.value }, {
|
|
899
|
+
tableToolbar: S(() => [
|
|
900
|
+
G(s.$slots, "tableToolbar")
|
|
901
|
+
]),
|
|
902
|
+
_: 3
|
|
903
|
+
}, 8, ["table-config"])
|
|
904
|
+
]),
|
|
905
|
+
_: 3
|
|
906
|
+
})) : N("", !0),
|
|
907
|
+
i.value ? (p(), F(Qe, {
|
|
908
|
+
key: 2,
|
|
909
|
+
visible: i.value.visible,
|
|
910
|
+
title: R.value,
|
|
911
|
+
mode: i.value.mode,
|
|
912
|
+
"modal-type": i.value.modalType,
|
|
913
|
+
"submit-text": A.value,
|
|
914
|
+
"cancel-text": w.value,
|
|
915
|
+
"onUpdate:visible": P,
|
|
916
|
+
onSubmit: M,
|
|
917
|
+
onClose: i.value.close
|
|
918
|
+
}, De({
|
|
919
|
+
default: S(() => [
|
|
920
|
+
X(ce, {
|
|
921
|
+
ref_key: "modalFormRef",
|
|
922
|
+
ref: u,
|
|
923
|
+
"form-type": "modal",
|
|
924
|
+
columns: E.value,
|
|
925
|
+
modelValue: i.value.data,
|
|
926
|
+
"onUpdate:modelValue": y[1] || (y[1] = (v) => i.value.data = v),
|
|
927
|
+
layout: i.value.layout,
|
|
928
|
+
disabled: i.value.mode === "view",
|
|
929
|
+
onSubmit: y[2] || (y[2] = (v) => i.value?.submit(v))
|
|
930
|
+
}, null, 8, ["columns", "modelValue", "layout", "disabled"])
|
|
931
|
+
]),
|
|
932
|
+
_: 2
|
|
933
|
+
}, [
|
|
934
|
+
s.$slots.modalFooter ? {
|
|
935
|
+
name: "footer",
|
|
936
|
+
fn: S(() => [
|
|
937
|
+
G(s.$slots, "modalFooter", {
|
|
938
|
+
modalForm: i.value,
|
|
939
|
+
submit: M,
|
|
940
|
+
close: i.value.close
|
|
941
|
+
})
|
|
942
|
+
]),
|
|
943
|
+
key: "0"
|
|
944
|
+
} : void 0
|
|
945
|
+
]), 1032, ["visible", "title", "mode", "modal-type", "submit-text", "cancel-text", "onClose"])) : N("", !0)
|
|
946
|
+
]));
|
|
947
|
+
}
|
|
948
|
+
}), Ft = {
|
|
949
|
+
"element-plus": be,
|
|
950
|
+
naive: Ke,
|
|
951
|
+
"ant-design-vue": je
|
|
952
|
+
};
|
|
953
|
+
function Pt(e) {
|
|
954
|
+
return e.adapter ? e.adapter : Ft[e.ui || "element-plus"];
|
|
955
|
+
}
|
|
956
|
+
function Rt(e = {}) {
|
|
957
|
+
return {
|
|
958
|
+
install(t, d) {
|
|
959
|
+
const u = { ...e, ...d || {} }, r = We(u, Pt(u));
|
|
960
|
+
qe(r), t.provide(he, r);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
export {
|
|
965
|
+
Mt as AutoCrud,
|
|
966
|
+
bt as CopyText,
|
|
967
|
+
Qe as CrudModal,
|
|
968
|
+
yt as DecodeText,
|
|
969
|
+
ce as DynamicForm,
|
|
970
|
+
St as DynamicTable,
|
|
971
|
+
je as antDesignVueAdapter,
|
|
972
|
+
Ge as copyText,
|
|
973
|
+
Rt as createAutoCrud,
|
|
974
|
+
It as createRequest,
|
|
975
|
+
be as elementPlusAdapter,
|
|
976
|
+
Ke as naiveAdapter,
|
|
977
|
+
Yt as showCrudMessage,
|
|
978
|
+
jt as sm4Decrypt,
|
|
979
|
+
Kt as sm4Encrypt,
|
|
980
|
+
q as useAutoCrudContext,
|
|
981
|
+
Et as useModalForm,
|
|
982
|
+
zt as useSearchForm,
|
|
983
|
+
Nt as useTable
|
|
984
|
+
};
|
|
985
|
+
//# sourceMappingURL=index.js.map
|