@skyfox2000/webui 1.3.3 → 1.3.5

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 (38) hide show
  1. package/lib/assets/modules/{file-upload-D4Pqs8h3.js → file-upload-C0twqMV5.js} +1 -1
  2. package/lib/assets/modules/{index-V1j9haWy.js → index-C4CryM-R.js} +1 -1
  3. package/lib/assets/modules/index-CKJIxasX.js +333 -0
  4. package/lib/assets/modules/{index-CSnwbbQT.js → index-D1XAa1Uo.js} +2 -2
  5. package/lib/assets/modules/{menuTabs-e8XoJN7m.js → menuTabs-BrYQa4UO.js} +2 -2
  6. package/lib/assets/modules/{toolIcon-BSF7eiPf.js → toolIcon-B-g9pyE4.js} +1 -1
  7. package/lib/assets/modules/{uploadList-DA4TRDWR.js → uploadList-0f2FA_5s.js} +490 -455
  8. package/lib/assets/modules/{uploadList-Bcf7g1bf.js → uploadList-DCWRIxPJ.js} +4 -4
  9. package/lib/components/content/table/index.vue.d.ts +95 -4
  10. package/lib/es/AceEditor/index.js +3 -3
  11. package/lib/es/BasicLayout/index.js +3 -3
  12. package/lib/es/Error403/index.js +1 -1
  13. package/lib/es/Error404/index.js +1 -1
  14. package/lib/es/ExcelForm/index.js +339 -202
  15. package/lib/es/UploadForm/index.js +4 -4
  16. package/lib/index.d.ts +3 -2
  17. package/lib/typings/option.d.ts +2 -2
  18. package/lib/utils/excel-view.d.ts +25 -0
  19. package/lib/utils/form-csv.d.ts +18 -0
  20. package/lib/utils/form-excel.d.ts +2 -13
  21. package/lib/utils/options.d.ts +2 -2
  22. package/lib/webui.css +1 -1
  23. package/lib/webui.es.js +897 -871
  24. package/package.json +2 -2
  25. package/src/components/common/loading/index.vue +1 -1
  26. package/src/components/content/dialog/excelForm.vue +386 -107
  27. package/src/components/content/table/index.vue +9 -6
  28. package/src/components/form/autoComplete/index.vue +9 -3
  29. package/src/components/form/cascader/index.vue +8 -6
  30. package/src/index.ts +25 -2
  31. package/src/typings/option.d.ts +2 -2
  32. package/src/utils/excel-view.ts +340 -0
  33. package/src/utils/form-csv.ts +55 -0
  34. package/src/utils/form-excel.ts +59 -192
  35. package/src/utils/options.ts +80 -22
  36. package/src/utils/table.ts +15 -2
  37. package/vite.config.ts +0 -1
  38. package/lib/assets/modules/form-excel-D1vXB4c4.js +0 -235
@@ -1,235 +0,0 @@
1
- import k from "async-validator";
2
- import { httpPost as J, ResStatus as C } from "@skyfox2000/fapi";
3
- import { i as N, ag as R } from "./uploadList-DA4TRDWR.js";
4
- import E from "vue-m-message";
5
- const F = async (d) => {
6
- const o = await import("exceljs"), g = new o.default.Workbook();
7
- await g.xlsx.load(d);
8
- const c = g.worksheets[0];
9
- if (!c)
10
- return E.error("Excel文件不包含工作表"), null;
11
- const s = [], h = [], i = [];
12
- return c.getRow(1).eachCell((e) => {
13
- let r = "";
14
- if (e.value !== null && e.value !== void 0)
15
- if (typeof e.value == "object")
16
- if ("richText" in e.value && Array.isArray(e.value.richText))
17
- r = e.value.richText.map((a) => a.text || "").join("");
18
- else if ("text" in e.value && typeof e.value.text == "string")
19
- r = e.value.text;
20
- else if (e.value instanceof Date)
21
- r = e.value.toLocaleDateString();
22
- else
23
- try {
24
- r = JSON.stringify(e.value);
25
- } catch {
26
- r = String(e.value);
27
- }
28
- else
29
- r = String(e.value);
30
- s.push(r);
31
- }), c.eachRow((e, r) => {
32
- if (r > 1) {
33
- const a = {}, n = [];
34
- s.forEach((l, y) => {
35
- if (l) {
36
- const m = e.getCell(y + 1).value;
37
- m != null ? typeof m == "object" ? "richText" in m && Array.isArray(m.richText) ? a[l] = m.richText.map((O) => O.text || "").join("") : "text" in m && typeof m.text == "string" ? a[l] = m.text : (m instanceof Date, a[l] = m) : a[l] = m : a[l] = null, n.push(a[l]);
38
- }
39
- }), h.push(a), i.push(n);
40
- }
41
- }), { workbook: g, worksheet: c, headers: s, excelData: h, excelRows: i };
42
- }, b = async (d, o) => {
43
- const g = await import("exceljs"), c = await F(d);
44
- if (!c) return { hasError: !0 };
45
- const { worksheet: s, headers: h } = c, { markCells: i, markHeaders: e } = o;
46
- if (i.length === 0 && (!e || e.length === 0))
47
- return { hasError: !1 };
48
- const r = [...h];
49
- e && e.length > 0 && e.forEach((f) => {
50
- r.includes(f) || r.push(f);
51
- });
52
- const a = new g.default.Workbook(), n = a.addWorksheet("Sheet1"), l = 15, y = /* @__PURE__ */ new Map();
53
- i.forEach(({ row: f, col: p, color: u }) => {
54
- const v = `${f}-${p}`;
55
- y.set(v, u || "FFFF0000");
56
- });
57
- for (let f = 0; f < r.length; f++) {
58
- const p = n.getColumn(f + 1);
59
- if (f < s.columnCount && f < h.length) {
60
- const u = s.getColumn(f + 1);
61
- u && u.width ? p.width = u.width : p.width = l;
62
- } else
63
- p.width = l;
64
- }
65
- const x = n.getRow(1);
66
- r.forEach((f, p) => {
67
- const u = x.getCell(p + 1);
68
- u.value = f;
69
- const v = p < h.length;
70
- if (v && p < s.columnCount) {
71
- const t = s.getRow(1).getCell(p + 1);
72
- t.style && (u.style = JSON.parse(JSON.stringify(t.style))), t.font && (u.font = JSON.parse(JSON.stringify(t.font))), t.alignment && (u.alignment = JSON.parse(JSON.stringify(t.alignment))), t.border && (u.border = JSON.parse(JSON.stringify(t.border))), t.numFmt && (u.numFmt = t.numFmt), t.fill && (u.fill = JSON.parse(JSON.stringify(t.fill)));
73
- }
74
- e && e.includes(f) && !v && (u.fill = {
75
- type: "pattern",
76
- pattern: "solid",
77
- fgColor: { argb: "FFFF0000" }
78
- // 红色背景
79
- }, u.font = {
80
- name: "Arial",
81
- size: 10,
82
- bold: !0,
83
- color: { argb: "FFFFFFFF" }
84
- // 白色文字
85
- });
86
- }), x.commit(), s.eachRow((f, p) => {
87
- if (p > 1) {
88
- const u = n.getRow(p);
89
- for (let v = 0; v < r.length; v++) {
90
- const t = u.getCell(v + 1);
91
- if (v < h.length && v < s.columnCount) {
92
- const w = f.getCell(v + 1);
93
- if (t.value = w.value, t.value !== null && t.value !== void 0 && typeof t.value == "object" && !("richText" in t.value) && !("formula" in t.value) && !("hyperlink" in t.value) && !(t.value instanceof Date))
94
- try {
95
- "text" in t.value && typeof t.value.text == "string" ? t.value = t.value.text : t.value = JSON.stringify(t.value);
96
- } catch {
97
- t.value = String(t.value);
98
- }
99
- w.style && (t.style = JSON.parse(JSON.stringify(w.style))), w.font && (t.font = JSON.parse(JSON.stringify(w.font))), w.alignment && (t.alignment = JSON.parse(JSON.stringify(w.alignment))), w.border && (t.border = JSON.parse(JSON.stringify(w.border))), w.numFmt && (t.numFmt = w.numFmt), w.fill && (t.fill = JSON.parse(JSON.stringify(w.fill)));
100
- const S = `${p}-${v + 1}`;
101
- y.has(S) && (t.fill = {
102
- type: "pattern",
103
- pattern: "solid",
104
- fgColor: { argb: y.get(S) }
105
- });
106
- } else
107
- t.value = null;
108
- }
109
- f.height && (u.height = f.height), f.outlineLevel && (u.outlineLevel = f.outlineLevel), u.commit();
110
- }
111
- });
112
- const m = await a.xlsx.writeBuffer();
113
- return { hasError: !0, errBlob: new Blob([m], {
114
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
115
- }) };
116
- }, W = async (d, o) => {
117
- if (!o || N(o))
118
- return { hasError: !1 };
119
- const g = await F(d);
120
- if (!g) return { hasError: !0 };
121
- const { headers: c, excelData: s } = g, h = [];
122
- if (Object.keys(o).forEach((r) => {
123
- c.includes(r) || h.push(r);
124
- }), c.length === 0 || s.length === 0)
125
- return E.error("Excel文件不包含足够的数据"), { hasError: !0 };
126
- const i = new k({});
127
- i.messages(R.messages()), i.define(o);
128
- const e = await D(c, s, i);
129
- if (e.length > 0 || h.length > 0) {
130
- const r = e.map((a) => ({
131
- row: a.row + 2,
132
- // 转为Excel行号(+2是因为表头占一行,且是1-based索引)
133
- col: a.col + 1,
134
- // 转为Excel列号(+1是因为是1-based索引)
135
- color: "FFFF0000"
136
- // 红色
137
- }));
138
- return b(d, {
139
- markCells: r,
140
- markHeaders: h
141
- });
142
- }
143
- return { hasError: !1 };
144
- }, D = async (d, o, g) => {
145
- const c = [];
146
- for (let s = 0; s < o.length; s++) {
147
- const h = o[s];
148
- try {
149
- await g.validate(h).catch(({ errors: i }) => {
150
- const e = [];
151
- i.forEach((r) => {
152
- const a = d.indexOf(r.field);
153
- a >= 0 && (e.some((l) => l.row === s && l.col === a) || e.push({
154
- row: s,
155
- col: a,
156
- header: r.field,
157
- message: r.message.replace("${label}", d[a])
158
- }));
159
- }), c.push(...e);
160
- });
161
- } catch (i) {
162
- console.error("验证表格数据时发生错误:", i), E.error("验证表格数据时发生错误:" + i);
163
- }
164
- }
165
- return c;
166
- }, $ = async (d, o, g) => {
167
- if (!o || o.length === 0)
168
- return { hasError: !1 };
169
- const c = await F(d);
170
- if (!c) return { hasError: !0 };
171
- const { headers: s, excelData: h } = c, i = [];
172
- if (o.forEach((n) => {
173
- s.includes(n) || i.push(n);
174
- }), i.length > 0)
175
- return E.error(`表头缺少重复检测所需字段: ${i.join(", ")}`), { hasError: !0 };
176
- const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), a = new Array();
177
- if (h.forEach((n, l) => {
178
- const y = o.map((x) => n[x]).join("|");
179
- a.push(y), e.has(y) ? (r.add(l), r.add(e.get(y))) : e.set(y, l);
180
- }), g) {
181
- const n = await J(g, {
182
- Data: a
183
- });
184
- if (n != null && n.data && n.data.forEach((l) => {
185
- r.add(l);
186
- }), (n == null ? void 0 : n.status) === C.ERROR)
187
- throw new Error(n.msg);
188
- }
189
- if (r.size > 0) {
190
- const n = [];
191
- return r.forEach((l) => {
192
- o.forEach((y) => {
193
- const x = s.indexOf(y);
194
- x >= 0 && n.push({
195
- row: l + 2,
196
- // Excel行号 = 数组索引 + 2(表头和1-based索引)
197
- col: x + 1,
198
- // Excel列号 = 数组索引 + 1(1-based索引)
199
- color: "FFFF0000"
200
- // 红色
201
- });
202
- });
203
- }), b(d, { markCells: n, markHeaders: i });
204
- }
205
- return { hasError: !1 };
206
- }, B = async (d, o, g) => {
207
- const c = d.originFileObj;
208
- if (c) {
209
- const s = await c.arrayBuffer(), h = await F(s);
210
- if (!h) {
211
- E.error("上传的文件不是Excel文件");
212
- return;
213
- }
214
- const { headers: i, excelRows: e, excelData: r } = h;
215
- g && g.length > 0 ? g.forEach((a) => {
216
- switch (a) {
217
- case "Headers":
218
- o.Headers = i;
219
- break;
220
- case "RawRows":
221
- o.RawRows = e;
222
- break;
223
- case "Records":
224
- o.Records = r;
225
- break;
226
- }
227
- }) : (o.Headers = i, o.RawRows = e, o.Records = r);
228
- }
229
- };
230
- export {
231
- B as a,
232
- $ as c,
233
- F as p,
234
- W as v
235
- };