@skyfox2000/webui 1.2.8 → 1.2.9
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.
- package/lib/assets/modules/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/lib/assets/modules/file-upload-BYIvmkmy.js +204 -0
- package/lib/assets/modules/form-excel-BUX2QW11.js +235 -0
- package/lib/assets/modules/{index-CTVMLeDF.js → index-DcRkhkn2.js} +1 -1
- package/lib/assets/modules/index-jl5Ie2tZ.js +112 -0
- package/lib/assets/modules/{menuTabs-BtOiocOC.js → menuTabs-DY1XBq16.js} +134 -139
- package/lib/assets/modules/{toolIcon-B9Mw9Ktm.js → toolIcon-BDIOj_3l.js} +1 -1
- package/lib/assets/modules/uploadList-BPG5whz7.js +369 -0
- package/lib/assets/modules/{index-D9kzQ23e.js → uploadList-D2Ux4h1N.js} +553 -513
- package/lib/components/common/index.d.ts +2 -0
- package/lib/components/common/loading/index.vue.d.ts +3 -0
- package/lib/components/content/dialog/index.vue.d.ts +1 -0
- package/lib/components/content/drawer/index.vue.d.ts +2 -0
- package/lib/components/content/form/formItem.vue.d.ts +2 -0
- package/lib/components/form/autoComplete/index.vue.d.ts +41 -4
- package/lib/components/form/cascader/index.vue.d.ts +13 -2
- package/lib/components/form/checkbox/index.vue.d.ts +13 -2
- package/lib/components/form/index.d.ts +1 -0
- package/lib/components/form/propEditor/index.vue.d.ts +10 -1
- package/lib/components/form/radio/index.vue.d.ts +13 -2
- package/lib/components/form/select/index.vue.d.ts +13 -2
- package/lib/components/form/upload/uploadList.vue.d.ts +14 -3
- package/lib/components/index.d.ts +2 -2
- package/lib/es/AceEditor/index.js +3 -3
- package/lib/es/BasicLayout/index.js +15 -15
- package/lib/es/Error403/index.js +1 -1
- package/lib/es/Error404/index.js +1 -1
- package/lib/es/ExcelForm/index.js +4 -4
- package/lib/es/UploadForm/index.js +60 -87
- package/lib/index.d.ts +2 -2
- package/lib/typings/form.d.ts +18 -2
- package/lib/typings/option.d.ts +16 -2
- package/lib/typings/page.d.ts +1 -0
- package/lib/utils/file-upload.d.ts +4 -2
- package/lib/utils/form-excel.d.ts +3 -0
- package/lib/webui.css +1 -1
- package/lib/webui.es.js +1085 -1063
- package/package.json +1 -1
- package/scripts/userInput.py +2 -0
- package/src/components/common/index.ts +3 -0
- package/src/components/common/loading/index.vue +11 -0
- package/src/components/content/dialog/index.vue +15 -8
- package/src/components/content/dialog/uploadForm.vue +38 -79
- package/src/components/content/drawer/index.vue +26 -6
- package/src/components/content/form/formItem.vue +21 -5
- package/src/components/content/form/index.vue +4 -2
- package/src/components/content/search/searchItem.vue +1 -1
- package/src/components/form/autoComplete/index.vue +12 -4
- package/src/components/form/cascader/index.vue +1 -1
- package/src/components/form/datePicker/index.vue +1 -1
- package/src/components/form/index.ts +1 -0
- package/src/components/form/input/inputIcon.vue +1 -1
- package/src/components/form/propEditor/index.vue +113 -33
- package/src/components/form/select/index.vue +27 -17
- package/src/components/form/upload/uploadList.vue +174 -34
- package/src/components/index.ts +13 -1
- package/src/directives/permission.ts +2 -2
- package/src/index.ts +3 -1
- package/src/typings/form.d.ts +18 -2
- package/src/typings/option.d.ts +16 -2
- package/src/typings/page.d.ts +1 -0
- package/src/utils/download.ts +1 -1
- package/src/utils/eventbus.ts +1 -1
- package/src/utils/file-upload.ts +75 -14
- package/src/utils/form-excel.ts +50 -1
- package/src/utils/form-validate.ts +18 -1
- package/src/utils/form.ts +3 -1
- package/src/utils/options.ts +38 -12
- package/lib/assets/modules/file-upload-CZO-pMJd.js +0 -176
- package/lib/assets/modules/form-excel-N-2OYqKv.js +0 -211
- package/lib/assets/modules/index-BnHnS9ug.js +0 -111
- package/lib/assets/modules/uploadList-B4LxzsC6.js +0 -210
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var E = (t, r, n) => r in t ? m(t, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[r] = n;
|
|
3
|
+
var d = (t, r, n) => E(t, typeof r != "symbol" ? r + "" : r, n);
|
|
4
|
+
import { hostUrl as v } from "@skyfox2000/fapi";
|
|
5
|
+
import { ac as S, ab as w, u as g } from "./uploadList-D2Ux4h1N.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__ */ ((t) => (t.Pending = "pending", t.Uploading = "uploading", t.Success = "success", t.Error = "error", t.Online = "online", t.Offline = "offline", t))(i || {});
|
|
10
|
+
const U = () => a.value ? a.value.getHostInfo() : S().hostInfo, x = () => a.value && a.value.getAppInfo ? a.value.getAppInfo() : w().appInfo, L = (t) => a.value && a.value.userLogin ? a.value.userLogin(t) : g().login(t, !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, n = 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 = n;
|
|
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, n, c, u, o) {
|
|
52
|
+
if (r.length) {
|
|
53
|
+
if (r.length === 0) {
|
|
54
|
+
p.warning("请选择上传的文件!");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
n.value = !0, await this.uploadFiles(r, o, (f) => {
|
|
58
|
+
let e = !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("保存上传成功的文件!"), e = !0) : p.error("上传结束,部分文件上传失败,取消保存!") : p.error("上传结束,所有文件上传失败!") : (p.success("全部文件上传成功!"), e = !0), n.value = !1, u == null || u(e, f);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 上传多个文件,控制并发数量
|
|
67
|
+
* @param files 文件列表(File[] 或 FileList)
|
|
68
|
+
* @param onProgress 上传进度回调
|
|
69
|
+
* @param onComplete 上传完成回调
|
|
70
|
+
*/
|
|
71
|
+
async uploadFiles(r, n, c) {
|
|
72
|
+
if (!r.length) return;
|
|
73
|
+
const u = Math.min(this.maxConcurrent, r.length), o = [];
|
|
74
|
+
for (const e of r)
|
|
75
|
+
switch (e.status) {
|
|
76
|
+
case i.Success:
|
|
77
|
+
case i.Online:
|
|
78
|
+
case i.Offline:
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
e.status = i.Pending, o.push(e);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
const f = [];
|
|
85
|
+
this.abortController = new AbortController();
|
|
86
|
+
try {
|
|
87
|
+
for (; f.length < u && o.length > 0; ) {
|
|
88
|
+
const e = o.shift();
|
|
89
|
+
if (!e) break;
|
|
90
|
+
f.push(this.handleFileStatus(e, f, o, n));
|
|
91
|
+
}
|
|
92
|
+
await Promise.all(f);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error("上传失败:", e), r.forEach((h) => {
|
|
95
|
+
h.status = i.Error, h.error = e instanceof Error ? e : new Error("上传失败"), n == null || n(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, n, c, u) {
|
|
109
|
+
try {
|
|
110
|
+
await this.uploadFile(r, this.abortController.signal, (o) => {
|
|
111
|
+
r.percent = o, u == null || u(r);
|
|
112
|
+
});
|
|
113
|
+
} catch (o) {
|
|
114
|
+
r.error = o instanceof Error ? o : new Error("上传失败"), console.error(r.error);
|
|
115
|
+
} finally {
|
|
116
|
+
if (c.length > 0) {
|
|
117
|
+
const o = c.shift();
|
|
118
|
+
o && n.push(this.handleFileStatus(o, n, c, u));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 使用 XMLHttpRequest 上传文件
|
|
124
|
+
* @param file 文件对象
|
|
125
|
+
* @param signal 中断信号
|
|
126
|
+
* @param onProgress 上传进度回调
|
|
127
|
+
*/
|
|
128
|
+
async uploadFile(r, n, c) {
|
|
129
|
+
return r.status = i.Uploading, new Promise((u, o) => {
|
|
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 e = new XMLHttpRequest(), h = v(this.urlInfo);
|
|
135
|
+
if (h === !1) return Promise.resolve(r);
|
|
136
|
+
if (e.open("POST", h, !0), this.urlInfo.header && typeof this.urlInfo.header == "object" && Object.entries(this.urlInfo.header).forEach(([s, l]) => {
|
|
137
|
+
e.setRequestHeader(s, l);
|
|
138
|
+
}), this.urlInfo.authorize) {
|
|
139
|
+
const s = b();
|
|
140
|
+
if (!s) {
|
|
141
|
+
o(new Error("未授权或授权过期"));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
e.setRequestHeader("Authorization", "Bearer " + s);
|
|
145
|
+
}
|
|
146
|
+
e.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
|
+
}), e.addEventListener("load", () => {
|
|
152
|
+
if (e.status >= 200 && e.status < 300) {
|
|
153
|
+
const s = e.getResponseHeader("Content-Type");
|
|
154
|
+
if (!s || !s.includes("application/json")) {
|
|
155
|
+
o(new Error("返回的结果不是 JSON 格式"));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
const l = JSON.parse(e.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, o(new Error(I));
|
|
174
|
+
}
|
|
175
|
+
} catch (l) {
|
|
176
|
+
r.status = i.Error, o(new Error("无法解析返回的 JSON 数据: " + l));
|
|
177
|
+
}
|
|
178
|
+
} else
|
|
179
|
+
r.status = i.Error, o(new Error(`上传失败,状态码:${e.status}`));
|
|
180
|
+
}), e.addEventListener("error", () => {
|
|
181
|
+
r.status = i.Error, o(new Error("上传失败,网络异常"));
|
|
182
|
+
}), e.send(f), n.addEventListener("abort", () => {
|
|
183
|
+
e.abort(), o(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,235 @@
|
|
|
1
|
+
import k from "async-validator";
|
|
2
|
+
import { httpPost as J, ResStatus as C } from "@skyfox2000/fapi";
|
|
3
|
+
import { i as N, ae as R } from "./uploadList-D2Ux4h1N.js";
|
|
4
|
+
import E from "vue-m-message";
|
|
5
|
+
const F = async (d) => {
|
|
6
|
+
const o = await import("exceljs"), g = new o.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.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
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as d, useAttrs as f, createElementBlock as u, openBlock as x, createVNode as e, withCtx as n, unref as o, mergeProps as r, renderSlot as p } from "vue";
|
|
2
2
|
import { Button as _ } from "ant-design-vue";
|
|
3
|
-
import { a as P, _ as k } from "./toolIcon-
|
|
3
|
+
import { a as P, _ as k } from "./toolIcon-BDIOj_3l.js";
|
|
4
4
|
const C = /* @__PURE__ */ d({
|
|
5
5
|
inheritAttrs: !1,
|
|
6
6
|
__name: "index",
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { defineComponent as F, provide as _, ref as w, watch as p, onMounted as B, createBlock as n, openBlock as r, unref as a, withCtx as i, createElementVNode as N, renderSlot as b, createVNode as V, createCommentVNode as d, createTextVNode as u, toDisplayString as v } from "vue";
|
|
2
|
+
import { _ as m } from "./index-DcRkhkn2.js";
|
|
3
|
+
import { Modal as D, Space as E } from "ant-design-vue";
|
|
4
|
+
import "@skyfox2000/fapi";
|
|
5
|
+
import { P as M, d as P, o as $, b as K } from "./uploadList-D2Ux4h1N.js";
|
|
6
|
+
import "@skyfox2000/microbase";
|
|
7
|
+
import "vue-m-message";
|
|
8
|
+
import "async-validator";
|
|
9
|
+
import "dayjs";
|
|
10
|
+
import "vue-draggable-next";
|
|
11
|
+
const U = { class: "overflow-y-auto w-full h-full" }, R = /* @__PURE__ */ F({
|
|
12
|
+
__name: "index",
|
|
13
|
+
props: {
|
|
14
|
+
saveText: {},
|
|
15
|
+
saveAsText: {},
|
|
16
|
+
cancelText: {},
|
|
17
|
+
editorCtrl: {},
|
|
18
|
+
dialogSave: { type: Function },
|
|
19
|
+
dialogSaveAs: { type: Function },
|
|
20
|
+
width: {},
|
|
21
|
+
full: { type: Boolean },
|
|
22
|
+
open: { type: Boolean }
|
|
23
|
+
},
|
|
24
|
+
emits: ["update:open"],
|
|
25
|
+
setup(C, { emit: T }) {
|
|
26
|
+
const l = C, e = l.editorCtrl;
|
|
27
|
+
_(M.EditorControl, e);
|
|
28
|
+
const t = w(l.open ?? !1), A = T, h = w(l.width ?? 430);
|
|
29
|
+
p(
|
|
30
|
+
() => e == null ? void 0 : e.visible.value,
|
|
31
|
+
(o) => {
|
|
32
|
+
t.value = o ?? !1;
|
|
33
|
+
}
|
|
34
|
+
), p(
|
|
35
|
+
() => l.open,
|
|
36
|
+
(o) => {
|
|
37
|
+
t.value = o;
|
|
38
|
+
}
|
|
39
|
+
), p(
|
|
40
|
+
() => t.value,
|
|
41
|
+
(o) => {
|
|
42
|
+
A("update:open", o), o || f();
|
|
43
|
+
}
|
|
44
|
+
), B(() => {
|
|
45
|
+
t.value = (e == null ? void 0 : e.visible.value) ?? !1;
|
|
46
|
+
});
|
|
47
|
+
const k = () => {
|
|
48
|
+
l.dialogSave ? l.dialogSave() : e && $(e);
|
|
49
|
+
}, x = () => {
|
|
50
|
+
l.dialogSaveAs ? l.dialogSaveAs() : e && K(e);
|
|
51
|
+
}, f = () => {
|
|
52
|
+
e ? P(e) : t.value = !1;
|
|
53
|
+
};
|
|
54
|
+
return (o, c) => (r(), n(a(D), {
|
|
55
|
+
open: t.value,
|
|
56
|
+
"onUpdate:open": c[0] || (c[0] = (s) => t.value = s),
|
|
57
|
+
wrapClassName: "modal mx-auto min-w-[430px] " + (o.full ? "full-modal w-full" : ""),
|
|
58
|
+
width: h.value
|
|
59
|
+
}, {
|
|
60
|
+
footer: i(() => [
|
|
61
|
+
V(a(E), null, {
|
|
62
|
+
default: i(() => {
|
|
63
|
+
var s, g, S, y;
|
|
64
|
+
return [
|
|
65
|
+
o.cancelText !== "" ? (r(), n(a(m), {
|
|
66
|
+
key: 0,
|
|
67
|
+
onClick: f
|
|
68
|
+
}, {
|
|
69
|
+
default: i(() => [
|
|
70
|
+
u(v(o.cancelText ?? "取消"), 1)
|
|
71
|
+
]),
|
|
72
|
+
_: 1
|
|
73
|
+
})) : d("", !0),
|
|
74
|
+
o.saveAsText !== "" && ((s = a(e)) == null ? void 0 : s.saveAsBtnVisible) !== !1 ? (r(), n(a(m), {
|
|
75
|
+
key: 1,
|
|
76
|
+
onClick: x,
|
|
77
|
+
type: "primary",
|
|
78
|
+
loading: (g = a(e)) == null ? void 0 : g.isFormSaving.value
|
|
79
|
+
}, {
|
|
80
|
+
default: i(() => [
|
|
81
|
+
u(v(o.saveAsText ?? "另存为"), 1)
|
|
82
|
+
]),
|
|
83
|
+
_: 1
|
|
84
|
+
}, 8, ["loading"])) : d("", !0),
|
|
85
|
+
o.saveText !== "" && ((S = a(e)) == null ? void 0 : S.saveBtnVisible) !== !1 ? (r(), n(a(m), {
|
|
86
|
+
key: 2,
|
|
87
|
+
onClick: k,
|
|
88
|
+
type: "primary",
|
|
89
|
+
loading: (y = a(e)) == null ? void 0 : y.isFormSaving.value
|
|
90
|
+
}, {
|
|
91
|
+
default: i(() => [
|
|
92
|
+
u(v(o.saveText ?? "保存"), 1)
|
|
93
|
+
]),
|
|
94
|
+
_: 1
|
|
95
|
+
}, 8, ["loading"])) : d("", !0)
|
|
96
|
+
];
|
|
97
|
+
}),
|
|
98
|
+
_: 1
|
|
99
|
+
})
|
|
100
|
+
]),
|
|
101
|
+
default: i(() => [
|
|
102
|
+
N("div", U, [
|
|
103
|
+
b(o.$slots, "default")
|
|
104
|
+
])
|
|
105
|
+
]),
|
|
106
|
+
_: 3
|
|
107
|
+
}, 8, ["open", "wrapClassName", "width"]));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
export {
|
|
111
|
+
R as _
|
|
112
|
+
};
|