antd-import-export 1.0.7 → 1.0.8

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