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