@skyfox2000/webui 1.2.0 → 1.2.2

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