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