@skyfox2000/webui 1.2.1 → 1.2.3

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.
@@ -0,0 +1,2186 @@
1
+ var ia = Object.defineProperty;
2
+ var la = (e, t, a) => t in e ? ia(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
+ var P = (e, t, a) => la(e, typeof t != "symbol" ? t + "" : t, a);
4
+ import { ref as f, h as D, defineComponent as W, toRaw as Qe, watch as T, useAttrs as ae, onMounted as te, onUnmounted as se, createElementBlock as O, openBlock as E, createVNode as q, unref as x, mergeProps as re, withCtx as H, createCommentVNode as j, Fragment as B, renderList as Ee, createBlock as Ae, normalizeClass as Ge, createTextVNode as Re, toDisplayString as J, createElementVNode as ua, inject as G, provide as he, nextTick as ca, shallowRef as Ve, reactive as fa } from "vue";
5
+ import { AutoComplete as pa, CheckboxGroup as da, Checkbox as ha, RadioGroup as ma, Radio as va, Select as ga, SelectOption as ya } from "ant-design-vue";
6
+ import { ResStatus as A, httpPost as _, setToken as me, fieldMapping as ba, parseFieldTemplate as Sa, API_HOST as ve, SERVER_HOST as Ia } from "@skyfox2000/fapi";
7
+ import S from "vue-m-message";
8
+ import { defineStore as Y, createPinia as xa } from "pinia";
9
+ import "vue-draggable-next";
10
+ import "dayjs";
11
+ import { combineParams as Te, isMicroApp as qe, mainAppApis as $e, EnvConfig as De, AppAction as Fe, AppSource as Ne, isBaseMicroApp as Ce } from "@skyfox2000/microbase";
12
+ import we from "async-validator";
13
+ import Ea from "pinia-plugin-persistedstate";
14
+ import { createRouter as Aa, createWebHashHistory as Ra } from "vue-router";
15
+ const Ta = 7 * 24 * 60 * 60 * 1e3, ge = /* @__PURE__ */ new Map(), Ue = /* @__PURE__ */ new Set(), C = f({}), At = C, Rt = (e) => {
16
+ var r;
17
+ if (!e.iconUrl) return Se;
18
+ const t = f(!0), a = f("");
19
+ let s = !0;
20
+ return (r = e.icons) != null && r.length && (s = e.icons.every((n) => C.value[n] !== void 0)), (e.icon && !C.value[e.icon] || !s) && wa(e, t).then(() => {
21
+ ka(e.iconUrl, e.monoColor || !1), t.value = !0;
22
+ }), W({
23
+ props: {
24
+ icon: {
25
+ type: String
26
+ },
27
+ icons: {
28
+ type: Array
29
+ },
30
+ iconIndex: {
31
+ type: Number
32
+ },
33
+ clickable: {
34
+ type: Boolean
35
+ },
36
+ angle: {
37
+ type: Number
38
+ },
39
+ flip: {
40
+ type: Boolean
41
+ },
42
+ class: {
43
+ type: [String, Array],
44
+ default: ""
45
+ }
46
+ },
47
+ emits: ["update:iconIndex"],
48
+ setup(n, { emit: o }) {
49
+ const i = f(n.icon), l = f(0), u = () => {
50
+ n.icons && l.value++;
51
+ };
52
+ return T(
53
+ () => n.iconIndex,
54
+ (c) => {
55
+ c !== void 0 && (l.value = c);
56
+ },
57
+ { immediate: !0 }
58
+ ), T(
59
+ () => l.value,
60
+ (c) => {
61
+ n.icons && (c >= n.icons.length && (l.value = 0), i.value = n.icons[l.value], X(a, i, i.value), o("update:iconIndex", l.value));
62
+ },
63
+ { immediate: !0 }
64
+ ), T(
65
+ () => C.value,
66
+ () => {
67
+ X(a, i, i.value);
68
+ },
69
+ { deep: !0 }
70
+ ), T(
71
+ () => n.icon,
72
+ (c) => {
73
+ X(a, i, c);
74
+ }
75
+ ), X(a, i, i.value), { isLoaded: t, Icon: a, handleClick: u };
76
+ },
77
+ render() {
78
+ if (!t.value)
79
+ return Se;
80
+ let n = this.class, o = "";
81
+ Array.isArray(n) ? o = n.join(" ") : typeof n == "string" && (o = n);
82
+ let i = [o];
83
+ return !/\bw-/.test(o) && !/$w-/.test(o) && i.push("w-4"), !/\bh-/.test(o) && !/$h-/.test(o) && i.push("h-4"), a.value ? D(Qe(a.value), {
84
+ onClick: this.$props.clickable ? this.handleClick : void 0,
85
+ class: `${i.join(" ")}`,
86
+ style: {
87
+ fill: "currentColor",
88
+ cursor: this.$props.clickable ? "pointer" : "default",
89
+ transform: Ma(this.angle, this.flip)
90
+ }
91
+ }) : D("div", { class: "w-[14px] h-[14px]" });
92
+ }
93
+ });
94
+ }, wa = (e, t) => {
95
+ let a = e.iconUrl;
96
+ if (!a)
97
+ return console.error("图标库地址不能为空"), Promise.resolve();
98
+ if (ge.has(a))
99
+ return Promise.resolve();
100
+ const s = Be(a);
101
+ if (s)
102
+ return new Promise(async (n) => (je(s.scriptContent), n()));
103
+ t.value = !1;
104
+ const r = new Promise(async (n) => {
105
+ await Oa(a, e.monoColor || !1), n(), ge.delete(a);
106
+ });
107
+ return ge.set(a, r), r;
108
+ }, Oa = async (e, t) => {
109
+ try {
110
+ const a = await fetch(e);
111
+ if (!a.ok) {
112
+ S.error("网络异常,无法加载图标库!");
113
+ return;
114
+ }
115
+ let s = await a.text();
116
+ s = t ? s.replace(/fill=\"[^\"]*\"/gi, "") : s;
117
+ let r = /^window\.(\w+)\s*=/;
118
+ const n = s.match(r);
119
+ if (n && n.length > 1) {
120
+ let o = n[1];
121
+ Pa(e, o, t, s);
122
+ }
123
+ je(s);
124
+ return;
125
+ } catch (a) {
126
+ return console.error("网络异常,无法加载图标库:", a), null;
127
+ }
128
+ }, je = (e) => {
129
+ const t = document.createElement("script");
130
+ t.textContent = e, document.head.appendChild(t);
131
+ }, Pa = (e, t, a, s) => {
132
+ let r = `icon_cache:${e}`;
133
+ const n = {
134
+ windowKey: t,
135
+ monoColor: a,
136
+ scriptContent: s,
137
+ expireTime: Date.now() + Ta
138
+ // 缓存时间:7天
139
+ };
140
+ localStorage.setItem(r, JSON.stringify(n));
141
+ }, Be = (e) => {
142
+ let t = `icon_cache:${e}`;
143
+ const a = localStorage.getItem(t);
144
+ if (!a) return null;
145
+ let s;
146
+ try {
147
+ s = JSON.parse(a);
148
+ } catch (r) {
149
+ return console.error("解析缓存失败:", r), null;
150
+ }
151
+ return s.expireTime < Date.now() ? (localStorage.removeItem(e), null) : s;
152
+ }, Tt = () => {
153
+ const e = Date.now();
154
+ for (const t in localStorage)
155
+ if (t.startsWith("icon_cache:")) {
156
+ const a = localStorage.getItem(t);
157
+ a && JSON.parse(a).expireTime < e && localStorage.removeItem(t);
158
+ }
159
+ }, X = (e, t, a) => {
160
+ setTimeout(() => {
161
+ t.value = a, t.value && (e.value = C.value[t.value]);
162
+ }, 1);
163
+ }, Se = D(
164
+ "svg",
165
+ { class: "w-4 h-4", viewBox: "0 0 50 50", style: { animation: "rotate 2s linear infinite" } },
166
+ [
167
+ D("circle", {
168
+ cx: "25",
169
+ cy: "25",
170
+ r: "20",
171
+ stroke: "currentColor",
172
+ fill: "none",
173
+ style: { strokeWidth: "3 !important" }
174
+ // 强制应用线宽
175
+ }),
176
+ D("circle", {
177
+ cx: "25",
178
+ cy: "6",
179
+ r: "6",
180
+ fill: "currentColor"
181
+ })
182
+ ]
183
+ ), ka = (e, t) => {
184
+ const a = Be(e);
185
+ Object.keys(window).forEach((s) => {
186
+ s.startsWith("_iconfont_svg_string_") && (a == null ? void 0 : a.windowKey) === s && !Ue.has(s) && (Ue.add(s), La(s, t));
187
+ });
188
+ }, La = (e, t) => {
189
+ const a = window[e], n = new DOMParser().parseFromString(a, "image/svg+xml").getElementsByTagName("symbol"), o = document.querySelectorAll("symbol");
190
+ for (const i of n) {
191
+ const l = i.id, u = Array.from(o).find((c) => c.id === l);
192
+ u && t && (u.innerHTML = i.innerHTML, u.querySelectorAll("*").forEach((c) => {
193
+ c.hasAttribute("fill") && c.removeAttribute("fill");
194
+ })), C.value[l] || (C.value[l] = D("svg", { fill: "currentColor" }, [D("use", { "xlink:href": `#${l}` })]));
195
+ }
196
+ }, Ma = (e, t) => {
197
+ let a = "";
198
+ return e && (a += `rotate(${e}deg)`), t && (a += " scaleX(-1)"), a;
199
+ }, $a = "settingInfoStore", wt = Y("settingInfo", {
200
+ state: () => ({
201
+ fullscreen: !1,
202
+ menuCollapse: !1,
203
+ tableColumns: {}
204
+ }),
205
+ actions: {
206
+ /**
207
+ * 设置全屏
208
+ */
209
+ setFullscreen(e) {
210
+ this.$patch({
211
+ fullscreen: e
212
+ });
213
+ },
214
+ /**
215
+ * 设置主菜单区折叠
216
+ */
217
+ setMenuCollapse(e) {
218
+ this.$patch({
219
+ menuCollapse: e
220
+ });
221
+ },
222
+ /**
223
+ * 获取表格头配置
224
+ */
225
+ getTableColumns(e) {
226
+ return this.tableColumns[e];
227
+ },
228
+ /**
229
+ * 设置表格头配置
230
+ */
231
+ setTableColumns(e, t) {
232
+ this.$patch({
233
+ tableColumns: {
234
+ ...this.tableColumns,
235
+ [e]: t
236
+ }
237
+ });
238
+ }
239
+ },
240
+ persist: {
241
+ key: $a,
242
+ storage: localStorage,
243
+ pick: ["fullscreen", "menuCollapse", "tableColumns"]
244
+ }
245
+ }), Ot = /* @__PURE__ */ W({
246
+ inheritAttrs: !1,
247
+ __name: "index",
248
+ props: {
249
+ ...ne,
250
+ autoload: {
251
+ type: Boolean,
252
+ default: !1
253
+ },
254
+ value: {
255
+ type: [String, Number, null, Array],
256
+ default: void 0
257
+ },
258
+ /**
259
+ * 查询字段
260
+ * - 模糊查询
261
+ */
262
+ searchField: {
263
+ type: String
264
+ },
265
+ /**
266
+ * 自定义查询参数
267
+ * - 查询参数
268
+ * - query参数
269
+ */
270
+ onsearch: {
271
+ type: Function
272
+ },
273
+ /**
274
+ * 修改输入数据则自动清空关联数据
275
+ */
276
+ autoClean: {
277
+ type: Boolean,
278
+ default: !0
279
+ }
280
+ },
281
+ emits: ["update:value", "select", "change", "update:labels"],
282
+ setup(e, { emit: t }) {
283
+ var w, m, b;
284
+ const a = e, s = ae(), r = f({
285
+ ...a.url,
286
+ url: ((w = a.url) == null ? void 0 : w.url) || "",
287
+ fieldMap: a.fieldMap || ((m = a.url) == null ? void 0 : m.fieldMap),
288
+ params: a.params || ((b = a.url) == null ? void 0 : b.params),
289
+ loadingText: !1
290
+ }), n = f(void 0);
291
+ T(
292
+ () => a.value,
293
+ () => {
294
+ n.value = a.value;
295
+ },
296
+ { immediate: !0 }
297
+ ), T(
298
+ () => n.value,
299
+ (g) => {
300
+ a.autoClean && a.formData && a.outFields && g !== a.value && na(a.formData, a.outFields, null);
301
+ }
302
+ );
303
+ const o = ue(), { editorCtrl: i, errInfo: l, labelText: u } = o, c = t;
304
+ o.inputEmit = c;
305
+ const p = f([]), h = (g) => {
306
+ var M;
307
+ if (p.value = [], g === "") return;
308
+ let d = g.trim(), I = {
309
+ ...r.value.params,
310
+ Query: {
311
+ ...(M = r.value.params) == null ? void 0 : M.Query
312
+ }
313
+ };
314
+ a.searchField && (I.Query[a.searchField] = {
315
+ $like: "%" + d + "%"
316
+ }), a.onsearch && a.onsearch(d, I), ce(!0, a, p, o, r.value, I);
317
+ }, v = (g) => {
318
+ const d = pe(a, g, p, o);
319
+ c("update:value", g), c("select", g);
320
+ const I = de(d);
321
+ c("update:labels", I), l != null && l.value.errClass && i && le(i);
322
+ };
323
+ return te(() => {
324
+ r.value && !r.value.fieldMap && (r.value.fieldMap = {
325
+ title: "Name",
326
+ label: "Name",
327
+ value: "Name",
328
+ key: "Id"
329
+ });
330
+ }), se(() => {
331
+ fe(a, o);
332
+ }), (g, d) => {
333
+ var I;
334
+ return E(), O("div", null, [
335
+ q(x(pa), re({
336
+ value: n.value,
337
+ "onUpdate:value": d[0] || (d[0] = (M) => n.value = M),
338
+ class: [(I = x(l)) == null ? void 0 : I.errClass, "error w-full"],
339
+ options: p.value,
340
+ onSearch: h,
341
+ onSelect: v,
342
+ placeholder: a.url && !a.url.loading ? "请输入并选择" + x(u) : ""
343
+ }, x(s)), null, 16, ["value", "class", "options", "placeholder"])
344
+ ]);
345
+ };
346
+ }
347
+ }), Da = { class: "min-h-[32px] pt-[5px]" }, Fa = {
348
+ key: 1,
349
+ class: "text-center text-gray-500"
350
+ }, Pt = /* @__PURE__ */ W({
351
+ inheritAttrs: !1,
352
+ __name: "index",
353
+ props: {
354
+ ...ne,
355
+ nodata: {
356
+ type: String,
357
+ default: ""
358
+ },
359
+ /**
360
+ * 换行数量
361
+ */
362
+ wrap: {
363
+ type: Number
364
+ },
365
+ disabledItems: {
366
+ type: Array
367
+ }
368
+ },
369
+ emits: ["change", "update:labels"],
370
+ setup(e, { emit: t }) {
371
+ var c, p, h;
372
+ const a = e, s = ae(), r = f({
373
+ ...a.url,
374
+ url: ((c = a.url) == null ? void 0 : c.url) || "",
375
+ fieldMap: a.fieldMap || ((p = a.url) == null ? void 0 : p.fieldMap),
376
+ params: a.params || ((h = a.url) == null ? void 0 : h.params),
377
+ loadingText: !1
378
+ }), n = ue(), { errInfo: o } = n, i = t;
379
+ n.inputEmit = i;
380
+ const l = f([]), u = (v) => {
381
+ const m = pe(a, v, l, n), b = de(m);
382
+ i("update:labels", b);
383
+ };
384
+ return te(() => {
385
+ r.value && !r.value.fieldMap && (r.value.fieldMap = {
386
+ title: "Name",
387
+ label: "Name",
388
+ value: "Id",
389
+ key: "Id"
390
+ }), ce(a.autoload, a, l, n, r.value, r.value.params);
391
+ }), se(() => {
392
+ fe(a, n);
393
+ }), (v, w) => (E(), O("div", Da, [
394
+ q(x(da), re({
395
+ onChange: u,
396
+ class: "w-full mb-[-3px]"
397
+ }, x(s)), {
398
+ default: H(() => [
399
+ l.value.length > 0 ? (E(!0), O(B, { key: 0 }, Ee(l.value, (m) => {
400
+ var b;
401
+ return E(), Ae(x(ha), {
402
+ key: m.value,
403
+ value: m.value,
404
+ disabled: m.disabled || m.value && e.disabledItems && e.disabledItems.indexOf(m.value.toString()) > -1,
405
+ class: Ge([
406
+ ((b = x(o)) == null ? void 0 : b.errClass) === "error" ? "error !text-red-400" : "",
407
+ "text-nowrap",
408
+ "pb-1",
409
+ e.wrap ? `w-1/${a.wrap}` : ""
410
+ ])
411
+ }, {
412
+ default: H(() => [
413
+ Re(J(m.label), 1)
414
+ ]),
415
+ _: 2
416
+ }, 1032, ["value", "disabled", "class"]);
417
+ }), 128)) : e.nodata ? (E(), O("div", Fa, J(e.nodata), 1)) : j("", !0)
418
+ ]),
419
+ _: 1
420
+ }, 16)
421
+ ]));
422
+ }
423
+ }), Na = { class: "min-h-[32px] pt-1" }, Ca = {
424
+ key: 1,
425
+ class: "text-center text-gray-500"
426
+ }, kt = /* @__PURE__ */ W({
427
+ inheritAttrs: !1,
428
+ __name: "index",
429
+ props: {
430
+ ...ne,
431
+ value: {
432
+ type: [String, Number, null, Array],
433
+ default: void 0
434
+ },
435
+ nodata: {
436
+ type: String,
437
+ default: "无数据"
438
+ },
439
+ /**
440
+ * 换行数量
441
+ */
442
+ wrap: {
443
+ type: Number
444
+ }
445
+ },
446
+ emits: ["change", "update:value", "update:labels"],
447
+ setup(e, { emit: t }) {
448
+ var h, v, w;
449
+ const a = e, s = ae(), r = f({
450
+ ...a.url,
451
+ url: ((h = a.url) == null ? void 0 : h.url) || "",
452
+ fieldMap: a.fieldMap || ((v = a.url) == null ? void 0 : v.fieldMap),
453
+ params: a.params || ((w = a.url) == null ? void 0 : w.params),
454
+ loadingText: !1
455
+ }), n = f(a.value), o = ue(), { errInfo: i } = o, l = f([]), u = t;
456
+ o.inputEmit = u, T(
457
+ () => n.value,
458
+ (m) => {
459
+ u("update:value", m);
460
+ }
461
+ );
462
+ const c = (m, b) => {
463
+ if (typeof m == "object" && typeof b == "object") {
464
+ const g = JSON.stringify(m) === JSON.stringify(b);
465
+ return g && (n.value = m), g;
466
+ }
467
+ return m === b;
468
+ }, p = (m) => {
469
+ const b = m.target.value, g = pe(a, b, l, o), d = de(g);
470
+ u("update:labels", d);
471
+ };
472
+ return te(() => {
473
+ var m;
474
+ r.value && !r.value.fieldMap && (r.value.fieldMap = {
475
+ label: "Name",
476
+ value: "Id",
477
+ key: "Id"
478
+ }), ce(a.autoload, a, l, o, r.value, (m = r.value) == null ? void 0 : m.params);
479
+ }), se(() => {
480
+ fe(a, o);
481
+ }), (m, b) => (E(), O("div", Na, [
482
+ q(x(ma), re({
483
+ value: n.value,
484
+ "onUpdate:value": b[0] || (b[0] = (g) => n.value = g),
485
+ autocheck: !1,
486
+ onChange: p,
487
+ class: "w-full flex align-items flex-wrap mb-[-3px]"
488
+ }, x(s)), {
489
+ default: H(() => [
490
+ l.value.length > 0 ? (E(!0), O(B, { key: 0 }, Ee(l.value, (g) => {
491
+ var d;
492
+ return E(), O(B, {
493
+ key: g.value
494
+ }, [
495
+ g.visible !== !1 ? (E(), Ae(x(va), {
496
+ key: 0,
497
+ checked: c(g.value, a.value),
498
+ value: g.value,
499
+ class: Ge([
500
+ ((d = x(i)) == null ? void 0 : d.errClass) === "error" ? "error !text-red-400" : "",
501
+ "text-nowrap",
502
+ "pb-1",
503
+ e.wrap ? `w-1/${a.wrap}` : ""
504
+ ])
505
+ }, {
506
+ default: H(() => [
507
+ Re(J(g.label), 1)
508
+ ]),
509
+ _: 2
510
+ }, 1032, ["checked", "value", "class"])) : j("", !0)
511
+ ], 64);
512
+ }), 128)) : e.nodata ? (E(), O("div", Ca, J(e.nodata), 1)) : j("", !0)
513
+ ]),
514
+ _: 1
515
+ }, 16, ["value"])
516
+ ]));
517
+ }
518
+ }), Ua = {
519
+ key: 0,
520
+ class: "absolute z-10 mt-[5px] mr-[10px] text-[#999] flex items-center"
521
+ }, Lt = /* @__PURE__ */ W({
522
+ inheritAttrs: !1,
523
+ __name: "index",
524
+ props: {
525
+ ...ne,
526
+ value: {
527
+ type: [String, Number, Array, null],
528
+ default: void 0
529
+ },
530
+ /**
531
+ * 自动选择第一个选项
532
+ */
533
+ selectFirst: {
534
+ type: Boolean,
535
+ default: !1
536
+ },
537
+ /**
538
+ * 数据源OPTIONS的key
539
+ */
540
+ dataKey: {
541
+ type: String,
542
+ required: !1
543
+ },
544
+ /**
545
+ * 是否显示全部选项
546
+ */
547
+ all: {
548
+ type: Boolean,
549
+ default: !1
550
+ },
551
+ /**
552
+ * 自定义全部选项的值
553
+ * 如果all为true,则显示全部选项
554
+ * 未设置allValue,则默认[0, 1]
555
+ */
556
+ allValue: {
557
+ type: [String, Number, Array],
558
+ required: !1
559
+ }
560
+ },
561
+ emits: ["change", "update:value", "update:labels"],
562
+ setup(e, { emit: t }) {
563
+ var m, b, g;
564
+ const a = e, s = ae(), r = f({
565
+ ...a.url,
566
+ url: ((m = a.url) == null ? void 0 : m.url) || "",
567
+ fieldMap: a.fieldMap || ((b = a.url) == null ? void 0 : b.fieldMap),
568
+ params: a.params || ((g = a.url) == null ? void 0 : g.params),
569
+ loadingText: !1
570
+ }), n = ue(), { editorCtrl: o, errInfo: i, labelText: l } = n, u = f(void 0), c = t;
571
+ n.inputEmit = c;
572
+ const p = f([]);
573
+ T(
574
+ () => p.value,
575
+ (d) => {
576
+ d.length > 0 && F(a.value) && a.selectFirst ? (u.value = d[0].value, w(d[0].value)) : u.value = a.value === null ? void 0 : a.value;
577
+ }
578
+ );
579
+ const h = f(s.placeholder);
580
+ T(
581
+ () => r.value.loading,
582
+ (d) => {
583
+ d ? h.value = "" : h.value || (h.value = "请选择" + l.value);
584
+ },
585
+ { immediate: !0 }
586
+ );
587
+ const v = f(a.value);
588
+ T(
589
+ () => u.value,
590
+ (d) => {
591
+ if (s.mode === "multiple" && F(d) && F(v.value)) {
592
+ c("update:value", v.value);
593
+ return;
594
+ }
595
+ c("update:value", d);
596
+ }
597
+ );
598
+ const w = (d) => {
599
+ const I = pe(a, d, p, n), M = de(I);
600
+ u.value = d, c("update:labels", M), c("change", d), i != null && i.value.errClass && o && le(o);
601
+ };
602
+ return te(() => {
603
+ var d;
604
+ if (r.value && !r.value.fieldMap && (r.value.fieldMap = {
605
+ label: "Name",
606
+ value: "Id",
607
+ key: "Id"
608
+ }), a.dataKey) {
609
+ const I = JSON.parse(JSON.stringify(L.getOptions(a.dataKey)));
610
+ p.value = I;
611
+ } else ce(a.autoload, a, p, n, r.value, (d = r.value) == null ? void 0 : d.params);
612
+ }), se(() => {
613
+ fe(a, n);
614
+ }), (d, I) => {
615
+ var M;
616
+ return E(), O("div", null, [
617
+ a.url && a.url.loading === !0 ? (E(), O("div", Ua, [
618
+ q(x(Se), { class: "text-[#555] mx-[5px] !ml-[10px] !w-4 !h-4" }),
619
+ I[1] || (I[1] = ua("span", null, "数据加载中...", -1))
620
+ ])) : j("", !0),
621
+ q(x(ga), re({
622
+ class: [(M = x(i)) == null ? void 0 : M.errClass, "w-full"],
623
+ value: u.value,
624
+ "onUpdate:value": I[0] || (I[0] = (K) => u.value = K),
625
+ "allow-clear": !0,
626
+ onChange: w,
627
+ placeholder: h.value,
628
+ "label-in-value": !1
629
+ }, x(s)), {
630
+ default: H(() => [
631
+ (E(!0), O(B, null, Ee(p.value, (K) => (E(), O(B, {
632
+ key: K.value
633
+ }, [
634
+ K.visible !== !1 ? (E(), Ae(x(ya), {
635
+ key: 0,
636
+ value: K.value
637
+ }, {
638
+ default: H(() => [
639
+ Re(J(K.label), 1)
640
+ ]),
641
+ _: 2
642
+ }, 1032, ["value"])) : j("", !0)
643
+ ], 64))), 128))
644
+ ]),
645
+ _: 1
646
+ }, 16, ["class", "value", "placeholder"])
647
+ ]);
648
+ };
649
+ }
650
+ });
651
+ var $ = /* @__PURE__ */ ((e) => (e.PageControl = "Page.PageControl", e.EditorControl = "Page.EditorControl", e.GridControl = "Page.GridControl", e.LabelText = "FormItem.LabelText", e.RuleKey = "FormItem.RuleKey", e.ErrInfo = "FormItem.ErrInfo", e))($ || {});
652
+ const R = class R {
653
+ };
654
+ P(R, "dict", {}), P(R, "Keys", {
655
+ EnableDisable: "EnableDisable",
656
+ SuccessResult: "SuccessResult",
657
+ YesNo: "YesNo",
658
+ MaleFemale: "MaleFemale"
659
+ }), /**
660
+ * 静态选择项列表
661
+ * @param key 名称
662
+ * @returns
663
+ */
664
+ P(R, "getOptions", (t) => R.dict[t]), /**
665
+ * 静态选择项对象
666
+ * @param key 名称
667
+ * @param value 值
668
+ * @returns
669
+ */
670
+ P(R, "getOptionItem", (t, a) => R.dict[t].find((s) => s.value === a)), /**
671
+ * 设置静态选择项
672
+ * @param key 名称
673
+ * @param list 列表
674
+ */
675
+ P(R, "setOptions", (t, a) => {
676
+ R.dict[t] = a;
677
+ }), /**
678
+ * 启用/停用选项
679
+ * - 启用 1
680
+ * - 停用 0
681
+ */
682
+ P(R, "EnableDisable", [
683
+ {
684
+ label: "启用",
685
+ text: "✅ 启用",
686
+ value: 1
687
+ },
688
+ {
689
+ label: "停用",
690
+ text: "🚫 停用",
691
+ value: 0
692
+ }
693
+ ]), /**
694
+ * 成功/失败选项
695
+ * - 成功 1
696
+ * - 失败 0
697
+ */
698
+ P(R, "SuccessResult", [
699
+ {
700
+ label: "成功",
701
+ text: "✅ 成功",
702
+ value: 1
703
+ },
704
+ {
705
+ label: "失败",
706
+ text: "🚫 失败",
707
+ value: 0
708
+ }
709
+ ]), /**
710
+ * 是/否选项
711
+ * - 是 1
712
+ * - 否 0
713
+ */
714
+ P(R, "YesNo", [
715
+ {
716
+ label: "是",
717
+ text: "✅ 是",
718
+ value: 1
719
+ },
720
+ {
721
+ label: "否",
722
+ text: "❎ 否",
723
+ value: 0
724
+ }
725
+ ]), /**
726
+ * 男/女选项
727
+ * - 男 M
728
+ * - 女 F
729
+ */
730
+ P(R, "MaleFemale", [
731
+ {
732
+ label: "男",
733
+ text: "男 👨",
734
+ value: "M"
735
+ },
736
+ {
737
+ label: "女",
738
+ text: "女 👩",
739
+ value: "F"
740
+ }
741
+ ]);
742
+ let L = R;
743
+ L.setOptions("EnableDisable", L.EnableDisable);
744
+ L.setOptions("SuccessResult", L.SuccessResult);
745
+ L.setOptions("YesNo", L.YesNo);
746
+ L.setOptions("MaleFemale", L.MaleFemale);
747
+ const ne = {
748
+ /**
749
+ * 自动接口加载数据
750
+ * - 默认为true
751
+ */
752
+ autoload: {
753
+ type: Boolean,
754
+ required: !1,
755
+ default: !0
756
+ },
757
+ /**
758
+ * 是否显示全部选项
759
+ * - 默认为false
760
+ */
761
+ all: {
762
+ type: Boolean,
763
+ required: !1,
764
+ default: !1
765
+ },
766
+ /**
767
+ * 选择项数据
768
+ */
769
+ data: {
770
+ type: Array,
771
+ required: !1
772
+ },
773
+ /**
774
+ * 字段转换控制
775
+ * - Key:目的字段
776
+ * - Value:源字段,支持模板 ${}
777
+ */
778
+ fieldMap: {
779
+ type: Object,
780
+ required: !1
781
+ },
782
+ /**
783
+ * 接口定义
784
+ */
785
+ url: {
786
+ type: Object,
787
+ required: !1
788
+ },
789
+ /**
790
+ * 接口自定义QOD参数
791
+ */
792
+ params: {
793
+ type: Object,
794
+ required: !1
795
+ },
796
+ /**
797
+ * 返回文字内容或文字内容数组
798
+ */
799
+ labels: {
800
+ type: [String, Number, Array],
801
+ required: !1
802
+ },
803
+ /**
804
+ * 表单数据
805
+ */
806
+ formData: {
807
+ type: Object,
808
+ required: !1
809
+ },
810
+ /**
811
+ * 输出字段转换控制
812
+ * - Key:目的字段
813
+ * - Value:源字段,支持模板 ${}
814
+ */
815
+ outFields: {
816
+ type: Object,
817
+ required: !1
818
+ },
819
+ /**
820
+ * 通过消息重载数据,只允许改变查询条件
821
+ * - eventBus.on(组件限定前缀 +"."+ reloadEvent, { Q参数 } | 数据[])
822
+ * - 数据组仅用于联动显示
823
+ * - 其它情况使用Query参数
824
+ */
825
+ reloadEvent: {
826
+ type: String,
827
+ required: !1
828
+ },
829
+ /**
830
+ * 通过消息触发事件,只允许改变查询条件
831
+ * - eventBus.emit(changeEvent, { Q参数 } | 数据[])
832
+ * - 数据组仅用于联动显示
833
+ * - 其它情况使用Query参数
834
+ */
835
+ changeEvent: {
836
+ type: [String, Array],
837
+ required: !1
838
+ }
839
+ }, F = (e) => e == null || e === "" ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1, oe = (e, t) => {
840
+ var r;
841
+ return {
842
+ url: "",
843
+ ...(r = e.page.urls) == null ? void 0 : r[t.urlKey],
844
+ ...e.url,
845
+ ...t.url,
846
+ loadingText: t.loadingText
847
+ };
848
+ }, ie = (e, t) => {
849
+ const a = e.page, s = t.url;
850
+ if (!s || !s.url) {
851
+ const n = `URL未设置: ${t.urlKey}`;
852
+ return console.warn(n), Promise.reject(new Error(n));
853
+ }
854
+ s.api || (s.api = a.api), s.authorize === void 0 && (s.authorize = a.authorize);
855
+ let r = JSON.parse(JSON.stringify(t.params));
856
+ return t.processParams && (r = t.processParams(r)), t.loadingState && (t.loadingState.value = !0), t.hideErrorToast && (s.hideErrorToast = !0), _(s, r).then((n) => (t.loadingState && (t.loadingState.value = !1), n)).catch((n) => (t.loadingState && (t.loadingState.value = !1), null));
857
+ }, Oe = (e, t) => {
858
+ t.params || (t.params = {}), t.params.Query || (t.params.Query = {});
859
+ const a = oe(e, t);
860
+ return t.url = a, ie(e, t);
861
+ }, Mt = (e, t) => (t.params || (t.params = {}), t.params.Query || (t.params.Query = {}), t.loadingText = t.loadingText === !1 ? !1 : t.loadingText || "开始执行...", t.url = oe(e, t), ie(e, t).then((a) => ((a == null ? void 0 : a.status) === A.SUCCESS && (t.hideErrorToast || S.success("执行成功!")), a))), Je = (e, t = {}) => {
862
+ const a = t.primaryKey || "Id";
863
+ if (t.params || (t.params = {}), t.params.Query || (t.params.Query = {}), !t.params.Data)
864
+ return S.error("错误!无保存数据!"), Promise.resolve(null);
865
+ const s = {
866
+ ...t,
867
+ urlKey: t.urlKey || "save",
868
+ loadingText: t.loadingText === !1 ? !1 : t.loadingText || "数据保存中..."
869
+ };
870
+ s.params.Query[a] = s.params.Data[a];
871
+ const r = oe(e, s);
872
+ return s.url = r, ie(e, s).then((n) => ((n == null ? void 0 : n.status) === A.SUCCESS && (t.hideErrorToast || S.success("保存成功!")), n));
873
+ }, _a = (e, t, a = {}) => {
874
+ const s = a.primaryKey || "Id";
875
+ a.params || (a.params = {}), a.params.Query || (a.params.Query = {});
876
+ const r = {
877
+ ...a,
878
+ urlKey: "delete",
879
+ loadingText: a.loadingText === !1 ? !1 : a.loadingText || "数据删除中..."
880
+ };
881
+ if (Array.isArray(t) ? r.params.Query[s] = t : r.params.Query[s] = t[s], F(r.params.Query) || F(r.params.Query[s]))
882
+ return S.error("错误!禁止无条件删除数据!"), Promise.resolve(null);
883
+ const n = oe(e, r);
884
+ return r.url = n, ie(e, r).then((o) => ((o == null ? void 0 : o.status) === A.SUCCESS && (a.hideErrorToast || S.success("删除成功!")), o));
885
+ }, Ka = (e, t) => Oe(e, {
886
+ urlKey: "tree",
887
+ params: {},
888
+ loadingState: e.isTreeLoading,
889
+ loadingText: !1,
890
+ processParams: () => Te(e.treeQuery, t)
891
+ }).then((a) => (a == null ? void 0 : a.status) === A.SUCCESS ? (e.data.value = a.data, e.data.value) : []);
892
+ let z;
893
+ const $t = (e) => {
894
+ z = new we({}), z.messages({
895
+ required: "${label}不能为空",
896
+ types: {
897
+ number: "${label}必须是数字"
898
+ },
899
+ enum: "${label}必须是${enum}中的一个",
900
+ string: {
901
+ len: "${label}长度必须为${len}",
902
+ min: "${label}长度不能小于${min}",
903
+ max: "${label}长度不能大于${max}",
904
+ range: "${label}长度必须在${min}和${max}之间"
905
+ },
906
+ number: {
907
+ len: "${label}必须为${len}",
908
+ min: "${label}不能小于${min}",
909
+ max: "${label}不能大于${max}",
910
+ range: "${label}必须在${min}和${max}之间"
911
+ },
912
+ array: {
913
+ len: "${label}长度必须为${len}",
914
+ min: "${label}长度不能小于${min}",
915
+ max: "${label}长度不能大于${max}",
916
+ range: "${label}长度必须在${min}和${max}之间"
917
+ },
918
+ ...e
919
+ });
920
+ }, Dt = (e) => {
921
+ if (!e || F(e))
922
+ return [];
923
+ const t = [], a = z.messages(), s = (n, o, i) => {
924
+ const l = o.type;
925
+ if (l && a.types && l in a.types) {
926
+ const c = a.types[l];
927
+ r(c, n, { type: l }, i);
928
+ }
929
+ const u = ["string", "number", "array"];
930
+ for (const c of u)
931
+ if (l === c && a[c]) {
932
+ const p = a[c], h = ["len", "min", "max", "range"];
933
+ for (const v of h)
934
+ v === "range" && o.min != null && o.max != null && p.range ? r(p.range, n, { min: o.min, max: o.max }, i) : v !== "range" && o[v] != null && p[v] && r(p[v], n, { [v]: o[v] }, i);
935
+ }
936
+ if (o.required && a.required && r(a.required, n, {}, i), o.pattern && a.pattern && r(o.message, n, {}, i), o.enum && Array.isArray(o.enum) && a.enum) {
937
+ const c = o.enum.join(", ");
938
+ r(a.enum, n, { enum: c }, i);
939
+ }
940
+ }, r = (n, o, i, l) => {
941
+ if (n)
942
+ try {
943
+ let u;
944
+ if (typeof n == "function") {
945
+ const c = [o];
946
+ for (const p in i)
947
+ c.push(i[p]);
948
+ u = n.apply(null, c), u && l.push(u);
949
+ } else {
950
+ u = String(n);
951
+ for (const c in i)
952
+ u = u.replace(new RegExp(`\\$\\{${c}\\}`, "g"), i[c]);
953
+ u = u.replace(/\$\{label\}/g, ""), u && l.push(u);
954
+ }
955
+ } catch (u) {
956
+ console.error("格式化验证消息出错:", u);
957
+ }
958
+ };
959
+ return Object.keys(e).forEach((n) => {
960
+ const o = e[n], i = [];
961
+ try {
962
+ s(n, o, i), Array.isArray(o) && o.forEach((u) => {
963
+ u && typeof u == "object" && s(n, u, i);
964
+ }), o && typeof o == "object" && "fields" in o;
965
+ } catch (u) {
966
+ console.error("处理验证规则出错:", u);
967
+ }
968
+ const l = Array.from(new Set(i));
969
+ n && l.length > 0 && t.push({
970
+ field: n,
971
+ rules: l
972
+ });
973
+ }), t;
974
+ }, le = async (e) => {
975
+ const t = e.formData.value, a = e.formRules.value;
976
+ F(a) || (Pe(e), e.ruleValidator || (e.ruleValidator = new we({}), e.ruleValidator.messages(z.messages()), e.ruleValidator.define(a)), e.ruleResults.value = await e.ruleValidator.validate(t).then(() => {
977
+ }).catch(({ fields: s }) => s));
978
+ }, Ft = async (e, t, a) => (a || (a = new we({}), a.messages(z.messages()), a.define(t)), a.validate(e).then(() => {
979
+ }).catch(({ fields: s }) => s)), Pe = (e) => {
980
+ e.ruleResults.value = void 0;
981
+ }, ue = () => {
982
+ const e = G($.EditorControl, void 0), t = f(G($.LabelText, "")), a = f(G($.RuleKey, "")), s = G($.ErrInfo, void 0);
983
+ return {
984
+ editorCtrl: e,
985
+ labelText: t,
986
+ ruleKey: a,
987
+ errInfo: s
988
+ };
989
+ }, Ha = (e, t) => {
990
+ let a = f({
991
+ msg: "",
992
+ errClass: ""
993
+ });
994
+ if (!e.label || !e.rule)
995
+ return a;
996
+ const s = t == null ? void 0 : t.ruleResults;
997
+ return T(
998
+ () => s == null ? void 0 : s.value,
999
+ (r) => {
1000
+ if (a.value.errClass = "", a.value.msg = "", !F(r)) {
1001
+ const n = Qa(
1002
+ {
1003
+ label: e.label,
1004
+ rule: e.rule
1005
+ },
1006
+ t == null ? void 0 : t.formRules.value,
1007
+ Qe(r)
1008
+ );
1009
+ a.value.errClass = n.errClass.value, a.value.msg = n.msg.value;
1010
+ }
1011
+ },
1012
+ { deep: !0 }
1013
+ ), a;
1014
+ }, Qa = (e, t, a) => {
1015
+ const s = f([]), r = f(""), n = f("");
1016
+ if (!e.rule || !t || !a)
1017
+ return { msg: r, ruleErrors: s, errClass: n };
1018
+ e.rule.split("|").forEach((l) => {
1019
+ if (l = l.trim(), l)
1020
+ if (a[l])
1021
+ s.value.push(...a[l]);
1022
+ else {
1023
+ const u = [];
1024
+ for (let c in a)
1025
+ c !== l && c.startsWith(l + ".") && u.push(...a[c]);
1026
+ u.length > 0 && s.value.push(...u);
1027
+ }
1028
+ });
1029
+ const i = /\${\w+}/g;
1030
+ return s.value.forEach((l) => {
1031
+ r.value && (r.value += " / "), r.value += l.message.replace("${label}", e.label ?? "");
1032
+ const u = t[l.field];
1033
+ if (u) {
1034
+ const c = r.value.match(i);
1035
+ c && c.forEach((p) => {
1036
+ const h = p.replace("${", "").replace("}", "");
1037
+ r.value = r.value.replace(p, u[h] ?? "");
1038
+ });
1039
+ }
1040
+ }), s.value.length > 0 && (n.value = "error"), { msg: r, ruleErrors: s, errClass: n };
1041
+ }, Nt = (e, t) => {
1042
+ he($.LabelText, e.label || ""), he($.RuleKey, e.rule || "");
1043
+ const a = Ha(e, t);
1044
+ return he($.ErrInfo, a), a;
1045
+ }, Ct = (e) => {
1046
+ ze(e);
1047
+ }, Ut = (e) => {
1048
+ const t = e.page, a = e.formData.value;
1049
+ a[e.primaryKey ?? t.primaryKey] = null, ze(e);
1050
+ }, _t = (e) => {
1051
+ e.visible.value = !1;
1052
+ }, ze = async (e) => {
1053
+ var s;
1054
+ const t = e.page;
1055
+ if (e.isFormSaving.value = !0, Pe(e), e.beforeSave && e.beforeSave() === !1)
1056
+ return e.isFormSaving.value = !1, Promise.resolve();
1057
+ if (e.formRules.value && await le(e), e.ruleResults.value)
1058
+ return S.error("提交表单时,验证失败!"), console.error("表单验证失败!", e.ruleResults.value), e.isFormSaving.value = !1, Promise.resolve();
1059
+ const a = e.formData.value;
1060
+ return Je(
1061
+ {
1062
+ page: t,
1063
+ // 转换为AnyControl接口
1064
+ reload: (s = e.grid) == null ? void 0 : s.reload
1065
+ },
1066
+ {
1067
+ url: e.saveUrl,
1068
+ primaryKey: e.primaryKey ?? t.primaryKey,
1069
+ params: {
1070
+ Data: a,
1071
+ Query: {}
1072
+ },
1073
+ hideErrorToast: !0,
1074
+ // 隐藏自动错误提示,特殊判断控制
1075
+ loadingState: e.isFormSaving
1076
+ }
1077
+ ).then((r) => {
1078
+ var n, o;
1079
+ if ((r == null ? void 0 : r.status) === A.SUCCESS)
1080
+ S.success("保存成功!"), e.grid && (e.grid.reload.value = !0), e.afterSave && e.afterSave(), e.autoClose !== !1 && (e.visible.value = !1);
1081
+ else if (r != null && r.msg && ((n = r == null ? void 0 : r.msg) == null ? void 0 : n.indexOf("Duplicate entry")) > -1) {
1082
+ const i = (o = r == null ? void 0 : r.msg) == null ? void 0 : o.match(/Duplicate entry '([^']+)' for key '([^']+)'/);
1083
+ if (i && i.length > 2 && i[1] && i[2]) {
1084
+ const l = i[1], u = i[2].replace(/Idx_/g, "").split("_"), c = e.formRules.value;
1085
+ if (c && u.length > 0) {
1086
+ const p = {};
1087
+ u.forEach((h) => {
1088
+ c[h] && (p[h] = [
1089
+ {
1090
+ field: h,
1091
+ fieldValue: l,
1092
+ message: "数据重复"
1093
+ }
1094
+ ]);
1095
+ }), Object.keys(p).length > 0 && (console.error("保存失败!", p), e.ruleResults.value = p);
1096
+ }
1097
+ S.error(`保存失败!数据 \`${l}\` 已存在!`);
1098
+ } else S.error((r == null ? void 0 : r.msg) ?? "保存失败!");
1099
+ } else
1100
+ S.error((r == null ? void 0 : r.msg) ?? "保存失败!");
1101
+ });
1102
+ }, Kt = async (e) => {
1103
+ const t = e.page, a = e.grid;
1104
+ e.isFormLoading.value = !0;
1105
+ const s = e.formData.value, r = e.primaryKey ?? t.primaryKey;
1106
+ return ta(a, { [r]: s[r] }, e.detailUrl).then((n) => {
1107
+ e.isFormLoading.value = !1, n && We(e, n);
1108
+ });
1109
+ }, Ht = (e) => {
1110
+ const t = e.grid;
1111
+ t && (t.rowData.value = void 0), e && (Ye(e), e.visible && (e.visible.value = !1), setTimeout(() => {
1112
+ e.visible.value = !0;
1113
+ }, 1));
1114
+ }, We = (e, t) => {
1115
+ Ye(e), e.formData.value = { ...e.formData.value, ...t };
1116
+ }, Ye = (e) => {
1117
+ e.formData.value = e.default ? JSON.parse(JSON.stringify(e.default)) : {}, Pe(e);
1118
+ }, Ie = "/login/", Z = [], Ga = (e) => {
1119
+ for (const t of e) {
1120
+ const a = Z.findIndex((s) => s.path === t.path);
1121
+ a !== -1 && Z.splice(a, 1), Z.push(t), U.addRoute(t);
1122
+ }
1123
+ }, Xe = (e, t, a, s = "") => {
1124
+ const r = s + (s ? "/" : "") + e.path;
1125
+ t[r] = { ...e, parent: a }, e.children && e.children.forEach((n) => Xe(n, t, e, r));
1126
+ }, U = Aa({
1127
+ history: Ra("/"),
1128
+ routes: Z
1129
+ }), Va = (e, t) => {
1130
+ var r, n;
1131
+ const a = ((r = e.meta) == null ? void 0 : r.roles) ?? [], s = (n = e.meta) == null ? void 0 : n.permission;
1132
+ if (!t)
1133
+ return a.length === 0 && !s;
1134
+ if (t) {
1135
+ const o = Q();
1136
+ if (De.VITE_PERMISSION_MODE === "role")
1137
+ return a.length === 0 ? !0 : o.hasRole(a);
1138
+ if (De.VITE_PERMISSION_MODE === "permit") {
1139
+ if (a.length === 0 && !s)
1140
+ return !0;
1141
+ let i = !1, l = !1;
1142
+ return a.length > 0 && (i = o.hasRole(a)), s && (l = o.hasPermit(e.path, ":page")), i || l;
1143
+ }
1144
+ }
1145
+ return !1;
1146
+ }, V = f(null);
1147
+ U.beforeEach((e, t, a) => {
1148
+ var i;
1149
+ const s = e;
1150
+ if (e.path.startsWith("/error/") || e.path.startsWith(Ie))
1151
+ return a();
1152
+ const r = s.meta, o = ((r == null ? void 0 : r.roles) ?? []).length > 0 || ((i = r == null ? void 0 : r.permission) == null ? void 0 : i.length);
1153
+ if (e.path === "/") {
1154
+ const l = N();
1155
+ if (!l.menuLoaded) {
1156
+ V.value = {
1157
+ to: e,
1158
+ next: (u) => {
1159
+ a({ path: u });
1160
+ }
1161
+ };
1162
+ return;
1163
+ }
1164
+ l.toDefaultApp();
1165
+ return;
1166
+ }
1167
+ if (!o)
1168
+ a();
1169
+ else {
1170
+ const l = Q();
1171
+ if (!l.isLogin)
1172
+ a({ path: Ie });
1173
+ else {
1174
+ if (!N().menuLoaded) {
1175
+ V.value = {
1176
+ to: e,
1177
+ next: a
1178
+ };
1179
+ return;
1180
+ }
1181
+ const c = Va(s, l.isLogin);
1182
+ a();
1183
+ }
1184
+ }
1185
+ });
1186
+ U.afterEach((e) => {
1187
+ if (qe() && $e.value) {
1188
+ const { mainAppPush: t } = $e.value;
1189
+ t && t(e.hash);
1190
+ }
1191
+ });
1192
+ const qa = (e) => {
1193
+ if (V.value) {
1194
+ const { to: t, next: a } = V.value;
1195
+ V.value = null, t.path === "/" ? a(e) : a(t.path);
1196
+ }
1197
+ }, ja = (e) => {
1198
+ const t = ke();
1199
+ if (t.TabEnabled) {
1200
+ if (Ba(e.key, t.TabPanes))
1201
+ return;
1202
+ t.TabPanes.push(e);
1203
+ }
1204
+ }, Ba = (e, t) => t.find((a) => a.key === e), ke = Y("pageInfo", {
1205
+ state: () => ({
1206
+ TabActive: "",
1207
+ TabPanes: [],
1208
+ TabEnabled: !0
1209
+ }),
1210
+ actions: {
1211
+ /**
1212
+ * 删除Tab,页面缓存不卸载
1213
+ * @param path 路由地址:路由地址
1214
+ */
1215
+ removeTabPane(e) {
1216
+ if (this.TabEnabled) {
1217
+ N().excludeComponent(e);
1218
+ let a = 0, s = [...this.TabPanes];
1219
+ for (let r = 0; r < s.length; r++)
1220
+ if (s[r].key === e) {
1221
+ s.splice(r, 1), a = r - 1 < 0 ? 0 : r - 1;
1222
+ break;
1223
+ }
1224
+ for (let r = 0; r < s.length; r++)
1225
+ if (s[r].key === this.TabActive) {
1226
+ a = r;
1227
+ break;
1228
+ }
1229
+ this.TabPanes = s, this.setTabActive(s[a].key);
1230
+ }
1231
+ },
1232
+ /**
1233
+ * 新增或激活Tab
1234
+ * @param path 路由地址:路由地址
1235
+ * @returns
1236
+ */
1237
+ async setTabActive(e) {
1238
+ let a = N().findRoute(e);
1239
+ if (!a) return;
1240
+ const s = {
1241
+ key: e,
1242
+ title: a.name.toString(),
1243
+ content: "",
1244
+ closable: !0,
1245
+ // 根据路由的meta.keepAlive确定是否加入对应缓存
1246
+ // 默认为true
1247
+ keepAlive: !(a.meta && !a.meta.keepAlive)
1248
+ };
1249
+ ja(s), this.TabActive = e;
1250
+ }
1251
+ }
1252
+ }), Ja = "appInfoStore", za = {
1253
+ appList: {
1254
+ api: "PLATFORM_API",
1255
+ authorize: !0,
1256
+ url: "/api/RCTenanetOpSrv/getApps",
1257
+ loadingText: !1
1258
+ }
1259
+ }, ye = /* @__PURE__ */ new Map(), xe = (e, t) => e.map((a) => {
1260
+ var o, i, l, u, c, p, h, v;
1261
+ const s = { ...a };
1262
+ if (!((i = (o = s.meta) == null ? void 0 : o.roles) != null && i.length) && !((u = (l = s.meta) == null ? void 0 : l.permission) != null && u.length))
1263
+ return s.children && (s.children = xe(s.children, t)), s;
1264
+ const r = (p = (c = s.meta) == null ? void 0 : c.roles) != null && p.length ? t.hasRole(s.meta.roles) : !1, n = (v = (h = s.meta) == null ? void 0 : h.permission) != null && v.length ? t.hasPermit(s.meta.permission, ":page") : !1;
1265
+ return r || n ? (s.children && (s.children = xe(s.children, t)), s) : null;
1266
+ }).filter(Boolean), Ze = (e, t = "") => {
1267
+ for (const a of e) {
1268
+ if (!a.children && !a.redirect) {
1269
+ let s = t + a.path;
1270
+ return s.startsWith("/") || (s = "/" + s), s;
1271
+ }
1272
+ if (a.children && a.children.length > 0 && a.path !== "/error" && a.path !== "/login" && a.path !== "/:page(.*)") {
1273
+ const s = Ze(a.children, t + a.path + "/");
1274
+ if (s)
1275
+ return s;
1276
+ }
1277
+ }
1278
+ }, N = Y("appInfo", {
1279
+ state: () => ({
1280
+ microRouter: null,
1281
+ microActions: {},
1282
+ appInfo: {
1283
+ Id: "",
1284
+ Name: "",
1285
+ AppCode: "",
1286
+ Version: "",
1287
+ Host: "",
1288
+ Source: Ne.Manual,
1289
+ Action: Fe.App,
1290
+ Path: "",
1291
+ Icon: "",
1292
+ Routes: [],
1293
+ flattenRoutes: {},
1294
+ defaultPage: "",
1295
+ Enabled: 1
1296
+ },
1297
+ appList: [],
1298
+ CachedComponents: [],
1299
+ ExcludeComponents: [],
1300
+ menuLoaded: !1
1301
+ }),
1302
+ actions: {
1303
+ init(e, t) {
1304
+ this.microRouter = e, this.microActions = t;
1305
+ },
1306
+ /**
1307
+ * 加载授权应用列表
1308
+ */
1309
+ async loadAppList(e) {
1310
+ return new Promise(async (t) => {
1311
+ e && e.length > 0 ? (this.appList.length = 0, setTimeout(async () => {
1312
+ this.appList.push(...e), t();
1313
+ }, 1e3)) : (this.appList.length === 0 && await this.getRemoteAppList(), t());
1314
+ });
1315
+ },
1316
+ async getRemoteAppList() {
1317
+ return _(za.appList, {
1318
+ Query: {}
1319
+ }).then((e) => {
1320
+ (e == null ? void 0 : e.status) === A.SUCCESS && e.data && (this.appList.length = 0, this.appList.push(...e.data));
1321
+ });
1322
+ },
1323
+ async toDefaultApp(e) {
1324
+ if (this.appList.length === 0 && await this.loadAppList(), this.appList.length === 0) {
1325
+ S.error("加载应用列表失败");
1326
+ return;
1327
+ }
1328
+ let t = "";
1329
+ const a = window.location.pathname.split("/");
1330
+ if (a.length > 1) {
1331
+ for (let r = a.length - 1; r >= 0; r--)
1332
+ if (a[r] !== "") {
1333
+ t = a[r];
1334
+ break;
1335
+ }
1336
+ }
1337
+ let s = null;
1338
+ t && t != "login" ? s = this.appList.find((r) => r.AppCode === t) : s = this.appList.find((r) => r.Default), t = s ? s.AppCode : this.appList[0].AppCode, await this.setActiveApp(t), (!e || e.startsWith("/#/") || e.includes("/error/") || window.location.hash.includes("/error/")) && this.push(this.appInfo.defaultPage);
1339
+ },
1340
+ /**
1341
+ * 设置当前应用
1342
+ * @param key 应用码
1343
+ * @returns
1344
+ */
1345
+ async setActiveApp(e, t) {
1346
+ this.menuLoaded = !1;
1347
+ const a = this.appList.find((s) => s.AppCode === e);
1348
+ a && (a.AppCode !== this.appInfo.AppCode && (this.appInfo = {
1349
+ ...a,
1350
+ flattenRoutes: {},
1351
+ Routes: t ?? [],
1352
+ defaultPage: ""
1353
+ }), (!qe() || !Ce()) && (await (await Q()).getRolePermits(a.Id), this.appInfo.Routes.length && this.setAppRoutes(this.appInfo.Routes)));
1354
+ },
1355
+ /**
1356
+ * 设置当前应用路由信息
1357
+ * @param routes 路由信息
1358
+ */
1359
+ setAppRoutes(e) {
1360
+ this.appInfo = {
1361
+ ...this.appInfo,
1362
+ flattenRoutes: {},
1363
+ Routes: e,
1364
+ defaultPage: ""
1365
+ };
1366
+ const t = this.appInfo.flattenRoutes;
1367
+ for (const s of e)
1368
+ Xe(s, t, void 0);
1369
+ Object.keys(t).forEach((s) => {
1370
+ const r = t[s];
1371
+ r.children || !r.component || (r.meta && r.meta.keepAlive === !1 ? this.ExcludeComponents.push(s) : this.CachedComponents.push(s));
1372
+ });
1373
+ const a = Q();
1374
+ if (a.isLogin) {
1375
+ const s = xe(this.appInfo.Routes, a);
1376
+ Ga(s), this.appInfo.defaultPage = Ze(s) || "", this.appInfo.defaultPage && (this.menuLoaded = !0, qa(this.appInfo.defaultPage));
1377
+ }
1378
+ },
1379
+ /**
1380
+ * 根据地址,返回组合地址结构,/类型/子应用名/#/路由地址
1381
+ * @param path 路由地址
1382
+ * @returns
1383
+ */
1384
+ formatRoute(e) {
1385
+ let t = e;
1386
+ return e.includes("#") ? e.startsWith("#") && (t = "/" + this.appInfo.Action.toLowerCase() + "/" + this.appInfo.AppCode + "/" + e) : this.appInfo.AppCode ? t = "/" + this.appInfo.Action.toLowerCase() + "/" + this.appInfo.AppCode + "/#" + e : t = "/#" + e, t;
1387
+ },
1388
+ /**
1389
+ * 应用导航,菜单路由,都使用此处导航
1390
+ * @param path 路由地址
1391
+ */
1392
+ push(e) {
1393
+ this.findRoute(e) && ke().setTabActive(e), ca(() => {
1394
+ Ce() ? (e = this.formatRoute(e), this.microRouter ? this.microRouter.push({ path: e }) : U.push({ path: e })) : U.push({ path: e });
1395
+ });
1396
+ },
1397
+ /**
1398
+ * 快速查找路由信息
1399
+ * @param key 路由地址
1400
+ * @returns
1401
+ */
1402
+ findRoute(e) {
1403
+ return this.appInfo.flattenRoutes[e];
1404
+ },
1405
+ /**
1406
+ * 根据路由信息返回组件实例
1407
+ * @param component 组件
1408
+ * @param route 路由
1409
+ * @returns 组件实例
1410
+ */
1411
+ cacheComponent(e, t) {
1412
+ let a = ye.get(t.path);
1413
+ if (!a)
1414
+ if (this.CachedComponents.includes(t.path))
1415
+ a = {
1416
+ // 设置组件包装器的名称为路由路径
1417
+ name: t.path,
1418
+ render() {
1419
+ return D(e);
1420
+ }
1421
+ }, ye.set(t.path, a);
1422
+ else return e;
1423
+ return a;
1424
+ },
1425
+ /**
1426
+ * 删除缓存组件
1427
+ * @param path 路由地址
1428
+ */
1429
+ excludeComponent(e) {
1430
+ this.ExcludeComponents.includes(e) || this.ExcludeComponents.push(e), this.CachedComponents.splice(this.CachedComponents.indexOf(e), 1), ye.delete(e);
1431
+ },
1432
+ /**
1433
+ * 路由路径层级查询,返回面包屑
1434
+ */
1435
+ matchedRoutes(e) {
1436
+ const t = [], a = this.findRoute(e);
1437
+ if (a && (t.push(a), a.parent)) {
1438
+ const s = this.matchedRoutes(a.parent.path);
1439
+ t.push(...s);
1440
+ }
1441
+ return t.reverse();
1442
+ },
1443
+ clear() {
1444
+ this.appInfo = {
1445
+ Id: "",
1446
+ Name: "",
1447
+ AppCode: "",
1448
+ Version: "",
1449
+ Host: "",
1450
+ Source: Ne.Manual,
1451
+ Action: Fe.App,
1452
+ Path: "",
1453
+ Icon: "",
1454
+ Routes: [],
1455
+ flattenRoutes: {},
1456
+ defaultPage: "",
1457
+ Enabled: 1
1458
+ }, this.CachedComponents.splice(0, this.CachedComponents.length), this.ExcludeComponents.splice(0, this.ExcludeComponents.length), this.appList.splice(0, this.appList.length), this.menuLoaded = !1;
1459
+ },
1460
+ logout() {
1461
+ this.microRouter ? this.microActions && typeof this.microActions.login == "function" && this.microActions.login() : U.push({ path: Ie + "#/" });
1462
+ }
1463
+ },
1464
+ persist: {
1465
+ key: Ja,
1466
+ storage: localStorage,
1467
+ pick: ["appList"]
1468
+ }
1469
+ }), Wa = "userInfoStore", ea = "Token解析失败", _e = "登录过期,请重新登录", Le = {
1470
+ login: {
1471
+ api: "PLATFORM_API",
1472
+ url: "/openapi/LoginSrv/login",
1473
+ loadingText: !1
1474
+ },
1475
+ auth: {
1476
+ api: "PLATFORM_API",
1477
+ authorize: !0,
1478
+ url: "/api/RCAccountOpSrv/getPermits",
1479
+ loadingText: !1
1480
+ },
1481
+ logout: {
1482
+ api: "PLATFORM_API",
1483
+ authorize: !0,
1484
+ url: "/api/LoginSrv/logout",
1485
+ loadingText: "正在退出..."
1486
+ }
1487
+ }, Ya = (e) => {
1488
+ let t = {
1489
+ Option: {},
1490
+ Query: e
1491
+ };
1492
+ return _(Le.login, t).then((a) => (a == null ? void 0 : a.status) === A.SUCCESS ? a : null);
1493
+ }, Xa = (e) => {
1494
+ let t = {
1495
+ Query: {
1496
+ AppId: e
1497
+ }
1498
+ };
1499
+ return _(Le.auth, t).then((a) => (a == null ? void 0 : a.status) === A.SUCCESS ? a.data : (S.error("获取授权信息失败," + (a == null ? void 0 : a.msg)), null));
1500
+ }, Za = () => {
1501
+ let e = {
1502
+ Option: {},
1503
+ Query: {}
1504
+ };
1505
+ return _(Le.logout, e).then((t) => (t == null ? void 0 : t.status) === A.SUCCESS ? t.data : null);
1506
+ }, et = (e) => {
1507
+ try {
1508
+ const a = JSON.parse(atob(e.split(".")[1])).exp;
1509
+ return Date.now() / 1e3 > a;
1510
+ } catch (t) {
1511
+ return console.error(ea, t), !0;
1512
+ }
1513
+ }, Ke = (e, t) => e == "" ? (S.error(_e, {
1514
+ duration: 3e3,
1515
+ onClose: t
1516
+ }), !1) : et(e) ? (S.error(_e, {
1517
+ duration: 3e3,
1518
+ onClose: t
1519
+ }), !1) : !0, at = (e) => {
1520
+ try {
1521
+ const t = JSON.parse(atob(e.token.split(".")[1]));
1522
+ return t.user = JSON.parse(t.user), e.UserInfo = t.user, !0;
1523
+ } catch (t) {
1524
+ return console.error(ea, t), !1;
1525
+ }
1526
+ }, k = f(null), Q = Y("userInfo", {
1527
+ state: () => ({
1528
+ isLogin: !1,
1529
+ userInfo: {
1530
+ Id: "",
1531
+ Name: "",
1532
+ Code: "",
1533
+ TenantId: null,
1534
+ UserLevel: "Guest"
1535
+ },
1536
+ token: "",
1537
+ refreshToken: ""
1538
+ }),
1539
+ actions: {
1540
+ /**
1541
+ * 启动时初始化用户信息
1542
+ */
1543
+ init() {
1544
+ this.token && this.isLogin ? (me(this.token), Ke(this.token, () => this.clean())) : this.clean();
1545
+ },
1546
+ /**
1547
+ * 登录操作
1548
+ * @param loginInfo 登录信息
1549
+ * @returns
1550
+ */
1551
+ async login(e, t) {
1552
+ const a = await Ya(e);
1553
+ if (a) {
1554
+ const s = a;
1555
+ if (s.errno)
1556
+ return s;
1557
+ {
1558
+ const r = a.data;
1559
+ if (this.token = r.token, me(this.token), this.isLogin = !0, at(r))
1560
+ this.userInfo = {
1561
+ ...this.userInfo,
1562
+ ...r.UserInfo
1563
+ };
1564
+ else {
1565
+ S.error("用户信息解析失败");
1566
+ return;
1567
+ }
1568
+ t && (await N()).toDefaultApp();
1569
+ }
1570
+ }
1571
+ },
1572
+ /**
1573
+ * 获取应用授权信息
1574
+ * @param appId 应用ID
1575
+ * @returns 是否获取成功
1576
+ */
1577
+ async getRolePermits(e) {
1578
+ if (!this.isLogin || !this.token)
1579
+ return !1;
1580
+ if (k.value && k.value.appId === e)
1581
+ return !0;
1582
+ try {
1583
+ const t = await Xa(e);
1584
+ return t ? (k.value = {
1585
+ appId: e,
1586
+ level: this.userInfo.UserLevel,
1587
+ permits: t.permits || [],
1588
+ lastTime: t.lastTime
1589
+ }, !0) : !1;
1590
+ } catch (t) {
1591
+ return console.error("获取授权信息出错", t), !1;
1592
+ }
1593
+ },
1594
+ /**
1595
+ * 检查角色权限
1596
+ * @param role 资源角色编码需求
1597
+ * @returns 是否有角色权限
1598
+ */
1599
+ hasRole(e) {
1600
+ return !k.value || !k.value.level ? !1 : Array.isArray(e) ? e.includes(k.value.level) : k.value.level === e;
1601
+ },
1602
+ /**
1603
+ * 检查功能权限
1604
+ * @param permitCode 资源权限编码
1605
+ * @returns 是否有功能权限
1606
+ */
1607
+ hasPermit(e, t) {
1608
+ var a;
1609
+ return !k.value || !k.value.permits ? !1 : ((a = k.value.permits[e]) == null ? void 0 : a.includes(t)) ?? !1;
1610
+ },
1611
+ /**
1612
+ * 获取用户信息
1613
+ * @returns 用户Token
1614
+ */
1615
+ getUserInfo() {
1616
+ return this.userInfo;
1617
+ },
1618
+ /**
1619
+ * 获取用户Token
1620
+ * @returns 用户Token
1621
+ */
1622
+ getToken() {
1623
+ return Ke(this.token, () => {
1624
+ this.clean(), this.logout();
1625
+ }) ? this.token : "";
1626
+ },
1627
+ /*
1628
+ * 清理登录信息
1629
+ */
1630
+ async clean() {
1631
+ return this.userInfo = {
1632
+ Id: "",
1633
+ Name: "",
1634
+ Code: "",
1635
+ TenantId: "",
1636
+ UserLevel: ""
1637
+ }, this.token = "", me(this.token), this.isLogin = !1, k.value = null, (await N()).clear(), Promise.resolve();
1638
+ },
1639
+ /**
1640
+ * 登出操作
1641
+ * @returns
1642
+ */
1643
+ async logout() {
1644
+ try {
1645
+ await Za();
1646
+ } catch (e) {
1647
+ console.error("调用登出接口失败", e);
1648
+ } finally {
1649
+ await this.clean(), setTimeout(async () => {
1650
+ S.success("已退出登录");
1651
+ }, 1e3), setTimeout(async () => {
1652
+ (await N()).logout();
1653
+ }, 2e3);
1654
+ }
1655
+ return Promise.resolve();
1656
+ }
1657
+ },
1658
+ persist: {
1659
+ key: Wa,
1660
+ storage: localStorage,
1661
+ pick: ["isLogin", "userInfo", "token", "refreshToken"]
1662
+ }
1663
+ }), Qt = (e, t) => {
1664
+ const a = Q();
1665
+ return e.filter((s) => {
1666
+ if (s.role && !a.hasRole(s.role) || s.permit && !a.hasPermit(U.currentRoute.value.path, s.permit))
1667
+ return !1;
1668
+ if (!t) {
1669
+ if (s.visible === !1)
1670
+ return !1;
1671
+ if (typeof s.visible == "function")
1672
+ return s.visible();
1673
+ }
1674
+ return !0;
1675
+ });
1676
+ }, Gt = (e, t) => {
1677
+ const a = t == null ? void 0 : t.filter((s) => {
1678
+ const r = e.find(
1679
+ (n) => n.dataIndex === s.dataIndex || n.key === s.key || n.title === s.title
1680
+ );
1681
+ return r ? { ...s, ...r } : !1;
1682
+ });
1683
+ return [...a || [], ...e.filter((s) => !(a != null && a.includes(s)))];
1684
+ }, tt = (e) => (e.remotePage = !1, aa(e).then((t) => t.rows)), aa = (e) => {
1685
+ e.gridQuery || (e.gridQuery = {});
1686
+ const t = e.remotePage ? "find" : "list";
1687
+ return Oe(e, {
1688
+ urlKey: t,
1689
+ url: e.gridUrl,
1690
+ params: e.gridQuery,
1691
+ loadingState: e.isGridLoading,
1692
+ processParams: (a) => {
1693
+ var r;
1694
+ return e.remotePage && (a.Query.$limit = [(e.pageNo.value - 1) * e.pageSize.value, e.pageSize.value]), Te((r = e.gridUrl) == null ? void 0 : r.params, a, e.gridQuery);
1695
+ }
1696
+ }).then((a) => {
1697
+ if ((a == null ? void 0 : a.status) === A.SUCCESS) {
1698
+ let s = a.data;
1699
+ return s.rows ? (e.tableData.value = s.rows, e.total.value = s.total) : (e.tableData.value = a.data, e.total.value = a.data.length, s = {
1700
+ total: e.total.value,
1701
+ rows: a.data
1702
+ }, e.afterLoad && e.afterLoad(s)), s;
1703
+ }
1704
+ return e.tableData.value = [], e.total.value = 0, {
1705
+ total: 0,
1706
+ rows: []
1707
+ };
1708
+ });
1709
+ }, st = (e, t, a = {}) => Je(e, {
1710
+ urlKey: "update",
1711
+ url: e.updateUrl,
1712
+ params: {
1713
+ Query: { [e.primaryKey]: t[e.primaryKey] },
1714
+ Data: t
1715
+ },
1716
+ loadingState: e.isGridSaving,
1717
+ ...a
1718
+ }).then((s) => ((s == null ? void 0 : s.status) === A.SUCCESS && setTimeout(() => {
1719
+ e.reload.value = !0, e.afterUpdate && e.afterUpdate(t);
1720
+ }, 50), s)), Vt = (e, t) => {
1721
+ const a = {};
1722
+ return a[e.primaryKey] = t[e.primaryKey], a[e.statusKey] = t[e.statusKey], st(e, a, {
1723
+ loadingText: !1,
1724
+ hideErrorToast: !0
1725
+ });
1726
+ }, ta = async (e, t, a) => await Oe(e, {
1727
+ urlKey: "detail",
1728
+ url: a,
1729
+ params: t,
1730
+ loadingState: e.isGridLoading
1731
+ }), qt = (e, t) => {
1732
+ const a = t;
1733
+ return ta(e, { [e.primaryKey]: a[e.primaryKey] }).then((s) => ((s == null ? void 0 : s.status) === A.SUCCESS && s.data && (e.expandRows.value[a[e.primaryKey]] = s), s));
1734
+ }, jt = (e, t) => {
1735
+ let a = e.editor;
1736
+ e.rowData.value = t, a && (We(a, t), a.visible.value = !0);
1737
+ }, Bt = (e, t) => _a(e, t, {
1738
+ url: e.deleteUrl,
1739
+ primaryKey: e.primaryKey
1740
+ }).then((a) => ((a == null ? void 0 : a.status) === A.SUCCESS && setTimeout(() => {
1741
+ e.reload.value = !0, e.afterDelete && !Array.isArray(t) && e.afterDelete(t);
1742
+ }, 50), a)), y = {
1743
+ PageOption: {
1744
+ primaryKey: "Id",
1745
+ statusKey: "Enabled"
1746
+ },
1747
+ GridOption: {
1748
+ autoload: !0,
1749
+ primaryKey: "Id",
1750
+ statusKey: "Enabled",
1751
+ remotePage: !0,
1752
+ tableSize: f("small"),
1753
+ selectable: f(!1),
1754
+ searchBar: f(!0),
1755
+ pageSize: f(10),
1756
+ rowExpand: f(!1),
1757
+ buttons: f(["New"]),
1758
+ tools: ["Reload", "RowHeight", "TableHeadset"],
1759
+ operates: ["Edit", "Delete"]
1760
+ },
1761
+ EditorOption: {
1762
+ primaryKey: "Id",
1763
+ autoClose: !0,
1764
+ autoDetail: !1,
1765
+ saveBtnVisible: !0,
1766
+ saveAsBtnVisible: !0
1767
+ },
1768
+ TreeOption: {
1769
+ autoload: !0
1770
+ }
1771
+ }, Jt = (e) => {
1772
+ y.PageOption = {
1773
+ ...y.PageOption,
1774
+ ...e.pageOption
1775
+ }, y.GridOption = {
1776
+ ...y.GridOption,
1777
+ ...e.gridOption
1778
+ }, y.EditorOption = {
1779
+ ...y.EditorOption,
1780
+ ...e.editorOptions
1781
+ }, y.TreeOption = {
1782
+ ...y.TreeOption,
1783
+ ...e.treeOption
1784
+ };
1785
+ }, rt = (e, t, a, s) => ({
1786
+ editorCtrl: {
1787
+ ...y.EditorOption,
1788
+ name: "",
1789
+ default: a ? JSON.parse(JSON.stringify(a)) : void 0,
1790
+ visible: f(!1),
1791
+ page: t,
1792
+ formData: f(a ? JSON.parse(JSON.stringify(a)) : void 0),
1793
+ formRules: f(s),
1794
+ ruleResults: f({}),
1795
+ updateData: f(void 0),
1796
+ saveUrl: e.urls.save,
1797
+ detailUrl: e.urls.detail,
1798
+ isFormSaving: f(!1),
1799
+ isFormLoading: f(!1)
1800
+ }
1801
+ }), nt = (e, t, a) => {
1802
+ const s = {
1803
+ ...y.GridOption,
1804
+ tableSize: f(y.GridOption.tableSize.value),
1805
+ selectable: f(y.GridOption.selectable.value),
1806
+ searchBar: f(y.GridOption.searchBar.value),
1807
+ pageSize: f(y.GridOption.pageSize.value),
1808
+ rowExpand: f(y.GridOption.rowExpand.value),
1809
+ buttons: f([...y.GridOption.buttons.value]),
1810
+ tools: [...y.GridOption.tools],
1811
+ operates: [...y.GridOption.operates],
1812
+ columns: f(a || []),
1813
+ reload: f(!1),
1814
+ pageNo: f(1),
1815
+ total: f(0),
1816
+ page: t,
1817
+ selectKeys: f([]),
1818
+ selectRows: f([]),
1819
+ rowData: f(void 0),
1820
+ gridQuery: {},
1821
+ tableData: Ve(void 0),
1822
+ expandRows: f({}),
1823
+ isGridLoading: f(!1),
1824
+ isGridSaving: f(!1),
1825
+ gridUrl: e.urls.list || e.urls.find,
1826
+ updateUrl: e.urls.update,
1827
+ deleteUrl: e.urls.delete
1828
+ };
1829
+ return T(
1830
+ () => s.reload.value,
1831
+ (r) => {
1832
+ r && (setTimeout(() => {
1833
+ s.reload.value = !1;
1834
+ }, 1), s.remotePage ? aa(s) : tt(s));
1835
+ }
1836
+ ), {
1837
+ gridCtrl: s
1838
+ };
1839
+ }, zt = (e, t) => {
1840
+ const a = {
1841
+ ...y.TreeOption,
1842
+ reload: f(!1),
1843
+ page: t,
1844
+ node: f(void 0),
1845
+ url: e.urls.tree,
1846
+ data: Ve(void 0),
1847
+ isTreeLoading: f(!1)
1848
+ };
1849
+ return T(
1850
+ () => a.reload.value,
1851
+ (s) => {
1852
+ s && (setTimeout(() => {
1853
+ a.reload.value = !1;
1854
+ }, 1), Ka(a));
1855
+ }
1856
+ ), {
1857
+ treeCtrl: a
1858
+ };
1859
+ }, Wt = (e, t, a) => {
1860
+ for (const o in e.urls)
1861
+ e.urls[o] && (e.urls[o].api || (e.urls[o].api = e.api), e.urls[o].authorize === void 0 && (e.urls[o].authorize = e.authorize));
1862
+ const s = {
1863
+ ...y.PageOption,
1864
+ ...e
1865
+ }, { editorCtrl: r } = rt(e, s, t, a), { gridCtrl: n } = nt(e, s);
1866
+ return s.editor = r, s.grid = n, n.editor = r, n.tools = ["Reload", "RowHeight", "TableHeadset", "Fullscreen"], r.grid = n, {
1867
+ pageCtrl: s,
1868
+ editorCtrl: r,
1869
+ gridCtrl: n
1870
+ };
1871
+ };
1872
+ var sa = /* @__PURE__ */ ((e) => (e.SelectReload = "Select.Reload", e.RadioReload = "Radio.Reload", e.CheckboxReload = "Checkbox.Reload", e.TreeSelectReload = "TreeSelect.Reload", e.TreeCheckReload = "TreeCheck.Reload", e))(sa || {});
1873
+ class ot {
1874
+ constructor() {
1875
+ P(this, "listeners", {});
1876
+ }
1877
+ // 检查事件名是否符合前缀
1878
+ isValidPrefix(t) {
1879
+ return Object.values(sa).some((a) => t.startsWith(a + "."));
1880
+ }
1881
+ /**
1882
+ * 事件订阅
1883
+ * @param event 事件名
1884
+ * @param listener 处理器
1885
+ */
1886
+ on(t, a) {
1887
+ if (!this.isValidPrefix(t)) {
1888
+ console.error(`事件前缀不正确: ${t}`);
1889
+ return;
1890
+ }
1891
+ this.listeners[t] || (this.listeners[t] = []), this.listeners[t].push(a);
1892
+ }
1893
+ /**
1894
+ * 取消订阅事件
1895
+ * @param event 事件名
1896
+ * @param listener 处理器
1897
+ */
1898
+ off(t, a) {
1899
+ if (!this.isValidPrefix(t)) {
1900
+ console.error(`事件前缀不正确: ${t}`);
1901
+ return;
1902
+ }
1903
+ this.listeners[t] && (this.listeners[t] = this.listeners[t].filter((s) => s !== a));
1904
+ }
1905
+ //
1906
+ /**
1907
+ * 触发事件
1908
+ * @param event 事件名
1909
+ * @param args 参数
1910
+ */
1911
+ emit(t, ...a) {
1912
+ if (!this.isValidPrefix(t)) {
1913
+ console.error(`事件前缀不正确: ${t}`);
1914
+ return;
1915
+ }
1916
+ this.listeners[t] && this.listeners[t].forEach((s) => s(t, ...a));
1917
+ }
1918
+ }
1919
+ const ee = new ot(), ce = (e, t, a, s, r, n) => {
1920
+ if (s && t.reloadEvent && (s.reloadHandler = (o, i) => {
1921
+ it(r, t, i, a);
1922
+ }, ee.on(t.reloadEvent, s.reloadHandler)), t.data)
1923
+ T(
1924
+ () => t.data,
1925
+ () => {
1926
+ Me(t, t.data, a, !0);
1927
+ },
1928
+ { deep: !0, immediate: !0 }
1929
+ );
1930
+ else if (r && r.url)
1931
+ e !== !1 && ra(r, t, n ?? {}, a);
1932
+ else {
1933
+ const o = f(G($.LabelText, ""));
1934
+ S.error("`" + o.value + "` 未配置选项数据!", {
1935
+ duration: 5e3
1936
+ });
1937
+ }
1938
+ }, Me = (e, t, a, s) => {
1939
+ if (!t || t.length === 0) {
1940
+ a.value = [];
1941
+ return;
1942
+ }
1943
+ if (s) {
1944
+ const r = {
1945
+ ...e.fieldMap
1946
+ };
1947
+ t = ba(r, t);
1948
+ }
1949
+ t = JSON.parse(JSON.stringify(t)), e.all && t.unshift({
1950
+ label: "全部",
1951
+ value: void 0
1952
+ }), a.value = t;
1953
+ }, it = (e, t, a, s) => {
1954
+ Array.isArray(a) ? Me(t, a, s, !0) : ra(e, t, { Query: a }, s);
1955
+ }, fe = (e, t) => {
1956
+ t && e.reloadEvent && t.reloadHandler && ee.off(e.reloadEvent, t.reloadHandler);
1957
+ }, ra = (e, t, a, s) => {
1958
+ const r = Te(e.params, a, t.params);
1959
+ lt(e, t.fieldMap, r).then((n) => {
1960
+ Me(t, n, s, !1);
1961
+ });
1962
+ }, lt = (e, t, a) => {
1963
+ const { fieldMap: s, ...r } = e, o = {
1964
+ ...{
1965
+ url: "",
1966
+ cacheTime: 6e4,
1967
+ fieldMap: {
1968
+ ...t,
1969
+ ...e.fieldMap
1970
+ }
1971
+ },
1972
+ ...r
1973
+ };
1974
+ return o.loadingText = !1, a || (a = {}), a.Query || (a.Query = {}), _(o, a).then((i) => (i == null ? void 0 : i.status) === A.SUCCESS && i.data ? i.data : []);
1975
+ }, ut = (e, t) => {
1976
+ if (e !== void 0)
1977
+ return Array.isArray(e) ? t.filter((a) => e.includes(a.value)) : t.find((a) => a.value === e);
1978
+ }, be = (e, t, a) => {
1979
+ const s = t.split(".");
1980
+ let r = e;
1981
+ for (let n = 0; n < s.length - 1; n++) {
1982
+ const o = s[n];
1983
+ r[o] || (r[o] = {}), r = r[o];
1984
+ }
1985
+ r[s[s.length - 1]] = a;
1986
+ }, na = (e, t, a) => {
1987
+ if (a == null) {
1988
+ Object.entries(t).forEach(([s]) => {
1989
+ be(e, s, a);
1990
+ });
1991
+ return;
1992
+ }
1993
+ Array.isArray(a) || Object.entries(t).forEach(([s, r]) => {
1994
+ if (r.includes("${")) {
1995
+ const n = Sa(r, a);
1996
+ be(e, s, n);
1997
+ } else
1998
+ be(e, s, a[r]);
1999
+ });
2000
+ }, pe = (e, t, a, s) => {
2001
+ var n;
2002
+ s.editorCtrl && ((n = s.errInfo) != null && n.value.errClass) && le(s.editorCtrl);
2003
+ const r = ut(t, a.value);
2004
+ return e.formData && e.outFields && na(e.formData, e.outFields, r), e.changeEvent && (Array.isArray(e.changeEvent) ? e.changeEvent.every((o) => {
2005
+ ee.emit(o, t, r);
2006
+ }) : ee.emit(e.changeEvent, t, r)), s.inputEmit && s.inputEmit("change", t, r), r;
2007
+ }, de = (e) => e === void 0 ? [] : Array.isArray(e) ? e.map((t) => t.label) : [e.label], Yt = (e, t, a, s) => {
2008
+ oa(e, [], a, s).forEach((n) => t.push(n));
2009
+ }, oa = (e, t, a, s) => {
2010
+ var o, i, l, u, c;
2011
+ const r = [], n = Q();
2012
+ for (const p of e) {
2013
+ if (p.redirect || p.path.includes("/login") || p.path.includes("/error") || p.path.includes("/:page(.*)") || (i = (o = p.meta) == null ? void 0 : o.roles) != null && i.length && !n.hasRole(p.meta.roles) && (l = p.meta) != null && l.permission && !n.hasPermit(p.meta.permission, ":page"))
2014
+ continue;
2015
+ const h = p.path.split("/");
2016
+ h.unshift(...t);
2017
+ const v = oa(p.children || [], h, a, s), w = {
2018
+ key: h.join("/"),
2019
+ label: ((u = p.name) == null ? void 0 : u.toString()) ?? "",
2020
+ title: ((c = p.name) == null ? void 0 : c.toString()) ?? "",
2021
+ icon: p.icon ? D(a, { ...s, icon: p.icon }) : void 0,
2022
+ children: v.length > 0 ? v : void 0
2023
+ };
2024
+ (v.length > 0 || !p.children) && r.push(w);
2025
+ }
2026
+ return r;
2027
+ }, He = fa([]), Xt = () => {
2028
+ He.length = 0;
2029
+ const e = N();
2030
+ let a = ke().TabActive;
2031
+ e.matchedRoutes(a).forEach((r, n) => {
2032
+ var i;
2033
+ const o = {
2034
+ index: n,
2035
+ path: r.path,
2036
+ breadcrumbName: ((i = r.name) == null ? void 0 : i.toString()) ?? ""
2037
+ };
2038
+ He.push(o);
2039
+ });
2040
+ }, ct = {
2041
+ host: {
2042
+ api: "SITEHOST_API",
2043
+ url: "/openapi/RCSiteHostSrv/get",
2044
+ fieldMap: {
2045
+ hostId: "Id",
2046
+ hostName: "Title"
2047
+ },
2048
+ loadingText: "站点配置加载中……",
2049
+ // 不显示错误
2050
+ hideErrorToast: !0
2051
+ }
2052
+ }, Zt = Y("hostInfo", {
2053
+ state: () => ({
2054
+ hostInfo: {
2055
+ Host: "",
2056
+ Title: "",
2057
+ API_HOST: {},
2058
+ SERVER_HOST: {},
2059
+ ExtraProps: {},
2060
+ ExtraPropLines: []
2061
+ }
2062
+ }),
2063
+ actions: {
2064
+ /**
2065
+ * 加载站点信息,如加载失败,则使用本地缓存或默认参数
2066
+ * @param hostApi 启动配置主机地址
2067
+ * @param hostKey 站点信息,默认为当前主域名
2068
+ * @param mainOpenApis 宿主机开放接口
2069
+ */
2070
+ async loadHostInfo(e, t, a) {
2071
+ if (a) {
2072
+ this._setHostInfo(a.getHostInfo());
2073
+ return;
2074
+ }
2075
+ return new Promise((s) => {
2076
+ ve.SITEHOST_API || (ve.SITEHOST_API = e);
2077
+ const r = t || window.location.origin;
2078
+ _(ct.host, {
2079
+ Query: {
2080
+ Host: r
2081
+ }
2082
+ }).then((n) => {
2083
+ if ((n == null ? void 0 : n.status) === A.SUCCESS && n.data) {
2084
+ const o = n.data;
2085
+ this._setHostInfo(o);
2086
+ }
2087
+ s();
2088
+ });
2089
+ });
2090
+ },
2091
+ /**
2092
+ * 设置主机信息(私有方法)
2093
+ */
2094
+ _setHostInfo(e) {
2095
+ if (this.hostInfo = {
2096
+ ...this.hostInfo,
2097
+ ...e
2098
+ }, this.hostInfo.API_HOST)
2099
+ for (const t in this.hostInfo.API_HOST) ve[t] = this.hostInfo.API_HOST[t];
2100
+ if (this.hostInfo.SERVER_HOST)
2101
+ for (const t in this.hostInfo.SERVER_HOST) Ia[t] = this.hostInfo.SERVER_HOST[t];
2102
+ },
2103
+ getHostInfo() {
2104
+ return this.hostInfo;
2105
+ }
2106
+ },
2107
+ // 使用自定义数据缓存
2108
+ persist: !1
2109
+ // persist: {
2110
+ // key: HOSTINFO_STORE_KEY,
2111
+ // storage: localStorage,
2112
+ // pick: ['hostInfo'],
2113
+ // },
2114
+ }), ft = xa();
2115
+ ft.use(Ea);
2116
+ export {
2117
+ Gt as $,
2118
+ F as A,
2119
+ Jt as B,
2120
+ rt as C,
2121
+ nt as D,
2122
+ zt as E,
2123
+ Wt as F,
2124
+ ut as G,
2125
+ na as H,
2126
+ pe as I,
2127
+ de as J,
2128
+ At as K,
2129
+ Tt as L,
2130
+ La as M,
2131
+ Ma as N,
2132
+ L as O,
2133
+ $ as P,
2134
+ Yt as Q,
2135
+ He as R,
2136
+ Xt as S,
2137
+ ze as T,
2138
+ Kt as U,
2139
+ We as V,
2140
+ $t as W,
2141
+ Ft as X,
2142
+ Pe as Y,
2143
+ Dt as Z,
2144
+ Ot as _,
2145
+ Ut as a,
2146
+ st as a0,
2147
+ ta as a1,
2148
+ qt as a2,
2149
+ Mt as a3,
2150
+ Je as a4,
2151
+ _a as a5,
2152
+ sa as a6,
2153
+ ee as a7,
2154
+ ft as a8,
2155
+ V as a9,
2156
+ Z as aa,
2157
+ N as ab,
2158
+ Zt as ac,
2159
+ ke as ad,
2160
+ z as ae,
2161
+ Ct as b,
2162
+ Rt as c,
2163
+ Nt as d,
2164
+ jt as e,
2165
+ Bt as f,
2166
+ Qt as g,
2167
+ Ht as h,
2168
+ ue as i,
2169
+ fe as j,
2170
+ le as k,
2171
+ ce as l,
2172
+ aa as m,
2173
+ tt as n,
2174
+ _t as o,
2175
+ Vt as p,
2176
+ Ka as q,
2177
+ U as r,
2178
+ ne as s,
2179
+ Se as t,
2180
+ wt as u,
2181
+ Pt as v,
2182
+ kt as w,
2183
+ Lt as x,
2184
+ Oe as y,
2185
+ Q as z
2186
+ };