@skyfox2000/webui 1.5.9 → 1.5.11

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 (64) hide show
  1. package/lib/assets/modules/{baseLayout-DfTxHOFc.js → baseLayout-CRSIlLKU.js} +9 -9
  2. package/lib/assets/modules/file-upload-CrA5-gqr.js +211 -0
  3. package/lib/assets/modules/{index-BwMaOrJT.js → index-CA_H2eOk.js} +1 -1
  4. package/lib/assets/modules/index-CW7dVG4Z.js +372 -0
  5. package/lib/assets/modules/index-Doi0zREW.js +114 -0
  6. package/lib/assets/modules/{menuTabs-DWaBSRNr.js → menuTabs-DRoP9rnS.js} +65 -58
  7. package/lib/assets/modules/{toolIcon-BYnHhAy-.js → toolIcon-CghIoh0a.js} +1 -1
  8. package/lib/assets/modules/{upload-template-BKm9mFq8.js → upload-template-D6r6X3vP.js} +2093 -2197
  9. package/lib/assets/modules/uploadList-CIGuBEpz.js +468 -0
  10. package/lib/const/options.d.ts +6 -20
  11. package/lib/const/stores.d.ts +11 -0
  12. package/lib/es/AceEditor/index.js +70 -70
  13. package/lib/es/BasicLayout/index.js +6 -6
  14. package/lib/es/Error403/index.js +1 -1
  15. package/lib/es/Error404/index.js +1 -1
  16. package/lib/es/ExcelForm/index.js +197 -197
  17. package/lib/es/MenuLayout/index.js +6 -6
  18. package/lib/es/TemplateFile/index.js +5 -5
  19. package/lib/es/UploadForm/index.js +5 -5
  20. package/lib/index.d.ts +2 -1
  21. package/lib/locales/default.d.ts +152 -115
  22. package/lib/utils/tools.d.ts +1 -0
  23. package/lib/webui.css +1 -1
  24. package/lib/webui.es.js +1710 -1568
  25. package/package.json +3 -3
  26. package/src/components/content/dialog/excelForm.vue +2 -2
  27. package/src/components/content/form/formItem.vue +3 -2
  28. package/src/components/content/search/searchItem.vue +3 -2
  29. package/src/components/form/aceEditor/index.vue +5 -3
  30. package/src/components/form/cascader/index.vue +5 -3
  31. package/src/components/form/checkbox/index.vue +1 -1
  32. package/src/components/form/datePicker/index.vue +2 -1
  33. package/src/components/form/input/inputNumber.vue +3 -1
  34. package/src/components/form/input/inputPassword.vue +3 -1
  35. package/src/components/form/propEditor/index.vue +8 -3
  36. package/src/components/form/radio/index.vue +2 -1
  37. package/src/components/form/radio/radioStatus.vue +2 -1
  38. package/src/components/form/switch/index.vue +3 -1
  39. package/src/components/form/timePicker/index.vue +4 -1
  40. package/src/components/form/treeSelect/index.vue +3 -1
  41. package/src/components/form/upload/imageList.vue +8 -8
  42. package/src/components/form/upload/uploadList.vue +6 -8
  43. package/src/components/layout/datetime/index.vue +15 -4
  44. package/src/components/layout/header/language.vue +2 -0
  45. package/src/const/options.ts +76 -52
  46. package/src/const/stores.ts +58 -0
  47. package/src/index.ts +2 -0
  48. package/src/locales/default.ts +160 -123
  49. package/src/locales/en-US.json +4 -4
  50. package/src/locales/index.ts +109 -39
  51. package/src/stores/hostInfo.ts +2 -19
  52. package/src/stores/userInfo.ts +2 -30
  53. package/src/utils/data.ts +1 -1
  54. package/src/utils/excel-preview.ts +10 -10
  55. package/src/utils/excel-view.ts +6 -4
  56. package/src/utils/file-upload.ts +2 -2
  57. package/src/utils/micro-openapis.ts +4 -3
  58. package/src/utils/options.ts +2 -2
  59. package/src/utils/tools.ts +89 -84
  60. package/src/utils/upload-template.ts +2 -1
  61. package/lib/assets/modules/file-upload-DTOdV5vM.js +0 -211
  62. package/lib/assets/modules/index-DUBY49Au.js +0 -114
  63. package/lib/assets/modules/index-M1qERbea.js +0 -381
  64. package/lib/assets/modules/uploadList-CHvr6Hp1.js +0 -472
@@ -1,381 +0,0 @@
1
- import V from "async-validator";
2
- import { httpPost as $, ResStatus as M } from "@skyfox2000/fapi";
3
- import { i as T, $ as m, aD as U, L as z, u as B } from "./upload-template-BKm9mFq8.js";
4
- import E from "vue-m-message";
5
- import { defineComponent as S, useAttrs as A, createElementBlock as O, openBlock as v, createVNode as N, unref as k, mergeProps as D, computed as x, createBlock as _, withCtx as L, normalizeStyle as P } from "vue";
6
- import { Spin as K, Alert as W } from "ant-design-vue";
7
- import { _ as q } from "./toolIcon-BYnHhAy-.js";
8
- const j = (i) => {
9
- const e = i.split(`
10
- `).filter((l) => l.trim() !== "");
11
- if (e.length === 0)
12
- return { headers: [], rows: [] };
13
- const s = e.map((l) => l.split(",").map((r) => {
14
- const o = r.trim();
15
- if (o === "" || o === "null") return null;
16
- const t = Number(o);
17
- return isNaN(t) ? o : t;
18
- })), c = s[0].map((l) => String(l || "")), a = s.slice(1);
19
- return { headers: c, rows: a };
20
- }, H = async (i) => {
21
- try {
22
- const e = await import("exceljs"), s = new e.default.Workbook();
23
- await s.xlsx.load(i);
24
- const c = s.worksheets[0];
25
- if (!c)
26
- return { headers: [], rows: [] };
27
- const a = [], l = [];
28
- return c.getRow(1).eachCell((r) => {
29
- let o = "";
30
- r.value !== null && r.value !== void 0 && (typeof r.value == "object" ? "richText" in r.value && Array.isArray(r.value.richText) ? o = r.value.richText.map((t) => t.text || "").join("") : "text" in r.value && typeof r.value.text == "string" ? o = r.value.text : r.value instanceof Date ? o = r.value.toLocaleDateString() : o = String(r.value) : o = String(r.value)), a.push(o);
31
- }), c.eachRow((r, o) => {
32
- if (o > 1) {
33
- const t = [];
34
- a.forEach((u, n) => {
35
- const f = r.getCell(n + 1).value;
36
- f != null ? typeof f == "object" ? "richText" in f && Array.isArray(f.richText) ? t.push(f.richText.map((h) => h.text || "").join("")) : "text" in f && typeof f.text == "string" ? t.push(f.text) : (f instanceof Date, t.push(f)) : t.push(f) : t.push(null);
37
- }), l.push(t);
38
- }
39
- }), { headers: a, rows: l };
40
- } catch (e) {
41
- return console.error("Excel解析失败:", e), { headers: [], rows: [] };
42
- }
43
- }, g = async (i, e, s) => {
44
- try {
45
- const c = await import("exceljs"), a = new c.default.Workbook(), l = a.addWorksheet("Sheet1"), { headers: r, rows: o } = i;
46
- if (r.length === 0)
47
- throw new Error("数据为空");
48
- const t = /* @__PURE__ */ new Map();
49
- s != null && s.markCells && s.markCells.forEach(({ row: h, col: p, color: d }) => {
50
- const y = `${h}-${p}`;
51
- t.set(y, d || "FFFF0000");
52
- });
53
- const u = l.getRow(1);
54
- r.forEach((h, p) => {
55
- const d = u.getCell(p + 1);
56
- d.value = h, d.font = { bold: !0 }, d.fill = {
57
- type: "pattern",
58
- pattern: "solid",
59
- fgColor: { argb: "FFE0E0E0" }
60
- }, s != null && s.markHeaders && s.markHeaders.includes(h) && (d.fill = {
61
- type: "pattern",
62
- pattern: "solid",
63
- fgColor: { argb: "FFFF0000" }
64
- }, d.font = {
65
- name: "Arial",
66
- size: 10,
67
- bold: !0,
68
- color: { argb: "FFFFFFFF" }
69
- });
70
- }), o.forEach((h, p) => {
71
- const d = l.getRow(p + 2);
72
- h.forEach((y, F) => {
73
- const C = d.getCell(F + 1);
74
- C.value = y;
75
- const R = `${p + 2}-${F + 1}`;
76
- t.has(R) && (C.fill = {
77
- type: "pattern",
78
- pattern: "solid",
79
- fgColor: { argb: t.get(R) }
80
- });
81
- });
82
- }), l.columns.forEach((h) => {
83
- h.width = 15;
84
- });
85
- const n = await a.xlsx.writeBuffer(), w = new Blob([n], {
86
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
87
- });
88
- return {
89
- success: !0,
90
- blobUrl: URL.createObjectURL(w),
91
- fileName: e.replace(/\.(csv|xlsx?)$/i, ".xlsx")
92
- };
93
- } catch (c) {
94
- return console.error("转换Excel失败:", c), {
95
- success: !1,
96
- error: c instanceof Error ? c.message : "未知错误"
97
- };
98
- }
99
- }, J = async (i, e) => {
100
- try {
101
- const s = j(i);
102
- return await g(s, e);
103
- } catch (s) {
104
- return {
105
- success: !1,
106
- error: s instanceof Error ? s.message : "CSV处理失败"
107
- };
108
- }
109
- }, G = async (i, e) => {
110
- try {
111
- const s = new Blob([i], {
112
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
113
- });
114
- return {
115
- success: !0,
116
- blobUrl: URL.createObjectURL(s),
117
- fileName: e
118
- };
119
- } catch (s) {
120
- return {
121
- success: !1,
122
- error: s instanceof Error ? s.message : "Excel处理失败"
123
- };
124
- }
125
- }, Q = async (i, e) => await g(i, e), le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126
- __proto__: null,
127
- csvToExcelView: J,
128
- csvToNormalized: j,
129
- excelToExcelView: G,
130
- excelToNormalized: H,
131
- normalizedToExcelView: Q,
132
- toExcel: g
133
- }, Symbol.toStringTag, { value: "Module" })), b = async (i) => {
134
- const e = await H(i);
135
- if (e.headers.length === 0)
136
- return E.error(m("webui.utils.formExcel.noWorksheet")), null;
137
- const s = [];
138
- return e.rows.forEach((c) => {
139
- const a = {};
140
- e.headers.forEach((l, r) => {
141
- l && (a[l] = c[r]);
142
- }), s.push(a);
143
- }), {
144
- headers: e.headers,
145
- excelData: s,
146
- excelRows: e.rows
147
- };
148
- }, X = async (i, e, s) => {
149
- const c = await b(i);
150
- if (!c)
151
- return { success: !1, error: m("webui.utils.formExcel.processFailed") };
152
- const { headers: a, excelRows: l } = c, { markHeaders: r } = e, o = [...a];
153
- r && r.length > 0 && r.forEach((u) => {
154
- o.includes(u) || o.push(u);
155
- });
156
- const t = l.map((u) => {
157
- const n = [...u];
158
- for (; n.length < o.length; )
159
- n.push(null);
160
- return n;
161
- });
162
- return await g({ headers: o, rows: t }, s, e);
163
- }, Y = async (i, e) => {
164
- if (!e || T(e))
165
- return { hasError: !1 };
166
- const s = await b(i);
167
- if (!s) return { hasError: !0 };
168
- const { headers: c, excelData: a } = s, l = [];
169
- if (Object.keys(e).forEach((t) => {
170
- c.includes(t) || l.push(t);
171
- }), c.length === 0 || a.length === 0)
172
- return E.error(m("webui.utils.formExcel.insufficientData")), { hasError: !0 };
173
- const r = new V({});
174
- r.messages(U.messages()), r.define(e);
175
- const o = await Z(c, a, r);
176
- return o.length > 0 || l.length > 0 ? {
177
- hasError: !0,
178
- markCells: o.map((u) => ({
179
- row: u.row + 2,
180
- // 转为Excel行号(+2是因为表头占一行,且是1-based索引)
181
- col: u.col + 1,
182
- // 转为Excel列号(+1是因为是1-based索引)
183
- color: "FFFF0000"
184
- // 红色
185
- })),
186
- markHeaders: l
187
- } : { hasError: !1 };
188
- }, Z = async (i, e, s) => {
189
- const c = [];
190
- for (let a = 0; a < e.length; a++) {
191
- const l = e[a];
192
- try {
193
- await s.validate(l).catch(({ errors: r }) => {
194
- const o = [];
195
- r.forEach((t) => {
196
- const u = i.indexOf(t.field);
197
- u >= 0 && (o.some((w) => w.row === a && w.col === u) || o.push({
198
- row: a,
199
- col: u,
200
- header: t.field,
201
- message: t.message.replace("${label}", i[u])
202
- }));
203
- }), c.push(...o);
204
- });
205
- } catch (r) {
206
- console.error(m("webui.utils.formExcel.validationError") + ":", r), E.error(m("webui.utils.formExcel.validationError") + ":" + r);
207
- }
208
- }
209
- return c;
210
- }, I = async (i, e, s) => {
211
- if (!e || e.length === 0)
212
- return { hasError: !1 };
213
- const c = await b(i);
214
- if (!c) return { hasError: !0 };
215
- const { headers: a, excelData: l } = c, r = [];
216
- if (e.forEach((n) => {
217
- a.includes(n) || r.push(n);
218
- }), r.length > 0)
219
- return E.error(m("webui.utils.formExcel.missingDuplicateFields") + `: ${r.join(", ")}`), { hasError: !0 };
220
- const o = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), u = new Array();
221
- if (l.forEach((n, w) => {
222
- const f = e.map((d) => n[d]), h = f.join("|");
223
- u.push(h);
224
- const p = f.some((d) => d != null && d !== "");
225
- p && o.has(h) ? (t.add(w), t.add(o.get(h))) : p && o.set(h, w);
226
- }), s) {
227
- const n = await $(s, {
228
- Data: u
229
- });
230
- if ((n == null ? void 0 : n.status) == M.SUCCESS)
231
- (n == null ? void 0 : n.data).forEach((f) => {
232
- t.add(f);
233
- });
234
- else throw (n == null ? void 0 : n.errno) == z ? (B().logout(!1), new Error("登录已过期")) : new Error(n == null ? void 0 : n.msg);
235
- }
236
- if (t.size > 0) {
237
- const n = [];
238
- return t.forEach((w) => {
239
- e.forEach((f) => {
240
- const h = a.indexOf(f);
241
- h >= 0 && n.push({
242
- row: w + 2,
243
- // Excel行号 = 数组索引 + 2(表头和1-based索引)
244
- col: h + 1,
245
- // Excel列号 = 数组索引 + 1(1-based索引)
246
- color: "FFA500"
247
- // 黄橙色
248
- });
249
- });
250
- }), {
251
- hasError: !0,
252
- markCells: n,
253
- markHeaders: r
254
- };
255
- }
256
- return { hasError: !1 };
257
- }, ie = async (i, e, s, c) => {
258
- const a = [], l = [];
259
- let r = !1, o = !1, t = m("webui.utils.formExcel.validationSuccess"), u = m("webui.utils.formExcel.duplicateValidationPending");
260
- const n = await Y(i, e);
261
- if (n.hasError ? (r = !0, t = m("webui.utils.formExcel.validationFailed"), n.markCells && a.push(...n.markCells), n.markHeaders && l.push(...n.markHeaders)) : e && Object.keys(e).length > 0 && (t = m("webui.utils.formExcel.validationPassed")), s && s.length > 0) {
262
- const f = await I(i, s, c);
263
- f.hasError ? (o = !0, u = m("webui.utils.formExcel.duplicateDetected"), f.markCells && f.markCells.forEach((h) => {
264
- const p = a.find(
265
- (d) => d.row === h.row && d.col === h.col
266
- );
267
- p ? p.color = "8B0000" : a.push(h);
268
- }), f.markHeaders && l.push(...f.markHeaders)) : u = m("webui.utils.formExcel.duplicateCheckPassed");
269
- }
270
- if (r || o) {
271
- const f = await X(
272
- i,
273
- {
274
- markCells: a,
275
- markHeaders: l
276
- },
277
- "validation_errors.xlsx"
278
- );
279
- return f.success && f.blobUrl ? {
280
- errBlob: await (await fetch(f.blobUrl)).blob(),
281
- validationMsg: t,
282
- duplicateMsg: u,
283
- hasFormatError: r,
284
- hasDuplicateError: o
285
- } : {
286
- validationMsg: t,
287
- duplicateMsg: u,
288
- hasFormatError: r,
289
- hasDuplicateError: o
290
- };
291
- }
292
- return {
293
- validationMsg: t,
294
- duplicateMsg: u,
295
- hasFormatError: !1,
296
- hasDuplicateError: !1
297
- };
298
- }, ue = async (i, e, s) => {
299
- const c = i.originFileObj;
300
- if (c) {
301
- const a = await c.arrayBuffer(), l = await b(a);
302
- if (!l) {
303
- E.error(m("webui.utils.formExcel.fileNotExcel"));
304
- return;
305
- }
306
- const { headers: r, excelRows: o, excelData: t } = l;
307
- s && s.length > 0 ? s.forEach((u) => {
308
- switch (u) {
309
- case "Headers":
310
- e.Headers = r;
311
- break;
312
- case "RawRows":
313
- e.RawRows = o;
314
- break;
315
- case "Records":
316
- e.Records = t;
317
- break;
318
- }
319
- }) : (e.Headers = r, e.RawRows = o, e.Records = t);
320
- }
321
- }, ee = { class: "absolute z-[9999] w-full h-full top-0 flex flex-flow row items-center justify-center" }, fe = /* @__PURE__ */ S({
322
- __name: "index",
323
- setup(i) {
324
- const e = A();
325
- return (s, c) => (v(), O("div", ee, [
326
- N(k(K), D({ style: { "margin-top": "-10%" } }, k(e)), null, 16)
327
- ]));
328
- }
329
- }), he = /* @__PURE__ */ S({
330
- __name: "index",
331
- props: {
332
- icon: {},
333
- type: { default: "info" },
334
- showIcon: { type: Boolean, default: !0 },
335
- message: {}
336
- },
337
- setup(i) {
338
- const e = i, s = {
339
- success: "#52c41a",
340
- info: "#1890ff",
341
- warning: "#faad14",
342
- error: "#ff4d4f"
343
- }, c = {
344
- success: "icon-success-fill",
345
- info: "icon-info-fill",
346
- warning: "icon-warn-fill",
347
- error: "icon-error-fill"
348
- }, a = x(() => e.type || "info"), l = x(() => s[a.value]), r = x(() => c[a.value]), o = Math.random().toString(36).substring(2, 9), t = x(() => `${o}-${a.value}-${r.value}`);
349
- return (u, n) => (v(), _(k(W), D({
350
- "show-icon": u.showIcon,
351
- type: u.type,
352
- message: u.message
353
- }, u.$attrs), {
354
- icon: L(() => [
355
- (v(), _(q, {
356
- icon: r.value,
357
- style: P({ color: l.value }),
358
- key: t.value
359
- }, null, 8, ["icon", "style"]))
360
- ]),
361
- _: 1
362
- }, 16, ["show-icon", "type", "message"]));
363
- }
364
- });
365
- export {
366
- he as _,
367
- I as a,
368
- ue as b,
369
- J as c,
370
- X as d,
371
- j as e,
372
- H as f,
373
- G as g,
374
- fe as h,
375
- ie as i,
376
- le as j,
377
- Q as n,
378
- b as p,
379
- g as t,
380
- Y as v
381
- };