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