@agent-xy/admin-vue3 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +43 -2
- package/dist/index.js +1404 -0
- package/dist/style.css +1 -0
- package/dist/types/components/BaseCard/index.vue.d.ts +26 -0
- package/dist/types/components/DataTable/TableCell.vue.d.ts +14 -0
- package/dist/types/components/DataTable/index.vue.d.ts +53 -0
- package/dist/types/components/DataTable/types.d.ts +81 -0
- package/dist/types/components/Dialog/BaseDialog.vue.d.ts +141 -0
- package/dist/types/components/Dialog/index.d.ts +43 -0
- package/dist/types/components/Drawer/BaseDrawer.vue.d.ts +130 -0
- package/dist/types/components/Drawer/index.d.ts +1 -0
- package/dist/types/components/SearchForm/components/FormItem.vue.d.ts +35 -0
- package/dist/types/components/SearchForm/index.vue.d.ts +45 -0
- package/dist/types/components/SearchForm/types.d.ts +97 -0
- package/dist/types/components/SearchForm/values.d.ts +4 -0
- package/dist/types/hooks/useAsyncListAction.d.ts +7 -0
- package/dist/types/hooks/usePageList.d.ts +30 -0
- package/dist/types/hooks/useSelectOptions.d.ts +16 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/types/admin.d.ts +3 -0
- package/dist/types/utils/adminCore.d.ts +74 -0
- package/dist/types/utils/data.d.ts +2 -0
- package/dist/types/utils/formRender.d.ts +2 -0
- package/dist/types/utils/tableRender.d.ts +7 -0
- package/docs/DataTable.md +23 -0
- package/docs/SearchForm.md +21 -0
- package/docs/usage.md +33 -0
- package/package.json +39 -4
- package/templates/manifest.json +23 -0
- package/templates/users/README.md +12 -0
- package/templates/users/UsersList.vue +73 -0
- package/templates/users/config.ts +12 -0
- package/templates/users/data-source.ts +5 -0
- package/templates/users/index.vue +21 -0
- package/templates/users/style.css +5 -0
- package/templates/users/types.ts +13 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1404 @@
|
|
|
1
|
+
import { defineComponent as Z, openBlock as b, createElementBlock as A, renderSlot as T, createElementVNode as J, toDisplayString as P, createCommentVNode as N, useId as Ce, computed as z, ref as F, watch as G, onBeforeUnmount as ne, createBlock as B, unref as C, normalizeClass as fe, withCtx as D, normalizeStyle as me, mergeProps as Q, Fragment as te, renderList as ae, createVNode as U, nextTick as oe, withModifiers as Se, createSlots as pe, createTextVNode as q, resolveDynamicComponent as ke, h as X, useAttrs as xe, useSlots as ge, shallowRef as re, onBeforeUpdate as Oe, normalizeProps as Ee, guardReactiveProps as De, withDirectives as ze, reactive as Be, isVNode as $e, render as be, onScopeDispose as ve, onMounted as je } from "vue";
|
|
2
|
+
import { ElFormItem as Ve, ElInput as Ae, ElInputNumber as ce, ElSelect as Ne, ElOption as Te, ElDatePicker as Fe, ElForm as Pe, ElButton as _, ElTooltip as Me, ElLoading as Re, ElPopover as Ie, ElCheckboxGroup as He, ElCheckbox as qe, ElTable as Le, ElTableColumn as se, ElEmpty as Ue, ElPagination as Ke, ElDialog as Ye, ElDrawer as We, ElMessage as Ge } from "element-plus";
|
|
3
|
+
import Je from "async-validator";
|
|
4
|
+
const Qe = { class: "base-card" }, Xe = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "base-card__header"
|
|
7
|
+
}, Ze = { class: "base-card__title" }, _e = { class: "base-card__body" }, et = /* @__PURE__ */ Z({
|
|
8
|
+
__name: "index",
|
|
9
|
+
props: { title: { type: String, default: "" } },
|
|
10
|
+
setup(e) {
|
|
11
|
+
return (i, o) => (b(), A("div", Qe, [
|
|
12
|
+
e.title || i.$slots.title ? (b(), A("div", Xe, [
|
|
13
|
+
T(i.$slots, "title", {}, () => [
|
|
14
|
+
J("span", Ze, P(e.title), 1)
|
|
15
|
+
], !0)
|
|
16
|
+
])) : N("", !0),
|
|
17
|
+
J("div", _e, [
|
|
18
|
+
T(i.$slots, "default", {}, void 0, !0)
|
|
19
|
+
])
|
|
20
|
+
]));
|
|
21
|
+
}
|
|
22
|
+
}), ie = (e, i) => {
|
|
23
|
+
const o = e.__vccOpts || e;
|
|
24
|
+
for (const [t, n] of i)
|
|
25
|
+
o[t] = n;
|
|
26
|
+
return o;
|
|
27
|
+
}, Et = /* @__PURE__ */ ie(et, [["__scopeId", "data-v-08a819b4"]]);
|
|
28
|
+
function L(e) {
|
|
29
|
+
if (e instanceof Date) return new Date(e.getTime());
|
|
30
|
+
if (Array.isArray(e)) return e.map(L);
|
|
31
|
+
if (e && typeof e == "object") {
|
|
32
|
+
if (Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null)
|
|
33
|
+
throw new TypeError("SearchForm 仅支持普通对象、数组和 Date");
|
|
34
|
+
return Object.fromEntries(
|
|
35
|
+
Object.entries(e).map(([i, o]) => [i, L(o)])
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
function he(e, i) {
|
|
41
|
+
if (Object.is(e, i)) return !0;
|
|
42
|
+
if (e instanceof Date && i instanceof Date)
|
|
43
|
+
return e.getTime() === i.getTime();
|
|
44
|
+
if (!e || !i || typeof e != "object" || typeof i != "object")
|
|
45
|
+
return !1;
|
|
46
|
+
const o = e, t = i;
|
|
47
|
+
return Object.keys(o).length === Object.keys(t).length && Object.keys(o).every((n) => Object.hasOwn(t, n) && he(o[n], t[n]));
|
|
48
|
+
}
|
|
49
|
+
function ee(e) {
|
|
50
|
+
return e.itemType === "inputBoxInterval" ? [e.propName1, e.propName2] : [e.propName];
|
|
51
|
+
}
|
|
52
|
+
const tt = {
|
|
53
|
+
key: 4,
|
|
54
|
+
class: "ai-code-search-form__range"
|
|
55
|
+
}, at = /* @__PURE__ */ Z({
|
|
56
|
+
__name: "FormItem",
|
|
57
|
+
props: {
|
|
58
|
+
item: {},
|
|
59
|
+
formObj: {},
|
|
60
|
+
disabled: { type: Boolean }
|
|
61
|
+
},
|
|
62
|
+
emits: ["change"],
|
|
63
|
+
setup(e, { expose: i, emit: o }) {
|
|
64
|
+
const t = e, n = o, d = `search-error-${Ce()}`, r = z(() => t.item.propName ?? t.item.propName1), f = z(
|
|
65
|
+
() => typeof t.item.width == "number" ? `${t.item.width}px` : t.item.width ?? (t.item.itemType.includes("ange") ? "280px" : "200px")
|
|
66
|
+
), c = z(() => {
|
|
67
|
+
var S;
|
|
68
|
+
return {
|
|
69
|
+
// Vue 会合并事件监听器,不能只依赖 v-bind 后面的属性覆盖。
|
|
70
|
+
...Object.fromEntries(
|
|
71
|
+
Object.entries(t.item.controlProps ?? {}).filter(
|
|
72
|
+
([a]) => ![
|
|
73
|
+
"modelValue",
|
|
74
|
+
"model-value",
|
|
75
|
+
"value",
|
|
76
|
+
"defaultValue",
|
|
77
|
+
"onUpdate:modelValue",
|
|
78
|
+
"onUpdate:model-value"
|
|
79
|
+
].includes(a)
|
|
80
|
+
)
|
|
81
|
+
),
|
|
82
|
+
placeholder: t.item.placeholder ?? (typeof ((S = t.item.controlProps) == null ? void 0 : S.placeholder) == "string" ? t.item.controlProps.placeholder : void 0),
|
|
83
|
+
disabled: t.disabled || t.item.disabled,
|
|
84
|
+
clearable: t.item.clearable !== !1,
|
|
85
|
+
"aria-label": t.item.labelName ?? t.item.placeholder ?? r.value,
|
|
86
|
+
"aria-invalid": E.value === "error",
|
|
87
|
+
"aria-describedby": j.value ? d : void 0,
|
|
88
|
+
"aria-required": I.value,
|
|
89
|
+
validateEvent: !1
|
|
90
|
+
};
|
|
91
|
+
}), h = z(() => String(t.formObj[r.value] ?? "")), g = (S) => typeof t.formObj[S ?? ""] == "number" ? t.formObj[S] : void 0, w = z(() => g(r.value)), O = z(
|
|
92
|
+
() => t.formObj[r.value]
|
|
93
|
+
), v = z(
|
|
94
|
+
() => t.formObj[r.value]
|
|
95
|
+
), x = z(
|
|
96
|
+
() => t.item.itemType === "datetimerange" ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD"
|
|
97
|
+
);
|
|
98
|
+
function V(S, a) {
|
|
99
|
+
!t.disabled && !t.item.disabled && (n("change", S, a ?? void 0), oe(() => Y("change")));
|
|
100
|
+
}
|
|
101
|
+
const p = (S) => V(r.value, S), m = (S) => S == null || typeof S == "string" && S.trim() === "" || Array.isArray(S) && (!S.length || S.every(m)), k = z(() => t.item.rules ? Array.isArray(t.item.rules) ? t.item.rules : [t.item.rules] : [
|
|
102
|
+
{
|
|
103
|
+
validator: (S, a, l) => {
|
|
104
|
+
const u = t.item, s = u.itemType === "inputBoxInterval" ? [t.formObj[u.propName1], t.formObj[u.propName2]] : a;
|
|
105
|
+
if (u.isRequired && m(s))
|
|
106
|
+
return l(new Error(`${u.labelName ?? r.value}不能为空`));
|
|
107
|
+
if (["inputBoxInterval", "dateRange", "datetimerange"].includes(
|
|
108
|
+
u.itemType
|
|
109
|
+
) && !m(s) && (!Array.isArray(s) || s.length !== 2 || s.some(m)))
|
|
110
|
+
return l(new Error("请完整填写区间两端"));
|
|
111
|
+
if (u.itemType === "inputBoxInterval" && Array.isArray(s) && s.every((y) => typeof y == "number") && s[0] > s[1])
|
|
112
|
+
return l(new Error("下限不能大于上限"));
|
|
113
|
+
l();
|
|
114
|
+
},
|
|
115
|
+
trigger: "change"
|
|
116
|
+
}
|
|
117
|
+
]), E = F(""), j = F(""), I = z(
|
|
118
|
+
() => t.item.rules ? k.value.some((S) => S.required) : !!t.item.isRequired
|
|
119
|
+
);
|
|
120
|
+
let H = 0, M = !1;
|
|
121
|
+
function K() {
|
|
122
|
+
H++, E.value = "", j.value = "";
|
|
123
|
+
}
|
|
124
|
+
G(
|
|
125
|
+
() => [
|
|
126
|
+
t.item,
|
|
127
|
+
...ee(t.item).map((S) => t.formObj[S])
|
|
128
|
+
],
|
|
129
|
+
K,
|
|
130
|
+
{ deep: !0, flush: "sync" }
|
|
131
|
+
);
|
|
132
|
+
async function Y(S = "") {
|
|
133
|
+
var u;
|
|
134
|
+
const a = k.value.filter(
|
|
135
|
+
(s) => !S || !s.trigger || (Array.isArray(s.trigger) ? s.trigger.includes(S) : s.trigger === S)
|
|
136
|
+
);
|
|
137
|
+
if (M || !a.length) return [];
|
|
138
|
+
const l = ++H;
|
|
139
|
+
E.value = "validating";
|
|
140
|
+
try {
|
|
141
|
+
return await new Je({ [r.value]: a }).validate(
|
|
142
|
+
L(t.formObj),
|
|
143
|
+
{ firstFields: !0, suppressValidatorError: !0 }
|
|
144
|
+
), !M && l === H && (E.value = "success", j.value = ""), [];
|
|
145
|
+
} catch (s) {
|
|
146
|
+
if (M || l !== H) return [];
|
|
147
|
+
const y = s && typeof s == "object" && "errors" in s && Array.isArray(s.errors) ? s.errors : [
|
|
148
|
+
{
|
|
149
|
+
field: r.value,
|
|
150
|
+
message: s instanceof Error ? s.message : "校验失败"
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
return E.value = "error", j.value = ((u = y[0]) == null ? void 0 : u.message) ?? "校验失败", y;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return ne(() => {
|
|
157
|
+
M = !0, K();
|
|
158
|
+
}), i({ validate: Y, clearValidate: K }), (S, a) => (b(), B(C(Ve), {
|
|
159
|
+
label: e.item.labelName,
|
|
160
|
+
"label-width": e.item.labelWidth,
|
|
161
|
+
prop: r.value,
|
|
162
|
+
"validate-status": E.value,
|
|
163
|
+
"show-message": !1,
|
|
164
|
+
class: fe({ "is-required": I.value })
|
|
165
|
+
}, {
|
|
166
|
+
default: D(() => [
|
|
167
|
+
J("div", {
|
|
168
|
+
class: "ai-code-search-form__control",
|
|
169
|
+
style: me({ width: f.value }),
|
|
170
|
+
onFocusout: a[2] || (a[2] = (l) => Y("blur"))
|
|
171
|
+
}, [
|
|
172
|
+
T(S.$slots, "default", {
|
|
173
|
+
form: e.formObj,
|
|
174
|
+
item: e.item,
|
|
175
|
+
value: e.formObj[r.value],
|
|
176
|
+
updateValue: p,
|
|
177
|
+
change: V
|
|
178
|
+
}, () => [
|
|
179
|
+
e.item.itemType === "text" ? (b(), B(C(Ae), Q({ key: 0 }, c.value, {
|
|
180
|
+
"model-value": h.value,
|
|
181
|
+
"onUpdate:modelValue": p
|
|
182
|
+
}), null, 16, ["model-value"])) : e.item.itemType === "number" ? (b(), B(C(ce), Q({ key: 1 }, c.value, {
|
|
183
|
+
"model-value": w.value,
|
|
184
|
+
min: e.item.min,
|
|
185
|
+
max: e.item.max,
|
|
186
|
+
precision: e.item.precision,
|
|
187
|
+
step: e.item.step,
|
|
188
|
+
"onUpdate:modelValue": p
|
|
189
|
+
}), null, 16, ["model-value", "min", "max", "precision", "step"])) : e.item.itemType === "selectOne" ? (b(), B(C(Ne), Q({ key: 2 }, c.value, {
|
|
190
|
+
"model-value": O.value,
|
|
191
|
+
multiple: e.item.multiple,
|
|
192
|
+
filterable: e.item.filterable,
|
|
193
|
+
loading: e.item.loading,
|
|
194
|
+
remote: e.item.remote,
|
|
195
|
+
"remote-method": (l) => {
|
|
196
|
+
var u, s;
|
|
197
|
+
return (s = (u = e.item).remoteMethod) == null ? void 0 : s.call(u, l, e.formObj[r.value]);
|
|
198
|
+
},
|
|
199
|
+
"onUpdate:modelValue": p
|
|
200
|
+
}), {
|
|
201
|
+
default: D(() => [
|
|
202
|
+
(b(!0), A(te, null, ae(e.item.optionsArr, (l) => (b(), B(C(Te), {
|
|
203
|
+
key: `${typeof l.value}:${l.value}`,
|
|
204
|
+
value: l.value,
|
|
205
|
+
label: l.label,
|
|
206
|
+
disabled: l.disabled
|
|
207
|
+
}, null, 8, ["value", "label", "disabled"]))), 128))
|
|
208
|
+
]),
|
|
209
|
+
_: 1
|
|
210
|
+
}, 16, ["model-value", "multiple", "filterable", "loading", "remote", "remote-method"])) : ["date", "dateRange", "datetimerange"].includes(e.item.itemType) ? (b(), B(C(Fe), Q({ key: 3 }, c.value, {
|
|
211
|
+
"model-value": v.value,
|
|
212
|
+
type: e.item.itemType === "dateRange" ? "daterange" : e.item.itemType === "datetimerange" ? "datetimerange" : "date",
|
|
213
|
+
format: e.item.format ?? x.value,
|
|
214
|
+
"value-format": e.item.valueFormat ?? x.value,
|
|
215
|
+
"onUpdate:modelValue": p
|
|
216
|
+
}), null, 16, ["model-value", "type", "format", "value-format"])) : e.item.itemType === "inputBoxInterval" ? (b(), A("div", tt, [
|
|
217
|
+
U(C(ce), Q({
|
|
218
|
+
...c.value,
|
|
219
|
+
"aria-label": `${e.item.labelName ?? "区间"} 下限`
|
|
220
|
+
}, {
|
|
221
|
+
"model-value": g(e.item.propName1),
|
|
222
|
+
min: e.item.min,
|
|
223
|
+
max: e.item.max,
|
|
224
|
+
precision: e.item.precision,
|
|
225
|
+
"onUpdate:modelValue": a[0] || (a[0] = (l) => V(e.item.propName1, l))
|
|
226
|
+
}), null, 16, ["model-value", "min", "max", "precision"]),
|
|
227
|
+
a[3] || (a[3] = J("span", null, "~", -1)),
|
|
228
|
+
U(C(ce), Q({
|
|
229
|
+
...c.value,
|
|
230
|
+
"aria-label": `${e.item.labelName ?? "区间"} 上限`
|
|
231
|
+
}, {
|
|
232
|
+
"model-value": g(e.item.propName2),
|
|
233
|
+
min: e.item.min,
|
|
234
|
+
max: e.item.max,
|
|
235
|
+
precision: e.item.precision,
|
|
236
|
+
"onUpdate:modelValue": a[1] || (a[1] = (l) => V(e.item.propName2, l))
|
|
237
|
+
}), null, 16, ["model-value", "min", "max", "precision"])
|
|
238
|
+
])) : N("", !0)
|
|
239
|
+
]),
|
|
240
|
+
j.value ? (b(), A("div", {
|
|
241
|
+
key: 0,
|
|
242
|
+
id: d,
|
|
243
|
+
class: "el-form-item__error",
|
|
244
|
+
role: "alert"
|
|
245
|
+
}, P(j.value), 1)) : N("", !0)
|
|
246
|
+
], 36)
|
|
247
|
+
]),
|
|
248
|
+
_: 3
|
|
249
|
+
}, 8, ["label", "label-width", "prop", "validate-status", "class"]));
|
|
250
|
+
}
|
|
251
|
+
}), lt = { class: "ai-code-search-form__fields" }, ot = { class: "ai-code-search-form__actions" }, Dt = /* @__PURE__ */ Z({
|
|
252
|
+
__name: "index",
|
|
253
|
+
props: {
|
|
254
|
+
formHeader: {},
|
|
255
|
+
formModel: {},
|
|
256
|
+
disabled: { type: Boolean },
|
|
257
|
+
loading: { type: Boolean },
|
|
258
|
+
showButton: { type: Boolean, default: !0 },
|
|
259
|
+
isShowReset: { type: Boolean, default: !0 },
|
|
260
|
+
labelPosition: { default: "left" },
|
|
261
|
+
labelWidth: {}
|
|
262
|
+
},
|
|
263
|
+
emits: ["submitForm", "resetForm", "formChange"],
|
|
264
|
+
setup(e, { expose: i, emit: o }) {
|
|
265
|
+
const t = e, n = o, d = F(), r = F({}), f = /* @__PURE__ */ new Map();
|
|
266
|
+
function c(a, l) {
|
|
267
|
+
for (const u of ee(a))
|
|
268
|
+
l && "validate" in l ? f.set(u, l) : f.delete(u);
|
|
269
|
+
}
|
|
270
|
+
const h = (a) => {
|
|
271
|
+
const u = (a === void 0 || Array.isArray(a) && !a.length ? x.value : Array.isArray(a) ? a : [a]).map(
|
|
272
|
+
(s) => Array.isArray(s) ? s.join(".") : s
|
|
273
|
+
);
|
|
274
|
+
return [
|
|
275
|
+
...new Set(
|
|
276
|
+
u.map((s) => f.get(s)).filter((s) => !!s)
|
|
277
|
+
)
|
|
278
|
+
];
|
|
279
|
+
}, g = (a) => {
|
|
280
|
+
h(a).forEach((l) => l.clearValidate());
|
|
281
|
+
}, w = async (a, l) => {
|
|
282
|
+
const u = E, s = await Promise.all(
|
|
283
|
+
h(a).map((R) => R.validate())
|
|
284
|
+
);
|
|
285
|
+
if (j || u !== E) return !1;
|
|
286
|
+
const y = {};
|
|
287
|
+
for (const R of s)
|
|
288
|
+
for (const ye of R) {
|
|
289
|
+
const de = ye.field ?? "";
|
|
290
|
+
(y[de] ?? (y[de] = [])).push(ye);
|
|
291
|
+
}
|
|
292
|
+
const $ = !Object.keys(y).length;
|
|
293
|
+
if (l)
|
|
294
|
+
return await l($, $ ? void 0 : y), $;
|
|
295
|
+
if (!$) throw y;
|
|
296
|
+
return !0;
|
|
297
|
+
}, O = (a) => w(void 0, a), v = z(() => t.formHeader), x = z(() => v.value.flatMap(ee)), V = /* @__PURE__ */ new Map();
|
|
298
|
+
let p = /* @__PURE__ */ new Map(), m, k = {}, E = 0, j = !1;
|
|
299
|
+
const I = F(!1), H = () => {
|
|
300
|
+
E++, I.value = !1;
|
|
301
|
+
}, M = () => Object.fromEntries(
|
|
302
|
+
x.value.map((a) => [a, L(r.value[a])])
|
|
303
|
+
);
|
|
304
|
+
G(
|
|
305
|
+
() => t.formModel,
|
|
306
|
+
(a) => {
|
|
307
|
+
const l = a ?? {};
|
|
308
|
+
for (const u of x.value)
|
|
309
|
+
(a !== m || !he(l[u], k[u])) && (r.value[u] = L(l[u]));
|
|
310
|
+
m = a, k = L(l), H();
|
|
311
|
+
},
|
|
312
|
+
{ immediate: !0, deep: !0, flush: "sync" }
|
|
313
|
+
), G(
|
|
314
|
+
v,
|
|
315
|
+
(a) => {
|
|
316
|
+
var u;
|
|
317
|
+
const l = /* @__PURE__ */ new Map();
|
|
318
|
+
for (const s of a)
|
|
319
|
+
for (const y of ee(s)) {
|
|
320
|
+
if (!y || l.has(y))
|
|
321
|
+
throw new Error(`SearchForm 字段必须有唯一名称:${y}`);
|
|
322
|
+
if (l.set(y, s.itemType), p.get(y) !== s.itemType) {
|
|
323
|
+
const $ = L(
|
|
324
|
+
(u = t.formModel) == null ? void 0 : u[y]
|
|
325
|
+
);
|
|
326
|
+
V.set(y, L($)), r.value[y] = $;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (const s of p.keys())
|
|
330
|
+
l.has(s) || (delete r.value[s], V.delete(s));
|
|
331
|
+
p = l, H(), g();
|
|
332
|
+
},
|
|
333
|
+
{ immediate: !0, deep: !0, flush: "sync" }
|
|
334
|
+
), G(
|
|
335
|
+
r,
|
|
336
|
+
() => {
|
|
337
|
+
H(), n("formChange", M());
|
|
338
|
+
},
|
|
339
|
+
{ deep: !0, flush: "sync" }
|
|
340
|
+
);
|
|
341
|
+
function K(a, l) {
|
|
342
|
+
!t.disabled && x.value.includes(a) && (r.value[a] = L(l));
|
|
343
|
+
}
|
|
344
|
+
async function Y() {
|
|
345
|
+
var l, u, s, y;
|
|
346
|
+
if (!d.value || t.disabled || t.loading || I.value || j)
|
|
347
|
+
return !1;
|
|
348
|
+
const a = ++E;
|
|
349
|
+
I.value = !0;
|
|
350
|
+
try {
|
|
351
|
+
try {
|
|
352
|
+
if (!await O()) return !1;
|
|
353
|
+
} catch ($) {
|
|
354
|
+
if (a === E && !j && $ && typeof $ == "object") {
|
|
355
|
+
const R = Object.keys($)[0];
|
|
356
|
+
R && (d.value.scrollToField(R), await oe(), a === E && !j && ((y = (s = (u = (l = d.value) == null ? void 0 : l.getField(R)) == null ? void 0 : u.$el) == null ? void 0 : s.querySelector(
|
|
357
|
+
'input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]'
|
|
358
|
+
)) == null || y.focus()));
|
|
359
|
+
}
|
|
360
|
+
return !1;
|
|
361
|
+
}
|
|
362
|
+
return j || a !== E || t.disabled || t.loading ? !1 : (n("submitForm", M()), !0);
|
|
363
|
+
} finally {
|
|
364
|
+
a === E && (I.value = !1);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function S() {
|
|
368
|
+
if (!t.disabled) {
|
|
369
|
+
H();
|
|
370
|
+
for (const a of x.value) r.value[a] = L(V.get(a));
|
|
371
|
+
g(), n("resetForm", M()), oe(() => g());
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return ne(() => {
|
|
375
|
+
j = !0, H();
|
|
376
|
+
}), i({
|
|
377
|
+
submitForm: Y,
|
|
378
|
+
resetForm: S,
|
|
379
|
+
getFormData: M,
|
|
380
|
+
validate: O,
|
|
381
|
+
validateField: w,
|
|
382
|
+
clearValidate: g
|
|
383
|
+
}), (a, l) => (b(), A("div", {
|
|
384
|
+
onSubmit: Se(Y, ["prevent", "stop"])
|
|
385
|
+
}, [
|
|
386
|
+
U(C(Pe), {
|
|
387
|
+
ref_key: "form",
|
|
388
|
+
ref: d,
|
|
389
|
+
class: "ai-code-search-form",
|
|
390
|
+
model: r.value,
|
|
391
|
+
disabled: e.disabled,
|
|
392
|
+
"label-position": e.labelPosition,
|
|
393
|
+
"label-width": e.labelWidth
|
|
394
|
+
}, {
|
|
395
|
+
default: D(() => [
|
|
396
|
+
J("div", lt, [
|
|
397
|
+
(b(!0), A(te, null, ae(v.value, (u) => (b(), B(at, {
|
|
398
|
+
key: C(ee)(u).join(":"),
|
|
399
|
+
ref_for: !0,
|
|
400
|
+
ref: (s) => c(u, s),
|
|
401
|
+
item: u,
|
|
402
|
+
"form-obj": r.value,
|
|
403
|
+
disabled: e.disabled,
|
|
404
|
+
onChange: K
|
|
405
|
+
}, pe({ _: 2 }, [
|
|
406
|
+
a.$slots[u.slotName ?? u.propName ?? ""] ? {
|
|
407
|
+
name: "default",
|
|
408
|
+
fn: D((s) => [
|
|
409
|
+
T(a.$slots, u.slotName ?? u.propName, Q({ ref_for: !0 }, s))
|
|
410
|
+
]),
|
|
411
|
+
key: "0"
|
|
412
|
+
} : void 0
|
|
413
|
+
]), 1032, ["item", "form-obj", "disabled"]))), 128)),
|
|
414
|
+
J("div", ot, [
|
|
415
|
+
T(a.$slots, "actions", {
|
|
416
|
+
submit: Y,
|
|
417
|
+
reset: S,
|
|
418
|
+
form: M(),
|
|
419
|
+
busy: e.loading || I.value
|
|
420
|
+
}, () => [
|
|
421
|
+
e.showButton ? (b(), B(C(_), {
|
|
422
|
+
key: 0,
|
|
423
|
+
"native-type": "submit",
|
|
424
|
+
type: "primary",
|
|
425
|
+
loading: e.loading || I.value
|
|
426
|
+
}, {
|
|
427
|
+
default: D(() => [...l[0] || (l[0] = [
|
|
428
|
+
q(" 搜索 ", -1)
|
|
429
|
+
])]),
|
|
430
|
+
_: 1
|
|
431
|
+
}, 8, ["loading"])) : N("", !0),
|
|
432
|
+
e.showButton && e.isShowReset ? (b(), B(C(_), {
|
|
433
|
+
key: 1,
|
|
434
|
+
"native-type": "button",
|
|
435
|
+
onClick: S
|
|
436
|
+
}, {
|
|
437
|
+
default: D(() => [...l[1] || (l[1] = [
|
|
438
|
+
q(" 重置 ", -1)
|
|
439
|
+
])]),
|
|
440
|
+
_: 1
|
|
441
|
+
})) : N("", !0)
|
|
442
|
+
]),
|
|
443
|
+
T(a.$slots, "actions-extra", {
|
|
444
|
+
form: M()
|
|
445
|
+
})
|
|
446
|
+
])
|
|
447
|
+
])
|
|
448
|
+
]),
|
|
449
|
+
_: 3
|
|
450
|
+
}, 8, ["model", "disabled", "label-position", "label-width"])
|
|
451
|
+
], 32));
|
|
452
|
+
}
|
|
453
|
+
}), rt = { key: 3 }, nt = /* @__PURE__ */ Z({
|
|
454
|
+
__name: "TableCell",
|
|
455
|
+
props: {
|
|
456
|
+
row: {},
|
|
457
|
+
column: {},
|
|
458
|
+
index: {}
|
|
459
|
+
},
|
|
460
|
+
setup(e) {
|
|
461
|
+
const i = e, o = z(() => {
|
|
462
|
+
const { row: f, column: c } = i;
|
|
463
|
+
return String(
|
|
464
|
+
(c.formatter ? c.formatter(f, c) : f[c.prop]) ?? ""
|
|
465
|
+
);
|
|
466
|
+
}), t = () => {
|
|
467
|
+
var f, c;
|
|
468
|
+
return (c = (f = i.column).render) == null ? void 0 : c.call(f, X, {
|
|
469
|
+
row: i.row,
|
|
470
|
+
column: i.column,
|
|
471
|
+
index: i.index
|
|
472
|
+
});
|
|
473
|
+
}, n = F(), d = F(!1), r = () => {
|
|
474
|
+
const f = n.value;
|
|
475
|
+
d.value = f ? f.scrollHeight > f.clientHeight || f.scrollWidth > f.clientWidth : !1;
|
|
476
|
+
};
|
|
477
|
+
return G([o, () => i.column.lineClamp], r, { flush: "post" }), G(
|
|
478
|
+
n,
|
|
479
|
+
(f, c, h) => {
|
|
480
|
+
if (r(), !f || typeof ResizeObserver > "u")
|
|
481
|
+
return;
|
|
482
|
+
const g = new ResizeObserver(r);
|
|
483
|
+
g.observe(f), h(() => g.disconnect());
|
|
484
|
+
},
|
|
485
|
+
{ flush: "post" }
|
|
486
|
+
), (f, c) => e.column.render ? (b(), B(t, { key: 0 })) : e.column.lineClamp ? (b(), B(C(Me), {
|
|
487
|
+
key: 1,
|
|
488
|
+
content: o.value,
|
|
489
|
+
disabled: !d.value,
|
|
490
|
+
trigger: ["hover", "focus"],
|
|
491
|
+
"trigger-keys": []
|
|
492
|
+
}, {
|
|
493
|
+
default: D(() => [
|
|
494
|
+
(b(), B(ke(e.column.click ? "button" : "span"), {
|
|
495
|
+
ref_key: "textRef",
|
|
496
|
+
ref: n,
|
|
497
|
+
class: fe(["table-cell__clamp", { "table-cell__link": e.column.click }]),
|
|
498
|
+
style: me({ "-webkit-line-clamp": e.column.lineClamp }),
|
|
499
|
+
tabindex: d.value ? 0 : null,
|
|
500
|
+
type: e.column.click ? "button" : null,
|
|
501
|
+
onClick: c[0] || (c[0] = (h) => {
|
|
502
|
+
var g, w;
|
|
503
|
+
return (w = (g = e.column).click) == null ? void 0 : w.call(g, e.row);
|
|
504
|
+
}),
|
|
505
|
+
onFocusin: r,
|
|
506
|
+
onMouseenter: r
|
|
507
|
+
}, {
|
|
508
|
+
default: D(() => [
|
|
509
|
+
q(P(o.value), 1)
|
|
510
|
+
]),
|
|
511
|
+
_: 1
|
|
512
|
+
}, 40, ["class", "style", "tabindex", "type"]))
|
|
513
|
+
]),
|
|
514
|
+
_: 1
|
|
515
|
+
}, 8, ["content", "disabled"])) : e.column.click ? (b(), A("button", {
|
|
516
|
+
key: 2,
|
|
517
|
+
class: "table-cell__link",
|
|
518
|
+
type: "button",
|
|
519
|
+
onClick: c[1] || (c[1] = (h) => {
|
|
520
|
+
var g, w;
|
|
521
|
+
return (w = (g = e.column).click) == null ? void 0 : w.call(g, e.row);
|
|
522
|
+
})
|
|
523
|
+
}, P(o.value), 1)) : (b(), A("span", rt, P(o.value), 1));
|
|
524
|
+
}
|
|
525
|
+
}), it = /* @__PURE__ */ ie(nt, [["__scopeId", "data-v-bba66ae0"]]), st = {
|
|
526
|
+
key: 0,
|
|
527
|
+
class: "ai-code-table__toolbar"
|
|
528
|
+
}, ut = { key: 0 }, dt = {
|
|
529
|
+
key: 1,
|
|
530
|
+
class: "ai-code-table__pagination"
|
|
531
|
+
}, ct = /* @__PURE__ */ Z({
|
|
532
|
+
inheritAttrs: !1,
|
|
533
|
+
__name: "index",
|
|
534
|
+
props: {
|
|
535
|
+
tableData: {},
|
|
536
|
+
tableColumns: {},
|
|
537
|
+
pageParams: {},
|
|
538
|
+
loading: { type: Boolean, default: !1 },
|
|
539
|
+
border: { type: Boolean, default: !0 },
|
|
540
|
+
stripe: { type: Boolean, default: !0 },
|
|
541
|
+
showHeader: { type: Boolean, default: !0 },
|
|
542
|
+
showSerialNumber: { type: Boolean, default: !0 },
|
|
543
|
+
serialNumberFixed: { type: Boolean, default: !0 },
|
|
544
|
+
selection: { type: Boolean },
|
|
545
|
+
selectionFixed: { type: Boolean },
|
|
546
|
+
reserveSelection: { type: Boolean },
|
|
547
|
+
showColumnSettings: { type: Boolean, default: !0 },
|
|
548
|
+
rowKey: {},
|
|
549
|
+
selectFn: {},
|
|
550
|
+
resizable: { type: Boolean, default: !0 },
|
|
551
|
+
tableHeight: { default: "auto" },
|
|
552
|
+
maxHeight: {},
|
|
553
|
+
rowheight: {},
|
|
554
|
+
minHeight: {},
|
|
555
|
+
noDataShow: { default: "暂无查询结果" },
|
|
556
|
+
paginationLayout: { default: "total,prev,pager,next,jumper,sizes" }
|
|
557
|
+
},
|
|
558
|
+
emits: ["handleSizeChange", "handleCurrentChange", "handleSelectionChange", "handleSortChange"],
|
|
559
|
+
setup(e, { expose: i, emit: o }) {
|
|
560
|
+
const t = Re.directive, n = e, d = o, r = xe(), f = () => Object.fromEntries(
|
|
561
|
+
Object.entries(r).filter(([a]) => a !== "class" && a !== "style")
|
|
562
|
+
), c = ge(), h = re({ ...c });
|
|
563
|
+
Oe(() => {
|
|
564
|
+
h.value = { ...c };
|
|
565
|
+
});
|
|
566
|
+
const g = ({ column: a, index: l }) => T(
|
|
567
|
+
h.value,
|
|
568
|
+
`header-${a.prop}`,
|
|
569
|
+
{ column: a, index: l },
|
|
570
|
+
() => [X("span", a.label)]
|
|
571
|
+
), w = F(), O = z(
|
|
572
|
+
() => typeof n.rowKey == "function" ? (a) => String(n.rowKey(a)) : n.rowKey
|
|
573
|
+
), v = (a) => {
|
|
574
|
+
const l = r["row-style"] ?? r.rowStyle;
|
|
575
|
+
return {
|
|
576
|
+
...typeof l == "function" ? l(a) : l,
|
|
577
|
+
...n.rowheight ? { height: n.rowheight } : {}
|
|
578
|
+
};
|
|
579
|
+
}, x = F([]), V = z(() => {
|
|
580
|
+
const a = new Set(x.value);
|
|
581
|
+
return n.tableColumns.filter(
|
|
582
|
+
(l) => l.hideable === !1 || a.has(l.prop)
|
|
583
|
+
);
|
|
584
|
+
}), p = z(() => {
|
|
585
|
+
const a = [];
|
|
586
|
+
n.tableColumns.forEach((u) => {
|
|
587
|
+
var R;
|
|
588
|
+
const s = ((R = u.group) == null ? void 0 : R.trim()) ?? "", y = u.fixed === !0 ? "left" : u.fixed || !1, $ = a[a.length - 1];
|
|
589
|
+
s && ($ == null ? void 0 : $.label) === s && $.fixed === y ? $.columns.push(u) : a.push({ key: u.prop, label: s, fixed: y, columns: [u] });
|
|
590
|
+
});
|
|
591
|
+
const l = new Set(
|
|
592
|
+
V.value.map((u) => u.prop)
|
|
593
|
+
);
|
|
594
|
+
return a.map((u) => ({
|
|
595
|
+
...u,
|
|
596
|
+
columns: u.columns.filter((s) => l.has(s.prop))
|
|
597
|
+
})).filter((u) => u.columns.length > 0);
|
|
598
|
+
}), m = ({ group: a }, { slots: l }) => {
|
|
599
|
+
var u;
|
|
600
|
+
return a.label ? X(
|
|
601
|
+
se,
|
|
602
|
+
{ label: a.label, fixed: a.fixed, headerAlign: "center" },
|
|
603
|
+
l
|
|
604
|
+
) : (u = l.default) == null ? void 0 : u.call(l);
|
|
605
|
+
};
|
|
606
|
+
G(
|
|
607
|
+
() => n.tableColumns.map(({ prop: a, showColumn: l, hideable: u }) => ({
|
|
608
|
+
prop: a,
|
|
609
|
+
visible: u === !1 || l !== !1,
|
|
610
|
+
required: u === !1
|
|
611
|
+
})),
|
|
612
|
+
(a, l = []) => {
|
|
613
|
+
const u = new Map(
|
|
614
|
+
l.map((y) => [y.prop, y.visible])
|
|
615
|
+
), s = new Set(x.value);
|
|
616
|
+
x.value = a.filter((y) => y.required || (u.get(y.prop) === y.visible ? s.has(y.prop) : y.visible)).map((y) => y.prop);
|
|
617
|
+
},
|
|
618
|
+
{ immediate: !0 }
|
|
619
|
+
);
|
|
620
|
+
const k = z(() => {
|
|
621
|
+
var a, l, u, s, y, $, R;
|
|
622
|
+
return {
|
|
623
|
+
page: ((a = n.pageParams) == null ? void 0 : a.currentPage) ?? ((l = n.pageParams) == null ? void 0 : l.page) ?? 1,
|
|
624
|
+
page_size: ((u = n.pageParams) == null ? void 0 : u.pageSize) ?? ((s = n.pageParams) == null ? void 0 : s.page_size) ?? 10,
|
|
625
|
+
page_sizes: ((y = n.pageParams) == null ? void 0 : y.pageSizes) ?? (($ = n.pageParams) == null ? void 0 : $.page_sizes) ?? [10, 20, 50],
|
|
626
|
+
total: ((R = n.pageParams) == null ? void 0 : R.total) ?? 0
|
|
627
|
+
};
|
|
628
|
+
}), E = (a) => (k.value.page - 1) * k.value.page_size + a + 1;
|
|
629
|
+
let j = !1, I = !1;
|
|
630
|
+
const H = (a) => {
|
|
631
|
+
j = !0, d("handleSizeChange", { pageSize: a }), oe(() => {
|
|
632
|
+
j = !1;
|
|
633
|
+
});
|
|
634
|
+
}, M = (a) => {
|
|
635
|
+
j || oe(() => {
|
|
636
|
+
!j && !I && a !== k.value.page && d("handleCurrentChange", { pageNum: a });
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
ne(() => {
|
|
640
|
+
I = !0;
|
|
641
|
+
});
|
|
642
|
+
const K = re([]), Y = (a) => {
|
|
643
|
+
K.value = a, d("handleSelectionChange", a);
|
|
644
|
+
}, S = ({ prop: a, order: l }) => d("handleSortChange", { prop: a, order: l });
|
|
645
|
+
return i({
|
|
646
|
+
clearSort: () => {
|
|
647
|
+
var a;
|
|
648
|
+
return (a = w.value) == null ? void 0 : a.clearSort();
|
|
649
|
+
},
|
|
650
|
+
sort: (...a) => {
|
|
651
|
+
var l;
|
|
652
|
+
return (l = w.value) == null ? void 0 : l.sort(...a);
|
|
653
|
+
},
|
|
654
|
+
doLayout: () => {
|
|
655
|
+
var a;
|
|
656
|
+
return (a = w.value) == null ? void 0 : a.doLayout();
|
|
657
|
+
},
|
|
658
|
+
clearSelection: () => {
|
|
659
|
+
var a;
|
|
660
|
+
return (a = w.value) == null ? void 0 : a.clearSelection();
|
|
661
|
+
},
|
|
662
|
+
getSelectionRows: () => {
|
|
663
|
+
var a;
|
|
664
|
+
return ((a = w.value) == null ? void 0 : a.getSelectionRows()) ?? [];
|
|
665
|
+
},
|
|
666
|
+
toggleRowSelection: (...a) => {
|
|
667
|
+
var l;
|
|
668
|
+
return (l = w.value) == null ? void 0 : l.toggleRowSelection(...a);
|
|
669
|
+
}
|
|
670
|
+
}), (a, l) => (b(), A("div", {
|
|
671
|
+
class: fe(["ai-code-table", C(r).class]),
|
|
672
|
+
style: me(C(r).style)
|
|
673
|
+
}, [
|
|
674
|
+
e.showColumnSettings || a.$slots.toolbar || a.$slots["multiple-operation"] ? (b(), A("div", st, [
|
|
675
|
+
e.selection ? (b(), A("span", ut, [
|
|
676
|
+
l[1] || (l[1] = q("已选 ", -1)),
|
|
677
|
+
J("strong", null, P(K.value.length), 1),
|
|
678
|
+
l[2] || (l[2] = q(" 个条目", -1))
|
|
679
|
+
])) : N("", !0),
|
|
680
|
+
T(a.$slots, "toolbar", {}, void 0, !0),
|
|
681
|
+
T(a.$slots, "multiple-operation", { selectionData: K.value }, void 0, !0),
|
|
682
|
+
e.showColumnSettings ? (b(), B(C(Ie), {
|
|
683
|
+
key: 1,
|
|
684
|
+
placement: "bottom-end",
|
|
685
|
+
trigger: "click",
|
|
686
|
+
width: 220
|
|
687
|
+
}, {
|
|
688
|
+
reference: D(() => [
|
|
689
|
+
U(C(_), Ee(De({ size: "default", "aria-label": "设置显示列" })), {
|
|
690
|
+
default: D(() => [...l[3] || (l[3] = [
|
|
691
|
+
q("列设置", -1)
|
|
692
|
+
])]),
|
|
693
|
+
_: 1
|
|
694
|
+
}, 16)
|
|
695
|
+
]),
|
|
696
|
+
default: D(() => [
|
|
697
|
+
l[4] || (l[4] = J("p", null, "显示列", -1)),
|
|
698
|
+
U(C(He), {
|
|
699
|
+
modelValue: x.value,
|
|
700
|
+
"onUpdate:modelValue": l[0] || (l[0] = (u) => x.value = u),
|
|
701
|
+
class: "ai-code-table__column-list"
|
|
702
|
+
}, {
|
|
703
|
+
default: D(() => [
|
|
704
|
+
(b(!0), A(te, null, ae(e.tableColumns, (u) => (b(), B(C(qe), {
|
|
705
|
+
key: u.prop,
|
|
706
|
+
value: u.prop,
|
|
707
|
+
disabled: u.hideable === !1
|
|
708
|
+
}, {
|
|
709
|
+
default: D(() => [
|
|
710
|
+
q(P(u.label), 1)
|
|
711
|
+
]),
|
|
712
|
+
_: 2
|
|
713
|
+
}, 1032, ["value", "disabled"]))), 128))
|
|
714
|
+
]),
|
|
715
|
+
_: 1
|
|
716
|
+
}, 8, ["modelValue"])
|
|
717
|
+
]),
|
|
718
|
+
_: 1
|
|
719
|
+
})) : N("", !0)
|
|
720
|
+
])) : N("", !0),
|
|
721
|
+
ze((b(), B(C(Le), Q({
|
|
722
|
+
ref_key: "tableRef",
|
|
723
|
+
ref: w
|
|
724
|
+
}, f(), {
|
|
725
|
+
border: e.border,
|
|
726
|
+
data: e.tableData,
|
|
727
|
+
height: e.tableHeight,
|
|
728
|
+
"max-height": e.maxHeight,
|
|
729
|
+
"row-key": O.value,
|
|
730
|
+
"row-style": v,
|
|
731
|
+
"show-header": e.showHeader,
|
|
732
|
+
stripe: e.stripe,
|
|
733
|
+
style: { minHeight: e.minHeight },
|
|
734
|
+
onSelectionChange: Y,
|
|
735
|
+
onSortChange: S
|
|
736
|
+
}), {
|
|
737
|
+
empty: D(() => [
|
|
738
|
+
T(a.$slots, "empty", {}, () => [
|
|
739
|
+
U(C(Ue), {
|
|
740
|
+
description: e.noDataShow,
|
|
741
|
+
"image-size": 96
|
|
742
|
+
}, null, 8, ["description"])
|
|
743
|
+
], !0)
|
|
744
|
+
]),
|
|
745
|
+
default: D(() => [
|
|
746
|
+
e.selection ? (b(), B(C(se), {
|
|
747
|
+
key: 0,
|
|
748
|
+
align: "center",
|
|
749
|
+
fixed: e.selectionFixed,
|
|
750
|
+
"reserve-selection": e.reserveSelection && !!e.rowKey,
|
|
751
|
+
resizable: e.resizable,
|
|
752
|
+
selectable: e.selectFn,
|
|
753
|
+
type: "selection",
|
|
754
|
+
width: 55
|
|
755
|
+
}, null, 8, ["fixed", "reserve-selection", "resizable", "selectable"])) : N("", !0),
|
|
756
|
+
e.showSerialNumber ? (b(), B(C(se), {
|
|
757
|
+
key: 1,
|
|
758
|
+
align: "center",
|
|
759
|
+
fixed: e.serialNumberFixed,
|
|
760
|
+
index: E,
|
|
761
|
+
label: "序号",
|
|
762
|
+
resizable: e.resizable,
|
|
763
|
+
type: "index",
|
|
764
|
+
width: 60
|
|
765
|
+
}, null, 8, ["fixed", "resizable"])) : N("", !0),
|
|
766
|
+
(b(!0), A(te, null, ae(p.value, (u) => (b(), B(m, {
|
|
767
|
+
key: u.key,
|
|
768
|
+
group: u
|
|
769
|
+
}, {
|
|
770
|
+
default: D(() => [
|
|
771
|
+
(b(!0), A(te, null, ae(u.columns, (s) => (b(), B(C(se), {
|
|
772
|
+
key: s.prop,
|
|
773
|
+
align: s.align || "center",
|
|
774
|
+
"class-name": s.className,
|
|
775
|
+
fixed: s.fixed,
|
|
776
|
+
"header-align": "center",
|
|
777
|
+
label: s.label,
|
|
778
|
+
"min-width": s.minWidth,
|
|
779
|
+
prop: s.prop,
|
|
780
|
+
resizable: e.resizable,
|
|
781
|
+
"show-overflow-tooltip": s.tooltip && !s.lineClamp,
|
|
782
|
+
"sort-orders": s.sortOrders,
|
|
783
|
+
sortable: s.sortable || !1,
|
|
784
|
+
width: s.width
|
|
785
|
+
}, {
|
|
786
|
+
header: D(({ $index: y }) => [
|
|
787
|
+
U(g, {
|
|
788
|
+
column: s,
|
|
789
|
+
index: y
|
|
790
|
+
}, null, 8, ["column", "index"])
|
|
791
|
+
]),
|
|
792
|
+
default: D(({ row: y, $index: $ }) => [
|
|
793
|
+
$ >= 0 ? T(a.$slots, s.prop, {
|
|
794
|
+
key: 0,
|
|
795
|
+
column: s,
|
|
796
|
+
index: $,
|
|
797
|
+
row: y
|
|
798
|
+
}, () => [
|
|
799
|
+
U(it, {
|
|
800
|
+
column: s,
|
|
801
|
+
index: $,
|
|
802
|
+
row: y
|
|
803
|
+
}, null, 8, ["column", "index", "row"])
|
|
804
|
+
], !0) : N("", !0)
|
|
805
|
+
]),
|
|
806
|
+
_: 2
|
|
807
|
+
}, 1032, ["align", "class-name", "fixed", "label", "min-width", "prop", "resizable", "show-overflow-tooltip", "sort-orders", "sortable", "width"]))), 128))
|
|
808
|
+
]),
|
|
809
|
+
_: 2
|
|
810
|
+
}, 1032, ["group"]))), 128))
|
|
811
|
+
]),
|
|
812
|
+
_: 3
|
|
813
|
+
}, 16, ["border", "data", "height", "max-height", "row-key", "show-header", "stripe", "style"])), [
|
|
814
|
+
[C(t), e.loading]
|
|
815
|
+
]),
|
|
816
|
+
k.value.total > 0 ? (b(), A("div", dt, [
|
|
817
|
+
U(C(Ke), {
|
|
818
|
+
background: "",
|
|
819
|
+
"current-page": k.value.page,
|
|
820
|
+
layout: e.paginationLayout,
|
|
821
|
+
"page-size": k.value.page_size,
|
|
822
|
+
"page-sizes": k.value.page_sizes,
|
|
823
|
+
total: k.value.total,
|
|
824
|
+
onCurrentChange: M,
|
|
825
|
+
onSizeChange: H
|
|
826
|
+
}, null, 8, ["current-page", "layout", "page-size", "page-sizes", "total"])
|
|
827
|
+
])) : N("", !0)
|
|
828
|
+
], 6));
|
|
829
|
+
}
|
|
830
|
+
}), zt = /* @__PURE__ */ ie(ct, [["__scopeId", "data-v-e3d6073e"]]), ft = {
|
|
831
|
+
key: 0,
|
|
832
|
+
role: "alert"
|
|
833
|
+
}, mt = {
|
|
834
|
+
key: 1,
|
|
835
|
+
class: "dialog-footer"
|
|
836
|
+
}, gt = /* @__PURE__ */ Z({
|
|
837
|
+
__name: "BaseDialog",
|
|
838
|
+
props: {
|
|
839
|
+
modelValue: Boolean,
|
|
840
|
+
closeOnConfirm: { type: Boolean, default: !0 },
|
|
841
|
+
confirmDisabled: { type: Boolean, default: !1 },
|
|
842
|
+
title: { type: String, default: "" },
|
|
843
|
+
width: { type: [String, Number], default: "50%" },
|
|
844
|
+
closeOnClickModal: { type: Boolean, default: !1 },
|
|
845
|
+
showClose: { type: Boolean, default: !0 },
|
|
846
|
+
destroyOnClose: { type: Boolean, default: !0 },
|
|
847
|
+
cancelText: { type: String, default: "取消" },
|
|
848
|
+
confirmText: { type: String, default: "确定" },
|
|
849
|
+
showCancel: { type: Boolean, default: !0 },
|
|
850
|
+
showConfirm: { type: Boolean, default: !0 },
|
|
851
|
+
onConfirm: Function,
|
|
852
|
+
onCancel: Function,
|
|
853
|
+
onClose: Function
|
|
854
|
+
},
|
|
855
|
+
emits: ["update:modelValue", "error", "closed", "opened"],
|
|
856
|
+
setup(e, { expose: i, emit: o }) {
|
|
857
|
+
const t = e, n = o, d = ge(), r = F(!1), f = F("");
|
|
858
|
+
let c = 0, h = !1;
|
|
859
|
+
G(
|
|
860
|
+
() => t.modelValue,
|
|
861
|
+
(p) => {
|
|
862
|
+
c++, r.value = !1, f.value = "", p && (h = !1);
|
|
863
|
+
}
|
|
864
|
+
), ne(() => {
|
|
865
|
+
c++;
|
|
866
|
+
});
|
|
867
|
+
const g = z({ get: () => t.modelValue, set: (p) => n("update:modelValue", p) });
|
|
868
|
+
function w() {
|
|
869
|
+
var p;
|
|
870
|
+
h || (h = !0, c++, n("update:modelValue", !1), (p = t.onClose) == null || p.call(t));
|
|
871
|
+
}
|
|
872
|
+
async function O() {
|
|
873
|
+
var m;
|
|
874
|
+
if (r.value || h || t.confirmDisabled) return;
|
|
875
|
+
const p = ++c;
|
|
876
|
+
r.value = !0, f.value = "";
|
|
877
|
+
try {
|
|
878
|
+
await ((m = t.onConfirm) == null ? void 0 : m.call(t)), p === c && t.closeOnConfirm && w();
|
|
879
|
+
} catch (k) {
|
|
880
|
+
p === c && (f.value = k instanceof Error ? k.message : "操作失败", n("error", k));
|
|
881
|
+
} finally {
|
|
882
|
+
p === c && (r.value = !1);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function v() {
|
|
886
|
+
var p;
|
|
887
|
+
r.value || ((p = t.onCancel) == null || p.call(t), w());
|
|
888
|
+
}
|
|
889
|
+
function x(p) {
|
|
890
|
+
r.value || (w(), p());
|
|
891
|
+
}
|
|
892
|
+
function V() {
|
|
893
|
+
n("closed");
|
|
894
|
+
}
|
|
895
|
+
return i({ close: w, confirm: O }), (p, m) => (b(), B(C(Ye), {
|
|
896
|
+
modelValue: g.value,
|
|
897
|
+
"onUpdate:modelValue": m[0] || (m[0] = (k) => g.value = k),
|
|
898
|
+
"close-on-click-modal": e.closeOnClickModal && !r.value,
|
|
899
|
+
"destroy-on-close": e.destroyOnClose,
|
|
900
|
+
"show-close": e.showClose && !r.value,
|
|
901
|
+
"close-on-press-escape": !r.value,
|
|
902
|
+
"before-close": x,
|
|
903
|
+
title: e.title,
|
|
904
|
+
width: e.width,
|
|
905
|
+
onClosed: V,
|
|
906
|
+
onOpened: m[1] || (m[1] = (k) => n("opened"))
|
|
907
|
+
}, {
|
|
908
|
+
footer: D(() => [
|
|
909
|
+
C(d).footer ? T(p.$slots, "footer", { key: 0 }, void 0, !0) : (b(), A("span", mt, [
|
|
910
|
+
e.showCancel ? (b(), B(C(_), {
|
|
911
|
+
key: 0,
|
|
912
|
+
disabled: r.value,
|
|
913
|
+
onClick: v
|
|
914
|
+
}, {
|
|
915
|
+
default: D(() => [
|
|
916
|
+
q(P(e.cancelText), 1)
|
|
917
|
+
]),
|
|
918
|
+
_: 1
|
|
919
|
+
}, 8, ["disabled"])) : N("", !0),
|
|
920
|
+
e.showConfirm ? (b(), B(C(_), {
|
|
921
|
+
key: 1,
|
|
922
|
+
loading: r.value,
|
|
923
|
+
disabled: r.value || e.confirmDisabled,
|
|
924
|
+
type: "primary",
|
|
925
|
+
onClick: O
|
|
926
|
+
}, {
|
|
927
|
+
default: D(() => [
|
|
928
|
+
q(P(e.confirmText), 1)
|
|
929
|
+
]),
|
|
930
|
+
_: 1
|
|
931
|
+
}, 8, ["loading", "disabled"])) : N("", !0)
|
|
932
|
+
]))
|
|
933
|
+
]),
|
|
934
|
+
default: D(() => [
|
|
935
|
+
T(p.$slots, "default", {}, void 0, !0),
|
|
936
|
+
f.value ? (b(), A("p", ft, P(f.value), 1)) : N("", !0)
|
|
937
|
+
]),
|
|
938
|
+
_: 3
|
|
939
|
+
}, 8, ["modelValue", "close-on-click-modal", "destroy-on-close", "show-close", "close-on-press-escape", "title", "width"]));
|
|
940
|
+
}
|
|
941
|
+
}), we = /* @__PURE__ */ ie(gt, [["__scopeId", "data-v-2f0ec0cc"]]);
|
|
942
|
+
function vt(e) {
|
|
943
|
+
const i = /* @__PURE__ */ new Set(), o = (n) => {
|
|
944
|
+
const d = Be({
|
|
945
|
+
title: "提示",
|
|
946
|
+
width: "500px",
|
|
947
|
+
...typeof n == "string" ? { content: n } : n
|
|
948
|
+
}), r = F(!0);
|
|
949
|
+
let f = !1, c = !1, h = !1;
|
|
950
|
+
const g = document.createElement("div");
|
|
951
|
+
document.body.appendChild(g);
|
|
952
|
+
const w = () => {
|
|
953
|
+
f || (f = !0, be(null, g), g.remove(), i.delete(v));
|
|
954
|
+
}, O = () => {
|
|
955
|
+
var p;
|
|
956
|
+
if (!(f || c)) {
|
|
957
|
+
c = !0, r.value = !1;
|
|
958
|
+
try {
|
|
959
|
+
(p = d.onClose) == null || p.call(d);
|
|
960
|
+
} finally {
|
|
961
|
+
h || queueMicrotask(w);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}, v = () => {
|
|
965
|
+
try {
|
|
966
|
+
O();
|
|
967
|
+
} finally {
|
|
968
|
+
w();
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
i.add(v);
|
|
972
|
+
const x = Z({
|
|
973
|
+
setup() {
|
|
974
|
+
return () => X(
|
|
975
|
+
we,
|
|
976
|
+
{
|
|
977
|
+
...d,
|
|
978
|
+
modelValue: r.value,
|
|
979
|
+
"onUpdate:modelValue": (p) => {
|
|
980
|
+
p || O();
|
|
981
|
+
},
|
|
982
|
+
onClose: O,
|
|
983
|
+
onClosed: w,
|
|
984
|
+
onOpened: () => {
|
|
985
|
+
h = !0;
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
default: () => typeof d.content == "string" || $e(d.content) ? d.content : d.content ? X(d.content) : null
|
|
990
|
+
}
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
}), V = U(x);
|
|
994
|
+
V.appContext = e;
|
|
995
|
+
try {
|
|
996
|
+
be(V, g);
|
|
997
|
+
} catch (p) {
|
|
998
|
+
throw v(), p;
|
|
999
|
+
}
|
|
1000
|
+
return {
|
|
1001
|
+
close: O,
|
|
1002
|
+
update: (p) => {
|
|
1003
|
+
f || Object.assign(d, p);
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
};
|
|
1007
|
+
return {
|
|
1008
|
+
showDialog: o,
|
|
1009
|
+
Dialog: {
|
|
1010
|
+
alert: (n, d) => o({ content: n, title: d ?? "提示", showCancel: !1 }),
|
|
1011
|
+
confirm: (n, d) => new Promise((r) => {
|
|
1012
|
+
o({
|
|
1013
|
+
content: n,
|
|
1014
|
+
title: d ?? "确认",
|
|
1015
|
+
onConfirm: () => {
|
|
1016
|
+
r(!0);
|
|
1017
|
+
},
|
|
1018
|
+
onClose: () => r(!1)
|
|
1019
|
+
});
|
|
1020
|
+
}),
|
|
1021
|
+
component: (n, d = {}) => o({ content: X(n, d), showCancel: !1, showConfirm: !1 })
|
|
1022
|
+
},
|
|
1023
|
+
dispose: () => {
|
|
1024
|
+
[...i].forEach((n) => n());
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
let le;
|
|
1029
|
+
function ue() {
|
|
1030
|
+
if (!le) throw new Error("请先 app.use(AdminDialog),或使用 createDialogService(appContext)");
|
|
1031
|
+
return le;
|
|
1032
|
+
}
|
|
1033
|
+
const Bt = (e) => ue().showDialog(e), $t = {
|
|
1034
|
+
alert: (e, i) => ue().Dialog.alert(e, i),
|
|
1035
|
+
confirm: (e, i) => ue().Dialog.confirm(e, i),
|
|
1036
|
+
component: (e, i) => ue().Dialog.component(e, i)
|
|
1037
|
+
}, jt = {
|
|
1038
|
+
install(e) {
|
|
1039
|
+
const i = vt(e._context);
|
|
1040
|
+
le = i, e.component("BaseDialog", we), e.provide("dialog", i), e.config.globalProperties.$dialog = i.Dialog;
|
|
1041
|
+
const o = e.unmount.bind(e);
|
|
1042
|
+
e.unmount = () => {
|
|
1043
|
+
i.dispose(), le === i && (le = void 0), o();
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
}, yt = {
|
|
1047
|
+
key: 0,
|
|
1048
|
+
role: "alert"
|
|
1049
|
+
}, bt = {
|
|
1050
|
+
key: 1,
|
|
1051
|
+
class: "drawer-footer"
|
|
1052
|
+
}, pt = /* @__PURE__ */ Z({
|
|
1053
|
+
__name: "BaseDrawer",
|
|
1054
|
+
props: {
|
|
1055
|
+
modelValue: Boolean,
|
|
1056
|
+
title: { type: String, default: "" },
|
|
1057
|
+
size: { type: [String, Number], default: "480px" },
|
|
1058
|
+
direction: { type: String, default: "rtl" },
|
|
1059
|
+
closeOnClickModal: { type: Boolean, default: !1 },
|
|
1060
|
+
showClose: { type: Boolean, default: !0 },
|
|
1061
|
+
destroyOnClose: { type: Boolean, default: !0 },
|
|
1062
|
+
cancelText: { type: String, default: "取消" },
|
|
1063
|
+
confirmText: { type: String, default: "确定" },
|
|
1064
|
+
showCancel: { type: Boolean, default: !1 },
|
|
1065
|
+
showConfirm: { type: Boolean, default: !1 },
|
|
1066
|
+
onConfirm: Function,
|
|
1067
|
+
onCancel: Function,
|
|
1068
|
+
onClose: Function
|
|
1069
|
+
},
|
|
1070
|
+
emits: ["update:modelValue", "error", "closed"],
|
|
1071
|
+
setup(e, { expose: i, emit: o }) {
|
|
1072
|
+
const t = e, n = o, d = ge(), r = F(!1), f = F("");
|
|
1073
|
+
let c = 0, h = !1;
|
|
1074
|
+
G(
|
|
1075
|
+
() => t.modelValue,
|
|
1076
|
+
(m) => {
|
|
1077
|
+
c++, r.value = !1, f.value = "", m && (h = !1);
|
|
1078
|
+
}
|
|
1079
|
+
), ne(() => {
|
|
1080
|
+
c++;
|
|
1081
|
+
});
|
|
1082
|
+
const g = z({ get: () => t.modelValue, set: (m) => n("update:modelValue", m) }), w = z(() => !!d.footer || t.showConfirm || t.showCancel);
|
|
1083
|
+
function O() {
|
|
1084
|
+
var m;
|
|
1085
|
+
h || (h = !0, c++, n("update:modelValue", !1), (m = t.onClose) == null || m.call(t));
|
|
1086
|
+
}
|
|
1087
|
+
async function v() {
|
|
1088
|
+
var k;
|
|
1089
|
+
if (r.value || h) return;
|
|
1090
|
+
const m = ++c;
|
|
1091
|
+
r.value = !0, f.value = "";
|
|
1092
|
+
try {
|
|
1093
|
+
await ((k = t.onConfirm) == null ? void 0 : k.call(t)), m === c && O();
|
|
1094
|
+
} catch (E) {
|
|
1095
|
+
m === c && (f.value = E instanceof Error ? E.message : "操作失败", n("error", E));
|
|
1096
|
+
} finally {
|
|
1097
|
+
m === c && (r.value = !1);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
function x() {
|
|
1101
|
+
var m;
|
|
1102
|
+
r.value || ((m = t.onCancel) == null || m.call(t), O());
|
|
1103
|
+
}
|
|
1104
|
+
function V(m) {
|
|
1105
|
+
r.value || (O(), m());
|
|
1106
|
+
}
|
|
1107
|
+
function p() {
|
|
1108
|
+
n("closed");
|
|
1109
|
+
}
|
|
1110
|
+
return i({ close: O }), (m, k) => (b(), B(C(We), {
|
|
1111
|
+
modelValue: g.value,
|
|
1112
|
+
"onUpdate:modelValue": k[0] || (k[0] = (E) => g.value = E),
|
|
1113
|
+
"close-on-click-modal": e.closeOnClickModal && !r.value,
|
|
1114
|
+
"destroy-on-close": e.destroyOnClose,
|
|
1115
|
+
direction: e.direction,
|
|
1116
|
+
title: e.title,
|
|
1117
|
+
"show-close": e.showClose && !r.value,
|
|
1118
|
+
"close-on-press-escape": !r.value,
|
|
1119
|
+
"before-close": V,
|
|
1120
|
+
size: e.size,
|
|
1121
|
+
onClosed: p
|
|
1122
|
+
}, pe({
|
|
1123
|
+
header: D(() => [
|
|
1124
|
+
T(m.$slots, "header", {}, () => [
|
|
1125
|
+
J("span", null, P(e.title), 1)
|
|
1126
|
+
], !0)
|
|
1127
|
+
]),
|
|
1128
|
+
default: D(() => [
|
|
1129
|
+
T(m.$slots, "default", {}, void 0, !0),
|
|
1130
|
+
f.value ? (b(), A("p", yt, P(f.value), 1)) : N("", !0)
|
|
1131
|
+
]),
|
|
1132
|
+
_: 2
|
|
1133
|
+
}, [
|
|
1134
|
+
w.value ? {
|
|
1135
|
+
name: "footer",
|
|
1136
|
+
fn: D(() => [
|
|
1137
|
+
C(d).footer ? T(m.$slots, "footer", { key: 0 }, void 0, !0) : (b(), A("span", bt, [
|
|
1138
|
+
e.showCancel ? (b(), B(C(_), {
|
|
1139
|
+
key: 0,
|
|
1140
|
+
disabled: r.value,
|
|
1141
|
+
onClick: x
|
|
1142
|
+
}, {
|
|
1143
|
+
default: D(() => [
|
|
1144
|
+
q(P(e.cancelText), 1)
|
|
1145
|
+
]),
|
|
1146
|
+
_: 1
|
|
1147
|
+
}, 8, ["disabled"])) : N("", !0),
|
|
1148
|
+
e.showConfirm ? (b(), B(C(_), {
|
|
1149
|
+
key: 1,
|
|
1150
|
+
loading: r.value,
|
|
1151
|
+
disabled: r.value,
|
|
1152
|
+
type: "primary",
|
|
1153
|
+
onClick: v
|
|
1154
|
+
}, {
|
|
1155
|
+
default: D(() => [
|
|
1156
|
+
q(P(e.confirmText), 1)
|
|
1157
|
+
]),
|
|
1158
|
+
_: 1
|
|
1159
|
+
}, 8, ["loading", "disabled"])) : N("", !0)
|
|
1160
|
+
]))
|
|
1161
|
+
]),
|
|
1162
|
+
key: "0"
|
|
1163
|
+
} : void 0
|
|
1164
|
+
]), 1032, ["modelValue", "close-on-click-modal", "destroy-on-close", "direction", "title", "show-close", "close-on-press-escape", "size"]));
|
|
1165
|
+
}
|
|
1166
|
+
}), Vt = /* @__PURE__ */ ie(pt, [["__scopeId", "data-v-b86ce758"]]);
|
|
1167
|
+
function W(e) {
|
|
1168
|
+
return e instanceof Date ? new Date(e.getTime()) : Array.isArray(e) ? e.map(W) : e && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(Object.entries(e).map(([i, o]) => [i, W(o)])) : e;
|
|
1169
|
+
}
|
|
1170
|
+
function ht(e, i) {
|
|
1171
|
+
let o = i;
|
|
1172
|
+
const t = W(o.initialQuery);
|
|
1173
|
+
let n = { result: void 0, query: W(e), tableData: [], total: 0, loading: !1, error: null }, d = 0, r, f = !0;
|
|
1174
|
+
const c = /* @__PURE__ */ new Set(), h = (v) => {
|
|
1175
|
+
n = { ...n, ...v }, c.forEach((x) => x());
|
|
1176
|
+
}, g = (v) => h({ query: { ...n.query, ...W(v) } }), w = () => ({
|
|
1177
|
+
currentPage: Number(n.query.page) || 1,
|
|
1178
|
+
pageSize: Number(n.query.page_size) || 10,
|
|
1179
|
+
pageSizes: n.query.page_sizes ?? [10, 20, 50, 100],
|
|
1180
|
+
total: n.total
|
|
1181
|
+
}), O = async () => {
|
|
1182
|
+
var p;
|
|
1183
|
+
if (!f) return;
|
|
1184
|
+
const v = ++d;
|
|
1185
|
+
r == null || r.abort();
|
|
1186
|
+
const x = new AbortController();
|
|
1187
|
+
r = x, h({ loading: !0, error: null, ...o.keepPrevious ? {} : { tableData: [], total: 0, result: void 0 } });
|
|
1188
|
+
const V = W(n.query);
|
|
1189
|
+
delete V.total, delete V.page_sizes;
|
|
1190
|
+
try {
|
|
1191
|
+
let m = await o.fetchList(V, x.signal);
|
|
1192
|
+
if (!f || v !== d) return;
|
|
1193
|
+
const k = (j) => {
|
|
1194
|
+
if (!j || !Array.isArray(j.list) || !Number.isFinite(j.total) || j.total < 0)
|
|
1195
|
+
throw new Error("fetchList 必须返回 { list: 数组, total: 非负数 }");
|
|
1196
|
+
};
|
|
1197
|
+
k(m);
|
|
1198
|
+
const E = Math.max(1, Math.ceil(m.total / w().pageSize));
|
|
1199
|
+
if (w().currentPage > E) {
|
|
1200
|
+
if (g({ page: E }), m = await o.fetchList({ ...V, page: E }, x.signal), !f || v !== d) return;
|
|
1201
|
+
k(m);
|
|
1202
|
+
}
|
|
1203
|
+
if (h({ result: m, tableData: m.list, total: m.total }), o.persistKey && typeof localStorage < "u")
|
|
1204
|
+
try {
|
|
1205
|
+
localStorage.setItem(
|
|
1206
|
+
o.persistKey,
|
|
1207
|
+
JSON.stringify({ page: n.query.page, page_size: n.query.page_size })
|
|
1208
|
+
);
|
|
1209
|
+
} catch {
|
|
1210
|
+
}
|
|
1211
|
+
return m;
|
|
1212
|
+
} catch (m) {
|
|
1213
|
+
f && v === d && (h({ error: m }), (p = o.onError) == null || p.call(o, m));
|
|
1214
|
+
return;
|
|
1215
|
+
} finally {
|
|
1216
|
+
f && v === d && h({ loading: !1 });
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
return {
|
|
1220
|
+
getSnapshot: () => n,
|
|
1221
|
+
subscribe: (v) => (c.add(v), () => {
|
|
1222
|
+
c.delete(v);
|
|
1223
|
+
}),
|
|
1224
|
+
setOptions: (v) => {
|
|
1225
|
+
o = v;
|
|
1226
|
+
},
|
|
1227
|
+
activate: () => {
|
|
1228
|
+
f = !0;
|
|
1229
|
+
},
|
|
1230
|
+
dispose: () => {
|
|
1231
|
+
f = !1, d++, r == null || r.abort();
|
|
1232
|
+
},
|
|
1233
|
+
pageParams: w,
|
|
1234
|
+
getData: O,
|
|
1235
|
+
onSubmit: (v) => (g({ ...v, page: 1 }), O()),
|
|
1236
|
+
handlePageChange: ({ pageNum: v }) => (g({ page: v }), O()),
|
|
1237
|
+
handleSizeChange: ({ pageSize: v }) => (g({ page: 1, page_size: v }), O()),
|
|
1238
|
+
reset: () => (d++, r == null || r.abort(), h({ query: { ...W(t), page: 1 }, result: void 0, tableData: [], total: 0, error: null, loading: !1 }), o.isRefreshData === !1 ? Promise.resolve(void 0) : O()),
|
|
1239
|
+
restorePagination: () => {
|
|
1240
|
+
if (!(!o.persistKey || typeof localStorage > "u"))
|
|
1241
|
+
try {
|
|
1242
|
+
const v = JSON.parse(localStorage.getItem(o.persistKey) ?? "null");
|
|
1243
|
+
v && Number.isInteger(v.page) && v.page > 0 && Number.isInteger(v.page_size) && v.page_size > 0 && g({ page: v.page, page_size: v.page_size });
|
|
1244
|
+
} catch {
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
function At(e, i) {
|
|
1250
|
+
return e.map((o) => {
|
|
1251
|
+
if (!o || typeof o != "object") throw new Error("选项必须为对象");
|
|
1252
|
+
const t = o, n = t[i.value];
|
|
1253
|
+
if (!["string", "number", "boolean"].includes(typeof n) || t[i.key] === void 0)
|
|
1254
|
+
throw new Error("选项映射字段缺失或类型不支持");
|
|
1255
|
+
return { label: String(t[i.key]), value: n };
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
function Nt(e) {
|
|
1259
|
+
return e instanceof Error && e.name === "AbortError";
|
|
1260
|
+
}
|
|
1261
|
+
function wt(e, i, o) {
|
|
1262
|
+
const t = /* @__PURE__ */ new Map();
|
|
1263
|
+
let n = 0, d = !0;
|
|
1264
|
+
return {
|
|
1265
|
+
activate: () => {
|
|
1266
|
+
d = !0;
|
|
1267
|
+
},
|
|
1268
|
+
dispose: () => {
|
|
1269
|
+
d = !1, n++, t.forEach(({ controller: r }) => r.abort()), t.clear();
|
|
1270
|
+
},
|
|
1271
|
+
exec: (r, f, c = "default") => {
|
|
1272
|
+
if (!d) return Promise.reject(new DOMException("操作所属组件已销毁", "AbortError"));
|
|
1273
|
+
if (t.has(c)) return t.get(c).promise;
|
|
1274
|
+
const h = n, g = new AbortController(), w = () => {
|
|
1275
|
+
if (!d || h !== n || g.signal.aborted)
|
|
1276
|
+
throw new DOMException("操作已取消", "AbortError");
|
|
1277
|
+
}, O = Promise.resolve().then(() => (w(), r(g.signal))).then(async (v) => {
|
|
1278
|
+
if (w(), d && h === n) {
|
|
1279
|
+
const x = typeof f == "function" ? f(v) : f;
|
|
1280
|
+
x && (i == null || i(x)), await (e == null ? void 0 : e());
|
|
1281
|
+
}
|
|
1282
|
+
return w(), v;
|
|
1283
|
+
}).catch((v) => {
|
|
1284
|
+
throw w(), v;
|
|
1285
|
+
}).finally(() => {
|
|
1286
|
+
d && h === n && (t.delete(c), o == null || o([...t.keys()]));
|
|
1287
|
+
});
|
|
1288
|
+
return t.set(c, { promise: O, controller: g }), o == null || o([...t.keys()]), O;
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
function Tt(e, i) {
|
|
1293
|
+
const o = ht(e, i), t = re(o.getSnapshot()), n = o.subscribe(() => {
|
|
1294
|
+
t.value = o.getSnapshot();
|
|
1295
|
+
for (const d of Object.keys(e))
|
|
1296
|
+
d in t.value.query || Reflect.deleteProperty(e, d);
|
|
1297
|
+
Object.assign(e, W(t.value.query));
|
|
1298
|
+
});
|
|
1299
|
+
return ve(() => {
|
|
1300
|
+
n(), o.dispose();
|
|
1301
|
+
}), {
|
|
1302
|
+
...o,
|
|
1303
|
+
state: t,
|
|
1304
|
+
result: z(() => t.value.result),
|
|
1305
|
+
loading: z(() => t.value.loading),
|
|
1306
|
+
error: z(() => t.value.error),
|
|
1307
|
+
tableData: z(() => t.value.tableData),
|
|
1308
|
+
total: z(() => t.value.total),
|
|
1309
|
+
pageParams: z(() => (t.value, o.pageParams()))
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
function Ft(e, i) {
|
|
1313
|
+
const o = re([]), t = F(!0), n = re(null);
|
|
1314
|
+
let d;
|
|
1315
|
+
async function r() {
|
|
1316
|
+
d == null || d.abort();
|
|
1317
|
+
const f = new AbortController();
|
|
1318
|
+
d = f, t.value = !0, n.value = null;
|
|
1319
|
+
try {
|
|
1320
|
+
const c = await e(f.signal);
|
|
1321
|
+
if (!Array.isArray(c)) throw new Error("选项接口必须返回数组");
|
|
1322
|
+
f.signal.aborted || (o.value = c.map(i));
|
|
1323
|
+
} catch (c) {
|
|
1324
|
+
f.signal.aborted || (n.value = c instanceof Error ? c : new Error(String(c)));
|
|
1325
|
+
} finally {
|
|
1326
|
+
f.signal.aborted || (t.value = !1);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return je(() => {
|
|
1330
|
+
r();
|
|
1331
|
+
}), ve(() => d == null ? void 0 : d.abort()), { options: o, loading: t, error: n, reload: r };
|
|
1332
|
+
}
|
|
1333
|
+
function Pt(e) {
|
|
1334
|
+
const i = F([]), o = wt(
|
|
1335
|
+
e,
|
|
1336
|
+
(t) => Ge.success(t),
|
|
1337
|
+
(t) => {
|
|
1338
|
+
i.value = t;
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
return ve(o.dispose), { ...o, pendingKeys: i };
|
|
1342
|
+
}
|
|
1343
|
+
function Mt(e) {
|
|
1344
|
+
return W(e);
|
|
1345
|
+
}
|
|
1346
|
+
function Ct(e, i, o) {
|
|
1347
|
+
var f, c;
|
|
1348
|
+
const n = ((h) => h.split(".").reduce(
|
|
1349
|
+
(g, w) => g !== null && typeof g == "object" ? g[w] : void 0,
|
|
1350
|
+
e
|
|
1351
|
+
))(i.type === "nested" ? i.path ?? i.prop : i.prop), d = String(
|
|
1352
|
+
i.type === "enum" ? ((c = (f = i.enumList) == null ? void 0 : f.find((h) => h.value === n)) == null ? void 0 : c.label) ?? "--" : n ?? "--"
|
|
1353
|
+
);
|
|
1354
|
+
if (i.type !== "clip") return X("span", d);
|
|
1355
|
+
const r = async () => {
|
|
1356
|
+
var h;
|
|
1357
|
+
try {
|
|
1358
|
+
if (!navigator.clipboard) throw new Error("当前环境不支持剪贴板,请使用 HTTPS 或手动复制");
|
|
1359
|
+
await navigator.clipboard.writeText(String(n ?? "")), (h = o.onCopied) == null || h.call(o);
|
|
1360
|
+
} catch (g) {
|
|
1361
|
+
o.onCopyError ? o.onCopyError(g) : window.alert(g instanceof Error ? g.message : "复制失败");
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
return X(
|
|
1365
|
+
"button",
|
|
1366
|
+
{
|
|
1367
|
+
type: "button",
|
|
1368
|
+
class: "ai-code-copy",
|
|
1369
|
+
onClick: () => {
|
|
1370
|
+
r();
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
d
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
function St(e, i = {}) {
|
|
1377
|
+
return e.render ? e.render : (o, { row: t }) => Ct(t, e, i);
|
|
1378
|
+
}
|
|
1379
|
+
function Rt(e, i = {}) {
|
|
1380
|
+
return e.map((o) => ({
|
|
1381
|
+
...o,
|
|
1382
|
+
showColumn: o.showColumn ?? !0,
|
|
1383
|
+
...o.render || o.formatter || !o.type || o.type === "default" ? {} : { render: St(o, i) }
|
|
1384
|
+
}));
|
|
1385
|
+
}
|
|
1386
|
+
export {
|
|
1387
|
+
jt as AdminDialog,
|
|
1388
|
+
Et as BaseCard,
|
|
1389
|
+
we as BaseDialog,
|
|
1390
|
+
Vt as BaseDrawer,
|
|
1391
|
+
zt as DataTable,
|
|
1392
|
+
$t as Dialog,
|
|
1393
|
+
Dt as SearchForm,
|
|
1394
|
+
Rt as buildColumns,
|
|
1395
|
+
Mt as buildFormItems,
|
|
1396
|
+
vt as createDialogService,
|
|
1397
|
+
St as createRender,
|
|
1398
|
+
At as getFiltedOptions,
|
|
1399
|
+
Nt as isAbortError,
|
|
1400
|
+
Bt as showDialog,
|
|
1401
|
+
Pt as useAsyncListAction,
|
|
1402
|
+
Tt as usePageList,
|
|
1403
|
+
Ft as useSelectOptions
|
|
1404
|
+
};
|