antd-import-export 1.0.0 → 1.0.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/README.md +20 -4
- package/README_EN.md +20 -4
- package/dist/core/excel/runtime.d.ts +3 -3
- package/dist/index.cjs +6 -0
- package/dist/index.mjs +1077 -498
- package/package.json +5 -8
- package/dist/core/excel/worker-url.js +0 -8
- package/dist/core/excel/worker.d.ts +0 -12
- package/dist/core/excel/worker.mjs +0 -119
- package/dist/worksheet-BEUkpIL-.js +0 -467
package/dist/index.mjs
CHANGED
|
@@ -1,126 +1,705 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
1
|
+
import e from "dayjs";
|
|
2
|
+
import t from "decimal.js";
|
|
3
|
+
import { saveAs as n } from "file-saver";
|
|
4
|
+
import r from "exceljs";
|
|
5
|
+
import { useCallback as i, useEffect as a, useMemo as o, useRef as s, useState as c, useSyncExternalStore as l } from "react";
|
|
6
|
+
import { DeleteOutlined as u, DownloadOutlined as d, FileOutlined as f, UploadOutlined as p } from "@ant-design/icons";
|
|
7
|
+
import { App as m, Button as h, Flex as g, Input as _, InputNumber as v, Modal as y, Popover as b, Progress as x, Select as S, Space as C, Table as ee, Tag as w, Tooltip as te, Typography as T, message as E, theme as ne } from "antd";
|
|
8
|
+
import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
9
|
+
// \0rolldown/runtime.js
|
|
10
|
+
var re = Object.create, A = Object.defineProperty, j = Object.getOwnPropertyDescriptor, M = Object.getOwnPropertyNames, ie = Object.getPrototypeOf, ae = Object.prototype.hasOwnProperty, oe = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), N = (e, t, n, r) => {
|
|
11
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = M(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ae.call(e, s) && s !== n && A(e, s, {
|
|
12
|
+
get: ((e) => t[e]).bind(null, s),
|
|
13
|
+
enumerable: !(r = j(t, s)) || r.enumerable
|
|
14
|
+
});
|
|
15
|
+
return e;
|
|
16
|
+
}, se = (e, t, n) => (n = e == null ? {} : re(ie(e)), N(t || !e || !e.__esModule || !ae.call(e, "default") ? A(n, "default", {
|
|
17
|
+
value: e,
|
|
18
|
+
enumerable: !0
|
|
19
|
+
}) : n, e));
|
|
10
20
|
// src/core/schema/index.ts
|
|
11
|
-
function
|
|
21
|
+
function ce(e) {
|
|
12
22
|
return e.filter((e) => e.importable !== !1);
|
|
13
23
|
}
|
|
24
|
+
// src/core/schema/multiValue.ts
|
|
25
|
+
var le = ";", ue = /[;;]/;
|
|
26
|
+
function P(e) {
|
|
27
|
+
return e.map((e) => String(e)).join(";");
|
|
28
|
+
}
|
|
29
|
+
function F(e) {
|
|
30
|
+
return e.split(ue).map((e) => e.trim()).filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
// src/core/schema/validate.ts
|
|
33
|
+
var de = /* @__PURE__ */ se((/* @__PURE__ */ oe(((e, t, n) => {
|
|
34
|
+
(function(n, r) {
|
|
35
|
+
typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs_plugin_customParseFormat = r();
|
|
36
|
+
})(n, (function() {
|
|
37
|
+
var e = {
|
|
38
|
+
LTS: "h:mm:ss A",
|
|
39
|
+
LT: "h:mm A",
|
|
40
|
+
L: "MM/DD/YYYY",
|
|
41
|
+
LL: "MMMM D, YYYY",
|
|
42
|
+
LLL: "MMMM D, YYYY h:mm A",
|
|
43
|
+
LLLL: "dddd, MMMM D, YYYY h:mm A"
|
|
44
|
+
}, t = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, n = /\d/, r = /\d\d/, i = /\d\d?/, a = /\d*[^-_:/,()\s\d]+/, o = {}, s = function(e) {
|
|
45
|
+
return (e = +e) + (e > 68 ? 1900 : 2e3);
|
|
46
|
+
}, c = function(e) {
|
|
47
|
+
return function(t) {
|
|
48
|
+
this[e] = +t;
|
|
49
|
+
};
|
|
50
|
+
}, l = [/[+-]\d\d:?(\d\d)?|Z/, function(e) {
|
|
51
|
+
(this.zone ||= {}).offset = function(e) {
|
|
52
|
+
if (!e || e === "Z") return 0;
|
|
53
|
+
var t = e.match(/([+-]|\d\d)/g), n = 60 * t[1] + (+t[2] || 0);
|
|
54
|
+
return n === 0 ? 0 : t[0] === "+" ? -n : n;
|
|
55
|
+
}(e);
|
|
56
|
+
}], u = function(e) {
|
|
57
|
+
var t = o[e];
|
|
58
|
+
return t && (t.indexOf ? t : t.s.concat(t.f));
|
|
59
|
+
}, d = function(e, t) {
|
|
60
|
+
var n, r = o.meridiem;
|
|
61
|
+
if (r) {
|
|
62
|
+
for (var i = 1; i <= 24; i += 1) if (e.indexOf(r(i, 0, t)) > -1) {
|
|
63
|
+
n = i > 12;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
} else n = e === (t ? "pm" : "PM");
|
|
67
|
+
return n;
|
|
68
|
+
}, f = {
|
|
69
|
+
A: [a, function(e) {
|
|
70
|
+
this.afternoon = d(e, !1);
|
|
71
|
+
}],
|
|
72
|
+
a: [a, function(e) {
|
|
73
|
+
this.afternoon = d(e, !0);
|
|
74
|
+
}],
|
|
75
|
+
Q: [n, function(e) {
|
|
76
|
+
this.month = 3 * (e - 1) + 1;
|
|
77
|
+
}],
|
|
78
|
+
S: [n, function(e) {
|
|
79
|
+
this.milliseconds = 100 * e;
|
|
80
|
+
}],
|
|
81
|
+
SS: [r, function(e) {
|
|
82
|
+
this.milliseconds = 10 * e;
|
|
83
|
+
}],
|
|
84
|
+
SSS: [/\d{3}/, function(e) {
|
|
85
|
+
this.milliseconds = +e;
|
|
86
|
+
}],
|
|
87
|
+
s: [i, c("seconds")],
|
|
88
|
+
ss: [i, c("seconds")],
|
|
89
|
+
m: [i, c("minutes")],
|
|
90
|
+
mm: [i, c("minutes")],
|
|
91
|
+
H: [i, c("hours")],
|
|
92
|
+
h: [i, c("hours")],
|
|
93
|
+
HH: [i, c("hours")],
|
|
94
|
+
hh: [i, c("hours")],
|
|
95
|
+
D: [i, c("day")],
|
|
96
|
+
DD: [r, c("day")],
|
|
97
|
+
Do: [a, function(e) {
|
|
98
|
+
var t = o.ordinal, n = e.match(/\d+/);
|
|
99
|
+
if (this.day = n[0], t) for (var r = 1; r <= 31; r += 1) t(r).replace(/\[|\]/g, "") === e && (this.day = r);
|
|
100
|
+
}],
|
|
101
|
+
w: [i, c("week")],
|
|
102
|
+
ww: [r, c("week")],
|
|
103
|
+
M: [i, c("month")],
|
|
104
|
+
MM: [r, c("month")],
|
|
105
|
+
MMM: [a, function(e) {
|
|
106
|
+
var t = u("months"), n = (u("monthsShort") || t.map((function(e) {
|
|
107
|
+
return e.slice(0, 3);
|
|
108
|
+
}))).indexOf(e) + 1;
|
|
109
|
+
if (n < 1) throw Error();
|
|
110
|
+
this.month = n % 12 || n;
|
|
111
|
+
}],
|
|
112
|
+
MMMM: [a, function(e) {
|
|
113
|
+
var t = u("months").indexOf(e) + 1;
|
|
114
|
+
if (t < 1) throw Error();
|
|
115
|
+
this.month = t % 12 || t;
|
|
116
|
+
}],
|
|
117
|
+
Y: [/[+-]?\d+/, c("year")],
|
|
118
|
+
YY: [r, function(e) {
|
|
119
|
+
this.year = s(e);
|
|
120
|
+
}],
|
|
121
|
+
YYYY: [/\d{4}/, c("year")],
|
|
122
|
+
Z: l,
|
|
123
|
+
ZZ: l
|
|
124
|
+
};
|
|
125
|
+
function p(n) {
|
|
126
|
+
for (var r = n, i = o && o.formats, a = (n = r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t, n, r) {
|
|
127
|
+
var a = r && r.toUpperCase();
|
|
128
|
+
return n || i[r] || e[r] || i[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e, t, n) {
|
|
129
|
+
return t || n.slice(1);
|
|
130
|
+
}));
|
|
131
|
+
}))).match(t), s = a.length, c = 0; c < s; c += 1) {
|
|
132
|
+
var l = a[c], u = f[l], d = u && u[0], p = u && u[1];
|
|
133
|
+
a[c] = p ? {
|
|
134
|
+
regex: d,
|
|
135
|
+
parser: p
|
|
136
|
+
} : l.replace(/^\[|\]$/g, "");
|
|
137
|
+
}
|
|
138
|
+
return function(e) {
|
|
139
|
+
for (var t = {}, n = 0, r = 0; n < s; n += 1) {
|
|
140
|
+
var i = a[n];
|
|
141
|
+
if (typeof i == "string") r += i.length;
|
|
142
|
+
else {
|
|
143
|
+
var o = i.regex, c = i.parser, l = e.slice(r), u = o.exec(l)[0];
|
|
144
|
+
c.call(t, u), e = e.replace(u, "");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return function(e) {
|
|
148
|
+
var t = e.afternoon;
|
|
149
|
+
if (t !== void 0) {
|
|
150
|
+
var n = e.hours;
|
|
151
|
+
t ? n < 12 && (e.hours += 12) : n === 12 && (e.hours = 0), delete e.afternoon;
|
|
152
|
+
}
|
|
153
|
+
}(t), t;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return function(e, t, n) {
|
|
157
|
+
n.p.customParseFormat = !0, e && e.parseTwoDigitYear && (s = e.parseTwoDigitYear);
|
|
158
|
+
var r = t.prototype, i = r.parse;
|
|
159
|
+
r.parse = function(e) {
|
|
160
|
+
var t = e.date, r = e.utc, a = e.args;
|
|
161
|
+
this.$u = r;
|
|
162
|
+
var s = a[1];
|
|
163
|
+
if (typeof s == "string") {
|
|
164
|
+
var c = !0 === a[2], l = !0 === a[3], u = c || l, d = a[2];
|
|
165
|
+
l && (d = a[2]), o = this.$locale(), !c && d && (o = n.Ls[d]), this.$d = function(e, t, n, r) {
|
|
166
|
+
try {
|
|
167
|
+
if (["x", "X"].indexOf(t) > -1) return /* @__PURE__ */ new Date((t === "X" ? 1e3 : 1) * e);
|
|
168
|
+
var i = p(t)(e), a = i.year, o = i.month, s = i.day, c = i.hours, l = i.minutes, u = i.seconds, d = i.milliseconds, f = i.zone, m = i.week, h = /* @__PURE__ */ new Date(), g = s || (a || o ? 1 : h.getDate()), _ = a || h.getFullYear(), v = 0;
|
|
169
|
+
a && !o || (v = o > 0 ? o - 1 : h.getMonth());
|
|
170
|
+
var y, b = c || 0, x = l || 0, S = u || 0, C = d || 0;
|
|
171
|
+
return f ? new Date(Date.UTC(_, v, g, b, x, S, C + 60 * f.offset * 1e3)) : n ? new Date(Date.UTC(_, v, g, b, x, S, C)) : (y = new Date(_, v, g, b, x, S, C), m && (y = r(y).week(m).toDate()), y);
|
|
172
|
+
} catch {
|
|
173
|
+
return /* @__PURE__ */ new Date("");
|
|
174
|
+
}
|
|
175
|
+
}(t, s, r, n), this.init(), d && !0 !== d && (this.$L = this.locale(d).$L), u && t != this.format(s) && (this.$d = /* @__PURE__ */ new Date("")), o = {};
|
|
176
|
+
} else if (s instanceof Array) for (var f = s.length, m = 1; m <= f; m += 1) {
|
|
177
|
+
a[1] = s[m - 1];
|
|
178
|
+
var h = n.apply(this, a);
|
|
179
|
+
if (h.isValid()) {
|
|
180
|
+
this.$d = h.$d, this.$L = h.$L, this.init();
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
m === f && (this.$d = /* @__PURE__ */ new Date(""));
|
|
184
|
+
}
|
|
185
|
+
else i.call(this, e);
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
}));
|
|
189
|
+
})))(), 1);
|
|
190
|
+
e.extend(de.default);
|
|
191
|
+
function fe(e, t) {
|
|
192
|
+
return e.length > t.property.max_length ? {
|
|
193
|
+
validateSuccess: !1,
|
|
194
|
+
validateMessage: `长度不能超过 ${t.property.max_length}`
|
|
195
|
+
} : {
|
|
196
|
+
validateSuccess: !0,
|
|
197
|
+
validateValue: e
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function pe(e, n) {
|
|
201
|
+
let r = Number(e);
|
|
202
|
+
if (!Number.isFinite(r)) return {
|
|
203
|
+
validateSuccess: !1,
|
|
204
|
+
validateMessage: "不是有效数字"
|
|
205
|
+
};
|
|
206
|
+
let i = n.property.precision, a;
|
|
207
|
+
try {
|
|
208
|
+
a = new t(e);
|
|
209
|
+
} catch {
|
|
210
|
+
return {
|
|
211
|
+
validateSuccess: !1,
|
|
212
|
+
validateMessage: "不是有效数字"
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
if (a.decimalPlaces() > i) return {
|
|
216
|
+
validateSuccess: !1,
|
|
217
|
+
validateMessage: `精度不能超过 ${i} 位小数`
|
|
218
|
+
};
|
|
219
|
+
let o = n.property.max_digits;
|
|
220
|
+
if (o !== void 0) {
|
|
221
|
+
let e = a.abs().trunc().toFixed(0).replace(/^0+/, "").length, t = o - i;
|
|
222
|
+
if (e > t) return {
|
|
223
|
+
validateSuccess: !1,
|
|
224
|
+
validateMessage: `整数部分不能超过 ${t} 位`
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
return n.property.min_value !== void 0 && r < n.property.min_value ? {
|
|
228
|
+
validateSuccess: !1,
|
|
229
|
+
validateMessage: `不能小于 ${n.property.min_value}`
|
|
230
|
+
} : n.property.max_value !== void 0 && r > n.property.max_value ? {
|
|
231
|
+
validateSuccess: !1,
|
|
232
|
+
validateMessage: `不能大于 ${n.property.max_value}`
|
|
233
|
+
} : {
|
|
234
|
+
validateSuccess: !0,
|
|
235
|
+
validateValue: r
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function me(e, t) {
|
|
239
|
+
return e === t.property.true_label ? {
|
|
240
|
+
validateSuccess: !0,
|
|
241
|
+
validateValue: !0
|
|
242
|
+
} : e === t.property.false_label ? {
|
|
243
|
+
validateSuccess: !0,
|
|
244
|
+
validateValue: !1
|
|
245
|
+
} : {
|
|
246
|
+
validateSuccess: !1,
|
|
247
|
+
validateMessage: `内容必须是 ${t.property.true_label}|${t.property.false_label}`
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function I(t) {
|
|
251
|
+
let n = e(t, "YYYY-MM-DD", !0);
|
|
252
|
+
return n.isValid() ? {
|
|
253
|
+
validateSuccess: !0,
|
|
254
|
+
validateValue: n.format("YYYY-MM-DD")
|
|
255
|
+
} : {
|
|
256
|
+
validateSuccess: !1,
|
|
257
|
+
validateMessage: "不是有效的日期格式 YYYY-MM-DD"
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function L(e) {
|
|
261
|
+
let t = /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/.exec(e);
|
|
262
|
+
return t ? {
|
|
263
|
+
validateSuccess: !0,
|
|
264
|
+
validateValue: `${t[1].padStart(2, "0")}:${t[2]}`
|
|
265
|
+
} : {
|
|
266
|
+
validateSuccess: !1,
|
|
267
|
+
validateMessage: "不是有效的日期格式 HH:mm"
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function R(t) {
|
|
271
|
+
let n = e(t, "YYYY-MM-DD HH:mm", !0);
|
|
272
|
+
return n.isValid() ? {
|
|
273
|
+
validateSuccess: !0,
|
|
274
|
+
validateValue: n.format("YYYY-MM-DD HH:mm")
|
|
275
|
+
} : {
|
|
276
|
+
validateSuccess: !1,
|
|
277
|
+
validateMessage: "不是有效的日期时间格式 YYYY-MM-DD HH:mm"
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function z(e, t) {
|
|
281
|
+
let n = F(e);
|
|
282
|
+
if (n.length > t.property.list_max_length) return {
|
|
283
|
+
validateSuccess: !1,
|
|
284
|
+
validateMessage: `列表长度不能超过 ${t.property.list_max_length}`
|
|
285
|
+
};
|
|
286
|
+
for (let e of n) if (e.length > t.property.text_max_length) return {
|
|
287
|
+
validateSuccess: !1,
|
|
288
|
+
validateMessage: `单项文本长度不能超过 ${t.property.text_max_length}`
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
validateSuccess: !0,
|
|
292
|
+
validateValue: n
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function B(e, t) {
|
|
296
|
+
return e in t.property.option_map ? {
|
|
297
|
+
validateSuccess: !0,
|
|
298
|
+
validateValue: t.property.option_map[e]
|
|
299
|
+
} : {
|
|
300
|
+
validateSuccess: !1,
|
|
301
|
+
validateMessage: `内容必须是 ${Object.keys(t.property.option_map).join("|")}`
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function V(e, t) {
|
|
305
|
+
let n = F(e), r = t.property.option_map, i = [];
|
|
306
|
+
for (let e of n) {
|
|
307
|
+
if (!(e in r)) return {
|
|
308
|
+
validateSuccess: !1,
|
|
309
|
+
validateMessage: `内容必须是 ${Object.keys(r).join("|")}`
|
|
310
|
+
};
|
|
311
|
+
i.push(r[e]);
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
validateSuccess: !0,
|
|
315
|
+
validateValue: i
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function H(e, t) {
|
|
319
|
+
if (e === null) return t.property.required ? {
|
|
320
|
+
validateSuccess: !1,
|
|
321
|
+
validateMessage: "不能为空"
|
|
322
|
+
} : {
|
|
323
|
+
validateSuccess: !0,
|
|
324
|
+
validateValue: t.property.default_value
|
|
325
|
+
};
|
|
326
|
+
if (t.type === "text") return fe(e, t);
|
|
327
|
+
if (t.type === "number") return pe(e, t);
|
|
328
|
+
if (t.type === "boolean") return me(e, t);
|
|
329
|
+
if (t.type === "date") return I(e);
|
|
330
|
+
if (t.type === "time") return L(e);
|
|
331
|
+
if (t.type === "datetime") return R(e);
|
|
332
|
+
if (t.type === "list") return z(e, t);
|
|
333
|
+
if (t.type === "single_choice") return B(e, t);
|
|
334
|
+
if (t.type === "multiple_choice") return V(e, t);
|
|
335
|
+
throw Error("未知的字段类型");
|
|
336
|
+
}
|
|
337
|
+
// src/core/limits.ts
|
|
338
|
+
var U = 2e4, he = 2e4, ge = 20971520;
|
|
339
|
+
// src/core/excel/importEditor.ts
|
|
340
|
+
function _e(e, t) {
|
|
341
|
+
if (t != null) {
|
|
342
|
+
if (e.type !== "single_choice" && e.type !== "multiple_choice") return String(t);
|
|
343
|
+
for (let [n, r] of Object.entries(e.property.option_map)) if (r === t) return n;
|
|
344
|
+
return String(t);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function ve(e, t) {
|
|
348
|
+
return e.type === "boolean" ? t === !0 ? e.property.true_label : t === !1 ? e.property.false_label : void 0 : e.type === "single_choice" ? _e(e, t) : e.type === "multiple_choice" ? Array.isArray(t) ? t.map((t) => _e(e, t)).filter(Boolean) : [] : e.type === "list" ? Array.isArray(t) ? P(t) : "" : e.type === "number" ? typeof t == "number" ? t : void 0 : t == null ? "" : String(t);
|
|
349
|
+
}
|
|
350
|
+
function ye(e, t) {
|
|
351
|
+
return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? F(t) : t;
|
|
352
|
+
}
|
|
353
|
+
function be(e, t) {
|
|
354
|
+
return t == null ? "" : e.type === "boolean" || e.type === "single_choice" ? String(t) : (e.type === "multiple_choice" || e.type === "list") && Array.isArray(t) ? P(t) : String(t);
|
|
355
|
+
}
|
|
14
356
|
// src/core/excel/importRow.ts
|
|
15
|
-
function
|
|
357
|
+
function xe(e, t, n) {
|
|
16
358
|
let r = {};
|
|
17
359
|
return t.forEach((t) => {
|
|
18
360
|
if (!n.includes(t.key)) return;
|
|
19
|
-
let i =
|
|
361
|
+
let i = be(t, e.values[t.key]), a = H(i.trim() === "" ? null : i, t);
|
|
20
362
|
if (!a.validateSuccess) throw Error(a.validateMessage);
|
|
21
363
|
r[t.key] = a.validateValue ?? null;
|
|
22
364
|
}), r;
|
|
23
365
|
}
|
|
24
|
-
// src/core/excel/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let r =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
366
|
+
// src/core/excel/parseSheet.ts
|
|
367
|
+
function Se(e) {
|
|
368
|
+
return !Number.isFinite(e) || e < 1 || e >= 2958466 ? null : new Date(Math.round((e - 25569) * 24 * 3600 * 1e3));
|
|
369
|
+
}
|
|
370
|
+
function Ce(e, t = !1) {
|
|
371
|
+
let n = String(e.getUTCMonth() + 1).padStart(2, "0"), r = String(e.getUTCDate()).padStart(2, "0"), i = `${e.getUTCFullYear()}-${n}-${r}`;
|
|
372
|
+
return t ? `${i} ${String(e.getUTCHours()).padStart(2, "0")}:${String(e.getUTCMinutes()).padStart(2, "0")}` : i;
|
|
373
|
+
}
|
|
374
|
+
function we(e, t) {
|
|
375
|
+
let n = (e) => e.trim() === "" ? null : e.trim(), i = t === "datetime", a = t === "date" || i;
|
|
376
|
+
if (e.type === r.ValueType.Null) return null;
|
|
377
|
+
if (e.type === r.ValueType.Date) return Ce(e.value, i);
|
|
378
|
+
if (e.type === r.ValueType.Formula) {
|
|
379
|
+
if (e.result === null || e.result === void 0) return null;
|
|
380
|
+
if (e.result instanceof Date) return Ce(e.result, i);
|
|
381
|
+
if (a && typeof e.result == "number") {
|
|
382
|
+
let t = Se(e.result);
|
|
383
|
+
if (t) return Ce(t, i);
|
|
384
|
+
}
|
|
385
|
+
return n(String(e.result));
|
|
386
|
+
}
|
|
387
|
+
if (e.type === r.ValueType.Number) {
|
|
388
|
+
if (a && typeof e.value == "number") {
|
|
389
|
+
let t = Se(e.value);
|
|
390
|
+
if (t) return Ce(t, i);
|
|
391
|
+
}
|
|
392
|
+
return n(String(e.value));
|
|
393
|
+
}
|
|
394
|
+
return n(e.text);
|
|
395
|
+
}
|
|
396
|
+
function Te(e) {
|
|
397
|
+
let t = e.property.default_value;
|
|
398
|
+
if (t == null) return null;
|
|
399
|
+
if (e.type === "boolean") return t ? e.property.true_label : e.property.false_label;
|
|
400
|
+
if (Array.isArray(t)) return t.length > 0 ? P(t) : null;
|
|
401
|
+
let n = String(t);
|
|
402
|
+
return n.trim() === "" ? null : n;
|
|
403
|
+
}
|
|
404
|
+
function Ee(e, t) {
|
|
405
|
+
let n = new Map(t.map((e) => [e.title, e])), r = [];
|
|
406
|
+
for (let t = 1; t <= e.columnCount; t++) {
|
|
407
|
+
let i = e.getRow(1).getCell(t).text.split("\n")[0].trim();
|
|
408
|
+
r[t - 1] = n.get(i) ?? null;
|
|
409
|
+
}
|
|
410
|
+
return r;
|
|
411
|
+
}
|
|
412
|
+
function De(e, t) {
|
|
413
|
+
let n = [], i = [], a = [], o = 0, s = !1, c = Ee(e, t), l = c.filter((e) => e !== null).map((e) => e.key), u = new Set(l);
|
|
414
|
+
if (t.forEach((e) => {
|
|
415
|
+
e.property.required && !u.has(e.key) && n.push(`缺少列: ${e.title}`);
|
|
416
|
+
}), n.length > 0) return {
|
|
417
|
+
headerMessages: n,
|
|
418
|
+
formulaMessages: i,
|
|
419
|
+
rows: a,
|
|
420
|
+
includedKeys: l
|
|
421
|
+
};
|
|
422
|
+
let d = 0;
|
|
423
|
+
return e.eachRow({ includeEmpty: !1 }, (e, l) => {
|
|
424
|
+
if (l === 1) return;
|
|
425
|
+
let f = {};
|
|
426
|
+
if (c.forEach((t, n) => {
|
|
427
|
+
t && (f[t.key] = we(e.getCell(n + 1), t.type));
|
|
428
|
+
}), c.forEach((t, n) => {
|
|
429
|
+
if (!t) return;
|
|
430
|
+
let a = e.getCell(n + 1);
|
|
431
|
+
a.type === r.ValueType.Formula && (a.result === null || a.result === void 0) && (o += 1, i.length < 20 && i.push(`第 ${l} 行 [${t.title}] 是公式且没有保存计算结果, 请用 Excel 打开并保存后再导入`));
|
|
432
|
+
}), Object.values(f).every((e) => e === null)) return;
|
|
433
|
+
if (d += 1, d > 2e4) {
|
|
434
|
+
s ||= (n.push(`导入数据超出限制(${U} 条), 请分批导入`), !0);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
let p = {
|
|
438
|
+
key: String(a.length),
|
|
439
|
+
rowNumber: l,
|
|
440
|
+
values: {},
|
|
441
|
+
errors: {}
|
|
442
|
+
};
|
|
443
|
+
t.forEach((e) => {
|
|
444
|
+
if (!u.has(e.key)) return;
|
|
445
|
+
let t = H(f[e.key] ?? Te(e), e);
|
|
446
|
+
t.validateSuccess ? p.values[e.key] = ve(e, t.validateValue ?? null) : (p.values[e.key] = ye(e, f[e.key] ?? null), p.errors[e.key] = t.validateMessage);
|
|
447
|
+
}), a.push(p);
|
|
448
|
+
}), o > i.length && i.push(`还有 ${o - i.length} 个公式单元格没有保存计算结果`), {
|
|
449
|
+
headerMessages: n,
|
|
450
|
+
formulaMessages: i,
|
|
451
|
+
rows: a,
|
|
452
|
+
includedKeys: l
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
// src/core/excel/worksheet.ts
|
|
456
|
+
function Oe(t, n) {
|
|
457
|
+
let r = n[t.key];
|
|
458
|
+
if (r == null || r === "") return null;
|
|
459
|
+
switch (t.type) {
|
|
460
|
+
case "datetime": return e(r).format("YYYY-MM-DD HH:mm");
|
|
461
|
+
case "boolean": return r ? t.property.true_label : t.property.false_label;
|
|
462
|
+
case "single_choice": {
|
|
463
|
+
let e = t.property.option_map;
|
|
464
|
+
return Object.keys(e).find((t) => e[t] === r) ?? String(r);
|
|
465
|
+
}
|
|
466
|
+
case "multiple_choice": {
|
|
467
|
+
let e = t.property.option_map;
|
|
468
|
+
return P((Array.isArray(r) ? r : [r]).map((t) => Object.keys(e).find((n) => e[n] === t) ?? String(t)));
|
|
469
|
+
}
|
|
470
|
+
case "list": {
|
|
471
|
+
let e = Array.isArray(r) ? r : [r], n = t.property.item_key;
|
|
472
|
+
return P(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
|
|
473
|
+
}
|
|
474
|
+
default: return r;
|
|
38
475
|
}
|
|
39
476
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
477
|
+
function ke(e, t) {
|
|
478
|
+
t.forEach((t, n) => {
|
|
479
|
+
t.type === "text" && (e.getColumn(n + 1).numFmt = "@");
|
|
480
|
+
});
|
|
43
481
|
}
|
|
44
|
-
|
|
45
|
-
let r =
|
|
46
|
-
|
|
482
|
+
function Ae(e, t, n) {
|
|
483
|
+
let r = n.map((e) => e.importable === !1 ? `${e.title}\n(仅导出)` : e.title), i = e.addRow(r);
|
|
484
|
+
i.height = 20 + (Math.max(...r.map((e) => e.split("\n").length)) - 1) * 15, i.eachCell({ includeEmpty: !0 }, (e) => {
|
|
485
|
+
e.font = {
|
|
486
|
+
bold: !0,
|
|
487
|
+
size: 14,
|
|
488
|
+
color: { argb: "FFFFFFFF" }
|
|
489
|
+
}, e.fill = {
|
|
490
|
+
type: "pattern",
|
|
491
|
+
pattern: "solid",
|
|
492
|
+
fgColor: { argb: "FF4472C4" }
|
|
493
|
+
}, e.alignment = {
|
|
494
|
+
vertical: "middle",
|
|
495
|
+
wrapText: !0
|
|
496
|
+
};
|
|
497
|
+
}), t.forEach((t) => {
|
|
498
|
+
e.addRow(n.map((e) => Oe(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
|
|
499
|
+
e.alignment = {
|
|
500
|
+
...e.alignment,
|
|
501
|
+
wrapText: !0,
|
|
502
|
+
vertical: "top"
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
}), ke(e, n), Ne(e);
|
|
47
506
|
}
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
|
|
507
|
+
function je(e) {
|
|
508
|
+
let t = [e.property.required ? "必填" : "可选"];
|
|
509
|
+
switch (e.type) {
|
|
510
|
+
case "text":
|
|
511
|
+
t.push(`最长 ${e.property.max_length} 个字符`);
|
|
512
|
+
break;
|
|
513
|
+
case "number":
|
|
514
|
+
t.push(`最多 ${e.property.precision} 位小数`), e.property.max_digits !== void 0 && t.push(`整数最多 ${e.property.max_digits - e.property.precision} 位`), e.property.min_value !== void 0 && t.push(`最小 ${e.property.min_value}`), e.property.max_value !== void 0 && t.push(`最大 ${e.property.max_value}`);
|
|
515
|
+
break;
|
|
516
|
+
case "boolean":
|
|
517
|
+
t.push(`填 ${e.property.true_label} 或 ${e.property.false_label}`);
|
|
518
|
+
break;
|
|
519
|
+
case "date":
|
|
520
|
+
t.push("格式 YYYY-MM-DD");
|
|
521
|
+
break;
|
|
522
|
+
case "time":
|
|
523
|
+
t.push("格式 HH:mm");
|
|
524
|
+
break;
|
|
525
|
+
case "datetime":
|
|
526
|
+
t.push("格式 YYYY-MM-DD HH:mm");
|
|
527
|
+
break;
|
|
528
|
+
case "list":
|
|
529
|
+
t.push(`多个值用分号分隔(中英文均可), 最多 ${e.property.list_max_length} 个`);
|
|
530
|
+
break;
|
|
531
|
+
case "single_choice":
|
|
532
|
+
t.push(`填其一: ${Object.keys(e.property.option_map).join(" / ")}`);
|
|
533
|
+
break;
|
|
534
|
+
case "multiple_choice": t.push(`可多选, 分号分隔(中英文均可): ${Object.keys(e.property.option_map).join(" / ")}`);
|
|
535
|
+
}
|
|
536
|
+
e.key.endsWith("_name") ? t.push("填对应记录的名称") : e.key.endsWith("_number") && t.push("填对应记录的编号");
|
|
537
|
+
let n = Oe(e, { [e.key]: e.property.default_value });
|
|
538
|
+
return t.push(`默认值: ${n == null || n === "" ? "空" : n}`), t.join("\n");
|
|
539
|
+
}
|
|
540
|
+
function Me(e, t) {
|
|
541
|
+
let n = t.map((e) => `${e.title}\n\n${je(e)}`), r = e.addRow(n);
|
|
542
|
+
r.height = 20 + (Math.max(...n.map((e) => e.split("\n").length)) - 1) * 15, r.eachCell({ includeEmpty: !0 }, (e) => {
|
|
543
|
+
e.font = {
|
|
544
|
+
bold: !0,
|
|
545
|
+
size: 14,
|
|
546
|
+
color: { argb: "FFFFFFFF" }
|
|
547
|
+
}, e.fill = {
|
|
548
|
+
type: "pattern",
|
|
549
|
+
pattern: "solid",
|
|
550
|
+
fgColor: { argb: "FF4472C4" }
|
|
551
|
+
}, e.alignment = {
|
|
552
|
+
vertical: "top",
|
|
553
|
+
wrapText: !0
|
|
554
|
+
};
|
|
555
|
+
}), ke(e, t), Ne(e);
|
|
556
|
+
}
|
|
557
|
+
function Ne(e, t = 20, n = 60) {
|
|
558
|
+
let r = [];
|
|
559
|
+
e.eachRow({ includeEmpty: !1 }, (e) => {
|
|
560
|
+
e.eachCell({ includeEmpty: !1 }, (e, t) => {
|
|
561
|
+
let n = t - 1, i = e.text, a = e.font?.size || 11, o = .8 + a / 11 * .4, s = i.split("\n"), c = 0;
|
|
562
|
+
for (let e of s) {
|
|
563
|
+
let t = 0;
|
|
564
|
+
for (let n of e) {
|
|
565
|
+
let e = n.charCodeAt(0);
|
|
566
|
+
t += e > 255 || e >= 65280 && e <= 65519 ? 2 : 1;
|
|
567
|
+
}
|
|
568
|
+
c = Math.max(c, t);
|
|
569
|
+
}
|
|
570
|
+
let l = c * 7 * (a / 11) * o;
|
|
571
|
+
(!r[n] || l > r[n]) && (r[n] = l);
|
|
572
|
+
});
|
|
573
|
+
}), r.forEach((r, i) => {
|
|
574
|
+
let a = r / 7;
|
|
575
|
+
e.getColumn(i + 1).width = Math.min(Math.max(a, t), n);
|
|
576
|
+
});
|
|
51
577
|
}
|
|
52
|
-
|
|
53
|
-
|
|
578
|
+
// src/core/excel/runtime.ts
|
|
579
|
+
var Pe = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Fe;
|
|
580
|
+
function Ie() {
|
|
581
|
+
return Fe ??= import("exceljs").then((e) => e.default ?? e), Fe;
|
|
582
|
+
}
|
|
583
|
+
function Le() {
|
|
584
|
+
return new Promise((e) => {
|
|
585
|
+
requestAnimationFrame(() => setTimeout(e, 0));
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function Re(e) {
|
|
589
|
+
if (e?.aborted) throw new DOMException("任务已取消", "AbortError");
|
|
590
|
+
}
|
|
591
|
+
async function ze(e, t, n) {
|
|
592
|
+
let r = await Ie();
|
|
593
|
+
Re(n), await Le();
|
|
594
|
+
let i = new r.Workbook();
|
|
595
|
+
Ae(i.addWorksheet("Sheet"), e, t);
|
|
596
|
+
let a = await i.xlsx.writeBuffer();
|
|
597
|
+
return Re(n), new Blob([a], { type: Pe });
|
|
598
|
+
}
|
|
599
|
+
async function Be(e, t, r) {
|
|
600
|
+
let i = await ze(e, t);
|
|
601
|
+
return n(i, `${r}.xlsx`), i;
|
|
602
|
+
}
|
|
603
|
+
async function Ve(e, t) {
|
|
604
|
+
let r = await Ie();
|
|
605
|
+
await Le();
|
|
606
|
+
let i = new r.Workbook();
|
|
607
|
+
Me(i.addWorksheet("导入模板"), e);
|
|
608
|
+
let a = await i.xlsx.writeBuffer();
|
|
609
|
+
n(new Blob([a], { type: Pe }), `${t}.xlsx`);
|
|
610
|
+
}
|
|
611
|
+
async function He(e, t) {
|
|
612
|
+
let n = await Ie(), r = await e.arrayBuffer();
|
|
613
|
+
await Le();
|
|
614
|
+
let i = new n.Workbook();
|
|
615
|
+
if (await i.xlsx.load(r), i.worksheets.length > 1) return {
|
|
616
|
+
headerMessages: ["文件包含多个工作表, 只支持单个工作表, 请删除其他工作表后再导入"],
|
|
617
|
+
formulaMessages: [],
|
|
618
|
+
rows: [],
|
|
619
|
+
includedKeys: []
|
|
620
|
+
};
|
|
621
|
+
let a = i.worksheets[0];
|
|
622
|
+
return a ? De(a, t) : {
|
|
623
|
+
headerMessages: ["文件里没有工作表"],
|
|
624
|
+
formulaMessages: [],
|
|
625
|
+
rows: [],
|
|
626
|
+
includedKeys: []
|
|
627
|
+
};
|
|
54
628
|
}
|
|
55
629
|
// src/core/httpError.ts
|
|
56
|
-
function
|
|
630
|
+
function Ue(e) {
|
|
57
631
|
let t = e;
|
|
58
632
|
return t !== null && (t.isAxiosError === !0 || t.response !== void 0);
|
|
59
633
|
}
|
|
60
|
-
function
|
|
634
|
+
function We(e) {
|
|
61
635
|
let t = e?.response?.status;
|
|
62
636
|
return typeof t == "number" ? t : void 0;
|
|
63
637
|
}
|
|
64
|
-
function
|
|
638
|
+
function Ge(e) {
|
|
65
639
|
return e?.response?.data;
|
|
66
640
|
}
|
|
67
641
|
// src/core/taskManager.ts
|
|
68
|
-
var
|
|
642
|
+
var W = class extends Error {
|
|
69
643
|
constructor(e) {
|
|
70
644
|
super(e), this.name = "ImportPauseError";
|
|
71
645
|
}
|
|
72
|
-
},
|
|
73
|
-
function
|
|
74
|
-
|
|
646
|
+
}, Ke = 100, qe = 500;
|
|
647
|
+
function Je(e, t) {
|
|
648
|
+
let n = t - (Date.now() - e);
|
|
649
|
+
return n > 0 ? new Promise((e) => setTimeout(e, n)) : Promise.resolve();
|
|
650
|
+
}
|
|
651
|
+
var G = { tasks: [] }, Ye = /* @__PURE__ */ new Set(), Xe = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map();
|
|
652
|
+
function Ze() {
|
|
653
|
+
G = { ...G }, Ye.forEach((e) => e());
|
|
75
654
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
78
|
-
|
|
655
|
+
function Qe(e) {
|
|
656
|
+
return Ye.add(e), () => {
|
|
657
|
+
Ye.delete(e);
|
|
79
658
|
};
|
|
80
659
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
660
|
+
function $e(e) {
|
|
661
|
+
return Qe(e);
|
|
83
662
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
663
|
+
function et() {
|
|
664
|
+
return G.tasks;
|
|
86
665
|
}
|
|
87
|
-
function
|
|
666
|
+
function tt() {
|
|
88
667
|
return `task-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
89
668
|
}
|
|
90
669
|
function J(e) {
|
|
91
|
-
return
|
|
670
|
+
return G.tasks.find((t) => t.id === e);
|
|
92
671
|
}
|
|
93
672
|
function Y(e, t) {
|
|
94
|
-
let n = !1, r =
|
|
673
|
+
let n = !1, r = G.tasks.map((r) => r.id === e ? (n = !0, {
|
|
95
674
|
...r,
|
|
96
675
|
...t
|
|
97
676
|
}) : r);
|
|
98
|
-
n && (
|
|
99
|
-
...
|
|
677
|
+
n && (G = {
|
|
678
|
+
...G,
|
|
100
679
|
tasks: r
|
|
101
|
-
},
|
|
680
|
+
}, Ze());
|
|
102
681
|
}
|
|
103
|
-
function
|
|
682
|
+
function nt(e, t) {
|
|
104
683
|
let n = J(e), r = Date.now();
|
|
105
684
|
return [...n?.samples ?? [], {
|
|
106
685
|
time: r,
|
|
107
686
|
processed: t
|
|
108
687
|
}].filter((e) => r - e.time <= 15e3).slice(-20);
|
|
109
688
|
}
|
|
110
|
-
var
|
|
111
|
-
function
|
|
112
|
-
let r =
|
|
689
|
+
var rt = 100, X = /* @__PURE__ */ new Set(), Z = null;
|
|
690
|
+
function it(e, t, n) {
|
|
691
|
+
let r = K.get(e);
|
|
113
692
|
r && (r.rowStates[t] = {
|
|
114
693
|
...r.rowStates[t],
|
|
115
694
|
...n
|
|
116
|
-
},
|
|
695
|
+
}, at(e));
|
|
117
696
|
}
|
|
118
|
-
function
|
|
697
|
+
function at(e) {
|
|
119
698
|
X.add(e), Z === null && (Z = setTimeout(() => {
|
|
120
699
|
Z = null;
|
|
121
700
|
let e = [...X];
|
|
122
|
-
X.clear(), e.forEach(
|
|
123
|
-
},
|
|
701
|
+
X.clear(), e.forEach(ot);
|
|
702
|
+
}, rt));
|
|
124
703
|
}
|
|
125
704
|
function Q(e) {
|
|
126
705
|
X.delete(e);
|
|
@@ -128,36 +707,36 @@ function Q(e) {
|
|
|
128
707
|
function $(e, t) {
|
|
129
708
|
return {
|
|
130
709
|
processed: t.processed,
|
|
131
|
-
total:
|
|
710
|
+
total: st(t),
|
|
132
711
|
successCount: t.successCount,
|
|
133
712
|
failureCount: t.failures.length,
|
|
134
713
|
validationFailedCount: t.validationFailedCount,
|
|
135
714
|
failures: t.failures,
|
|
136
715
|
rowStates: t.rowStates,
|
|
137
|
-
samples:
|
|
716
|
+
samples: nt(e, t.processed)
|
|
138
717
|
};
|
|
139
718
|
}
|
|
140
|
-
function
|
|
141
|
-
let t =
|
|
719
|
+
function ot(e) {
|
|
720
|
+
let t = K.get(e);
|
|
142
721
|
t && J(e) && Y(e, $(e, t));
|
|
143
722
|
}
|
|
144
|
-
function
|
|
723
|
+
function st(e) {
|
|
145
724
|
return e.options.rows.length - e.deletedIndexes.size;
|
|
146
725
|
}
|
|
147
|
-
async function
|
|
148
|
-
let { options:
|
|
149
|
-
t.controller =
|
|
726
|
+
async function ct(e, t, r) {
|
|
727
|
+
let { options: i } = t;
|
|
728
|
+
t.controller = r, t.cancelRequested = !1;
|
|
150
729
|
try {
|
|
151
730
|
for (; !t.cancelRequested;) {
|
|
152
|
-
let
|
|
153
|
-
if (
|
|
731
|
+
let n = t.cursorId === void 0 ? {} : { cursor_id: t.cursorId }, a = await i.fetchPage(n, r.signal);
|
|
732
|
+
if (r.signal.aborted) throw new DOMException("任务已取消", "AbortError");
|
|
154
733
|
if (t.total = a.count, a.results.length === 0) break;
|
|
155
734
|
t.rows = t.rows.concat(a.results);
|
|
156
735
|
let o = t.rows.length;
|
|
157
736
|
Y(e, {
|
|
158
737
|
total: t.total,
|
|
159
738
|
processed: o,
|
|
160
|
-
samples:
|
|
739
|
+
samples: nt(e, o)
|
|
161
740
|
});
|
|
162
741
|
let s = a.results[a.results.length - 1]?.id;
|
|
163
742
|
if (typeof s != "number") throw Error("导出数据缺少 id");
|
|
@@ -174,24 +753,24 @@ async function Me(e, t, n) {
|
|
|
174
753
|
}
|
|
175
754
|
if (t.rows.length === 0) throw Error("没有可导出的数据");
|
|
176
755
|
Y(e, { finalizing: !0 });
|
|
177
|
-
let
|
|
178
|
-
if (
|
|
756
|
+
let a = Date.now(), o = await ze(t.rows, i.fieldSchemas, r.signal);
|
|
757
|
+
if (r.signal.aborted) throw new DOMException("任务已取消", "AbortError");
|
|
179
758
|
try {
|
|
180
|
-
|
|
759
|
+
n(o, `${i.fileName}.xlsx`);
|
|
181
760
|
} catch (e) {
|
|
182
761
|
console.error(`自动下载失败: ${e}`);
|
|
183
762
|
}
|
|
184
|
-
Y(e, {
|
|
763
|
+
await Je(a, qe), Y(e, {
|
|
185
764
|
status: "completed",
|
|
186
765
|
pausing: !1,
|
|
187
766
|
finalizing: !1,
|
|
188
767
|
canceling: !1,
|
|
189
768
|
total: t.rows.length,
|
|
190
769
|
processed: t.rows.length,
|
|
191
|
-
blob:
|
|
770
|
+
blob: o
|
|
192
771
|
});
|
|
193
772
|
} catch (t) {
|
|
194
|
-
if (
|
|
773
|
+
if (r.signal.aborted) {
|
|
195
774
|
Y(e, {
|
|
196
775
|
status: "canceled",
|
|
197
776
|
pausing: !1,
|
|
@@ -205,21 +784,21 @@ async function Me(e, t, n) {
|
|
|
205
784
|
pausing: !1,
|
|
206
785
|
finalizing: !1,
|
|
207
786
|
canceling: !1,
|
|
208
|
-
errorMessage:
|
|
787
|
+
errorMessage: lt(t)
|
|
209
788
|
});
|
|
210
789
|
} finally {
|
|
211
790
|
t.controller = null;
|
|
212
791
|
}
|
|
213
792
|
}
|
|
214
|
-
function
|
|
215
|
-
if (!
|
|
216
|
-
let t =
|
|
793
|
+
function lt(e) {
|
|
794
|
+
if (!Ue(e)) return e instanceof Error ? e.message : "导出失败";
|
|
795
|
+
let t = We(e);
|
|
217
796
|
return t === void 0 ? "网络异常, 导出失败" : t === 401 ? "登录已过期, 导出失败" : t === 403 ? "没有导出权限, 导出失败" : t === 404 ? "导出接口不存在, 导出失败" : t === 400 ? "导出参数错误, 导出失败" : t >= 500 ? "服务器错误, 导出失败" : "导出失败";
|
|
218
797
|
}
|
|
219
|
-
function
|
|
798
|
+
function ut(e) {
|
|
220
799
|
return `导入完成: 成功 ${e.successCount} 条, 失败 ${e.failures.length} 条`;
|
|
221
800
|
}
|
|
222
|
-
async function
|
|
801
|
+
async function dt(e, t, n) {
|
|
223
802
|
let r = t.options.rows.length;
|
|
224
803
|
if (t.controller = n, t.pauseRequested = !1, t.cancelRequested = !1, t.cycleFailureCount = 0, r === 0) {
|
|
225
804
|
Y(e, {
|
|
@@ -251,7 +830,7 @@ async function Fe(e, t, n) {
|
|
|
251
830
|
let r = o();
|
|
252
831
|
if (r.length === 0) return;
|
|
253
832
|
r.forEach((t) => {
|
|
254
|
-
|
|
833
|
+
it(e, t, {
|
|
255
834
|
status: "running",
|
|
256
835
|
message: void 0,
|
|
257
836
|
fieldErrors: void 0
|
|
@@ -260,10 +839,10 @@ async function Fe(e, t, n) {
|
|
|
260
839
|
try {
|
|
261
840
|
let i = r.map((e) => t.options.rows[e]), a = await t.options.importRows(i, n.signal);
|
|
262
841
|
if (n.signal.aborted) return;
|
|
263
|
-
if (a.length !== r.length) throw new
|
|
842
|
+
if (a.length !== r.length) throw new W("导入接口返回结果数量不正确, 任务已暂停");
|
|
264
843
|
a.forEach((n, i) => {
|
|
265
844
|
let a = r[i], o = t.options.rows[a];
|
|
266
|
-
n.success ? (t.successCount += 1,
|
|
845
|
+
n.success ? (t.successCount += 1, it(e, a, {
|
|
267
846
|
status: "completed",
|
|
268
847
|
fieldErrors: void 0
|
|
269
848
|
})) : (t.failures.push({
|
|
@@ -271,27 +850,27 @@ async function Fe(e, t, n) {
|
|
|
271
850
|
rowNumber: o.rowNumber,
|
|
272
851
|
message: n.message ?? "导入失败",
|
|
273
852
|
fieldErrors: n.fieldErrors
|
|
274
|
-
}),
|
|
853
|
+
}), it(e, a, {
|
|
275
854
|
status: "failed",
|
|
276
855
|
message: n.message,
|
|
277
856
|
fieldErrors: n.fieldErrors
|
|
278
|
-
}), t.cycleFailureCount += 1, t.cycleFailureCount >
|
|
857
|
+
}), t.cycleFailureCount += 1, t.cycleFailureCount > Ke && (t.pauseRequested = !0));
|
|
279
858
|
});
|
|
280
859
|
} catch (i) {
|
|
281
860
|
if (n.signal.aborted) return;
|
|
282
|
-
let a = i instanceof
|
|
861
|
+
let a = i instanceof W, o = i instanceof Error ? i.message : "导入失败";
|
|
283
862
|
r.forEach((n) => {
|
|
284
863
|
t.failures.push({
|
|
285
864
|
index: n,
|
|
286
865
|
rowNumber: t.options.rows[n].rowNumber,
|
|
287
866
|
message: o
|
|
288
|
-
}),
|
|
867
|
+
}), it(e, n, {
|
|
289
868
|
status: "failed",
|
|
290
869
|
message: o
|
|
291
870
|
}), t.cycleFailureCount += 1;
|
|
292
|
-
}), a ? (t.pauseRequested = !0, n.abort()) : t.cycleFailureCount >
|
|
871
|
+
}), a ? (t.pauseRequested = !0, n.abort()) : t.cycleFailureCount > Ke && (t.pauseRequested = !0);
|
|
293
872
|
} finally {
|
|
294
|
-
t.processed += r.length,
|
|
873
|
+
t.processed += r.length, at(e);
|
|
295
874
|
}
|
|
296
875
|
}
|
|
297
876
|
}, c = Math.min(a, Math.max(1, r));
|
|
@@ -340,7 +919,7 @@ async function Fe(e, t, n) {
|
|
|
340
919
|
...$(e, t),
|
|
341
920
|
status: "paused",
|
|
342
921
|
pausing: !1,
|
|
343
|
-
errorMessage:
|
|
922
|
+
errorMessage: ut(t)
|
|
344
923
|
}), t.options.onFinished?.();
|
|
345
924
|
return;
|
|
346
925
|
}
|
|
@@ -356,20 +935,20 @@ async function Fe(e, t, n) {
|
|
|
356
935
|
pausing: !1
|
|
357
936
|
}), t.options.onFinished?.());
|
|
358
937
|
}
|
|
359
|
-
function
|
|
938
|
+
function ft(e, t) {
|
|
360
939
|
let n = new AbortController();
|
|
361
|
-
|
|
362
|
-
|
|
940
|
+
q.set(e, n), ct(e, t, n).finally(() => {
|
|
941
|
+
q.delete(e), Xe.delete(e);
|
|
363
942
|
});
|
|
364
943
|
}
|
|
365
|
-
function
|
|
944
|
+
function pt(e, t) {
|
|
366
945
|
let n = new AbortController();
|
|
367
|
-
|
|
368
|
-
|
|
946
|
+
q.set(e, n), dt(e, t, n).finally(() => {
|
|
947
|
+
q.delete(e), X.delete(e), J(e)?.status !== "paused" && K.delete(e);
|
|
369
948
|
});
|
|
370
949
|
}
|
|
371
|
-
function
|
|
372
|
-
let t =
|
|
950
|
+
function mt(e) {
|
|
951
|
+
let t = tt(), n = {
|
|
373
952
|
id: t,
|
|
374
953
|
type: "export",
|
|
375
954
|
title: e.title,
|
|
@@ -379,9 +958,9 @@ function Re(e) {
|
|
|
379
958
|
fileName: e.fileName,
|
|
380
959
|
samples: []
|
|
381
960
|
};
|
|
382
|
-
|
|
383
|
-
...
|
|
384
|
-
tasks: [...
|
|
961
|
+
G = {
|
|
962
|
+
...G,
|
|
963
|
+
tasks: [...G.tasks, n]
|
|
385
964
|
};
|
|
386
965
|
let r = {
|
|
387
966
|
options: e,
|
|
@@ -390,10 +969,10 @@ function Re(e) {
|
|
|
390
969
|
cancelRequested: !1,
|
|
391
970
|
controller: null
|
|
392
971
|
};
|
|
393
|
-
return
|
|
972
|
+
return Xe.set(t, r), Ze(), ft(t, r), t;
|
|
394
973
|
}
|
|
395
|
-
function
|
|
396
|
-
let t =
|
|
974
|
+
function ht(e) {
|
|
975
|
+
let t = tt(), n = e.rows.map((e) => ({
|
|
397
976
|
status: "queued",
|
|
398
977
|
validationErrors: Object.keys(e.errors).length > 0 ? e.errors : void 0
|
|
399
978
|
})), r = new Set(e.rows.flatMap((e, t) => Object.keys(e.errors).length > 0 ? [t] : [])), i = r.size, a = {
|
|
@@ -411,9 +990,9 @@ function ze(e) {
|
|
|
411
990
|
failures: [],
|
|
412
991
|
samples: []
|
|
413
992
|
};
|
|
414
|
-
|
|
415
|
-
...
|
|
416
|
-
tasks: [...
|
|
993
|
+
G = {
|
|
994
|
+
...G,
|
|
995
|
+
tasks: [...G.tasks, a]
|
|
417
996
|
};
|
|
418
997
|
let o = {
|
|
419
998
|
options: e,
|
|
@@ -430,12 +1009,12 @@ function ze(e) {
|
|
|
430
1009
|
cycleFailureCount: 0,
|
|
431
1010
|
controller: null
|
|
432
1011
|
};
|
|
433
|
-
return
|
|
1012
|
+
return K.set(t, o), Ze(), pt(t, o), t;
|
|
434
1013
|
}
|
|
435
|
-
function
|
|
1014
|
+
function gt(e) {
|
|
436
1015
|
let t = J(e);
|
|
437
1016
|
if (!t || t.type !== "import" || t.status !== "paused") return;
|
|
438
|
-
let n =
|
|
1017
|
+
let n = K.get(e);
|
|
439
1018
|
if (!n) return;
|
|
440
1019
|
let r = n.rowStates.filter((e) => e.status === "completed").length, i = n.rowStates.map((e) => e.status === "completed" || e.status === "deleted" ? e : {
|
|
441
1020
|
status: "queued",
|
|
@@ -452,22 +1031,22 @@ function Be(e) {
|
|
|
452
1031
|
failures: [],
|
|
453
1032
|
rowStates: i,
|
|
454
1033
|
errorMessage: void 0
|
|
455
|
-
}),
|
|
1034
|
+
}), pt(e, n);
|
|
456
1035
|
}
|
|
457
|
-
function
|
|
1036
|
+
function _t(e) {
|
|
458
1037
|
let t = J(e);
|
|
459
1038
|
if (!t || t.type !== "import" || t.status !== "running" || t.canceling) return;
|
|
460
|
-
let n =
|
|
1039
|
+
let n = K.get(e);
|
|
461
1040
|
n && (n.pauseRequested = !0, Y(e, { pausing: !0 }));
|
|
462
1041
|
}
|
|
463
|
-
function
|
|
464
|
-
let r = J(e), i =
|
|
1042
|
+
function vt(e, t, n) {
|
|
1043
|
+
let r = J(e), i = K.get(e);
|
|
465
1044
|
if (!r || r.type !== "import" || r.status !== "paused" && r.status !== "failed" || !i) return;
|
|
466
1045
|
let a = r.rowStates?.[t]?.status;
|
|
467
1046
|
(a === "queued" || a === "failed") && (i.options.rows[t] = n);
|
|
468
1047
|
}
|
|
469
|
-
function
|
|
470
|
-
let r = J(e), i =
|
|
1048
|
+
function yt(e, t, n) {
|
|
1049
|
+
let r = J(e), i = K.get(e);
|
|
471
1050
|
if (!r || r.type !== "import" || !i || r.status !== "paused" && r.status !== "failed") return;
|
|
472
1051
|
let a = Object.keys(n).length > 0, o = i.rowStates[t]?.validationErrors, s = !!(o && Object.keys(o).length > 0);
|
|
473
1052
|
a ? (i.skippedIndexes.add(t), s || (i.validationFailedCount += 1)) : (i.skippedIndexes.delete(t), s && --i.validationFailedCount), i.rowStates[t] = {
|
|
@@ -481,8 +1060,8 @@ function Ue(e, t, n) {
|
|
|
481
1060
|
rowStates: i.rowStates
|
|
482
1061
|
});
|
|
483
1062
|
}
|
|
484
|
-
function
|
|
485
|
-
let n = J(e), r =
|
|
1063
|
+
function bt(e, t) {
|
|
1064
|
+
let n = J(e), r = K.get(e);
|
|
486
1065
|
n && n.type === "import" && n.status === "paused" && r && (t.forEach((e) => {
|
|
487
1066
|
let t = r.rowStates[e];
|
|
488
1067
|
t?.status === "queued" && (t.validationErrors && Object.keys(t.validationErrors).length > 0 && --r.validationFailedCount, r.deletedIndexes.add(e), r.rowStates[e] = {
|
|
@@ -490,21 +1069,21 @@ function We(e, t) {
|
|
|
490
1069
|
fieldErrors: void 0
|
|
491
1070
|
});
|
|
492
1071
|
}), Y(e, {
|
|
493
|
-
total:
|
|
1072
|
+
total: st(r),
|
|
494
1073
|
validationFailedCount: r.validationFailedCount,
|
|
495
1074
|
rowStates: r.rowStates
|
|
496
1075
|
}));
|
|
497
1076
|
}
|
|
498
|
-
function
|
|
1077
|
+
function xt(e, t, n) {
|
|
499
1078
|
let r = J(e)?.rowStates?.[t];
|
|
500
1079
|
if (!r?.fieldErrors?.some((e) => n in e)) return;
|
|
501
1080
|
let i = r.fieldErrors.filter((e) => !(n in e));
|
|
502
|
-
|
|
1081
|
+
it(e, t, {
|
|
503
1082
|
...r,
|
|
504
1083
|
fieldErrors: i.length > 0 ? i : void 0
|
|
505
1084
|
});
|
|
506
1085
|
}
|
|
507
|
-
function
|
|
1086
|
+
function St(e) {
|
|
508
1087
|
let t = J(e);
|
|
509
1088
|
if (!t) return;
|
|
510
1089
|
if (t.status === "paused") {
|
|
@@ -513,43 +1092,43 @@ function Ke(e) {
|
|
|
513
1092
|
pausing: !1,
|
|
514
1093
|
canceling: !1,
|
|
515
1094
|
rowStates: (t.rowStates ?? []).map((e) => e.status === "queued" || e.status === "running" ? { status: "canceled" } : e)
|
|
516
|
-
}),
|
|
1095
|
+
}), K.delete(e), X.delete(e);
|
|
517
1096
|
return;
|
|
518
1097
|
}
|
|
519
1098
|
if (t.status !== "running") return;
|
|
520
1099
|
if (t.type === "export") {
|
|
521
1100
|
if (t.canceling) return;
|
|
522
|
-
let n =
|
|
1101
|
+
let n = Xe.get(e);
|
|
523
1102
|
if (!n) return;
|
|
524
1103
|
n.cancelRequested = !0, n.controller?.abort(), Y(e, { canceling: !0 });
|
|
525
1104
|
return;
|
|
526
1105
|
}
|
|
527
1106
|
if (t.canceling) return;
|
|
528
|
-
let n =
|
|
1107
|
+
let n = K.get(e);
|
|
529
1108
|
n && (n.cancelRequested = !0, Y(e, { canceling: !0 }));
|
|
530
1109
|
}
|
|
531
|
-
function
|
|
1110
|
+
function Ct(e) {
|
|
532
1111
|
let t = J(e);
|
|
533
|
-
t && (t.status === "running" &&
|
|
534
|
-
...
|
|
535
|
-
tasks:
|
|
536
|
-
},
|
|
1112
|
+
t && (t.status === "running" && q.get(e)?.abort(), Xe.delete(e), K.delete(e), X.delete(e), G = {
|
|
1113
|
+
...G,
|
|
1114
|
+
tasks: G.tasks.filter((t) => t.id !== e)
|
|
1115
|
+
}, Ze());
|
|
537
1116
|
}
|
|
538
|
-
function
|
|
1117
|
+
function wt(e, t) {
|
|
539
1118
|
try {
|
|
540
|
-
return
|
|
1119
|
+
return n(e, `${t}.xlsx`), !0;
|
|
541
1120
|
} catch (e) {
|
|
542
1121
|
return console.error(`下载失败: ${e}`), !1;
|
|
543
1122
|
}
|
|
544
1123
|
}
|
|
545
|
-
function
|
|
1124
|
+
function Tt(e) {
|
|
546
1125
|
let t = J(e);
|
|
547
|
-
return t?.type !== "export" || !t.blob || !t.fileName ? !1 :
|
|
1126
|
+
return t?.type !== "export" || !t.blob || !t.fileName ? !1 : wt(t.blob, t.fileName);
|
|
548
1127
|
}
|
|
549
|
-
function
|
|
550
|
-
|
|
1128
|
+
function Et() {
|
|
1129
|
+
q.forEach((e) => e.abort()), q.clear(), Xe.clear(), K.clear(), X.clear(), Z !== null && (clearTimeout(Z), Z = null), G = { tasks: [] }, Ze();
|
|
551
1130
|
}
|
|
552
|
-
function
|
|
1131
|
+
function Dt(e) {
|
|
553
1132
|
if (e.status !== "running" || e.total <= 0) return null;
|
|
554
1133
|
let t = Math.max(0, e.total - (e.validationFailedCount ?? 0) - e.processed);
|
|
555
1134
|
if (t === 0) return 0;
|
|
@@ -557,58 +1136,58 @@ function Ze(e) {
|
|
|
557
1136
|
let n = e.samples[0], r = e.samples[e.samples.length - 1], i = (r.time - n.time) / 1e3, a = r.processed - n.processed;
|
|
558
1137
|
return i <= 0 || a <= 0 ? null : t / (a / i);
|
|
559
1138
|
}
|
|
560
|
-
function
|
|
1139
|
+
function Ot(e) {
|
|
561
1140
|
return e.type === "import" ? e.successCount === void 0 ? e.rowStates?.filter((e) => e.status === "completed").length ?? e.processed : e.successCount : e.processed;
|
|
562
1141
|
}
|
|
563
|
-
function
|
|
564
|
-
return e.total <= 0 ? 0 : Math.min(100,
|
|
1142
|
+
function kt(e) {
|
|
1143
|
+
return e.total <= 0 ? 0 : Math.min(100, Ot(e) / e.total * 100);
|
|
565
1144
|
}
|
|
566
|
-
function
|
|
567
|
-
let t =
|
|
1145
|
+
function At(e) {
|
|
1146
|
+
let t = kt(e);
|
|
568
1147
|
return t >= 100 ? 100 : Math.trunc(t * 10) / 10;
|
|
569
1148
|
}
|
|
570
|
-
function
|
|
1149
|
+
function jt(e) {
|
|
571
1150
|
return `${(Math.trunc(e * 10) / 10).toFixed(1)}%`;
|
|
572
1151
|
}
|
|
573
|
-
function
|
|
1152
|
+
function Mt(e) {
|
|
574
1153
|
if (e === null) return "计算中...";
|
|
575
1154
|
let t = Math.ceil(e);
|
|
576
1155
|
return t < 60 ? `约 ${t} 秒` : `约 ${Math.floor(t / 60)} 分 ${t % 60} 秒`;
|
|
577
1156
|
}
|
|
578
1157
|
// src/react/useTaskDetail.ts
|
|
579
|
-
function
|
|
580
|
-
let t =
|
|
581
|
-
return
|
|
1158
|
+
function Nt(e) {
|
|
1159
|
+
let t = i(() => e ? et().find((t) => t.id === e) : void 0, [e]);
|
|
1160
|
+
return l($e, t);
|
|
582
1161
|
}
|
|
583
1162
|
// src/components/BatchExportButton.tsx
|
|
584
|
-
var
|
|
585
|
-
let [
|
|
586
|
-
return /* @__PURE__ */
|
|
1163
|
+
var Pt = ({ title: t, fieldSchemas: n, selectedRows: r, disabled: i }) => {
|
|
1164
|
+
let [a, o] = c(!1);
|
|
1165
|
+
return /* @__PURE__ */ O(h, {
|
|
587
1166
|
type: "default",
|
|
588
|
-
icon: /* @__PURE__ */
|
|
589
|
-
loading:
|
|
590
|
-
disabled:
|
|
1167
|
+
icon: /* @__PURE__ */ O(d, {}),
|
|
1168
|
+
loading: a,
|
|
1169
|
+
disabled: i ?? r.length === 0,
|
|
591
1170
|
onClick: async () => {
|
|
592
|
-
if (
|
|
593
|
-
if (
|
|
594
|
-
|
|
1171
|
+
if (r.length === 0) return;
|
|
1172
|
+
if (r.length > 2e4) {
|
|
1173
|
+
E.error(`导出数据 ${r.length.toLocaleString()} 条,超过上限 ${he} 条,请分批导出`);
|
|
595
1174
|
return;
|
|
596
1175
|
}
|
|
597
|
-
let
|
|
598
|
-
|
|
1176
|
+
let i = `${t}_${e().format("YYYYMMDDHHmmss")}`;
|
|
1177
|
+
o(!0);
|
|
599
1178
|
try {
|
|
600
|
-
await
|
|
1179
|
+
await Be(r, n, i), E.success("导出成功");
|
|
601
1180
|
} catch (e) {
|
|
602
|
-
console.error(`导出失败: ${e}`),
|
|
1181
|
+
console.error(`导出失败: ${e}`), E.error("导出失败");
|
|
603
1182
|
} finally {
|
|
604
|
-
|
|
1183
|
+
o(!1);
|
|
605
1184
|
}
|
|
606
1185
|
},
|
|
607
1186
|
children: "批量导出"
|
|
608
1187
|
});
|
|
609
1188
|
};
|
|
610
1189
|
// src/components/ExportTaskModal.tsx
|
|
611
|
-
function
|
|
1190
|
+
function Ft(e) {
|
|
612
1191
|
if (e.canceling) return "正在取消";
|
|
613
1192
|
if (e.finalizing) return "正在生成文件";
|
|
614
1193
|
switch (e.status) {
|
|
@@ -619,26 +1198,26 @@ function at(e) {
|
|
|
619
1198
|
case "canceled": return "已取消";
|
|
620
1199
|
}
|
|
621
1200
|
}
|
|
622
|
-
function
|
|
1201
|
+
function It(e) {
|
|
623
1202
|
if (e.canceling) return "warning";
|
|
624
1203
|
if (e.finalizing) return "processing";
|
|
625
1204
|
}
|
|
626
|
-
function
|
|
1205
|
+
function Lt(e) {
|
|
627
1206
|
switch (e.status) {
|
|
628
1207
|
case "failed": return "exception";
|
|
629
1208
|
case "completed": return "success";
|
|
630
1209
|
default: return "normal";
|
|
631
1210
|
}
|
|
632
1211
|
}
|
|
633
|
-
var
|
|
634
|
-
let n =
|
|
1212
|
+
var Rt = ({ taskId: e, onClose: t }) => {
|
|
1213
|
+
let n = Nt(e), { message: r } = m.useApp();
|
|
635
1214
|
if (!n) return null;
|
|
636
|
-
let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a =
|
|
637
|
-
|
|
1215
|
+
let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = At(n), o = () => {
|
|
1216
|
+
Ct(n.id), t();
|
|
638
1217
|
}, s = () => {
|
|
639
|
-
|
|
640
|
-
}, c =
|
|
641
|
-
return /* @__PURE__ */
|
|
1218
|
+
Tt(n.id) || r.error("文件不存在");
|
|
1219
|
+
}, c = Ft(n);
|
|
1220
|
+
return /* @__PURE__ */ O(y, {
|
|
642
1221
|
title: "导出任务",
|
|
643
1222
|
open: !0,
|
|
644
1223
|
maskClosable: !1,
|
|
@@ -647,154 +1226,154 @@ var ct = ({ taskId: e, onClose: t }) => {
|
|
|
647
1226
|
onCancel: () => {
|
|
648
1227
|
i && o();
|
|
649
1228
|
},
|
|
650
|
-
footer: i ? /* @__PURE__ */
|
|
1229
|
+
footer: i ? /* @__PURE__ */ k(g, {
|
|
651
1230
|
justify: "flex-end",
|
|
652
1231
|
gap: 8,
|
|
653
|
-
children: [n.status === "completed" ? /* @__PURE__ */
|
|
1232
|
+
children: [n.status === "completed" ? /* @__PURE__ */ O(h, {
|
|
654
1233
|
onClick: s,
|
|
655
1234
|
children: "重新下载"
|
|
656
|
-
}) : null, /* @__PURE__ */
|
|
1235
|
+
}) : null, /* @__PURE__ */ O(h, {
|
|
657
1236
|
type: "primary",
|
|
658
1237
|
onClick: o,
|
|
659
1238
|
children: "关闭"
|
|
660
1239
|
})]
|
|
661
|
-
}) : /* @__PURE__ */
|
|
1240
|
+
}) : /* @__PURE__ */ O(g, {
|
|
662
1241
|
justify: "flex-end",
|
|
663
|
-
children: /* @__PURE__ */
|
|
1242
|
+
children: /* @__PURE__ */ O(h, {
|
|
664
1243
|
danger: !0,
|
|
665
1244
|
loading: n.canceling,
|
|
666
|
-
disabled: n.canceling,
|
|
667
|
-
onClick: () =>
|
|
1245
|
+
disabled: n.canceling || n.finalizing,
|
|
1246
|
+
onClick: () => St(n.id),
|
|
668
1247
|
children: n.canceling ? "取消中" : "取消任务"
|
|
669
1248
|
})
|
|
670
1249
|
}),
|
|
671
|
-
children: /* @__PURE__ */
|
|
1250
|
+
children: /* @__PURE__ */ k(g, {
|
|
672
1251
|
vertical: !0,
|
|
673
1252
|
gap: 12,
|
|
674
1253
|
children: [
|
|
675
|
-
/* @__PURE__ */
|
|
1254
|
+
/* @__PURE__ */ k(g, {
|
|
676
1255
|
justify: "space-between",
|
|
677
1256
|
align: "center",
|
|
678
1257
|
gap: 12,
|
|
679
|
-
children: [/* @__PURE__ */
|
|
1258
|
+
children: [/* @__PURE__ */ O(T.Text, {
|
|
680
1259
|
strong: !0,
|
|
681
1260
|
ellipsis: !0,
|
|
682
1261
|
children: n.title
|
|
683
|
-
}), /* @__PURE__ */
|
|
684
|
-
color:
|
|
1262
|
+
}), /* @__PURE__ */ O(w, {
|
|
1263
|
+
color: It(n),
|
|
685
1264
|
children: c
|
|
686
1265
|
})]
|
|
687
1266
|
}),
|
|
688
|
-
/* @__PURE__ */
|
|
1267
|
+
/* @__PURE__ */ O(x, {
|
|
689
1268
|
percent: a,
|
|
690
|
-
format: () =>
|
|
691
|
-
status:
|
|
1269
|
+
format: () => jt(a),
|
|
1270
|
+
status: Lt(n),
|
|
692
1271
|
size: "small"
|
|
693
1272
|
}),
|
|
694
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ k(g, {
|
|
695
1274
|
justify: "space-between",
|
|
696
1275
|
children: [
|
|
697
|
-
/* @__PURE__ */
|
|
1276
|
+
/* @__PURE__ */ k(T.Text, {
|
|
698
1277
|
type: "secondary",
|
|
699
1278
|
children: [
|
|
700
1279
|
"已导出 ",
|
|
701
|
-
|
|
1280
|
+
Ot(n).toLocaleString(),
|
|
702
1281
|
" / 总数 ",
|
|
703
1282
|
n.total > 0 ? n.total.toLocaleString() : "--"
|
|
704
1283
|
]
|
|
705
1284
|
}),
|
|
706
|
-
n.finalizing ? /* @__PURE__ */
|
|
1285
|
+
n.finalizing ? /* @__PURE__ */ O(T.Text, {
|
|
707
1286
|
type: "secondary",
|
|
708
1287
|
children: "正在生成文件..."
|
|
709
1288
|
}) : null,
|
|
710
|
-
n.canceling ? /* @__PURE__ */
|
|
1289
|
+
n.canceling ? /* @__PURE__ */ O(T.Text, {
|
|
711
1290
|
type: "secondary",
|
|
712
1291
|
children: "正在取消..."
|
|
713
1292
|
}) : null
|
|
714
1293
|
]
|
|
715
1294
|
}),
|
|
716
|
-
n.errorMessage ? /* @__PURE__ */
|
|
1295
|
+
n.errorMessage ? /* @__PURE__ */ O(T.Text, {
|
|
717
1296
|
type: "danger",
|
|
718
1297
|
children: n.errorMessage
|
|
719
1298
|
}) : null
|
|
720
1299
|
]
|
|
721
1300
|
})
|
|
722
1301
|
});
|
|
723
|
-
},
|
|
724
|
-
let { message:
|
|
725
|
-
return
|
|
726
|
-
|
|
727
|
-
}, [
|
|
728
|
-
|
|
729
|
-
}, []), /* @__PURE__ */
|
|
1302
|
+
}, zt = ({ title: t, buttonText: n = "导出", fieldSchemas: r, filters: i, totalCount: o, disabled: l, fetchPage: u }) => {
|
|
1303
|
+
let { message: f } = m.useApp(), [p, g] = c(), _ = s(void 0);
|
|
1304
|
+
return a(() => {
|
|
1305
|
+
_.current = p;
|
|
1306
|
+
}, [p]), a(() => () => {
|
|
1307
|
+
_.current && Ct(_.current);
|
|
1308
|
+
}, []), /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(te, {
|
|
730
1309
|
title: "导出 Excel",
|
|
731
|
-
children: /* @__PURE__ */
|
|
1310
|
+
children: /* @__PURE__ */ O(h, {
|
|
732
1311
|
type: "default",
|
|
733
|
-
icon: /* @__PURE__ */
|
|
734
|
-
disabled:
|
|
1312
|
+
icon: /* @__PURE__ */ O(d, {}),
|
|
1313
|
+
disabled: l,
|
|
735
1314
|
onClick: () => {
|
|
736
|
-
if (
|
|
737
|
-
|
|
1315
|
+
if (o === 0) {
|
|
1316
|
+
f.error("没有可导出的数据");
|
|
738
1317
|
return;
|
|
739
1318
|
}
|
|
740
|
-
if (
|
|
741
|
-
|
|
1319
|
+
if (o > 2e4) {
|
|
1320
|
+
f.error(`导出数据共 ${o.toLocaleString()} 条, 超过上限 ${he} 条, 请缩小筛选范围后分批导出`);
|
|
742
1321
|
return;
|
|
743
1322
|
}
|
|
744
|
-
let
|
|
745
|
-
|
|
746
|
-
title: `${
|
|
747
|
-
fileName:
|
|
748
|
-
fieldSchemas:
|
|
749
|
-
fetchPage: (e, t) =>
|
|
750
|
-
...
|
|
1323
|
+
let n = `${t}_${e().format("YYYYMMDDHHmmss")}`;
|
|
1324
|
+
g(mt({
|
|
1325
|
+
title: `${t}导出`,
|
|
1326
|
+
fileName: n,
|
|
1327
|
+
fieldSchemas: r,
|
|
1328
|
+
fetchPage: (e, t) => u({
|
|
1329
|
+
...i,
|
|
751
1330
|
...e
|
|
752
1331
|
}, t)
|
|
753
1332
|
}));
|
|
754
1333
|
},
|
|
755
|
-
children:
|
|
1334
|
+
children: n
|
|
756
1335
|
})
|
|
757
|
-
}),
|
|
758
|
-
taskId:
|
|
759
|
-
onClose: () =>
|
|
1336
|
+
}), p ? /* @__PURE__ */ O(Rt, {
|
|
1337
|
+
taskId: p,
|
|
1338
|
+
onClose: () => g(void 0)
|
|
760
1339
|
}) : null] });
|
|
761
|
-
}, { Text:
|
|
1340
|
+
}, { Text: Bt } = T, Vt = ({ missingTitles: e, headerMessages: t }) => /* @__PURE__ */ k(g, {
|
|
762
1341
|
vertical: !0,
|
|
763
1342
|
gap: 4,
|
|
764
|
-
children: [e.length > 0 ? /* @__PURE__ */
|
|
1343
|
+
children: [e.length > 0 ? /* @__PURE__ */ O(Bt, { children: `缺少必填列: ${e.join(", ")}` }) : null, t.map((e, t) => /* @__PURE__ */ O(Bt, { children: e }, t))]
|
|
765
1344
|
});
|
|
766
1345
|
// src/react/useDebouncedValue.ts
|
|
767
|
-
function
|
|
768
|
-
let [n, r] =
|
|
769
|
-
return
|
|
1346
|
+
function Ht(e, t) {
|
|
1347
|
+
let [n, r] = c(e);
|
|
1348
|
+
return a(() => {
|
|
770
1349
|
let n = setTimeout(() => r(e), t);
|
|
771
1350
|
return () => clearTimeout(n);
|
|
772
1351
|
}, [e, t]), n;
|
|
773
1352
|
}
|
|
774
1353
|
// src/react/useThrottledValue.ts
|
|
775
|
-
function
|
|
776
|
-
let [n, r] =
|
|
777
|
-
return i.current = e,
|
|
778
|
-
let n = Date.now() -
|
|
779
|
-
n >= t ? (
|
|
780
|
-
|
|
1354
|
+
function Ut(e, t) {
|
|
1355
|
+
let [n, r] = c(e), i = s(e), o = s(0), l = s(null);
|
|
1356
|
+
return i.current = e, a(() => {
|
|
1357
|
+
let n = Date.now() - o.current;
|
|
1358
|
+
n >= t ? (o.current = Date.now(), r(e)) : l.current === null && (l.current = setTimeout(() => {
|
|
1359
|
+
l.current = null, o.current = Date.now(), r(i.current);
|
|
781
1360
|
}, t - n));
|
|
782
|
-
}, [e, t]),
|
|
783
|
-
|
|
1361
|
+
}, [e, t]), a(() => () => {
|
|
1362
|
+
l.current !== null && clearTimeout(l.current);
|
|
784
1363
|
}, []), n;
|
|
785
1364
|
}
|
|
786
1365
|
// src/components/ImportPreviewModal.tsx
|
|
787
|
-
function
|
|
788
|
-
return e == null || e === "" ? "" : Array.isArray(e) ?
|
|
1366
|
+
function Wt(e) {
|
|
1367
|
+
return e == null || e === "" ? "" : Array.isArray(e) ? P(e) : String(e);
|
|
789
1368
|
}
|
|
790
|
-
var
|
|
791
|
-
let { token: a } =
|
|
792
|
-
if (o && !n) return e.type === "boolean" ? /* @__PURE__ */
|
|
1369
|
+
var Gt = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
1370
|
+
let { token: a } = ne.useToken(), [o, s] = c(!1), [l, u] = c(!1), d = t.values[e.key];
|
|
1371
|
+
if (o && !n) return e.type === "boolean" ? /* @__PURE__ */ O(S, {
|
|
793
1372
|
autoFocus: !0,
|
|
794
1373
|
open: !0,
|
|
795
1374
|
size: "small",
|
|
796
1375
|
style: { width: "100%" },
|
|
797
|
-
value: typeof
|
|
1376
|
+
value: typeof d == "string" ? d : void 0,
|
|
798
1377
|
options: [{
|
|
799
1378
|
value: e.property.true_label,
|
|
800
1379
|
label: e.property.true_label
|
|
@@ -806,12 +1385,12 @@ var ht = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
806
1385
|
r(e), i(e), s(!1);
|
|
807
1386
|
},
|
|
808
1387
|
onBlur: () => s(!1)
|
|
809
|
-
}) : e.type === "single_choice" ? /* @__PURE__ */
|
|
1388
|
+
}) : e.type === "single_choice" ? /* @__PURE__ */ O(S, {
|
|
810
1389
|
autoFocus: !0,
|
|
811
1390
|
open: !0,
|
|
812
1391
|
size: "small",
|
|
813
1392
|
style: { width: "100%" },
|
|
814
|
-
value: typeof
|
|
1393
|
+
value: typeof d == "string" ? d : void 0,
|
|
815
1394
|
options: Object.keys(e.property.option_map).map((e) => ({
|
|
816
1395
|
value: e,
|
|
817
1396
|
label: e
|
|
@@ -820,49 +1399,49 @@ var ht = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
820
1399
|
r(e), i(e), s(!1);
|
|
821
1400
|
},
|
|
822
1401
|
onBlur: () => s(!1)
|
|
823
|
-
}) : e.type === "multiple_choice" ? /* @__PURE__ */
|
|
1402
|
+
}) : e.type === "multiple_choice" ? /* @__PURE__ */ O(S, {
|
|
824
1403
|
autoFocus: !0,
|
|
825
1404
|
open: !0,
|
|
826
1405
|
mode: "multiple",
|
|
827
1406
|
size: "small",
|
|
828
1407
|
style: { width: "100%" },
|
|
829
|
-
value: Array.isArray(
|
|
1408
|
+
value: Array.isArray(d) ? d : [],
|
|
830
1409
|
options: Object.keys(e.property.option_map).map((e) => ({
|
|
831
1410
|
value: e,
|
|
832
1411
|
label: e
|
|
833
1412
|
})),
|
|
834
1413
|
onChange: r,
|
|
835
1414
|
onBlur: () => {
|
|
836
|
-
s(!1), i(
|
|
1415
|
+
s(!1), i(d);
|
|
837
1416
|
}
|
|
838
|
-
}) : e.type === "number" ? /* @__PURE__ */
|
|
1417
|
+
}) : e.type === "number" ? /* @__PURE__ */ O(v, {
|
|
839
1418
|
autoFocus: !0,
|
|
840
1419
|
size: "small",
|
|
841
1420
|
style: { width: "100%" },
|
|
842
|
-
value: typeof
|
|
1421
|
+
value: typeof d == "number" || typeof d == "string" ? d : void 0,
|
|
843
1422
|
onChange: r,
|
|
844
1423
|
onBlur: () => {
|
|
845
|
-
s(!1), i(
|
|
1424
|
+
s(!1), i(d);
|
|
846
1425
|
},
|
|
847
1426
|
onPressEnter: () => {
|
|
848
|
-
s(!1), i(
|
|
1427
|
+
s(!1), i(d);
|
|
849
1428
|
}
|
|
850
|
-
}) : /* @__PURE__ */
|
|
1429
|
+
}) : /* @__PURE__ */ O(_, {
|
|
851
1430
|
autoFocus: !0,
|
|
852
1431
|
size: "small",
|
|
853
|
-
value: typeof
|
|
1432
|
+
value: typeof d == "string" ? d : "",
|
|
854
1433
|
placeholder: e.type === "list" ? "多个值用分号分隔(中英文均可)" : void 0,
|
|
855
1434
|
onChange: (e) => r(e.target.value),
|
|
856
1435
|
onBlur: () => {
|
|
857
|
-
s(!1), i(
|
|
1436
|
+
s(!1), i(d);
|
|
858
1437
|
},
|
|
859
1438
|
onPressEnter: () => {
|
|
860
|
-
s(!1), i(
|
|
1439
|
+
s(!1), i(d);
|
|
861
1440
|
}
|
|
862
1441
|
});
|
|
863
|
-
let
|
|
864
|
-
return /* @__PURE__ */
|
|
865
|
-
title:
|
|
1442
|
+
let f = Wt(d);
|
|
1443
|
+
return /* @__PURE__ */ O("div", {
|
|
1444
|
+
title: f || void 0,
|
|
866
1445
|
style: {
|
|
867
1446
|
height: 24,
|
|
868
1447
|
boxSizing: "border-box",
|
|
@@ -873,27 +1452,27 @@ var ht = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
873
1452
|
lineHeight: "22px",
|
|
874
1453
|
whiteSpace: "nowrap",
|
|
875
1454
|
overflow: "hidden",
|
|
876
|
-
border: `1px solid ${
|
|
1455
|
+
border: `1px solid ${l && !n ? a.colorBorder : "transparent"}`,
|
|
877
1456
|
borderRadius: a.borderRadiusSM,
|
|
878
1457
|
cursor: n ? "default" : "text"
|
|
879
1458
|
},
|
|
880
|
-
onMouseEnter: () =>
|
|
881
|
-
onMouseLeave: () =>
|
|
1459
|
+
onMouseEnter: () => u(!0),
|
|
1460
|
+
onMouseLeave: () => u(!1),
|
|
882
1461
|
onClick: () => {
|
|
883
1462
|
n || s(!0);
|
|
884
1463
|
},
|
|
885
|
-
children: /* @__PURE__ */
|
|
1464
|
+
children: /* @__PURE__ */ O("span", {
|
|
886
1465
|
style: {
|
|
887
1466
|
minWidth: 0,
|
|
888
1467
|
overflow: "hidden",
|
|
889
1468
|
textOverflow: "ellipsis",
|
|
890
1469
|
whiteSpace: "nowrap"
|
|
891
1470
|
},
|
|
892
|
-
children:
|
|
1471
|
+
children: f
|
|
893
1472
|
})
|
|
894
1473
|
});
|
|
895
1474
|
};
|
|
896
|
-
function
|
|
1475
|
+
function Kt(e) {
|
|
897
1476
|
if (e.canceling) return {
|
|
898
1477
|
label: "正在取消",
|
|
899
1478
|
color: "warning"
|
|
@@ -921,21 +1500,21 @@ function gt(e) {
|
|
|
921
1500
|
};
|
|
922
1501
|
}
|
|
923
1502
|
}
|
|
924
|
-
function
|
|
1503
|
+
function qt(e, t) {
|
|
925
1504
|
if (e.canceling) return "正在取消...";
|
|
926
1505
|
switch (e.status) {
|
|
927
|
-
case "running": return `预计剩余 ${
|
|
1506
|
+
case "running": return `预计剩余 ${Mt(t)}`;
|
|
928
1507
|
default: return null;
|
|
929
1508
|
}
|
|
930
1509
|
}
|
|
931
|
-
function
|
|
1510
|
+
function Jt(e) {
|
|
932
1511
|
switch (e.status) {
|
|
933
1512
|
case "failed": return "exception";
|
|
934
1513
|
case "completed": return "success";
|
|
935
1514
|
default: return "normal";
|
|
936
1515
|
}
|
|
937
1516
|
}
|
|
938
|
-
var
|
|
1517
|
+
var Yt = {
|
|
939
1518
|
valid: {
|
|
940
1519
|
label: "已校验",
|
|
941
1520
|
color: "success"
|
|
@@ -944,7 +1523,7 @@ var yt = {
|
|
|
944
1523
|
label: "校验失败",
|
|
945
1524
|
color: "error"
|
|
946
1525
|
}
|
|
947
|
-
},
|
|
1526
|
+
}, Xt = {
|
|
948
1527
|
pending: {
|
|
949
1528
|
label: "待导入",
|
|
950
1529
|
color: "default"
|
|
@@ -966,10 +1545,10 @@ var yt = {
|
|
|
966
1545
|
color: "warning"
|
|
967
1546
|
}
|
|
968
1547
|
};
|
|
969
|
-
function
|
|
1548
|
+
function Zt(e) {
|
|
970
1549
|
return Object.keys(e.errors).length > 0 ? "invalid" : "valid";
|
|
971
1550
|
}
|
|
972
|
-
function
|
|
1551
|
+
function Qt(e, t, n) {
|
|
973
1552
|
if (!t || e.taskIndex === void 0) return "pending";
|
|
974
1553
|
switch (n?.rowStates?.[e.taskIndex]?.status) {
|
|
975
1554
|
case "running": return "running";
|
|
@@ -979,19 +1558,19 @@ function St(e, t, n) {
|
|
|
979
1558
|
default: return "pending";
|
|
980
1559
|
}
|
|
981
1560
|
}
|
|
982
|
-
var
|
|
983
|
-
let [
|
|
984
|
-
|
|
985
|
-
},
|
|
986
|
-
|
|
987
|
-
let
|
|
1561
|
+
var $t = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys: a, onChangeCell: s, onSaveCell: l, onDelete: d, onConfirm: f, onClose: p }) => {
|
|
1562
|
+
let [m, v] = c("all"), [C, te] = c("all"), [E, ne] = c(""), re = Ht(E, 300), A = () => {
|
|
1563
|
+
v("all"), te("all"), ne("");
|
|
1564
|
+
}, j = Nt(i), [M, ie] = c(), ae = o(() => new Set(a), [a]), oe = n.filter((e) => ae.has(e.key));
|
|
1565
|
+
j && j !== M && ie(j);
|
|
1566
|
+
let N = j ?? (M?.id === i ? M : void 0), se = N ? Kt(N) : void 0, ce = !!(N && N.status !== "completed" && N.status !== "failed" && N.status !== "canceled"), le = Ut(N?.status === "running" ? Dt(N) : null, 1e3), ue = N ? qt(N, le) : null, P = (e) => e.taskIndex === void 0 ? void 0 : N?.rowStates?.[e.taskIndex], F = !(!j || j.status !== "failed" && j.status !== "paused"), de = (e) => {
|
|
988
1567
|
if (!i) return !0;
|
|
989
|
-
let t =
|
|
990
|
-
return
|
|
991
|
-
},
|
|
1568
|
+
let t = P(e)?.status;
|
|
1569
|
+
return F && (t === "queued" || t === "failed") ? !0 : F && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
|
|
1570
|
+
}, fe = (e) => !i || j?.status === "paused" && P(e)?.status === "queued", pe = o(() => ["valid", "invalid"].map((e) => ({
|
|
992
1571
|
value: e,
|
|
993
|
-
label:
|
|
994
|
-
})), []),
|
|
1572
|
+
label: Yt[e].label
|
|
1573
|
+
})), []), me = o(() => [
|
|
995
1574
|
"pending",
|
|
996
1575
|
"running",
|
|
997
1576
|
"completed",
|
|
@@ -999,33 +1578,33 @@ var Ct = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
999
1578
|
"canceled"
|
|
1000
1579
|
].map((e) => ({
|
|
1001
1580
|
value: e,
|
|
1002
|
-
label:
|
|
1003
|
-
})), []),
|
|
1004
|
-
if (!
|
|
1005
|
-
let e =
|
|
1006
|
-
return r.filter((t) =>
|
|
1581
|
+
label: Xt[e].label
|
|
1582
|
+
})), []), I = N?.status === "running", L = I ? "" : re, R = !I && m !== "all" && pe.some((e) => e.value === m) ? m : "all", z = !I && C !== "all" && me.some((e) => e.value === C) ? C : "all", B = R !== "all" || L.trim() !== "", V = z !== "all", H = B || V, U = o(() => {
|
|
1583
|
+
if (!B) return r;
|
|
1584
|
+
let e = L.trim().toLowerCase();
|
|
1585
|
+
return r.filter((t) => R !== "all" && Zt(t) !== R ? !1 : !e || Object.values(t.values).some((t) => (Array.isArray(t) ? t.join(" ") : String(t ?? "")).toLowerCase().includes(e)));
|
|
1007
1586
|
}, [
|
|
1008
1587
|
r,
|
|
1009
|
-
F,
|
|
1010
|
-
_e,
|
|
1011
|
-
L
|
|
1012
|
-
]), ye = pt(b, 300), B = R ? ye : void 0, be = y(() => R ? z.filter((e) => St(e, i, B) === I) : i && b ? z.slice() : z, [
|
|
1013
|
-
z,
|
|
1014
|
-
I,
|
|
1015
1588
|
R,
|
|
1016
|
-
|
|
1017
|
-
|
|
1589
|
+
L,
|
|
1590
|
+
B
|
|
1591
|
+
]), he = Ut(N, 300), ge = V ? he : void 0, _e = o(() => V ? U.filter((e) => Qt(e, i, ge) === z) : i && N ? U.slice() : U, [
|
|
1592
|
+
U,
|
|
1593
|
+
z,
|
|
1594
|
+
V,
|
|
1595
|
+
ge,
|
|
1596
|
+
N,
|
|
1018
1597
|
i
|
|
1019
|
-
]),
|
|
1598
|
+
]), ve = (e) => {
|
|
1020
1599
|
let t = Object.entries(e.errors);
|
|
1021
|
-
return /* @__PURE__ */
|
|
1600
|
+
return /* @__PURE__ */ O(g, {
|
|
1022
1601
|
vertical: !0,
|
|
1023
1602
|
gap: 4,
|
|
1024
1603
|
style: { maxWidth: 320 },
|
|
1025
1604
|
children: t.map(([e, t]) => {
|
|
1026
1605
|
let r = n.find((t) => t.key === e)?.title ?? e;
|
|
1027
|
-
return /* @__PURE__ */
|
|
1028
|
-
/* @__PURE__ */
|
|
1606
|
+
return /* @__PURE__ */ k(T.Text, { children: [
|
|
1607
|
+
/* @__PURE__ */ O(T.Text, {
|
|
1029
1608
|
strong: !0,
|
|
1030
1609
|
children: r
|
|
1031
1610
|
}),
|
|
@@ -1034,45 +1613,45 @@ var Ct = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1034
1613
|
] }, e);
|
|
1035
1614
|
})
|
|
1036
1615
|
});
|
|
1037
|
-
},
|
|
1038
|
-
let t =
|
|
1039
|
-
return t === "invalid" ? /* @__PURE__ */
|
|
1616
|
+
}, ye = (e) => {
|
|
1617
|
+
let t = Zt(e), n = Yt[t];
|
|
1618
|
+
return t === "invalid" ? /* @__PURE__ */ O(b, {
|
|
1040
1619
|
trigger: "hover",
|
|
1041
1620
|
placement: "topRight",
|
|
1042
1621
|
title: "错误信息",
|
|
1043
|
-
content:
|
|
1044
|
-
children: /* @__PURE__ */
|
|
1622
|
+
content: ve(e),
|
|
1623
|
+
children: /* @__PURE__ */ O(w, {
|
|
1045
1624
|
color: n.color,
|
|
1046
1625
|
children: n.label
|
|
1047
1626
|
})
|
|
1048
|
-
}) : /* @__PURE__ */
|
|
1627
|
+
}) : /* @__PURE__ */ O(w, {
|
|
1049
1628
|
color: n.color,
|
|
1050
1629
|
children: n.label
|
|
1051
1630
|
});
|
|
1052
|
-
},
|
|
1053
|
-
let t =
|
|
1054
|
-
if (r.length === 0) return /* @__PURE__ */
|
|
1631
|
+
}, be = (e) => {
|
|
1632
|
+
let t = P(e), r = t?.fieldErrors ?? [], i = t?.message;
|
|
1633
|
+
if (r.length === 0) return /* @__PURE__ */ O(T.Text, { children: i ?? "导入失败" });
|
|
1055
1634
|
let a = /* @__PURE__ */ new Map();
|
|
1056
1635
|
r.forEach((e) => {
|
|
1057
1636
|
let [t, r] = Object.entries(e)[0] ?? [], i = t === "detail" || t === "non_field_errors" ? "错误" : n.find((e) => e.key === t)?.title ?? "数据", o = a.get(i) ?? [];
|
|
1058
1637
|
o.push(r), a.set(i, o);
|
|
1059
1638
|
});
|
|
1060
1639
|
let o = [...a.entries()], s = o.slice(0, 3), c = o.length - s.length;
|
|
1061
|
-
return /* @__PURE__ */
|
|
1640
|
+
return /* @__PURE__ */ k(g, {
|
|
1062
1641
|
vertical: !0,
|
|
1063
1642
|
gap: 8,
|
|
1064
1643
|
style: { maxWidth: 360 },
|
|
1065
1644
|
children: [
|
|
1066
|
-
i ? /* @__PURE__ */
|
|
1067
|
-
s.map(([e, t]) => /* @__PURE__ */
|
|
1645
|
+
i ? /* @__PURE__ */ O(T.Text, { children: i }) : null,
|
|
1646
|
+
s.map(([e, t]) => /* @__PURE__ */ k(g, {
|
|
1068
1647
|
vertical: !0,
|
|
1069
1648
|
gap: 2,
|
|
1070
|
-
children: [/* @__PURE__ */
|
|
1649
|
+
children: [/* @__PURE__ */ O(T.Text, {
|
|
1071
1650
|
strong: !0,
|
|
1072
1651
|
children: e
|
|
1073
|
-
}), t.map((e, t) => /* @__PURE__ */
|
|
1652
|
+
}), t.map((e, t) => /* @__PURE__ */ k(T.Text, { children: ["• ", e] }, t))]
|
|
1074
1653
|
}, e)),
|
|
1075
|
-
c > 0 ? /* @__PURE__ */
|
|
1654
|
+
c > 0 ? /* @__PURE__ */ k(T.Text, {
|
|
1076
1655
|
type: "secondary",
|
|
1077
1656
|
children: [
|
|
1078
1657
|
"还有 ",
|
|
@@ -1082,36 +1661,36 @@ var Ct = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1082
1661
|
}) : null
|
|
1083
1662
|
]
|
|
1084
1663
|
});
|
|
1085
|
-
},
|
|
1086
|
-
let t =
|
|
1664
|
+
}, xe = (e) => {
|
|
1665
|
+
let t = Qt(e, i, N), n = Xt[t];
|
|
1087
1666
|
if (t === "failed") {
|
|
1088
|
-
let t =
|
|
1089
|
-
return /* @__PURE__ */
|
|
1667
|
+
let t = P(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
|
|
1668
|
+
return /* @__PURE__ */ O(b, {
|
|
1090
1669
|
trigger: "hover",
|
|
1091
1670
|
placement: "topRight",
|
|
1092
1671
|
title: "错误信息",
|
|
1093
|
-
content:
|
|
1094
|
-
children: /* @__PURE__ */
|
|
1672
|
+
content: be(e),
|
|
1673
|
+
children: /* @__PURE__ */ O(w, {
|
|
1095
1674
|
color: n.color,
|
|
1096
1675
|
children: i
|
|
1097
1676
|
})
|
|
1098
1677
|
});
|
|
1099
1678
|
}
|
|
1100
|
-
return /* @__PURE__ */
|
|
1679
|
+
return /* @__PURE__ */ O(w, {
|
|
1101
1680
|
color: n.color,
|
|
1102
1681
|
children: n.label
|
|
1103
1682
|
});
|
|
1104
|
-
},
|
|
1683
|
+
}, Se = (e) => /* @__PURE__ */ O(h, {
|
|
1105
1684
|
type: "primary",
|
|
1106
1685
|
danger: !0,
|
|
1107
1686
|
size: "small",
|
|
1108
|
-
disabled: !
|
|
1109
|
-
icon: /* @__PURE__ */
|
|
1687
|
+
disabled: !fe(e),
|
|
1688
|
+
icon: /* @__PURE__ */ O(u, {}),
|
|
1110
1689
|
onClick: () => {
|
|
1111
|
-
|
|
1690
|
+
d(e), j && e.taskIndex !== void 0 && bt(j.id, [e.taskIndex]);
|
|
1112
1691
|
},
|
|
1113
1692
|
children: "删除"
|
|
1114
|
-
}),
|
|
1693
|
+
}), Ce = [
|
|
1115
1694
|
{
|
|
1116
1695
|
key: "rowNumber",
|
|
1117
1696
|
title: "行号",
|
|
@@ -1119,17 +1698,17 @@ var Ct = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1119
1698
|
width: 60,
|
|
1120
1699
|
fixed: "left"
|
|
1121
1700
|
},
|
|
1122
|
-
...
|
|
1701
|
+
...oe.map((e) => ({
|
|
1123
1702
|
key: e.key,
|
|
1124
1703
|
title: e.title,
|
|
1125
1704
|
dataIndex: e.key,
|
|
1126
1705
|
width: 160,
|
|
1127
|
-
render: (t, n) => /* @__PURE__ */
|
|
1706
|
+
render: (t, n) => /* @__PURE__ */ O(Gt, {
|
|
1128
1707
|
field: e,
|
|
1129
1708
|
record: n,
|
|
1130
|
-
disabled: !
|
|
1131
|
-
onChange: (t) =>
|
|
1132
|
-
onSave: (t) =>
|
|
1709
|
+
disabled: !de(n),
|
|
1710
|
+
onChange: (t) => s(n, e, t),
|
|
1711
|
+
onSave: (t) => l(n, e, t)
|
|
1133
1712
|
})
|
|
1134
1713
|
})),
|
|
1135
1714
|
{
|
|
@@ -1137,24 +1716,24 @@ var Ct = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1137
1716
|
title: "数据状态",
|
|
1138
1717
|
width: 100,
|
|
1139
1718
|
fixed: "right",
|
|
1140
|
-
render: (e, t) =>
|
|
1719
|
+
render: (e, t) => ye(t)
|
|
1141
1720
|
},
|
|
1142
1721
|
{
|
|
1143
1722
|
key: "importStatus",
|
|
1144
1723
|
title: "导入状态",
|
|
1145
1724
|
width: 110,
|
|
1146
1725
|
fixed: "right",
|
|
1147
|
-
render: (e, t) =>
|
|
1726
|
+
render: (e, t) => xe(t)
|
|
1148
1727
|
},
|
|
1149
1728
|
{
|
|
1150
1729
|
key: "action",
|
|
1151
1730
|
title: "操作",
|
|
1152
1731
|
width: 80,
|
|
1153
1732
|
fixed: "right",
|
|
1154
|
-
render: (e, t) =>
|
|
1733
|
+
render: (e, t) => Se(t)
|
|
1155
1734
|
}
|
|
1156
|
-
],
|
|
1157
|
-
return /* @__PURE__ */
|
|
1735
|
+
], we = Math.max(1200, 60 + oe.length * 160 + 100 + 110 + 80), Te = N && N.total > 0 ? At(N) : 0, Ee = N?.failureCount ?? N?.failures?.length ?? 0, De = N?.validationFailedCount ?? r.filter((e) => Object.keys(e.errors).length > 0).length, Oe = r.filter((e) => Object.keys(e.errors).length > 0).length, ke = r.length > 0 && Oe === r.length;
|
|
1736
|
+
return /* @__PURE__ */ O(D, { children: /* @__PURE__ */ k(y, {
|
|
1158
1737
|
title: i ? `${t}导入` : `${t}导入预览`,
|
|
1159
1738
|
open: e,
|
|
1160
1739
|
width: "min(1400px, 96vw)",
|
|
@@ -1162,252 +1741,252 @@ var Ct = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1162
1741
|
closable: !1,
|
|
1163
1742
|
keyboard: !1,
|
|
1164
1743
|
onCancel: () => {
|
|
1165
|
-
|
|
1744
|
+
ce || p();
|
|
1166
1745
|
},
|
|
1167
1746
|
footer: (() => {
|
|
1168
|
-
if (!i) return /* @__PURE__ */
|
|
1747
|
+
if (!i) return /* @__PURE__ */ k(g, {
|
|
1169
1748
|
justify: "space-between",
|
|
1170
1749
|
align: "center",
|
|
1171
1750
|
gap: 8,
|
|
1172
1751
|
wrap: !0,
|
|
1173
|
-
children: [/* @__PURE__ */
|
|
1174
|
-
type:
|
|
1175
|
-
children:
|
|
1176
|
-
}) : null }), /* @__PURE__ */
|
|
1752
|
+
children: [/* @__PURE__ */ O("span", { children: r.length > 0 && Oe > 0 ? /* @__PURE__ */ O(T.Text, {
|
|
1753
|
+
type: ke ? "danger" : "secondary",
|
|
1754
|
+
children: ke ? "全部行校验失败, 请先修正后再导入" : `有 ${Oe} 行校验失败, 不会导入`
|
|
1755
|
+
}) : null }), /* @__PURE__ */ k(g, {
|
|
1177
1756
|
gap: 8,
|
|
1178
|
-
children: [/* @__PURE__ */
|
|
1179
|
-
onClick:
|
|
1757
|
+
children: [/* @__PURE__ */ O(h, {
|
|
1758
|
+
onClick: p,
|
|
1180
1759
|
children: "取消"
|
|
1181
|
-
}), /* @__PURE__ */
|
|
1760
|
+
}), /* @__PURE__ */ O(h, {
|
|
1182
1761
|
type: "primary",
|
|
1183
|
-
disabled: r.length === 0 ||
|
|
1762
|
+
disabled: r.length === 0 || ke,
|
|
1184
1763
|
onClick: () => {
|
|
1185
|
-
|
|
1764
|
+
A(), f();
|
|
1186
1765
|
},
|
|
1187
1766
|
children: "开始导入"
|
|
1188
1767
|
})]
|
|
1189
1768
|
})]
|
|
1190
1769
|
});
|
|
1191
|
-
if (!
|
|
1770
|
+
if (!j || !N) return /* @__PURE__ */ O(g, {
|
|
1192
1771
|
justify: "flex-end",
|
|
1193
|
-
children: /* @__PURE__ */
|
|
1194
|
-
onClick:
|
|
1772
|
+
children: /* @__PURE__ */ O(h, {
|
|
1773
|
+
onClick: p,
|
|
1195
1774
|
children: "关闭"
|
|
1196
1775
|
})
|
|
1197
1776
|
});
|
|
1198
|
-
let e =
|
|
1199
|
-
return /* @__PURE__ */
|
|
1777
|
+
let e = N.status === "running", t = N.status === "paused";
|
|
1778
|
+
return /* @__PURE__ */ k(g, {
|
|
1200
1779
|
justify: "flex-end",
|
|
1201
1780
|
gap: 8,
|
|
1202
1781
|
children: [
|
|
1203
|
-
e ? /* @__PURE__ */
|
|
1782
|
+
e ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(h, {
|
|
1204
1783
|
danger: !0,
|
|
1205
|
-
loading:
|
|
1206
|
-
disabled:
|
|
1207
|
-
onClick: () =>
|
|
1208
|
-
children:
|
|
1209
|
-
}), /* @__PURE__ */
|
|
1210
|
-
loading:
|
|
1211
|
-
disabled:
|
|
1212
|
-
onClick: () =>
|
|
1784
|
+
loading: N.canceling,
|
|
1785
|
+
disabled: N.canceling,
|
|
1786
|
+
onClick: () => St(N.id),
|
|
1787
|
+
children: N.canceling ? "取消中" : "取消任务"
|
|
1788
|
+
}), /* @__PURE__ */ O(h, {
|
|
1789
|
+
loading: N.pausing,
|
|
1790
|
+
disabled: N.canceling,
|
|
1791
|
+
onClick: () => _t(N.id),
|
|
1213
1792
|
children: "暂停"
|
|
1214
1793
|
})] }) : null,
|
|
1215
|
-
t ? /* @__PURE__ */
|
|
1794
|
+
t ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(h, {
|
|
1216
1795
|
danger: !0,
|
|
1217
|
-
onClick: () =>
|
|
1796
|
+
onClick: () => St(N.id),
|
|
1218
1797
|
children: "取消任务"
|
|
1219
|
-
}), /* @__PURE__ */
|
|
1798
|
+
}), /* @__PURE__ */ O(h, {
|
|
1220
1799
|
type: "primary",
|
|
1221
1800
|
onClick: () => {
|
|
1222
|
-
|
|
1801
|
+
A(), gt(N.id);
|
|
1223
1802
|
},
|
|
1224
1803
|
children: "继续导入"
|
|
1225
1804
|
})] }) : null,
|
|
1226
|
-
!e && !t ? /* @__PURE__ */
|
|
1805
|
+
!e && !t ? /* @__PURE__ */ O(h, {
|
|
1227
1806
|
type: "primary",
|
|
1228
|
-
onClick:
|
|
1807
|
+
onClick: p,
|
|
1229
1808
|
children: "关闭"
|
|
1230
1809
|
}) : null
|
|
1231
1810
|
]
|
|
1232
1811
|
});
|
|
1233
1812
|
})(),
|
|
1234
1813
|
children: [
|
|
1235
|
-
|
|
1814
|
+
N && se ? /* @__PURE__ */ k(g, {
|
|
1236
1815
|
vertical: !0,
|
|
1237
1816
|
gap: 4,
|
|
1238
1817
|
style: { marginBottom: 12 },
|
|
1239
|
-
children: [/* @__PURE__ */
|
|
1818
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1240
1819
|
justify: "space-between",
|
|
1241
1820
|
align: "center",
|
|
1242
|
-
children: [/* @__PURE__ */
|
|
1821
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1243
1822
|
type: "secondary",
|
|
1244
1823
|
children: [
|
|
1245
1824
|
"已导入 ",
|
|
1246
|
-
|
|
1825
|
+
Ot(N).toLocaleString(),
|
|
1247
1826
|
" / 总数 ",
|
|
1248
|
-
|
|
1827
|
+
N.total.toLocaleString()
|
|
1249
1828
|
]
|
|
1250
|
-
}), /* @__PURE__ */
|
|
1829
|
+
}), /* @__PURE__ */ k(g, {
|
|
1251
1830
|
align: "center",
|
|
1252
1831
|
gap: 8,
|
|
1253
1832
|
children: [
|
|
1254
|
-
|
|
1833
|
+
ue ? /* @__PURE__ */ O(T.Text, {
|
|
1255
1834
|
type: "secondary",
|
|
1256
|
-
children:
|
|
1835
|
+
children: ue
|
|
1257
1836
|
}) : null,
|
|
1258
|
-
|
|
1837
|
+
De > 0 ? /* @__PURE__ */ k(w, {
|
|
1259
1838
|
color: "error",
|
|
1260
1839
|
children: [
|
|
1261
1840
|
"校验失败 ",
|
|
1262
|
-
|
|
1841
|
+
De,
|
|
1263
1842
|
" 条"
|
|
1264
1843
|
]
|
|
1265
1844
|
}) : null,
|
|
1266
|
-
|
|
1845
|
+
Ee > 0 ? /* @__PURE__ */ k(w, {
|
|
1267
1846
|
color: "error",
|
|
1268
1847
|
children: [
|
|
1269
1848
|
"导入失败 ",
|
|
1270
|
-
|
|
1849
|
+
Ee,
|
|
1271
1850
|
" 条"
|
|
1272
1851
|
]
|
|
1273
1852
|
}) : null,
|
|
1274
|
-
/* @__PURE__ */
|
|
1275
|
-
color:
|
|
1276
|
-
children:
|
|
1853
|
+
/* @__PURE__ */ O(w, {
|
|
1854
|
+
color: se.color,
|
|
1855
|
+
children: se.label
|
|
1277
1856
|
})
|
|
1278
1857
|
]
|
|
1279
1858
|
})]
|
|
1280
|
-
}), /* @__PURE__ */
|
|
1281
|
-
percent:
|
|
1282
|
-
format: () =>
|
|
1283
|
-
status:
|
|
1859
|
+
}), /* @__PURE__ */ O(x, {
|
|
1860
|
+
percent: Te,
|
|
1861
|
+
format: () => jt(Te),
|
|
1862
|
+
status: Jt(N),
|
|
1284
1863
|
size: "small"
|
|
1285
1864
|
})]
|
|
1286
|
-
}) : i ? null : /* @__PURE__ */
|
|
1865
|
+
}) : i ? null : /* @__PURE__ */ k(g, {
|
|
1287
1866
|
vertical: !0,
|
|
1288
1867
|
gap: 4,
|
|
1289
1868
|
style: { marginBottom: 12 },
|
|
1290
|
-
children: [/* @__PURE__ */
|
|
1869
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1291
1870
|
justify: "space-between",
|
|
1292
1871
|
align: "center",
|
|
1293
|
-
children: [/* @__PURE__ */
|
|
1872
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1294
1873
|
type: "secondary",
|
|
1295
1874
|
children: ["总数 ", r.length.toLocaleString()]
|
|
1296
|
-
}), /* @__PURE__ */
|
|
1875
|
+
}), /* @__PURE__ */ k(g, {
|
|
1297
1876
|
align: "center",
|
|
1298
1877
|
gap: 8,
|
|
1299
|
-
children: [
|
|
1878
|
+
children: [De > 0 ? /* @__PURE__ */ k(w, {
|
|
1300
1879
|
color: "error",
|
|
1301
1880
|
children: [
|
|
1302
1881
|
"校验失败 ",
|
|
1303
|
-
|
|
1882
|
+
De,
|
|
1304
1883
|
" 条"
|
|
1305
1884
|
]
|
|
1306
|
-
}) : null, /* @__PURE__ */
|
|
1885
|
+
}) : null, /* @__PURE__ */ O(w, { children: "待导入" })]
|
|
1307
1886
|
})]
|
|
1308
|
-
}), /* @__PURE__ */
|
|
1887
|
+
}), /* @__PURE__ */ O(x, {
|
|
1309
1888
|
percent: 0,
|
|
1310
1889
|
format: () => "0.0%",
|
|
1311
1890
|
size: "small"
|
|
1312
1891
|
})]
|
|
1313
1892
|
}),
|
|
1314
|
-
/* @__PURE__ */
|
|
1893
|
+
/* @__PURE__ */ k(g, {
|
|
1315
1894
|
justify: "space-between",
|
|
1316
1895
|
align: "center",
|
|
1317
1896
|
gap: 8,
|
|
1318
1897
|
wrap: !0,
|
|
1319
1898
|
style: { marginBottom: 8 },
|
|
1320
|
-
children: [/* @__PURE__ */
|
|
1899
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1321
1900
|
align: "center",
|
|
1322
1901
|
gap: 8,
|
|
1323
1902
|
wrap: !0,
|
|
1324
1903
|
children: [
|
|
1325
|
-
/* @__PURE__ */
|
|
1904
|
+
/* @__PURE__ */ O(_, {
|
|
1326
1905
|
allowClear: !0,
|
|
1327
|
-
disabled:
|
|
1906
|
+
disabled: I,
|
|
1328
1907
|
placeholder: "搜索所有字段",
|
|
1329
|
-
value:
|
|
1908
|
+
value: I ? "" : E,
|
|
1330
1909
|
style: { width: 260 },
|
|
1331
1910
|
onChange: (e) => {
|
|
1332
1911
|
ne(e.target.value);
|
|
1333
1912
|
}
|
|
1334
1913
|
}),
|
|
1335
|
-
/* @__PURE__ */
|
|
1914
|
+
/* @__PURE__ */ O(S, {
|
|
1336
1915
|
allowClear: !0,
|
|
1337
|
-
disabled:
|
|
1916
|
+
disabled: I,
|
|
1338
1917
|
placeholder: "数据状态",
|
|
1339
|
-
value:
|
|
1340
|
-
options:
|
|
1918
|
+
value: R === "all" ? void 0 : R,
|
|
1919
|
+
options: pe,
|
|
1341
1920
|
style: { width: 140 },
|
|
1342
1921
|
onChange: (e) => {
|
|
1343
|
-
|
|
1922
|
+
v(e ?? "all");
|
|
1344
1923
|
}
|
|
1345
1924
|
}),
|
|
1346
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ O(S, {
|
|
1347
1926
|
allowClear: !0,
|
|
1348
|
-
disabled:
|
|
1927
|
+
disabled: I,
|
|
1349
1928
|
placeholder: "导入状态",
|
|
1350
|
-
value:
|
|
1351
|
-
options:
|
|
1929
|
+
value: z === "all" ? void 0 : z,
|
|
1930
|
+
options: me,
|
|
1352
1931
|
style: { width: 140 },
|
|
1353
1932
|
onChange: (e) => {
|
|
1354
1933
|
te(e ?? "all");
|
|
1355
1934
|
}
|
|
1356
1935
|
})
|
|
1357
1936
|
]
|
|
1358
|
-
}),
|
|
1937
|
+
}), H ? /* @__PURE__ */ k(T.Text, {
|
|
1359
1938
|
type: "secondary",
|
|
1360
1939
|
children: [
|
|
1361
1940
|
"筛选出 ",
|
|
1362
|
-
|
|
1941
|
+
_e.length,
|
|
1363
1942
|
" 条"
|
|
1364
1943
|
]
|
|
1365
1944
|
}) : null]
|
|
1366
1945
|
}),
|
|
1367
|
-
/* @__PURE__ */
|
|
1946
|
+
/* @__PURE__ */ O(ee, {
|
|
1368
1947
|
rowKey: "key",
|
|
1369
1948
|
size: "middle",
|
|
1370
1949
|
tableLayout: "fixed",
|
|
1371
1950
|
virtual: !0,
|
|
1372
|
-
columns:
|
|
1373
|
-
dataSource:
|
|
1951
|
+
columns: Ce,
|
|
1952
|
+
dataSource: _e,
|
|
1374
1953
|
pagination: !1,
|
|
1375
1954
|
scroll: {
|
|
1376
|
-
x:
|
|
1955
|
+
x: we,
|
|
1377
1956
|
y: 520
|
|
1378
1957
|
},
|
|
1379
|
-
locale: { emptyText:
|
|
1958
|
+
locale: { emptyText: H ? "没有符合条件的行" : void 0 }
|
|
1380
1959
|
})
|
|
1381
1960
|
]
|
|
1382
1961
|
}) });
|
|
1383
|
-
},
|
|
1962
|
+
}, en = "缺少列: ", tn = [
|
|
1384
1963
|
/期望为一个包含物件的列表/,
|
|
1385
1964
|
/expected a list/i,
|
|
1386
1965
|
/得到的类型是/,
|
|
1387
1966
|
/not a list/i
|
|
1388
1967
|
];
|
|
1389
|
-
function
|
|
1390
|
-
return
|
|
1968
|
+
function nn(e) {
|
|
1969
|
+
return tn.some((t) => t.test(e)) ? "数据格式不正确, 请检查导入内容" : e;
|
|
1391
1970
|
}
|
|
1392
|
-
function
|
|
1971
|
+
function rn(e) {
|
|
1393
1972
|
if (Object.keys(e).length === 0) return { success: !0 };
|
|
1394
1973
|
let t = [], n;
|
|
1395
1974
|
return Object.entries(e).forEach(([e, r]) => {
|
|
1396
1975
|
let i = Array.isArray(r) ? r : [r];
|
|
1397
|
-
e === "detail" || e === "non_field_errors" ? n = i.map((e) =>
|
|
1976
|
+
e === "detail" || e === "non_field_errors" ? n = i.map((e) => nn(String(e))).join("; ") : i.forEach((n) => t.push({ [e]: nn(String(n)) }));
|
|
1398
1977
|
}), {
|
|
1399
1978
|
success: !1,
|
|
1400
1979
|
...n ? { message: n } : {},
|
|
1401
1980
|
...t.length > 0 ? { fieldErrors: t } : {}
|
|
1402
1981
|
};
|
|
1403
1982
|
}
|
|
1404
|
-
function
|
|
1405
|
-
if (!
|
|
1406
|
-
let t =
|
|
1983
|
+
function an(e) {
|
|
1984
|
+
if (!Ue(e)) return "导入失败, 任务已暂停";
|
|
1985
|
+
let t = We(e);
|
|
1407
1986
|
return t === void 0 ? "网络异常, 任务已暂停" : t === 401 ? "登录已过期, 任务已暂停" : t === 403 ? "没有导入权限, 任务已暂停" : t === 404 ? "导入接口不存在, 任务已暂停" : t === 400 ? "请求参数错误, 任务已暂停" : t >= 500 ? "服务器错误, 任务已暂停" : "导入失败, 任务已暂停";
|
|
1408
1987
|
}
|
|
1409
|
-
function
|
|
1410
|
-
let t =
|
|
1988
|
+
function on(e) {
|
|
1989
|
+
let t = Ge(e);
|
|
1411
1990
|
if (t && typeof t == "object") {
|
|
1412
1991
|
let e = t;
|
|
1413
1992
|
if (typeof e.detail == "string") return e.detail;
|
|
@@ -1419,110 +1998,110 @@ function kt(e) {
|
|
|
1419
1998
|
}
|
|
1420
1999
|
return "导入数据校验失败";
|
|
1421
2000
|
}
|
|
1422
|
-
var
|
|
1423
|
-
let [i,
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}, [
|
|
1427
|
-
|
|
2001
|
+
var sn = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
2002
|
+
let [i, l] = c(!1), [u, d] = c([]), [g, _] = c(), [v, y] = c("empty"), [b, x] = c(!1), [S, ee] = c(!1), [w, T] = c([]), { modal: ne } = m.useApp(), re = s(null), A = s(void 0), j = o(() => ce(t), [t]);
|
|
2003
|
+
a(() => {
|
|
2004
|
+
A.current = g;
|
|
2005
|
+
}, [g]), a(() => () => {
|
|
2006
|
+
A.current && Ct(A.current);
|
|
1428
2007
|
}, []);
|
|
1429
|
-
let
|
|
1430
|
-
|
|
2008
|
+
let M = () => re.current?.click(), ie = (e, t) => {
|
|
2009
|
+
ne.warning({
|
|
1431
2010
|
title: t ?? (e.missingTitles.length > 0 ? "文件表头不完整" : "文件检查未通过"),
|
|
1432
2011
|
width: 480,
|
|
1433
|
-
content: /* @__PURE__ */
|
|
2012
|
+
content: /* @__PURE__ */ O(Vt, { ...e }),
|
|
1434
2013
|
okCancel: !0,
|
|
1435
2014
|
okText: "重新选择文件",
|
|
1436
2015
|
cancelText: "关闭",
|
|
1437
2016
|
closable: !0,
|
|
1438
|
-
onOk:
|
|
2017
|
+
onOk: M
|
|
1439
2018
|
});
|
|
1440
|
-
},
|
|
1441
|
-
if (e.size > 20971520)
|
|
2019
|
+
}, ae = async (e) => {
|
|
2020
|
+
if (e.size > 20971520) E.error("文件大小超过 20MB, 请拆分后再导入");
|
|
1442
2021
|
else {
|
|
1443
|
-
|
|
2022
|
+
_(void 0), T([]), x(!0);
|
|
1444
2023
|
try {
|
|
1445
|
-
let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await
|
|
2024
|
+
let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await He(e, j);
|
|
1446
2025
|
if (n.length > 0) {
|
|
1447
|
-
|
|
2026
|
+
ie({
|
|
1448
2027
|
missingTitles: [],
|
|
1449
2028
|
headerMessages: n
|
|
1450
2029
|
}, "文件里的公式还没有计算结果");
|
|
1451
2030
|
return;
|
|
1452
2031
|
}
|
|
1453
2032
|
if (t.length > 0) {
|
|
1454
|
-
|
|
1455
|
-
missingTitles: t.filter((e) => e.startsWith(
|
|
1456
|
-
headerMessages: t.filter((e) => !e.startsWith(
|
|
2033
|
+
ie({
|
|
2034
|
+
missingTitles: t.filter((e) => e.startsWith(en)).map((e) => e.slice(5)),
|
|
2035
|
+
headerMessages: t.filter((e) => !e.startsWith(en))
|
|
1457
2036
|
});
|
|
1458
2037
|
return;
|
|
1459
2038
|
}
|
|
1460
2039
|
if (r.length === 0) {
|
|
1461
|
-
|
|
2040
|
+
E.error("文件里没有数据行");
|
|
1462
2041
|
return;
|
|
1463
2042
|
}
|
|
1464
|
-
|
|
2043
|
+
T(i), y(`${e.name}-${Date.now()}`), d(r), l(!0);
|
|
1465
2044
|
} catch (e) {
|
|
1466
|
-
console.error(`导入文件解析失败: ${e}`),
|
|
2045
|
+
console.error(`导入文件解析失败: ${e}`), E.error("导入文件解析失败, 请确认上传的是 Excel 文件");
|
|
1467
2046
|
} finally {
|
|
1468
|
-
|
|
2047
|
+
x(!1);
|
|
1469
2048
|
}
|
|
1470
2049
|
}
|
|
1471
2050
|
};
|
|
1472
|
-
return /* @__PURE__ */
|
|
1473
|
-
/* @__PURE__ */
|
|
2051
|
+
return /* @__PURE__ */ k(D, { children: [
|
|
2052
|
+
/* @__PURE__ */ k(C.Compact, {
|
|
1474
2053
|
block: !0,
|
|
1475
|
-
children: [/* @__PURE__ */
|
|
2054
|
+
children: [/* @__PURE__ */ O(te, {
|
|
1476
2055
|
title: "Excel 导入",
|
|
1477
|
-
children: /* @__PURE__ */
|
|
2056
|
+
children: /* @__PURE__ */ O(h, {
|
|
1478
2057
|
type: "default",
|
|
1479
|
-
icon: /* @__PURE__ */
|
|
1480
|
-
loading:
|
|
1481
|
-
disabled:
|
|
1482
|
-
onClick:
|
|
2058
|
+
icon: /* @__PURE__ */ O(p, {}),
|
|
2059
|
+
loading: b,
|
|
2060
|
+
disabled: b,
|
|
2061
|
+
onClick: M,
|
|
1483
2062
|
children: "导入"
|
|
1484
2063
|
})
|
|
1485
|
-
}), /* @__PURE__ */
|
|
2064
|
+
}), /* @__PURE__ */ O(te, {
|
|
1486
2065
|
title: "Excel 导入模板",
|
|
1487
|
-
children: /* @__PURE__ */
|
|
2066
|
+
children: /* @__PURE__ */ O(h, {
|
|
1488
2067
|
type: "default",
|
|
1489
|
-
icon: /* @__PURE__ */
|
|
1490
|
-
loading:
|
|
2068
|
+
icon: /* @__PURE__ */ O(f, {}),
|
|
2069
|
+
loading: S,
|
|
1491
2070
|
onClick: async () => {
|
|
1492
|
-
|
|
2071
|
+
ee(!0);
|
|
1493
2072
|
try {
|
|
1494
|
-
await
|
|
2073
|
+
await Ve(j, `${e}导入模板`);
|
|
1495
2074
|
} catch (e) {
|
|
1496
|
-
console.error(`模板下载失败: ${e}`),
|
|
2075
|
+
console.error(`模板下载失败: ${e}`), E.error("模板下载失败");
|
|
1497
2076
|
} finally {
|
|
1498
|
-
|
|
2077
|
+
ee(!1);
|
|
1499
2078
|
}
|
|
1500
2079
|
},
|
|
1501
2080
|
children: "下载模板"
|
|
1502
2081
|
})
|
|
1503
2082
|
})]
|
|
1504
2083
|
}),
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
ref:
|
|
2084
|
+
/* @__PURE__ */ O("input", {
|
|
2085
|
+
ref: re,
|
|
1507
2086
|
type: "file",
|
|
1508
2087
|
accept: ".xlsx",
|
|
1509
2088
|
style: { display: "none" },
|
|
1510
2089
|
onChange: (e) => {
|
|
1511
2090
|
let t = e.target.files?.[0];
|
|
1512
|
-
e.target.value = "", t &&
|
|
2091
|
+
e.target.value = "", t && ae(t);
|
|
1513
2092
|
}
|
|
1514
2093
|
}),
|
|
1515
|
-
/* @__PURE__ */
|
|
2094
|
+
/* @__PURE__ */ O($t, {
|
|
1516
2095
|
open: i,
|
|
1517
2096
|
title: e,
|
|
1518
|
-
fieldSchemas:
|
|
1519
|
-
rows:
|
|
1520
|
-
taskId:
|
|
1521
|
-
includedKeys:
|
|
2097
|
+
fieldSchemas: j,
|
|
2098
|
+
rows: u,
|
|
2099
|
+
taskId: g,
|
|
2100
|
+
includedKeys: w,
|
|
1522
2101
|
onChangeCell: (e, t, n) => {
|
|
1523
|
-
if (!
|
|
1524
|
-
let r =
|
|
1525
|
-
|
|
2102
|
+
if (!w.includes(t.key)) return;
|
|
2103
|
+
let r = be(t, n), i = H(r.trim() === "" ? null : r, t);
|
|
2104
|
+
d((r) => r.map((r) => {
|
|
1526
2105
|
if (r.key !== e.key) return r;
|
|
1527
2106
|
let a = { ...r.errors };
|
|
1528
2107
|
return i.validateSuccess ? delete a[t.key] : a[t.key] = i.validateMessage, {
|
|
@@ -1536,14 +2115,14 @@ var At = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
1536
2115
|
}));
|
|
1537
2116
|
},
|
|
1538
2117
|
onSaveCell: (e, t, n) => {
|
|
1539
|
-
if (!
|
|
2118
|
+
if (!w.includes(t.key)) return;
|
|
1540
2119
|
let r = {
|
|
1541
2120
|
...e.values,
|
|
1542
2121
|
[t.key]: n
|
|
1543
2122
|
}, i = {};
|
|
1544
|
-
|
|
1545
|
-
if (!
|
|
1546
|
-
let t =
|
|
2123
|
+
j.forEach((e) => {
|
|
2124
|
+
if (!w.includes(e.key)) return;
|
|
2125
|
+
let t = be(e, r[e.key]), n = H(t.trim() === "" ? null : t, e);
|
|
1547
2126
|
n.validateSuccess || (i[e.key] = n.validateMessage);
|
|
1548
2127
|
});
|
|
1549
2128
|
let a = {
|
|
@@ -1551,48 +2130,48 @@ var At = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
1551
2130
|
values: r,
|
|
1552
2131
|
errors: i
|
|
1553
2132
|
};
|
|
1554
|
-
|
|
2133
|
+
d((t) => t.map((t) => t.key === e.key ? a : t)), g && e.taskIndex !== void 0 && (xt(g, e.taskIndex, t.key), yt(g, e.taskIndex, i), vt(g, e.taskIndex, a));
|
|
1555
2134
|
},
|
|
1556
2135
|
onDelete: (e) => {
|
|
1557
|
-
|
|
2136
|
+
d((t) => t.filter((t) => t.key !== e.key));
|
|
1558
2137
|
},
|
|
1559
2138
|
onConfirm: () => {
|
|
1560
|
-
let t =
|
|
2139
|
+
let t = u;
|
|
1561
2140
|
if (t.length === 0) {
|
|
1562
|
-
|
|
2141
|
+
E.error("没有可导入的数据");
|
|
1563
2142
|
return;
|
|
1564
2143
|
}
|
|
1565
2144
|
if (t.every((e) => Object.keys(e.errors).length > 0)) {
|
|
1566
|
-
|
|
2145
|
+
E.error("所有行都有校验错误, 请先修正后再导入");
|
|
1567
2146
|
return;
|
|
1568
2147
|
}
|
|
1569
2148
|
let i = t.map((e, t) => ({
|
|
1570
2149
|
...e,
|
|
1571
2150
|
taskIndex: t
|
|
1572
2151
|
}));
|
|
1573
|
-
|
|
1574
|
-
let a =
|
|
2152
|
+
d(i);
|
|
2153
|
+
let a = ht({
|
|
1575
2154
|
title: `${e}导入`,
|
|
1576
2155
|
rows: i,
|
|
1577
|
-
fieldSchemas:
|
|
1578
|
-
includedKeys:
|
|
2156
|
+
fieldSchemas: j,
|
|
2157
|
+
includedKeys: w,
|
|
1579
2158
|
importRows: async (e, t) => {
|
|
1580
2159
|
try {
|
|
1581
|
-
let r = await n(e.map((e) =>
|
|
1582
|
-
if (r.length !== e.length) throw new
|
|
1583
|
-
return r.map(
|
|
2160
|
+
let r = await n(e.map((e) => xe(e, j, w)), t);
|
|
2161
|
+
if (r.length !== e.length) throw new W("导入接口返回结果数量不正确, 任务已暂停");
|
|
2162
|
+
return r.map(rn);
|
|
1584
2163
|
} catch (e) {
|
|
1585
|
-
throw t.aborted || e instanceof
|
|
2164
|
+
throw t.aborted || e instanceof W ? e : We(e) === 422 ? Error(on(e)) : new W(an(e));
|
|
1586
2165
|
}
|
|
1587
2166
|
},
|
|
1588
2167
|
onFinished: r
|
|
1589
2168
|
});
|
|
1590
|
-
|
|
2169
|
+
_(a);
|
|
1591
2170
|
},
|
|
1592
2171
|
onClose: () => {
|
|
1593
|
-
|
|
2172
|
+
g && Ct(g), l(!1), _(void 0), d([]), T([]);
|
|
1594
2173
|
}
|
|
1595
|
-
},
|
|
2174
|
+
}, v)
|
|
1596
2175
|
] });
|
|
1597
2176
|
};
|
|
1598
|
-
export {
|
|
2177
|
+
export { Pt as BatchExportButton, zt as ExcelExportButton, sn as ExcelImportButton, Rt as ExportTaskModal, W as ImportPauseError, he as MAX_EXPORT_ROWS, ge as MAX_IMPORT_FILE_SIZE, U as MAX_IMPORT_ROWS, le as MULTI_VALUE_SEPARATOR, Ne as autoAdjustColumnWidths, ze as buildExportBlob, xe as buildImportPayload, St as cancelTask, xt as clearImportRowFieldError, gt as continueTask, bt as deleteImportRows, Ct as dismissTask, Ve as downloadImportTemplate, Tt as downloadTask, mt as enqueueExport, ht as enqueueImport, Be as exportExcel, jt as formatTaskPercent, Mt as formatTaskRemainingSeconds, At as getTaskDisplayPercent, Dt as getTaskRemainingSeconds, Ot as getTaskSuccessCount, et as getTasksSnapshot, ce as importableFields, P as joinMultiValues, He as parseImportFile, _t as pauseTask, Et as resetTasks, yt as setImportRowValidation, F as splitMultiValues, $e as subscribeTasks, vt as updateImportRowData, Nt as useTaskDetail, me as validateBooleanField, I as validateDateField, R as validateDateTimeField, H as validateField, z as validateListField, V as validateMultipleChoiceField, pe as validateNumberField, B as validateSingleChoiceField, fe as validateTextField, L as validateTimeField };
|