antd-import-export 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -7,30 +7,30 @@ import { App as c, Button as l, Flex as u, Input as d, InputNumber as f, Modal a
7
7
  import { useCallback as C, useEffect as w, useMemo as T, useRef as E, useState as D, useSyncExternalStore as O } from "react";
8
8
  import { Fragment as ee, jsx as k, jsxs as A } from "react/jsx-runtime";
9
9
  // \0rolldown/runtime.js
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, {
10
+ var j = Object.create, M = Object.defineProperty, te = Object.getOwnPropertyDescriptor, N = Object.getOwnPropertyNames, ne = Object.getPrototypeOf, P = Object.prototype.hasOwnProperty, re = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), ie = (e, t, n, r) => {
11
+ if (t && typeof t == "object" || typeof t == "function") for (var i = N(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !P.call(e, s) && s !== n && M(e, s, {
12
12
  get: ((e) => t[e]).bind(null, s),
13
- enumerable: !(r = M(t, s)) || r.enumerable
13
+ enumerable: !(r = te(t, s)) || r.enumerable
14
14
  });
15
15
  return e;
16
- }, ie = (e, t, n) => (n = e == null ? {} : j(N(e)), re(t || !e || !e.__esModule || !P.call(e, "default") ? te(n, "default", {
16
+ }, ae = (e, t, n) => (n = e == null ? {} : j(ne(e)), ie(t || !e || !e.__esModule || !P.call(e, "default") ? M(n, "default", {
17
17
  value: e,
18
18
  enumerable: !0
19
19
  }) : n, e));
20
20
  // src/core/schema/index.ts
21
- function ae(e) {
21
+ function oe(e) {
22
22
  return e.filter((e) => e.importable !== !1);
23
23
  }
24
24
  // src/core/schema/multiValue.ts
25
- var I = ";", oe = /[;;]/;
26
- function L(e) {
25
+ var F = ";", se = /[;;]/;
26
+ function I(e) {
27
27
  return e.map((e) => String(e)).join(";");
28
28
  }
29
- function se(e) {
30
- return e.split(oe).map((e) => e.trim()).filter(Boolean);
29
+ function ce(e) {
30
+ return e.split(se).map((e) => e.trim()).filter(Boolean);
31
31
  }
32
32
  // src/core/schema/validate.ts
33
- var ce = /* @__PURE__ */ ie((/* @__PURE__ */ F(((e, t, n) => {
33
+ var le = /* @__PURE__ */ ae((/* @__PURE__ */ re(((e, t, n) => {
34
34
  (function(n, r) {
35
35
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs_plugin_customParseFormat = r();
36
36
  })(n, (function() {
@@ -187,8 +187,8 @@ var ce = /* @__PURE__ */ ie((/* @__PURE__ */ F(((e, t, n) => {
187
187
  };
188
188
  }));
189
189
  })))(), 1);
190
- e.extend(ce.default);
191
- function R(e, t) {
190
+ e.extend(le.default);
191
+ function L(e, t) {
192
192
  return e.length > t.property.max_length ? {
193
193
  validateSuccess: !1,
194
194
  validateMessage: `长度不能超过 ${t.property.max_length}`
@@ -197,7 +197,7 @@ function R(e, t) {
197
197
  validateValue: e
198
198
  };
199
199
  }
200
- function le(e, n) {
200
+ function ue(e, n) {
201
201
  let r = Number(e);
202
202
  if (!Number.isFinite(r)) return {
203
203
  validateSuccess: !1,
@@ -235,7 +235,7 @@ function le(e, n) {
235
235
  validateValue: r
236
236
  };
237
237
  }
238
- function ue(e, t) {
238
+ function de(e, t) {
239
239
  return e === t.property.true_label ? {
240
240
  validateSuccess: !0,
241
241
  validateValue: !0
@@ -247,7 +247,7 @@ function ue(e, t) {
247
247
  validateMessage: `内容必须是 ${t.property.true_label}|${t.property.false_label}`
248
248
  };
249
249
  }
250
- function de(t) {
250
+ function fe(t) {
251
251
  let n = e(t, "YYYY-MM-DD", !0);
252
252
  return n.isValid() ? {
253
253
  validateSuccess: !0,
@@ -257,7 +257,7 @@ function de(t) {
257
257
  validateMessage: "不是有效的日期格式 YYYY-MM-DD"
258
258
  };
259
259
  }
260
- function fe(e) {
260
+ function pe(e) {
261
261
  let t = /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/.exec(e);
262
262
  return t ? {
263
263
  validateSuccess: !0,
@@ -267,7 +267,7 @@ function fe(e) {
267
267
  validateMessage: "不是有效的日期格式 HH:mm"
268
268
  };
269
269
  }
270
- function pe(t) {
270
+ function me(t) {
271
271
  let n = e(t, "YYYY-MM-DD HH:mm:ss", !0);
272
272
  if (n.isValid()) return {
273
273
  validateSuccess: !0,
@@ -282,8 +282,8 @@ function pe(t) {
282
282
  validateMessage: "不是有效的日期时间格式 YYYY-MM-DD HH:mm 或 YYYY-MM-DD HH:mm:ss"
283
283
  };
284
284
  }
285
- function z(e, t) {
286
- let n = se(e);
285
+ function R(e, t) {
286
+ let n = ce(e);
287
287
  if (n.length > t.property.list_max_length) return {
288
288
  validateSuccess: !1,
289
289
  validateMessage: `列表长度不能超过 ${t.property.list_max_length}`
@@ -297,7 +297,7 @@ function z(e, t) {
297
297
  validateValue: n
298
298
  };
299
299
  }
300
- function me(e, t) {
300
+ function z(e, t) {
301
301
  return e in t.property.option_map ? {
302
302
  validateSuccess: !0,
303
303
  validateValue: t.property.option_map[e]
@@ -307,7 +307,7 @@ function me(e, t) {
307
307
  };
308
308
  }
309
309
  function B(e, t) {
310
- let n = se(e), r = t.property.option_map, i = [];
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 {
313
313
  validateSuccess: !1,
@@ -328,14 +328,14 @@ function V(e, t) {
328
328
  validateSuccess: !0,
329
329
  validateValue: t.property.default_value
330
330
  };
331
- if (t.type === "text") return R(e, t);
332
- if (t.type === "number") return le(e, t);
333
- if (t.type === "boolean") return ue(e, t);
334
- if (t.type === "date") return de(e);
335
- if (t.type === "time") return fe(e);
336
- if (t.type === "datetime") return pe(e);
337
- if (t.type === "list") return z(e, t);
338
- if (t.type === "single_choice") return me(e, t);
331
+ if (t.type === "text") return L(e, t);
332
+ if (t.type === "number") return ue(e, t);
333
+ if (t.type === "boolean") return de(e, t);
334
+ if (t.type === "date") return fe(e);
335
+ if (t.type === "time") return pe(e);
336
+ if (t.type === "datetime") return me(e);
337
+ if (t.type === "list") return R(e, t);
338
+ if (t.type === "single_choice") return z(e, t);
339
339
  if (t.type === "multiple_choice") return B(e, t);
340
340
  throw Error("未知的字段类型");
341
341
  }
@@ -357,65 +357,55 @@ function _e(e, t) {
357
357
  }
358
358
  }
359
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) ? L(t) : "" : e.type === "number" ? typeof t == "number" ? t : void 0 : t == null ? "" : String(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);
361
361
  }
362
362
  function ye(e, t) {
363
- return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? se(t) : t;
363
+ return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? ce(t) : t;
364
364
  }
365
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);
367
- }
368
- // src/core/excel/importRow.ts
369
- function xe(e, t, n) {
370
- let r = {};
371
- return t.forEach((t) => {
372
- if (!n.includes(t.key)) return;
373
- let i = be(t, e.values[t.key]), a = V(i.trim() === "" ? null : i, t);
374
- if (!a.validateSuccess) throw Error(a.validateMessage);
375
- r[t.key] = a.validateValue ?? null;
376
- }), r;
366
+ return t == null ? "" : e.type === "boolean" || e.type === "single_choice" ? String(t) : (e.type === "multiple_choice" || e.type === "list") && Array.isArray(t) ? I(t) : String(t);
377
367
  }
378
368
  // src/core/excel/parseSheet.ts
379
- function Se(e) {
369
+ function xe(e) {
380
370
  return !Number.isFinite(e) || e < 1 || e >= 2958466 ? null : new Date(Math.round((e - 25569) * 24 * 3600 * 1e3));
381
371
  }
382
- function Ce(e, t = !1) {
372
+ function Se(e, t = !1) {
383
373
  let n = String(e.getUTCMonth() + 1).padStart(2, "0"), r = String(e.getUTCDate()).padStart(2, "0"), i = `${e.getUTCFullYear()}-${n}-${r}`;
384
374
  if (!t) return i;
385
375
  let a = String(e.getUTCHours()).padStart(2, "0"), o = String(e.getUTCMinutes()).padStart(2, "0"), s = e.getUTCSeconds();
386
376
  return s === 0 ? `${i} ${a}:${o}` : `${i} ${a}:${o}:${s}`;
387
377
  }
388
- function we(e, t) {
378
+ function Ce(e, t) {
389
379
  let n = (e) => e.trim() === "" ? null : e.trim(), i = t === "datetime", a = t === "date" || i;
390
380
  if (e.type === r.ValueType.Null) return null;
391
- if (e.type === r.ValueType.Date) return Ce(e.value, i);
381
+ if (e.type === r.ValueType.Date) return Se(e.value, i);
392
382
  if (e.type === r.ValueType.Formula) {
393
383
  if (e.result === null || e.result === void 0) return null;
394
- if (e.result instanceof Date) return Ce(e.result, i);
384
+ if (e.result instanceof Date) return Se(e.result, i);
395
385
  if (a && typeof e.result == "number") {
396
- let t = Se(e.result);
397
- if (t) return Ce(t, i);
386
+ let t = xe(e.result);
387
+ if (t) return Se(t, i);
398
388
  }
399
389
  return n(String(e.result));
400
390
  }
401
391
  if (e.type === r.ValueType.Number) {
402
392
  if (a && typeof e.value == "number") {
403
- let t = Se(e.value);
404
- if (t) return Ce(t, i);
393
+ let t = xe(e.value);
394
+ if (t) return Se(t, i);
405
395
  }
406
396
  return n(String(e.value));
407
397
  }
408
398
  return n(e.text);
409
399
  }
410
- function Te(e) {
400
+ function we(e) {
411
401
  let t = e.property.default_value;
412
402
  if (t == null) return null;
413
403
  if (e.type === "boolean") return t ? e.property.true_label : e.property.false_label;
414
- if (Array.isArray(t)) return t.length > 0 ? L(t) : null;
404
+ if (Array.isArray(t)) return t.length > 0 ? I(t) : null;
415
405
  let n = String(t);
416
406
  return n.trim() === "" ? null : n;
417
407
  }
418
- function Ee(e, t) {
408
+ function Te(e, t) {
419
409
  let n = new Map(t.map((e) => [e.title, e])), r = [];
420
410
  for (let t = 1; t <= e.columnCount; t++) {
421
411
  let i = e.getRow(1).getCell(t).text.split("\n")[0].trim();
@@ -423,8 +413,8 @@ function Ee(e, t) {
423
413
  }
424
414
  return r;
425
415
  }
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);
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);
428
418
  if (t.forEach((e) => {
429
419
  e.property.required && !u.has(e.key) && n.push(`缺少列: ${e.title}`);
430
420
  }), n.length > 0) return {
@@ -438,7 +428,7 @@ function De(e, t) {
438
428
  if (l === 1) return;
439
429
  let f = {};
440
430
  if (c.forEach((t, n) => {
441
- t && (f[t.key] = we(e.getCell(n + 1), t.type));
431
+ t && (f[t.key] = Ce(e.getCell(n + 1), t.type));
442
432
  }), c.forEach((t, n) => {
443
433
  if (!t) return;
444
434
  let a = e.getCell(n + 1);
@@ -456,7 +446,7 @@ function De(e, t) {
456
446
  };
457
447
  t.forEach((e) => {
458
448
  if (!u.has(e.key)) return;
459
- let t = V(f[e.key] ?? Te(e), e);
449
+ let t = V(f[e.key] ?? we(e), e);
460
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);
461
451
  }), a.push(p);
462
452
  }), o > i.length && i.push(`还有 ${o - i.length} 个公式单元格没有保存计算结果`), {
@@ -467,7 +457,7 @@ function De(e, t) {
467
457
  };
468
458
  }
469
459
  // src/core/excel/worksheet.ts
470
- function G(t, n) {
460
+ function De(t, n) {
471
461
  let r = n[t.key];
472
462
  if (r == null || r === "") return null;
473
463
  switch (t.type) {
@@ -482,21 +472,21 @@ function G(t, n) {
482
472
  }
483
473
  case "multiple_choice": {
484
474
  let e = t.property.option_map;
485
- return L((Array.isArray(r) ? r : [r]).map((t) => Object.keys(e).find((n) => e[n] === t) ?? String(t)));
475
+ return I((Array.isArray(r) ? r : [r]).map((t) => Object.keys(e).find((n) => e[n] === t) ?? String(t)));
486
476
  }
487
477
  case "list": {
488
478
  let e = Array.isArray(r) ? r : [r], n = t.property.item_key;
489
- return L(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
479
+ return I(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
490
480
  }
491
481
  default: return r;
492
482
  }
493
483
  }
494
- function Oe(e, t) {
484
+ function G(e, t) {
495
485
  t.forEach((t, n) => {
496
486
  t.type === "text" && (e.getColumn(n + 1).numFmt = "@");
497
487
  });
498
488
  }
499
- function ke(e, t, n) {
489
+ function Oe(e, t, n) {
500
490
  let r = n.map((e) => e.importable === !1 ? `${e.title}\n(仅导出)` : e.title), i = e.addRow(r);
501
491
  i.height = 20 + (Math.max(1, ...r.map((e) => e.split("\n").length)) - 1) * 15, i.eachCell({ includeEmpty: !0 }, (e) => {
502
492
  e.font = {
@@ -512,16 +502,16 @@ function ke(e, t, n) {
512
502
  wrapText: !0
513
503
  };
514
504
  }), t.forEach((t) => {
515
- e.addRow(n.map((e) => G(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
505
+ e.addRow(n.map((e) => De(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
516
506
  e.alignment = {
517
507
  ...e.alignment,
518
508
  wrapText: !0,
519
509
  vertical: "top"
520
510
  };
521
511
  });
522
- }), Oe(e, n), Me(e);
512
+ }), G(e, n), je(e);
523
513
  }
524
- function Ae(e) {
514
+ function ke(e) {
525
515
  let t = [e.property.required ? "必填" : "可选"];
526
516
  switch (e.type) {
527
517
  case "text":
@@ -551,11 +541,11 @@ function Ae(e) {
551
541
  case "multiple_choice": t.push(`可多选, 分号分隔(中英文均可): ${Object.keys(e.property.option_map).join(" / ")}`);
552
542
  }
553
543
  e.key.endsWith("_name") ? t.push("填对应记录的名称") : e.key.endsWith("_number") && t.push("填对应记录的编号");
554
- let n = G(e, { [e.key]: e.property.default_value });
544
+ let n = De(e, { [e.key]: e.property.default_value });
555
545
  return t.push(`默认值: ${n == null || n === "" ? "空" : n}`), t.join("\n");
556
546
  }
557
- function je(e, t) {
558
- let n = t.map((e) => `${e.title}\n\n${Ae(e)}`), r = e.addRow(n);
547
+ function Ae(e, t) {
548
+ let n = t.map((e) => `${e.title}\n\n${ke(e)}`), r = e.addRow(n);
559
549
  r.height = 20 + (Math.max(1, ...n.map((e) => e.split("\n").length)) - 1) * 15, r.eachCell({ includeEmpty: !0 }, (e) => {
560
550
  e.font = {
561
551
  bold: !0,
@@ -569,9 +559,9 @@ function je(e, t) {
569
559
  vertical: "top",
570
560
  wrapText: !0
571
561
  };
572
- }), Oe(e, t), Me(e);
562
+ }), G(e, t), je(e);
573
563
  }
574
- function Me(e, t = 20, n = 60) {
564
+ function je(e, t = 20, n = 60) {
575
565
  let r = [];
576
566
  e.eachRow({ includeEmpty: !1 }, (e) => {
577
567
  e.eachCell({ includeEmpty: !1 }, (e, t) => {
@@ -593,47 +583,47 @@ function Me(e, t = 20, n = 60) {
593
583
  });
594
584
  }
595
585
  // src/core/excel/runtime.ts
596
- var Ne = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
597
- function Pe(e, t) {
586
+ var Me = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
587
+ function Ne(e, t) {
598
588
  n(e, `${t}.xlsx`);
599
589
  }
600
- var Fe;
601
- function Ie() {
602
- return Fe ??= import("exceljs").then((e) => e.default ?? e, (e) => {
603
- throw Fe = void 0, e;
604
- }), Fe;
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;
605
595
  }
606
- function Le() {
596
+ function Ie() {
607
597
  return new Promise((e) => {
608
598
  requestAnimationFrame(() => setTimeout(e, 0));
609
599
  });
610
600
  }
611
- function Re(e) {
601
+ function Le(e) {
612
602
  if (e?.aborted) throw new DOMException("任务已取消", "AbortError");
613
603
  }
614
- async function ze(e, t, n) {
615
- let r = await Ie();
616
- Re(n), await Le();
604
+ async function Re(e, t, n) {
605
+ let r = await Fe();
606
+ Le(n), await Ie();
617
607
  let i = new r.Workbook();
618
- ke(i.addWorksheet("Sheet"), e, t);
608
+ Oe(i.addWorksheet("Sheet"), e, t);
619
609
  let a = await i.xlsx.writeBuffer();
620
- return Re(n), new Blob([a], { type: Ne });
610
+ return Le(n), new Blob([a], { type: Me });
621
611
  }
622
- async function Be(e, t, n) {
623
- let r = await ze(e, t);
624
- return Pe(r, n), r;
612
+ async function ze(e, t, n) {
613
+ let r = await Re(e, t);
614
+ return Ne(r, n), r;
625
615
  }
626
- async function Ve(e, t) {
627
- let n = await Ie();
628
- await Le();
616
+ async function Be(e, t) {
617
+ let n = await Fe();
618
+ await Ie();
629
619
  let r = new n.Workbook();
630
- je(r.addWorksheet("导入模板"), e);
620
+ Ae(r.addWorksheet("导入模板"), e);
631
621
  let i = await r.xlsx.writeBuffer();
632
- Pe(new Blob([i], { type: Ne }), t);
622
+ Ne(new Blob([i], { type: Me }), t);
633
623
  }
634
- async function He(e, t) {
635
- let n = await Ie(), r = await e.arrayBuffer();
636
- await Le();
624
+ async function Ve(e, t) {
625
+ let n = await Fe(), r = await e.arrayBuffer();
626
+ await Ie();
637
627
  let i = new n.Workbook();
638
628
  if (await i.xlsx.load(r), i.worksheets.length > 1) return {
639
629
  headerMessages: ["文件包含多个工作表, 只支持单个工作表, 请删除其他工作表后再导入"],
@@ -642,7 +632,7 @@ async function He(e, t) {
642
632
  includedKeys: []
643
633
  };
644
634
  let a = i.worksheets[0];
645
- return a ? De(a, t) : {
635
+ return a ? Ee(a, t) : {
646
636
  headerMessages: ["文件里没有工作表"],
647
637
  formulaMessages: [],
648
638
  rows: [],
@@ -650,23 +640,23 @@ async function He(e, t) {
650
640
  };
651
641
  }
652
642
  // src/core/excel/exportFile.ts
653
- function Ue(t) {
643
+ function He(t) {
654
644
  return `${t}_${e().format("YYYYMMDDHHmmss")}`;
655
645
  }
656
- async function We(e) {
646
+ async function Ue(e) {
657
647
  let { title: t, fieldSchemas: n, rows: r, maxRows: i = U } = e;
658
648
  if (r.length === 0) throw Error("没有可导出的数据");
659
- return ge(r.length, i, "导出"), Be(r, n, Ue(t));
649
+ return ge(r.length, i, "导出"), ze(r, n, He(t));
660
650
  }
661
651
  // src/core/task/stats.ts
662
- function Ge(e, t) {
652
+ function We(e, t) {
663
653
  let n = Date.now();
664
654
  return [...e, {
665
655
  time: n,
666
656
  processed: t
667
657
  }].filter((e) => n - e.time <= 15e3).slice(-20);
668
658
  }
669
- function Ke(e) {
659
+ function Ge(e) {
670
660
  if (e.status !== "running" || e.total <= 0) return null;
671
661
  let t = Math.max(0, e.total - (e.validationFailedCount ?? 0) - e.processed);
672
662
  if (t === 0) return 0;
@@ -674,42 +664,42 @@ function Ke(e) {
674
664
  let n = e.samples[0], r = e.samples[e.samples.length - 1], i = (r.time - n.time) / 1e3, a = r.processed - n.processed;
675
665
  return i <= 0 || a <= 0 ? null : t / (a / i);
676
666
  }
677
- function qe(e) {
667
+ function Ke(e) {
678
668
  return e.type === "import" ? e.successCount === void 0 ? e.rowStates?.filter((e) => e.status === "completed").length ?? e.processed : e.successCount : e.processed;
679
669
  }
680
- function Je(e) {
681
- return e.total <= 0 ? 0 : Math.min(100, qe(e) / e.total * 100);
670
+ function qe(e) {
671
+ return e.total <= 0 ? 0 : Math.min(100, Ke(e) / e.total * 100);
682
672
  }
683
- function Ye(e) {
673
+ function Je(e) {
684
674
  if (e.finalizing) return 100;
685
- let t = Je(e);
675
+ let t = qe(e);
686
676
  return t >= 100 ? 100 : Math.trunc(t * 10) / 10;
687
677
  }
688
- function Xe(e) {
678
+ function Ye(e) {
689
679
  return `${(Math.trunc(e * 10) / 10).toFixed(1)}%`;
690
680
  }
691
- function Ze(e) {
681
+ function Xe(e) {
692
682
  if (e === null) return "计算中...";
693
683
  let t = Math.ceil(e);
694
684
  return t < 60 ? `约 ${t} 秒` : `约 ${Math.floor(t / 60)} 分 ${t % 60} 秒`;
695
685
  }
696
686
  // 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());
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());
700
690
  }
701
- function tt(e) {
702
- return Qe.add(e), () => {
703
- Qe.delete(e);
691
+ function et(e) {
692
+ return Ze.add(e), () => {
693
+ Ze.delete(e);
704
694
  };
705
695
  }
706
- function nt(e) {
707
- return tt(e);
696
+ function tt(e) {
697
+ return et(e);
708
698
  }
709
- function rt() {
699
+ function nt() {
710
700
  return K.tasks;
711
701
  }
712
- function it() {
702
+ function rt() {
713
703
  return `task-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
714
704
  }
715
705
  function Y(e) {
@@ -723,72 +713,72 @@ function X(e, t) {
723
713
  n && (K = {
724
714
  ...K,
725
715
  tasks: r
726
- }, et());
716
+ }, $e());
727
717
  }
728
- function at(e) {
718
+ function it(e) {
729
719
  K = {
730
720
  ...K,
731
721
  tasks: [...K.tasks, e]
732
- }, et();
722
+ }, $e();
733
723
  }
734
- function ot(e) {
724
+ function at(e) {
735
725
  K = {
736
726
  ...K,
737
727
  tasks: K.tasks.filter((t) => t.id !== e)
738
- }, et();
728
+ }, $e();
739
729
  }
740
- function st() {
741
- J.forEach((e) => e.abort()), J.clear(), $e.clear(), q.clear(), K = { tasks: [] }, et();
730
+ function ot() {
731
+ J.forEach((e) => e.abort()), J.clear(), Qe.clear(), q.clear(), K = { tasks: [] }, $e();
742
732
  }
743
733
  // src/core/task/types.ts
744
- var ct = class extends Error {
734
+ var st = class extends Error {
745
735
  constructor(e) {
746
736
  super(e), this.name = "ImportPauseError";
747
737
  }
748
- }, lt = 100, ut = 100, Z = /* @__PURE__ */ new Set(), Q = null;
749
- function dt(e, t, n) {
738
+ }, ct = 100, lt = 100, Z = /* @__PURE__ */ new Set(), Q = null;
739
+ function ut(e, t, n) {
750
740
  let r = q.get(e);
751
741
  r && (r.rowStates[t] = {
752
742
  ...r.rowStates[t],
753
743
  ...n
754
- }, ft(e));
744
+ }, dt(e));
755
745
  }
756
- function ft(e) {
746
+ function dt(e) {
757
747
  Z.add(e), Q === null && (Q = setTimeout(() => {
758
748
  Q = null;
759
749
  let e = [...Z];
760
- Z.clear(), e.forEach(gt);
761
- }, ut));
750
+ Z.clear(), e.forEach(ht);
751
+ }, lt));
762
752
  }
763
- function pt(e) {
753
+ function ft(e) {
764
754
  Z.delete(e);
765
755
  }
766
- function mt() {
756
+ function pt() {
767
757
  Z.clear(), Q !== null && (clearTimeout(Q), Q = null);
768
758
  }
769
- function ht(e, t) {
759
+ function mt(e, t) {
770
760
  return {
771
761
  processed: t.processed,
772
- total: _t(t),
762
+ total: gt(t),
773
763
  successCount: t.successCount,
774
764
  failureCount: t.failures.length,
775
765
  validationFailedCount: t.validationFailedCount,
776
766
  failures: t.failures,
777
767
  rowStates: t.rowStates,
778
- samples: Ge(Y(e)?.samples ?? [], t.processed)
768
+ samples: We(Y(e)?.samples ?? [], t.processed)
779
769
  };
780
770
  }
781
- function gt(e) {
771
+ function ht(e) {
782
772
  let t = q.get(e);
783
- t && Y(e) && X(e, ht(e, t));
773
+ t && Y(e) && X(e, mt(e, t));
784
774
  }
785
- function _t(e) {
775
+ function gt(e) {
786
776
  return e.options.rows.length - e.deletedIndexes.size;
787
777
  }
788
- function vt(e) {
778
+ function _t(e) {
789
779
  return `成功 ${e.successCount} 条, 失败 ${e.failures.length} 条, 可修正失败行后继续`;
790
780
  }
791
- async function yt(e, t, n) {
781
+ async function vt(e, t, n) {
792
782
  let r = t.options.rows.length;
793
783
  if (t.controller = n, t.pauseRequested = !1, t.cancelRequested = !1, t.runFailureCount = 0, r === 0) {
794
784
  X(e, {
@@ -809,7 +799,7 @@ async function yt(e, t, n) {
809
799
  return;
810
800
  }
811
801
  X(e, {
812
- ...ht(e, t),
802
+ ...mt(e, t),
813
803
  status: "running",
814
804
  samples: [{
815
805
  time: Date.now(),
@@ -830,7 +820,7 @@ async function yt(e, t, n) {
830
820
  let r = o();
831
821
  if (r.length === 0) return;
832
822
  r.forEach((t) => {
833
- dt(e, t, {
823
+ ut(e, t, {
834
824
  status: "running",
835
825
  message: void 0,
836
826
  fieldErrors: void 0
@@ -839,10 +829,10 @@ async function yt(e, t, n) {
839
829
  try {
840
830
  let i = r.map((e) => t.options.rows[e]), a = await t.options.importRows(i, n.signal);
841
831
  if (n.signal.aborted) return;
842
- if (a.length !== r.length) throw new ct("导入接口返回结果数量不正确, 任务已暂停");
832
+ if (a.length !== r.length) throw new st("导入接口返回结果数量不正确, 任务已暂停");
843
833
  a.forEach((n, i) => {
844
834
  let a = r[i], o = t.options.rows[a];
845
- n.success ? (t.successCount += 1, dt(e, a, {
835
+ n.success ? (t.successCount += 1, ut(e, a, {
846
836
  status: "completed",
847
837
  fieldErrors: void 0
848
838
  })) : (t.failures.push({
@@ -850,68 +840,68 @@ async function yt(e, t, n) {
850
840
  rowNumber: o.rowNumber,
851
841
  message: n.message ?? "导入失败",
852
842
  fieldErrors: n.fieldErrors
853
- }), dt(e, a, {
843
+ }), ut(e, a, {
854
844
  status: "failed",
855
845
  message: n.message,
856
846
  fieldErrors: n.fieldErrors
857
- }), t.runFailureCount += 1, t.runFailureCount > lt && (t.pauseRequested = !0));
847
+ }), t.runFailureCount += 1, t.runFailureCount > ct && (t.pauseRequested = !0));
858
848
  });
859
849
  } catch (i) {
860
850
  if (n.signal.aborted) return;
861
- let a = i instanceof ct, o = `${i instanceof Error ? i.message : "导入失败"}(该批结果未知,重试可能重复)`;
851
+ let a = i instanceof st, o = `${i instanceof Error ? i.message : "导入失败"}(该批结果未知,重试可能重复)`;
862
852
  r.forEach((n) => {
863
853
  t.failures.push({
864
854
  index: n,
865
855
  rowNumber: t.options.rows[n].rowNumber,
866
856
  message: o
867
- }), dt(e, n, {
857
+ }), ut(e, n, {
868
858
  status: "failed",
869
859
  message: o
870
860
  }), t.runFailureCount += 1;
871
- }), a ? (t.pauseRequested = !0, n.abort()) : t.runFailureCount > lt && (t.pauseRequested = !0);
861
+ }), a ? (t.pauseRequested = !0, n.abort()) : t.runFailureCount > ct && (t.pauseRequested = !0);
872
862
  } finally {
873
- t.processed += r.length, ft(e);
863
+ t.processed += r.length, dt(e);
874
864
  }
875
865
  }
876
866
  }, c = Math.min(a, Math.max(1, r));
877
- await Promise.all(Array.from({ length: c }, () => s())), t.controller = null, Y(e) && Ct(e, t, n);
867
+ await Promise.all(Array.from({ length: c }, () => s())), t.controller = null, Y(e) && St(e, t, n);
878
868
  }
879
- function bt(e) {
869
+ function yt(e) {
880
870
  e.rowStates = e.rowStates.map((e) => e.status === "queued" || e.status === "running" ? { status: "canceled" } : e);
881
871
  }
882
- function xt(e) {
872
+ function bt(e) {
883
873
  e.rowStates = e.rowStates.map((e) => e.status === "running" ? {
884
874
  status: "queued",
885
875
  validationErrors: e.validationErrors
886
876
  } : e);
887
877
  }
888
- function St(e) {
878
+ function xt(e) {
889
879
  return e.failures.length > 0 ? `累计失败 ${e.failures.length} 条, 任务已暂停, 可继续导入` : void 0;
890
880
  }
891
881
  function $(e, t, n) {
892
882
  X(e, {
893
- ...ht(e, t),
883
+ ...mt(e, t),
894
884
  pausing: !1,
895
885
  ...n
896
886
  }), t.options.onFinished?.();
897
887
  }
898
- function Ct(e, t, n) {
899
- if (pt(e), t.cancelRequested) {
900
- bt(t), $(e, t, {
888
+ function St(e, t, n) {
889
+ if (ft(e), t.cancelRequested) {
890
+ yt(t), $(e, t, {
901
891
  status: "canceled",
902
892
  canceling: !1
903
893
  });
904
894
  return;
905
895
  }
906
896
  if (t.pauseRequested && n.signal.aborted) {
907
- xt(t), $(e, t, {
897
+ bt(t), $(e, t, {
908
898
  status: "paused",
909
- errorMessage: St(t)
899
+ errorMessage: xt(t)
910
900
  });
911
901
  return;
912
902
  }
913
903
  if (n.signal.aborted) {
914
- bt(t), $(e, t, {
904
+ yt(t), $(e, t, {
915
905
  status: "canceled",
916
906
  canceling: !1
917
907
  });
@@ -920,14 +910,14 @@ function Ct(e, t, n) {
920
910
  if (t.pauseRequested && t.nextIndex < t.options.rows.length) {
921
911
  $(e, t, {
922
912
  status: "paused",
923
- errorMessage: St(t)
913
+ errorMessage: xt(t)
924
914
  });
925
915
  return;
926
916
  }
927
917
  if (t.failures.length > 0) {
928
918
  $(e, t, {
929
919
  status: "paused",
930
- errorMessage: vt(t)
920
+ errorMessage: _t(t)
931
921
  });
932
922
  return;
933
923
  }
@@ -937,14 +927,14 @@ function Ct(e, t, n) {
937
927
  errorMessage: `有 ${r} 条校验失败数据待修复`
938
928
  }) : $(e, t, { status: "completed" });
939
929
  }
940
- function wt(e, t) {
930
+ function Ct(e, t) {
941
931
  let n = new AbortController();
942
- J.set(e, n), yt(e, t, n).finally(() => {
932
+ J.set(e, n), vt(e, t, n).finally(() => {
943
933
  J.delete(e), Z.delete(e), Y(e)?.status !== "paused" && q.delete(e);
944
934
  });
945
935
  }
946
- function Tt(e) {
947
- let t = it(), n = e.rows.map((e) => ({
936
+ function wt(e) {
937
+ let t = rt(), n = e.rows.map((e) => ({
948
938
  status: "queued",
949
939
  validationErrors: Object.keys(e.errors).length > 0 ? e.errors : void 0
950
940
  })), r = new Set(e.rows.flatMap((e, t) => Object.keys(e.errors).length > 0 ? [t] : [])), i = r.size, a = {
@@ -976,9 +966,9 @@ function Tt(e) {
976
966
  runFailureCount: 0,
977
967
  controller: null
978
968
  };
979
- return q.set(t, o), at(a), wt(t, o), t;
969
+ return q.set(t, o), it(a), Ct(t, o), t;
980
970
  }
981
- function Et(e) {
971
+ function Tt(e) {
982
972
  let t = Y(e);
983
973
  if (!t || t.type !== "import" || t.status !== "paused") return;
984
974
  let n = q.get(e);
@@ -998,21 +988,21 @@ function Et(e) {
998
988
  failures: [],
999
989
  rowStates: i,
1000
990
  errorMessage: void 0
1001
- }), wt(e, n);
991
+ }), Ct(e, n);
1002
992
  }
1003
- function Dt(e) {
993
+ function Et(e) {
1004
994
  let t = Y(e);
1005
995
  if (!t || t.type !== "import" || t.status !== "running" || t.canceling) return;
1006
996
  let n = q.get(e);
1007
997
  n && (n.pauseRequested = !0, X(e, { pausing: !0 }));
1008
998
  }
1009
- function Ot(e, t, n) {
999
+ function Dt(e, t, n) {
1010
1000
  let r = Y(e), i = q.get(e);
1011
1001
  if (!r || r.type !== "import" || r.status !== "paused" && r.status !== "failed" || !i) return;
1012
1002
  let a = r.rowStates?.[t]?.status;
1013
1003
  (a === "queued" || a === "failed") && (i.options.rows[t] = n);
1014
1004
  }
1015
- function kt(e, t, n) {
1005
+ function Ot(e, t, n) {
1016
1006
  let r = Y(e), i = q.get(e);
1017
1007
  if (!r || r.type !== "import" || !i || r.status !== "paused" && r.status !== "failed") return;
1018
1008
  let a = Object.keys(n).length > 0, o = i.rowStates[t]?.validationErrors, s = !!(o && Object.keys(o).length > 0);
@@ -1027,7 +1017,7 @@ function kt(e, t, n) {
1027
1017
  rowStates: i.rowStates
1028
1018
  });
1029
1019
  }
1030
- function At(e, t) {
1020
+ function kt(e, t) {
1031
1021
  let n = Y(e), r = q.get(e);
1032
1022
  n && n.type === "import" && n.status === "paused" && r && (t.forEach((e) => {
1033
1023
  let t = r.rowStates[e];
@@ -1036,37 +1026,51 @@ function At(e, t) {
1036
1026
  fieldErrors: void 0
1037
1027
  });
1038
1028
  }), X(e, {
1039
- total: _t(r),
1029
+ total: gt(r),
1040
1030
  validationFailedCount: r.validationFailedCount,
1041
1031
  rowStates: r.rowStates
1042
1032
  }));
1043
1033
  }
1044
- function jt(e, t, n) {
1034
+ function At(e, t, n) {
1045
1035
  let r = Y(e)?.rowStates?.[t];
1046
1036
  if (!r?.fieldErrors?.some((e) => n in e)) return;
1047
1037
  let i = r.fieldErrors.filter((e) => !(n in e));
1048
- dt(e, t, {
1038
+ ut(e, t, {
1049
1039
  ...r,
1050
1040
  fieldErrors: i.length > 0 ? i : void 0
1051
1041
  });
1052
1042
  }
1053
1043
  // src/core/httpError.ts
1054
- function Mt(e) {
1044
+ function jt(e) {
1045
+ if (typeof e != "object" || !e) return !1;
1055
1046
  let t = e;
1056
- return t !== null && (t.isAxiosError === !0 || t.response !== void 0);
1047
+ return t.isAxiosError === !0 || t.response !== void 0 || typeof t.status == "number" || typeof t.statusCode == "number";
1048
+ }
1049
+ function Mt(e) {
1050
+ let t = e, n = t?.response?.status ?? t?.status ?? t?.statusCode;
1051
+ return typeof n == "number" ? n : void 0;
1057
1052
  }
1058
1053
  function Nt(e) {
1059
- let t = e?.response?.status;
1060
- return typeof t == "number" ? t : void 0;
1054
+ let t = e;
1055
+ return t?.response?.data ?? t?.data;
1061
1056
  }
1062
1057
  function Pt(e) {
1063
- return e?.response?.data;
1064
- }
1065
- function Ft(e) {
1066
- if (!Mt(e)) return;
1067
- let t = Nt(e);
1058
+ if (!jt(e)) return;
1059
+ let t = Mt(e);
1068
1060
  return t === void 0 ? "network" : t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 404 ? "notFound" : t === 400 ? "badRequest" : t >= 500 ? "server" : "unknown";
1069
1061
  }
1062
+ function Ft(e, t, n) {
1063
+ let r = Pt(e);
1064
+ if (r !== void 0) switch (r) {
1065
+ case "network": return `网络异常, ${n}`;
1066
+ case "unauthorized": return `登录已过期, ${n}`;
1067
+ case "forbidden": return `没有${t}权限, ${n}`;
1068
+ case "notFound": return `${t}接口不存在, ${n}`;
1069
+ case "badRequest": return `${t}参数错误, ${n}`;
1070
+ case "server": return `服务器错误, ${n}`;
1071
+ default: return `${t}失败`;
1072
+ }
1073
+ }
1070
1074
  // src/core/task/exportRunner.ts
1071
1075
  var It = 300;
1072
1076
  function Lt(e) {
@@ -1078,7 +1082,9 @@ async function Rt(e, t, n) {
1078
1082
  let i = r.maxRows ?? 2e4;
1079
1083
  try {
1080
1084
  for (; !t.cancelRequested;) {
1081
- let a = t.cursorId === void 0 ? {} : { cursor_id: t.cursorId }, o = await r.exportRows(a, n.signal);
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);
1082
1088
  if (n.signal.aborted) throw new DOMException("任务已取消", "AbortError");
1083
1089
  if (t.total = o.count, ge(o.count, i, "导出"), o.results.length === 0) break;
1084
1090
  t.rows = t.rows.concat(o.results), ge(t.rows.length, i, "导出");
@@ -1086,7 +1092,7 @@ async function Rt(e, t, n) {
1086
1092
  X(e, {
1087
1093
  total: t.total,
1088
1094
  processed: s,
1089
- samples: Ge(Y(e)?.samples ?? [], s)
1095
+ samples: We(Y(e)?.samples ?? [], s)
1090
1096
  });
1091
1097
  let c = o.results[o.results.length - 1]?.id;
1092
1098
  if (typeof c != "number") throw Error("导出数据缺少 id");
@@ -1103,10 +1109,10 @@ async function Rt(e, t, n) {
1103
1109
  }
1104
1110
  if (t.rows.length === 0) throw Error("没有可导出的数据");
1105
1111
  X(e, { finalizing: !0 }), await Lt(It);
1106
- let a = await ze(t.rows, r.fieldSchemas, n.signal);
1112
+ let a = await Re(t.rows, r.fieldSchemas, n.signal);
1107
1113
  if (n.signal.aborted) throw new DOMException("任务已取消", "AbortError");
1108
1114
  try {
1109
- Pe(a, r.fileName);
1115
+ Ne(a, r.fileName);
1110
1116
  } catch (e) {
1111
1117
  console.error(`自动下载失败: ${e}`);
1112
1118
  }
@@ -1134,33 +1140,23 @@ async function Rt(e, t, n) {
1134
1140
  pausing: !1,
1135
1141
  finalizing: !1,
1136
1142
  canceling: !1,
1137
- errorMessage: Bt(t)
1143
+ errorMessage: zt(t)
1138
1144
  });
1139
1145
  } finally {
1140
1146
  t.controller = null, r.onFinished?.();
1141
1147
  }
1142
1148
  }
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];
1149
+ function zt(e) {
1150
+ return Ft(e, "导出", "导出失败") ?? (e instanceof Error && e.message ? e.message : "导出失败");
1155
1151
  }
1156
- function Vt(e, t) {
1152
+ function Bt(e, t) {
1157
1153
  let n = new AbortController();
1158
1154
  J.set(e, n), Rt(e, t, n).finally(() => {
1159
- J.delete(e), $e.delete(e);
1155
+ J.delete(e), Qe.delete(e);
1160
1156
  });
1161
1157
  }
1162
- function Ht(e) {
1163
- let t = it(), n = {
1158
+ function Vt(e) {
1159
+ let t = rt(), n = {
1164
1160
  id: t,
1165
1161
  type: "export",
1166
1162
  title: e.title,
@@ -1176,21 +1172,21 @@ function Ht(e) {
1176
1172
  cancelRequested: !1,
1177
1173
  controller: null
1178
1174
  };
1179
- return $e.set(t, r), at(n), Vt(t, r), t;
1175
+ return Qe.set(t, r), it(n), Bt(t, r), t;
1180
1176
  }
1181
- function Ut(e, t) {
1177
+ function Ht(e, t) {
1182
1178
  try {
1183
- return Pe(e, t), !0;
1179
+ return Ne(e, t), !0;
1184
1180
  } catch (e) {
1185
1181
  return console.error(`下载失败: ${e}`), !1;
1186
1182
  }
1187
1183
  }
1188
- function Wt(e) {
1184
+ function Ut(e) {
1189
1185
  let t = Y(e);
1190
- return t?.type !== "export" || !t.blob || !t.fileName ? !1 : Ut(t.blob, t.fileName);
1186
+ return t?.type !== "export" || !t.blob || !t.fileName ? !1 : Ht(t.blob, t.fileName);
1191
1187
  }
1192
1188
  // src/core/task/index.ts
1193
- function Gt(e) {
1189
+ function Wt(e) {
1194
1190
  let t = Y(e);
1195
1191
  if (!t) return;
1196
1192
  if (t.status === "paused") {
@@ -1199,13 +1195,13 @@ function Gt(e) {
1199
1195
  pausing: !1,
1200
1196
  canceling: !1,
1201
1197
  rowStates: (t.rowStates ?? []).map((e) => e.status === "queued" || e.status === "running" ? { status: "canceled" } : e)
1202
- }), q.delete(e), pt(e);
1198
+ }), q.delete(e), ft(e);
1203
1199
  return;
1204
1200
  }
1205
1201
  if (t.status !== "running") return;
1206
1202
  if (t.type === "export") {
1207
1203
  if (t.canceling || t.finalizing) return;
1208
- let n = $e.get(e);
1204
+ let n = Qe.get(e);
1209
1205
  if (!n) return;
1210
1206
  n.cancelRequested = !0, n.controller?.abort(), X(e, { canceling: !0 });
1211
1207
  return;
@@ -1214,20 +1210,20 @@ function Gt(e) {
1214
1210
  let n = q.get(e);
1215
1211
  n && (n.cancelRequested = !0, X(e, { canceling: !0 }));
1216
1212
  }
1217
- function Kt(e) {
1213
+ function Gt(e) {
1218
1214
  let t = Y(e);
1219
- t && (t.status === "running" && J.get(e)?.abort(), $e.delete(e), q.delete(e), pt(e), ot(e));
1215
+ t && (t.status === "running" && J.get(e)?.abort(), Qe.delete(e), q.delete(e), ft(e), at(e));
1220
1216
  }
1221
- function qt() {
1222
- mt(), st();
1217
+ function Kt() {
1218
+ pt(), ot();
1223
1219
  }
1224
1220
  // src/react/useTaskDetail.ts
1225
- function Jt(e) {
1226
- let t = C(() => e ? rt().find((t) => t.id === e) : void 0, [e]);
1227
- return O(nt, t);
1221
+ function qt(e) {
1222
+ let t = C(() => e ? nt().find((t) => t.id === e) : void 0, [e]);
1223
+ return O(tt, t);
1228
1224
  }
1229
1225
  // src/components/ExportTaskModal.tsx
1230
- function Yt(e) {
1226
+ function Jt(e) {
1231
1227
  if (e.canceling) return "正在取消";
1232
1228
  if (e.finalizing) return "正在生成文件";
1233
1229
  switch (e.status) {
@@ -1238,25 +1234,25 @@ function Yt(e) {
1238
1234
  case "canceled": return "已取消";
1239
1235
  }
1240
1236
  }
1241
- function Xt(e) {
1237
+ function Yt(e) {
1242
1238
  if (e.canceling) return "warning";
1243
1239
  if (e.finalizing) return "processing";
1244
1240
  }
1245
- function Zt(e) {
1241
+ function Xt(e) {
1246
1242
  switch (e.status) {
1247
1243
  case "failed": return "exception";
1248
1244
  case "completed": return "success";
1249
1245
  default: return "normal";
1250
1246
  }
1251
1247
  }
1252
- var Qt = ({ taskId: e, onClose: t }) => {
1253
- let n = Jt(e), { message: r } = c.useApp();
1248
+ var Zt = ({ taskId: e, onClose: t }) => {
1249
+ let n = qt(e), { message: r } = c.useApp();
1254
1250
  if (!n) return null;
1255
- let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = Ye(n), o = () => {
1256
- Kt(n.id), t();
1251
+ let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = Je(n), o = () => {
1252
+ Gt(n.id), t();
1257
1253
  }, s = () => {
1258
- Wt(n.id) || r.error("文件不存在");
1259
- }, d = Yt(n);
1254
+ Ut(n.id) || r.error("文件不存在");
1255
+ }, d = Jt(n);
1260
1256
  return /* @__PURE__ */ k(p, {
1261
1257
  title: n.title,
1262
1258
  open: !0,
@@ -1283,7 +1279,7 @@ var Qt = ({ taskId: e, onClose: t }) => {
1283
1279
  danger: !0,
1284
1280
  loading: n.canceling,
1285
1281
  disabled: n.canceling || n.finalizing,
1286
- onClick: () => Gt(n.id),
1282
+ onClick: () => Wt(n.id),
1287
1283
  children: n.canceling ? "取消中" : "取消任务"
1288
1284
  })
1289
1285
  }),
@@ -1299,19 +1295,19 @@ var Qt = ({ taskId: e, onClose: t }) => {
1299
1295
  type: "secondary",
1300
1296
  children: [
1301
1297
  "已导出 ",
1302
- qe(n).toLocaleString(),
1298
+ Ke(n).toLocaleString(),
1303
1299
  " / 总数 ",
1304
1300
  n.total > 0 ? n.total.toLocaleString() : "--"
1305
1301
  ]
1306
1302
  }), /* @__PURE__ */ k(y, {
1307
- color: Xt(n),
1303
+ color: Yt(n),
1308
1304
  children: d
1309
1305
  })]
1310
1306
  }),
1311
1307
  /* @__PURE__ */ k(h, {
1312
1308
  percent: a,
1313
- format: () => Xe(a),
1314
- status: Zt(n),
1309
+ format: () => Ye(a),
1310
+ status: Xt(n),
1315
1311
  size: "small"
1316
1312
  }),
1317
1313
  n.errorMessage ? /* @__PURE__ */ k(x.Text, {
@@ -1321,42 +1317,47 @@ var Qt = ({ taskId: e, onClose: t }) => {
1321
1317
  ]
1322
1318
  })
1323
1319
  });
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);
1320
+ };
1321
+ // src/react/useActiveTask.ts
1322
+ function Qt() {
1323
+ let [e, t] = D(), n = E(void 0);
1326
1324
  return w(() => {
1327
- m.current = f;
1328
- }, [f]), w(() => () => {
1329
- m.current && Kt(m.current);
1330
- }, []), /* @__PURE__ */ A(ee, { children: [/* @__PURE__ */ k(b, {
1325
+ n.current = e;
1326
+ }, [e]), w(() => () => {
1327
+ n.current && Gt(n.current);
1328
+ }, []), [e, t];
1329
+ }
1330
+ // 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, {
1331
1334
  title: "导出 Excel",
1332
1335
  children: /* @__PURE__ */ k(l, {
1333
1336
  type: "default",
1334
1337
  icon: /* @__PURE__ */ k(a, {}),
1335
- disabled: i,
1338
+ disabled: o,
1336
1339
  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
- }));
1340
+ try {
1341
+ await u?.();
1342
+ } catch (e) {
1343
+ f.error(e instanceof Error ? e.message : "导出已取消");
1344
+ return;
1353
1345
  }
1346
+ m(Vt({
1347
+ title: `${e}导出`,
1348
+ fileName: He(e),
1349
+ fieldSchemas: t,
1350
+ maxRows: r,
1351
+ batchSize: i,
1352
+ exportRows: s,
1353
+ onFinished: d
1354
+ }));
1354
1355
  },
1355
- children: "导出"
1356
+ children: n
1356
1357
  })
1357
- }), f ? /* @__PURE__ */ k(Qt, {
1358
- taskId: f,
1359
- onClose: () => p(void 0)
1358
+ }), p ? /* @__PURE__ */ k(Zt, {
1359
+ taskId: p,
1360
+ onClose: () => m(void 0)
1360
1361
  }) : null] });
1361
1362
  }, { Text: en } = x, tn = ({ missingTitles: e, headerMessages: t }) => /* @__PURE__ */ A(u, {
1362
1363
  vertical: !0,
@@ -1365,7 +1366,7 @@ var Qt = ({ taskId: e, onClose: t }) => {
1365
1366
  });
1366
1367
  // src/components/EditableImportCell.tsx
1367
1368
  function nn(e) {
1368
- return e == null || e === "" ? "" : Array.isArray(e) ? L(e) : String(e);
1369
+ return e == null || e === "" ? "" : Array.isArray(e) ? I(e) : String(e);
1369
1370
  }
1370
1371
  var rn = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
1371
1372
  let { token: a } = S.useToken(), [o, s] = D(!1), [c, l] = D(!1), u = t.values[e.key];
@@ -1505,7 +1506,7 @@ function an(e) {
1505
1506
  function on(e, t) {
1506
1507
  if (e.canceling) return "正在取消...";
1507
1508
  switch (e.status) {
1508
- case "running": return `预计剩余 ${Ze(t)}`;
1509
+ case "running": return `预计剩余 ${Xe(t)}`;
1509
1510
  default: return null;
1510
1511
  }
1511
1512
  }
@@ -1583,20 +1584,20 @@ function pn(e, t) {
1583
1584
  }
1584
1585
  // src/components/ImportPreviewModal.tsx
1585
1586
  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);
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);
1589
1590
  w(() => {
1590
- P && (F.current = P);
1591
+ P && (re.current = P);
1591
1592
  }, [P]);
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
+ 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) => {
1593
1594
  if (!a) return !0;
1594
- let t = R(e)?.status;
1595
- return le && (t === "queued" || t === "failed") ? !0 : le && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
1596
- }, de = (e) => !a || P?.status === "paused" && R(e)?.status === "queued", fe = T(() => ["valid", "invalid"].map((e) => ({
1595
+ let t = L(e)?.status;
1596
+ return ue && (t === "queued" || t === "failed") ? !0 : ue && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
1597
+ }, fe = (e) => !a || P?.status === "paused" && L(e)?.status === "queued", pe = T(() => ["valid", "invalid"].map((e) => ({
1597
1598
  value: e,
1598
1599
  label: cn[e].label
1599
- })), []), pe = T(() => [
1600
+ })), []), me = T(() => [
1600
1601
  "pending",
1601
1602
  "running",
1602
1603
  "completed",
@@ -1605,21 +1606,21 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1605
1606
  ].map((e) => ({
1606
1607
  value: e,
1607
1608
  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
+ })), []), 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(() => {
1609
1610
  if (!H) return r;
1610
- let e = me.trim().toLowerCase();
1611
+ let e = z.trim().toLowerCase();
1611
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)));
1612
1613
  }, [
1613
1614
  r,
1614
1615
  B,
1615
- me,
1616
+ z,
1616
1617
  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
+ ]), 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, [
1618
1619
  W,
1619
1620
  V,
1620
1621
  U,
1621
1622
  _e,
1622
- I,
1623
+ F,
1623
1624
  a
1624
1625
  ]), ye = (e) => {
1625
1626
  let t = Object.entries(e.errors);
@@ -1655,7 +1656,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1655
1656
  children: n.label
1656
1657
  });
1657
1658
  }, xe = (e) => {
1658
- let t = R(e), r = t?.fieldErrors ?? [], i = t?.message;
1659
+ let t = L(e), r = t?.fieldErrors ?? [], i = t?.message;
1659
1660
  if (r.length === 0) return /* @__PURE__ */ k(x.Text, { children: i ?? "导入失败" });
1660
1661
  let a = /* @__PURE__ */ new Map();
1661
1662
  r.forEach((e) => {
@@ -1688,9 +1689,9 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1688
1689
  ]
1689
1690
  });
1690
1691
  }, Se = (e) => {
1691
- let t = dn(e, a, I), n = ln[t];
1692
+ let t = dn(e, a, F), n = ln[t];
1692
1693
  if (t === "failed") {
1693
- let t = R(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
1694
+ let t = L(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
1694
1695
  return /* @__PURE__ */ k(m, {
1695
1696
  trigger: "hover",
1696
1697
  placement: "topRight",
@@ -1710,10 +1711,10 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1710
1711
  type: "primary",
1711
1712
  danger: !0,
1712
1713
  size: "small",
1713
- disabled: !de(e),
1714
+ disabled: !fe(e),
1714
1715
  icon: /* @__PURE__ */ k(i, {}),
1715
1716
  onClick: () => {
1716
- f(e), P && e.taskIndex !== void 0 && At(P.id, [e.taskIndex]);
1717
+ f(e), P && e.taskIndex !== void 0 && kt(P.id, [e.taskIndex]);
1717
1718
  },
1718
1719
  children: "删除"
1719
1720
  }), we = [
@@ -1724,7 +1725,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1724
1725
  width: 60,
1725
1726
  fixed: "left"
1726
1727
  },
1727
- ...ie.map((e) => ({
1728
+ ...ae.map((e) => ({
1728
1729
  key: e.key,
1729
1730
  title: e.title,
1730
1731
  dataIndex: e.key,
@@ -1732,7 +1733,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1732
1733
  render: (t, n) => /* @__PURE__ */ k(rn, {
1733
1734
  field: e,
1734
1735
  record: n,
1735
- disabled: !ue(n),
1736
+ disabled: !de(n),
1736
1737
  onChange: (t) => s(n, e, t),
1737
1738
  onSave: (t) => c(n, e, t)
1738
1739
  })
@@ -1758,7 +1759,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1758
1759
  fixed: "right",
1759
1760
  render: (e, t) => Ce(t)
1760
1761
  }
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
+ ], 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;
1762
1763
  return /* @__PURE__ */ k(ee, { children: /* @__PURE__ */ A(p, {
1763
1764
  title: a ? `${t}导入` : `${t}导入预览`,
1764
1765
  open: e,
@@ -1767,7 +1768,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1767
1768
  closable: !1,
1768
1769
  keyboard: !1,
1769
1770
  onCancel: () => {
1770
- L || b();
1771
+ I || b();
1771
1772
  },
1772
1773
  footer: (() => {
1773
1774
  if (!a) return /* @__PURE__ */ A(u, {
@@ -1787,44 +1788,44 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1787
1788
  type: "primary",
1788
1789
  disabled: r.length === 0 || ke,
1789
1790
  onClick: () => {
1790
- N(), _();
1791
+ ne(), _();
1791
1792
  },
1792
1793
  children: "开始导入"
1793
1794
  })]
1794
1795
  })]
1795
1796
  });
1796
- if (!P || !I) return /* @__PURE__ */ k(u, {
1797
+ if (!P || !F) return /* @__PURE__ */ k(u, {
1797
1798
  justify: "flex-end",
1798
1799
  children: /* @__PURE__ */ k(l, {
1799
1800
  onClick: b,
1800
1801
  children: "关闭"
1801
1802
  })
1802
1803
  });
1803
- let e = I.status === "running", t = I.status === "paused";
1804
+ let e = F.status === "running", t = F.status === "paused";
1804
1805
  return /* @__PURE__ */ A(u, {
1805
1806
  justify: "flex-end",
1806
1807
  gap: 8,
1807
1808
  children: [
1808
1809
  e ? /* @__PURE__ */ A(ee, { children: [/* @__PURE__ */ k(l, {
1809
1810
  danger: !0,
1810
- loading: I.canceling,
1811
- disabled: I.canceling,
1812
- onClick: () => Gt(I.id),
1813
- children: I.canceling ? "取消中" : "取消任务"
1811
+ loading: F.canceling,
1812
+ disabled: F.canceling,
1813
+ onClick: () => Wt(F.id),
1814
+ children: F.canceling ? "取消中" : "取消任务"
1814
1815
  }), /* @__PURE__ */ k(l, {
1815
- loading: I.pausing,
1816
- disabled: I.canceling,
1817
- onClick: () => Dt(I.id),
1816
+ loading: F.pausing,
1817
+ disabled: F.canceling,
1818
+ onClick: () => Et(F.id),
1818
1819
  children: "暂停"
1819
1820
  })] }) : null,
1820
1821
  t ? /* @__PURE__ */ A(ee, { children: [/* @__PURE__ */ k(l, {
1821
1822
  danger: !0,
1822
- onClick: () => Gt(I.id),
1823
+ onClick: () => Wt(F.id),
1823
1824
  children: "取消任务"
1824
1825
  }), /* @__PURE__ */ k(l, {
1825
1826
  type: "primary",
1826
1827
  onClick: () => {
1827
- N(), Et(I.id);
1828
+ ne(), Tt(F.id);
1828
1829
  },
1829
1830
  children: "继续导入"
1830
1831
  })] }) : null,
@@ -1837,7 +1838,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1837
1838
  });
1838
1839
  })(),
1839
1840
  children: [
1840
- I && oe ? /* @__PURE__ */ A(u, {
1841
+ F && se ? /* @__PURE__ */ A(u, {
1841
1842
  vertical: !0,
1842
1843
  gap: 4,
1843
1844
  style: { marginBottom: 12 },
@@ -1848,17 +1849,17 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1848
1849
  type: "secondary",
1849
1850
  children: [
1850
1851
  "已导入 ",
1851
- qe(I).toLocaleString(),
1852
+ Ke(F).toLocaleString(),
1852
1853
  " / 总数 ",
1853
- I.total.toLocaleString()
1854
+ F.total.toLocaleString()
1854
1855
  ]
1855
1856
  }), /* @__PURE__ */ A(u, {
1856
1857
  align: "center",
1857
1858
  gap: 8,
1858
1859
  children: [
1859
- ce ? /* @__PURE__ */ k(x.Text, {
1860
+ le ? /* @__PURE__ */ k(x.Text, {
1860
1861
  type: "secondary",
1861
- children: ce
1862
+ children: le
1862
1863
  }) : null,
1863
1864
  G > 0 ? /* @__PURE__ */ A(y, {
1864
1865
  color: "error",
@@ -1877,15 +1878,15 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1877
1878
  ]
1878
1879
  }) : null,
1879
1880
  /* @__PURE__ */ k(y, {
1880
- color: oe.color,
1881
- children: oe.label
1881
+ color: se.color,
1882
+ children: se.label
1882
1883
  })
1883
1884
  ]
1884
1885
  })]
1885
1886
  }), /* @__PURE__ */ k(h, {
1886
1887
  percent: Ee,
1887
- format: () => Xe(Ee),
1888
- status: sn(I),
1888
+ format: () => Ye(Ee),
1889
+ status: sn(F),
1889
1890
  size: "small"
1890
1891
  })]
1891
1892
  }) : a ? null : /* @__PURE__ */ A(u, {
@@ -1929,20 +1930,20 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1929
1930
  children: [
1930
1931
  /* @__PURE__ */ k(d, {
1931
1932
  allowClear: !0,
1932
- disabled: z,
1933
+ disabled: R,
1933
1934
  placeholder: "搜索所有字段",
1934
- value: z ? "" : te,
1935
+ value: R ? "" : M,
1935
1936
  style: { width: 260 },
1936
1937
  onChange: (e) => {
1937
- M(e.target.value);
1938
+ te(e.target.value);
1938
1939
  }
1939
1940
  }),
1940
1941
  /* @__PURE__ */ k(g, {
1941
1942
  allowClear: !0,
1942
- disabled: z,
1943
+ disabled: R,
1943
1944
  placeholder: "数据状态",
1944
1945
  value: B === "all" ? void 0 : B,
1945
- options: fe,
1946
+ options: pe,
1946
1947
  style: { width: 140 },
1947
1948
  onChange: (e) => {
1948
1949
  C(e ?? "all");
@@ -1950,10 +1951,10 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1950
1951
  }),
1951
1952
  /* @__PURE__ */ k(g, {
1952
1953
  allowClear: !0,
1953
- disabled: z,
1954
+ disabled: R,
1954
1955
  placeholder: "导入状态",
1955
1956
  value: V === "all" ? void 0 : V,
1956
- options: pe,
1957
+ options: me,
1957
1958
  style: { width: 140 },
1958
1959
  onChange: (e) => {
1959
1960
  j(e ?? "all");
@@ -1985,42 +1986,44 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1985
1986
  })
1986
1987
  ]
1987
1988
  }) });
1988
- }, hn = "缺少列: ", gn = [
1989
+ }, hn = [
1989
1990
  /期望为一个包含物件的列表/,
1990
1991
  /expected a list/i,
1991
1992
  /得到的类型是/,
1992
1993
  /not a list/i
1993
1994
  ];
1994
- function _n(e) {
1995
- return gn.some((t) => t.test(e)) ? "数据格式不正确, 请检查导入内容" : e;
1995
+ function gn(e) {
1996
+ return hn.some((t) => t.test(e)) ? "数据格式不正确, 请检查导入内容" : e;
1996
1997
  }
1997
- function vn(e) {
1998
+ function _n(e, t) {
1998
1999
  if (Object.keys(e).length === 0) return { success: !0 };
1999
- let t = [], n;
2000
- return Object.entries(e).forEach(([e, r]) => {
2001
- let i = Array.isArray(r) ? r : [r];
2002
- e === "detail" || e === "non_field_errors" ? n = i.map((e) => _n(String(e))).join("; ") : i.forEach((n) => t.push({ [e]: _n(String(n)) }));
2000
+ let n = [], r;
2001
+ return Object.entries(e).forEach(([e, i]) => {
2002
+ let a = Array.isArray(i) ? i : [i];
2003
+ if (e === "detail" || e === "non_field_errors" || !t.has(e)) {
2004
+ let t = a.map((e) => gn(String(e))).join("; ");
2005
+ r = e === "detail" || e === "non_field_errors" ? t : `${e}: ${t}`;
2006
+ } else a.forEach((t) => n.push({ [e]: gn(String(t)) }));
2003
2007
  }), {
2004
2008
  success: !1,
2005
- ...n ? { message: n } : {},
2006
- ...t.length > 0 ? { fieldErrors: t } : {}
2009
+ ...r ? { message: r } : {},
2010
+ ...n.length > 0 ? { fieldErrors: n } : {}
2007
2011
  };
2008
2012
  }
2009
- var yn = {
2010
- network: "网络异常, 任务已暂停",
2011
- unauthorized: "登录已过期, 任务已暂停",
2012
- forbidden: "没有导入权限, 任务已暂停",
2013
- notFound: "导入接口不存在, 任务已暂停",
2014
- badRequest: "请求参数错误, 任务已暂停",
2015
- server: "服务器错误, 任务已暂停",
2016
- unknown: "导入失败, 任务已暂停"
2017
- };
2018
- function bn(e) {
2019
- let t = Ft(e);
2020
- return t === void 0 ? "导入失败, 任务已暂停" : yn[t];
2013
+ // src/core/excel/importRow.ts
2014
+ function vn(e, t, n) {
2015
+ let r = {};
2016
+ return t.forEach((t) => {
2017
+ if (!n.includes(t.key)) return;
2018
+ let i = be(t, e.values[t.key]), a = V(i.trim() === "" ? null : i, t);
2019
+ if (!a.validateSuccess) throw Error(a.validateMessage);
2020
+ r[t.key] = a.validateValue ?? null;
2021
+ }), r;
2021
2022
  }
2022
- function xn(e) {
2023
- let t = Pt(e);
2023
+ // src/components/ImportButton.tsx
2024
+ var yn = "缺少列: ";
2025
+ function bn(e) {
2026
+ let t = Nt(e);
2024
2027
  if (t && typeof t == "object") {
2025
2028
  let e = t;
2026
2029
  if (typeof e.detail == "string") return e.detail;
@@ -2030,16 +2033,10 @@ function xn(e) {
2030
2033
  return `${e}: ${String(r)}`;
2031
2034
  }
2032
2035
  }
2033
- return "导入数据校验失败";
2036
+ return Ft(e, "导入", "任务已暂停") ?? (e instanceof Error && e.message ? e.message : "导入失败, 任务已暂停");
2034
2037
  }
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);
2041
- }, []);
2042
- let F = () => ne.current?.click(), re = (e, t) => {
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) => {
2043
2040
  te.warning({
2044
2041
  title: t ?? (e.missingTitles.length > 0 ? "文件表头不完整" : "文件检查未通过"),
2045
2042
  width: 480,
@@ -2048,37 +2045,37 @@ var Sn = ({ title: e, fieldSchemas: t, maxRows: n = H, importRows: r, beforeImpo
2048
2045
  okText: "重新选择文件",
2049
2046
  cancelText: "关闭",
2050
2047
  closable: !0,
2051
- onOk: F
2048
+ onOk: ie
2052
2049
  });
2053
- }, ie = async (e) => {
2054
- if (e.size > 20971520) M.error("文件大小超过 20MB, 请拆分后再导入");
2050
+ }, F = async (e) => {
2051
+ if (e.size > 20971520) N.error("文件大小超过 20MB, 请拆分后再导入");
2055
2052
  else {
2056
- h(void 0), j([]), x(!0);
2053
+ v(void 0), M([]), C(!0);
2057
2054
  try {
2058
- let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await He(e, P);
2055
+ let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await Ve(e, P);
2059
2056
  if (n.length > 0) {
2060
- re({
2057
+ ae({
2061
2058
  missingTitles: [],
2062
2059
  headerMessages: n
2063
2060
  }, "文件里的公式还没有计算结果");
2064
2061
  return;
2065
2062
  }
2066
2063
  if (t.length > 0) {
2067
- re({
2068
- missingTitles: t.filter((e) => e.startsWith(hn)).map((e) => e.slice(5)),
2069
- headerMessages: t.filter((e) => !e.startsWith(hn))
2064
+ ae({
2065
+ missingTitles: t.filter((e) => e.startsWith(yn)).map((e) => e.slice(5)),
2066
+ headerMessages: t.filter((e) => !e.startsWith(yn))
2070
2067
  });
2071
2068
  return;
2072
2069
  }
2073
2070
  if (r.length === 0) {
2074
- M.error("文件里没有数据行");
2071
+ N.error("文件里没有数据行");
2075
2072
  return;
2076
2073
  }
2077
- j(i), v(`${e.name}-${Date.now()}`), p(r), d(!0);
2074
+ M(i), x(`${e.name}-${Date.now()}`), h(r), p(!0);
2078
2075
  } catch (e) {
2079
- console.error(`导入文件解析失败: ${e}`), M.error("导入文件解析失败, 请确认上传的是 Excel 文件");
2076
+ console.error(`导入文件解析失败: ${e}`), N.error("导入文件解析失败, 请确认上传的是 Excel 文件");
2080
2077
  } finally {
2081
- x(!1);
2078
+ C(!1);
2082
2079
  }
2083
2080
  }
2084
2081
  };
@@ -2090,25 +2087,25 @@ var Sn = ({ title: e, fieldSchemas: t, maxRows: n = H, importRows: r, beforeImpo
2090
2087
  children: /* @__PURE__ */ k(l, {
2091
2088
  type: "default",
2092
2089
  icon: /* @__PURE__ */ k(s, {}),
2093
- loading: y,
2094
- disabled: y,
2095
- onClick: F,
2096
- children: "导入"
2090
+ loading: S,
2091
+ disabled: S,
2092
+ onClick: ie,
2093
+ children: n
2097
2094
  })
2098
2095
  }), /* @__PURE__ */ k(b, {
2099
2096
  title: "Excel 导入模板",
2100
2097
  children: /* @__PURE__ */ k(l, {
2101
2098
  type: "default",
2102
2099
  icon: /* @__PURE__ */ k(o, {}),
2103
- loading: S,
2100
+ loading: w,
2104
2101
  onClick: async () => {
2105
- C(!0);
2102
+ O(!0);
2106
2103
  try {
2107
- await Ve(P, `${e}导入模板`);
2104
+ await Be(P, `${e}导入模板`);
2108
2105
  } catch (e) {
2109
- console.error(`模板下载失败: ${e}`), M.error("模板下载失败");
2106
+ console.error(`模板下载失败: ${e}`), N.error("模板下载失败");
2110
2107
  } finally {
2111
- C(!1);
2108
+ O(!1);
2112
2109
  }
2113
2110
  },
2114
2111
  children: "下载模板"
@@ -2122,20 +2119,20 @@ var Sn = ({ title: e, fieldSchemas: t, maxRows: n = H, importRows: r, beforeImpo
2122
2119
  style: { display: "none" },
2123
2120
  onChange: (e) => {
2124
2121
  let t = e.target.files?.[0];
2125
- e.target.value = "", t && ie(t);
2122
+ e.target.value = "", t && F(t);
2126
2123
  }
2127
2124
  }),
2128
2125
  /* @__PURE__ */ k(mn, {
2129
- open: u,
2126
+ open: f,
2130
2127
  title: e,
2131
2128
  fieldSchemas: P,
2132
- rows: f,
2133
- taskId: m,
2134
- includedKeys: O,
2129
+ rows: m,
2130
+ taskId: g,
2131
+ includedKeys: j,
2135
2132
  onChangeCell: (e, t, n) => {
2136
- if (!O.includes(t.key)) return;
2133
+ if (!j.includes(t.key)) return;
2137
2134
  let r = be(t, n), i = V(r.trim() === "" ? null : r, t);
2138
- p((r) => r.map((r) => {
2135
+ h((r) => r.map((r) => {
2139
2136
  if (r.key !== e.key) return r;
2140
2137
  let a = { ...r.errors };
2141
2138
  return i.validateSuccess ? delete a[t.key] : a[t.key] = i.validateMessage, {
@@ -2149,13 +2146,13 @@ var Sn = ({ title: e, fieldSchemas: t, maxRows: n = H, importRows: r, beforeImpo
2149
2146
  }));
2150
2147
  },
2151
2148
  onSaveCell: (e, t, n) => {
2152
- if (!O.includes(t.key)) return;
2149
+ if (!j.includes(t.key)) return;
2153
2150
  let r = {
2154
2151
  ...e.values,
2155
2152
  [t.key]: n
2156
2153
  }, i = {};
2157
2154
  P.forEach((e) => {
2158
- if (!O.includes(e.key)) return;
2155
+ if (!j.includes(e.key)) return;
2159
2156
  let t = be(e, r[e.key]), n = V(t.trim() === "" ? null : t, e);
2160
2157
  n.validateSuccess || (i[e.key] = n.validateMessage);
2161
2158
  });
@@ -2164,60 +2161,61 @@ var Sn = ({ title: e, fieldSchemas: t, maxRows: n = H, importRows: r, beforeImpo
2164
2161
  values: r,
2165
2162
  errors: i
2166
2163
  };
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));
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));
2168
2165
  },
2169
2166
  onDelete: (e) => {
2170
- p((t) => t.filter((t) => t.key !== e.key));
2167
+ h((t) => t.filter((t) => t.key !== e.key));
2171
2168
  },
2172
2169
  onConfirm: async () => {
2173
- let t = f;
2170
+ let t = m;
2174
2171
  if (t.length === 0) {
2175
- M.error("没有可导入的数据");
2172
+ N.error("没有可导入的数据");
2176
2173
  return;
2177
2174
  }
2178
2175
  if (t.every((e) => Object.keys(e.errors).length > 0)) {
2179
- M.error("所有行都有校验错误, 请先修正后再导入");
2176
+ N.error("所有行都有校验错误, 请先修正后再导入");
2180
2177
  return;
2181
2178
  }
2182
- let o = W(t.length, n, "导入");
2183
- if (o) {
2184
- M.error(o);
2179
+ let n = W(t.length, r, "导入");
2180
+ if (n) {
2181
+ N.error(n);
2185
2182
  return;
2186
2183
  }
2187
2184
  try {
2188
- await i?.();
2185
+ await u?.();
2189
2186
  } catch (e) {
2190
- M.error(e instanceof Error ? e.message : "导入已取消");
2187
+ N.error(e instanceof Error ? e.message : "导入已取消");
2191
2188
  return;
2192
2189
  }
2193
- let s = t.map((e, t) => ({
2190
+ let o = t.map((e, t) => ({
2194
2191
  ...e,
2195
2192
  taskIndex: t
2196
2193
  }));
2197
- p(s);
2198
- let c = Tt({
2194
+ h(o);
2195
+ let s = wt({
2199
2196
  title: `${e}导入`,
2200
- rows: s,
2197
+ rows: o,
2201
2198
  fieldSchemas: P,
2202
- includedKeys: O,
2203
- maxRows: n,
2199
+ includedKeys: j,
2200
+ maxRows: r,
2201
+ batchSize: i,
2204
2202
  importRows: async (e, t) => {
2205
2203
  try {
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);
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));
2209
2207
  } catch (e) {
2210
- throw t.aborted || e instanceof ct ? e : Nt(e) === 422 ? Error(xn(e)) : new ct(bn(e));
2208
+ throw t.aborted || e instanceof st ? e : new st(bn(e));
2211
2209
  }
2212
2210
  },
2213
- onFinished: a
2211
+ onFinished: d
2214
2212
  });
2215
- h(c);
2213
+ v(s);
2216
2214
  },
2217
2215
  onClose: () => {
2218
- m && Kt(m), d(!1), h(void 0), p([]), j([]);
2216
+ g && Gt(g), p(!1), v(void 0), h([]), M([]);
2219
2217
  }
2220
- }, g)
2218
+ }, y)
2221
2219
  ] });
2222
2220
  };
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 };
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 };