antd-import-export 1.0.7 → 1.0.9

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
@@ -13,24 +13,24 @@ var j = Object.create, M = Object.defineProperty, te = Object.getOwnPropertyDesc
13
13
  enumerable: !(r = te(t, s)) || r.enumerable
14
14
  });
15
15
  return e;
16
- }, ae = (e, t, n) => (n = e == null ? {} : j(ne(e)), ie(t || !e || !e.__esModule || !P.call(e, "default") ? M(n, "default", {
16
+ }, F = (e, t, n) => (n = e == null ? {} : j(ne(e)), ie(t || !e || !e.__esModule || !P.call(e, "default") ? M(n, "default", {
17
17
  value: e,
18
18
  enumerable: !0
19
19
  }) : n, e));
20
20
  // src/core/schema/index.ts
21
- function oe(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 F = ";", se = /[;;]/;
26
- function I(e) {
25
+ var I = ";", oe = /[;;]/;
26
+ function L(e) {
27
27
  return e.map((e) => String(e)).join(";");
28
28
  }
29
- function ce(e) {
30
- return e.split(se).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 le = /* @__PURE__ */ ae((/* @__PURE__ */ re(((e, t, n) => {
33
+ var ce = /* @__PURE__ */ F((/* @__PURE__ */ re(((e, t, n) => {
34
34
  (function(n, r) {
35
35
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs_plugin_customParseFormat = r();
36
36
  })(n, (function() {
@@ -187,8 +187,8 @@ var le = /* @__PURE__ */ ae((/* @__PURE__ */ re(((e, t, n) => {
187
187
  };
188
188
  }));
189
189
  })))(), 1);
190
- e.extend(le.default);
191
- function L(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 L(e, t) {
197
197
  validateValue: e
198
198
  };
199
199
  }
200
- function ue(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 ue(e, n) {
235
235
  validateValue: r
236
236
  };
237
237
  }
238
- function de(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 de(e, t) {
247
247
  validateMessage: `内容必须是 ${t.property.true_label}|${t.property.false_label}`
248
248
  };
249
249
  }
250
- function fe(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,17 +257,25 @@ function fe(t) {
257
257
  validateMessage: "不是有效的日期格式 YYYY-MM-DD"
258
258
  };
259
259
  }
260
- function pe(e) {
261
- let t = /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/.exec(e);
262
- return t ? {
260
+ function fe(e) {
261
+ let t = /^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/.exec(e);
262
+ if (t) {
263
+ let e = t[1].padStart(2, "0"), n = t[2], r = t[3];
264
+ return {
265
+ validateSuccess: !0,
266
+ validateValue: r === "00" ? `${e}:${n}` : `${e}:${n}:${r}`
267
+ };
268
+ }
269
+ let n = /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/.exec(e);
270
+ return n ? {
263
271
  validateSuccess: !0,
264
- validateValue: `${t[1].padStart(2, "0")}:${t[2]}`
272
+ validateValue: `${n[1].padStart(2, "0")}:${n[2]}`
265
273
  } : {
266
274
  validateSuccess: !1,
267
- validateMessage: "不是有效的日期格式 HH:mm"
275
+ validateMessage: "不是有效的时间格式 HH:mm 或 HH:mm:ss"
268
276
  };
269
277
  }
270
- function me(t) {
278
+ function pe(t) {
271
279
  let n = e(t, "YYYY-MM-DD HH:mm:ss", !0);
272
280
  if (n.isValid()) return {
273
281
  validateSuccess: !0,
@@ -282,8 +290,8 @@ function me(t) {
282
290
  validateMessage: "不是有效的日期时间格式 YYYY-MM-DD HH:mm 或 YYYY-MM-DD HH:mm:ss"
283
291
  };
284
292
  }
285
- function R(e, t) {
286
- let n = ce(e);
293
+ function z(e, t) {
294
+ let n = se(e);
287
295
  if (n.length > t.property.list_max_length) return {
288
296
  validateSuccess: !1,
289
297
  validateMessage: `列表长度不能超过 ${t.property.list_max_length}`
@@ -297,7 +305,7 @@ function R(e, t) {
297
305
  validateValue: n
298
306
  };
299
307
  }
300
- function z(e, t) {
308
+ function B(e, t) {
301
309
  return e in t.property.option_map ? {
302
310
  validateSuccess: !0,
303
311
  validateValue: t.property.option_map[e]
@@ -306,8 +314,8 @@ function z(e, t) {
306
314
  validateMessage: `内容必须是 ${Object.keys(t.property.option_map).join("|")}`
307
315
  };
308
316
  }
309
- function B(e, t) {
310
- let n = ce(e), r = t.property.option_map, i = [];
317
+ function V(e, t) {
318
+ let n = se(e), r = t.property.option_map, i = [];
311
319
  for (let e of n) {
312
320
  if (!(e in r)) return {
313
321
  validateSuccess: !1,
@@ -320,7 +328,7 @@ function B(e, t) {
320
328
  validateValue: i
321
329
  };
322
330
  }
323
- function V(e, t) {
331
+ function H(e, t) {
324
332
  if (e === null) return t.property.required ? {
325
333
  validateSuccess: !1,
326
334
  validateMessage: "不能为空"
@@ -328,84 +336,81 @@ function V(e, t) {
328
336
  validateSuccess: !0,
329
337
  validateValue: t.property.default_value
330
338
  };
331
- if (t.type === "text") return L(e, t);
332
- if (t.type === "number") return ue(e, t);
333
- if (t.type === "boolean") return de(e, t);
334
- if (t.type === "date") return fe(e);
335
- if (t.type === "time") return pe(e);
336
- if (t.type === "datetime") return me(e);
337
- if (t.type === "list") return R(e, t);
338
- if (t.type === "single_choice") return z(e, t);
339
- if (t.type === "multiple_choice") return B(e, t);
339
+ if (t.type === "text") return R(e, t);
340
+ if (t.type === "number") return le(e, t);
341
+ if (t.type === "boolean") return ue(e, t);
342
+ if (t.type === "date") return de(e);
343
+ if (t.type === "time") return fe(e);
344
+ if (t.type === "datetime") return pe(e);
345
+ if (t.type === "list") return z(e, t);
346
+ if (t.type === "single_choice") return B(e, t);
347
+ if (t.type === "multiple_choice") return V(e, t);
340
348
  throw Error("未知的字段类型");
341
349
  }
342
350
  // src/core/limits.ts
343
- var H = 2e4, U = 2e4, he = 20971520;
344
- function W(e, t, n) {
345
- return e <= t ? null : `${n}数据 ${e.toLocaleString()} 条,超过上限 ${t.toLocaleString()} 条,请分批${n}`;
346
- }
347
- function ge(e, t, n) {
348
- let r = W(e, t, n);
349
- if (r) throw Error(r);
350
- }
351
+ var me = 20971520;
351
352
  // src/core/excel/importEditor.ts
352
- function _e(e, t) {
353
+ function U(e, t) {
353
354
  if (t != null) {
354
355
  if (e.type !== "single_choice" && e.type !== "multiple_choice") return String(t);
355
356
  for (let [n, r] of Object.entries(e.property.option_map)) if (r === t) return n;
356
357
  return String(t);
357
358
  }
358
359
  }
359
- function ve(e, t) {
360
- return e.type === "boolean" ? t === !0 ? e.property.true_label : t === !1 ? e.property.false_label : void 0 : e.type === "single_choice" ? _e(e, t) : e.type === "multiple_choice" ? Array.isArray(t) ? t.map((t) => _e(e, t)).filter(Boolean) : [] : e.type === "list" ? Array.isArray(t) ? I(t) : "" : e.type === "number" ? typeof t == "number" ? t : void 0 : t == null ? "" : String(t);
360
+ function he(e, t) {
361
+ return e.type === "boolean" ? t === !0 ? e.property.true_label : t === !1 ? e.property.false_label : void 0 : e.type === "single_choice" ? U(e, t) : e.type === "multiple_choice" ? Array.isArray(t) ? t.map((t) => U(e, t)).filter(Boolean) : [] : e.type === "list" ? Array.isArray(t) ? L(t) : "" : e.type === "number" ? typeof t == "number" ? t : void 0 : t == null ? "" : String(t);
361
362
  }
362
- function ye(e, t) {
363
- return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? ce(t) : t;
363
+ function W(e, t) {
364
+ return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? se(t) : t;
364
365
  }
365
- function be(e, t) {
366
- return t == null ? "" : e.type === "boolean" || e.type === "single_choice" ? String(t) : (e.type === "multiple_choice" || e.type === "list") && Array.isArray(t) ? I(t) : String(t);
366
+ function ge(e, t) {
367
+ return t == null ? "" : e.type === "boolean" || e.type === "single_choice" ? String(t) : (e.type === "multiple_choice" || e.type === "list") && Array.isArray(t) ? L(t) : String(t);
367
368
  }
368
369
  // src/core/excel/parseSheet.ts
369
- function xe(e) {
370
+ function _e(e) {
370
371
  return !Number.isFinite(e) || e < 1 || e >= 2958466 ? null : new Date(Math.round((e - 25569) * 24 * 3600 * 1e3));
371
372
  }
372
- function Se(e, t = !1) {
373
+ function ve(e, t = !1) {
373
374
  let n = String(e.getUTCMonth() + 1).padStart(2, "0"), r = String(e.getUTCDate()).padStart(2, "0"), i = `${e.getUTCFullYear()}-${n}-${r}`;
374
375
  if (!t) return i;
375
376
  let a = String(e.getUTCHours()).padStart(2, "0"), o = String(e.getUTCMinutes()).padStart(2, "0"), s = e.getUTCSeconds();
376
377
  return s === 0 ? `${i} ${a}:${o}` : `${i} ${a}:${o}:${s}`;
377
378
  }
378
- function Ce(e, t) {
379
- let n = (e) => e.trim() === "" ? null : e.trim(), i = t === "datetime", a = t === "date" || i;
379
+ function ye(e) {
380
+ let t = String(e.getUTCHours()).padStart(2, "0"), n = String(e.getUTCMinutes()).padStart(2, "0"), r = e.getUTCSeconds();
381
+ return r === 0 ? `${t}:${n}` : `${t}:${n}:${r}`;
382
+ }
383
+ function be(e, t) {
384
+ let n = (e) => e.trim() === "" ? null : e.trim(), i = t === "datetime", a = t === "time", o = t === "date" || i || a, s = (e) => a ? ye(e) : ve(e, i);
380
385
  if (e.type === r.ValueType.Null) return null;
381
- if (e.type === r.ValueType.Date) return Se(e.value, i);
386
+ if (e.type === r.ValueType.Date) return s(e.value);
382
387
  if (e.type === r.ValueType.Formula) {
383
388
  if (e.result === null || e.result === void 0) return null;
384
- if (e.result instanceof Date) return Se(e.result, i);
385
- if (a && typeof e.result == "number") {
386
- let t = xe(e.result);
387
- if (t) return Se(t, i);
389
+ if (e.result instanceof Date) return s(e.result);
390
+ if (o && typeof e.result == "number") {
391
+ let t = _e(e.result);
392
+ if (t) return s(t);
388
393
  }
389
394
  return n(String(e.result));
390
395
  }
391
396
  if (e.type === r.ValueType.Number) {
392
- if (a && typeof e.value == "number") {
393
- let t = xe(e.value);
394
- if (t) return Se(t, i);
397
+ if (o && typeof e.value == "number") {
398
+ let t = _e(e.value);
399
+ if (t) return s(t);
395
400
  }
396
401
  return n(String(e.value));
397
402
  }
398
403
  return n(e.text);
399
404
  }
400
- function we(e) {
405
+ function xe(e) {
401
406
  let t = e.property.default_value;
402
407
  if (t == null) return null;
403
408
  if (e.type === "boolean") return t ? e.property.true_label : e.property.false_label;
404
- if (Array.isArray(t)) return t.length > 0 ? I(t) : null;
409
+ if (Array.isArray(t)) return t.length > 0 ? L(t) : null;
405
410
  let n = String(t);
406
411
  return n.trim() === "" ? null : n;
407
412
  }
408
- function Te(e, t) {
413
+ function Se(e, t) {
409
414
  let n = new Map(t.map((e) => [e.title, e])), r = [];
410
415
  for (let t = 1; t <= e.columnCount; t++) {
411
416
  let i = e.getRow(1).getCell(t).text.split("\n")[0].trim();
@@ -413,51 +418,40 @@ function Te(e, t) {
413
418
  }
414
419
  return r;
415
420
  }
416
- function Ee(e, t) {
417
- let n = [], i = [], a = [], o = 0, s = !1, c = Te(e, t), l = c.filter((e) => e !== null).map((e) => e.key), u = new Set(l);
418
- if (t.forEach((e) => {
419
- e.property.required && !u.has(e.key) && n.push(`缺少列: ${e.title}`);
420
- }), n.length > 0) return {
421
- headerMessages: n,
422
- formulaMessages: i,
423
- rows: a,
424
- includedKeys: l
425
- };
426
- let d = 0;
427
- return e.eachRow({ includeEmpty: !1 }, (e, l) => {
428
- if (l === 1) return;
429
- let f = {};
430
- if (c.forEach((t, n) => {
431
- t && (f[t.key] = Ce(e.getCell(n + 1), t.type));
432
- }), c.forEach((t, n) => {
421
+ function Ce(e, t) {
422
+ let n = [], i = [], a = [], o = 0, s = Se(e, t), c = s.filter((e) => e !== null).map((e) => e.key), l = new Set(c);
423
+ return t.forEach((e) => {
424
+ e.property.required && !l.has(e.key) && n.push(`缺少列: ${e.title}`);
425
+ }), n.length > 0 || (e.eachRow({ includeEmpty: !1 }, (e, n) => {
426
+ if (n === 1) return;
427
+ let c = {};
428
+ if (s.forEach((t, n) => {
429
+ t && (c[t.key] = be(e.getCell(n + 1), t.type));
430
+ }), s.forEach((t, a) => {
433
431
  if (!t) return;
434
- let a = e.getCell(n + 1);
435
- a.type === r.ValueType.Formula && (a.result === null || a.result === void 0) && (o += 1, i.length < 20 && i.push(`第 ${l} 行 [${t.title}] 是公式且没有保存计算结果, 请用 Excel 打开并保存后再导入`));
436
- }), Object.values(f).every((e) => e === null)) return;
437
- if (d += 1, d > 2e4) {
438
- s ||= (n.push(`导入数据超出限制(${H} 条), 请分批导入`), !0);
439
- return;
440
- }
441
- let p = {
432
+ let s = e.getCell(a + 1);
433
+ s.type === r.ValueType.Formula && (s.result === null || s.result === void 0) && (o += 1, i.length < 20 && i.push(`第 ${n} 行 [${t.title}] 是公式且没有保存计算结果, 请用 Excel 打开并保存后再导入`));
434
+ }), Object.values(c).every((e) => e === null)) return;
435
+ let u = {
442
436
  key: String(a.length),
443
- rowNumber: l,
437
+ rowNumber: n,
444
438
  values: {},
445
439
  errors: {}
446
440
  };
447
441
  t.forEach((e) => {
448
- if (!u.has(e.key)) return;
449
- let t = V(f[e.key] ?? we(e), e);
450
- t.validateSuccess ? p.values[e.key] = ve(e, t.validateValue ?? null) : (p.values[e.key] = ye(e, f[e.key] ?? null), p.errors[e.key] = t.validateMessage);
451
- }), a.push(p);
452
- }), o > i.length && i.push(`还有 ${o - i.length} 个公式单元格没有保存计算结果`), {
442
+ if (!l.has(e.key)) return;
443
+ let t = H(c[e.key] ?? xe(e), e);
444
+ t.validateSuccess ? u.values[e.key] = he(e, t.validateValue ?? null) : (u.values[e.key] = W(e, c[e.key] ?? null), u.errors[e.key] = t.validateMessage);
445
+ }), a.push(u);
446
+ }), o > i.length && i.push(`还有 ${o - i.length} 个公式单元格没有保存计算结果`)), {
453
447
  headerMessages: n,
454
448
  formulaMessages: i,
455
449
  rows: a,
456
- includedKeys: l
450
+ includedKeys: c
457
451
  };
458
452
  }
459
453
  // src/core/excel/worksheet.ts
460
- function De(t, n) {
454
+ function we(t, n) {
461
455
  let r = n[t.key];
462
456
  if (r == null || r === "") return null;
463
457
  switch (t.type) {
@@ -465,6 +459,12 @@ function De(t, n) {
465
459
  let t = e(r);
466
460
  return t.second() === 0 ? t.format("YYYY-MM-DD HH:mm") : t.format("YYYY-MM-DD HH:mm:ss");
467
461
  }
462
+ case "time": {
463
+ let e = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(r));
464
+ if (!e) return String(r);
465
+ let t = e[1].padStart(2, "0"), n = e[3];
466
+ return n && n !== "00" ? `${t}:${e[2]}:${n}` : `${t}:${e[2]}`;
467
+ }
468
468
  case "boolean": return r ? t.property.true_label : t.property.false_label;
469
469
  case "single_choice": {
470
470
  let e = t.property.option_map;
@@ -472,21 +472,21 @@ function De(t, n) {
472
472
  }
473
473
  case "multiple_choice": {
474
474
  let e = t.property.option_map;
475
- return I((Array.isArray(r) ? r : [r]).map((t) => Object.keys(e).find((n) => e[n] === t) ?? String(t)));
475
+ return L((Array.isArray(r) ? r : [r]).map((t) => Object.keys(e).find((n) => e[n] === t) ?? String(t)));
476
476
  }
477
477
  case "list": {
478
478
  let e = Array.isArray(r) ? r : [r], n = t.property.item_key;
479
- return I(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
479
+ return L(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
480
480
  }
481
481
  default: return r;
482
482
  }
483
483
  }
484
- function G(e, t) {
484
+ function Te(e, t) {
485
485
  t.forEach((t, n) => {
486
486
  t.type === "text" && (e.getColumn(n + 1).numFmt = "@");
487
487
  });
488
488
  }
489
- function Oe(e, t, n) {
489
+ function Ee(e, t, n) {
490
490
  let r = n.map((e) => e.importable === !1 ? `${e.title}\n(仅导出)` : e.title), i = e.addRow(r);
491
491
  i.height = 20 + (Math.max(1, ...r.map((e) => e.split("\n").length)) - 1) * 15, i.eachCell({ includeEmpty: !0 }, (e) => {
492
492
  e.font = {
@@ -502,16 +502,16 @@ function Oe(e, t, n) {
502
502
  wrapText: !0
503
503
  };
504
504
  }), t.forEach((t) => {
505
- e.addRow(n.map((e) => De(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
505
+ e.addRow(n.map((e) => we(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
506
506
  e.alignment = {
507
507
  ...e.alignment,
508
508
  wrapText: !0,
509
509
  vertical: "top"
510
510
  };
511
511
  });
512
- }), G(e, n), je(e);
512
+ }), Te(e, n), ke(e);
513
513
  }
514
- function ke(e) {
514
+ function De(e) {
515
515
  let t = [e.property.required ? "必填" : "可选"];
516
516
  switch (e.type) {
517
517
  case "text":
@@ -527,7 +527,7 @@ function ke(e) {
527
527
  t.push("格式 YYYY-MM-DD");
528
528
  break;
529
529
  case "time":
530
- t.push("格式 HH:mm");
530
+ t.push("格式 HH:mm, 可带秒");
531
531
  break;
532
532
  case "datetime":
533
533
  t.push("格式 YYYY-MM-DD HH:mm, 可带秒");
@@ -541,11 +541,11 @@ function ke(e) {
541
541
  case "multiple_choice": t.push(`可多选, 分号分隔(中英文均可): ${Object.keys(e.property.option_map).join(" / ")}`);
542
542
  }
543
543
  e.key.endsWith("_name") ? t.push("填对应记录的名称") : e.key.endsWith("_number") && t.push("填对应记录的编号");
544
- let n = De(e, { [e.key]: e.property.default_value });
544
+ let n = we(e, { [e.key]: e.property.default_value });
545
545
  return t.push(`默认值: ${n == null || n === "" ? "空" : n}`), t.join("\n");
546
546
  }
547
- function Ae(e, t) {
548
- let n = t.map((e) => `${e.title}\n\n${ke(e)}`), r = e.addRow(n);
547
+ function Oe(e, t) {
548
+ let n = t.map((e) => `${e.title}\n\n${De(e)}`), r = e.addRow(n);
549
549
  r.height = 20 + (Math.max(1, ...n.map((e) => e.split("\n").length)) - 1) * 15, r.eachCell({ includeEmpty: !0 }, (e) => {
550
550
  e.font = {
551
551
  bold: !0,
@@ -559,9 +559,9 @@ function Ae(e, t) {
559
559
  vertical: "top",
560
560
  wrapText: !0
561
561
  };
562
- }), G(e, t), je(e);
562
+ }), Te(e, t), ke(e);
563
563
  }
564
- function je(e, t = 20, n = 60) {
564
+ function ke(e, t = 20, n = 60) {
565
565
  let r = [];
566
566
  e.eachRow({ includeEmpty: !1 }, (e) => {
567
567
  e.eachCell({ includeEmpty: !1 }, (e, t) => {
@@ -583,47 +583,47 @@ function je(e, t = 20, n = 60) {
583
583
  });
584
584
  }
585
585
  // src/core/excel/runtime.ts
586
- var Me = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
587
- function Ne(e, t) {
586
+ var Ae = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
587
+ function je(e, t) {
588
588
  n(e, `${t}.xlsx`);
589
589
  }
590
- var Pe;
591
- function Fe() {
592
- return Pe ??= import("exceljs").then((e) => e.default ?? e, (e) => {
593
- throw Pe = void 0, e;
594
- }), Pe;
590
+ var Me;
591
+ function Ne() {
592
+ return Me ??= import("exceljs").then((e) => e.default ?? e, (e) => {
593
+ throw Me = void 0, e;
594
+ }), Me;
595
595
  }
596
- function Ie() {
596
+ function Pe() {
597
597
  return new Promise((e) => {
598
598
  requestAnimationFrame(() => setTimeout(e, 0));
599
599
  });
600
600
  }
601
- function Le(e) {
601
+ function Fe(e) {
602
602
  if (e?.aborted) throw new DOMException("任务已取消", "AbortError");
603
603
  }
604
- async function Re(e, t, n) {
605
- let r = await Fe();
606
- Le(n), await Ie();
604
+ async function Ie(e, t, n) {
605
+ let r = await Ne();
606
+ Fe(n), await Pe();
607
607
  let i = new r.Workbook();
608
- Oe(i.addWorksheet("Sheet"), e, t);
608
+ Ee(i.addWorksheet("Sheet"), e, t);
609
609
  let a = await i.xlsx.writeBuffer();
610
- return Le(n), new Blob([a], { type: Me });
610
+ return Fe(n), new Blob([a], { type: Ae });
611
611
  }
612
- async function ze(e, t, n) {
613
- let r = await Re(e, t);
614
- return Ne(r, n), r;
612
+ async function Le(e, t, n) {
613
+ let r = await Ie(e, t);
614
+ return je(r, n), r;
615
615
  }
616
- async function Be(e, t) {
617
- let n = await Fe();
618
- await Ie();
616
+ async function Re(e, t) {
617
+ let n = await Ne();
618
+ await Pe();
619
619
  let r = new n.Workbook();
620
- Ae(r.addWorksheet("导入模板"), e);
620
+ Oe(r.addWorksheet("导入模板"), e);
621
621
  let i = await r.xlsx.writeBuffer();
622
- Ne(new Blob([i], { type: Me }), t);
622
+ je(new Blob([i], { type: Ae }), t);
623
623
  }
624
- async function Ve(e, t) {
625
- let n = await Fe(), r = await e.arrayBuffer();
626
- await Ie();
624
+ async function ze(e, t) {
625
+ let n = await Ne(), r = await e.arrayBuffer();
626
+ await Pe();
627
627
  let i = new n.Workbook();
628
628
  if (await i.xlsx.load(r), i.worksheets.length > 1) return {
629
629
  headerMessages: ["文件包含多个工作表, 只支持单个工作表, 请删除其他工作表后再导入"],
@@ -632,7 +632,7 @@ async function Ve(e, t) {
632
632
  includedKeys: []
633
633
  };
634
634
  let a = i.worksheets[0];
635
- return a ? Ee(a, t) : {
635
+ return a ? Ce(a, t) : {
636
636
  headerMessages: ["文件里没有工作表"],
637
637
  formulaMessages: [],
638
638
  rows: [],
@@ -640,23 +640,23 @@ async function Ve(e, t) {
640
640
  };
641
641
  }
642
642
  // src/core/excel/exportFile.ts
643
- function He(t) {
643
+ function Be(t) {
644
644
  return `${t}_${e().format("YYYYMMDDHHmmss")}`;
645
645
  }
646
- async function Ue(e) {
647
- let { title: t, fieldSchemas: n, rows: r, maxRows: i = U } = e;
646
+ async function Ve(e) {
647
+ let { title: t, fieldSchemas: n, rows: r } = e;
648
648
  if (r.length === 0) throw Error("没有可导出的数据");
649
- return ge(r.length, i, "导出"), ze(r, n, He(t));
649
+ return Le(r, n, Be(t));
650
650
  }
651
651
  // src/core/task/stats.ts
652
- function We(e, t) {
652
+ function He(e, t) {
653
653
  let n = Date.now();
654
654
  return [...e, {
655
655
  time: n,
656
656
  processed: t
657
657
  }].filter((e) => n - e.time <= 15e3).slice(-20);
658
658
  }
659
- function Ge(e) {
659
+ function Ue(e) {
660
660
  if (e.status !== "running" || e.total <= 0) return null;
661
661
  let t = Math.max(0, e.total - (e.validationFailedCount ?? 0) - e.processed);
662
662
  if (t === 0) return 0;
@@ -664,149 +664,144 @@ function Ge(e) {
664
664
  let n = e.samples[0], r = e.samples[e.samples.length - 1], i = (r.time - n.time) / 1e3, a = r.processed - n.processed;
665
665
  return i <= 0 || a <= 0 ? null : t / (a / i);
666
666
  }
667
- function Ke(e) {
667
+ function We(e) {
668
668
  return e.type === "import" ? e.successCount === void 0 ? e.rowStates?.filter((e) => e.status === "completed").length ?? e.processed : e.successCount : e.processed;
669
669
  }
670
- function qe(e) {
671
- return e.total <= 0 ? 0 : Math.min(100, Ke(e) / e.total * 100);
670
+ function Ge(e) {
671
+ return e.total <= 0 ? 0 : Math.min(100, We(e) / e.total * 100);
672
672
  }
673
- function Je(e) {
673
+ function Ke(e) {
674
674
  if (e.finalizing) return 100;
675
- let t = qe(e);
675
+ let t = Ge(e);
676
676
  return t >= 100 ? 100 : Math.trunc(t * 10) / 10;
677
677
  }
678
- function Ye(e) {
678
+ function qe(e) {
679
679
  return `${(Math.trunc(e * 10) / 10).toFixed(1)}%`;
680
680
  }
681
- function Xe(e) {
681
+ function Je(e) {
682
682
  if (e === null) return "计算中...";
683
683
  let t = Math.ceil(e);
684
684
  return t < 60 ? `约 ${t} 秒` : `约 ${Math.floor(t / 60)} 分 ${t % 60} 秒`;
685
685
  }
686
686
  // src/core/task/store.ts
687
- var K = { tasks: [] }, Ze = /* @__PURE__ */ new Set(), Qe = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
688
- function $e() {
689
- K = { ...K }, Ze.forEach((e) => e());
687
+ var G = { tasks: [] }, Ye = /* @__PURE__ */ new Set(), Xe = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map();
688
+ function Ze() {
689
+ G = { ...G }, Ye.forEach((e) => e());
690
690
  }
691
- function et(e) {
692
- return Ze.add(e), () => {
693
- Ze.delete(e);
691
+ function Qe(e) {
692
+ return Ye.add(e), () => {
693
+ Ye.delete(e);
694
694
  };
695
695
  }
696
- function tt(e) {
697
- return et(e);
696
+ function $e(e) {
697
+ return Qe(e);
698
698
  }
699
- function nt() {
700
- return K.tasks;
699
+ function et() {
700
+ return G.tasks;
701
701
  }
702
- function rt() {
702
+ function tt() {
703
703
  return `task-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
704
704
  }
705
- function Y(e) {
706
- return K.tasks.find((t) => t.id === e);
705
+ function J(e) {
706
+ return G.tasks.find((t) => t.id === e);
707
707
  }
708
- function X(e, t) {
709
- let n = !1, r = K.tasks.map((r) => r.id === e ? (n = !0, {
708
+ function Y(e, t) {
709
+ let n = !1, r = G.tasks.map((r) => r.id === e ? (n = !0, {
710
710
  ...r,
711
711
  ...t
712
712
  }) : r);
713
- n && (K = {
714
- ...K,
713
+ n && (G = {
714
+ ...G,
715
715
  tasks: r
716
- }, $e());
716
+ }, Ze());
717
717
  }
718
- function it(e) {
719
- K = {
720
- ...K,
721
- tasks: [...K.tasks, e]
722
- }, $e();
718
+ function nt(e) {
719
+ G = {
720
+ ...G,
721
+ tasks: [...G.tasks, e]
722
+ }, Ze();
723
723
  }
724
- function at(e) {
725
- K = {
726
- ...K,
727
- tasks: K.tasks.filter((t) => t.id !== e)
728
- }, $e();
724
+ function rt(e) {
725
+ G = {
726
+ ...G,
727
+ tasks: G.tasks.filter((t) => t.id !== e)
728
+ }, Ze();
729
729
  }
730
- function ot() {
731
- J.forEach((e) => e.abort()), J.clear(), Qe.clear(), q.clear(), K = { tasks: [] }, $e();
730
+ function it() {
731
+ q.forEach((e) => e.abort()), q.clear(), Xe.clear(), K.clear(), G = { tasks: [] }, Ze();
732
732
  }
733
733
  // src/core/task/types.ts
734
- var st = class extends Error {
734
+ var at = class extends Error {
735
735
  constructor(e) {
736
736
  super(e), this.name = "ImportPauseError";
737
737
  }
738
- }, ct = 100, lt = 100, Z = /* @__PURE__ */ new Set(), Q = null;
739
- function ut(e, t, n) {
740
- let r = q.get(e);
738
+ }, ot = 100, st = 20, ct = 200, lt = 100, X = /* @__PURE__ */ new Set(), Z = null;
739
+ function Q(e, t, n) {
740
+ let r = K.get(e);
741
741
  r && (r.rowStates[t] = {
742
742
  ...r.rowStates[t],
743
743
  ...n
744
- }, dt(e));
744
+ }, ut(e));
745
745
  }
746
- function dt(e) {
747
- Z.add(e), Q === null && (Q = setTimeout(() => {
748
- Q = null;
749
- let e = [...Z];
750
- Z.clear(), e.forEach(ht);
746
+ function ut(e) {
747
+ X.add(e), Z === null && (Z = setTimeout(() => {
748
+ Z = null;
749
+ let e = [...X];
750
+ X.clear(), e.forEach(mt);
751
751
  }, lt));
752
752
  }
753
- function ft(e) {
754
- Z.delete(e);
753
+ function dt(e) {
754
+ X.delete(e);
755
755
  }
756
- function pt() {
757
- Z.clear(), Q !== null && (clearTimeout(Q), Q = null);
756
+ function ft() {
757
+ X.clear(), Z !== null && (clearTimeout(Z), Z = null);
758
758
  }
759
- function mt(e, t) {
759
+ function pt(e, t) {
760
760
  return {
761
761
  processed: t.processed,
762
- total: gt(t),
762
+ total: ht(t),
763
763
  successCount: t.successCount,
764
764
  failureCount: t.failures.length,
765
765
  validationFailedCount: t.validationFailedCount,
766
766
  failures: t.failures,
767
767
  rowStates: t.rowStates,
768
- samples: We(Y(e)?.samples ?? [], t.processed)
768
+ samples: He(J(e)?.samples ?? [], t.processed)
769
769
  };
770
770
  }
771
+ function mt(e) {
772
+ let t = K.get(e);
773
+ t && J(e) && Y(e, pt(e, t));
774
+ }
771
775
  function ht(e) {
772
- let t = q.get(e);
773
- t && Y(e) && X(e, mt(e, t));
776
+ return e.options.rows.length - e.deletedIndexes.size;
774
777
  }
775
778
  function gt(e) {
776
- return e.options.rows.length - e.deletedIndexes.size;
779
+ return `成功 ${e.successCount} 条, 失败 ${e.failures.length} 条, 可修正失败行后继续`;
777
780
  }
778
781
  function _t(e) {
779
- return `成功 ${e.successCount} 条, 失败 ${e.failures.length} 条, 可修正失败行后继续`;
782
+ if (e === void 0) return st;
783
+ let t = Math.floor(e);
784
+ return !Number.isFinite(t) || t < 1 ? st : Math.min(t, ct);
780
785
  }
781
786
  async function vt(e, t, n) {
782
787
  let r = t.options.rows.length;
783
788
  if (t.controller = n, t.pauseRequested = !1, t.cancelRequested = !1, t.runFailureCount = 0, r === 0) {
784
- X(e, {
789
+ Y(e, {
785
790
  status: "failed",
786
791
  pausing: !1,
787
792
  errorMessage: "没有可导入的数据"
788
793
  }), t.options.onFinished?.();
789
794
  return;
790
795
  }
791
- try {
792
- ge(r, t.options.maxRows ?? 2e4, "导入");
793
- } catch (n) {
794
- X(e, {
795
- status: "failed",
796
- pausing: !1,
797
- errorMessage: n instanceof Error ? n.message : "导入数据超出上限"
798
- }), t.options.onFinished?.();
799
- return;
800
- }
801
- X(e, {
802
- ...mt(e, t),
796
+ Y(e, {
797
+ ...pt(e, t),
803
798
  status: "running",
804
799
  samples: [{
805
800
  time: Date.now(),
806
801
  processed: t.processed
807
802
  }]
808
803
  });
809
- let i = Math.min(Math.max(t.options.batchSize ?? 20, 1), 200), a = Math.min(Math.max(t.options.concurrency ?? 3, 1), 5), o = () => {
804
+ let i = _t(t.options.batchSize), a = Math.min(Math.max(t.options.concurrency ?? 3, 1), 5), o = () => {
810
805
  let e = [];
811
806
  for (; e.length < i;) {
812
807
  let n = t.nextIndex;
@@ -820,19 +815,19 @@ async function vt(e, t, n) {
820
815
  let r = o();
821
816
  if (r.length === 0) return;
822
817
  r.forEach((t) => {
823
- ut(e, t, {
818
+ Q(e, t, {
824
819
  status: "running",
825
820
  message: void 0,
826
821
  fieldErrors: void 0
827
822
  });
828
823
  });
829
824
  try {
830
- let i = r.map((e) => t.options.rows[e]), a = await t.options.importRows(i, n.signal);
825
+ let i = r.map((e) => t.options.rows[e]), a = await t.options.importRows(i);
831
826
  if (n.signal.aborted) return;
832
- if (a.length !== r.length) throw new st("导入接口返回结果数量不正确, 任务已暂停");
827
+ if (a.length !== r.length) throw new at("导入接口返回结果数量不正确, 任务已暂停");
833
828
  a.forEach((n, i) => {
834
829
  let a = r[i], o = t.options.rows[a];
835
- n.success ? (t.successCount += 1, ut(e, a, {
830
+ n.success ? (t.successCount += 1, Q(e, a, {
836
831
  status: "completed",
837
832
  fieldErrors: void 0
838
833
  })) : (t.failures.push({
@@ -840,31 +835,31 @@ async function vt(e, t, n) {
840
835
  rowNumber: o.rowNumber,
841
836
  message: n.message ?? "导入失败",
842
837
  fieldErrors: n.fieldErrors
843
- }), ut(e, a, {
838
+ }), Q(e, a, {
844
839
  status: "failed",
845
840
  message: n.message,
846
841
  fieldErrors: n.fieldErrors
847
- }), t.runFailureCount += 1, t.runFailureCount > ct && (t.pauseRequested = !0));
842
+ }), t.runFailureCount += 1, t.runFailureCount > ot && (t.pauseRequested = !0));
848
843
  });
849
844
  } catch (i) {
850
845
  if (n.signal.aborted) return;
851
- let a = i instanceof st, o = `${i instanceof Error ? i.message : "导入失败"}(该批结果未知,重试可能重复)`;
846
+ let a = i instanceof at, o = `${i instanceof Error ? i.message : "导入失败"}(该批结果未知,重试可能重复)`;
852
847
  r.forEach((n) => {
853
848
  t.failures.push({
854
849
  index: n,
855
850
  rowNumber: t.options.rows[n].rowNumber,
856
851
  message: o
857
- }), ut(e, n, {
852
+ }), Q(e, n, {
858
853
  status: "failed",
859
854
  message: o
860
855
  }), t.runFailureCount += 1;
861
- }), a ? (t.pauseRequested = !0, n.abort()) : t.runFailureCount > ct && (t.pauseRequested = !0);
856
+ }), a ? (t.pauseRequested = !0, n.abort()) : t.runFailureCount > ot && (t.pauseRequested = !0);
862
857
  } finally {
863
- t.processed += r.length, dt(e);
858
+ t.processed += r.length, ut(e);
864
859
  }
865
860
  }
866
861
  }, c = Math.min(a, Math.max(1, r));
867
- await Promise.all(Array.from({ length: c }, () => s())), t.controller = null, Y(e) && St(e, t, n);
862
+ await Promise.all(Array.from({ length: c }, () => s())), t.controller = null, J(e) && St(e, t, n);
868
863
  }
869
864
  function yt(e) {
870
865
  e.rowStates = e.rowStates.map((e) => e.status === "queued" || e.status === "running" ? { status: "canceled" } : e);
@@ -879,14 +874,14 @@ function xt(e) {
879
874
  return e.failures.length > 0 ? `累计失败 ${e.failures.length} 条, 任务已暂停, 可继续导入` : void 0;
880
875
  }
881
876
  function $(e, t, n) {
882
- X(e, {
883
- ...mt(e, t),
877
+ Y(e, {
878
+ ...pt(e, t),
884
879
  pausing: !1,
885
880
  ...n
886
- }), t.options.onFinished?.();
881
+ }), n.status !== "paused" && t.options.onFinished?.();
887
882
  }
888
883
  function St(e, t, n) {
889
- if (ft(e), t.cancelRequested) {
884
+ if (dt(e), t.cancelRequested) {
890
885
  yt(t), $(e, t, {
891
886
  status: "canceled",
892
887
  canceling: !1
@@ -917,7 +912,7 @@ function St(e, t, n) {
917
912
  if (t.failures.length > 0) {
918
913
  $(e, t, {
919
914
  status: "paused",
920
- errorMessage: _t(t)
915
+ errorMessage: gt(t)
921
916
  });
922
917
  return;
923
918
  }
@@ -929,12 +924,12 @@ function St(e, t, n) {
929
924
  }
930
925
  function Ct(e, t) {
931
926
  let n = new AbortController();
932
- J.set(e, n), vt(e, t, n).finally(() => {
933
- J.delete(e), Z.delete(e), Y(e)?.status !== "paused" && q.delete(e);
927
+ q.set(e, n), vt(e, t, n).finally(() => {
928
+ q.delete(e), X.delete(e), J(e)?.status !== "paused" && K.delete(e);
934
929
  });
935
930
  }
936
931
  function wt(e) {
937
- let t = rt(), n = e.rows.map((e) => ({
932
+ let t = tt(), n = e.rows.map((e) => ({
938
933
  status: "queued",
939
934
  validationErrors: Object.keys(e.errors).length > 0 ? e.errors : void 0
940
935
  })), r = new Set(e.rows.flatMap((e, t) => Object.keys(e.errors).length > 0 ? [t] : [])), i = r.size, a = {
@@ -966,18 +961,18 @@ function wt(e) {
966
961
  runFailureCount: 0,
967
962
  controller: null
968
963
  };
969
- return q.set(t, o), it(a), Ct(t, o), t;
964
+ return K.set(t, o), nt(a), Ct(t, o), t;
970
965
  }
971
966
  function Tt(e) {
972
- let t = Y(e);
967
+ let t = J(e);
973
968
  if (!t || t.type !== "import" || t.status !== "paused") return;
974
- let n = q.get(e);
969
+ let n = K.get(e);
975
970
  if (!n) return;
976
971
  let r = n.rowStates.filter((e) => e.status === "completed").length, i = n.rowStates.map((e) => e.status === "completed" || e.status === "deleted" ? e : {
977
972
  status: "queued",
978
973
  validationErrors: e.validationErrors
979
974
  }), a = i.filter((e) => e.validationErrors && Object.keys(e.validationErrors).length > 0).length;
980
- n.rowStates = i, n.validationFailedCount = a, n.nextIndex = 0, n.processed = r, n.successCount = r, n.failures = [], n.pauseRequested = !1, n.cancelRequested = !1, n.runFailureCount = 0, X(e, {
975
+ 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, Y(e, {
981
976
  status: "running",
982
977
  pausing: !1,
983
978
  canceling: !1,
@@ -991,19 +986,19 @@ function Tt(e) {
991
986
  }), Ct(e, n);
992
987
  }
993
988
  function Et(e) {
994
- let t = Y(e);
989
+ let t = J(e);
995
990
  if (!t || t.type !== "import" || t.status !== "running" || t.canceling) return;
996
- let n = q.get(e);
997
- n && (n.pauseRequested = !0, X(e, { pausing: !0 }));
991
+ let n = K.get(e);
992
+ n && (n.pauseRequested = !0, Y(e, { pausing: !0 }));
998
993
  }
999
994
  function Dt(e, t, n) {
1000
- let r = Y(e), i = q.get(e);
995
+ let r = J(e), i = K.get(e);
1001
996
  if (!r || r.type !== "import" || r.status !== "paused" && r.status !== "failed" || !i) return;
1002
997
  let a = r.rowStates?.[t]?.status;
1003
998
  (a === "queued" || a === "failed") && (i.options.rows[t] = n);
1004
999
  }
1005
1000
  function Ot(e, t, n) {
1006
- let r = Y(e), i = q.get(e);
1001
+ let r = J(e), i = K.get(e);
1007
1002
  if (!r || r.type !== "import" || !i || r.status !== "paused" && r.status !== "failed") return;
1008
1003
  let a = Object.keys(n).length > 0, o = i.rowStates[t]?.validationErrors, s = !!(o && Object.keys(o).length > 0);
1009
1004
  a ? (i.skippedIndexes.add(t), s || (i.validationFailedCount += 1)) : (i.skippedIndexes.delete(t), s && --i.validationFailedCount), i.rowStates[t] = {
@@ -1012,30 +1007,30 @@ function Ot(e, t, n) {
1012
1007
  }, i.options.rows[t] = {
1013
1008
  ...i.options.rows[t],
1014
1009
  errors: n
1015
- }, X(e, {
1010
+ }, Y(e, {
1016
1011
  validationFailedCount: i.validationFailedCount,
1017
1012
  rowStates: i.rowStates
1018
1013
  });
1019
1014
  }
1020
1015
  function kt(e, t) {
1021
- let n = Y(e), r = q.get(e);
1016
+ let n = J(e), r = K.get(e);
1022
1017
  n && n.type === "import" && n.status === "paused" && r && (t.forEach((e) => {
1023
1018
  let t = r.rowStates[e];
1024
1019
  t?.status === "queued" && (t.validationErrors && Object.keys(t.validationErrors).length > 0 && --r.validationFailedCount, r.deletedIndexes.add(e), r.rowStates[e] = {
1025
1020
  status: "deleted",
1026
1021
  fieldErrors: void 0
1027
1022
  });
1028
- }), X(e, {
1029
- total: gt(r),
1023
+ }), Y(e, {
1024
+ total: ht(r),
1030
1025
  validationFailedCount: r.validationFailedCount,
1031
1026
  rowStates: r.rowStates
1032
1027
  }));
1033
1028
  }
1034
1029
  function At(e, t, n) {
1035
- let r = Y(e)?.rowStates?.[t];
1030
+ let r = J(e)?.rowStates?.[t];
1036
1031
  if (!r?.fieldErrors?.some((e) => n in e)) return;
1037
1032
  let i = r.fieldErrors.filter((e) => !(n in e));
1038
- ut(e, t, {
1033
+ Q(e, t, {
1039
1034
  ...r,
1040
1035
  fieldErrors: i.length > 0 ? i : void 0
1041
1036
  });
@@ -1079,27 +1074,24 @@ function Lt(e) {
1079
1074
  async function Rt(e, t, n) {
1080
1075
  let { options: r } = t;
1081
1076
  t.controller = n, t.cancelRequested = !1;
1082
- let i = r.maxRows ?? 2e4;
1083
1077
  try {
1084
1078
  for (; !t.cancelRequested;) {
1085
- let a = t.cursorId === void 0 ? {} : { cursor_id: t.cursorId };
1086
- r.batchSize !== void 0 && (a.page_size = Math.min(Math.max(Math.floor(r.batchSize), 1), 1e3));
1087
- let o = await r.exportRows(a, n.signal);
1079
+ let i = t.cursorId === void 0 ? {} : { cursor_id: t.cursorId }, a = await r.exportRows(i);
1088
1080
  if (n.signal.aborted) throw new DOMException("任务已取消", "AbortError");
1089
- if (t.total = o.count, ge(o.count, i, "导出"), o.results.length === 0) break;
1090
- t.rows = t.rows.concat(o.results), ge(t.rows.length, i, "导出");
1091
- let s = t.rows.length;
1092
- X(e, {
1081
+ if (t.total = a.count, a.results.length === 0) break;
1082
+ t.rows = t.rows.concat(a.results);
1083
+ let o = t.rows.length;
1084
+ Y(e, {
1093
1085
  total: t.total,
1094
- processed: s,
1095
- samples: We(Y(e)?.samples ?? [], s)
1086
+ processed: o,
1087
+ samples: He(J(e)?.samples ?? [], o)
1096
1088
  });
1097
- let c = o.results[o.results.length - 1]?.id;
1098
- if (typeof c != "number") throw Error("导出数据缺少 id");
1099
- t.cursorId = c;
1089
+ let s = a.results[a.results.length - 1]?.id;
1090
+ if (typeof s != "number") throw Error("导出数据缺少 id");
1091
+ t.cursorId = s;
1100
1092
  }
1101
1093
  if (t.cancelRequested) {
1102
- X(e, {
1094
+ Y(e, {
1103
1095
  status: "canceled",
1104
1096
  pausing: !1,
1105
1097
  canceling: !1,
@@ -1108,26 +1100,26 @@ async function Rt(e, t, n) {
1108
1100
  return;
1109
1101
  }
1110
1102
  if (t.rows.length === 0) throw Error("没有可导出的数据");
1111
- X(e, { finalizing: !0 }), await Lt(It);
1112
- let a = await Re(t.rows, r.fieldSchemas, n.signal);
1103
+ Y(e, { finalizing: !0 }), await Lt(It);
1104
+ let i = await Ie(t.rows, r.fieldSchemas, n.signal);
1113
1105
  if (n.signal.aborted) throw new DOMException("任务已取消", "AbortError");
1114
1106
  try {
1115
- Ne(a, r.fileName);
1107
+ je(i, r.fileName);
1116
1108
  } catch (e) {
1117
1109
  console.error(`自动下载失败: ${e}`);
1118
1110
  }
1119
- X(e, {
1111
+ Y(e, {
1120
1112
  status: "completed",
1121
1113
  pausing: !1,
1122
1114
  finalizing: !1,
1123
1115
  canceling: !1,
1124
1116
  total: t.rows.length,
1125
1117
  processed: t.rows.length,
1126
- blob: a
1118
+ blob: i
1127
1119
  });
1128
1120
  } catch (t) {
1129
1121
  if (n.signal.aborted) {
1130
- X(e, {
1122
+ Y(e, {
1131
1123
  status: "canceled",
1132
1124
  pausing: !1,
1133
1125
  finalizing: !1,
@@ -1135,7 +1127,7 @@ async function Rt(e, t, n) {
1135
1127
  });
1136
1128
  return;
1137
1129
  }
1138
- X(e, {
1130
+ Y(e, {
1139
1131
  status: "failed",
1140
1132
  pausing: !1,
1141
1133
  finalizing: !1,
@@ -1151,12 +1143,12 @@ function zt(e) {
1151
1143
  }
1152
1144
  function Bt(e, t) {
1153
1145
  let n = new AbortController();
1154
- J.set(e, n), Rt(e, t, n).finally(() => {
1155
- J.delete(e), Qe.delete(e);
1146
+ q.set(e, n), Rt(e, t, n).finally(() => {
1147
+ q.delete(e), Xe.delete(e);
1156
1148
  });
1157
1149
  }
1158
1150
  function Vt(e) {
1159
- let t = rt(), n = {
1151
+ let t = tt(), n = {
1160
1152
  id: t,
1161
1153
  type: "export",
1162
1154
  title: e.title,
@@ -1172,55 +1164,57 @@ function Vt(e) {
1172
1164
  cancelRequested: !1,
1173
1165
  controller: null
1174
1166
  };
1175
- return Qe.set(t, r), it(n), Bt(t, r), t;
1167
+ return Xe.set(t, r), nt(n), Bt(t, r), t;
1176
1168
  }
1177
1169
  function Ht(e, t) {
1178
1170
  try {
1179
- return Ne(e, t), !0;
1171
+ return je(e, t), !0;
1180
1172
  } catch (e) {
1181
1173
  return console.error(`下载失败: ${e}`), !1;
1182
1174
  }
1183
1175
  }
1184
1176
  function Ut(e) {
1185
- let t = Y(e);
1177
+ let t = J(e);
1186
1178
  return t?.type !== "export" || !t.blob || !t.fileName ? !1 : Ht(t.blob, t.fileName);
1187
1179
  }
1188
1180
  // src/core/task/index.ts
1189
1181
  function Wt(e) {
1190
- let t = Y(e);
1182
+ let t = J(e);
1191
1183
  if (!t) return;
1192
1184
  if (t.status === "paused") {
1193
- X(e, {
1185
+ Y(e, {
1194
1186
  status: "canceled",
1195
1187
  pausing: !1,
1196
1188
  canceling: !1,
1197
1189
  rowStates: (t.rowStates ?? []).map((e) => e.status === "queued" || e.status === "running" ? { status: "canceled" } : e)
1198
- }), q.delete(e), ft(e);
1190
+ });
1191
+ let n = K.get(e);
1192
+ K.delete(e), dt(e), n?.options.onFinished?.();
1199
1193
  return;
1200
1194
  }
1201
1195
  if (t.status !== "running") return;
1202
1196
  if (t.type === "export") {
1203
1197
  if (t.canceling || t.finalizing) return;
1204
- let n = Qe.get(e);
1198
+ let n = Xe.get(e);
1205
1199
  if (!n) return;
1206
- n.cancelRequested = !0, n.controller?.abort(), X(e, { canceling: !0 });
1200
+ n.cancelRequested = !0, n.controller?.abort(), Y(e, { canceling: !0 });
1207
1201
  return;
1208
1202
  }
1209
1203
  if (t.canceling) return;
1210
- let n = q.get(e);
1211
- n && (n.cancelRequested = !0, X(e, { canceling: !0 }));
1204
+ let n = K.get(e);
1205
+ n && (n.cancelRequested = !0, Y(e, { canceling: !0 }));
1212
1206
  }
1213
1207
  function Gt(e) {
1214
- let t = Y(e);
1215
- t && (t.status === "running" && J.get(e)?.abort(), Qe.delete(e), q.delete(e), ft(e), at(e));
1208
+ let t = J(e);
1209
+ t && (t.status === "running" && q.get(e)?.abort(), Xe.delete(e), K.delete(e), dt(e), rt(e));
1216
1210
  }
1217
1211
  function Kt() {
1218
- pt(), ot();
1212
+ ft(), it();
1219
1213
  }
1220
1214
  // src/react/useTaskDetail.ts
1221
1215
  function qt(e) {
1222
- let t = C(() => e ? nt().find((t) => t.id === e) : void 0, [e]);
1223
- return O(tt, t);
1216
+ let t = C(() => e ? et().find((t) => t.id === e) : void 0, [e]);
1217
+ return O($e, t);
1224
1218
  }
1225
1219
  // src/components/ExportTaskModal.tsx
1226
1220
  function Jt(e) {
@@ -1248,7 +1242,7 @@ function Xt(e) {
1248
1242
  var Zt = ({ taskId: e, onClose: t }) => {
1249
1243
  let n = qt(e), { message: r } = c.useApp();
1250
1244
  if (!n) return null;
1251
- let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = Je(n), o = () => {
1245
+ let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = Ke(n), o = () => {
1252
1246
  Gt(n.id), t();
1253
1247
  }, s = () => {
1254
1248
  Ut(n.id) || r.error("文件不存在");
@@ -1295,7 +1289,7 @@ var Zt = ({ taskId: e, onClose: t }) => {
1295
1289
  type: "secondary",
1296
1290
  children: [
1297
1291
  "已导出 ",
1298
- Ke(n).toLocaleString(),
1292
+ We(n).toLocaleString(),
1299
1293
  " / 总数 ",
1300
1294
  n.total > 0 ? n.total.toLocaleString() : "--"
1301
1295
  ]
@@ -1306,7 +1300,7 @@ var Zt = ({ taskId: e, onClose: t }) => {
1306
1300
  }),
1307
1301
  /* @__PURE__ */ k(h, {
1308
1302
  percent: a,
1309
- format: () => Ye(a),
1303
+ format: () => qe(a),
1310
1304
  status: Xt(n),
1311
1305
  size: "small"
1312
1306
  }),
@@ -1328,36 +1322,36 @@ function Qt() {
1328
1322
  }, []), [e, t];
1329
1323
  }
1330
1324
  // src/components/ExportButton.tsx
1331
- var $t = ({ title: e, fieldSchemas: t, buttonText: n = "导出", maxRows: r = U, batchSize: i, disabled: o, exportRows: s, beforeExport: u, afterExport: d }) => {
1332
- let { message: f } = c.useApp(), [p, m] = Qt();
1325
+ var $t = ({ title: e, fieldSchemas: t, buttonText: n = "导出", disabled: r, exportRows: i, beforeExport: o, afterExport: s, onModalClose: u }) => {
1326
+ let { message: d } = c.useApp(), [f, p] = Qt();
1333
1327
  return /* @__PURE__ */ A(ee, { children: [/* @__PURE__ */ k(b, {
1334
1328
  title: "导出 Excel",
1335
1329
  children: /* @__PURE__ */ k(l, {
1336
1330
  type: "default",
1337
1331
  icon: /* @__PURE__ */ k(a, {}),
1338
- disabled: o,
1332
+ disabled: r,
1339
1333
  onClick: async () => {
1340
1334
  try {
1341
- await u?.();
1335
+ await o?.();
1342
1336
  } catch (e) {
1343
- f.error(e instanceof Error ? e.message : "导出已取消");
1337
+ d.error(e instanceof Error ? e.message : "导出已取消");
1344
1338
  return;
1345
1339
  }
1346
- m(Vt({
1340
+ p(Vt({
1347
1341
  title: `${e}导出`,
1348
- fileName: He(e),
1342
+ fileName: Be(e),
1349
1343
  fieldSchemas: t,
1350
- maxRows: r,
1351
- batchSize: i,
1352
- exportRows: s,
1353
- onFinished: d
1344
+ exportRows: i,
1345
+ onFinished: s
1354
1346
  }));
1355
1347
  },
1356
1348
  children: n
1357
1349
  })
1358
- }), p ? /* @__PURE__ */ k(Zt, {
1359
- taskId: p,
1360
- onClose: () => m(void 0)
1350
+ }), f ? /* @__PURE__ */ k(Zt, {
1351
+ taskId: f,
1352
+ onClose: () => {
1353
+ p(void 0), u?.();
1354
+ }
1361
1355
  }) : null] });
1362
1356
  }, { Text: en } = x, tn = ({ missingTitles: e, headerMessages: t }) => /* @__PURE__ */ A(u, {
1363
1357
  vertical: !0,
@@ -1366,7 +1360,7 @@ var $t = ({ title: e, fieldSchemas: t, buttonText: n = "导出", maxRows: r = U,
1366
1360
  });
1367
1361
  // src/components/EditableImportCell.tsx
1368
1362
  function nn(e) {
1369
- return e == null || e === "" ? "" : Array.isArray(e) ? I(e) : String(e);
1363
+ return e == null || e === "" ? "" : Array.isArray(e) ? L(e) : String(e);
1370
1364
  }
1371
1365
  var rn = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
1372
1366
  let { token: a } = S.useToken(), [o, s] = D(!1), [c, l] = D(!1), u = t.values[e.key];
@@ -1506,7 +1500,7 @@ function an(e) {
1506
1500
  function on(e, t) {
1507
1501
  if (e.canceling) return "正在取消...";
1508
1502
  switch (e.status) {
1509
- case "running": return `预计剩余 ${Xe(t)}`;
1503
+ case "running": return `预计剩余 ${Je(t)}`;
1510
1504
  default: return null;
1511
1505
  }
1512
1506
  }
@@ -1590,14 +1584,14 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1590
1584
  w(() => {
1591
1585
  P && (re.current = P);
1592
1586
  }, [P]);
1593
- let ie = T(() => new Set(o), [o]), ae = n.filter((e) => ie.has(e.key)), oe = re.current, F = P ?? (oe?.id === a ? oe : void 0), se = F ? an(F) : void 0, I = !!(F && F.status !== "completed" && F.status !== "failed" && F.status !== "canceled"), ce = pn(F?.status === "running" ? Ge(F) : null, 1e3), le = F ? on(F, ce) : null, L = (e) => e.taskIndex === void 0 ? void 0 : F?.rowStates?.[e.taskIndex], ue = !(!P || P.status !== "failed" && P.status !== "paused"), de = (e) => {
1587
+ let ie = T(() => new Set(o), [o]), F = n.filter((e) => ie.has(e.key)), ae = re.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" ? Ue(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) => {
1594
1588
  if (!a) return !0;
1595
- let t = L(e)?.status;
1596
- return ue && (t === "queued" || t === "failed") ? !0 : ue && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
1597
- }, fe = (e) => !a || P?.status === "paused" && L(e)?.status === "queued", pe = T(() => ["valid", "invalid"].map((e) => ({
1589
+ let t = R(e)?.status;
1590
+ return le && (t === "queued" || t === "failed") ? !0 : le && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
1591
+ }, de = (e) => !a || P?.status === "paused" && R(e)?.status === "queued", fe = T(() => ["valid", "invalid"].map((e) => ({
1598
1592
  value: e,
1599
1593
  label: cn[e].label
1600
- })), []), me = T(() => [
1594
+ })), []), pe = T(() => [
1601
1595
  "pending",
1602
1596
  "running",
1603
1597
  "completed",
@@ -1606,21 +1600,21 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1606
1600
  ].map((e) => ({
1607
1601
  value: e,
1608
1602
  label: ln[e].label
1609
- })), []), R = F?.status === "running", z = R ? "" : N, B = !R && S !== "all" && pe.some((e) => e.value === S) ? S : "all", V = !R && O !== "all" && me.some((e) => e.value === O) ? O : "all", H = B !== "all" || z.trim() !== "", U = V !== "all", he = H || U, W = T(() => {
1610
- if (!H) return r;
1611
- let e = z.trim().toLowerCase();
1612
- return r.filter((t) => B !== "all" && un(t) !== B ? !1 : !e || Object.values(t.values).some((t) => (Array.isArray(t) ? t.join(" ") : String(t ?? "")).toLowerCase().includes(e)));
1603
+ })), []), z = I?.status === "running", B = z ? "" : N, V = !z && S !== "all" && fe.some((e) => e.value === S) ? S : "all", H = !z && O !== "all" && pe.some((e) => e.value === O) ? O : "all", me = V !== "all" || B.trim() !== "", U = H !== "all", he = me || U, W = T(() => {
1604
+ if (!me) return r;
1605
+ let e = B.trim().toLowerCase();
1606
+ return r.filter((t) => V !== "all" && un(t) !== V ? !1 : !e || Object.values(t.values).some((t) => (Array.isArray(t) ? t.join(" ") : String(t ?? "")).toLowerCase().includes(e)));
1613
1607
  }, [
1614
1608
  r,
1609
+ V,
1615
1610
  B,
1616
- z,
1617
- H
1618
- ]), ge = pn(F, 300), _e = U ? ge : void 0, ve = T(() => U ? W.filter((e) => dn(e, a, _e) === V) : a && F ? W.slice() : W, [
1611
+ me
1612
+ ]), ge = pn(I, 300), _e = U ? ge : void 0, ve = T(() => U ? W.filter((e) => dn(e, a, _e) === H) : a && I ? W.slice() : W, [
1619
1613
  W,
1620
- V,
1614
+ H,
1621
1615
  U,
1622
1616
  _e,
1623
- F,
1617
+ I,
1624
1618
  a
1625
1619
  ]), ye = (e) => {
1626
1620
  let t = Object.entries(e.errors);
@@ -1656,7 +1650,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1656
1650
  children: n.label
1657
1651
  });
1658
1652
  }, xe = (e) => {
1659
- let t = L(e), r = t?.fieldErrors ?? [], i = t?.message;
1653
+ let t = R(e), r = t?.fieldErrors ?? [], i = t?.message;
1660
1654
  if (r.length === 0) return /* @__PURE__ */ k(x.Text, { children: i ?? "导入失败" });
1661
1655
  let a = /* @__PURE__ */ new Map();
1662
1656
  r.forEach((e) => {
@@ -1689,9 +1683,9 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1689
1683
  ]
1690
1684
  });
1691
1685
  }, Se = (e) => {
1692
- let t = dn(e, a, F), n = ln[t];
1686
+ let t = dn(e, a, I), n = ln[t];
1693
1687
  if (t === "failed") {
1694
- let t = L(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
1688
+ let t = R(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
1695
1689
  return /* @__PURE__ */ k(m, {
1696
1690
  trigger: "hover",
1697
1691
  placement: "topRight",
@@ -1711,7 +1705,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1711
1705
  type: "primary",
1712
1706
  danger: !0,
1713
1707
  size: "small",
1714
- disabled: !fe(e),
1708
+ disabled: !de(e),
1715
1709
  icon: /* @__PURE__ */ k(i, {}),
1716
1710
  onClick: () => {
1717
1711
  f(e), P && e.taskIndex !== void 0 && kt(P.id, [e.taskIndex]);
@@ -1725,7 +1719,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1725
1719
  width: 60,
1726
1720
  fixed: "left"
1727
1721
  },
1728
- ...ae.map((e) => ({
1722
+ ...F.map((e) => ({
1729
1723
  key: e.key,
1730
1724
  title: e.title,
1731
1725
  dataIndex: e.key,
@@ -1733,7 +1727,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1733
1727
  render: (t, n) => /* @__PURE__ */ k(rn, {
1734
1728
  field: e,
1735
1729
  record: n,
1736
- disabled: !de(n),
1730
+ disabled: !ue(n),
1737
1731
  onChange: (t) => s(n, e, t),
1738
1732
  onSave: (t) => c(n, e, t)
1739
1733
  })
@@ -1759,7 +1753,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1759
1753
  fixed: "right",
1760
1754
  render: (e, t) => Ce(t)
1761
1755
  }
1762
- ], Te = Math.max(1200, 60 + ae.length * 160 + 100 + 110 + 80), Ee = F && F.total > 0 ? Je(F) : 0, De = F?.failureCount ?? F?.failures?.length ?? 0, G = F?.validationFailedCount ?? r.filter((e) => Object.keys(e.errors).length > 0).length, Oe = r.filter((e) => Object.keys(e.errors).length > 0).length, ke = r.length > 0 && Oe === r.length;
1756
+ ], Te = Math.max(1200, 60 + F.length * 160 + 100 + 110 + 80), Ee = I && I.total > 0 ? Ke(I) : 0, De = I?.failureCount ?? I?.failures?.length ?? 0, Oe = I?.validationFailedCount ?? r.filter((e) => Object.keys(e.errors).length > 0).length, ke = r.filter((e) => Object.keys(e.errors).length > 0).length, Ae = r.length > 0 && ke === r.length;
1763
1757
  return /* @__PURE__ */ k(ee, { children: /* @__PURE__ */ A(p, {
1764
1758
  title: a ? `${t}导入` : `${t}导入预览`,
1765
1759
  open: e,
@@ -1768,7 +1762,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1768
1762
  closable: !1,
1769
1763
  keyboard: !1,
1770
1764
  onCancel: () => {
1771
- I || b();
1765
+ L || b();
1772
1766
  },
1773
1767
  footer: (() => {
1774
1768
  if (!a) return /* @__PURE__ */ A(u, {
@@ -1776,9 +1770,9 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1776
1770
  align: "center",
1777
1771
  gap: 8,
1778
1772
  wrap: !0,
1779
- children: [/* @__PURE__ */ k("span", { children: r.length > 0 && Oe > 0 ? /* @__PURE__ */ k(x.Text, {
1780
- type: ke ? "danger" : "secondary",
1781
- children: ke ? "全部行校验失败, 请先修正后再导入" : `有 ${Oe} 行校验失败, 不会导入`
1773
+ children: [/* @__PURE__ */ k("span", { children: r.length > 0 && ke > 0 ? /* @__PURE__ */ k(x.Text, {
1774
+ type: Ae ? "danger" : "secondary",
1775
+ children: Ae ? "全部行校验失败, 请先修正后再导入" : `有 ${ke} 行校验失败, 不会导入`
1782
1776
  }) : null }), /* @__PURE__ */ A(u, {
1783
1777
  gap: 8,
1784
1778
  children: [/* @__PURE__ */ k(l, {
@@ -1786,7 +1780,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1786
1780
  children: "取消"
1787
1781
  }), /* @__PURE__ */ k(l, {
1788
1782
  type: "primary",
1789
- disabled: r.length === 0 || ke,
1783
+ disabled: r.length === 0 || Ae,
1790
1784
  onClick: () => {
1791
1785
  ne(), _();
1792
1786
  },
@@ -1794,38 +1788,38 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1794
1788
  })]
1795
1789
  })]
1796
1790
  });
1797
- if (!P || !F) return /* @__PURE__ */ k(u, {
1791
+ if (!P || !I) return /* @__PURE__ */ k(u, {
1798
1792
  justify: "flex-end",
1799
1793
  children: /* @__PURE__ */ k(l, {
1800
1794
  onClick: b,
1801
1795
  children: "关闭"
1802
1796
  })
1803
1797
  });
1804
- let e = F.status === "running", t = F.status === "paused";
1798
+ let e = I.status === "running", t = I.status === "paused";
1805
1799
  return /* @__PURE__ */ A(u, {
1806
1800
  justify: "flex-end",
1807
1801
  gap: 8,
1808
1802
  children: [
1809
1803
  e ? /* @__PURE__ */ A(ee, { children: [/* @__PURE__ */ k(l, {
1810
1804
  danger: !0,
1811
- loading: F.canceling,
1812
- disabled: F.canceling,
1813
- onClick: () => Wt(F.id),
1814
- children: F.canceling ? "取消中" : "取消任务"
1805
+ loading: I.canceling,
1806
+ disabled: I.canceling,
1807
+ onClick: () => Wt(I.id),
1808
+ children: I.canceling ? "取消中" : "取消任务"
1815
1809
  }), /* @__PURE__ */ k(l, {
1816
- loading: F.pausing,
1817
- disabled: F.canceling,
1818
- onClick: () => Et(F.id),
1810
+ loading: I.pausing,
1811
+ disabled: I.canceling,
1812
+ onClick: () => Et(I.id),
1819
1813
  children: "暂停"
1820
1814
  })] }) : null,
1821
1815
  t ? /* @__PURE__ */ A(ee, { children: [/* @__PURE__ */ k(l, {
1822
1816
  danger: !0,
1823
- onClick: () => Wt(F.id),
1817
+ onClick: () => Wt(I.id),
1824
1818
  children: "取消任务"
1825
1819
  }), /* @__PURE__ */ k(l, {
1826
1820
  type: "primary",
1827
1821
  onClick: () => {
1828
- ne(), Tt(F.id);
1822
+ ne(), Tt(I.id);
1829
1823
  },
1830
1824
  children: "继续导入"
1831
1825
  })] }) : null,
@@ -1838,7 +1832,7 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1838
1832
  });
1839
1833
  })(),
1840
1834
  children: [
1841
- F && se ? /* @__PURE__ */ A(u, {
1835
+ I && oe ? /* @__PURE__ */ A(u, {
1842
1836
  vertical: !0,
1843
1837
  gap: 4,
1844
1838
  style: { marginBottom: 12 },
@@ -1849,23 +1843,23 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1849
1843
  type: "secondary",
1850
1844
  children: [
1851
1845
  "已导入 ",
1852
- Ke(F).toLocaleString(),
1846
+ We(I).toLocaleString(),
1853
1847
  " / 总数 ",
1854
- F.total.toLocaleString()
1848
+ I.total.toLocaleString()
1855
1849
  ]
1856
1850
  }), /* @__PURE__ */ A(u, {
1857
1851
  align: "center",
1858
1852
  gap: 8,
1859
1853
  children: [
1860
- le ? /* @__PURE__ */ k(x.Text, {
1854
+ ce ? /* @__PURE__ */ k(x.Text, {
1861
1855
  type: "secondary",
1862
- children: le
1856
+ children: ce
1863
1857
  }) : null,
1864
- G > 0 ? /* @__PURE__ */ A(y, {
1858
+ Oe > 0 ? /* @__PURE__ */ A(y, {
1865
1859
  color: "error",
1866
1860
  children: [
1867
1861
  "校验失败 ",
1868
- G,
1862
+ Oe,
1869
1863
  " 条"
1870
1864
  ]
1871
1865
  }) : null,
@@ -1878,15 +1872,15 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1878
1872
  ]
1879
1873
  }) : null,
1880
1874
  /* @__PURE__ */ k(y, {
1881
- color: se.color,
1882
- children: se.label
1875
+ color: oe.color,
1876
+ children: oe.label
1883
1877
  })
1884
1878
  ]
1885
1879
  })]
1886
1880
  }), /* @__PURE__ */ k(h, {
1887
1881
  percent: Ee,
1888
- format: () => Ye(Ee),
1889
- status: sn(F),
1882
+ format: () => qe(Ee),
1883
+ status: sn(I),
1890
1884
  size: "small"
1891
1885
  })]
1892
1886
  }) : a ? null : /* @__PURE__ */ A(u, {
@@ -1902,11 +1896,11 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1902
1896
  }), /* @__PURE__ */ A(u, {
1903
1897
  align: "center",
1904
1898
  gap: 8,
1905
- children: [G > 0 ? /* @__PURE__ */ A(y, {
1899
+ children: [Oe > 0 ? /* @__PURE__ */ A(y, {
1906
1900
  color: "error",
1907
1901
  children: [
1908
1902
  "校验失败 ",
1909
- G,
1903
+ Oe,
1910
1904
  " 条"
1911
1905
  ]
1912
1906
  }) : null, /* @__PURE__ */ k(y, { children: "待导入" })]
@@ -1930,9 +1924,9 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1930
1924
  children: [
1931
1925
  /* @__PURE__ */ k(d, {
1932
1926
  allowClear: !0,
1933
- disabled: R,
1927
+ disabled: z,
1934
1928
  placeholder: "搜索所有字段",
1935
- value: R ? "" : M,
1929
+ value: z ? "" : M,
1936
1930
  style: { width: 260 },
1937
1931
  onChange: (e) => {
1938
1932
  te(e.target.value);
@@ -1940,10 +1934,10 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1940
1934
  }),
1941
1935
  /* @__PURE__ */ k(g, {
1942
1936
  allowClear: !0,
1943
- disabled: R,
1937
+ disabled: z,
1944
1938
  placeholder: "数据状态",
1945
- value: B === "all" ? void 0 : B,
1946
- options: pe,
1939
+ value: V === "all" ? void 0 : V,
1940
+ options: fe,
1947
1941
  style: { width: 140 },
1948
1942
  onChange: (e) => {
1949
1943
  C(e ?? "all");
@@ -1951,10 +1945,10 @@ var mn = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: a, includedKeys
1951
1945
  }),
1952
1946
  /* @__PURE__ */ k(g, {
1953
1947
  allowClear: !0,
1954
- disabled: R,
1948
+ disabled: z,
1955
1949
  placeholder: "导入状态",
1956
- value: V === "all" ? void 0 : V,
1957
- options: me,
1950
+ value: H === "all" ? void 0 : H,
1951
+ options: pe,
1958
1952
  style: { width: 140 },
1959
1953
  onChange: (e) => {
1960
1954
  j(e ?? "all");
@@ -2015,7 +2009,7 @@ function vn(e, t, n) {
2015
2009
  let r = {};
2016
2010
  return t.forEach((t) => {
2017
2011
  if (!n.includes(t.key)) return;
2018
- let i = be(t, e.values[t.key]), a = V(i.trim() === "" ? null : i, t);
2012
+ let i = ge(t, e.values[t.key]), a = H(i.trim() === "" ? null : i, t);
2019
2013
  if (!a.validateSuccess) throw Error(a.validateMessage);
2020
2014
  r[t.key] = a.validateValue ?? null;
2021
2015
  }), r;
@@ -2035,8 +2029,8 @@ function bn(e) {
2035
2029
  }
2036
2030
  return Ft(e, "导入", "任务已暂停") ?? (e instanceof Error && e.message ? e.message : "导入失败, 任务已暂停");
2037
2031
  }
2038
- var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H, batchSize: i = 20, importRows: a, beforeImport: u, afterImport: d }) => {
2039
- let [f, p] = D(!1), [m, h] = D([]), [g, v] = Qt(), [y, x] = D("empty"), [S, C] = D(!1), [w, O] = D(!1), [j, M] = D([]), { modal: te, message: N } = c.useApp(), ne = E(null), P = T(() => oe(t), [t]), re = T(() => new Set([...j].filter((e) => P.some((t) => t.key === e))), [P, j]), ie = () => ne.current?.click(), ae = (e, t) => {
2032
+ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", batchSize: r = 20, importRows: i, beforeImport: a, afterImport: u, onModalClose: d }) => {
2033
+ let [f, p] = D(!1), [m, h] = D([]), [g, v] = Qt(), [y, x] = D("empty"), [S, C] = D(!1), [w, O] = D(!1), [j, M] = D([]), { modal: te, message: N } = c.useApp(), ne = E(null), P = T(() => ae(t), [t]), re = T(() => new Set([...j].filter((e) => P.some((t) => t.key === e))), [P, j]), ie = () => ne.current?.click(), F = (e, t) => {
2040
2034
  te.warning({
2041
2035
  title: t ?? (e.missingTitles.length > 0 ? "文件表头不完整" : "文件检查未通过"),
2042
2036
  width: 480,
@@ -2047,21 +2041,21 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2047
2041
  closable: !0,
2048
2042
  onOk: ie
2049
2043
  });
2050
- }, F = async (e) => {
2044
+ }, I = async (e) => {
2051
2045
  if (e.size > 20971520) N.error("文件大小超过 20MB, 请拆分后再导入");
2052
2046
  else {
2053
2047
  v(void 0), M([]), C(!0);
2054
2048
  try {
2055
- let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await Ve(e, P);
2049
+ let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await ze(e, P);
2056
2050
  if (n.length > 0) {
2057
- ae({
2051
+ F({
2058
2052
  missingTitles: [],
2059
2053
  headerMessages: n
2060
2054
  }, "文件里的公式还没有计算结果");
2061
2055
  return;
2062
2056
  }
2063
2057
  if (t.length > 0) {
2064
- ae({
2058
+ F({
2065
2059
  missingTitles: t.filter((e) => e.startsWith(yn)).map((e) => e.slice(5)),
2066
2060
  headerMessages: t.filter((e) => !e.startsWith(yn))
2067
2061
  });
@@ -2071,6 +2065,12 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2071
2065
  N.error("文件里没有数据行");
2072
2066
  return;
2073
2067
  }
2068
+ try {
2069
+ await a?.(r);
2070
+ } catch (e) {
2071
+ N.error(e instanceof Error ? e.message : "导入已取消");
2072
+ return;
2073
+ }
2074
2074
  M(i), x(`${e.name}-${Date.now()}`), h(r), p(!0);
2075
2075
  } catch (e) {
2076
2076
  console.error(`导入文件解析失败: ${e}`), N.error("导入文件解析失败, 请确认上传的是 Excel 文件");
@@ -2101,7 +2101,7 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2101
2101
  onClick: async () => {
2102
2102
  O(!0);
2103
2103
  try {
2104
- await Be(P, `${e}导入模板`);
2104
+ await Re(P, `${e}导入模板`);
2105
2105
  } catch (e) {
2106
2106
  console.error(`模板下载失败: ${e}`), N.error("模板下载失败");
2107
2107
  } finally {
@@ -2119,7 +2119,7 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2119
2119
  style: { display: "none" },
2120
2120
  onChange: (e) => {
2121
2121
  let t = e.target.files?.[0];
2122
- e.target.value = "", t && F(t);
2122
+ e.target.value = "", t && I(t);
2123
2123
  }
2124
2124
  }),
2125
2125
  /* @__PURE__ */ k(mn, {
@@ -2131,7 +2131,7 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2131
2131
  includedKeys: j,
2132
2132
  onChangeCell: (e, t, n) => {
2133
2133
  if (!j.includes(t.key)) return;
2134
- let r = be(t, n), i = V(r.trim() === "" ? null : r, t);
2134
+ let r = ge(t, n), i = H(r.trim() === "" ? null : r, t);
2135
2135
  h((r) => r.map((r) => {
2136
2136
  if (r.key !== e.key) return r;
2137
2137
  let a = { ...r.errors };
@@ -2153,7 +2153,7 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2153
2153
  }, i = {};
2154
2154
  P.forEach((e) => {
2155
2155
  if (!j.includes(e.key)) return;
2156
- let t = be(e, r[e.key]), n = V(t.trim() === "" ? null : t, e);
2156
+ let t = ge(e, r[e.key]), n = H(t.trim() === "" ? null : t, e);
2157
2157
  n.validateSuccess || (i[e.key] = n.validateMessage);
2158
2158
  });
2159
2159
  let a = {
@@ -2176,46 +2176,34 @@ var xn = ({ title: e, fieldSchemas: t, buttonText: n = "导入", maxRows: r = H,
2176
2176
  N.error("所有行都有校验错误, 请先修正后再导入");
2177
2177
  return;
2178
2178
  }
2179
- let n = W(t.length, r, "导入");
2180
- if (n) {
2181
- N.error(n);
2182
- return;
2183
- }
2184
- try {
2185
- await u?.();
2186
- } catch (e) {
2187
- N.error(e instanceof Error ? e.message : "导入已取消");
2188
- return;
2189
- }
2190
- let o = t.map((e, t) => ({
2179
+ let n = t.map((e, t) => ({
2191
2180
  ...e,
2192
2181
  taskIndex: t
2193
2182
  }));
2194
- h(o);
2195
- let s = wt({
2183
+ h(n);
2184
+ let a = wt({
2196
2185
  title: `${e}导入`,
2197
- rows: o,
2186
+ rows: n,
2198
2187
  fieldSchemas: P,
2199
2188
  includedKeys: j,
2200
- maxRows: r,
2201
- batchSize: i,
2202
- importRows: async (e, t) => {
2189
+ batchSize: r,
2190
+ importRows: async (e) => {
2203
2191
  try {
2204
- let n = await a(e.map((e) => vn(e, P, j)), t);
2205
- if (n.length !== e.length) throw new st("导入接口返回结果数量不正确, 任务已暂停");
2206
- return n.map((e) => _n(e, re));
2192
+ let t = await i(e.map((e) => vn(e, P, j)));
2193
+ if (t.length !== e.length) throw new at("导入接口返回结果数量不正确, 任务已暂停");
2194
+ return t.map((e) => _n(e, re));
2207
2195
  } catch (e) {
2208
- throw t.aborted || e instanceof st ? e : new st(bn(e));
2196
+ throw e instanceof at ? e : new at(bn(e));
2209
2197
  }
2210
2198
  },
2211
- onFinished: d
2199
+ onFinished: u
2212
2200
  });
2213
- v(s);
2201
+ v(a);
2214
2202
  },
2215
2203
  onClose: () => {
2216
- g && Gt(g), p(!1), v(void 0), h([]), M([]);
2204
+ g && Gt(g), p(!1), v(void 0), h([]), M([]), d?.();
2217
2205
  }
2218
2206
  }, y)
2219
2207
  ] });
2220
2208
  };
2221
- export { $t as ExportButton, xn as ImportButton, U as MAX_EXPORT_ROWS, he as MAX_IMPORT_FILE_SIZE, H as MAX_IMPORT_ROWS, F as MULTI_VALUE_SEPARATOR, Ue as exportRowsToFile, oe as importableFields, I as joinMultiValues, Kt as resetTasks, ce as splitMultiValues, de as validateBooleanField, fe as validateDateField, me as validateDateTimeField, V as validateField, R as validateListField, B as validateMultipleChoiceField, ue as validateNumberField, z as validateSingleChoiceField, L as validateTextField, pe as validateTimeField };
2209
+ export { $t as ExportButton, xn as ImportButton, me as MAX_IMPORT_FILE_SIZE, I as MULTI_VALUE_SEPARATOR, Ve as exportRowsToFile, ae as importableFields, L as joinMultiValues, Kt as resetTasks, se as splitMultiValues, ue as validateBooleanField, de as validateDateField, pe as validateDateTimeField, H as validateField, z as validateListField, V as validateMultipleChoiceField, le as validateNumberField, B as validateSingleChoiceField, R as validateTextField, fe as validateTimeField };