@lumal/core 0.0.1-beta → 0.0.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +13 -13
- package/dist/components-CYwpPqgm.cjs +2 -0
- package/dist/components-DVnNb4-n.js +2254 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{composables-C9EuCUjj.js → composables-DrGkFGvy.js} +39 -32
- package/dist/composables-edipbw70.cjs +1 -0
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +18 -17
- package/dist/core.css +1 -1
- package/dist/{dictionary-ClEWtQCU.cjs → dictionary-BtPCmrLY.cjs} +1 -1
- package/dist/{dictionary-B7tsaVqB.js → dictionary-CKEqfCLG.js} +1 -1
- package/dist/dictionary.cjs +1 -1
- package/dist/dictionary.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +42 -42
- package/dist/layout-7345ntRV.cjs +1 -0
- package/dist/{layout-C8H9wuQa.js → layout-CuuRkGBF.js} +211 -201
- package/dist/layout.cjs +1 -1
- package/dist/layout.js +1 -1
- package/dist/request.cjs +1 -1
- package/dist/request.js +22 -19
- package/dist/router.cjs +1 -1
- package/dist/router.js +24 -21
- package/dist/src/app/createLumalAdmin.d.ts.map +1 -1
- package/dist/src/components/crud-table/LumalCrudTable.vue.d.ts.map +1 -1
- package/dist/src/components/crud-table/useCrudData.d.ts.map +1 -1
- package/dist/src/components/crud-table/useCrudDialog.d.ts +1 -1
- package/dist/src/components/crud-table/useCrudDialog.d.ts.map +1 -1
- package/dist/src/components/schema-form/LumalSchemaForm.vue.d.ts.map +1 -1
- package/dist/src/components/schema-table/LumalSchemaTable.vue.d.ts.map +1 -1
- package/dist/src/components/schema-table/cell.d.ts +1 -1
- package/dist/src/components/schema-table/cell.d.ts.map +1 -1
- package/dist/src/composables/usePagination.d.ts.map +1 -1
- package/dist/src/dictionary/index.d.ts +1 -1
- package/dist/src/dictionary/index.d.ts.map +1 -1
- package/dist/src/dictionary/normalize.d.ts +3 -1
- package/dist/src/dictionary/normalize.d.ts.map +1 -1
- package/dist/src/layout/LumalTabs.vue.d.ts.map +1 -1
- package/dist/src/request/client.d.ts.map +1 -1
- package/dist/src/router/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/theme-chalk/index.scss +2 -2
- package/dist/components-DJiHYQQB.cjs +0 -2
- package/dist/components-DYmKh-eF.js +0 -2206
- package/dist/composables-C4twj5Ov.cjs +0 -1
- package/dist/layout-ZnyG9X3N.cjs +0 -1
|
@@ -0,0 +1,2254 @@
|
|
|
1
|
+
import { f as e, i as t, p as n } from "./composables-DrGkFGvy.js";
|
|
2
|
+
import { t as r } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
3
|
+
import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createSlots as u, createTextVNode as d, createVNode as f, defineComponent as p, guardReactiveProps as m, mergeModels as h, mergeProps as g, nextTick as _, normalizeClass as v, normalizeProps as y, normalizeStyle as b, onBeforeUnmount as x, onMounted as S, openBlock as C, reactive as w, renderList as T, renderSlot as E, shallowRef as D, toDisplayString as O, unref as k, useModel as ee, useSlots as A, useTemplateRef as j, vShow as M, watch as N, withCtx as P, withDirectives as te, withKeys as ne, withModifiers as F } from "vue";
|
|
4
|
+
import { LumalIcon as I, LumalIcon as re, LumalIconPicker as L, LumalIconPickerDialog as ie } from "@lumal/icons-vue";
|
|
5
|
+
import { ElButton as R, ElCheckbox as ae, ElCheckboxGroup as oe, ElCol as z, ElDatePicker as se, ElDialog as B, ElDrawer as ce, ElForm as le, ElFormItem as ue, ElInput as de, ElInputNumber as fe, ElLoading as pe, ElMessageBox as me, ElOption as he, ElPagination as ge, ElPopover as _e, ElRadio as ve, ElRadioGroup as ye, ElRow as be, ElSelect as xe, ElSwitch as Se, ElTable as Ce, ElTableColumn as we, ElTreeSelect as Te, ElUpload as Ee } from "element-plus";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/components/pagination/LumalPagination.vue
|
|
8
|
+
var De = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
9
|
+
__name: "LumalPagination",
|
|
10
|
+
props: /*@__PURE__*/ h({
|
|
11
|
+
total: {},
|
|
12
|
+
pageSizes: { default: () => [
|
|
13
|
+
10,
|
|
14
|
+
20,
|
|
15
|
+
50,
|
|
16
|
+
100
|
|
17
|
+
] },
|
|
18
|
+
disabled: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: !1
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
page: { default: 1 },
|
|
24
|
+
pageModifiers: {},
|
|
25
|
+
pageSize: { default: 10 },
|
|
26
|
+
pageSizeModifiers: {}
|
|
27
|
+
}),
|
|
28
|
+
emits: /*@__PURE__*/ h(["change"], ["update:page", "update:pageSize"]),
|
|
29
|
+
setup(e, { expose: t, emit: n }) {
|
|
30
|
+
let r = e, i = n, s = ee(e, "page"), c = ee(e, "pageSize"), l = j("paginationRef"), u = a(() => Math.max(1, Math.ceil(r.total / c.value)));
|
|
31
|
+
function d(e, t) {
|
|
32
|
+
i("change", {
|
|
33
|
+
page: e,
|
|
34
|
+
pageSize: t
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function f(e) {
|
|
38
|
+
if (r.disabled) return;
|
|
39
|
+
let t = Math.min(Math.max(e, 1), u.value);
|
|
40
|
+
s.value = t, d(t, c.value);
|
|
41
|
+
}
|
|
42
|
+
function p(e) {
|
|
43
|
+
r.disabled || (c.value = e, s.value = 1, d(1, e));
|
|
44
|
+
}
|
|
45
|
+
return t({
|
|
46
|
+
getPaginationElement: () => l.value?.$el,
|
|
47
|
+
getPaginationInstance: () => l.value
|
|
48
|
+
}), (t, n) => (C(), o(k(ge), {
|
|
49
|
+
ref_key: "paginationRef",
|
|
50
|
+
ref: l,
|
|
51
|
+
class: "lumal-pagination",
|
|
52
|
+
background: "",
|
|
53
|
+
layout: "total, sizes, prev, pager, next, jumper",
|
|
54
|
+
"current-page": s.value,
|
|
55
|
+
"page-size": c.value,
|
|
56
|
+
"page-sizes": e.pageSizes,
|
|
57
|
+
total: e.total,
|
|
58
|
+
disabled: e.disabled,
|
|
59
|
+
onCurrentChange: f,
|
|
60
|
+
onSizeChange: p
|
|
61
|
+
}, null, 8, [
|
|
62
|
+
"current-page",
|
|
63
|
+
"page-size",
|
|
64
|
+
"page-sizes",
|
|
65
|
+
"total",
|
|
66
|
+
"disabled"
|
|
67
|
+
]));
|
|
68
|
+
}
|
|
69
|
+
}), [["__scopeId", "data-v-d546f46b"]]);
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/components/schema-form/normalize.ts
|
|
72
|
+
function Oe(e) {
|
|
73
|
+
return `lumal-schema-form-${e.replace(/[^\w-]/g, "-")}`;
|
|
74
|
+
}
|
|
75
|
+
function V(e, t) {
|
|
76
|
+
return typeof e == "function" ? !!e(t) : !!e;
|
|
77
|
+
}
|
|
78
|
+
function H(e, t, n) {
|
|
79
|
+
return typeof e == "function" ? e(t) : e ?? n;
|
|
80
|
+
}
|
|
81
|
+
function ke(e, t) {
|
|
82
|
+
return !e.authority || t.canAccess?.(e.authority) !== !1;
|
|
83
|
+
}
|
|
84
|
+
function U(e = [], t = {}) {
|
|
85
|
+
let n = t.model ?? {};
|
|
86
|
+
return e.filter((e) => e.field.trim()).map((e) => {
|
|
87
|
+
let r = {
|
|
88
|
+
field: e.field,
|
|
89
|
+
getValues: () => n,
|
|
90
|
+
mode: t.mode ?? "create",
|
|
91
|
+
model: n,
|
|
92
|
+
setFieldValue: t.setFieldValue ?? (() => void 0),
|
|
93
|
+
value: n[e.field]
|
|
94
|
+
}, i = e.component ?? (e.dictionary || e.dictType ? "select" : "input"), a = V(e.hidden, r), o = V(e.disabled, r), s = e.readonlyAuthority ? t.canAccess?.(e.readonlyAuthority) === !1 : !1, c = r.mode === "view" || s || V(e.readonly, r), l = !a && i !== "hidden" && ke(e, t), u = H(e.componentProps, r, {}), d = typeof e.options == "function" ? e.options(r) : k(e.options);
|
|
95
|
+
return {
|
|
96
|
+
...e,
|
|
97
|
+
id: Oe(e.field),
|
|
98
|
+
component: i,
|
|
99
|
+
componentProps: { ...u },
|
|
100
|
+
description: H(e.description, r, ""),
|
|
101
|
+
disabled: o,
|
|
102
|
+
help: H(e.help, r, ""),
|
|
103
|
+
options: d ?? [],
|
|
104
|
+
required: V(e.required, r),
|
|
105
|
+
readonly: c,
|
|
106
|
+
renderable: l,
|
|
107
|
+
rules: H(e.rules, r, [])
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function W(e, t = {}) {
|
|
112
|
+
return e.reduce((e, t) => (!(t.field in e) && t.defaultValue !== void 0 && (e[t.field] = t.defaultValue), e), { ...t });
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/components/schema-form/LumalSchemaForm.vue?vue&type=script&setup=true&lang.ts
|
|
116
|
+
var G = {
|
|
117
|
+
key: 0,
|
|
118
|
+
class: "lumal-schema-form__readonly-value"
|
|
119
|
+
}, Ae = {
|
|
120
|
+
key: 0,
|
|
121
|
+
class: "lumal-schema-form__description"
|
|
122
|
+
}, K = {
|
|
123
|
+
key: 1,
|
|
124
|
+
class: "lumal-schema-form__help"
|
|
125
|
+
}, q = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
126
|
+
__name: "LumalSchemaForm",
|
|
127
|
+
props: /*@__PURE__*/ h({
|
|
128
|
+
canAccess: {},
|
|
129
|
+
actionLayout: { default: "rowEnd" },
|
|
130
|
+
actionPosition: { default: "right" },
|
|
131
|
+
columns: { default: 1 },
|
|
132
|
+
compact: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
default: !1
|
|
135
|
+
},
|
|
136
|
+
disabled: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: !1
|
|
139
|
+
},
|
|
140
|
+
gutter: { default: 16 },
|
|
141
|
+
labelPosition: { default: "right" },
|
|
142
|
+
labelWidth: { default: "auto" },
|
|
143
|
+
loading: {
|
|
144
|
+
type: Boolean,
|
|
145
|
+
default: !1
|
|
146
|
+
},
|
|
147
|
+
mode: { default: "create" },
|
|
148
|
+
resetText: { default: "重置" },
|
|
149
|
+
schemas: {},
|
|
150
|
+
scrollToFirstError: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
default: !0
|
|
153
|
+
},
|
|
154
|
+
showReset: {
|
|
155
|
+
type: Boolean,
|
|
156
|
+
default: !1
|
|
157
|
+
},
|
|
158
|
+
submitLoading: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: !1
|
|
161
|
+
},
|
|
162
|
+
submitOnEnter: {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
default: !1
|
|
165
|
+
},
|
|
166
|
+
submitText: { default: "提交" },
|
|
167
|
+
showActions: {
|
|
168
|
+
type: Boolean,
|
|
169
|
+
default: !1
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
modelValue: { default: () => ({}) },
|
|
173
|
+
modelModifiers: {}
|
|
174
|
+
}),
|
|
175
|
+
emits: /*@__PURE__*/ h([
|
|
176
|
+
"reset",
|
|
177
|
+
"submit",
|
|
178
|
+
"valuesChange"
|
|
179
|
+
], ["update:modelValue"]),
|
|
180
|
+
setup(e, { expose: n, emit: r }) {
|
|
181
|
+
let l = e, p = r, m = ee(e, "modelValue"), h = j("formRef"), _ = pe.directive, y = D(l.mode);
|
|
182
|
+
N(() => l.mode, (e) => {
|
|
183
|
+
y.value = e;
|
|
184
|
+
});
|
|
185
|
+
let b = D({ ...m.value }), x = w(W(U(l.schemas, {
|
|
186
|
+
canAccess: l.canAccess,
|
|
187
|
+
mode: y.value,
|
|
188
|
+
model: m.value,
|
|
189
|
+
setFieldValue: Q
|
|
190
|
+
}), m.value)), S = a(() => x), A = D([]);
|
|
191
|
+
function M() {
|
|
192
|
+
A.value = l.schemas.map((e) => a(() => U([e], {
|
|
193
|
+
canAccess: l.canAccess,
|
|
194
|
+
mode: y.value,
|
|
195
|
+
model: x,
|
|
196
|
+
setFieldValue: Q
|
|
197
|
+
})[0]));
|
|
198
|
+
let e = W(U(l.schemas, {
|
|
199
|
+
canAccess: l.canAccess,
|
|
200
|
+
mode: y.value,
|
|
201
|
+
model: x,
|
|
202
|
+
setFieldValue: Q
|
|
203
|
+
}), x);
|
|
204
|
+
Object.keys(e).forEach((t) => {
|
|
205
|
+
Object.hasOwn(x, t) || (x[t] = e[t]);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
N(() => l.schemas, M, {
|
|
209
|
+
deep: !0,
|
|
210
|
+
immediate: !0
|
|
211
|
+
});
|
|
212
|
+
let I = a(() => A.value.map((e) => e.value).filter((e) => !!e)), re = a(() => I.value.filter((e) => e.renderable));
|
|
213
|
+
function L(e) {
|
|
214
|
+
let t = x, n = e;
|
|
215
|
+
Object.keys(t).forEach((e) => {
|
|
216
|
+
Object.hasOwn(n, e) || delete t[e];
|
|
217
|
+
}), Object.assign(t, n);
|
|
218
|
+
}
|
|
219
|
+
N(() => m.value, L, { deep: !0 });
|
|
220
|
+
let { dictionaryMap: ie } = t(() => I.value.map((e) => e.dictionary ?? e.dictType));
|
|
221
|
+
function B(e) {
|
|
222
|
+
let t = S.value[e];
|
|
223
|
+
return typeof t == "number" || typeof t == "string" ? t : t == null ? "" : String(t);
|
|
224
|
+
}
|
|
225
|
+
function ce(e) {
|
|
226
|
+
let t = S.value[e];
|
|
227
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "boolean" || typeof e == "number" || typeof e == "string") : typeof t == "boolean" || typeof t == "number" || typeof t == "string" ? t : "";
|
|
228
|
+
}
|
|
229
|
+
function me(e) {
|
|
230
|
+
let t = ce(e);
|
|
231
|
+
return Array.isArray(t) ? t[0] ?? "" : t;
|
|
232
|
+
}
|
|
233
|
+
function ge(e) {
|
|
234
|
+
let t = S.value[e];
|
|
235
|
+
if (typeof t == "number") return t;
|
|
236
|
+
if (typeof t == "string" && t.trim()) return Number(t);
|
|
237
|
+
}
|
|
238
|
+
function _e(e) {
|
|
239
|
+
return !!S.value[e];
|
|
240
|
+
}
|
|
241
|
+
function Ce(e) {
|
|
242
|
+
let t = S.value[e];
|
|
243
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "number" || typeof e == "string") : [];
|
|
244
|
+
}
|
|
245
|
+
function we(e) {
|
|
246
|
+
let t = S.value[e];
|
|
247
|
+
if (t instanceof Date || typeof t == "number" || typeof t == "string" || Array.isArray(t) && t.every((e) => e instanceof Date || typeof e == "number" || typeof e == "string")) return t;
|
|
248
|
+
}
|
|
249
|
+
function De(e) {
|
|
250
|
+
return e.component === "datetime" ? "datetime" : e.component === "daterange" ? "daterange" : "date";
|
|
251
|
+
}
|
|
252
|
+
function Oe(e) {
|
|
253
|
+
let t = S.value[e];
|
|
254
|
+
if (typeof t == "boolean" || typeof t == "number" || typeof t == "string" || t && typeof t == "object") return t;
|
|
255
|
+
}
|
|
256
|
+
function V(e) {
|
|
257
|
+
return String(e.componentProps.type ?? "text");
|
|
258
|
+
}
|
|
259
|
+
function H(e) {
|
|
260
|
+
return e.component === "daterange" ? [`${e.id}-start`, `${e.id}-end`] : e.id;
|
|
261
|
+
}
|
|
262
|
+
function ke(e) {
|
|
263
|
+
return e.component === "daterange" ? [`${e.field}-start`, `${e.field}-end`] : e.field;
|
|
264
|
+
}
|
|
265
|
+
function q(e) {
|
|
266
|
+
return l.disabled || e.disabled || e.readonly || y.value === "edit" && !!e.editDisabled || !!e.componentProps.disabled;
|
|
267
|
+
}
|
|
268
|
+
function je(e) {
|
|
269
|
+
return typeof e.span == "number" ? Math.min(24, Math.max(1, e.span)) : Math.floor(24 / Math.max(1, l.columns));
|
|
270
|
+
}
|
|
271
|
+
function J(e) {
|
|
272
|
+
let t = e.dictionary ?? e.dictType;
|
|
273
|
+
return t ? ie.value[t] ?? [] : e.options;
|
|
274
|
+
}
|
|
275
|
+
function Y(e) {
|
|
276
|
+
return e.componentProps;
|
|
277
|
+
}
|
|
278
|
+
function X(e) {
|
|
279
|
+
let t = S.value[e.field];
|
|
280
|
+
if (e.formatter) return e.formatter(t, S.value);
|
|
281
|
+
let n = (Array.isArray(t) ? t : [t]).map((t) => J(e).find((e) => String(e.value) === String(t))?.label ?? t).filter((e) => e != null && e !== "");
|
|
282
|
+
return n.length > 0 ? n.map(String).join(", ") : "-";
|
|
283
|
+
}
|
|
284
|
+
function Z(e, t) {
|
|
285
|
+
return {
|
|
286
|
+
field: e,
|
|
287
|
+
getValues: () => S.value,
|
|
288
|
+
mode: y.value,
|
|
289
|
+
model: S.value,
|
|
290
|
+
setFieldValue: Q,
|
|
291
|
+
value: t
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function Q(e, t) {
|
|
295
|
+
x[e] = t;
|
|
296
|
+
let n = { ...x };
|
|
297
|
+
m.value = n, I.value.find((t) => t.field === e)?.onChange?.(t, Z(e, t)), p("valuesChange", n, [e]);
|
|
298
|
+
}
|
|
299
|
+
function $(e, t) {
|
|
300
|
+
Q(e, t);
|
|
301
|
+
}
|
|
302
|
+
async function Me() {
|
|
303
|
+
y.value === "view" || l.submitLoading || await Be() && p("submit", S.value);
|
|
304
|
+
}
|
|
305
|
+
function Ne(e) {
|
|
306
|
+
!l.submitOnEnter || e.isComposing || e.target?.tagName === "TEXTAREA" || (e.preventDefault(), Me());
|
|
307
|
+
}
|
|
308
|
+
function Pe() {
|
|
309
|
+
Ve(), p("reset", S.value);
|
|
310
|
+
}
|
|
311
|
+
function Fe(e) {
|
|
312
|
+
return `field-${e.field}`;
|
|
313
|
+
}
|
|
314
|
+
function Ie(e) {
|
|
315
|
+
return `prefix-${e.field}`;
|
|
316
|
+
}
|
|
317
|
+
function Le(e) {
|
|
318
|
+
return `suffix-${e.field}`;
|
|
319
|
+
}
|
|
320
|
+
function Re(e) {
|
|
321
|
+
let t = {
|
|
322
|
+
...x,
|
|
323
|
+
...e
|
|
324
|
+
};
|
|
325
|
+
L(t), m.value = t;
|
|
326
|
+
}
|
|
327
|
+
function ze(e) {
|
|
328
|
+
y.value = e;
|
|
329
|
+
}
|
|
330
|
+
async function Be() {
|
|
331
|
+
try {
|
|
332
|
+
return await h.value?.validate?.() !== !1;
|
|
333
|
+
} catch (e) {
|
|
334
|
+
if (l.scrollToFirstError && e && typeof e == "object") {
|
|
335
|
+
let t = Object.keys(e)[0];
|
|
336
|
+
t && h.value?.scrollToField?.(t);
|
|
337
|
+
}
|
|
338
|
+
return !1;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function Ve() {
|
|
342
|
+
h.value?.resetFields?.();
|
|
343
|
+
let e = W(I.value, b.value);
|
|
344
|
+
L(e), m.value = e;
|
|
345
|
+
}
|
|
346
|
+
function He(e) {
|
|
347
|
+
h.value?.clearValidate?.(e);
|
|
348
|
+
}
|
|
349
|
+
function Ue(e) {
|
|
350
|
+
h.value?.scrollToField?.(e);
|
|
351
|
+
}
|
|
352
|
+
function We(e) {
|
|
353
|
+
return (h.value?.$el)?.querySelector(`[data-field="${e}"] input, [data-field="${e}"] textarea, [data-field="${e}"] select, [data-field="${e}"] button`) ?? void 0;
|
|
354
|
+
}
|
|
355
|
+
return n({
|
|
356
|
+
clearValidate: He,
|
|
357
|
+
getFieldComponent: We,
|
|
358
|
+
getFormElement: () => h.value?.$el,
|
|
359
|
+
getFormInstance: () => h.value,
|
|
360
|
+
getValues: () => S.value,
|
|
361
|
+
resetFields: Ve,
|
|
362
|
+
scrollToField: Ue,
|
|
363
|
+
setFieldValue: Q,
|
|
364
|
+
setMode: ze,
|
|
365
|
+
setValues: Re,
|
|
366
|
+
validate: Be
|
|
367
|
+
}), (t, n) => te((C(), o(k(le), {
|
|
368
|
+
ref_key: "formRef",
|
|
369
|
+
ref: h,
|
|
370
|
+
class: v(["lumal-schema-form", { "is-compact": l.compact }]),
|
|
371
|
+
disabled: l.disabled,
|
|
372
|
+
"label-position": l.labelPosition,
|
|
373
|
+
"label-width": l.labelWidth,
|
|
374
|
+
model: S.value,
|
|
375
|
+
onKeydown: ne(Ne, ["enter"]),
|
|
376
|
+
onSubmit: F(Me, ["prevent"])
|
|
377
|
+
}, {
|
|
378
|
+
default: P(() => [f(k(be), {
|
|
379
|
+
class: "lumal-schema-form__row",
|
|
380
|
+
gutter: l.gutter,
|
|
381
|
+
"data-columns": l.columns
|
|
382
|
+
}, {
|
|
383
|
+
default: P(() => [(C(!0), c(i, null, T(re.value, (e) => (C(), o(k(z), {
|
|
384
|
+
key: e.field,
|
|
385
|
+
span: je(e),
|
|
386
|
+
class: v({ "is-full-span": je(e) === 24 })
|
|
387
|
+
}, {
|
|
388
|
+
default: P(() => [f(k(ue), {
|
|
389
|
+
class: "lumal-schema-form__item",
|
|
390
|
+
label: e.label,
|
|
391
|
+
prop: e.field,
|
|
392
|
+
required: e.required,
|
|
393
|
+
rules: e.rules,
|
|
394
|
+
"data-field": e.field
|
|
395
|
+
}, {
|
|
396
|
+
default: P(() => [
|
|
397
|
+
E(t.$slots, Ie(e), {
|
|
398
|
+
model: S.value,
|
|
399
|
+
schema: e,
|
|
400
|
+
value: S.value[e.field]
|
|
401
|
+
}, void 0, !0),
|
|
402
|
+
E(t.$slots, Fe(e), {
|
|
403
|
+
model: S.value,
|
|
404
|
+
schema: e,
|
|
405
|
+
value: S.value[e.field]
|
|
406
|
+
}, () => [y.value === "view" ? (C(), c("span", G, O(X(e)), 1)) : e.component === "textarea" ? (C(), o(k(de), g({
|
|
407
|
+
key: 1,
|
|
408
|
+
ref_for: !0
|
|
409
|
+
}, Y(e), {
|
|
410
|
+
id: e.id,
|
|
411
|
+
"model-value": B(e.field),
|
|
412
|
+
name: e.field,
|
|
413
|
+
placeholder: e.placeholder,
|
|
414
|
+
disabled: q(e),
|
|
415
|
+
required: e.required,
|
|
416
|
+
type: "textarea",
|
|
417
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
418
|
+
}), null, 16, [
|
|
419
|
+
"id",
|
|
420
|
+
"model-value",
|
|
421
|
+
"name",
|
|
422
|
+
"placeholder",
|
|
423
|
+
"disabled",
|
|
424
|
+
"required",
|
|
425
|
+
"onUpdate:modelValue"
|
|
426
|
+
])) : e.component === "select" ? (C(), o(k(xe), g({
|
|
427
|
+
key: 2,
|
|
428
|
+
ref_for: !0
|
|
429
|
+
}, Y(e), {
|
|
430
|
+
id: e.id,
|
|
431
|
+
"model-value": ce(e.field),
|
|
432
|
+
name: e.field,
|
|
433
|
+
placeholder: e.placeholder,
|
|
434
|
+
disabled: q(e),
|
|
435
|
+
required: e.required,
|
|
436
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
437
|
+
}), {
|
|
438
|
+
default: P(() => [(C(!0), c(i, null, T(J(e), (e) => (C(), o(k(he), {
|
|
439
|
+
key: String(e.value),
|
|
440
|
+
label: e.label,
|
|
441
|
+
value: e.value,
|
|
442
|
+
disabled: e.disabled
|
|
443
|
+
}, null, 8, [
|
|
444
|
+
"label",
|
|
445
|
+
"value",
|
|
446
|
+
"disabled"
|
|
447
|
+
]))), 128))]),
|
|
448
|
+
_: 2
|
|
449
|
+
}, 1040, [
|
|
450
|
+
"id",
|
|
451
|
+
"model-value",
|
|
452
|
+
"name",
|
|
453
|
+
"placeholder",
|
|
454
|
+
"disabled",
|
|
455
|
+
"required",
|
|
456
|
+
"onUpdate:modelValue"
|
|
457
|
+
])) : e.component === "number" ? (C(), o(k(fe), g({
|
|
458
|
+
key: 3,
|
|
459
|
+
ref_for: !0
|
|
460
|
+
}, Y(e), {
|
|
461
|
+
id: e.id,
|
|
462
|
+
"model-value": ge(e.field),
|
|
463
|
+
name: e.field,
|
|
464
|
+
placeholder: e.placeholder,
|
|
465
|
+
disabled: q(e),
|
|
466
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
467
|
+
}), u({ _: 2 }, [e.prefix ? {
|
|
468
|
+
name: "prefix",
|
|
469
|
+
fn: P(() => [d(O(e.prefix), 1)]),
|
|
470
|
+
key: "0"
|
|
471
|
+
} : void 0, e.suffix ? {
|
|
472
|
+
name: "suffix",
|
|
473
|
+
fn: P(() => [d(O(e.suffix), 1)]),
|
|
474
|
+
key: "1"
|
|
475
|
+
} : void 0]), 1040, [
|
|
476
|
+
"id",
|
|
477
|
+
"model-value",
|
|
478
|
+
"name",
|
|
479
|
+
"placeholder",
|
|
480
|
+
"disabled",
|
|
481
|
+
"onUpdate:modelValue"
|
|
482
|
+
])) : e.component === "switch" ? (C(), o(k(Se), g({
|
|
483
|
+
key: 4,
|
|
484
|
+
ref_for: !0
|
|
485
|
+
}, Y(e), {
|
|
486
|
+
"model-value": _e(e.field),
|
|
487
|
+
name: e.field,
|
|
488
|
+
disabled: q(e),
|
|
489
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
490
|
+
}), null, 16, [
|
|
491
|
+
"model-value",
|
|
492
|
+
"name",
|
|
493
|
+
"disabled",
|
|
494
|
+
"onUpdate:modelValue"
|
|
495
|
+
])) : e.component === "date" || e.component === "datetime" || e.component === "daterange" ? (C(), o(k(se), g({
|
|
496
|
+
key: 5,
|
|
497
|
+
ref_for: !0
|
|
498
|
+
}, Y(e), {
|
|
499
|
+
id: H(e),
|
|
500
|
+
"model-value": we(e.field),
|
|
501
|
+
name: ke(e),
|
|
502
|
+
placeholder: e.placeholder,
|
|
503
|
+
disabled: q(e),
|
|
504
|
+
type: De(e),
|
|
505
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
506
|
+
}), null, 16, [
|
|
507
|
+
"id",
|
|
508
|
+
"model-value",
|
|
509
|
+
"name",
|
|
510
|
+
"placeholder",
|
|
511
|
+
"disabled",
|
|
512
|
+
"type",
|
|
513
|
+
"onUpdate:modelValue"
|
|
514
|
+
])) : e.component === "radio" ? (C(), o(k(ye), g({
|
|
515
|
+
key: 6,
|
|
516
|
+
ref_for: !0
|
|
517
|
+
}, Y(e), {
|
|
518
|
+
"model-value": me(e.field),
|
|
519
|
+
name: e.field,
|
|
520
|
+
disabled: q(e),
|
|
521
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
522
|
+
}), {
|
|
523
|
+
default: P(() => [(C(!0), c(i, null, T(J(e), (e) => (C(), o(k(ve), {
|
|
524
|
+
key: String(e.value),
|
|
525
|
+
value: e.value,
|
|
526
|
+
disabled: e.disabled
|
|
527
|
+
}, {
|
|
528
|
+
default: P(() => [d(O(e.label), 1)]),
|
|
529
|
+
_: 2
|
|
530
|
+
}, 1032, ["value", "disabled"]))), 128))]),
|
|
531
|
+
_: 2
|
|
532
|
+
}, 1040, [
|
|
533
|
+
"model-value",
|
|
534
|
+
"name",
|
|
535
|
+
"disabled",
|
|
536
|
+
"onUpdate:modelValue"
|
|
537
|
+
])) : e.component === "checkbox" ? (C(), o(k(oe), g({
|
|
538
|
+
key: 7,
|
|
539
|
+
ref_for: !0
|
|
540
|
+
}, Y(e), {
|
|
541
|
+
"model-value": Ce(e.field),
|
|
542
|
+
name: e.field,
|
|
543
|
+
disabled: q(e),
|
|
544
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
545
|
+
}), {
|
|
546
|
+
default: P(() => [(C(!0), c(i, null, T(J(e), (e) => (C(), o(k(ae), {
|
|
547
|
+
key: String(e.value),
|
|
548
|
+
value: e.value,
|
|
549
|
+
disabled: e.disabled
|
|
550
|
+
}, {
|
|
551
|
+
default: P(() => [d(O(e.label), 1)]),
|
|
552
|
+
_: 2
|
|
553
|
+
}, 1032, ["value", "disabled"]))), 128))]),
|
|
554
|
+
_: 2
|
|
555
|
+
}, 1040, [
|
|
556
|
+
"model-value",
|
|
557
|
+
"name",
|
|
558
|
+
"disabled",
|
|
559
|
+
"onUpdate:modelValue"
|
|
560
|
+
])) : e.component === "tree-select" ? (C(), o(k(Te), g({
|
|
561
|
+
key: 8,
|
|
562
|
+
ref_for: !0
|
|
563
|
+
}, Y(e), {
|
|
564
|
+
id: e.id,
|
|
565
|
+
"model-value": Oe(e.field),
|
|
566
|
+
name: e.field,
|
|
567
|
+
placeholder: e.placeholder,
|
|
568
|
+
disabled: q(e),
|
|
569
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
570
|
+
}), null, 16, [
|
|
571
|
+
"id",
|
|
572
|
+
"model-value",
|
|
573
|
+
"name",
|
|
574
|
+
"placeholder",
|
|
575
|
+
"disabled",
|
|
576
|
+
"onUpdate:modelValue"
|
|
577
|
+
])) : e.component === "upload" ? (C(), o(k(Ee), g({
|
|
578
|
+
key: 9,
|
|
579
|
+
ref_for: !0
|
|
580
|
+
}, Y(e), { disabled: q(e) }), {
|
|
581
|
+
default: P(() => [f(k(R), { type: "primary" }, {
|
|
582
|
+
default: P(() => [...n[0] ||= [d(" 上传 ", -1)]]),
|
|
583
|
+
_: 1
|
|
584
|
+
})]),
|
|
585
|
+
_: 1
|
|
586
|
+
}, 16, ["disabled"])) : (C(), o(k(de), g({
|
|
587
|
+
key: 10,
|
|
588
|
+
ref_for: !0
|
|
589
|
+
}, Y(e), {
|
|
590
|
+
id: e.id,
|
|
591
|
+
"model-value": B(e.field),
|
|
592
|
+
name: e.field,
|
|
593
|
+
type: V(e),
|
|
594
|
+
placeholder: e.placeholder,
|
|
595
|
+
disabled: q(e),
|
|
596
|
+
required: e.required,
|
|
597
|
+
"onUpdate:modelValue": (t) => $(e.field, t)
|
|
598
|
+
}), u({ _: 2 }, [
|
|
599
|
+
e.prepend ? {
|
|
600
|
+
name: "prepend",
|
|
601
|
+
fn: P(() => [d(O(e.prepend), 1)]),
|
|
602
|
+
key: "0"
|
|
603
|
+
} : void 0,
|
|
604
|
+
e.append ? {
|
|
605
|
+
name: "append",
|
|
606
|
+
fn: P(() => [d(O(e.append), 1)]),
|
|
607
|
+
key: "1"
|
|
608
|
+
} : void 0,
|
|
609
|
+
e.prefix ? {
|
|
610
|
+
name: "prefix",
|
|
611
|
+
fn: P(() => [d(O(e.prefix), 1)]),
|
|
612
|
+
key: "2"
|
|
613
|
+
} : void 0,
|
|
614
|
+
e.suffix ? {
|
|
615
|
+
name: "suffix",
|
|
616
|
+
fn: P(() => [d(O(e.suffix), 1)]),
|
|
617
|
+
key: "3"
|
|
618
|
+
} : void 0
|
|
619
|
+
]), 1040, [
|
|
620
|
+
"id",
|
|
621
|
+
"model-value",
|
|
622
|
+
"name",
|
|
623
|
+
"type",
|
|
624
|
+
"placeholder",
|
|
625
|
+
"disabled",
|
|
626
|
+
"required",
|
|
627
|
+
"onUpdate:modelValue"
|
|
628
|
+
]))], !0),
|
|
629
|
+
E(t.$slots, Le(e), {
|
|
630
|
+
model: S.value,
|
|
631
|
+
schema: e,
|
|
632
|
+
value: S.value[e.field]
|
|
633
|
+
}, void 0, !0),
|
|
634
|
+
e.description ? (C(), c("p", Ae, O(e.description), 1)) : s("", !0),
|
|
635
|
+
e.help ? (C(), c("p", K, O(e.help), 1)) : s("", !0)
|
|
636
|
+
]),
|
|
637
|
+
_: 2
|
|
638
|
+
}, 1032, [
|
|
639
|
+
"label",
|
|
640
|
+
"prop",
|
|
641
|
+
"required",
|
|
642
|
+
"rules",
|
|
643
|
+
"data-field"
|
|
644
|
+
])]),
|
|
645
|
+
_: 2
|
|
646
|
+
}, 1032, ["span", "class"]))), 128))]),
|
|
647
|
+
_: 3
|
|
648
|
+
}, 8, ["gutter", "data-columns"]), e.showActions && y.value !== "view" ? (C(), c("div", {
|
|
649
|
+
key: 0,
|
|
650
|
+
class: v(["lumal-schema-form__actions", [`is-${e.actionLayout}`, `is-${e.actionPosition}`]])
|
|
651
|
+
}, [e.showReset ? (C(), o(k(R), {
|
|
652
|
+
key: 0,
|
|
653
|
+
"native-type": "button",
|
|
654
|
+
disabled: e.submitLoading,
|
|
655
|
+
onClick: Pe
|
|
656
|
+
}, {
|
|
657
|
+
default: P(() => [d(O(e.resetText), 1)]),
|
|
658
|
+
_: 1
|
|
659
|
+
}, 8, ["disabled"])) : s("", !0), f(k(R), {
|
|
660
|
+
type: "primary",
|
|
661
|
+
"native-type": "submit",
|
|
662
|
+
loading: e.submitLoading,
|
|
663
|
+
disabled: e.submitLoading
|
|
664
|
+
}, {
|
|
665
|
+
default: P(() => [d(O(e.submitText), 1)]),
|
|
666
|
+
_: 1
|
|
667
|
+
}, 8, ["loading", "disabled"])], 2)) : s("", !0)]),
|
|
668
|
+
_: 3
|
|
669
|
+
}, 8, [
|
|
670
|
+
"class",
|
|
671
|
+
"disabled",
|
|
672
|
+
"label-position",
|
|
673
|
+
"label-width",
|
|
674
|
+
"model"
|
|
675
|
+
])), [[k(_), l.loading]]);
|
|
676
|
+
}
|
|
677
|
+
}), [["__scopeId", "data-v-a2c0ed84"]]);
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/components/schema-table/cell.ts
|
|
680
|
+
function je(e) {
|
|
681
|
+
return e == null || typeof e == "boolean" || typeof e == "number" || typeof e == "string" || Array.isArray(e) && e.every((e) => typeof e == "boolean" || typeof e == "number" || typeof e == "string");
|
|
682
|
+
}
|
|
683
|
+
function J(t, n, r = e(t)) {
|
|
684
|
+
let i = (Array.isArray(n) ? n : [n]).map((e, t) => {
|
|
685
|
+
let n = r.get(String(e));
|
|
686
|
+
return {
|
|
687
|
+
...n?.color ? { color: n.color } : {},
|
|
688
|
+
key: `${String(e)}-${t}`,
|
|
689
|
+
label: n?.label ?? String(e)
|
|
690
|
+
};
|
|
691
|
+
});
|
|
692
|
+
return i.some((e) => e.color) ? i : [];
|
|
693
|
+
}
|
|
694
|
+
function Y(e, t, r, i = [], a) {
|
|
695
|
+
let o = e[t.field], s = t.formatter?.(o, e, r) ?? o;
|
|
696
|
+
return s == null || s === "" || Array.isArray(s) && s.length === 0 ? {
|
|
697
|
+
tags: [],
|
|
698
|
+
text: t.emptyText
|
|
699
|
+
} : t.formatter ? {
|
|
700
|
+
tags: [],
|
|
701
|
+
text: String(s)
|
|
702
|
+
} : i.length > 0 && je(s) ? {
|
|
703
|
+
tags: J(i, s, a),
|
|
704
|
+
text: n(i, s, a)
|
|
705
|
+
} : {
|
|
706
|
+
tags: [],
|
|
707
|
+
text: Array.isArray(s) ? s.map((e) => String(e)).join(", ") : String(s)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/components/schema-table/LumalSchemaTableCell.vue?vue&type=script&setup=true&lang.ts
|
|
712
|
+
var X = {
|
|
713
|
+
key: 0,
|
|
714
|
+
class: "lumal-schema-table__dictionary-tags"
|
|
715
|
+
}, Z = {
|
|
716
|
+
key: 0,
|
|
717
|
+
class: "lumal-schema-table__dictionary-dot",
|
|
718
|
+
"aria-hidden": "true"
|
|
719
|
+
}, Q = { key: 1 }, $ = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
720
|
+
__name: "LumalSchemaTableCell",
|
|
721
|
+
props: { display: {} },
|
|
722
|
+
setup(e) {
|
|
723
|
+
function t(e) {
|
|
724
|
+
return e.color ? { "--lumal-dictionary-color": e.color } : void 0;
|
|
725
|
+
}
|
|
726
|
+
return (n, r) => e.display.tags.length ? (C(), c("div", X, [(C(!0), c(i, null, T(e.display.tags, (e) => (C(), c("span", {
|
|
727
|
+
key: e.key,
|
|
728
|
+
class: "lumal-schema-table__dictionary-tag",
|
|
729
|
+
style: b(t(e))
|
|
730
|
+
}, [e.color ? (C(), c("span", Z)) : s("", !0), l("span", null, O(e.label), 1)], 4))), 128))])) : (C(), c("span", Q, O(e.display.text), 1));
|
|
731
|
+
}
|
|
732
|
+
}), [["__scopeId", "data-v-ad0cf9f4"]]);
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region src/components/schema-table/normalize.ts
|
|
735
|
+
function Me(e, t) {
|
|
736
|
+
return typeof e == "function" ? !!e(t) : !!e;
|
|
737
|
+
}
|
|
738
|
+
function Ne(e, t) {
|
|
739
|
+
return !e.authority || t.canAccess?.(e.authority) !== !1;
|
|
740
|
+
}
|
|
741
|
+
function Pe(e = [], t = {}) {
|
|
742
|
+
let n = { rows: t.rows ?? [] };
|
|
743
|
+
return e.map((e) => ({
|
|
744
|
+
...e,
|
|
745
|
+
field: e.field.trim()
|
|
746
|
+
})).filter((e) => e.field).map((e) => ({
|
|
747
|
+
...e,
|
|
748
|
+
align: e.align ?? "left",
|
|
749
|
+
componentProps: e.componentProps ?? {},
|
|
750
|
+
emptyText: e.emptyText ?? "-",
|
|
751
|
+
renderable: (typeof e.hidden == "function" || !Me(e.hidden, n)) && Ne(e, t)
|
|
752
|
+
}));
|
|
753
|
+
}
|
|
754
|
+
//#endregion
|
|
755
|
+
//#region src/components/schema-table/LumalSchemaTable.vue?vue&type=script&setup=true&lang.ts
|
|
756
|
+
var Fe = {
|
|
757
|
+
key: 0,
|
|
758
|
+
class: "lumal-schema-table__toolbar"
|
|
759
|
+
}, Ie = {
|
|
760
|
+
key: 0,
|
|
761
|
+
class: "lumal-schema-table__toolbar-title"
|
|
762
|
+
}, Le = {
|
|
763
|
+
key: 1,
|
|
764
|
+
class: "lumal-schema-table__toolbar-content"
|
|
765
|
+
}, Re = {
|
|
766
|
+
key: 2,
|
|
767
|
+
class: "lumal-schema-table__toolbar-tools"
|
|
768
|
+
}, ze = {
|
|
769
|
+
key: 0,
|
|
770
|
+
class: "lumal-schema-table__column-settings"
|
|
771
|
+
}, Be = {
|
|
772
|
+
class: "lumal-schema-table__column-settings-trigger",
|
|
773
|
+
"aria-label": "列设置",
|
|
774
|
+
title: "列设置"
|
|
775
|
+
}, Ve = { class: "lumal-schema-table__column-options" }, He = [
|
|
776
|
+
"draggable",
|
|
777
|
+
"onDragstart",
|
|
778
|
+
"onDrop"
|
|
779
|
+
], Ue = {
|
|
780
|
+
key: 0,
|
|
781
|
+
class: "lumal-schema-table__column-order-actions"
|
|
782
|
+
}, We = [
|
|
783
|
+
"disabled",
|
|
784
|
+
"aria-label",
|
|
785
|
+
"onClick"
|
|
786
|
+
], Ge = [
|
|
787
|
+
"disabled",
|
|
788
|
+
"aria-label",
|
|
789
|
+
"onClick"
|
|
790
|
+
], Ke = {
|
|
791
|
+
key: 1,
|
|
792
|
+
class: "lumal-schema-table__error",
|
|
793
|
+
role: "alert"
|
|
794
|
+
}, qe = {
|
|
795
|
+
key: 2,
|
|
796
|
+
class: "lumal-schema-table__scroll"
|
|
797
|
+
}, Je = { class: "lumal-schema-table__actions lumal-schema-table__actions--desktop" }, Ye = [
|
|
798
|
+
"aria-expanded",
|
|
799
|
+
"onClick",
|
|
800
|
+
"onKeydown"
|
|
801
|
+
], Xe = {
|
|
802
|
+
key: 3,
|
|
803
|
+
class: "lumal-schema-table__pagination"
|
|
804
|
+
}, Ze = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
805
|
+
__name: "LumalSchemaTable",
|
|
806
|
+
props: /*@__PURE__*/ h({
|
|
807
|
+
actionLabel: { default: "操作" },
|
|
808
|
+
actionWidth: { default: 160 },
|
|
809
|
+
autoResize: {
|
|
810
|
+
type: Boolean,
|
|
811
|
+
default: !0
|
|
812
|
+
},
|
|
813
|
+
canAccess: {},
|
|
814
|
+
cellClassName: {},
|
|
815
|
+
columnResizable: {
|
|
816
|
+
type: Boolean,
|
|
817
|
+
default: !0
|
|
818
|
+
},
|
|
819
|
+
columnSettings: {},
|
|
820
|
+
columns: {},
|
|
821
|
+
defaultExpandAll: { type: Boolean },
|
|
822
|
+
emptyText: { default: "暂无数据" },
|
|
823
|
+
error: {
|
|
824
|
+
type: [
|
|
825
|
+
Error,
|
|
826
|
+
String,
|
|
827
|
+
Boolean
|
|
828
|
+
],
|
|
829
|
+
default: !1
|
|
830
|
+
},
|
|
831
|
+
errorText: { default: "数据加载失败" },
|
|
832
|
+
headerCellClassName: {},
|
|
833
|
+
indexLabel: { default: "#" },
|
|
834
|
+
indexWidth: { default: 64 },
|
|
835
|
+
loading: {
|
|
836
|
+
type: Boolean,
|
|
837
|
+
default: !1
|
|
838
|
+
},
|
|
839
|
+
mobileActionLabel: { default: "更多" },
|
|
840
|
+
mobileActionWidth: { default: 72 },
|
|
841
|
+
pageSizes: { default: () => [
|
|
842
|
+
10,
|
|
843
|
+
20,
|
|
844
|
+
50,
|
|
845
|
+
100
|
|
846
|
+
] },
|
|
847
|
+
pagination: {
|
|
848
|
+
type: Boolean,
|
|
849
|
+
default: !1
|
|
850
|
+
},
|
|
851
|
+
rowClassName: {},
|
|
852
|
+
rowKey: {
|
|
853
|
+
type: [String, Function],
|
|
854
|
+
default: "id"
|
|
855
|
+
},
|
|
856
|
+
rows: { default: () => [] },
|
|
857
|
+
retryText: { default: "重新加载" },
|
|
858
|
+
scaleColumnWidth: {
|
|
859
|
+
type: Boolean,
|
|
860
|
+
default: !0
|
|
861
|
+
},
|
|
862
|
+
selection: {
|
|
863
|
+
type: Boolean,
|
|
864
|
+
default: !1
|
|
865
|
+
},
|
|
866
|
+
showColumnSettings: {
|
|
867
|
+
type: Boolean,
|
|
868
|
+
default: !1
|
|
869
|
+
},
|
|
870
|
+
showIndex: {
|
|
871
|
+
type: Boolean,
|
|
872
|
+
default: !1
|
|
873
|
+
},
|
|
874
|
+
tableProps: { default: () => ({}) },
|
|
875
|
+
total: { default: 0 },
|
|
876
|
+
treeProps: {}
|
|
877
|
+
}, {
|
|
878
|
+
page: { default: 1 },
|
|
879
|
+
pageModifiers: {},
|
|
880
|
+
pageSize: { default: 10 },
|
|
881
|
+
pageSizeModifiers: {}
|
|
882
|
+
}),
|
|
883
|
+
emits: /*@__PURE__*/ h([
|
|
884
|
+
"currentChange",
|
|
885
|
+
"expandChange",
|
|
886
|
+
"filterChange",
|
|
887
|
+
"pageChange",
|
|
888
|
+
"retry",
|
|
889
|
+
"rowClick",
|
|
890
|
+
"selectionChange",
|
|
891
|
+
"sortChange"
|
|
892
|
+
], ["update:page", "update:pageSize"]),
|
|
893
|
+
setup(n, { expose: r, emit: u }) {
|
|
894
|
+
let p = n, m = u, h = ee(n, "page"), v = ee(n, "pageSize"), y = pe.directive, b = j("containerRef"), w = j("tableRef"), A = D(/* @__PURE__ */ new Set()), M = D([]), re = D([]), L = D([]), ie = D(typeof window < "u" && window.innerWidth <= 768), R = D(null), oe, z, se = "", B = a(() => Pe(p.columns, { canAccess: p.canAccess })), ce = a(() => {
|
|
895
|
+
let e = M.value;
|
|
896
|
+
if (e.length === 0) return B.value;
|
|
897
|
+
let t = new Map(e.map((e, t) => [e, t]));
|
|
898
|
+
return [...B.value].sort((e, n) => (t.get(String(e.field)) ?? 2 ** 53 - 1) - (t.get(String(n.field)) ?? 2 ** 53 - 1));
|
|
899
|
+
}), le = a(() => ce.value.filter((e) => e.renderable && !A.value.has(String(e.field)))), ue = a(() => ce.value.filter((e) => e.renderable && !e.fixed && e.configurable !== !1)), de = a(() => [...le.value].reverse().find((e) => !e.fixed)?.field), { dictionaryMap: fe } = t(() => B.value.map((e) => e.dictionary ?? e.dictType)), me = a(() => new Map(B.value.map((t) => {
|
|
900
|
+
let n = G(t);
|
|
901
|
+
return [String(t.field), e(n)];
|
|
902
|
+
}))), he = a(() => new Map(p.rows.map((e, t) => [e, t]))), ge = a(() => {
|
|
903
|
+
if (typeof p.rowKey != "function") return p.rowKey;
|
|
904
|
+
let e = p.rowKey, t = he.value;
|
|
905
|
+
return (n) => String(e(n, t.get(n) ?? -1));
|
|
906
|
+
}), ve = a(() => p.pagination && p.total > 0), ye = a(() => p.showColumnSettings || p.columnSettings?.enabled), be = a(() => ie.value ? p.mobileActionWidth : p.actionWidth), xe = a(() => p.error instanceof Error ? p.error.message || p.errorText : typeof p.error == "string" ? p.error : p.errorText), Se = a(() => p.defaultExpandAll ?? !!p.tableProps.defaultExpandAll), Te = a(() => p.treeProps ?? p.tableProps.treeProps ?? {
|
|
907
|
+
children: "children",
|
|
908
|
+
hasChildren: "hasChildren"
|
|
909
|
+
});
|
|
910
|
+
function Ee(e) {
|
|
911
|
+
let t = new Set(A.value);
|
|
912
|
+
if (t.has(e)) t.delete(e);
|
|
913
|
+
else {
|
|
914
|
+
if (ue.value.filter((e) => !t.has(String(e.field))).length <= 1) return;
|
|
915
|
+
t.add(e);
|
|
916
|
+
}
|
|
917
|
+
A.value = t, U(), _(() => w.value?.doLayout?.());
|
|
918
|
+
}
|
|
919
|
+
function Oe() {
|
|
920
|
+
A.value = /* @__PURE__ */ new Set(), M.value = B.value.map((e) => String(e.field)), U(), _(() => w.value?.doLayout?.());
|
|
921
|
+
}
|
|
922
|
+
function V(e, t) {
|
|
923
|
+
let n = ue.value.map((e) => String(e.field)), r = n.indexOf(e), i = r + t;
|
|
924
|
+
if (r < 0 || i < 0 || i >= n.length) return;
|
|
925
|
+
let a = n[i], o = ce.value.map((e) => String(e.field)), s = o.indexOf(e), c = o.indexOf(a);
|
|
926
|
+
o.splice(s, 1), o.splice(c, 0, e), M.value = o, U(), _(() => w.value?.doLayout?.());
|
|
927
|
+
}
|
|
928
|
+
function H(e) {
|
|
929
|
+
se = e;
|
|
930
|
+
}
|
|
931
|
+
function ke(e) {
|
|
932
|
+
if (!se || se === e) {
|
|
933
|
+
se = "";
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
let t = ce.value.map((e) => String(e.field)), n = t.indexOf(se), r = t.indexOf(e);
|
|
937
|
+
n >= 0 && r >= 0 && (t.splice(n, 1), t.splice(r, 0, se), M.value = t, U(), _(() => w.value?.doLayout?.())), se = "";
|
|
938
|
+
}
|
|
939
|
+
function U() {
|
|
940
|
+
let e = p.columnSettings?.storageKey;
|
|
941
|
+
if (!(!e || typeof localStorage > "u")) try {
|
|
942
|
+
localStorage.setItem(e, JSON.stringify({
|
|
943
|
+
hidden: [...A.value],
|
|
944
|
+
order: M.value
|
|
945
|
+
}));
|
|
946
|
+
} catch {}
|
|
947
|
+
}
|
|
948
|
+
function W() {
|
|
949
|
+
M.value = B.value.map((e) => String(e.field));
|
|
950
|
+
let e = p.columnSettings?.storageKey;
|
|
951
|
+
if (!(!e || typeof localStorage > "u")) try {
|
|
952
|
+
let t = JSON.parse(localStorage.getItem(e) ?? "{}"), n = new Set(B.value.map((e) => String(e.field)));
|
|
953
|
+
A.value = new Set((t.hidden ?? []).filter((e) => n.has(e))), M.value = [...(t.order ?? []).filter((e) => n.has(e)), ...[...n].filter((e) => !(t.order ?? []).includes(e))];
|
|
954
|
+
} catch {
|
|
955
|
+
Oe();
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
function G(e) {
|
|
959
|
+
let t = e.dictionary ?? e.dictType;
|
|
960
|
+
return t ? fe.value[t] ?? [] : k(e.options) ?? [];
|
|
961
|
+
}
|
|
962
|
+
function Ae(e, t, n) {
|
|
963
|
+
return typeof t.hidden == "function" && !!t.hidden({
|
|
964
|
+
rows: p.rows,
|
|
965
|
+
row: e,
|
|
966
|
+
index: n
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
function K(e, t, n) {
|
|
970
|
+
return Y(e, t, n, G(t), me.value.get(String(t.field)));
|
|
971
|
+
}
|
|
972
|
+
function q(e) {
|
|
973
|
+
return (t, n, r, i) => Ae(t, e, i) ? "" : K(t, e, i).text;
|
|
974
|
+
}
|
|
975
|
+
let je = a(() => new Map(B.value.map((e) => [String(e.field), q(e)])));
|
|
976
|
+
function J(e) {
|
|
977
|
+
return je.value.get(String(e.field));
|
|
978
|
+
}
|
|
979
|
+
function X(e) {
|
|
980
|
+
if (!p.scaleColumnWidth) return;
|
|
981
|
+
let t = e.minWidth ?? e.componentProps.minWidth;
|
|
982
|
+
return e.field === de.value ? t ?? e.width ?? e.componentProps.width : t;
|
|
983
|
+
}
|
|
984
|
+
function Z(e) {
|
|
985
|
+
if (!(!p.scaleColumnWidth || e.field === de.value)) return e.width;
|
|
986
|
+
}
|
|
987
|
+
function Q(e, t) {
|
|
988
|
+
if (typeof p.rowKey == "function") return p.rowKey(e, t);
|
|
989
|
+
let n = p.rowKey ? e[p.rowKey] : void 0;
|
|
990
|
+
return typeof n == "string" || typeof n == "number" ? n : void 0;
|
|
991
|
+
}
|
|
992
|
+
function Me(e, t) {
|
|
993
|
+
let n = Q(e, t);
|
|
994
|
+
return n === void 0 ? `index:${t}` : `row:${typeof n}:${n}`;
|
|
995
|
+
}
|
|
996
|
+
function Ne(e, t) {
|
|
997
|
+
return R.value === Me(e, t);
|
|
998
|
+
}
|
|
999
|
+
function Ze(e, t, n) {
|
|
1000
|
+
let r = Me(e, t);
|
|
1001
|
+
n ? R.value = r : R.value === r && (R.value = null);
|
|
1002
|
+
}
|
|
1003
|
+
function Qe(e, t) {
|
|
1004
|
+
let n = Me(e, t);
|
|
1005
|
+
R.value = R.value === n ? null : n;
|
|
1006
|
+
}
|
|
1007
|
+
function $e() {
|
|
1008
|
+
R.value = null;
|
|
1009
|
+
}
|
|
1010
|
+
function et(e) {
|
|
1011
|
+
re.value = e, L.value = e.map((e) => Q(e, he.value.get(e) ?? -1)).filter((e) => e !== void 0), m("selectionChange", e, L.value);
|
|
1012
|
+
}
|
|
1013
|
+
function tt(e) {
|
|
1014
|
+
m("pageChange", e);
|
|
1015
|
+
}
|
|
1016
|
+
function nt(e, t, n) {
|
|
1017
|
+
m("rowClick", e, t, n);
|
|
1018
|
+
}
|
|
1019
|
+
function rt(e, t) {
|
|
1020
|
+
m("currentChange", e, t);
|
|
1021
|
+
}
|
|
1022
|
+
function it(e, t) {
|
|
1023
|
+
m("expandChange", e, t);
|
|
1024
|
+
}
|
|
1025
|
+
function at() {
|
|
1026
|
+
if (typeof window > "u") return;
|
|
1027
|
+
let e = window.innerWidth <= 768;
|
|
1028
|
+
e !== ie.value && (ie.value = e, e || $e(), _(() => w.value?.doLayout?.()));
|
|
1029
|
+
}
|
|
1030
|
+
function ot(e) {
|
|
1031
|
+
e.key === "Escape" && $e();
|
|
1032
|
+
}
|
|
1033
|
+
function st() {
|
|
1034
|
+
!p.autoResize || typeof ResizeObserver > "u" || !b.value || (oe = new ResizeObserver(() => {
|
|
1035
|
+
z && clearTimeout(z), z = setTimeout(() => {
|
|
1036
|
+
z = void 0, w.value?.doLayout?.();
|
|
1037
|
+
});
|
|
1038
|
+
}), oe.observe(b.value));
|
|
1039
|
+
}
|
|
1040
|
+
function ct() {
|
|
1041
|
+
oe?.disconnect(), oe = void 0, z &&= (clearTimeout(z), void 0);
|
|
1042
|
+
}
|
|
1043
|
+
return N(() => p.autoResize, () => {
|
|
1044
|
+
ct(), st();
|
|
1045
|
+
}), N(() => [p.columns.map((e) => String(e.field)).join("\0"), p.columnSettings?.storageKey], W), N(R, (e) => {
|
|
1046
|
+
typeof document > "u" || (document.removeEventListener("keydown", ot), e !== null && document.addEventListener("keydown", ot));
|
|
1047
|
+
}), S(() => {
|
|
1048
|
+
W(), at(), st(), window.addEventListener("resize", at);
|
|
1049
|
+
}), x(() => {
|
|
1050
|
+
ct(), window.removeEventListener("resize", at), document.removeEventListener("keydown", ot);
|
|
1051
|
+
}), r({
|
|
1052
|
+
clearSelection: () => w.value?.clearSelection?.(),
|
|
1053
|
+
doLayout: () => w.value?.doLayout?.(),
|
|
1054
|
+
getSelectedRowKeys: () => [...L.value],
|
|
1055
|
+
getSelectedRows: () => [...re.value],
|
|
1056
|
+
getColumnOrder: () => [...M.value],
|
|
1057
|
+
getExportData: (e = p.rows) => {
|
|
1058
|
+
let t = new Map(e.map((e, t) => [e, t]));
|
|
1059
|
+
return {
|
|
1060
|
+
columns: le.value.map((e) => ({
|
|
1061
|
+
field: String(e.field),
|
|
1062
|
+
label: e.label
|
|
1063
|
+
})),
|
|
1064
|
+
rows: e.map((e) => le.value.map((n) => K(e, n, t.get(e) ?? -1).text))
|
|
1065
|
+
};
|
|
1066
|
+
},
|
|
1067
|
+
getVisibleColumns: () => [...le.value],
|
|
1068
|
+
resetColumnSettings: Oe,
|
|
1069
|
+
getTableElement: () => w.value?.$el,
|
|
1070
|
+
getTableInstance: () => w.value,
|
|
1071
|
+
toggleRowSelection: (e, t) => w.value?.toggleRowSelection?.(e, t)
|
|
1072
|
+
}), (e, t) => (C(), c("div", {
|
|
1073
|
+
ref_key: "containerRef",
|
|
1074
|
+
ref: b,
|
|
1075
|
+
class: "lumal-schema-table"
|
|
1076
|
+
}, [
|
|
1077
|
+
e.$slots["toolbar-title"] || e.$slots.toolbar || e.$slots["toolbar-tools"] || ye.value ? (C(), c("div", Fe, [
|
|
1078
|
+
e.$slots["toolbar-title"] ? (C(), c("div", Ie, [E(e.$slots, "toolbar-title", {}, void 0, !0)])) : s("", !0),
|
|
1079
|
+
e.$slots.toolbar ? (C(), c("div", Le, [E(e.$slots, "toolbar", {}, void 0, !0)])) : s("", !0),
|
|
1080
|
+
e.$slots["toolbar-tools"] || ye.value ? (C(), c("div", Re, [E(e.$slots, "toolbar-tools", {}, void 0, !0), ye.value ? (C(), c("div", ze, [l("details", null, [l("summary", Be, [f(k(I), { name: "lumal:grid" })]), l("div", Ve, [l("div", { class: "lumal-schema-table__column-options-header" }, [t[6] ||= l("strong", null, "列设置", -1), l("button", {
|
|
1081
|
+
type: "button",
|
|
1082
|
+
onClick: Oe
|
|
1083
|
+
}, " 恢复默认 ")]), (C(!0), c(i, null, T(ue.value, (e, r) => (C(), c("div", {
|
|
1084
|
+
key: String(e.field),
|
|
1085
|
+
class: "lumal-schema-table__column-option",
|
|
1086
|
+
draggable: n.columnSettings?.reorderable !== !1,
|
|
1087
|
+
onDragstart: (t) => H(String(e.field)),
|
|
1088
|
+
onDragover: t[0] ||= F(() => {}, ["prevent"]),
|
|
1089
|
+
onDrop: (t) => ke(String(e.field))
|
|
1090
|
+
}, [f(k(ae), {
|
|
1091
|
+
"model-value": !A.value.has(String(e.field)),
|
|
1092
|
+
"onUpdate:modelValue": (t) => Ee(String(e.field))
|
|
1093
|
+
}, {
|
|
1094
|
+
default: P(() => [d(O(e.label), 1)]),
|
|
1095
|
+
_: 2
|
|
1096
|
+
}, 1032, ["model-value", "onUpdate:modelValue"]), n.columnSettings?.reorderable === !1 ? s("", !0) : (C(), c("span", Ue, [l("button", {
|
|
1097
|
+
type: "button",
|
|
1098
|
+
disabled: r === 0,
|
|
1099
|
+
"aria-label": `上移${e.label}`,
|
|
1100
|
+
onClick: (t) => V(String(e.field), -1)
|
|
1101
|
+
}, " ↑ ", 8, We), l("button", {
|
|
1102
|
+
type: "button",
|
|
1103
|
+
disabled: r === ue.value.length - 1,
|
|
1104
|
+
"aria-label": `下移${e.label}`,
|
|
1105
|
+
onClick: (t) => V(String(e.field), 1)
|
|
1106
|
+
}, " ↓ ", 8, Ge)]))], 40, He))), 128))])])])) : s("", !0)])) : s("", !0)
|
|
1107
|
+
])) : s("", !0),
|
|
1108
|
+
n.error ? (C(), c("div", Ke, [l("span", null, O(xe.value), 1), l("button", {
|
|
1109
|
+
type: "button",
|
|
1110
|
+
onClick: t[1] ||= (e) => m("retry")
|
|
1111
|
+
}, O(n.retryText), 1)])) : (C(), c("div", qe, [te((C(), o(k(Ce), g({
|
|
1112
|
+
ref_key: "tableRef",
|
|
1113
|
+
ref: w
|
|
1114
|
+
}, n.tableProps, {
|
|
1115
|
+
class: "lumal-schema-table__body",
|
|
1116
|
+
data: n.rows,
|
|
1117
|
+
"row-key": ge.value,
|
|
1118
|
+
"empty-text": n.emptyText,
|
|
1119
|
+
"row-class-name": n.rowClassName,
|
|
1120
|
+
"cell-class-name": n.cellClassName,
|
|
1121
|
+
"header-cell-class-name": n.headerCellClassName,
|
|
1122
|
+
"default-expand-all": Se.value,
|
|
1123
|
+
"tree-props": Te.value,
|
|
1124
|
+
"data-loading": n.loading,
|
|
1125
|
+
onSelectionChange: et,
|
|
1126
|
+
onSortChange: t[2] ||= (e) => m("sortChange", e),
|
|
1127
|
+
onFilterChange: t[3] ||= (e) => m("filterChange", e),
|
|
1128
|
+
onRowClick: nt,
|
|
1129
|
+
onCurrentChange: rt,
|
|
1130
|
+
onExpandChange: it
|
|
1131
|
+
}), {
|
|
1132
|
+
default: P(() => [
|
|
1133
|
+
n.selection ? (C(), o(k(we), {
|
|
1134
|
+
key: 0,
|
|
1135
|
+
type: "selection",
|
|
1136
|
+
width: "48"
|
|
1137
|
+
})) : s("", !0),
|
|
1138
|
+
n.showIndex ? (C(), o(k(we), {
|
|
1139
|
+
key: 1,
|
|
1140
|
+
type: "index",
|
|
1141
|
+
label: n.indexLabel,
|
|
1142
|
+
width: n.indexWidth
|
|
1143
|
+
}, null, 8, ["label", "width"])) : s("", !0),
|
|
1144
|
+
(C(!0), c(i, null, T(le.value, (t) => (C(), o(k(we), g({ key: String(t.field) }, { ref_for: !0 }, t.componentProps, {
|
|
1145
|
+
prop: String(t.field),
|
|
1146
|
+
label: t.label,
|
|
1147
|
+
align: t.align,
|
|
1148
|
+
width: Z(t),
|
|
1149
|
+
"min-width": X(t),
|
|
1150
|
+
fixed: t.fixed,
|
|
1151
|
+
resizable: n.columnResizable,
|
|
1152
|
+
"show-overflow-tooltip": t.showOverflowTooltip ?? !0,
|
|
1153
|
+
formatter: J(t),
|
|
1154
|
+
"data-field": String(t.field)
|
|
1155
|
+
}), {
|
|
1156
|
+
default: P(({ row: n, $index: r }) => [Ae(n, t, r) ? s("", !0) : E(e.$slots, `table-${String(t.field)}`, {
|
|
1157
|
+
key: 0,
|
|
1158
|
+
row: n,
|
|
1159
|
+
index: r,
|
|
1160
|
+
column: t,
|
|
1161
|
+
value: n[t.field]
|
|
1162
|
+
}, () => [f($, { display: K(n, t, r) }, null, 8, ["display"])], !0)]),
|
|
1163
|
+
_: 2
|
|
1164
|
+
}, 1040, [
|
|
1165
|
+
"prop",
|
|
1166
|
+
"label",
|
|
1167
|
+
"align",
|
|
1168
|
+
"width",
|
|
1169
|
+
"min-width",
|
|
1170
|
+
"fixed",
|
|
1171
|
+
"resizable",
|
|
1172
|
+
"show-overflow-tooltip",
|
|
1173
|
+
"formatter",
|
|
1174
|
+
"data-field"
|
|
1175
|
+
]))), 128)),
|
|
1176
|
+
e.$slots.actions ? (C(), o(k(we), {
|
|
1177
|
+
key: 2,
|
|
1178
|
+
fixed: "right",
|
|
1179
|
+
label: n.actionLabel,
|
|
1180
|
+
width: be.value,
|
|
1181
|
+
"data-field": "actions"
|
|
1182
|
+
}, {
|
|
1183
|
+
default: P(({ row: t, $index: r }) => [l("div", Je, [E(e.$slots, "actions", {
|
|
1184
|
+
row: t,
|
|
1185
|
+
index: r
|
|
1186
|
+
}, void 0, !0)]), f(k(_e), {
|
|
1187
|
+
visible: Ne(t, r),
|
|
1188
|
+
teleported: !0,
|
|
1189
|
+
trigger: "click",
|
|
1190
|
+
placement: "bottom-end",
|
|
1191
|
+
"popper-class": "lumal-schema-table__mobile-actions-popper",
|
|
1192
|
+
"onUpdate:visible": (e) => Ze(t, r, e)
|
|
1193
|
+
}, {
|
|
1194
|
+
reference: P(() => [l("button", {
|
|
1195
|
+
type: "button",
|
|
1196
|
+
class: "lumal-schema-table__mobile-actions",
|
|
1197
|
+
"aria-haspopup": "menu",
|
|
1198
|
+
"aria-expanded": Ne(t, r),
|
|
1199
|
+
onClick: F((e) => Qe(t, r), ["stop"]),
|
|
1200
|
+
onKeydown: ne(F($e, ["stop", "prevent"]), ["esc"])
|
|
1201
|
+
}, O(n.mobileActionLabel), 41, Ye)]),
|
|
1202
|
+
default: P(() => [l("div", {
|
|
1203
|
+
class: "lumal-schema-table__mobile-actions-menu",
|
|
1204
|
+
role: "menu",
|
|
1205
|
+
onClickCapture: $e
|
|
1206
|
+
}, [E(e.$slots, "actions", {
|
|
1207
|
+
row: t,
|
|
1208
|
+
index: r
|
|
1209
|
+
}, void 0, !0)], 32)]),
|
|
1210
|
+
_: 2
|
|
1211
|
+
}, 1032, ["visible", "onUpdate:visible"])]),
|
|
1212
|
+
_: 3
|
|
1213
|
+
}, 8, ["label", "width"])) : s("", !0)
|
|
1214
|
+
]),
|
|
1215
|
+
_: 3
|
|
1216
|
+
}, 16, [
|
|
1217
|
+
"data",
|
|
1218
|
+
"row-key",
|
|
1219
|
+
"empty-text",
|
|
1220
|
+
"row-class-name",
|
|
1221
|
+
"cell-class-name",
|
|
1222
|
+
"header-cell-class-name",
|
|
1223
|
+
"default-expand-all",
|
|
1224
|
+
"tree-props",
|
|
1225
|
+
"data-loading"
|
|
1226
|
+
])), [[k(y), n.loading]])])),
|
|
1227
|
+
ve.value ? (C(), c("div", Xe, [f(k(De), {
|
|
1228
|
+
page: h.value,
|
|
1229
|
+
"onUpdate:page": t[4] ||= (e) => h.value = e,
|
|
1230
|
+
"page-size": v.value,
|
|
1231
|
+
"onUpdate:pageSize": t[5] ||= (e) => v.value = e,
|
|
1232
|
+
total: n.total,
|
|
1233
|
+
"page-sizes": n.pageSizes,
|
|
1234
|
+
onChange: tt
|
|
1235
|
+
}, null, 8, [
|
|
1236
|
+
"page",
|
|
1237
|
+
"page-size",
|
|
1238
|
+
"total",
|
|
1239
|
+
"page-sizes"
|
|
1240
|
+
])])) : s("", !0)
|
|
1241
|
+
], 512));
|
|
1242
|
+
}
|
|
1243
|
+
}), [["__scopeId", "data-v-e0b97914"]]), Qe = /* @__PURE__ */ p({
|
|
1244
|
+
__name: "LumalCrudEditor",
|
|
1245
|
+
props: /*@__PURE__*/ h({
|
|
1246
|
+
beforeClose: {},
|
|
1247
|
+
closeOnClickModal: {
|
|
1248
|
+
type: Boolean,
|
|
1249
|
+
default: !1
|
|
1250
|
+
},
|
|
1251
|
+
destroyOnClose: {
|
|
1252
|
+
type: Boolean,
|
|
1253
|
+
default: !0
|
|
1254
|
+
},
|
|
1255
|
+
title: {},
|
|
1256
|
+
type: { default: "dialog" },
|
|
1257
|
+
width: { default: "min(920px, calc(100vw - 32px))" }
|
|
1258
|
+
}, {
|
|
1259
|
+
modelValue: {
|
|
1260
|
+
type: Boolean,
|
|
1261
|
+
default: !1
|
|
1262
|
+
},
|
|
1263
|
+
modelModifiers: {}
|
|
1264
|
+
}),
|
|
1265
|
+
emits: ["update:modelValue"],
|
|
1266
|
+
setup(e) {
|
|
1267
|
+
let t = ee(e, "modelValue");
|
|
1268
|
+
return (n, r) => e.type === "drawer" ? (C(), o(k(ce), {
|
|
1269
|
+
key: 0,
|
|
1270
|
+
modelValue: t.value,
|
|
1271
|
+
"onUpdate:modelValue": r[0] ||= (e) => t.value = e,
|
|
1272
|
+
title: e.title,
|
|
1273
|
+
size: e.width,
|
|
1274
|
+
"close-on-click-modal": e.closeOnClickModal,
|
|
1275
|
+
"destroy-on-close": e.destroyOnClose,
|
|
1276
|
+
"before-close": e.beforeClose,
|
|
1277
|
+
class: "lumal-crud-table__drawer"
|
|
1278
|
+
}, {
|
|
1279
|
+
footer: P(() => [E(n.$slots, "footer")]),
|
|
1280
|
+
default: P(() => [E(n.$slots, "default")]),
|
|
1281
|
+
_: 3
|
|
1282
|
+
}, 8, [
|
|
1283
|
+
"modelValue",
|
|
1284
|
+
"title",
|
|
1285
|
+
"size",
|
|
1286
|
+
"close-on-click-modal",
|
|
1287
|
+
"destroy-on-close",
|
|
1288
|
+
"before-close"
|
|
1289
|
+
])) : (C(), o(k(B), {
|
|
1290
|
+
key: 1,
|
|
1291
|
+
modelValue: t.value,
|
|
1292
|
+
"onUpdate:modelValue": r[1] ||= (e) => t.value = e,
|
|
1293
|
+
title: e.title,
|
|
1294
|
+
width: e.width,
|
|
1295
|
+
"close-on-click-modal": e.closeOnClickModal,
|
|
1296
|
+
"destroy-on-close": e.destroyOnClose,
|
|
1297
|
+
"before-close": e.beforeClose,
|
|
1298
|
+
class: "lumal-crud-table__dialog"
|
|
1299
|
+
}, {
|
|
1300
|
+
footer: P(() => [E(n.$slots, "footer")]),
|
|
1301
|
+
default: P(() => [E(n.$slots, "default")]),
|
|
1302
|
+
_: 3
|
|
1303
|
+
}, 8, [
|
|
1304
|
+
"modelValue",
|
|
1305
|
+
"title",
|
|
1306
|
+
"width",
|
|
1307
|
+
"close-on-click-modal",
|
|
1308
|
+
"destroy-on-close",
|
|
1309
|
+
"before-close"
|
|
1310
|
+
]));
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
//#endregion
|
|
1314
|
+
//#region src/components/crud-table/schema.ts
|
|
1315
|
+
function $e(e = [], t = []) {
|
|
1316
|
+
return t.length > 0 ? [...t] : e.filter((e) => e.showInForm !== !1 && e.field !== "action").map((e) => ({
|
|
1317
|
+
append: e.append,
|
|
1318
|
+
component: e.component ?? (e.dictionary || e.dictType ? "select" : "input"),
|
|
1319
|
+
componentProps: e.formComponentProps,
|
|
1320
|
+
defaultValue: e.defaultValue,
|
|
1321
|
+
dictionary: e.dictionary,
|
|
1322
|
+
dictType: e.dictType,
|
|
1323
|
+
editDisabled: e.editDisabled,
|
|
1324
|
+
field: e.field,
|
|
1325
|
+
label: e.label,
|
|
1326
|
+
options: e.options,
|
|
1327
|
+
placeholder: e.placeholder,
|
|
1328
|
+
prefix: e.prefix,
|
|
1329
|
+
prepend: e.prepend,
|
|
1330
|
+
required: e.required,
|
|
1331
|
+
rules: e.rules,
|
|
1332
|
+
span: e.span,
|
|
1333
|
+
suffix: e.suffix
|
|
1334
|
+
}));
|
|
1335
|
+
}
|
|
1336
|
+
//#endregion
|
|
1337
|
+
//#region src/components/crud-table/useCrudData.ts
|
|
1338
|
+
function et(e) {
|
|
1339
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1340
|
+
}
|
|
1341
|
+
function tt(e) {
|
|
1342
|
+
let t = D([]), n = D(0), r = D(!1), i = D(""), o = 0, s = a(() => e.dataSource.value ? t.value : e.rows.value), c = a(() => e.dataSource.value ? n.value : e.total.value), l = a(() => e.loading.value || r.value);
|
|
1343
|
+
function u(t) {
|
|
1344
|
+
let n = e.dataSource.value;
|
|
1345
|
+
return n?.parseResponse ? n.parseResponse(t) : !et(t) || !Array.isArray(t.items) || typeof t.total != "number" ? {
|
|
1346
|
+
items: [],
|
|
1347
|
+
total: 0
|
|
1348
|
+
} : {
|
|
1349
|
+
items: t.items,
|
|
1350
|
+
total: t.total
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
async function d() {
|
|
1354
|
+
let a = ++o, s = e.dataSource.value;
|
|
1355
|
+
if (!s) {
|
|
1356
|
+
r.value = !1, i.value = "";
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
r.value = !0, i.value = "";
|
|
1360
|
+
try {
|
|
1361
|
+
let r = u(await s.fetch({
|
|
1362
|
+
page: e.page.value,
|
|
1363
|
+
pageSize: e.pageSize.value,
|
|
1364
|
+
query: { ...e.queryModel.value }
|
|
1365
|
+
}));
|
|
1366
|
+
a === o && (t.value = r.items, n.value = r.total);
|
|
1367
|
+
} catch (e) {
|
|
1368
|
+
a === o && (i.value = e instanceof Error ? e.message : String(e), t.value = [], n.value = 0);
|
|
1369
|
+
} finally {
|
|
1370
|
+
a === o && (r.value = !1);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return {
|
|
1374
|
+
currentLoading: l,
|
|
1375
|
+
currentRows: s,
|
|
1376
|
+
currentTotal: c,
|
|
1377
|
+
error: i,
|
|
1378
|
+
load: d
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
//#endregion
|
|
1382
|
+
//#region src/components/crud-table/useCrudDialog.ts
|
|
1383
|
+
function nt(e) {
|
|
1384
|
+
try {
|
|
1385
|
+
return JSON.stringify(e);
|
|
1386
|
+
} catch {
|
|
1387
|
+
return String(e);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
function rt(e) {
|
|
1391
|
+
try {
|
|
1392
|
+
return structuredClone(e);
|
|
1393
|
+
} catch {
|
|
1394
|
+
return JSON.parse(JSON.stringify(e));
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
function it(e) {
|
|
1398
|
+
let t = D(!1), n = D("create"), r = D({}), i = D("{}"), o = D(), s = D(!1), c = D(""), l = a(() => n.value !== "view" && nt(r.value) !== i.value);
|
|
1399
|
+
function u(e, a) {
|
|
1400
|
+
let s = a ? rt(a) : {};
|
|
1401
|
+
n.value = e, o.value = a, r.value = s, i.value = nt(s), c.value = "", t.value = !0;
|
|
1402
|
+
}
|
|
1403
|
+
async function d(r, a) {
|
|
1404
|
+
if (s.value) return !1;
|
|
1405
|
+
let l = e.dataSource.value;
|
|
1406
|
+
if (!l) return t.value = !1, !0;
|
|
1407
|
+
s.value = !0, c.value = "";
|
|
1408
|
+
try {
|
|
1409
|
+
return a && !await a() ? !1 : (n.value === "edit" && o.value ? await l.update?.(o.value, r) : await l.create?.(r), i.value = nt(r), t.value = !1, s.value = !1, await e.afterSave(), !0);
|
|
1410
|
+
} catch (e) {
|
|
1411
|
+
return c.value = e instanceof Error ? e.message : String(e), !1;
|
|
1412
|
+
} finally {
|
|
1413
|
+
s.value = !1;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return {
|
|
1417
|
+
dirty: l,
|
|
1418
|
+
editingRow: o,
|
|
1419
|
+
error: c,
|
|
1420
|
+
mode: n,
|
|
1421
|
+
model: r,
|
|
1422
|
+
open: u,
|
|
1423
|
+
saving: s,
|
|
1424
|
+
submit: d,
|
|
1425
|
+
visible: t
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
//#endregion
|
|
1429
|
+
//#region src/components/crud-table/useCrudQuery.ts
|
|
1430
|
+
function at(e) {
|
|
1431
|
+
let t = D(e.defaultCollapsed.value), n = a(() => W(U(e.schemas.value))), r = a(() => {
|
|
1432
|
+
if (!e.collapsible.value || !t.value) return e.schemas.value;
|
|
1433
|
+
let n = 24 / e.columns.value, r = e.columns.value * e.collapsedRows.value, i = 0;
|
|
1434
|
+
return e.schemas.value.filter((e) => {
|
|
1435
|
+
let t = Math.max(1, Math.ceil((e.span ?? n) / n));
|
|
1436
|
+
return i + t > r ? !1 : (i += t, !0);
|
|
1437
|
+
});
|
|
1438
|
+
}), i = a(() => e.collapsible.value && r.value.length < e.schemas.value.length);
|
|
1439
|
+
function o() {
|
|
1440
|
+
let t = { ...n.value };
|
|
1441
|
+
return e.model.value = t, t;
|
|
1442
|
+
}
|
|
1443
|
+
function s() {
|
|
1444
|
+
t.value = !t.value;
|
|
1445
|
+
}
|
|
1446
|
+
return {
|
|
1447
|
+
canCollapse: i,
|
|
1448
|
+
collapsed: t,
|
|
1449
|
+
defaultModel: n,
|
|
1450
|
+
reset: o,
|
|
1451
|
+
toggle: s,
|
|
1452
|
+
visibleSchemas: r
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
//#endregion
|
|
1456
|
+
//#region src/components/crud-table/useCrudSelection.ts
|
|
1457
|
+
function ot() {
|
|
1458
|
+
let e = D([]), t = D([]);
|
|
1459
|
+
function n() {
|
|
1460
|
+
e.value = [], t.value = [];
|
|
1461
|
+
}
|
|
1462
|
+
function r(n, r = []) {
|
|
1463
|
+
e.value = n, t.value = r;
|
|
1464
|
+
}
|
|
1465
|
+
return {
|
|
1466
|
+
clear: n,
|
|
1467
|
+
selectedRowKeys: t,
|
|
1468
|
+
selectedRows: e,
|
|
1469
|
+
update: r
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
//#endregion
|
|
1473
|
+
//#region src/components/crud-table/LumalCrudTable.vue?vue&type=script&setup=true&lang.ts
|
|
1474
|
+
var st = { class: "lumal-crud-table__query-actions" }, ct = {
|
|
1475
|
+
key: 1,
|
|
1476
|
+
class: "lumal-crud-table__error",
|
|
1477
|
+
role: "alert"
|
|
1478
|
+
}, lt = { class: "lumal-crud-table__table-panel" }, ut = { class: "lumal-crud-table__body" }, dt = { class: "lumal-crud-table__toolbar-tools" }, ft = {
|
|
1479
|
+
key: 0,
|
|
1480
|
+
class: "lumal-crud-table__extra"
|
|
1481
|
+
}, pt = {
|
|
1482
|
+
key: 1,
|
|
1483
|
+
class: "lumal-crud-table__pagination"
|
|
1484
|
+
}, mt = {
|
|
1485
|
+
key: 0,
|
|
1486
|
+
class: "lumal-crud-table__dialog-error",
|
|
1487
|
+
role: "alert"
|
|
1488
|
+
}, ht = { class: "lumal-crud-table__dialog-footer" }, gt = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
1489
|
+
__name: "LumalCrudTable",
|
|
1490
|
+
props: /*@__PURE__*/ h({
|
|
1491
|
+
title: {},
|
|
1492
|
+
querySchemas: { default: () => [] },
|
|
1493
|
+
formSchemas: { default: () => [] },
|
|
1494
|
+
columns: { default: () => [] },
|
|
1495
|
+
dataSource: {},
|
|
1496
|
+
rows: { default: () => [] },
|
|
1497
|
+
rowKey: {},
|
|
1498
|
+
total: { default: 0 },
|
|
1499
|
+
pageSizes: { default: () => [
|
|
1500
|
+
10,
|
|
1501
|
+
20,
|
|
1502
|
+
50,
|
|
1503
|
+
100
|
|
1504
|
+
] },
|
|
1505
|
+
pagination: {
|
|
1506
|
+
type: [Boolean, Object],
|
|
1507
|
+
default: !0
|
|
1508
|
+
},
|
|
1509
|
+
loading: {
|
|
1510
|
+
type: Boolean,
|
|
1511
|
+
default: !1
|
|
1512
|
+
},
|
|
1513
|
+
emptyText: { default: "暂无数据" },
|
|
1514
|
+
searchText: { default: "查询" },
|
|
1515
|
+
resetText: { default: "重置" },
|
|
1516
|
+
createText: { default: "新增" },
|
|
1517
|
+
batchDeleteText: { default: "批量删除" },
|
|
1518
|
+
selection: {
|
|
1519
|
+
type: Boolean,
|
|
1520
|
+
default: !1
|
|
1521
|
+
},
|
|
1522
|
+
query: {},
|
|
1523
|
+
table: {},
|
|
1524
|
+
toolbar: {},
|
|
1525
|
+
actions: {},
|
|
1526
|
+
editor: {}
|
|
1527
|
+
}, {
|
|
1528
|
+
queryModel: { default: () => ({}) },
|
|
1529
|
+
queryModelModifiers: {},
|
|
1530
|
+
page: { default: 1 },
|
|
1531
|
+
pageModifiers: {},
|
|
1532
|
+
pageSize: { default: 10 },
|
|
1533
|
+
pageSizeModifiers: {}
|
|
1534
|
+
}),
|
|
1535
|
+
emits: /*@__PURE__*/ h([
|
|
1536
|
+
"search",
|
|
1537
|
+
"reset",
|
|
1538
|
+
"pageChange",
|
|
1539
|
+
"export",
|
|
1540
|
+
"operationError"
|
|
1541
|
+
], [
|
|
1542
|
+
"update:queryModel",
|
|
1543
|
+
"update:page",
|
|
1544
|
+
"update:pageSize"
|
|
1545
|
+
]),
|
|
1546
|
+
setup(e, { expose: t, emit: n }) {
|
|
1547
|
+
let r = e, i = n, p = ee(e, "queryModel"), h = ee(e, "page"), g = ee(e, "pageSize"), b = j("crudRef"), w = j("queryRef"), A = j("queryFormRef"), ne = j("dialogFormRef"), F = j("tableRef"), re = a(() => r.query?.schemas ?? r.querySchemas), L = a(() => r.table?.columns ?? r.columns), ie = a(() => L.value.filter((e) => e.showInTable !== !1)), ae = a(() => $e(L.value, r.formSchemas)), oe = a(() => r.table?.rowKey ?? r.rowKey), z = a(() => r.table?.selection ?? r.selection), se = a(() => r.table?.emptyText ?? r.emptyText), B = D(3), ce = a(() => Math.max(1, r.query?.columns ?? B.value)), le = a(() => r.query?.collapsible ?? !1), ue = a(() => r.query?.defaultCollapsed ?? !0), de = a(() => Math.max(1, r.query?.collapsedRows ?? 1)), fe = a(() => typeof r.pagination == "object" ? r.pagination.enabled !== !1 : r.pagination), pe = a(() => typeof r.pagination == "object" ? r.pagination.pageSizes ?? r.pageSizes : r.pageSizes), he = a(() => re.value.length > 0), ge = a(() => ae.value.length > 0), _e = a(() => ge.value && r.toolbar?.create !== !1), ve = a(() => z.value && r.toolbar?.batchDelete !== !1), ye = a(() => !!r.dataSource && r.toolbar?.refresh !== !1), be = a(() => !!r.toolbar?.export), xe = a(() => r.toolbar?.fullscreen !== !1), Se = a(() => he.value && r.toolbar?.queryToggle !== !1), Ce = a(() => _e.value || ve.value || be.value), we = a(() => Se.value || ye.value || xe.value), Te = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(max-width: 768px)").matches, Ee = {
|
|
1548
|
+
desktop: r.query?.defaultVisible ?? !0,
|
|
1549
|
+
mobile: r.query?.mobileDefaultVisible ?? r.query?.defaultVisible ?? !0
|
|
1550
|
+
}, Oe = a(() => r.dataSource), V = D(!1), H = D(!1), ke = D(Te), U = a(() => ke.value ? "mobile" : "desktop"), W = D(Ee), G = D(Ee[Te ? "mobile" : "desktop"]), Ae, K, je, J = tt({
|
|
1551
|
+
dataSource: Oe,
|
|
1552
|
+
loading: a(() => r.loading),
|
|
1553
|
+
page: h,
|
|
1554
|
+
pageSize: g,
|
|
1555
|
+
queryModel: p,
|
|
1556
|
+
rows: a(() => r.rows),
|
|
1557
|
+
total: a(() => r.total)
|
|
1558
|
+
}), Y = at({
|
|
1559
|
+
collapsedRows: de,
|
|
1560
|
+
collapsible: le,
|
|
1561
|
+
columns: ce,
|
|
1562
|
+
defaultCollapsed: ue,
|
|
1563
|
+
model: p,
|
|
1564
|
+
schemas: re
|
|
1565
|
+
}), X = ot(), Z = it({
|
|
1566
|
+
dataSource: Oe,
|
|
1567
|
+
afterSave: J.load
|
|
1568
|
+
}), Q = a(() => J.currentLoading.value || V.value), $ = a(() => fe.value && J.currentTotal.value > 0), Me = a(() => ({
|
|
1569
|
+
create: r.editor?.createTitle ?? r.toolbar?.createText ?? r.createText,
|
|
1570
|
+
edit: r.editor?.editTitle ?? "编辑",
|
|
1571
|
+
view: r.editor?.viewTitle ?? "查看"
|
|
1572
|
+
})[Z.mode.value]);
|
|
1573
|
+
N(() => r.dataSource, () => void J.load(), { immediate: !0 }), N([h, g], () => void J.load());
|
|
1574
|
+
function Ne() {
|
|
1575
|
+
H.value = typeof document < "u" && document.fullscreenElement === b.value;
|
|
1576
|
+
}
|
|
1577
|
+
function Pe(e) {
|
|
1578
|
+
if (r.query?.columns !== void 0 || e <= 0) return;
|
|
1579
|
+
let t = e >= 1280 ? 4 : e >= 960 ? 3 : e >= 640 ? 2 : 1;
|
|
1580
|
+
B.value !== t && (B.value = t);
|
|
1581
|
+
}
|
|
1582
|
+
function Fe() {
|
|
1583
|
+
K?.disconnect(), K = void 0, w.value && (Pe(w.value.clientWidth), !(typeof ResizeObserver > "u") && (K = new ResizeObserver((e) => Pe(e[0]?.contentRect.width ?? 0)), K.observe(w.value)));
|
|
1584
|
+
}
|
|
1585
|
+
function Ie(e) {
|
|
1586
|
+
ke.value !== e && (ke.value = e, G.value = W.value[U.value], _(() => {
|
|
1587
|
+
G.value ? Fe() : K?.disconnect(), F.value?.doLayout();
|
|
1588
|
+
}));
|
|
1589
|
+
}
|
|
1590
|
+
function Le(e) {
|
|
1591
|
+
Ie(e.matches);
|
|
1592
|
+
}
|
|
1593
|
+
S(() => {
|
|
1594
|
+
typeof document < "u" && document.addEventListener("fullscreenchange", Ne), typeof window < "u" && typeof window.matchMedia == "function" && (je = window.matchMedia("(max-width: 768px)"), Ie(je.matches), je.addEventListener?.("change", Le)), Fe();
|
|
1595
|
+
}), x(() => {
|
|
1596
|
+
typeof document < "u" && document.removeEventListener("fullscreenchange", Ne), je?.removeEventListener?.("change", Le), K?.disconnect(), Ae && clearTimeout(Ae);
|
|
1597
|
+
}), N(() => r.query?.columns, (e) => {
|
|
1598
|
+
e === void 0 && Pe(w.value?.clientWidth ?? 0);
|
|
1599
|
+
}), N([() => r.query?.defaultVisible, () => r.query?.mobileDefaultVisible], ([e, t]) => {
|
|
1600
|
+
W.value = {
|
|
1601
|
+
desktop: e ?? !0,
|
|
1602
|
+
mobile: t ?? e ?? !0
|
|
1603
|
+
}, G.value = W.value[U.value];
|
|
1604
|
+
});
|
|
1605
|
+
function Re() {
|
|
1606
|
+
i("search", { ...p.value }), h.value === 1 ? J.load() : h.value = 1;
|
|
1607
|
+
}
|
|
1608
|
+
function ze() {
|
|
1609
|
+
let e = Y.reset();
|
|
1610
|
+
A.value?.resetFields(), i("reset", e), h.value === 1 ? J.load() : h.value = 1;
|
|
1611
|
+
}
|
|
1612
|
+
function Be() {
|
|
1613
|
+
r.query?.submitOnChange && (Ae && clearTimeout(Ae), Ae = setTimeout(Re, Math.max(0, r.query.submitDebounce ?? 300)));
|
|
1614
|
+
}
|
|
1615
|
+
async function Ve() {
|
|
1616
|
+
let e = [...X.selectedRows.value], t = e.length > 0 ? e : J.currentRows.value, n = {
|
|
1617
|
+
columns: ie.value,
|
|
1618
|
+
query: { ...p.value },
|
|
1619
|
+
rows: t,
|
|
1620
|
+
selectedRows: e
|
|
1621
|
+
};
|
|
1622
|
+
i("export", {
|
|
1623
|
+
query: n.query,
|
|
1624
|
+
selectedRows: e
|
|
1625
|
+
});
|
|
1626
|
+
let a = typeof r.toolbar?.export == "object" ? r.toolbar.export : void 0;
|
|
1627
|
+
if (a?.handler) {
|
|
1628
|
+
await a.handler(n);
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
let o = F.value?.getExportData(t);
|
|
1632
|
+
if (!o || typeof document > "u" || typeof URL > "u" || typeof navigator < "u" && navigator.userAgent.toLowerCase().includes("jsdom")) return;
|
|
1633
|
+
let s = (e) => `"${e.replace(/"/g, "\"\"")}"`, c = [o.columns.map((e) => s(e.label)).join(","), ...o.rows.map((e) => e.map(s).join(","))].join("\n"), l = new Blob([`\uFEFF${c}`], { type: "text/csv;charset=utf-8" }), u = URL.createObjectURL(l), d = document.createElement("a");
|
|
1634
|
+
d.href = u, d.download = a?.filename ?? `lumal-export-${Date.now()}.csv`, d.click(), URL.revokeObjectURL(u);
|
|
1635
|
+
}
|
|
1636
|
+
async function He() {
|
|
1637
|
+
if (!(!b.value || typeof document > "u")) try {
|
|
1638
|
+
document.fullscreenElement === b.value ? await document.exitFullscreen?.() : await b.value.requestFullscreen?.();
|
|
1639
|
+
} catch (e) {
|
|
1640
|
+
i("operationError", e);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
function Ue(e) {
|
|
1644
|
+
i("pageChange", e);
|
|
1645
|
+
}
|
|
1646
|
+
function We() {
|
|
1647
|
+
if (G.value = !G.value, W.value = {
|
|
1648
|
+
...W.value,
|
|
1649
|
+
[U.value]: G.value
|
|
1650
|
+
}, G.value) {
|
|
1651
|
+
_(() => {
|
|
1652
|
+
Fe(), F.value?.doLayout();
|
|
1653
|
+
});
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
K?.disconnect(), _(() => F.value?.doLayout());
|
|
1657
|
+
}
|
|
1658
|
+
function Ge(e, t, n, r) {
|
|
1659
|
+
return typeof e == "function" ? e(n, r) : e ?? t;
|
|
1660
|
+
}
|
|
1661
|
+
function Ke() {
|
|
1662
|
+
Z.open("create");
|
|
1663
|
+
}
|
|
1664
|
+
function qe(e) {
|
|
1665
|
+
Z.open("edit", e);
|
|
1666
|
+
}
|
|
1667
|
+
function Je(e) {
|
|
1668
|
+
Z.open("view", e);
|
|
1669
|
+
}
|
|
1670
|
+
async function Ye(e) {
|
|
1671
|
+
!await Z.submit(e, async () => await ne.value?.validate() !== !1) && Z.error.value && i("operationError", Error(Z.error.value));
|
|
1672
|
+
}
|
|
1673
|
+
async function Xe(e) {
|
|
1674
|
+
let t = r.actions?.confirmRemove;
|
|
1675
|
+
if (t === !1) return !0;
|
|
1676
|
+
if (typeof t == "function") return t(e);
|
|
1677
|
+
let n = typeof t?.message == "function" ? t.message(e) : t?.message ?? `确定删除选中的 ${e.length} 条数据吗?`;
|
|
1678
|
+
try {
|
|
1679
|
+
return await me.confirm(n, t?.title ?? "删除确认", {
|
|
1680
|
+
cancelButtonText: t?.cancelButtonText ?? "取消",
|
|
1681
|
+
confirmButtonText: t?.confirmButtonText ?? "删除",
|
|
1682
|
+
type: "warning"
|
|
1683
|
+
}), !0;
|
|
1684
|
+
} catch {
|
|
1685
|
+
return !1;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
async function et(e) {
|
|
1689
|
+
V.value = !0;
|
|
1690
|
+
try {
|
|
1691
|
+
return await e(), bt(), await J.load(), !0;
|
|
1692
|
+
} catch (e) {
|
|
1693
|
+
return i("operationError", e), !1;
|
|
1694
|
+
} finally {
|
|
1695
|
+
V.value = !1;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
async function nt(e) {
|
|
1699
|
+
let t = r.dataSource?.remove, n = !r.dataSource?.beforeRemove || await r.dataSource.beforeRemove([e]);
|
|
1700
|
+
!t || !n || !await Xe([e]) || await et(() => t(e));
|
|
1701
|
+
}
|
|
1702
|
+
async function rt() {
|
|
1703
|
+
let e = [...X.selectedRows.value], t = !r.dataSource?.beforeRemove || await r.dataSource.beforeRemove(e);
|
|
1704
|
+
e.length === 0 || !t || !await Xe(e) || await et(() => r.dataSource?.removeMany ? r.dataSource.removeMany(e) : Promise.all(e.map((e) => r.dataSource?.remove?.(e))));
|
|
1705
|
+
}
|
|
1706
|
+
async function gt() {
|
|
1707
|
+
if (Z.saving.value) return !1;
|
|
1708
|
+
if (!Z.dirty.value) return !0;
|
|
1709
|
+
if (r.editor?.confirmClose) return r.editor.confirmClose({
|
|
1710
|
+
mode: Z.mode.value,
|
|
1711
|
+
model: Z.model.value,
|
|
1712
|
+
row: Z.editingRow.value
|
|
1713
|
+
});
|
|
1714
|
+
try {
|
|
1715
|
+
return await me.confirm("表单内容尚未保存,确定关闭吗?", "关闭确认", {
|
|
1716
|
+
cancelButtonText: "继续编辑",
|
|
1717
|
+
confirmButtonText: "关闭",
|
|
1718
|
+
type: "warning"
|
|
1719
|
+
}), !0;
|
|
1720
|
+
} catch {
|
|
1721
|
+
return !1;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function _t(e) {
|
|
1725
|
+
gt().then((t) => {
|
|
1726
|
+
t && e();
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
function vt() {
|
|
1730
|
+
gt().then((e) => {
|
|
1731
|
+
e && (Z.visible.value = !1);
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
function yt() {
|
|
1735
|
+
Ye(Z.model.value);
|
|
1736
|
+
}
|
|
1737
|
+
function bt() {
|
|
1738
|
+
X.clear(), F.value?.clearSelection();
|
|
1739
|
+
}
|
|
1740
|
+
return t({
|
|
1741
|
+
clearSelection: bt,
|
|
1742
|
+
getCrudElement: () => b.value,
|
|
1743
|
+
closeEditor: vt,
|
|
1744
|
+
getEditorForm: () => ne.value,
|
|
1745
|
+
getQueryForm: () => A.value,
|
|
1746
|
+
getSelectedRowKeys: () => [...X.selectedRowKeys.value],
|
|
1747
|
+
getSelectedRows: () => [...X.selectedRows.value],
|
|
1748
|
+
getTable: () => F.value,
|
|
1749
|
+
isLoading: () => Q.value,
|
|
1750
|
+
openCreate: Ke,
|
|
1751
|
+
openEdit: qe,
|
|
1752
|
+
openView: Je,
|
|
1753
|
+
query: Re,
|
|
1754
|
+
reset: ze,
|
|
1755
|
+
reload: J.load,
|
|
1756
|
+
removeRow: nt,
|
|
1757
|
+
removeSelectedRows: rt,
|
|
1758
|
+
setFormData: (e) => ne.value?.setValues(e),
|
|
1759
|
+
toggleFullscreen: He,
|
|
1760
|
+
toggleQuery: Y.toggle,
|
|
1761
|
+
toggleQueryPanel: We
|
|
1762
|
+
}), (t, n) => (C(), c("div", {
|
|
1763
|
+
ref_key: "crudRef",
|
|
1764
|
+
ref: b,
|
|
1765
|
+
class: "lumal-crud-table"
|
|
1766
|
+
}, [
|
|
1767
|
+
he.value ? te((C(), c("div", {
|
|
1768
|
+
key: 0,
|
|
1769
|
+
ref_key: "queryRef",
|
|
1770
|
+
ref: w,
|
|
1771
|
+
class: v(["lumal-crud-table__query", { "is-collapsed": k(Y).collapsed.value }])
|
|
1772
|
+
}, [f(k(q), {
|
|
1773
|
+
ref_key: "queryFormRef",
|
|
1774
|
+
ref: A,
|
|
1775
|
+
modelValue: p.value,
|
|
1776
|
+
"onUpdate:modelValue": n[0] ||= (e) => p.value = e,
|
|
1777
|
+
schemas: k(Y).visibleSchemas.value,
|
|
1778
|
+
columns: ce.value,
|
|
1779
|
+
"label-width": e.query?.labelWidth ?? 88,
|
|
1780
|
+
class: "lumal-crud-table__query-form",
|
|
1781
|
+
onValuesChange: Be
|
|
1782
|
+
}, u({ _: 2 }, [T(k(Y).visibleSchemas.value.filter((e) => t.$slots[`query-${String(e.field)}`]), (e) => ({
|
|
1783
|
+
name: `field-${String(e.field)}`,
|
|
1784
|
+
fn: P((n) => [E(t.$slots, `query-${String(e.field)}`, y(m(n)), void 0, !0)])
|
|
1785
|
+
}))]), 1032, [
|
|
1786
|
+
"modelValue",
|
|
1787
|
+
"schemas",
|
|
1788
|
+
"columns",
|
|
1789
|
+
"label-width"
|
|
1790
|
+
]), l("div", st, [
|
|
1791
|
+
f(k(R), {
|
|
1792
|
+
type: "primary",
|
|
1793
|
+
"native-type": "button",
|
|
1794
|
+
"data-action": "search",
|
|
1795
|
+
onClick: Re
|
|
1796
|
+
}, {
|
|
1797
|
+
default: P(() => [d(O(e.query?.searchText ?? e.searchText), 1)]),
|
|
1798
|
+
_: 1
|
|
1799
|
+
}),
|
|
1800
|
+
f(k(R), {
|
|
1801
|
+
"native-type": "button",
|
|
1802
|
+
"data-action": "reset",
|
|
1803
|
+
onClick: ze
|
|
1804
|
+
}, {
|
|
1805
|
+
default: P(() => [d(O(e.query?.resetText ?? e.resetText), 1)]),
|
|
1806
|
+
_: 1
|
|
1807
|
+
}),
|
|
1808
|
+
k(Y).canCollapse.value ? (C(), o(k(R), {
|
|
1809
|
+
key: 0,
|
|
1810
|
+
"native-type": "button",
|
|
1811
|
+
"data-action": "toggle-query",
|
|
1812
|
+
"aria-expanded": String(!k(Y).collapsed.value),
|
|
1813
|
+
onClick: k(Y).toggle
|
|
1814
|
+
}, {
|
|
1815
|
+
default: P(() => [d(O(k(Y).collapsed.value ? "展开" : "收起"), 1)]),
|
|
1816
|
+
_: 1
|
|
1817
|
+
}, 8, ["aria-expanded", "onClick"])) : s("", !0)
|
|
1818
|
+
])], 2)), [[M, G.value]]) : s("", !0),
|
|
1819
|
+
k(J).error.value ? (C(), c("div", ct, [l("span", null, O(k(J).error.value), 1), f(k(R), {
|
|
1820
|
+
"native-type": "button",
|
|
1821
|
+
"data-action": "retry",
|
|
1822
|
+
onClick: k(J).load
|
|
1823
|
+
}, {
|
|
1824
|
+
default: P(() => [...n[5] ||= [d(" 重试 ", -1)]]),
|
|
1825
|
+
_: 1
|
|
1826
|
+
}, 8, ["onClick"])])) : s("", !0),
|
|
1827
|
+
l("section", lt, [
|
|
1828
|
+
l("div", ut, [f(k(Ze), {
|
|
1829
|
+
ref_key: "tableRef",
|
|
1830
|
+
ref: F,
|
|
1831
|
+
columns: ie.value,
|
|
1832
|
+
rows: k(J).currentRows.value,
|
|
1833
|
+
"row-key": oe.value,
|
|
1834
|
+
"empty-text": se.value,
|
|
1835
|
+
loading: Q.value,
|
|
1836
|
+
selection: z.value,
|
|
1837
|
+
"show-column-settings": e.table?.showColumnSettings,
|
|
1838
|
+
"column-settings": e.table?.columnSettings,
|
|
1839
|
+
"auto-resize": e.table?.autoResize ?? !0,
|
|
1840
|
+
"action-width": e.table?.actionWidth,
|
|
1841
|
+
"mobile-action-width": e.table?.mobileActionWidth,
|
|
1842
|
+
"table-props": {
|
|
1843
|
+
height: "100%",
|
|
1844
|
+
border: !0
|
|
1845
|
+
},
|
|
1846
|
+
onSelectionChange: k(X).update
|
|
1847
|
+
}, u({ _: 2 }, [
|
|
1848
|
+
t.$slots["table-title"] || e.title ? {
|
|
1849
|
+
name: "toolbar-title",
|
|
1850
|
+
fn: P(() => [E(t.$slots, "table-title", {}, () => [d(O(e.title), 1)], !0)]),
|
|
1851
|
+
key: "0"
|
|
1852
|
+
} : void 0,
|
|
1853
|
+
Ce.value || t.$slots.actions || t.$slots["toolbar-actions"] ? {
|
|
1854
|
+
name: "toolbar",
|
|
1855
|
+
fn: P(() => [l("div", { class: v(["lumal-crud-table__toolbar", `is-${e.toolbar?.actionsPosition ?? "right"}`]) }, [
|
|
1856
|
+
_e.value ? E(t.$slots, "create-action", {
|
|
1857
|
+
key: 0,
|
|
1858
|
+
openCreate: Ke
|
|
1859
|
+
}, () => [f(k(R), {
|
|
1860
|
+
type: "primary",
|
|
1861
|
+
"native-type": "button",
|
|
1862
|
+
"data-action": "create",
|
|
1863
|
+
onClick: Ke
|
|
1864
|
+
}, {
|
|
1865
|
+
default: P(() => [f(k(I), { name: "lumal:plus" }), d(" " + O(e.toolbar?.createText ?? e.createText), 1)]),
|
|
1866
|
+
_: 1
|
|
1867
|
+
})], !0) : s("", !0),
|
|
1868
|
+
ve.value ? (C(), o(k(R), {
|
|
1869
|
+
key: 1,
|
|
1870
|
+
"native-type": "button",
|
|
1871
|
+
"data-action": "batch-remove",
|
|
1872
|
+
disabled: k(X).selectedRows.value.length === 0 || V.value,
|
|
1873
|
+
onClick: rt
|
|
1874
|
+
}, {
|
|
1875
|
+
default: P(() => [d(O(e.toolbar?.batchDeleteText ?? e.batchDeleteText), 1)]),
|
|
1876
|
+
_: 1
|
|
1877
|
+
}, 8, ["disabled"])) : s("", !0),
|
|
1878
|
+
be.value ? (C(), o(k(R), {
|
|
1879
|
+
key: 2,
|
|
1880
|
+
"native-type": "button",
|
|
1881
|
+
"data-action": "export",
|
|
1882
|
+
onClick: Ve
|
|
1883
|
+
}, {
|
|
1884
|
+
default: P(() => [d(O(e.toolbar?.exportText ?? "导出"), 1)]),
|
|
1885
|
+
_: 1
|
|
1886
|
+
})) : s("", !0),
|
|
1887
|
+
E(t.$slots, "toolbar-actions", {
|
|
1888
|
+
reload: k(J).load,
|
|
1889
|
+
openCreate: Ke,
|
|
1890
|
+
selectedRows: k(X).selectedRows.value,
|
|
1891
|
+
selectedRowKeys: k(X).selectedRowKeys.value,
|
|
1892
|
+
clearSelection: bt
|
|
1893
|
+
}, void 0, !0),
|
|
1894
|
+
E(t.$slots, "actions", {}, void 0, !0)
|
|
1895
|
+
], 2)]),
|
|
1896
|
+
key: "1"
|
|
1897
|
+
} : void 0,
|
|
1898
|
+
we.value || t.$slots["toolbar-tools"] ? {
|
|
1899
|
+
name: "toolbar-tools",
|
|
1900
|
+
fn: P(() => [l("div", dt, [
|
|
1901
|
+
E(t.$slots, "toolbar-tools", {
|
|
1902
|
+
reload: k(J).load,
|
|
1903
|
+
toggleFullscreen: He
|
|
1904
|
+
}, void 0, !0),
|
|
1905
|
+
Se.value ? (C(), o(k(R), {
|
|
1906
|
+
key: 0,
|
|
1907
|
+
circle: "",
|
|
1908
|
+
"native-type": "button",
|
|
1909
|
+
"data-action": "toggle-query-panel",
|
|
1910
|
+
class: v({ "is-active": G.value }),
|
|
1911
|
+
"aria-expanded": String(G.value),
|
|
1912
|
+
"aria-label": G.value ? "隐藏筛选条件" : "显示筛选条件",
|
|
1913
|
+
title: G.value ? "隐藏筛选条件" : "显示筛选条件",
|
|
1914
|
+
onClick: We
|
|
1915
|
+
}, {
|
|
1916
|
+
default: P(() => [f(k(I), { name: "lumal:filter" })]),
|
|
1917
|
+
_: 1
|
|
1918
|
+
}, 8, [
|
|
1919
|
+
"class",
|
|
1920
|
+
"aria-expanded",
|
|
1921
|
+
"aria-label",
|
|
1922
|
+
"title"
|
|
1923
|
+
])) : s("", !0),
|
|
1924
|
+
ye.value ? (C(), o(k(R), {
|
|
1925
|
+
key: 1,
|
|
1926
|
+
circle: "",
|
|
1927
|
+
"native-type": "button",
|
|
1928
|
+
"data-action": "refresh",
|
|
1929
|
+
"aria-label": e.toolbar?.refreshText ?? "刷新",
|
|
1930
|
+
title: e.toolbar?.refreshText ?? "刷新",
|
|
1931
|
+
onClick: k(J).load
|
|
1932
|
+
}, {
|
|
1933
|
+
default: P(() => [f(k(I), { name: "lumal:refresh" })]),
|
|
1934
|
+
_: 1
|
|
1935
|
+
}, 8, [
|
|
1936
|
+
"aria-label",
|
|
1937
|
+
"title",
|
|
1938
|
+
"onClick"
|
|
1939
|
+
])) : s("", !0),
|
|
1940
|
+
xe.value ? (C(), o(k(R), {
|
|
1941
|
+
key: 2,
|
|
1942
|
+
circle: "",
|
|
1943
|
+
"native-type": "button",
|
|
1944
|
+
"data-action": "fullscreen",
|
|
1945
|
+
"aria-label": e.toolbar?.fullscreenText ?? (H.value ? "退出全屏" : "全屏"),
|
|
1946
|
+
title: e.toolbar?.fullscreenText ?? (H.value ? "退出全屏" : "全屏"),
|
|
1947
|
+
onClick: He
|
|
1948
|
+
}, {
|
|
1949
|
+
default: P(() => [f(k(I), { name: H.value ? "lumal:fullscreen-exit" : "lumal:fullscreen" }, null, 8, ["name"])]),
|
|
1950
|
+
_: 1
|
|
1951
|
+
}, 8, ["aria-label", "title"])) : s("", !0)
|
|
1952
|
+
])]),
|
|
1953
|
+
key: "2"
|
|
1954
|
+
} : void 0,
|
|
1955
|
+
T(ie.value.filter((e) => t.$slots[`table-${String(e.field)}`]), (e) => ({
|
|
1956
|
+
name: `table-${String(e.field)}`,
|
|
1957
|
+
fn: P((n) => [E(t.$slots, `table-${String(e.field)}`, y(m(n)), void 0, !0)])
|
|
1958
|
+
})),
|
|
1959
|
+
ge.value || Oe.value?.remove || t.$slots["row-actions"] ? {
|
|
1960
|
+
name: "actions",
|
|
1961
|
+
fn: P(({ row: n, index: r }) => [E(t.$slots, "row-actions", {
|
|
1962
|
+
row: n,
|
|
1963
|
+
index: r,
|
|
1964
|
+
openView: Je,
|
|
1965
|
+
openEdit: qe,
|
|
1966
|
+
removeRow: nt
|
|
1967
|
+
}, () => [
|
|
1968
|
+
Ge(e.actions?.view, ge.value, n, r) ? (C(), o(k(R), {
|
|
1969
|
+
key: 0,
|
|
1970
|
+
"native-type": "button",
|
|
1971
|
+
"data-action": "view",
|
|
1972
|
+
onClick: (e) => Je(n)
|
|
1973
|
+
}, {
|
|
1974
|
+
default: P(() => [d(O(e.actions?.viewText ?? "查看"), 1)]),
|
|
1975
|
+
_: 1
|
|
1976
|
+
}, 8, ["onClick"])) : s("", !0),
|
|
1977
|
+
Ge(e.actions?.edit, ge.value, n, r) ? (C(), o(k(R), {
|
|
1978
|
+
key: 1,
|
|
1979
|
+
"native-type": "button",
|
|
1980
|
+
"data-action": "edit",
|
|
1981
|
+
onClick: (e) => qe(n)
|
|
1982
|
+
}, {
|
|
1983
|
+
default: P(() => [d(O(e.actions?.editText ?? "编辑"), 1)]),
|
|
1984
|
+
_: 1
|
|
1985
|
+
}, 8, ["onClick"])) : s("", !0),
|
|
1986
|
+
Ge(e.actions?.remove, !!Oe.value?.remove, n, r) ? (C(), o(k(R), {
|
|
1987
|
+
key: 2,
|
|
1988
|
+
type: "danger",
|
|
1989
|
+
"native-type": "button",
|
|
1990
|
+
"data-action": "remove",
|
|
1991
|
+
onClick: (e) => nt(n)
|
|
1992
|
+
}, {
|
|
1993
|
+
default: P(() => [d(O(e.actions?.removeText ?? "删除"), 1)]),
|
|
1994
|
+
_: 1
|
|
1995
|
+
}, 8, ["onClick"])) : s("", !0)
|
|
1996
|
+
], !0)]),
|
|
1997
|
+
key: "3"
|
|
1998
|
+
} : void 0
|
|
1999
|
+
]), 1032, [
|
|
2000
|
+
"columns",
|
|
2001
|
+
"rows",
|
|
2002
|
+
"row-key",
|
|
2003
|
+
"empty-text",
|
|
2004
|
+
"loading",
|
|
2005
|
+
"selection",
|
|
2006
|
+
"show-column-settings",
|
|
2007
|
+
"column-settings",
|
|
2008
|
+
"auto-resize",
|
|
2009
|
+
"action-width",
|
|
2010
|
+
"mobile-action-width",
|
|
2011
|
+
"onSelectionChange"
|
|
2012
|
+
])]),
|
|
2013
|
+
t.$slots.default ? (C(), c("div", ft, [E(t.$slots, "default", {}, void 0, !0)])) : s("", !0),
|
|
2014
|
+
$.value ? (C(), c("div", pt, [f(k(De), {
|
|
2015
|
+
page: h.value,
|
|
2016
|
+
"onUpdate:page": n[1] ||= (e) => h.value = e,
|
|
2017
|
+
"page-size": g.value,
|
|
2018
|
+
"onUpdate:pageSize": n[2] ||= (e) => g.value = e,
|
|
2019
|
+
total: k(J).currentTotal.value,
|
|
2020
|
+
"page-sizes": pe.value,
|
|
2021
|
+
onChange: Ue
|
|
2022
|
+
}, null, 8, [
|
|
2023
|
+
"page",
|
|
2024
|
+
"page-size",
|
|
2025
|
+
"total",
|
|
2026
|
+
"page-sizes"
|
|
2027
|
+
])])) : s("", !0)
|
|
2028
|
+
]),
|
|
2029
|
+
f(Qe, {
|
|
2030
|
+
modelValue: k(Z).visible.value,
|
|
2031
|
+
"onUpdate:modelValue": n[4] ||= (e) => k(Z).visible.value = e,
|
|
2032
|
+
title: Me.value,
|
|
2033
|
+
type: e.editor?.type ?? "dialog",
|
|
2034
|
+
width: e.editor?.width ?? (e.editor?.type === "drawer" ? "min(720px, 92vw)" : "min(920px, calc(100vw - 32px))"),
|
|
2035
|
+
"close-on-click-modal": e.editor?.closeOnClickModal ?? !1,
|
|
2036
|
+
"destroy-on-close": e.editor?.destroyOnClose ?? !0,
|
|
2037
|
+
"before-close": _t
|
|
2038
|
+
}, {
|
|
2039
|
+
footer: P(() => [E(t.$slots, "footer", {
|
|
2040
|
+
mode: k(Z).mode.value,
|
|
2041
|
+
model: k(Z).model.value,
|
|
2042
|
+
close: vt,
|
|
2043
|
+
submit: yt
|
|
2044
|
+
}, () => [l("div", ht, [f(k(R), {
|
|
2045
|
+
"native-type": "button",
|
|
2046
|
+
onClick: vt
|
|
2047
|
+
}, {
|
|
2048
|
+
default: P(() => [d(O(k(Z).mode.value === "view" ? "关闭" : "取消"), 1)]),
|
|
2049
|
+
_: 1
|
|
2050
|
+
}), k(Z).mode.value === "view" ? s("", !0) : (C(), o(k(R), {
|
|
2051
|
+
key: 0,
|
|
2052
|
+
type: "primary",
|
|
2053
|
+
"native-type": "button",
|
|
2054
|
+
loading: k(Z).saving.value,
|
|
2055
|
+
onClick: yt
|
|
2056
|
+
}, {
|
|
2057
|
+
default: P(() => [d(O(e.editor?.submitText ?? "保存"), 1)]),
|
|
2058
|
+
_: 1
|
|
2059
|
+
}, 8, ["loading"]))])], !0)]),
|
|
2060
|
+
default: P(() => [k(Z).error.value ? (C(), c("div", mt, O(k(Z).error.value), 1)) : s("", !0), f(k(q), {
|
|
2061
|
+
ref_key: "dialogFormRef",
|
|
2062
|
+
ref: ne,
|
|
2063
|
+
modelValue: k(Z).model.value,
|
|
2064
|
+
"onUpdate:modelValue": n[3] ||= (e) => k(Z).model.value = e,
|
|
2065
|
+
mode: k(Z).mode.value,
|
|
2066
|
+
schemas: ae.value,
|
|
2067
|
+
columns: e.editor?.columns ?? 2,
|
|
2068
|
+
"label-width": e.editor?.labelWidth ?? 88,
|
|
2069
|
+
loading: e.editor?.loading,
|
|
2070
|
+
disabled: k(Z).saving.value || e.editor?.disabled,
|
|
2071
|
+
"submit-loading": k(Z).saving.value,
|
|
2072
|
+
"show-actions": !1,
|
|
2073
|
+
onSubmit: Ye
|
|
2074
|
+
}, u({ _: 2 }, [T(ae.value.filter((e) => t.$slots[`form-${String(e.field)}`]), (e) => ({
|
|
2075
|
+
name: `field-${String(e.field)}`,
|
|
2076
|
+
fn: P((n) => [E(t.$slots, `form-${String(e.field)}`, y(m(n)), void 0, !0)])
|
|
2077
|
+
}))]), 1032, [
|
|
2078
|
+
"modelValue",
|
|
2079
|
+
"mode",
|
|
2080
|
+
"schemas",
|
|
2081
|
+
"columns",
|
|
2082
|
+
"label-width",
|
|
2083
|
+
"loading",
|
|
2084
|
+
"disabled",
|
|
2085
|
+
"submit-loading"
|
|
2086
|
+
])]),
|
|
2087
|
+
_: 3
|
|
2088
|
+
}, 8, [
|
|
2089
|
+
"modelValue",
|
|
2090
|
+
"title",
|
|
2091
|
+
"type",
|
|
2092
|
+
"width",
|
|
2093
|
+
"close-on-click-modal",
|
|
2094
|
+
"destroy-on-close"
|
|
2095
|
+
])
|
|
2096
|
+
], 512));
|
|
2097
|
+
}
|
|
2098
|
+
}), [["__scopeId", "data-v-9c07c262"]]), _t = { class: "lumal-info-table__value" }, vt = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
2099
|
+
__name: "LumalInfoTable",
|
|
2100
|
+
props: {
|
|
2101
|
+
items: {},
|
|
2102
|
+
columns: { default: 1 },
|
|
2103
|
+
labelWidth: { default: "88px" },
|
|
2104
|
+
emptyText: { default: "-" },
|
|
2105
|
+
bordered: {
|
|
2106
|
+
type: Boolean,
|
|
2107
|
+
default: !0
|
|
2108
|
+
}
|
|
2109
|
+
},
|
|
2110
|
+
setup(e, { expose: t }) {
|
|
2111
|
+
let n = e, r = j("infoTableRef"), o = a(() => n.items.filter((e) => !e.hidden)), s = a(() => ({ "--lumal-info-table-columns": String(Math.max(1, n.columns)) })), u = a(() => ({ width: typeof n.labelWidth == "number" ? `${n.labelWidth}px` : n.labelWidth }));
|
|
2112
|
+
function d(e) {
|
|
2113
|
+
return e.value === void 0 || e.value === null || e.value === "" ? e.emptyText ?? n.emptyText : String(e.value);
|
|
2114
|
+
}
|
|
2115
|
+
function f(e) {
|
|
2116
|
+
return Math.max(1, Math.min(e.span ?? 1, n.columns));
|
|
2117
|
+
}
|
|
2118
|
+
return t({ getInfoTableElement: () => r.value }), (t, n) => (C(), c("dl", {
|
|
2119
|
+
ref_key: "infoTableRef",
|
|
2120
|
+
ref: r,
|
|
2121
|
+
class: v(["lumal-info-table", { "lumal-info-table--bordered": e.bordered }]),
|
|
2122
|
+
style: b(s.value)
|
|
2123
|
+
}, [(C(!0), c(i, null, T(o.value, (e) => (C(), c("div", {
|
|
2124
|
+
key: e.label,
|
|
2125
|
+
class: "lumal-info-table__item",
|
|
2126
|
+
style: b({ gridColumn: `span ${f(e)}` })
|
|
2127
|
+
}, [l("dt", {
|
|
2128
|
+
class: "lumal-info-table__label",
|
|
2129
|
+
style: b(u.value)
|
|
2130
|
+
}, O(e.label), 5), l("dd", _t, O(d(e)), 1)], 4))), 128))], 6));
|
|
2131
|
+
}
|
|
2132
|
+
}), [["__scopeId", "data-v-3dfbcf43"]]), yt = {
|
|
2133
|
+
key: 0,
|
|
2134
|
+
class: "lumal-page__header"
|
|
2135
|
+
}, bt = { class: "lumal-page__heading" }, xt = {
|
|
2136
|
+
key: 0,
|
|
2137
|
+
class: "lumal-page__title"
|
|
2138
|
+
}, St = {
|
|
2139
|
+
key: 0,
|
|
2140
|
+
class: "lumal-page__description"
|
|
2141
|
+
}, Ct = {
|
|
2142
|
+
key: 0,
|
|
2143
|
+
class: "lumal-page__actions"
|
|
2144
|
+
}, wt = {
|
|
2145
|
+
key: 1,
|
|
2146
|
+
class: "lumal-page__loading"
|
|
2147
|
+
}, Tt = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
2148
|
+
__name: "LumalPage",
|
|
2149
|
+
props: {
|
|
2150
|
+
title: {},
|
|
2151
|
+
description: {},
|
|
2152
|
+
contentClass: { default: "" },
|
|
2153
|
+
fill: {
|
|
2154
|
+
type: Boolean,
|
|
2155
|
+
default: !1
|
|
2156
|
+
},
|
|
2157
|
+
loading: {
|
|
2158
|
+
type: Boolean,
|
|
2159
|
+
default: !1
|
|
2160
|
+
},
|
|
2161
|
+
loadingText: { default: "加载中" },
|
|
2162
|
+
noPadding: {
|
|
2163
|
+
type: Boolean,
|
|
2164
|
+
default: !1
|
|
2165
|
+
}
|
|
2166
|
+
},
|
|
2167
|
+
setup(e, { expose: t }) {
|
|
2168
|
+
let n = e, r = j("pageRef"), i = A(), o = a(() => !!(n.title || n.description || i.title || i.actions));
|
|
2169
|
+
return t({ getPageElement: () => r.value }), (t, n) => (C(), c("section", {
|
|
2170
|
+
ref_key: "pageRef",
|
|
2171
|
+
ref: r,
|
|
2172
|
+
class: v(["lumal-page", {
|
|
2173
|
+
"is-fill": e.fill,
|
|
2174
|
+
"is-no-padding": e.noPadding
|
|
2175
|
+
}])
|
|
2176
|
+
}, [
|
|
2177
|
+
o.value ? (C(), c("header", yt, [l("div", bt, [E(t.$slots, "title", {}, () => [e.title ? (C(), c("h2", xt, O(e.title), 1)) : s("", !0)], !0), e.description ? (C(), c("p", St, O(e.description), 1)) : s("", !0)]), t.$slots.actions ? (C(), c("div", Ct, [E(t.$slots, "actions", {}, void 0, !0)])) : s("", !0)])) : s("", !0),
|
|
2178
|
+
l("div", { class: v(["lumal-page__body", e.contentClass]) }, [E(t.$slots, "default", {}, void 0, !0)], 2),
|
|
2179
|
+
e.loading ? (C(), c("div", wt, O(e.loadingText), 1)) : s("", !0)
|
|
2180
|
+
], 2));
|
|
2181
|
+
}
|
|
2182
|
+
}), [["__scopeId", "data-v-c57520b6"]]), Et = {
|
|
2183
|
+
key: 0,
|
|
2184
|
+
class: "lumal-page-layout__query"
|
|
2185
|
+
}, Dt = { class: "lumal-page-layout__query-body" }, Ot = { class: "lumal-page-layout__query-actions" }, kt = {
|
|
2186
|
+
key: 1,
|
|
2187
|
+
class: "lumal-page-layout__toolbar"
|
|
2188
|
+
}, At = { class: "lumal-page-layout__content" }, jt = {
|
|
2189
|
+
key: 2,
|
|
2190
|
+
class: "lumal-page-layout__pagination"
|
|
2191
|
+
}, Mt = /*#__PURE__*/ r(/* @__PURE__ */ p({
|
|
2192
|
+
__name: "LumalPageLayout",
|
|
2193
|
+
props: {
|
|
2194
|
+
contentScrollable: {
|
|
2195
|
+
type: Boolean,
|
|
2196
|
+
default: !0
|
|
2197
|
+
},
|
|
2198
|
+
fill: {
|
|
2199
|
+
type: Boolean,
|
|
2200
|
+
default: !1
|
|
2201
|
+
},
|
|
2202
|
+
searchText: { default: "查询" },
|
|
2203
|
+
resetText: { default: "重置" },
|
|
2204
|
+
queryCollapsed: {
|
|
2205
|
+
type: Boolean,
|
|
2206
|
+
default: !1
|
|
2207
|
+
},
|
|
2208
|
+
surface: {
|
|
2209
|
+
type: Boolean,
|
|
2210
|
+
default: !0
|
|
2211
|
+
}
|
|
2212
|
+
},
|
|
2213
|
+
emits: ["reset", "search"],
|
|
2214
|
+
setup(e, { expose: t, emit: n }) {
|
|
2215
|
+
let r = e, i = n, o = j("pageLayoutRef"), u = A(), p = a(() => !!(u.query || u.form)), m = a(() => !!u.toolbar), h = a(() => !!u.pagination);
|
|
2216
|
+
function g() {
|
|
2217
|
+
i("search");
|
|
2218
|
+
}
|
|
2219
|
+
function _() {
|
|
2220
|
+
i("reset");
|
|
2221
|
+
}
|
|
2222
|
+
return t({ getPageLayoutElement: () => o.value }), (t, n) => (C(), c("section", {
|
|
2223
|
+
ref_key: "pageLayoutRef",
|
|
2224
|
+
ref: o,
|
|
2225
|
+
class: v(["lumal-page-layout", {
|
|
2226
|
+
"is-content-scrollable": e.contentScrollable,
|
|
2227
|
+
"is-fill": e.fill,
|
|
2228
|
+
"is-surface": e.surface
|
|
2229
|
+
}])
|
|
2230
|
+
}, [
|
|
2231
|
+
p.value ? (C(), c("div", Et, [te(l("div", Dt, [E(t.$slots, "query", {}, () => [E(t.$slots, "form", {}, void 0, !0)], !0)], 512), [[M, !r.queryCollapsed]]), l("div", Ot, [f(k(R), {
|
|
2232
|
+
type: "primary",
|
|
2233
|
+
"native-type": "button",
|
|
2234
|
+
"data-action": "search",
|
|
2235
|
+
onClick: g
|
|
2236
|
+
}, {
|
|
2237
|
+
default: P(() => [d(O(r.searchText), 1)]),
|
|
2238
|
+
_: 1
|
|
2239
|
+
}), f(k(R), {
|
|
2240
|
+
"native-type": "button",
|
|
2241
|
+
"data-action": "reset",
|
|
2242
|
+
onClick: _
|
|
2243
|
+
}, {
|
|
2244
|
+
default: P(() => [d(O(r.resetText), 1)]),
|
|
2245
|
+
_: 1
|
|
2246
|
+
})])])) : s("", !0),
|
|
2247
|
+
m.value ? (C(), c("div", kt, [E(t.$slots, "toolbar", {}, void 0, !0)])) : s("", !0),
|
|
2248
|
+
l("div", At, [E(t.$slots, "default", {}, void 0, !0)]),
|
|
2249
|
+
h.value ? (C(), c("div", jt, [E(t.$slots, "pagination", {}, void 0, !0)])) : s("", !0)
|
|
2250
|
+
], 2));
|
|
2251
|
+
}
|
|
2252
|
+
}), [["__scopeId", "data-v-d4b9bb06"]]);
|
|
2253
|
+
//#endregion
|
|
2254
|
+
export { Tt as a, $e as c, De as d, Mt as i, Ze as l, L as n, vt as o, ie as r, gt as s, re as t, q as u };
|