@skyfox2000/webui 1.3.18 → 1.3.20

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 (131) hide show
  1. package/lib/AceEditor.d.ts +1 -0
  2. package/lib/BasicLayout.d.ts +1 -0
  3. package/lib/Error403.d.ts +1 -0
  4. package/lib/Error404.d.ts +1 -0
  5. package/lib/ExcelForm.d.ts +1 -0
  6. package/lib/MenuLayout.d.ts +1 -0
  7. package/lib/UploadForm.d.ts +1 -0
  8. package/lib/assets/modules/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  9. package/lib/assets/modules/baseLayout-B9dSxkYo.js +79 -0
  10. package/lib/assets/modules/file-upload-JBIvw5Xx.js +204 -0
  11. package/lib/assets/modules/index-BMkaOjBS.js +380 -0
  12. package/lib/assets/modules/index-BOYtm8ib.js +112 -0
  13. package/lib/assets/modules/index-BkChvyed.js +109 -0
  14. package/lib/assets/modules/menuTabs-BFPjaQRI.js +671 -0
  15. package/lib/assets/modules/toolIcon-XOgjdQdO.js +50 -0
  16. package/lib/assets/modules/uploadList-BedljASx.js +2407 -0
  17. package/lib/assets/modules/uploadList-CW7OIDS3.js +382 -0
  18. package/lib/components/common/alert/index.vue.d.ts +13 -0
  19. package/lib/components/common/button/index.vue.d.ts +41 -0
  20. package/lib/components/common/icon/appicon.vue.d.ts +11 -0
  21. package/lib/components/common/icon/fullscreen.vue.d.ts +3 -0
  22. package/lib/components/common/icon/helper.vue.d.ts +23 -0
  23. package/lib/components/common/icon/index.vue.d.ts +243 -0
  24. package/lib/components/common/icon/layoutIcon.vue.d.ts +43 -0
  25. package/lib/components/common/icon/projectIcon.vue.d.ts +59 -0
  26. package/lib/components/common/icon/toolIcon.vue.d.ts +43 -0
  27. package/lib/components/common/index.d.ts +22 -0
  28. package/lib/components/common/loading/index.vue.d.ts +3 -0
  29. package/lib/components/common/tooltip/index.vue.d.ts +21 -0
  30. package/lib/components/content/dialog/index.vue.d.ts +35 -0
  31. package/lib/components/content/drawer/index.vue.d.ts +28 -0
  32. package/lib/components/content/form/formItem.vue.d.ts +28 -0
  33. package/lib/components/content/form/index.vue.d.ts +25 -0
  34. package/lib/components/content/index.d.ts +22 -0
  35. package/lib/components/content/search/index.vue.d.ts +32 -0
  36. package/lib/components/content/search/searchItem.vue.d.ts +23 -0
  37. package/lib/components/content/table/index.vue.d.ts +127 -0
  38. package/lib/components/content/table/tableOperate.vue.d.ts +18 -0
  39. package/lib/components/content/toolbar/icontool.vue.d.ts +7 -0
  40. package/lib/components/content/toolbar/index.vue.d.ts +18 -0
  41. package/lib/components/content/tree/index.vue.d.ts +46 -0
  42. package/lib/components/form/aceEditor/aceConfig.d.ts +8 -0
  43. package/lib/components/form/autoComplete/index.vue.d.ts +101 -0
  44. package/lib/components/form/cascader/index.vue.d.ts +80 -0
  45. package/lib/components/form/checkbox/index.vue.d.ts +100 -0
  46. package/lib/components/form/datePicker/index.vue.d.ts +6 -0
  47. package/lib/components/form/index.d.ts +41 -0
  48. package/lib/components/form/input/index.vue.d.ts +29 -0
  49. package/lib/components/form/input/inputIcon.vue.d.ts +10 -0
  50. package/lib/components/form/input/inputNumber.vue.d.ts +3 -0
  51. package/lib/components/form/input/inputPassword.vue.d.ts +3 -0
  52. package/lib/components/form/propEditor/index.vue.d.ts +15 -0
  53. package/lib/components/form/radio/index.vue.d.ts +105 -0
  54. package/lib/components/form/radio/radioStatus.vue.d.ts +31 -0
  55. package/lib/components/form/rangePicker/index.vue.d.ts +16 -0
  56. package/lib/components/form/select/index.vue.d.ts +119 -0
  57. package/lib/components/form/switch/index.vue.d.ts +76 -0
  58. package/lib/components/form/textarea/index.vue.d.ts +3 -0
  59. package/lib/components/form/timePicker/index.vue.d.ts +6 -0
  60. package/lib/components/form/transfer/index.vue.d.ts +38 -0
  61. package/lib/components/form/transfer/transferTable.vue.d.ts +38 -0
  62. package/lib/components/form/treeSelect/index.vue.d.ts +47 -0
  63. package/lib/components/form/upload/uploadList.vue.d.ts +488 -0
  64. package/lib/components/index.d.ts +4 -0
  65. package/lib/components/layout/breadcrumb/index.vue.d.ts +3 -0
  66. package/lib/components/layout/content/index.vue.d.ts +22 -0
  67. package/lib/components/layout/datetime/index.vue.d.ts +3 -0
  68. package/lib/components/layout/header/headerExits.vue.d.ts +3 -0
  69. package/lib/components/layout/header/index.vue.d.ts +3 -0
  70. package/lib/components/layout/header/user.vue.d.ts +3 -0
  71. package/lib/components/layout/index.d.ts +14 -0
  72. package/lib/components/layout/menu/index.vue.d.ts +6 -0
  73. package/lib/components/layout/menu/menuTabs.vue.d.ts +3 -0
  74. package/lib/const/options.d.ts +32 -0
  75. package/lib/directives/enter-submit.d.ts +4 -0
  76. package/lib/directives/index.d.ts +2 -0
  77. package/lib/directives/permission.d.ts +5 -0
  78. package/lib/es/AceEditor/index.js +167 -0
  79. package/lib/es/BasicLayout/index.js +54 -0
  80. package/lib/es/Error403/index.js +39 -0
  81. package/lib/es/Error404/index.js +39 -0
  82. package/lib/es/ExcelForm/index.js +491 -0
  83. package/lib/es/MenuLayout/index.js +54 -0
  84. package/lib/es/UploadForm/index.js +110 -0
  85. package/lib/index.d.ts +46 -0
  86. package/lib/router/index.d.ts +15 -0
  87. package/lib/stores/appInfo.d.ts +31 -0
  88. package/lib/stores/hostInfo.d.ts +11 -0
  89. package/lib/stores/pageInfo.d.ts +18 -0
  90. package/lib/stores/pinia.d.ts +3 -0
  91. package/lib/stores/settingInfo.d.ts +8 -0
  92. package/lib/stores/userInfo.d.ts +25 -0
  93. package/lib/typings/data.d.ts +80 -0
  94. package/lib/typings/form.d.ts +206 -0
  95. package/lib/typings/menu.d.ts +7 -0
  96. package/lib/typings/option.d.ts +209 -0
  97. package/lib/typings/page.d.ts +70 -0
  98. package/lib/typings/table.d.ts +181 -0
  99. package/lib/typings/tools.d.ts +130 -0
  100. package/lib/typings/tree.d.ts +72 -0
  101. package/lib/typings/upload.d.ts +161 -0
  102. package/lib/typings/urls.d.ts +69 -0
  103. package/lib/utils/cache.d.ts +23 -0
  104. package/lib/utils/data.d.ts +6 -0
  105. package/lib/utils/download.d.ts +6 -0
  106. package/lib/utils/eventbus.d.ts +16 -0
  107. package/lib/utils/excel-preview.d.ts +24 -0
  108. package/lib/utils/excel-view.d.ts +25 -0
  109. package/lib/utils/export-table.d.ts +12 -0
  110. package/lib/utils/file-upload.d.ts +17 -0
  111. package/lib/utils/form-csv.d.ts +18 -0
  112. package/lib/utils/form-excel.d.ts +36 -0
  113. package/lib/utils/form-validate.d.ts +29 -0
  114. package/lib/utils/form.d.ts +9 -0
  115. package/lib/utils/icon-loader.d.ts +125 -0
  116. package/lib/utils/isEmpty.d.ts +1 -0
  117. package/lib/utils/main-openapis.d.ts +8 -0
  118. package/lib/utils/menu.d.ts +6 -0
  119. package/lib/utils/options.d.ts +7 -0
  120. package/lib/utils/page.d.ts +30 -0
  121. package/lib/utils/table.d.ts +21 -0
  122. package/lib/utils/tools.d.ts +18 -0
  123. package/lib/utils/tree.d.ts +3 -0
  124. package/lib/vite-env.d.ts +8 -0
  125. package/lib/webui.css +1 -0
  126. package/lib/webui.es.js +2345 -0
  127. package/package.json +1 -1
  128. package/src/components/layout/page/menuLayout.vue +34 -0
  129. package/vite.config.ts +1 -1
  130. package/.cursorignore +0 -8
  131. package/scripts/userInput.py +0 -2
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,9 @@
1
+ const s = (t, r) => {
2
+ const o = t.__vccOpts || t;
3
+ for (const [c, e] of r)
4
+ o[c] = e;
5
+ return o;
6
+ };
7
+ export {
8
+ s as _
9
+ };
@@ -0,0 +1,79 @@
1
+ import { defineComponent as _, onMounted as I, createBlock as s, openBlock as o, unref as e, withCtx as l, createCommentVNode as r, createVNode as p, createElementVNode as x, createElementBlock as y, toDisplayString as g, renderSlot as h } from "vue";
2
+ import { Layout as i, LayoutSider as k } from "ant-design-vue";
3
+ import { a as b } from "./toolIcon-XOgjdQdO.js";
4
+ import { I as C, _ as S, f as w, d as $, g as N } from "./menuTabs-BFPjaQRI.js";
5
+ import { ad as v, a as B, af as E } from "./uploadList-BedljASx.js";
6
+ import "@skyfox2000/microbase";
7
+ import "@skyfox2000/fapi";
8
+ import L from "vue-m-message";
9
+ import "async-validator";
10
+ import "dayjs";
11
+ import "vue-draggable-next";
12
+ const V = { class: "h-[40px] max-h-[40px] bg-[rgba(240,240,240,0.2)] flex flex-nowrap items-center justify-center text-white font-bold text-lg overflow-hidden text-ellipsis" }, z = {
13
+ key: 0,
14
+ class: "ml-[10px]"
15
+ }, H = /* @__PURE__ */ _({
16
+ __name: "baseLayout",
17
+ props: {
18
+ routes: {}
19
+ },
20
+ setup(f) {
21
+ const m = f, a = v(), t = B(), u = E();
22
+ return I(() => {
23
+ L.closeAll();
24
+ }), (d, c) => (o(), s(e(i), { class: "h-screen" }, {
25
+ default: l(() => [
26
+ e(t).fullscreen ? r("", !0) : (o(), s(e(k), {
27
+ key: 0,
28
+ class: "overflow-auto h-screen left-0 top-0 bottom-0",
29
+ collapsed: e(t).menuCollapse,
30
+ "onUpdate:collapsed": c[0] || (c[0] = (n) => e(t).menuCollapse = n),
31
+ collapsible: ""
32
+ }, {
33
+ default: l(() => [
34
+ x("div", V, [
35
+ p(b, {
36
+ title: e(t).menuCollapse ? e(a).appInfo.Name : "",
37
+ placement: "right"
38
+ }, {
39
+ default: l(() => {
40
+ var n;
41
+ return [
42
+ (n = e(a).appInfo.Icon) != null && n.startsWith("sym-") ? (o(), s(C, {
43
+ key: 0,
44
+ icon: e(a).appInfo.Icon,
45
+ fontsize: "30px",
46
+ size: "26px"
47
+ }, null, 8, ["icon"])) : (o(), s(S, {
48
+ key: 1,
49
+ icon: e(a).appInfo.Icon,
50
+ class: "mx-1"
51
+ }, null, 8, ["icon"]))
52
+ ];
53
+ }),
54
+ _: 1
55
+ }, 8, ["title"]),
56
+ e(t).menuCollapse ? r("", !0) : (o(), y("span", z, g(e(a).appInfo.Name), 1))
57
+ ]),
58
+ p(w, {
59
+ routes: m.routes
60
+ }, null, 8, ["routes"])
61
+ ]),
62
+ _: 1
63
+ }, 8, ["collapsed"])),
64
+ p(e(i), { class: "overflow-y-auto block" }, {
65
+ default: l(() => [
66
+ e(t).fullscreen ? r("", !0) : (o(), s($, { key: 0 })),
67
+ e(u).TabEnabled ? (o(), s(N, { key: 1 })) : r("", !0),
68
+ h(d.$slots, "default")
69
+ ]),
70
+ _: 3
71
+ })
72
+ ]),
73
+ _: 3
74
+ }));
75
+ }
76
+ });
77
+ export {
78
+ H as _
79
+ };
@@ -0,0 +1,204 @@
1
+ var m = Object.defineProperty;
2
+ var E = (e, r, o) => r in e ? m(e, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[r] = o;
3
+ var d = (e, r, o) => E(e, typeof r != "symbol" ? r + "" : r, o);
4
+ import { hostUrl as v } from "@skyfox2000/fapi";
5
+ import { ae as S, ad as w, u as g } from "./uploadList-BedljASx.js";
6
+ import { mainAppApis as a } from "@skyfox2000/microbase";
7
+ import y from "dayjs";
8
+ import p from "vue-m-message";
9
+ var i = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Uploading = "uploading", e.Success = "success", e.Error = "error", e.Online = "online", e.Offline = "offline", e))(i || {});
10
+ const U = () => a.value ? a.value.getHostInfo() : S().hostInfo, x = () => a.value && a.value.getAppInfo ? a.value.getAppInfo() : w().appInfo, L = (e) => a.value && a.value.userLogin ? a.value.userLogin(e) : g().login(e, !0), M = () => a.value && a.value.userLogout ? a.value.userLogout() : g().logout(), b = () => a.value && a.value.getToken ? a.value.getToken() : g().getToken(), N = () => a.value && a.value.getUserInfo ? a.value.getUserInfo() : g().getUserInfo();
11
+ class z {
12
+ /**
13
+ * 连接路径参数,已判断 undefined 或 null 值
14
+ * @param args 路径参数数组
15
+ * @returns 连接后的路径字符串
16
+ */
17
+ static join(...r) {
18
+ return r.filter((u) => u != null).join("/").replace(/[\/]+/, "/");
19
+ }
20
+ }
21
+ class C {
22
+ /**
23
+ * AsyncUploader 构造函数
24
+ * @param urlInfo 文件上传的 API 配置(IUrlInfo 对象)
25
+ * @param maxConcurrent 最大允许并发上传的文件数量
26
+ */
27
+ constructor(r, o = 3) {
28
+ /**
29
+ * 设置 API 端点和最大并发数,所有上传文件通过该类控制
30
+ */
31
+ d(this, "urlInfo");
32
+ /**
33
+ * 最大并发上传数
34
+ */
35
+ d(this, "maxConcurrent");
36
+ /**
37
+ * 控制上传任务的中断信号
38
+ */
39
+ d(this, "abortController");
40
+ this.urlInfo = r, this.maxConcurrent = o;
41
+ }
42
+ /**
43
+ * 执行上传
44
+ * @param fileList 文件列表
45
+ * @param loading 加载状态
46
+ * @param continueOnError 错误时是否继续上传
47
+ * @param onComplete 上传完成回调
48
+ * @param onProgress 上传进度回调
49
+ * @returns 上传结果
50
+ */
51
+ async doUpload(r, o, c, u, n) {
52
+ if (r.length) {
53
+ if (r.length === 0) {
54
+ p.warning("请选择上传的文件!");
55
+ return;
56
+ }
57
+ o.value = !0, await this.uploadFiles(r, n, (f) => {
58
+ let t = !1, h = 0;
59
+ for (const s of f)
60
+ s.status === i.Error && h++;
61
+ h ? h < f.length ? c ? (p.error("上传结束,部分文件上传失败!"), p.warning("保存上传成功的文件!"), t = !0) : p.error("上传结束,部分文件上传失败,取消保存!") : p.error("上传结束,所有文件上传失败!") : (p.success("全部文件上传成功!"), t = !0), o.value = !1, u == null || u(t, f);
62
+ });
63
+ }
64
+ }
65
+ /**
66
+ * 上传多个文件,控制并发数量
67
+ * @param files 文件列表(File[] 或 FileList)
68
+ * @param onProgress 上传进度回调
69
+ * @param onComplete 上传完成回调
70
+ */
71
+ async uploadFiles(r, o, c) {
72
+ if (!r.length) return;
73
+ const u = Math.min(this.maxConcurrent, r.length), n = [];
74
+ for (const t of r)
75
+ switch (t.status) {
76
+ case i.Success:
77
+ case i.Online:
78
+ case i.Offline:
79
+ break;
80
+ default:
81
+ t.status = i.Pending, n.push(t);
82
+ break;
83
+ }
84
+ const f = [];
85
+ this.abortController = new AbortController();
86
+ try {
87
+ for (; f.length < u && n.length > 0; ) {
88
+ const t = n.shift();
89
+ if (!t) break;
90
+ f.push(this.handleFileStatus(t, f, n, o));
91
+ }
92
+ await Promise.all(f);
93
+ } catch (t) {
94
+ r.forEach((h) => {
95
+ h.status = i.Error, h.error = t instanceof Error ? t : new Error("上传失败"), o == null || o(h);
96
+ });
97
+ } finally {
98
+ c == null || c(r);
99
+ }
100
+ }
101
+ /**
102
+ * 处理单个文件的上传逻辑
103
+ * @param file 当前上传的文件
104
+ * @param activeUploads 当前正在上传的文件列表
105
+ * @param pendingFiles 等待上传的文件列表
106
+ * @param onProgress 上传进度回调
107
+ */
108
+ async handleFileStatus(r, o, c, u) {
109
+ try {
110
+ await this.uploadFile(r, this.abortController.signal, (n) => {
111
+ r.percent = n, u == null || u(r);
112
+ });
113
+ } catch (n) {
114
+ r.error = n instanceof Error ? n : new Error("上传失败");
115
+ } finally {
116
+ if (c.length > 0) {
117
+ const n = c.shift();
118
+ n && o.push(this.handleFileStatus(n, o, c, u));
119
+ }
120
+ }
121
+ }
122
+ /**
123
+ * 使用 XMLHttpRequest 上传文件
124
+ * @param file 文件对象
125
+ * @param signal 中断信号
126
+ * @param onProgress 上传进度回调
127
+ */
128
+ async uploadFile(r, o, c) {
129
+ return r.status = i.Uploading, new Promise((u, n) => {
130
+ const f = new FormData();
131
+ if (f.append("file", r.originFileObj), r.params)
132
+ for (const s in r.params)
133
+ f.append(s, r.params[s]);
134
+ const t = new XMLHttpRequest(), h = v(this.urlInfo);
135
+ if (h === !1) return Promise.resolve(r);
136
+ if (t.open("POST", h, !0), this.urlInfo.header && typeof this.urlInfo.header == "object" && Object.entries(this.urlInfo.header).forEach(([s, l]) => {
137
+ t.setRequestHeader(s, l);
138
+ }), this.urlInfo.authorize) {
139
+ const s = b();
140
+ if (!s) {
141
+ n(new Error("未授权或授权过期"));
142
+ return;
143
+ }
144
+ t.setRequestHeader("Authorization", "Bearer " + s);
145
+ }
146
+ t.upload.addEventListener("progress", (s) => {
147
+ if (s.lengthComputable && s.total > 0) {
148
+ const l = Math.round(s.loaded / s.total * 100);
149
+ c(l);
150
+ }
151
+ }), t.addEventListener("load", () => {
152
+ if (t.status >= 200 && t.status < 300) {
153
+ const s = t.getResponseHeader("Content-Type");
154
+ if (!s || !s.includes("application/json")) {
155
+ n(new Error("返回的结果不是 JSON 格式"));
156
+ return;
157
+ }
158
+ try {
159
+ const l = JSON.parse(t.response);
160
+ if (l.status === "success")
161
+ l.data && (r.minioFile = {
162
+ ETag: l.data.ETag,
163
+ Bucket: l.data.Bucket,
164
+ FileName: r.fileName,
165
+ Key: l.data.Key,
166
+ Size: l.data.Size,
167
+ Type: r.type,
168
+ UpdateTime: y().format("YYYY-MM-DD HH:mm:ss"),
169
+ Status: i.Success
170
+ }), r.status = i.Success, u(r);
171
+ else {
172
+ const I = l.msg;
173
+ r.status = i.Error, n(new Error(I));
174
+ }
175
+ } catch (l) {
176
+ r.status = i.Error, n(new Error("无法解析返回的 JSON 数据: " + l));
177
+ }
178
+ } else
179
+ r.status = i.Error, n(new Error(`上传失败,状态码:${t.status}`));
180
+ }), t.addEventListener("error", () => {
181
+ r.status = i.Error, n(new Error("上传失败,网络异常"));
182
+ }), t.send(f), o.addEventListener("abort", () => {
183
+ t.abort(), n(new Error("上传已取消"));
184
+ });
185
+ });
186
+ }
187
+ /**
188
+ * 取消当前所有的上传任务
189
+ */
190
+ cancelUpload() {
191
+ this.abortController && this.abortController.abort();
192
+ }
193
+ }
194
+ export {
195
+ C as A,
196
+ i as U,
197
+ x as a,
198
+ M as b,
199
+ b as c,
200
+ N as d,
201
+ U as g,
202
+ z as p,
203
+ L as u
204
+ };
@@ -0,0 +1,380 @@
1
+ import S from "async-validator";
2
+ import { httpPost as M, ResStatus as V } from "@skyfox2000/fapi";
3
+ import { i as T, ag as $ } from "./uploadList-BedljASx.js";
4
+ import m from "vue-m-message";
5
+ import { defineComponent as R, useAttrs as U, createElementBlock as z, openBlock as b, createVNode as B, unref as v, mergeProps as D, computed as E, createBlock as _, withCtx as O, normalizeStyle as A } from "vue";
6
+ import { Spin as N, Alert as L } from "ant-design-vue";
7
+ import { _ as K } from "./toolIcon-XOgjdQdO.js";
8
+ const j = (i) => {
9
+ const e = i.split(`
10
+ `).filter((c) => c.trim() !== "");
11
+ if (e.length === 0)
12
+ return { headers: [], rows: [] };
13
+ const s = e.map((c) => c.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
+ })), n = s[0].map((c) => String(c || "")), a = s.slice(1);
19
+ return { headers: n, 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 n = s.worksheets[0];
25
+ if (!n)
26
+ return { headers: [], rows: [] };
27
+ const a = [], c = [];
28
+ return n.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
+ }), n.eachRow((r, o) => {
32
+ if (o > 1) {
33
+ const t = [];
34
+ a.forEach((u, l) => {
35
+ const f = r.getCell(l + 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
+ }), c.push(t);
38
+ }
39
+ }), { headers: a, rows: c };
40
+ } catch (e) {
41
+ return console.error("Excel解析失败:", e), { headers: [], rows: [] };
42
+ }
43
+ }, g = async (i, e, s) => {
44
+ try {
45
+ const n = await import("exceljs"), a = new n.default.Workbook(), c = 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: w, color: d }) => {
50
+ const y = `${h}-${w}`;
51
+ t.set(y, d || "FFFF0000");
52
+ });
53
+ const u = c.getRow(1);
54
+ r.forEach((h, w) => {
55
+ const d = u.getCell(w + 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, w) => {
71
+ const d = c.getRow(w + 2);
72
+ h.forEach((y, k) => {
73
+ const F = d.getCell(k + 1);
74
+ F.value = y;
75
+ const C = `${w + 2}-${k + 1}`;
76
+ t.has(C) && (F.fill = {
77
+ type: "pattern",
78
+ pattern: "solid",
79
+ fgColor: { argb: t.get(C) }
80
+ });
81
+ });
82
+ }), c.columns.forEach((h) => {
83
+ h.width = 15;
84
+ });
85
+ const l = await a.xlsx.writeBuffer(), p = new Blob([l], {
86
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
87
+ });
88
+ return {
89
+ success: !0,
90
+ blobUrl: URL.createObjectURL(p),
91
+ fileName: e.replace(/\.(csv|xlsx?)$/i, ".xlsx")
92
+ };
93
+ } catch (n) {
94
+ return console.error("转换Excel失败:", n), {
95
+ success: !1,
96
+ error: n instanceof Error ? n.message : "未知错误"
97
+ };
98
+ }
99
+ }, P = 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
+ }, W = 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), ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126
+ __proto__: null,
127
+ csvToExcelView: P,
128
+ csvToNormalized: j,
129
+ excelToExcelView: W,
130
+ excelToNormalized: H,
131
+ normalizedToExcelView: q,
132
+ toExcel: g
133
+ }, Symbol.toStringTag, { value: "Module" })), x = async (i) => {
134
+ const e = await H(i);
135
+ if (e.headers.length === 0)
136
+ return m.error("Excel文件不包含工作表"), null;
137
+ const s = [];
138
+ return e.rows.forEach((n) => {
139
+ const a = {};
140
+ e.headers.forEach((c, r) => {
141
+ c && (a[c] = n[r]);
142
+ }), s.push(a);
143
+ }), {
144
+ headers: e.headers,
145
+ excelData: s,
146
+ excelRows: e.rows
147
+ };
148
+ }, J = async (i, e, s) => {
149
+ const n = await x(i);
150
+ if (!n)
151
+ return { success: !1, error: "Excel文件处理失败" };
152
+ const { headers: a, excelRows: c } = n, { markHeaders: r } = e, o = [...a];
153
+ r && r.length > 0 && r.forEach((u) => {
154
+ o.includes(u) || o.push(u);
155
+ });
156
+ const t = c.map((u) => {
157
+ const l = [...u];
158
+ for (; l.length < o.length; )
159
+ l.push(null);
160
+ return l;
161
+ });
162
+ return await g({ headers: o, rows: t }, s, e);
163
+ }, G = async (i, e) => {
164
+ if (!e || T(e))
165
+ return { hasError: !1 };
166
+ const s = await x(i);
167
+ if (!s) return { hasError: !0 };
168
+ const { headers: n, excelData: a } = s, c = [];
169
+ if (Object.keys(e).forEach((t) => {
170
+ n.includes(t) || c.push(t);
171
+ }), n.length === 0 || a.length === 0)
172
+ return m.error("Excel文件不包含足够的数据"), { hasError: !0 };
173
+ const r = new S({});
174
+ r.messages($.messages()), r.define(e);
175
+ const o = await Q(n, a, r);
176
+ return o.length > 0 || c.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: c
187
+ } : { hasError: !1 };
188
+ }, Q = async (i, e, s) => {
189
+ const n = [];
190
+ for (let a = 0; a < e.length; a++) {
191
+ const c = e[a];
192
+ try {
193
+ await s.validate(c).catch(({ errors: r }) => {
194
+ const o = [];
195
+ r.forEach((t) => {
196
+ const u = i.indexOf(t.field);
197
+ u >= 0 && (o.some((p) => p.row === a && p.col === u) || o.push({
198
+ row: a,
199
+ col: u,
200
+ header: t.field,
201
+ message: t.message.replace("${label}", i[u])
202
+ }));
203
+ }), n.push(...o);
204
+ });
205
+ } catch (r) {
206
+ console.error("验证表格数据时发生错误:", r), m.error("验证表格数据时发生错误:" + r);
207
+ }
208
+ }
209
+ return n;
210
+ }, X = async (i, e, s) => {
211
+ if (!e || e.length === 0)
212
+ return { hasError: !1 };
213
+ const n = await x(i);
214
+ if (!n) return { hasError: !0 };
215
+ const { headers: a, excelData: c } = n, r = [];
216
+ if (e.forEach((l) => {
217
+ a.includes(l) || r.push(l);
218
+ }), r.length > 0)
219
+ return m.error(`表头缺少重复检测所需字段: ${r.join(", ")}`), { hasError: !0 };
220
+ const o = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), u = new Array();
221
+ if (c.forEach((l, p) => {
222
+ const f = e.map((d) => l[d]), h = f.join("|");
223
+ u.push(h);
224
+ const w = f.some((d) => d != null && d !== "");
225
+ w && o.has(h) ? (t.add(p), t.add(o.get(h))) : w && o.set(h, p);
226
+ }), s) {
227
+ const l = await M(s, {
228
+ Data: u
229
+ });
230
+ if (l != null && l.data && l.data.forEach((p) => {
231
+ t.add(p);
232
+ }), (l == null ? void 0 : l.status) === V.ERROR)
233
+ throw new Error(l.msg);
234
+ }
235
+ if (t.size > 0) {
236
+ const l = [];
237
+ return t.forEach((p) => {
238
+ e.forEach((f) => {
239
+ const h = a.indexOf(f);
240
+ h >= 0 && l.push({
241
+ row: p + 2,
242
+ // Excel行号 = 数组索引 + 2(表头和1-based索引)
243
+ col: h + 1,
244
+ // Excel列号 = 数组索引 + 1(1-based索引)
245
+ color: "FFA500"
246
+ // 黄橙色
247
+ });
248
+ });
249
+ }), {
250
+ hasError: !0,
251
+ markCells: l,
252
+ markHeaders: r
253
+ };
254
+ }
255
+ return { hasError: !1 };
256
+ }, ne = async (i, e, s, n) => {
257
+ const a = [], c = [];
258
+ let r = !1, o = !1, t = "数据验证成功", u = "待验证重复数据";
259
+ const l = await G(i, e);
260
+ if (l.hasError ? (r = !0, t = "数据验证失败", l.markCells && a.push(...l.markCells), l.markHeaders && c.push(...l.markHeaders)) : e && Object.keys(e).length > 0 && (t = "数据验证通过"), s && s.length > 0) {
261
+ const f = await X(i, s, n);
262
+ f.hasError ? (o = !0, u = "检测到重复数据", f.markCells && f.markCells.forEach((h) => {
263
+ const w = a.find(
264
+ (d) => d.row === h.row && d.col === h.col
265
+ );
266
+ w ? w.color = "8B0000" : a.push(h);
267
+ }), f.markHeaders && c.push(...f.markHeaders)) : u = "重复性检验通过";
268
+ }
269
+ if (r || o) {
270
+ const f = await J(
271
+ i,
272
+ {
273
+ markCells: a,
274
+ markHeaders: c
275
+ },
276
+ "validation_errors.xlsx"
277
+ );
278
+ return f.success && f.blobUrl ? {
279
+ errBlob: await (await fetch(f.blobUrl)).blob(),
280
+ validationMsg: t,
281
+ duplicateMsg: u,
282
+ hasFormatError: r,
283
+ hasDuplicateError: o
284
+ } : {
285
+ validationMsg: t,
286
+ duplicateMsg: u,
287
+ hasFormatError: r,
288
+ hasDuplicateError: o
289
+ };
290
+ }
291
+ return {
292
+ validationMsg: t,
293
+ duplicateMsg: u,
294
+ hasFormatError: !1,
295
+ hasDuplicateError: !1
296
+ };
297
+ }, ce = async (i, e, s) => {
298
+ const n = i.originFileObj;
299
+ if (n) {
300
+ const a = await n.arrayBuffer(), c = await x(a);
301
+ if (!c) {
302
+ m.error("上传的文件不是Excel文件");
303
+ return;
304
+ }
305
+ const { headers: r, excelRows: o, excelData: t } = c;
306
+ s && s.length > 0 ? s.forEach((u) => {
307
+ switch (u) {
308
+ case "Headers":
309
+ e.Headers = r;
310
+ break;
311
+ case "RawRows":
312
+ e.RawRows = o;
313
+ break;
314
+ case "Records":
315
+ e.Records = t;
316
+ break;
317
+ }
318
+ }) : (e.Headers = r, e.RawRows = o, e.Records = t);
319
+ }
320
+ }, Y = { class: "absolute z-[9999] w-full h-full top-0 flex flex-flow row items-center justify-center" }, le = /* @__PURE__ */ R({
321
+ __name: "index",
322
+ setup(i) {
323
+ const e = U();
324
+ return (s, n) => (b(), z("div", Y, [
325
+ B(v(N), D({ style: { "margin-top": "-10%" } }, v(e)), null, 16)
326
+ ]));
327
+ }
328
+ }), ie = /* @__PURE__ */ R({
329
+ __name: "index",
330
+ props: {
331
+ icon: {},
332
+ type: { default: "info" },
333
+ showIcon: { type: Boolean, default: !0 },
334
+ message: {}
335
+ },
336
+ setup(i) {
337
+ const e = i, s = {
338
+ success: "#52c41a",
339
+ info: "#1890ff",
340
+ warning: "#faad14",
341
+ error: "#ff4d4f"
342
+ }, n = {
343
+ success: "icon-success-fill",
344
+ info: "icon-info-fill",
345
+ warning: "icon-warn-fill",
346
+ error: "icon-error-fill"
347
+ }, a = E(() => e.type || "info"), c = E(() => s[a.value]), r = E(() => n[a.value]), o = Math.random().toString(36).substring(2, 9), t = E(() => `${o}-${a.value}-${r.value}`);
348
+ return (u, l) => (b(), _(v(L), D({
349
+ "show-icon": u.showIcon,
350
+ type: u.type,
351
+ message: u.message
352
+ }, u.$attrs), {
353
+ icon: O(() => [
354
+ (b(), _(K, {
355
+ icon: r.value,
356
+ style: A({ color: c.value }),
357
+ key: t.value
358
+ }, null, 8, ["icon", "style"]))
359
+ ]),
360
+ _: 1
361
+ }, 16, ["show-icon", "type", "message"]));
362
+ }
363
+ });
364
+ export {
365
+ ie as _,
366
+ X as a,
367
+ ce as b,
368
+ P as c,
369
+ J as d,
370
+ j as e,
371
+ H as f,
372
+ W as g,
373
+ le as h,
374
+ ne as i,
375
+ ae as j,
376
+ q as n,
377
+ x as p,
378
+ g as t,
379
+ G as v
380
+ };