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