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