@skyfox2000/webui 1.2.8 → 1.2.10

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