antd-import-export 1.0.4 → 1.0.6

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