antd-import-export 1.0.6 → 1.0.8

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