@skyfox2000/webui 1.3.4 → 1.3.6

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 (55) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/lib/assets/modules/{file-upload-BBlFaIXB.js → file-upload-DhPgqGdk.js} +50 -50
  3. package/lib/assets/modules/index-02J2AYth.js +377 -0
  4. package/lib/assets/modules/{index-m5rogIyM.js → index-C31q4LHC.js} +2 -2
  5. package/lib/assets/modules/{index-BG1SqSVl.js → index-CCpTizF9.js} +1 -1
  6. package/lib/assets/modules/{menuTabs-tPIz4a89.js → menuTabs-DyhSKN9r.js} +2 -2
  7. package/lib/assets/modules/{toolIcon-DwWoD9TN.js → toolIcon-CqM4gBIc.js} +1 -1
  8. package/lib/assets/modules/{uploadList-D_Z-Y2tw.js → uploadList-DAVjJkqz.js} +511 -476
  9. package/lib/assets/modules/{uploadList-Da7mQUNK.js → uploadList-ZajZKqaS.js} +4 -4
  10. package/lib/components/common/alert/index.vue.d.ts +13 -0
  11. package/lib/components/common/icon/helper.vue.d.ts +1 -0
  12. package/lib/components/common/index.d.ts +2 -0
  13. package/lib/components/content/form/formItem.vue.d.ts +1 -0
  14. package/lib/components/content/table/index.vue.d.ts +95 -4
  15. package/lib/components/form/input/index.vue.d.ts +4 -1
  16. package/lib/components/form/select/index.vue.d.ts +2 -0
  17. package/lib/components/form/treeSelect/index.vue.d.ts +11 -2
  18. package/lib/components/index.d.ts +1 -1
  19. package/lib/es/AceEditor/index.js +3 -3
  20. package/lib/es/BasicLayout/index.js +3 -3
  21. package/lib/es/Error403/index.js +1 -1
  22. package/lib/es/Error404/index.js +1 -1
  23. package/lib/es/ExcelForm/index.js +317 -274
  24. package/lib/es/UploadForm/index.js +4 -4
  25. package/lib/index.d.ts +1 -1
  26. package/lib/typings/form.d.ts +2 -2
  27. package/lib/typings/option.d.ts +2 -2
  28. package/lib/utils/excel-preview.d.ts +24 -0
  29. package/lib/utils/form-excel.d.ts +17 -4
  30. package/lib/utils/options.d.ts +2 -2
  31. package/lib/webui.css +1 -1
  32. package/lib/webui.es.js +759 -747
  33. package/package.json +1 -1
  34. package/src/components/common/alert/index.vue +76 -0
  35. package/src/components/common/icon/helper.vue +7 -1
  36. package/src/components/common/index.ts +4 -1
  37. package/src/components/common/loading/index.vue +1 -1
  38. package/src/components/content/dialog/excelForm.vue +343 -313
  39. package/src/components/content/form/formItem.vue +6 -2
  40. package/src/components/content/table/index.vue +9 -6
  41. package/src/components/form/autoComplete/index.vue +9 -3
  42. package/src/components/form/cascader/index.vue +8 -6
  43. package/src/components/form/input/index.vue +16 -3
  44. package/src/components/form/select/index.vue +5 -11
  45. package/src/components/form/treeSelect/index.vue +22 -17
  46. package/src/components/index.ts +1 -0
  47. package/src/index.ts +1 -0
  48. package/src/typings/form.d.ts +2 -2
  49. package/src/typings/option.d.ts +2 -2
  50. package/src/utils/excel-preview.ts +188 -0
  51. package/src/utils/file-upload.ts +0 -2
  52. package/src/utils/form-excel.ts +132 -126
  53. package/src/utils/options.ts +80 -22
  54. package/src/utils/table.ts +15 -2
  55. package/lib/assets/modules/index-4kDAt8nS.js +0 -333
@@ -1,333 +0,0 @@
1
- import D from "async-validator";
2
- import { httpPost as S, ResStatus as T } from "@skyfox2000/fapi";
3
- import { i as _, ag as j } from "./uploadList-D_Z-Y2tw.js";
4
- import d from "vue-m-message";
5
- import { defineComponent as C, useAttrs as V, createElementBlock as A, openBlock as U, createVNode as O, unref as F, mergeProps as B } from "vue";
6
- import { Spin as H } from "ant-design-vue";
7
- const k = (u) => {
8
- const o = u.split(`
9
- `).filter((i) => i.trim() !== "");
10
- if (o.length === 0)
11
- return { headers: [], rows: [] };
12
- const s = o.map((i) => i.split(",").map((r) => {
13
- const e = r.trim();
14
- if (e === "" || e === "null") return null;
15
- const t = Number(e);
16
- return isNaN(t) ? e : t;
17
- })), a = s[0].map((i) => String(i || "")), l = s.slice(1);
18
- return { headers: a, rows: l };
19
- }, z = async (u) => {
20
- try {
21
- const o = await import("exceljs"), s = new o.default.Workbook();
22
- await s.xlsx.load(u);
23
- const a = s.worksheets[0];
24
- if (!a)
25
- return { headers: [], rows: [] };
26
- const l = [], i = [];
27
- return a.getRow(1).eachCell((r) => {
28
- let e = "";
29
- r.value !== null && r.value !== void 0 && (typeof r.value == "object" ? "richText" in r.value && Array.isArray(r.value.richText) ? e = r.value.richText.map((t) => t.text || "").join("") : "text" in r.value && typeof r.value.text == "string" ? e = r.value.text : r.value instanceof Date ? e = r.value.toLocaleDateString() : e = String(r.value) : e = String(r.value)), l.push(e);
30
- }), a.eachRow((r, e) => {
31
- if (e > 1) {
32
- const t = [];
33
- l.forEach((n, c) => {
34
- const h = r.getCell(c + 1).value;
35
- h != null ? typeof h == "object" ? "richText" in h && Array.isArray(h.richText) ? t.push(h.richText.map((p) => p.text || "").join("")) : "text" in h && typeof h.text == "string" ? t.push(h.text) : (h instanceof Date, t.push(h)) : t.push(h) : t.push(null);
36
- }), i.push(t);
37
- }
38
- }), { headers: l, rows: i };
39
- } catch (o) {
40
- return console.error("Excel解析失败:", o), { headers: [], rows: [] };
41
- }
42
- }, m = async (u, o, s) => {
43
- try {
44
- const a = await import("exceljs"), l = new a.default.Workbook(), i = l.addWorksheet("Sheet1"), { headers: r, rows: e } = u;
45
- if (r.length === 0)
46
- throw new Error("数据为空");
47
- const t = /* @__PURE__ */ new Map();
48
- s != null && s.markCells && s.markCells.forEach(({ row: p, col: w, color: x }) => {
49
- const E = `${p}-${w}`;
50
- t.set(E, x || "FFFF0000");
51
- });
52
- const n = i.getRow(1);
53
- r.forEach((p, w) => {
54
- const x = n.getCell(w + 1);
55
- x.value = p, x.font = { bold: !0 }, x.fill = {
56
- type: "pattern",
57
- pattern: "solid",
58
- fgColor: { argb: "FFE0E0E0" }
59
- }, s != null && s.markHeaders && s.markHeaders.includes(p) && (x.fill = {
60
- type: "pattern",
61
- pattern: "solid",
62
- fgColor: { argb: "FFFF0000" }
63
- }, x.font = {
64
- name: "Arial",
65
- size: 10,
66
- bold: !0,
67
- color: { argb: "FFFFFFFF" }
68
- });
69
- }), e.forEach((p, w) => {
70
- const x = i.getRow(w + 2);
71
- p.forEach((E, b) => {
72
- const y = x.getCell(b + 1);
73
- y.value = E;
74
- const v = `${w + 2}-${b + 1}`;
75
- t.has(v) && (y.fill = {
76
- type: "pattern",
77
- pattern: "solid",
78
- fgColor: { argb: t.get(v) }
79
- });
80
- });
81
- }), i.columns.forEach((p) => {
82
- p.width = 15;
83
- });
84
- const c = await l.xlsx.writeBuffer(), f = new Blob([c], {
85
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
86
- });
87
- return {
88
- success: !0,
89
- blobUrl: URL.createObjectURL(f),
90
- fileName: o.replace(/\.(csv|xlsx?)$/i, ".xlsx")
91
- };
92
- } catch (a) {
93
- return console.error("转换Excel失败:", a), {
94
- success: !1,
95
- error: a instanceof Error ? a.message : "未知错误"
96
- };
97
- }
98
- }, N = async (u, o) => {
99
- try {
100
- const s = k(u);
101
- return await m(s, o);
102
- } catch (s) {
103
- return {
104
- success: !1,
105
- error: s instanceof Error ? s.message : "CSV处理失败"
106
- };
107
- }
108
- }, M = async (u, o) => {
109
- try {
110
- const s = new Blob([u], {
111
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
112
- });
113
- return {
114
- success: !0,
115
- blobUrl: URL.createObjectURL(s),
116
- fileName: o
117
- };
118
- } catch (s) {
119
- return {
120
- success: !1,
121
- error: s instanceof Error ? s.message : "Excel处理失败"
122
- };
123
- }
124
- }, $ = async (u, o) => await m(u, o), X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
125
- __proto__: null,
126
- csvToExcelView: N,
127
- csvToNormalized: k,
128
- excelToExcelView: M,
129
- excelToNormalized: z,
130
- normalizedToExcelView: $,
131
- toExcel: m
132
- }, Symbol.toStringTag, { value: "Module" })), g = async (u) => {
133
- const o = await import("exceljs"), s = new o.default.Workbook();
134
- await s.xlsx.load(u);
135
- const a = s.worksheets[0];
136
- if (!a)
137
- return d.error("Excel文件不包含工作表"), null;
138
- const l = [], i = [], r = [];
139
- return a.getRow(1).eachCell((e) => {
140
- let t = "";
141
- if (e.value !== null && e.value !== void 0)
142
- if (typeof e.value == "object")
143
- if ("richText" in e.value && Array.isArray(e.value.richText))
144
- t = e.value.richText.map((n) => n.text || "").join("");
145
- else if ("text" in e.value && typeof e.value.text == "string")
146
- t = e.value.text;
147
- else if (e.value instanceof Date)
148
- t = e.value.toLocaleDateString();
149
- else
150
- try {
151
- t = JSON.stringify(e.value);
152
- } catch {
153
- t = String(e.value);
154
- }
155
- else
156
- t = String(e.value);
157
- l.push(t);
158
- }), a.eachRow((e, t) => {
159
- if (t > 1) {
160
- const n = {}, c = [];
161
- l.forEach((f, h) => {
162
- if (f) {
163
- const w = e.getCell(h + 1).value;
164
- w != null ? typeof w == "object" ? "richText" in w && Array.isArray(w.richText) ? n[f] = w.richText.map((x) => x.text || "").join("") : "text" in w && typeof w.text == "string" ? n[f] = w.text : (w instanceof Date, n[f] = w) : n[f] = w : n[f] = null, c.push(n[f]);
165
- }
166
- }), i.push(n), r.push(c);
167
- }
168
- }), { workbook: s, worksheet: a, headers: l, excelData: i, excelRows: r };
169
- }, R = async (u, o, s) => {
170
- const a = await g(u);
171
- if (!a)
172
- return { success: !1, error: "Excel文件处理失败" };
173
- const { headers: l, excelRows: i } = a, { markHeaders: r } = o, e = [...l];
174
- r && r.length > 0 && r.forEach((n) => {
175
- e.includes(n) || e.push(n);
176
- });
177
- const t = i.map((n) => {
178
- const c = [...n];
179
- for (; c.length < e.length; )
180
- c.push(null);
181
- return c;
182
- });
183
- return await m({ headers: e, rows: t }, s, o);
184
- }, Y = async (u, o) => {
185
- if (!o || _(o))
186
- return { hasError: !1 };
187
- const s = await g(u);
188
- if (!s) return { hasError: !0 };
189
- const { headers: a, excelData: l } = s, i = [];
190
- if (Object.keys(o).forEach((t) => {
191
- a.includes(t) || i.push(t);
192
- }), a.length === 0 || l.length === 0)
193
- return d.error("Excel文件不包含足够的数据"), { hasError: !0 };
194
- const r = new D({});
195
- r.messages(j.messages()), r.define(o);
196
- const e = await L(a, l, r);
197
- if (e.length > 0 || i.length > 0) {
198
- const t = e.map((c) => ({
199
- row: c.row + 2,
200
- // 转为Excel行号(+2是因为表头占一行,且是1-based索引)
201
- col: c.col + 1,
202
- // 转为Excel列号(+1是因为是1-based索引)
203
- color: "FFFF0000"
204
- // 红色
205
- })), n = await R(
206
- u,
207
- {
208
- markCells: t,
209
- markHeaders: i
210
- },
211
- "validation_errors.xlsx"
212
- );
213
- return n.success && n.blobUrl ? { hasError: !0, errBlob: await (await fetch(n.blobUrl)).blob() } : { hasError: !0 };
214
- }
215
- return { hasError: !1 };
216
- }, L = async (u, o, s) => {
217
- const a = [];
218
- for (let l = 0; l < o.length; l++) {
219
- const i = o[l];
220
- try {
221
- await s.validate(i).catch(({ errors: r }) => {
222
- const e = [];
223
- r.forEach((t) => {
224
- const n = u.indexOf(t.field);
225
- n >= 0 && (e.some((f) => f.row === l && f.col === n) || e.push({
226
- row: l,
227
- col: n,
228
- header: t.field,
229
- message: t.message.replace("${label}", u[n])
230
- }));
231
- }), a.push(...e);
232
- });
233
- } catch (r) {
234
- console.error("验证表格数据时发生错误:", r), d.error("验证表格数据时发生错误:" + r);
235
- }
236
- }
237
- return a;
238
- }, Z = async (u, o, s) => {
239
- if (!o || o.length === 0)
240
- return { hasError: !1 };
241
- const a = await g(u);
242
- if (!a) return { hasError: !0 };
243
- const { headers: l, excelData: i } = a, r = [];
244
- if (o.forEach((c) => {
245
- l.includes(c) || r.push(c);
246
- }), r.length > 0)
247
- return d.error(`表头缺少重复检测所需字段: ${r.join(", ")}`), { hasError: !0 };
248
- const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = new Array();
249
- if (i.forEach((c, f) => {
250
- const h = o.map((p) => c[p]).join("|");
251
- n.push(h), e.has(h) ? (t.add(f), t.add(e.get(h))) : e.set(h, f);
252
- }), s) {
253
- const c = await S(s, {
254
- Data: n
255
- });
256
- if (c != null && c.data && c.data.forEach((f) => {
257
- t.add(f);
258
- }), (c == null ? void 0 : c.status) === T.ERROR)
259
- throw new Error(c.msg);
260
- }
261
- if (t.size > 0) {
262
- const c = [];
263
- t.forEach((h) => {
264
- o.forEach((p) => {
265
- const w = l.indexOf(p);
266
- w >= 0 && c.push({
267
- row: h + 2,
268
- // Excel行号 = 数组索引 + 2(表头和1-based索引)
269
- col: w + 1,
270
- // Excel列号 = 数组索引 + 1(1-based索引)
271
- color: "FFFF0000"
272
- // 红色
273
- });
274
- });
275
- });
276
- const f = await R(
277
- u,
278
- {
279
- markCells: c,
280
- markHeaders: r
281
- },
282
- "duplicate_errors.xlsx"
283
- );
284
- return f.success && f.blobUrl ? { hasError: !0, errBlob: await (await fetch(f.blobUrl)).blob() } : { hasError: !0 };
285
- }
286
- return { hasError: !1 };
287
- }, I = async (u, o, s) => {
288
- const a = u.originFileObj;
289
- if (a) {
290
- const l = await a.arrayBuffer(), i = await g(l);
291
- if (!i) {
292
- d.error("上传的文件不是Excel文件");
293
- return;
294
- }
295
- const { headers: r, excelRows: e, excelData: t } = i;
296
- s && s.length > 0 ? s.forEach((n) => {
297
- switch (n) {
298
- case "Headers":
299
- o.Headers = r;
300
- break;
301
- case "RawRows":
302
- o.RawRows = e;
303
- break;
304
- case "Records":
305
- o.Records = t;
306
- break;
307
- }
308
- }) : (o.Headers = r, o.RawRows = e, o.Records = t);
309
- }
310
- }, J = { class: "absolute z-9999 w-full h-full top-0 flex flex-flow row items-center justify-center" }, ee = /* @__PURE__ */ C({
311
- __name: "index",
312
- setup(u) {
313
- const o = V();
314
- return (s, a) => (U(), A("div", J, [
315
- O(F(H), B({ style: { "margin-top": "-10%" } }, F(o)), null, 16)
316
- ]));
317
- }
318
- });
319
- export {
320
- ee as _,
321
- Z as a,
322
- I as b,
323
- N as c,
324
- R as d,
325
- k as e,
326
- z as f,
327
- M as g,
328
- X as h,
329
- $ as n,
330
- g as p,
331
- m as t,
332
- Y as v
333
- };