@skyfox2000/webui 1.2.1 → 1.2.2
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/.vscode/settings.json +1 -1
- package/lib/assets/modules/download-C3KYmuzo.js +210 -0
- package/lib/assets/modules/file-upload-CMHnVQty.js +179 -0
- package/lib/assets/modules/form-excel-Xre5F1Ez.js +211 -0
- package/lib/assets/modules/hostInfo-DK8lknRe.js +2182 -0
- package/lib/assets/modules/index-htdsukeW.js +109 -0
- package/lib/assets/modules/{index-Civhd8xG.js → index-lc53kVVe.js} +34 -35
- package/lib/assets/modules/{menuTabs-BRYvFWA-.js → menuTabs-CkAkFKU8.js} +50 -49
- package/lib/assets/modules/{index-DmWrkTXX.js → toolIcon-Dpr1pbgl.js} +1 -1
- package/lib/components/common/icon/index.vue.d.ts +1 -1
- package/lib/components/index.d.ts +4 -5
- package/lib/es/AceEditor/index.js +7 -8
- package/lib/es/BasicLayout/index.js +20 -19
- package/lib/es/Error403/index.js +7 -6
- package/lib/es/Error404/index.js +7 -6
- package/lib/es/ExcelForm/index.js +179 -380
- package/lib/es/UploadForm/index.js +24 -25
- package/lib/index.d.ts +1 -0
- package/lib/webui.css +1 -1
- package/lib/webui.es.js +1119 -854
- package/package.json +1 -1
- package/src/components/index.ts +9 -54
- package/src/index.ts +50 -0
- package/vite.config.ts +1 -1
- package/lib/assets/modules/file-upload-CBUcsUnR.js +0 -170
- package/lib/assets/modules/form-validate-CgX7aR7T.js +0 -297
- package/lib/assets/modules/index-DQMdt51R.js +0 -726
- package/lib/assets/modules/settingInfo-BZakNKIN.js +0 -999
- package/lib/assets/modules/uploadList-B7XoxGOh.js +0 -278
|
@@ -1,232 +1,31 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import { Modal as
|
|
4
|
-
import {
|
|
5
|
-
import "../../assets/modules/
|
|
6
|
-
import
|
|
7
|
-
import "
|
|
8
|
-
import b from "vue-m-message";
|
|
9
|
-
import ge from "async-validator";
|
|
1
|
+
import { defineComponent as X, ref as r, watch as V, onMounted as Y, createBlock as ee, openBlock as d, unref as i, withCtx as _, renderSlot as le, createElementVNode as c, createVNode as m, createElementBlock as f, createCommentVNode as M, createTextVNode as O, toDisplayString as F, normalizeClass as ae, Fragment as P, renderList as $ } from "vue";
|
|
2
|
+
import { _ as A } from "../../assets/modules/index-htdsukeW.js";
|
|
3
|
+
import { Modal as te, Upload as I, Alert as G, Space as re } from "ant-design-vue";
|
|
4
|
+
import { ResStatus as oe } from "@skyfox2000/fapi";
|
|
5
|
+
import { Z as se, a4 as ie } from "../../assets/modules/hostInfo-DK8lknRe.js";
|
|
6
|
+
import "vue-draggable-next";
|
|
7
|
+
import n from "vue-m-message";
|
|
10
8
|
import "dayjs";
|
|
11
|
-
import "
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const f = a.worksheets[0];
|
|
17
|
-
if (!f)
|
|
18
|
-
return b.error("Excel文件不包含工作表"), null;
|
|
19
|
-
const s = [], y = [];
|
|
20
|
-
return f.getRow(1).eachCell((t) => {
|
|
21
|
-
let r = "";
|
|
22
|
-
if (t.value !== null && t.value !== void 0)
|
|
23
|
-
if (typeof t.value == "object")
|
|
24
|
-
if ("richText" in t.value && Array.isArray(t.value.richText))
|
|
25
|
-
r = t.value.richText.map((l) => l.text || "").join("");
|
|
26
|
-
else if ("text" in t.value && typeof t.value.text == "string")
|
|
27
|
-
r = t.value.text;
|
|
28
|
-
else if (t.value instanceof Date)
|
|
29
|
-
r = t.value.toLocaleDateString();
|
|
30
|
-
else
|
|
31
|
-
try {
|
|
32
|
-
r = JSON.stringify(t.value);
|
|
33
|
-
} catch {
|
|
34
|
-
r = String(t.value);
|
|
35
|
-
}
|
|
36
|
-
else
|
|
37
|
-
r = String(t.value);
|
|
38
|
-
s.push(r);
|
|
39
|
-
}), f.eachRow((t, r) => {
|
|
40
|
-
if (r > 1) {
|
|
41
|
-
const l = {};
|
|
42
|
-
s.forEach((c, i) => {
|
|
43
|
-
if (c) {
|
|
44
|
-
const n = t.getCell(i + 1).value;
|
|
45
|
-
n != null ? typeof n == "object" ? "richText" in n && Array.isArray(n.richText) ? l[c] = n.richText.map((g) => g.text || "").join("") : "text" in n && typeof n.text == "string" ? l[c] = n.text : (n instanceof Date, l[c] = n) : l[c] = n : l[c] = null;
|
|
46
|
-
}
|
|
47
|
-
}), y.push(l);
|
|
48
|
-
}
|
|
49
|
-
}), { workbook: a, worksheet: f, headers: s, excelData: y };
|
|
50
|
-
}, Z = async (C, o) => {
|
|
51
|
-
const a = await import("exceljs"), f = await K(C);
|
|
52
|
-
if (!f) return { hasError: !0 };
|
|
53
|
-
const { worksheet: s, headers: y } = f, { markCells: t, markHeaders: r } = o;
|
|
54
|
-
if (t.length === 0 && (!r || r.length === 0))
|
|
55
|
-
return { hasError: !1 };
|
|
56
|
-
const l = [...y];
|
|
57
|
-
r && r.length > 0 && r.forEach((v) => {
|
|
58
|
-
l.includes(v) || l.push(v);
|
|
59
|
-
});
|
|
60
|
-
const c = new a.Workbook(), i = c.addWorksheet("Sheet1"), p = 15, n = /* @__PURE__ */ new Map();
|
|
61
|
-
t.forEach(({ row: v, col: F, color: u }) => {
|
|
62
|
-
const w = `${v}-${F}`;
|
|
63
|
-
n.set(w, u || "FFFF0000");
|
|
64
|
-
});
|
|
65
|
-
for (let v = 0; v < l.length; v++) {
|
|
66
|
-
const F = i.getColumn(v + 1);
|
|
67
|
-
if (v < s.columnCount && v < y.length) {
|
|
68
|
-
const u = s.getColumn(v + 1);
|
|
69
|
-
u && u.width ? F.width = u.width : F.width = p;
|
|
70
|
-
} else
|
|
71
|
-
F.width = p;
|
|
72
|
-
}
|
|
73
|
-
const g = i.getRow(1);
|
|
74
|
-
l.forEach((v, F) => {
|
|
75
|
-
const u = g.getCell(F + 1);
|
|
76
|
-
u.value = v;
|
|
77
|
-
const w = F < y.length;
|
|
78
|
-
if (w && F < s.columnCount) {
|
|
79
|
-
const e = s.getRow(1).getCell(F + 1);
|
|
80
|
-
e.style && (u.style = JSON.parse(JSON.stringify(e.style))), e.font && (u.font = JSON.parse(JSON.stringify(e.font))), e.alignment && (u.alignment = JSON.parse(JSON.stringify(e.alignment))), e.border && (u.border = JSON.parse(JSON.stringify(e.border))), e.numFmt && (u.numFmt = e.numFmt), e.fill && (u.fill = JSON.parse(JSON.stringify(e.fill)));
|
|
81
|
-
}
|
|
82
|
-
r && r.includes(v) && !w && (u.fill = {
|
|
83
|
-
type: "pattern",
|
|
84
|
-
pattern: "solid",
|
|
85
|
-
fgColor: { argb: "FFFF0000" }
|
|
86
|
-
// 红色背景
|
|
87
|
-
}, u.font = {
|
|
88
|
-
name: "Arial",
|
|
89
|
-
size: 10,
|
|
90
|
-
bold: !0,
|
|
91
|
-
color: { argb: "FFFFFFFF" }
|
|
92
|
-
// 白色文字
|
|
93
|
-
});
|
|
94
|
-
}), g.commit(), s.eachRow((v, F) => {
|
|
95
|
-
if (F > 1) {
|
|
96
|
-
const u = i.getRow(F);
|
|
97
|
-
for (let w = 0; w < l.length; w++) {
|
|
98
|
-
const e = u.getCell(w + 1);
|
|
99
|
-
if (w < y.length && w < s.columnCount) {
|
|
100
|
-
const h = v.getCell(w + 1);
|
|
101
|
-
if (e.value = h.value, e.value !== null && e.value !== void 0 && typeof e.value == "object" && !("richText" in e.value) && !("formula" in e.value) && !("hyperlink" in e.value) && !(e.value instanceof Date))
|
|
102
|
-
try {
|
|
103
|
-
"text" in e.value && typeof e.value.text == "string" ? e.value = e.value.text : e.value = JSON.stringify(e.value);
|
|
104
|
-
} catch {
|
|
105
|
-
e.value = String(e.value);
|
|
106
|
-
}
|
|
107
|
-
h.style && (e.style = JSON.parse(JSON.stringify(h.style))), h.font && (e.font = JSON.parse(JSON.stringify(h.font))), h.alignment && (e.alignment = JSON.parse(JSON.stringify(h.alignment))), h.border && (e.border = JSON.parse(JSON.stringify(h.border))), h.numFmt && (e.numFmt = h.numFmt), h.fill && (e.fill = JSON.parse(JSON.stringify(h.fill)));
|
|
108
|
-
const A = `${F}-${w + 1}`;
|
|
109
|
-
n.has(A) && (e.fill = {
|
|
110
|
-
type: "pattern",
|
|
111
|
-
pattern: "solid",
|
|
112
|
-
fgColor: { argb: n.get(A) }
|
|
113
|
-
});
|
|
114
|
-
} else
|
|
115
|
-
e.value = null;
|
|
116
|
-
}
|
|
117
|
-
v.height && (u.height = v.height), v.outlineLevel && (u.outlineLevel = v.outlineLevel), u.commit();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
const J = await c.xlsx.writeBuffer();
|
|
121
|
-
return { hasError: !0, errBlob: new Blob([J], {
|
|
122
|
-
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
123
|
-
}) };
|
|
124
|
-
}, xe = async (C, o) => {
|
|
125
|
-
if (!o || se(o))
|
|
126
|
-
return { hasError: !1 };
|
|
127
|
-
const a = await K(C);
|
|
128
|
-
if (!a) return { hasError: !0 };
|
|
129
|
-
const { headers: f, excelData: s } = a, y = [];
|
|
130
|
-
if (Object.keys(o).forEach((l) => {
|
|
131
|
-
f.includes(l) || y.push(l);
|
|
132
|
-
}), f.length === 0 || s.length === 0)
|
|
133
|
-
return b.error("Excel文件不包含足够的数据"), { hasError: !0 };
|
|
134
|
-
const t = new ge({});
|
|
135
|
-
t.messages(ie.messages()), t.define(o);
|
|
136
|
-
const r = await ye(f, s, t);
|
|
137
|
-
if (r.length > 0 || y.length > 0) {
|
|
138
|
-
const l = r.map((c) => ({
|
|
139
|
-
row: c.row + 2,
|
|
140
|
-
// 转为Excel行号(+2是因为表头占一行,且是1-based索引)
|
|
141
|
-
col: c.col + 1,
|
|
142
|
-
// 转为Excel列号(+1是因为是1-based索引)
|
|
143
|
-
color: "FFFF0000"
|
|
144
|
-
// 红色
|
|
145
|
-
}));
|
|
146
|
-
return Z(C, {
|
|
147
|
-
markCells: l,
|
|
148
|
-
markHeaders: y
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return { hasError: !1 };
|
|
152
|
-
}, ye = async (C, o, a) => {
|
|
153
|
-
const f = [];
|
|
154
|
-
for (let s = 0; s < o.length; s++) {
|
|
155
|
-
const y = o[s];
|
|
156
|
-
try {
|
|
157
|
-
await a.validate(y).catch(({ errors: t }) => {
|
|
158
|
-
const r = [];
|
|
159
|
-
t.forEach((l) => {
|
|
160
|
-
const c = C.indexOf(l.field);
|
|
161
|
-
c >= 0 && (r.some((p) => p.row === s && p.col === c) || r.push({
|
|
162
|
-
row: s,
|
|
163
|
-
col: c,
|
|
164
|
-
header: l.field,
|
|
165
|
-
message: l.message.replace("${label}", C[c])
|
|
166
|
-
}));
|
|
167
|
-
}), f.push(...r);
|
|
168
|
-
});
|
|
169
|
-
} catch (t) {
|
|
170
|
-
console.error("验证表格数据时发生错误:", t), b.error("验证表格数据时发生错误:" + t);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return f;
|
|
174
|
-
}, we = async (C, o, a) => {
|
|
175
|
-
if (!o || o.length === 0)
|
|
176
|
-
return { hasError: !1 };
|
|
177
|
-
const f = await K(C);
|
|
178
|
-
if (!f) return { hasError: !0 };
|
|
179
|
-
const { headers: s, excelData: y } = f, t = [];
|
|
180
|
-
if (o.forEach((i) => {
|
|
181
|
-
s.includes(i) || t.push(i);
|
|
182
|
-
}), t.length > 0)
|
|
183
|
-
return b.error(`表头缺少重复检测所需字段: ${t.join(", ")}`), { hasError: !0 };
|
|
184
|
-
const r = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), c = new Array();
|
|
185
|
-
if (y.forEach((i, p) => {
|
|
186
|
-
const n = o.map((g) => i[g]).join("|");
|
|
187
|
-
c.push(n), r.has(n) ? (l.add(p), l.add(r.get(n))) : r.set(n, p);
|
|
188
|
-
}), a) {
|
|
189
|
-
const i = await ve(a, {
|
|
190
|
-
Data: c
|
|
191
|
-
});
|
|
192
|
-
if (i != null && i.data && i.data.forEach((p) => {
|
|
193
|
-
l.add(p);
|
|
194
|
-
}), (i == null ? void 0 : i.status) === Y.ERROR)
|
|
195
|
-
throw new Error(i.msg);
|
|
196
|
-
}
|
|
197
|
-
if (l.size > 0) {
|
|
198
|
-
const i = [];
|
|
199
|
-
return l.forEach((p) => {
|
|
200
|
-
o.forEach((n) => {
|
|
201
|
-
const g = s.indexOf(n);
|
|
202
|
-
g >= 0 && i.push({
|
|
203
|
-
row: p + 2,
|
|
204
|
-
// Excel行号 = 数组索引 + 2(表头和1-based索引)
|
|
205
|
-
col: g + 1,
|
|
206
|
-
// Excel列号 = 数组索引 + 1(1-based索引)
|
|
207
|
-
color: "FFFF0000"
|
|
208
|
-
// 红色
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
}), Z(C, { markCells: i, markHeaders: t });
|
|
212
|
-
}
|
|
213
|
-
return { hasError: !1 };
|
|
214
|
-
}, be = { class: "mb-4 flex items-center" }, Fe = {
|
|
9
|
+
import "@skyfox2000/microbase";
|
|
10
|
+
import { A as ue, p as ne, U as ce } from "../../assets/modules/file-upload-CMHnVQty.js";
|
|
11
|
+
import { p as ve, v as de, c as fe } from "../../assets/modules/form-excel-Xre5F1Ez.js";
|
|
12
|
+
import pe from "@vue-office/excel";
|
|
13
|
+
const me = { class: "mb-4 flex items-center" }, xe = {
|
|
215
14
|
key: 0,
|
|
216
15
|
class: "ml-3 text-gray-600"
|
|
217
|
-
},
|
|
16
|
+
}, ge = { class: "flex gap-4" }, ye = {
|
|
218
17
|
key: 0,
|
|
219
18
|
class: "w-[22%] flex-grow overflow-hidden flex flex-col"
|
|
220
|
-
},
|
|
19
|
+
}, he = { class: "bg-gray-50 p-2 rounded border flex-grow flex flex-col" }, _e = {
|
|
221
20
|
key: 0,
|
|
222
21
|
class: "text-gray-500"
|
|
223
|
-
},
|
|
22
|
+
}, be = {
|
|
224
23
|
key: 1,
|
|
225
24
|
class: "flex flex-col"
|
|
226
|
-
},
|
|
25
|
+
}, we = { class: "overflow-y-auto" }, Ce = { class: "text-[13px] text-gray-600" }, Fe = { class: "pl-5 mt-1 mb-0" }, Ee = {
|
|
227
26
|
key: 0,
|
|
228
27
|
class: "mt-3"
|
|
229
|
-
}, Ue = { class: "text-[12px] text-gray-600 p-1" },
|
|
28
|
+
}, Ue = { class: "text-[12px] text-gray-600 p-1" }, Se = { class: "text-[13px] text-gray-600" }, ke = { class: "pl-5 mt-1 mb-0" }, De = { class: "text-[12px] text-gray-600" }, Pe = /* @__PURE__ */ X({
|
|
230
29
|
__name: "excelForm",
|
|
231
30
|
props: {
|
|
232
31
|
title: {},
|
|
@@ -238,189 +37,189 @@ const K = async (C) => {
|
|
|
238
37
|
excelBatchField: {},
|
|
239
38
|
saveText: {}
|
|
240
39
|
},
|
|
241
|
-
setup(
|
|
242
|
-
const o =
|
|
243
|
-
|
|
244
|
-
() =>
|
|
40
|
+
setup(Q) {
|
|
41
|
+
const o = Q, e = o.excelCtrl, b = r(!1), w = r(""), Z = r([]), x = r(""), E = r(!0), U = r("待验证数据规则"), S = r("warning"), k = r("待验证重复数据"), D = r("warning");
|
|
42
|
+
V(
|
|
43
|
+
() => e.visible.value,
|
|
245
44
|
() => {
|
|
246
|
-
|
|
45
|
+
b.value = e.visible.value;
|
|
247
46
|
}
|
|
248
|
-
),
|
|
249
|
-
() =>
|
|
47
|
+
), V(
|
|
48
|
+
() => b.value,
|
|
250
49
|
() => {
|
|
251
|
-
|
|
50
|
+
e.visible.value = b.value;
|
|
252
51
|
}
|
|
253
52
|
);
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
257
|
-
|
|
53
|
+
const R = r(o.uploadParams), p = r(R.value.uploadUrl), g = r(R.value.duplicateRules), C = r(R.value.duplicateUrl), q = async () => {
|
|
54
|
+
const l = p.value;
|
|
55
|
+
if (!l) {
|
|
56
|
+
n.error("未配置文件上传地址!");
|
|
258
57
|
return;
|
|
259
58
|
}
|
|
260
|
-
if (
|
|
261
|
-
|
|
59
|
+
if (B.value) {
|
|
60
|
+
n.error("表格数据存在验证错误,请修正后再上传!");
|
|
262
61
|
return;
|
|
263
62
|
}
|
|
264
|
-
|
|
63
|
+
e.isFormLoading.value = !0;
|
|
265
64
|
try {
|
|
266
|
-
if (!
|
|
267
|
-
|
|
65
|
+
if (!z.value || !x.value) {
|
|
66
|
+
n.warning("请先选择Excel文件!"), e.isFormLoading.value = !1;
|
|
268
67
|
return;
|
|
269
68
|
}
|
|
270
|
-
const
|
|
69
|
+
const a = new ue(l, 1), s = new File([z.value], x.value, {
|
|
271
70
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
272
|
-
}),
|
|
71
|
+
}), t = ne.join(R.value.basePath, x.value), v = {
|
|
273
72
|
uid: "1",
|
|
274
|
-
name:
|
|
275
|
-
originFileObj:
|
|
276
|
-
status:
|
|
73
|
+
name: x.value,
|
|
74
|
+
originFileObj: s,
|
|
75
|
+
status: ce.Uploading,
|
|
277
76
|
percent: 0,
|
|
278
77
|
params: {
|
|
279
|
-
FileKey:
|
|
78
|
+
FileKey: t
|
|
280
79
|
}
|
|
281
|
-
},
|
|
80
|
+
}, y = new AbortController();
|
|
282
81
|
try {
|
|
283
|
-
await
|
|
284
|
-
|
|
285
|
-
}),
|
|
286
|
-
} catch (
|
|
287
|
-
throw console.error("文件上传错误:",
|
|
82
|
+
await a.uploadFile(v, y.signal, (u) => {
|
|
83
|
+
v.percent = u;
|
|
84
|
+
}), n.success("文件上传成功,开始业务处理!"), H(v);
|
|
85
|
+
} catch (u) {
|
|
86
|
+
throw console.error("文件上传错误:", u), n.error((u == null ? void 0 : u.message) || "文件上传失败,请稍后再试!"), u;
|
|
288
87
|
}
|
|
289
|
-
} catch (
|
|
290
|
-
console.error("上传处理错误:",
|
|
88
|
+
} catch (a) {
|
|
89
|
+
console.error("上传处理错误:", a), n.error("上传处理失败:" + ((a == null ? void 0 : a.message) || "未知错误"));
|
|
291
90
|
} finally {
|
|
292
|
-
|
|
91
|
+
e.isFormLoading.value = !1;
|
|
293
92
|
}
|
|
294
|
-
},
|
|
295
|
-
if (
|
|
93
|
+
}, H = async (l) => {
|
|
94
|
+
if (e.formData.value) {
|
|
296
95
|
if (o.excelBatchField) {
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
const { excelData:
|
|
300
|
-
const
|
|
301
|
-
for (const
|
|
302
|
-
const
|
|
303
|
-
|
|
96
|
+
const t = await ve(z.value);
|
|
97
|
+
if (!t) return null;
|
|
98
|
+
const { excelData: v } = t, y = v.map((u) => {
|
|
99
|
+
const h = {};
|
|
100
|
+
for (const L in u) {
|
|
101
|
+
const j = o.excelFieldMap[L];
|
|
102
|
+
j && (h[j] = u[L]);
|
|
304
103
|
}
|
|
305
|
-
return
|
|
104
|
+
return h;
|
|
306
105
|
});
|
|
307
|
-
|
|
106
|
+
e.formData.value[o.excelBatchField] = y;
|
|
308
107
|
}
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
const
|
|
108
|
+
const a = o.fileField ?? "FileInfo";
|
|
109
|
+
e.formData.value[a] = l, e.beforeSave && e.beforeSave();
|
|
110
|
+
const s = {
|
|
312
111
|
Data: {
|
|
313
|
-
...
|
|
112
|
+
...e.formData.value
|
|
314
113
|
},
|
|
315
114
|
Query: {
|
|
316
|
-
[o.excelCtrl.primaryKey]:
|
|
115
|
+
[o.excelCtrl.primaryKey]: e.formData.value[o.excelCtrl.primaryKey]
|
|
317
116
|
}
|
|
318
117
|
};
|
|
319
|
-
|
|
118
|
+
e.isFormLoading.value = !0;
|
|
320
119
|
try {
|
|
321
|
-
const
|
|
322
|
-
params:
|
|
120
|
+
const t = await ie(o.excelCtrl, {
|
|
121
|
+
params: s,
|
|
323
122
|
urlKey: "save",
|
|
324
123
|
url: o.excelCtrl.saveUrl
|
|
325
124
|
});
|
|
326
|
-
(
|
|
327
|
-
} catch (
|
|
328
|
-
console.error("保存错误:",
|
|
125
|
+
(t == null ? void 0 : t.status) === oe.SUCCESS ? (n.success("数据保存成功!"), e.afterSave && e.afterSave(), e.visible.value = !1) : n.error("保存失败:" + ((t == null ? void 0 : t.msg) || "未知错误"));
|
|
126
|
+
} catch (t) {
|
|
127
|
+
console.error("保存错误:", t), n.error("数据保存失败,请稍后再试!");
|
|
329
128
|
} finally {
|
|
330
|
-
|
|
129
|
+
e.isFormLoading.value = !1;
|
|
331
130
|
}
|
|
332
131
|
}
|
|
333
|
-
},
|
|
334
|
-
if (!(
|
|
335
|
-
return
|
|
132
|
+
}, B = r(!1), N = r(!1), z = r(null), J = async (l) => {
|
|
133
|
+
if (!(l.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || l.type === "application/vnd.ms-excel"))
|
|
134
|
+
return n.error("只能上传Excel文件!"), I.LIST_IGNORE;
|
|
336
135
|
try {
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
if (
|
|
343
|
-
const { hasError:
|
|
344
|
-
if (
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
|
|
136
|
+
x.value = l.name, B.value = !1, N.value = !1, E.value = !0, U.value = "待验证数据规则", S.value = "warning", k.value = "待验证重复数据", D.value = "warning";
|
|
137
|
+
const s = await l.arrayBuffer();
|
|
138
|
+
z.value = s;
|
|
139
|
+
const t = new FileReader();
|
|
140
|
+
t.readAsDataURL(l), t.onload = async (v) => {
|
|
141
|
+
if (v.target) {
|
|
142
|
+
const { hasError: y, errBlob: u } = await de(s, e.formRules.value);
|
|
143
|
+
if (y) {
|
|
144
|
+
if (u) {
|
|
145
|
+
B.value = !0, E.value = !1, U.value = "数据验证失败", S.value = "error";
|
|
146
|
+
const h = URL.createObjectURL(u);
|
|
147
|
+
w.value = h;
|
|
349
148
|
}
|
|
350
149
|
return;
|
|
351
150
|
} else
|
|
352
|
-
|
|
353
|
-
if (
|
|
151
|
+
U.value = "数据验证成功", S.value = "success";
|
|
152
|
+
if (g.value && g.value.length > 0 && C.value)
|
|
354
153
|
try {
|
|
355
|
-
|
|
356
|
-
const { hasError:
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
154
|
+
C.value.api || (C.value.api = o.gridCtrl.page.api), C.value.authorize === void 0 && (C.value.authorize = o.gridCtrl.page.authorize);
|
|
155
|
+
const { hasError: h, errBlob: L } = await fe(
|
|
156
|
+
s,
|
|
157
|
+
g.value,
|
|
158
|
+
C.value
|
|
360
159
|
);
|
|
361
|
-
if (
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
160
|
+
if (h) {
|
|
161
|
+
if (L) {
|
|
162
|
+
N.value = !0, k.value = "检测到重复数据", D.value = "error";
|
|
163
|
+
const j = URL.createObjectURL(L);
|
|
164
|
+
w.value = j;
|
|
366
165
|
}
|
|
367
166
|
return;
|
|
368
167
|
} else
|
|
369
|
-
|
|
168
|
+
N.value = !1, k.value = "数据验证通过", D.value = "success";
|
|
370
169
|
} catch {
|
|
371
|
-
|
|
170
|
+
k.value = "重复检测异常", D.value = "error";
|
|
372
171
|
}
|
|
373
|
-
|
|
172
|
+
w.value = v.target.result, E.value = !1;
|
|
374
173
|
} else
|
|
375
|
-
|
|
174
|
+
n.error("加载Excel文件失败,请检查文件格式!");
|
|
376
175
|
};
|
|
377
|
-
} catch (
|
|
378
|
-
console.error("Excel处理错误:",
|
|
176
|
+
} catch (s) {
|
|
177
|
+
console.error("Excel处理错误:", s), n.error("Excel文件处理失败,请检查文件格式!"), E.value = !1, U.value = "Excel处理错误", S.value = "error";
|
|
379
178
|
}
|
|
380
179
|
return !1;
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
|
|
180
|
+
}, T = se(e.formRules.value);
|
|
181
|
+
Y(() => {
|
|
182
|
+
const l = o.gridCtrl.page;
|
|
183
|
+
if (p.value = p.value ?? l.urls.upload, !p.value) {
|
|
184
|
+
n.error("未配置文件上传地址!");
|
|
386
185
|
return;
|
|
387
186
|
}
|
|
388
|
-
|
|
389
|
-
for (const
|
|
390
|
-
o.gridCtrl.rowData.value && (
|
|
391
|
-
|
|
187
|
+
p.value.api || (p.value.api = l.api), p.value.authorize === void 0 && (p.value.authorize = l.authorize);
|
|
188
|
+
for (const a in e.formData.value)
|
|
189
|
+
o.gridCtrl.rowData.value && (e.formData.value[a] = o.gridCtrl.rowData.value[a]);
|
|
190
|
+
b.value = e.visible.value;
|
|
392
191
|
});
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
},
|
|
192
|
+
const K = () => {
|
|
193
|
+
e.visible.value = !1;
|
|
194
|
+
}, W = () => {
|
|
396
195
|
console.error("渲染失败");
|
|
397
196
|
};
|
|
398
|
-
return (
|
|
399
|
-
title:
|
|
400
|
-
open:
|
|
401
|
-
"onUpdate:open":
|
|
402
|
-
wrapClassName: ["modal", "mx-auto",
|
|
197
|
+
return (l, a) => (d(), ee(i(te), {
|
|
198
|
+
title: l.title ?? "Excel文件上传",
|
|
199
|
+
open: b.value,
|
|
200
|
+
"onUpdate:open": a[0] || (a[0] = (s) => b.value = s),
|
|
201
|
+
wrapClassName: ["modal", "mx-auto", l.$attrs.width ? "w-[" + l.$attrs.width + "]" : ""].join(" "),
|
|
403
202
|
width: 940,
|
|
404
|
-
onClose:
|
|
203
|
+
onClose: K
|
|
405
204
|
}, {
|
|
406
|
-
footer:
|
|
407
|
-
|
|
408
|
-
default:
|
|
409
|
-
|
|
410
|
-
default:
|
|
411
|
-
|
|
205
|
+
footer: _(() => [
|
|
206
|
+
m(i(re), null, {
|
|
207
|
+
default: _(() => [
|
|
208
|
+
m(i(A), { onClick: K }, {
|
|
209
|
+
default: _(() => a[2] || (a[2] = [
|
|
210
|
+
O("取消")
|
|
412
211
|
])),
|
|
413
212
|
_: 1,
|
|
414
213
|
__: [2]
|
|
415
214
|
}),
|
|
416
|
-
|
|
417
|
-
onClick:
|
|
215
|
+
m(i(A), {
|
|
216
|
+
onClick: q,
|
|
418
217
|
type: "primary",
|
|
419
|
-
loading:
|
|
420
|
-
disabled: !
|
|
218
|
+
loading: i(e).isFormSaving.value,
|
|
219
|
+
disabled: !w.value || B.value || N.value || E.value
|
|
421
220
|
}, {
|
|
422
|
-
default:
|
|
423
|
-
|
|
221
|
+
default: _(() => [
|
|
222
|
+
O(F(l.saveText ?? "上传文件"), 1)
|
|
424
223
|
]),
|
|
425
224
|
_: 1
|
|
426
225
|
}, 8, ["loading", "disabled"])
|
|
@@ -428,19 +227,19 @@ const K = async (C) => {
|
|
|
428
227
|
_: 1
|
|
429
228
|
})
|
|
430
229
|
]),
|
|
431
|
-
default:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
"file-list":
|
|
436
|
-
"before-upload":
|
|
230
|
+
default: _(() => [
|
|
231
|
+
le(l.$slots, "default"),
|
|
232
|
+
c("div", me, [
|
|
233
|
+
m(i(I), {
|
|
234
|
+
"file-list": Z.value,
|
|
235
|
+
"before-upload": J,
|
|
437
236
|
accept: ".xlsx,.xls",
|
|
438
237
|
showUploadList: !0
|
|
439
238
|
}, {
|
|
440
|
-
default:
|
|
441
|
-
|
|
442
|
-
default:
|
|
443
|
-
|
|
239
|
+
default: _(() => [
|
|
240
|
+
m(i(A), { type: "primary" }, {
|
|
241
|
+
default: _(() => a[1] || (a[1] = [
|
|
242
|
+
O("选择Excel文件")
|
|
444
243
|
])),
|
|
445
244
|
_: 1,
|
|
446
245
|
__: [1]
|
|
@@ -448,18 +247,18 @@ const K = async (C) => {
|
|
|
448
247
|
]),
|
|
449
248
|
_: 1
|
|
450
249
|
}, 8, ["file-list"]),
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
])) :
|
|
250
|
+
w.value && x.value ? (d(), f("div", xe, [
|
|
251
|
+
c("span", null, F(x.value), 1)
|
|
252
|
+
])) : M("", !0)
|
|
454
253
|
]),
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
class:
|
|
254
|
+
c("div", ge, [
|
|
255
|
+
c("div", {
|
|
256
|
+
class: ae(["flex-shrink-0 excel-container", [i(T).length === 0 ? "w-[100%]" : "w-[80%]"]]),
|
|
458
257
|
style: { height: "430px" }
|
|
459
258
|
}, [
|
|
460
|
-
|
|
461
|
-
src:
|
|
462
|
-
onError:
|
|
259
|
+
m(i(pe), {
|
|
260
|
+
src: w.value,
|
|
261
|
+
onError: W,
|
|
463
262
|
style: { width: "100%", height: "100%" },
|
|
464
263
|
options: {
|
|
465
264
|
styles: !0,
|
|
@@ -471,46 +270,46 @@ const K = async (C) => {
|
|
|
471
270
|
}
|
|
472
271
|
}, null, 8, ["src"])
|
|
473
272
|
], 2),
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
message:
|
|
479
|
-
type:
|
|
273
|
+
i(T).length > 0 ? (d(), f("div", ye, [
|
|
274
|
+
c("div", he, [
|
|
275
|
+
i(T).length === 0 ? (d(), f("div", _e, "没有设置验证规则")) : (d(), f("div", be, [
|
|
276
|
+
m(i(G), {
|
|
277
|
+
message: U.value,
|
|
278
|
+
type: S.value,
|
|
480
279
|
"show-icon": "",
|
|
481
280
|
class: "mb-2"
|
|
482
281
|
}, null, 8, ["message", "type"]),
|
|
483
|
-
|
|
484
|
-
(
|
|
485
|
-
key:
|
|
282
|
+
c("div", we, [
|
|
283
|
+
(d(!0), f(P, null, $(i(T), (s, t) => (d(), f("div", {
|
|
284
|
+
key: t,
|
|
486
285
|
class: "border-b pb-0"
|
|
487
286
|
}, [
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
(
|
|
491
|
-
key:
|
|
287
|
+
c("div", Ce, F(s.field), 1),
|
|
288
|
+
c("ul", Fe, [
|
|
289
|
+
(d(!0), f(P, null, $(s.rules, (v, y) => (d(), f("li", {
|
|
290
|
+
key: y,
|
|
492
291
|
class: "text-[12px] text-gray-600"
|
|
493
|
-
},
|
|
292
|
+
}, F(v), 1))), 128))
|
|
494
293
|
])
|
|
495
294
|
]))), 128))
|
|
496
295
|
]),
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
message:
|
|
500
|
-
type:
|
|
296
|
+
g.value && g.value.length > 0 ? (d(), f("div", Ee, [
|
|
297
|
+
m(i(G), {
|
|
298
|
+
message: k.value,
|
|
299
|
+
type: D.value,
|
|
501
300
|
"show-icon": "",
|
|
502
301
|
class: "mt-2 mb-2"
|
|
503
302
|
}, null, 8, ["message", "type"]),
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
303
|
+
c("div", Ue, [
|
|
304
|
+
c("div", Se, " 以下" + F(g.value.length > 1 ? "组合" : "字段") + "必须唯一 ", 1),
|
|
305
|
+
c("ul", ke, [
|
|
306
|
+
c("li", De, F(g.value.join(", ")), 1)
|
|
508
307
|
])
|
|
509
308
|
])
|
|
510
|
-
])) :
|
|
309
|
+
])) : M("", !0)
|
|
511
310
|
]))
|
|
512
311
|
])
|
|
513
|
-
])) :
|
|
312
|
+
])) : M("", !0)
|
|
514
313
|
])
|
|
515
314
|
]),
|
|
516
315
|
_: 3
|
|
@@ -518,5 +317,5 @@ const K = async (C) => {
|
|
|
518
317
|
}
|
|
519
318
|
});
|
|
520
319
|
export {
|
|
521
|
-
|
|
320
|
+
Pe as default
|
|
522
321
|
};
|