antd-import-export 1.0.1 → 1.0.3
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.cjs +1 -1
- package/dist/index.mjs +411 -415
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,32 +5,32 @@ 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
7
|
import { App as m, Button as h, Flex as g, Input as _, InputNumber as v, Modal as y, Popover as b, Progress as x, Select as S, Space as C, Table as ee, Tag as w, Tooltip as te, Typography as T, message as E, theme as ne } from "antd";
|
|
8
|
-
import { Fragment as
|
|
8
|
+
import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
9
9
|
// \0rolldown/runtime.js
|
|
10
|
-
var
|
|
11
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
10
|
+
var re = Object.create, A = Object.defineProperty, j = Object.getOwnPropertyDescriptor, M = Object.getOwnPropertyNames, ie = Object.getPrototypeOf, ae = Object.prototype.hasOwnProperty, oe = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), N = (e, t, n, r) => {
|
|
11
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = M(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ae.call(e, s) && s !== n && A(e, s, {
|
|
12
12
|
get: ((e) => t[e]).bind(null, s),
|
|
13
|
-
enumerable: !(r =
|
|
13
|
+
enumerable: !(r = j(t, s)) || r.enumerable
|
|
14
14
|
});
|
|
15
15
|
return e;
|
|
16
|
-
},
|
|
16
|
+
}, se = (e, t, n) => (n = e == null ? {} : re(ie(e)), N(t || !e || !e.__esModule || !ae.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 ce(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 le = ";", ue = /[;;]/;
|
|
26
|
+
function P(e) {
|
|
27
27
|
return e.map((e) => String(e)).join(";");
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return e.split(
|
|
29
|
+
function F(e) {
|
|
30
|
+
return e.split(ue).map((e) => e.trim()).filter(Boolean);
|
|
31
31
|
}
|
|
32
32
|
// src/core/schema/validate.ts
|
|
33
|
-
var
|
|
33
|
+
var de = /* @__PURE__ */ se((/* @__PURE__ */ oe(((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 fe = /* @__PURE__ */ ce((/* @__PURE__ */ se(((e, t, n) => {
|
|
|
187
187
|
};
|
|
188
188
|
}));
|
|
189
189
|
})))(), 1);
|
|
190
|
-
e.extend(
|
|
191
|
-
function
|
|
190
|
+
e.extend(de.default);
|
|
191
|
+
function fe(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 pe(e, t) {
|
|
|
197
197
|
validateValue: e
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function pe(e, n) {
|
|
201
201
|
let r = Number(e);
|
|
202
202
|
if (!Number.isFinite(r)) return {
|
|
203
203
|
validateSuccess: !1,
|
|
@@ -235,7 +235,7 @@ function me(e, n) {
|
|
|
235
235
|
validateValue: r
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function me(e, t) {
|
|
239
239
|
return e === t.property.true_label ? {
|
|
240
240
|
validateSuccess: !0,
|
|
241
241
|
validateValue: !0
|
|
@@ -247,7 +247,7 @@ function he(e, t) {
|
|
|
247
247
|
validateMessage: `内容必须是 ${t.property.true_label}|${t.property.false_label}`
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function I(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 F(t) {
|
|
|
257
257
|
validateMessage: "不是有效的日期格式 YYYY-MM-DD"
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function L(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 ge(e) {
|
|
|
267
267
|
validateMessage: "不是有效的日期格式 HH:mm"
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function R(t) {
|
|
271
271
|
let n = e(t, "YYYY-MM-DD HH:mm", !0);
|
|
272
272
|
return n.isValid() ? {
|
|
273
273
|
validateSuccess: !0,
|
|
@@ -277,8 +277,8 @@ function I(t) {
|
|
|
277
277
|
validateMessage: "不是有效的日期时间格式 YYYY-MM-DD HH:mm"
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
let n =
|
|
280
|
+
function z(e, t) {
|
|
281
|
+
let n = F(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 L(e, t) {
|
|
|
292
292
|
validateValue: n
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function B(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 _e(e, t) {
|
|
|
301
301
|
validateMessage: `内容必须是 ${Object.keys(t.property.option_map).join("|")}`
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
|
-
function
|
|
305
|
-
let n =
|
|
304
|
+
function V(e, t) {
|
|
305
|
+
let n = F(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 R(e, t) {
|
|
|
315
315
|
validateValue: i
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function H(e, t) {
|
|
319
319
|
if (e === null) return t.property.required ? {
|
|
320
320
|
validateSuccess: !1,
|
|
321
321
|
validateMessage: "不能为空"
|
|
@@ -323,85 +323,85 @@ function z(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
|
|
332
|
-
if (t.type === "list") return
|
|
333
|
-
if (t.type === "single_choice") return
|
|
334
|
-
if (t.type === "multiple_choice") return
|
|
326
|
+
if (t.type === "text") return fe(e, t);
|
|
327
|
+
if (t.type === "number") return pe(e, t);
|
|
328
|
+
if (t.type === "boolean") return me(e, t);
|
|
329
|
+
if (t.type === "date") return I(e);
|
|
330
|
+
if (t.type === "time") return L(e);
|
|
331
|
+
if (t.type === "datetime") return R(e);
|
|
332
|
+
if (t.type === "list") return z(e, t);
|
|
333
|
+
if (t.type === "single_choice") return B(e, t);
|
|
334
|
+
if (t.type === "multiple_choice") return V(e, t);
|
|
335
335
|
throw Error("未知的字段类型");
|
|
336
336
|
}
|
|
337
337
|
// src/core/limits.ts
|
|
338
|
-
var
|
|
338
|
+
var U = 2e4, he = 2e4, ge = 20971520;
|
|
339
339
|
// src/core/excel/importEditor.ts
|
|
340
|
-
function
|
|
340
|
+
function _e(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
|
|
348
|
-
return e.type === "boolean" ? t === !0 ? e.property.true_label : t === !1 ? e.property.false_label : void 0 : e.type === "single_choice" ?
|
|
347
|
+
function ve(e, t) {
|
|
348
|
+
return e.type === "boolean" ? t === !0 ? e.property.true_label : t === !1 ? e.property.false_label : void 0 : e.type === "single_choice" ? _e(e, t) : e.type === "multiple_choice" ? Array.isArray(t) ? t.map((t) => _e(e, t)).filter(Boolean) : [] : e.type === "list" ? Array.isArray(t) ? P(t) : "" : e.type === "number" ? typeof t == "number" ? t : void 0 : t == null ? "" : String(t);
|
|
349
349
|
}
|
|
350
|
-
function
|
|
351
|
-
return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ?
|
|
350
|
+
function ye(e, t) {
|
|
351
|
+
return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? F(t) : t;
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
return t == null ? "" : e.type === "boolean" || e.type === "single_choice" ? String(t) : (e.type === "multiple_choice" || e.type === "list") && Array.isArray(t) ?
|
|
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);
|
|
355
355
|
}
|
|
356
356
|
// src/core/excel/importRow.ts
|
|
357
|
-
function
|
|
357
|
+
function xe(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 = be(t, e.values[t.key]), a = H(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 Se(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 Ce(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 we(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 Ce(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 Ce(e.result, i);
|
|
381
381
|
if (a && typeof e.result == "number") {
|
|
382
|
-
let t =
|
|
383
|
-
if (t) return
|
|
382
|
+
let t = Se(e.result);
|
|
383
|
+
if (t) return Ce(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 = Se(e.value);
|
|
390
|
+
if (t) return Ce(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 Te(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 ? P(t) : null;
|
|
401
401
|
let n = String(t);
|
|
402
402
|
return n.trim() === "" ? null : n;
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function Ee(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 Oe(e, t) {
|
|
|
409
409
|
}
|
|
410
410
|
return r;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
let n = [], i = [], a = [], o = 0, s = !1, c =
|
|
412
|
+
function De(e, t) {
|
|
413
|
+
let n = [], i = [], a = [], o = 0, s = !1, c = Ee(e, t), l = c.filter((e) => e !== null).map((e) => e.key), u = new Set(l);
|
|
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 H(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] = we(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(`导入数据超出限制(${U} 条), 请分批导入`), !0);
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
437
|
let p = {
|
|
@@ -442,8 +442,8 @@ function H(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 = H(f[e.key] ?? Te(e), e);
|
|
446
|
+
t.validateSuccess ? p.values[e.key] = ve(e, t.validateValue ?? null) : (p.values[e.key] = ye(e, f[e.key] ?? null), p.errors[e.key] = t.validateMessage);
|
|
447
447
|
}), a.push(p);
|
|
448
448
|
}), o > i.length && i.push(`还有 ${o - i.length} 个公式单元格没有保存计算结果`), {
|
|
449
449
|
headerMessages: n,
|
|
@@ -453,7 +453,7 @@ function H(e, t) {
|
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
455
|
// src/core/excel/worksheet.ts
|
|
456
|
-
function
|
|
456
|
+
function Oe(t, n) {
|
|
457
457
|
let r = n[t.key];
|
|
458
458
|
if (r == null || r === "") return null;
|
|
459
459
|
switch (t.type) {
|
|
@@ -465,11 +465,11 @@ function U(t, n) {
|
|
|
465
465
|
}
|
|
466
466
|
case "multiple_choice": {
|
|
467
467
|
let e = t.property.option_map;
|
|
468
|
-
return
|
|
468
|
+
return P((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 P(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
|
|
473
473
|
}
|
|
474
474
|
default: return r;
|
|
475
475
|
}
|
|
@@ -495,7 +495,7 @@ 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) => Oe(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
|
|
499
499
|
e.alignment = {
|
|
500
500
|
...e.alignment,
|
|
501
501
|
wrapText: !0,
|
|
@@ -534,7 +534,7 @@ 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 = Oe(e, { [e.key]: e.property.default_value });
|
|
538
538
|
return t.push(`默认值: ${n == null || n === "" ? "空" : n}`), t.join("\n");
|
|
539
539
|
}
|
|
540
540
|
function Me(e, t) {
|
|
@@ -619,7 +619,7 @@ async function He(e, t) {
|
|
|
619
619
|
includedKeys: []
|
|
620
620
|
};
|
|
621
621
|
let a = i.worksheets[0];
|
|
622
|
-
return a ?
|
|
622
|
+
return a ? De(a, t) : {
|
|
623
623
|
headerMessages: ["文件里没有工作表"],
|
|
624
624
|
formulaMessages: [],
|
|
625
625
|
rows: [],
|
|
@@ -643,22 +643,27 @@ var W = class extends Error {
|
|
|
643
643
|
constructor(e) {
|
|
644
644
|
super(e), this.name = "ImportPauseError";
|
|
645
645
|
}
|
|
646
|
-
}, Ke = 100,
|
|
647
|
-
function
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
646
|
+
}, Ke = 100, qe = 500;
|
|
647
|
+
function Je(e, t) {
|
|
648
|
+
let n = t - (Date.now() - e);
|
|
649
|
+
return n > 0 ? new Promise((e) => setTimeout(e, n)) : Promise.resolve();
|
|
650
|
+
}
|
|
651
|
+
var G = { tasks: [] }, Ye = /* @__PURE__ */ new Set(), Xe = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map();
|
|
652
|
+
function Ze() {
|
|
653
|
+
G = { ...G }, Ye.forEach((e) => e());
|
|
654
|
+
}
|
|
655
|
+
function Qe(e) {
|
|
656
|
+
return Ye.add(e), () => {
|
|
657
|
+
Ye.delete(e);
|
|
653
658
|
};
|
|
654
659
|
}
|
|
655
|
-
function
|
|
656
|
-
return
|
|
660
|
+
function $e(e) {
|
|
661
|
+
return Qe(e);
|
|
657
662
|
}
|
|
658
|
-
function
|
|
663
|
+
function et() {
|
|
659
664
|
return G.tasks;
|
|
660
665
|
}
|
|
661
|
-
function
|
|
666
|
+
function tt() {
|
|
662
667
|
return `task-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
663
668
|
}
|
|
664
669
|
function J(e) {
|
|
@@ -672,29 +677,29 @@ function Y(e, t) {
|
|
|
672
677
|
n && (G = {
|
|
673
678
|
...G,
|
|
674
679
|
tasks: r
|
|
675
|
-
},
|
|
680
|
+
}, Ze());
|
|
676
681
|
}
|
|
677
|
-
function
|
|
682
|
+
function nt(e, t) {
|
|
678
683
|
let n = J(e), r = Date.now();
|
|
679
684
|
return [...n?.samples ?? [], {
|
|
680
685
|
time: r,
|
|
681
686
|
processed: t
|
|
682
687
|
}].filter((e) => r - e.time <= 15e3).slice(-20);
|
|
683
688
|
}
|
|
684
|
-
var
|
|
685
|
-
function
|
|
689
|
+
var rt = 100, X = /* @__PURE__ */ new Set(), Z = null;
|
|
690
|
+
function it(e, t, n) {
|
|
686
691
|
let r = K.get(e);
|
|
687
692
|
r && (r.rowStates[t] = {
|
|
688
693
|
...r.rowStates[t],
|
|
689
694
|
...n
|
|
690
|
-
},
|
|
695
|
+
}, at(e));
|
|
691
696
|
}
|
|
692
|
-
function
|
|
697
|
+
function at(e) {
|
|
693
698
|
X.add(e), Z === null && (Z = setTimeout(() => {
|
|
694
699
|
Z = null;
|
|
695
700
|
let e = [...X];
|
|
696
|
-
X.clear(), e.forEach(
|
|
697
|
-
},
|
|
701
|
+
X.clear(), e.forEach(ot);
|
|
702
|
+
}, rt));
|
|
698
703
|
}
|
|
699
704
|
function Q(e) {
|
|
700
705
|
X.delete(e);
|
|
@@ -702,23 +707,23 @@ function Q(e) {
|
|
|
702
707
|
function $(e, t) {
|
|
703
708
|
return {
|
|
704
709
|
processed: t.processed,
|
|
705
|
-
total:
|
|
710
|
+
total: st(t),
|
|
706
711
|
successCount: t.successCount,
|
|
707
712
|
failureCount: t.failures.length,
|
|
708
713
|
validationFailedCount: t.validationFailedCount,
|
|
709
714
|
failures: t.failures,
|
|
710
715
|
rowStates: t.rowStates,
|
|
711
|
-
samples:
|
|
716
|
+
samples: nt(e, t.processed)
|
|
712
717
|
};
|
|
713
718
|
}
|
|
714
|
-
function
|
|
719
|
+
function ot(e) {
|
|
715
720
|
let t = K.get(e);
|
|
716
721
|
t && J(e) && Y(e, $(e, t));
|
|
717
722
|
}
|
|
718
|
-
function
|
|
723
|
+
function st(e) {
|
|
719
724
|
return e.options.rows.length - e.deletedIndexes.size;
|
|
720
725
|
}
|
|
721
|
-
async function
|
|
726
|
+
async function ct(e, t, r) {
|
|
722
727
|
let { options: i } = t;
|
|
723
728
|
t.controller = r, t.cancelRequested = !1;
|
|
724
729
|
try {
|
|
@@ -731,7 +736,7 @@ async function ot(e, t, r) {
|
|
|
731
736
|
Y(e, {
|
|
732
737
|
total: t.total,
|
|
733
738
|
processed: o,
|
|
734
|
-
samples:
|
|
739
|
+
samples: nt(e, o)
|
|
735
740
|
});
|
|
736
741
|
let s = a.results[a.results.length - 1]?.id;
|
|
737
742
|
if (typeof s != "number") throw Error("导出数据缺少 id");
|
|
@@ -748,21 +753,21 @@ async function ot(e, t, r) {
|
|
|
748
753
|
}
|
|
749
754
|
if (t.rows.length === 0) throw Error("没有可导出的数据");
|
|
750
755
|
Y(e, { finalizing: !0 });
|
|
751
|
-
let a = await ze(t.rows, i.fieldSchemas, r.signal);
|
|
756
|
+
let a = Date.now(), o = await ze(t.rows, i.fieldSchemas, r.signal);
|
|
752
757
|
if (r.signal.aborted) throw new DOMException("任务已取消", "AbortError");
|
|
753
758
|
try {
|
|
754
|
-
n(
|
|
759
|
+
n(o, `${i.fileName}.xlsx`);
|
|
755
760
|
} catch (e) {
|
|
756
761
|
console.error(`自动下载失败: ${e}`);
|
|
757
762
|
}
|
|
758
|
-
Y(e, {
|
|
763
|
+
await Je(a, qe), Y(e, {
|
|
759
764
|
status: "completed",
|
|
760
765
|
pausing: !1,
|
|
761
766
|
finalizing: !1,
|
|
762
767
|
canceling: !1,
|
|
763
768
|
total: t.rows.length,
|
|
764
769
|
processed: t.rows.length,
|
|
765
|
-
blob:
|
|
770
|
+
blob: o
|
|
766
771
|
});
|
|
767
772
|
} catch (t) {
|
|
768
773
|
if (r.signal.aborted) {
|
|
@@ -779,21 +784,21 @@ async function ot(e, t, r) {
|
|
|
779
784
|
pausing: !1,
|
|
780
785
|
finalizing: !1,
|
|
781
786
|
canceling: !1,
|
|
782
|
-
errorMessage:
|
|
787
|
+
errorMessage: lt(t)
|
|
783
788
|
});
|
|
784
789
|
} finally {
|
|
785
790
|
t.controller = null;
|
|
786
791
|
}
|
|
787
792
|
}
|
|
788
|
-
function
|
|
793
|
+
function lt(e) {
|
|
789
794
|
if (!Ue(e)) return e instanceof Error ? e.message : "导出失败";
|
|
790
795
|
let t = We(e);
|
|
791
796
|
return t === void 0 ? "网络异常, 导出失败" : t === 401 ? "登录已过期, 导出失败" : t === 403 ? "没有导出权限, 导出失败" : t === 404 ? "导出接口不存在, 导出失败" : t === 400 ? "导出参数错误, 导出失败" : t >= 500 ? "服务器错误, 导出失败" : "导出失败";
|
|
792
797
|
}
|
|
793
|
-
function
|
|
798
|
+
function ut(e) {
|
|
794
799
|
return `导入完成: 成功 ${e.successCount} 条, 失败 ${e.failures.length} 条`;
|
|
795
800
|
}
|
|
796
|
-
async function
|
|
801
|
+
async function dt(e, t, n) {
|
|
797
802
|
let r = t.options.rows.length;
|
|
798
803
|
if (t.controller = n, t.pauseRequested = !1, t.cancelRequested = !1, t.cycleFailureCount = 0, r === 0) {
|
|
799
804
|
Y(e, {
|
|
@@ -825,7 +830,7 @@ async function lt(e, t, n) {
|
|
|
825
830
|
let r = o();
|
|
826
831
|
if (r.length === 0) return;
|
|
827
832
|
r.forEach((t) => {
|
|
828
|
-
|
|
833
|
+
it(e, t, {
|
|
829
834
|
status: "running",
|
|
830
835
|
message: void 0,
|
|
831
836
|
fieldErrors: void 0
|
|
@@ -837,7 +842,7 @@ async function lt(e, t, n) {
|
|
|
837
842
|
if (a.length !== r.length) throw new W("导入接口返回结果数量不正确, 任务已暂停");
|
|
838
843
|
a.forEach((n, i) => {
|
|
839
844
|
let a = r[i], o = t.options.rows[a];
|
|
840
|
-
n.success ? (t.successCount += 1,
|
|
845
|
+
n.success ? (t.successCount += 1, it(e, a, {
|
|
841
846
|
status: "completed",
|
|
842
847
|
fieldErrors: void 0
|
|
843
848
|
})) : (t.failures.push({
|
|
@@ -845,7 +850,7 @@ async function lt(e, t, n) {
|
|
|
845
850
|
rowNumber: o.rowNumber,
|
|
846
851
|
message: n.message ?? "导入失败",
|
|
847
852
|
fieldErrors: n.fieldErrors
|
|
848
|
-
}),
|
|
853
|
+
}), it(e, a, {
|
|
849
854
|
status: "failed",
|
|
850
855
|
message: n.message,
|
|
851
856
|
fieldErrors: n.fieldErrors
|
|
@@ -859,13 +864,13 @@ async function lt(e, t, n) {
|
|
|
859
864
|
index: n,
|
|
860
865
|
rowNumber: t.options.rows[n].rowNumber,
|
|
861
866
|
message: o
|
|
862
|
-
}),
|
|
867
|
+
}), it(e, n, {
|
|
863
868
|
status: "failed",
|
|
864
869
|
message: o
|
|
865
870
|
}), t.cycleFailureCount += 1;
|
|
866
871
|
}), a ? (t.pauseRequested = !0, n.abort()) : t.cycleFailureCount > Ke && (t.pauseRequested = !0);
|
|
867
872
|
} finally {
|
|
868
|
-
t.processed += r.length,
|
|
873
|
+
t.processed += r.length, at(e);
|
|
869
874
|
}
|
|
870
875
|
}
|
|
871
876
|
}, c = Math.min(a, Math.max(1, r));
|
|
@@ -914,7 +919,7 @@ async function lt(e, t, n) {
|
|
|
914
919
|
...$(e, t),
|
|
915
920
|
status: "paused",
|
|
916
921
|
pausing: !1,
|
|
917
|
-
errorMessage:
|
|
922
|
+
errorMessage: ut(t)
|
|
918
923
|
}), t.options.onFinished?.();
|
|
919
924
|
return;
|
|
920
925
|
}
|
|
@@ -930,20 +935,20 @@ async function lt(e, t, n) {
|
|
|
930
935
|
pausing: !1
|
|
931
936
|
}), t.options.onFinished?.());
|
|
932
937
|
}
|
|
933
|
-
function
|
|
938
|
+
function ft(e, t) {
|
|
934
939
|
let n = new AbortController();
|
|
935
|
-
q.set(e, n),
|
|
936
|
-
q.delete(e),
|
|
940
|
+
q.set(e, n), ct(e, t, n).finally(() => {
|
|
941
|
+
q.delete(e), Xe.delete(e);
|
|
937
942
|
});
|
|
938
943
|
}
|
|
939
|
-
function
|
|
944
|
+
function pt(e, t) {
|
|
940
945
|
let n = new AbortController();
|
|
941
|
-
q.set(e, n),
|
|
946
|
+
q.set(e, n), dt(e, t, n).finally(() => {
|
|
942
947
|
q.delete(e), X.delete(e), J(e)?.status !== "paused" && K.delete(e);
|
|
943
948
|
});
|
|
944
949
|
}
|
|
945
|
-
function
|
|
946
|
-
let t =
|
|
950
|
+
function mt(e) {
|
|
951
|
+
let t = tt(), n = {
|
|
947
952
|
id: t,
|
|
948
953
|
type: "export",
|
|
949
954
|
title: e.title,
|
|
@@ -964,10 +969,10 @@ function ft(e) {
|
|
|
964
969
|
cancelRequested: !1,
|
|
965
970
|
controller: null
|
|
966
971
|
};
|
|
967
|
-
return
|
|
972
|
+
return Xe.set(t, r), Ze(), ft(t, r), t;
|
|
968
973
|
}
|
|
969
|
-
function
|
|
970
|
-
let t =
|
|
974
|
+
function ht(e) {
|
|
975
|
+
let t = tt(), n = e.rows.map((e) => ({
|
|
971
976
|
status: "queued",
|
|
972
977
|
validationErrors: Object.keys(e.errors).length > 0 ? e.errors : void 0
|
|
973
978
|
})), r = new Set(e.rows.flatMap((e, t) => Object.keys(e.errors).length > 0 ? [t] : [])), i = r.size, a = {
|
|
@@ -1004,9 +1009,9 @@ function pt(e) {
|
|
|
1004
1009
|
cycleFailureCount: 0,
|
|
1005
1010
|
controller: null
|
|
1006
1011
|
};
|
|
1007
|
-
return K.set(t, o),
|
|
1012
|
+
return K.set(t, o), Ze(), pt(t, o), t;
|
|
1008
1013
|
}
|
|
1009
|
-
function
|
|
1014
|
+
function gt(e) {
|
|
1010
1015
|
let t = J(e);
|
|
1011
1016
|
if (!t || t.type !== "import" || t.status !== "paused") return;
|
|
1012
1017
|
let n = K.get(e);
|
|
@@ -1026,21 +1031,21 @@ function mt(e) {
|
|
|
1026
1031
|
failures: [],
|
|
1027
1032
|
rowStates: i,
|
|
1028
1033
|
errorMessage: void 0
|
|
1029
|
-
}),
|
|
1034
|
+
}), pt(e, n);
|
|
1030
1035
|
}
|
|
1031
|
-
function
|
|
1036
|
+
function _t(e) {
|
|
1032
1037
|
let t = J(e);
|
|
1033
1038
|
if (!t || t.type !== "import" || t.status !== "running" || t.canceling) return;
|
|
1034
1039
|
let n = K.get(e);
|
|
1035
1040
|
n && (n.pauseRequested = !0, Y(e, { pausing: !0 }));
|
|
1036
1041
|
}
|
|
1037
|
-
function
|
|
1042
|
+
function vt(e, t, n) {
|
|
1038
1043
|
let r = J(e), i = K.get(e);
|
|
1039
1044
|
if (!r || r.type !== "import" || r.status !== "paused" && r.status !== "failed" || !i) return;
|
|
1040
1045
|
let a = r.rowStates?.[t]?.status;
|
|
1041
1046
|
(a === "queued" || a === "failed") && (i.options.rows[t] = n);
|
|
1042
1047
|
}
|
|
1043
|
-
function
|
|
1048
|
+
function yt(e, t, n) {
|
|
1044
1049
|
let r = J(e), i = K.get(e);
|
|
1045
1050
|
if (!r || r.type !== "import" || !i || r.status !== "paused" && r.status !== "failed") return;
|
|
1046
1051
|
let a = Object.keys(n).length > 0, o = i.rowStates[t]?.validationErrors, s = !!(o && Object.keys(o).length > 0);
|
|
@@ -1055,7 +1060,7 @@ function _t(e, t, n) {
|
|
|
1055
1060
|
rowStates: i.rowStates
|
|
1056
1061
|
});
|
|
1057
1062
|
}
|
|
1058
|
-
function
|
|
1063
|
+
function bt(e, t) {
|
|
1059
1064
|
let n = J(e), r = K.get(e);
|
|
1060
1065
|
n && n.type === "import" && n.status === "paused" && r && (t.forEach((e) => {
|
|
1061
1066
|
let t = r.rowStates[e];
|
|
@@ -1064,21 +1069,21 @@ function vt(e, t) {
|
|
|
1064
1069
|
fieldErrors: void 0
|
|
1065
1070
|
});
|
|
1066
1071
|
}), Y(e, {
|
|
1067
|
-
total:
|
|
1072
|
+
total: st(r),
|
|
1068
1073
|
validationFailedCount: r.validationFailedCount,
|
|
1069
1074
|
rowStates: r.rowStates
|
|
1070
1075
|
}));
|
|
1071
1076
|
}
|
|
1072
|
-
function
|
|
1077
|
+
function xt(e, t, n) {
|
|
1073
1078
|
let r = J(e)?.rowStates?.[t];
|
|
1074
1079
|
if (!r?.fieldErrors?.some((e) => n in e)) return;
|
|
1075
1080
|
let i = r.fieldErrors.filter((e) => !(n in e));
|
|
1076
|
-
|
|
1081
|
+
it(e, t, {
|
|
1077
1082
|
...r,
|
|
1078
1083
|
fieldErrors: i.length > 0 ? i : void 0
|
|
1079
1084
|
});
|
|
1080
1085
|
}
|
|
1081
|
-
function
|
|
1086
|
+
function St(e) {
|
|
1082
1087
|
let t = J(e);
|
|
1083
1088
|
if (!t) return;
|
|
1084
1089
|
if (t.status === "paused") {
|
|
@@ -1093,7 +1098,7 @@ function bt(e) {
|
|
|
1093
1098
|
if (t.status !== "running") return;
|
|
1094
1099
|
if (t.type === "export") {
|
|
1095
1100
|
if (t.canceling) return;
|
|
1096
|
-
let n =
|
|
1101
|
+
let n = Xe.get(e);
|
|
1097
1102
|
if (!n) return;
|
|
1098
1103
|
n.cancelRequested = !0, n.controller?.abort(), Y(e, { canceling: !0 });
|
|
1099
1104
|
return;
|
|
@@ -1102,28 +1107,28 @@ function bt(e) {
|
|
|
1102
1107
|
let n = K.get(e);
|
|
1103
1108
|
n && (n.cancelRequested = !0, Y(e, { canceling: !0 }));
|
|
1104
1109
|
}
|
|
1105
|
-
function
|
|
1110
|
+
function Ct(e) {
|
|
1106
1111
|
let t = J(e);
|
|
1107
|
-
t && (t.status === "running" && q.get(e)?.abort(),
|
|
1112
|
+
t && (t.status === "running" && q.get(e)?.abort(), Xe.delete(e), K.delete(e), X.delete(e), G = {
|
|
1108
1113
|
...G,
|
|
1109
1114
|
tasks: G.tasks.filter((t) => t.id !== e)
|
|
1110
|
-
},
|
|
1115
|
+
}, Ze());
|
|
1111
1116
|
}
|
|
1112
|
-
function
|
|
1117
|
+
function wt(e, t) {
|
|
1113
1118
|
try {
|
|
1114
1119
|
return n(e, `${t}.xlsx`), !0;
|
|
1115
1120
|
} catch (e) {
|
|
1116
1121
|
return console.error(`下载失败: ${e}`), !1;
|
|
1117
1122
|
}
|
|
1118
1123
|
}
|
|
1119
|
-
function
|
|
1124
|
+
function Tt(e) {
|
|
1120
1125
|
let t = J(e);
|
|
1121
|
-
return t?.type !== "export" || !t.blob || !t.fileName ? !1 :
|
|
1126
|
+
return t?.type !== "export" || !t.blob || !t.fileName ? !1 : wt(t.blob, t.fileName);
|
|
1122
1127
|
}
|
|
1123
|
-
function
|
|
1124
|
-
q.forEach((e) => e.abort()), q.clear(),
|
|
1128
|
+
function Et() {
|
|
1129
|
+
q.forEach((e) => e.abort()), q.clear(), Xe.clear(), K.clear(), X.clear(), Z !== null && (clearTimeout(Z), Z = null), G = { tasks: [] }, Ze();
|
|
1125
1130
|
}
|
|
1126
|
-
function
|
|
1131
|
+
function Dt(e) {
|
|
1127
1132
|
if (e.status !== "running" || e.total <= 0) return null;
|
|
1128
1133
|
let t = Math.max(0, e.total - (e.validationFailedCount ?? 0) - e.processed);
|
|
1129
1134
|
if (t === 0) return 0;
|
|
@@ -1131,41 +1136,42 @@ function Tt(e) {
|
|
|
1131
1136
|
let n = e.samples[0], r = e.samples[e.samples.length - 1], i = (r.time - n.time) / 1e3, a = r.processed - n.processed;
|
|
1132
1137
|
return i <= 0 || a <= 0 ? null : t / (a / i);
|
|
1133
1138
|
}
|
|
1134
|
-
function
|
|
1139
|
+
function Ot(e) {
|
|
1135
1140
|
return e.type === "import" ? e.successCount === void 0 ? e.rowStates?.filter((e) => e.status === "completed").length ?? e.processed : e.successCount : e.processed;
|
|
1136
1141
|
}
|
|
1137
|
-
function
|
|
1138
|
-
return e.total <= 0 ? 0 : Math.min(100,
|
|
1142
|
+
function kt(e) {
|
|
1143
|
+
return e.total <= 0 ? 0 : Math.min(100, Ot(e) / e.total * 100);
|
|
1139
1144
|
}
|
|
1140
|
-
function
|
|
1141
|
-
|
|
1145
|
+
function At(e) {
|
|
1146
|
+
if (e.finalizing) return 100;
|
|
1147
|
+
let t = kt(e);
|
|
1142
1148
|
return t >= 100 ? 100 : Math.trunc(t * 10) / 10;
|
|
1143
1149
|
}
|
|
1144
|
-
function
|
|
1150
|
+
function jt(e) {
|
|
1145
1151
|
return `${(Math.trunc(e * 10) / 10).toFixed(1)}%`;
|
|
1146
1152
|
}
|
|
1147
|
-
function
|
|
1153
|
+
function Mt(e) {
|
|
1148
1154
|
if (e === null) return "计算中...";
|
|
1149
1155
|
let t = Math.ceil(e);
|
|
1150
1156
|
return t < 60 ? `约 ${t} 秒` : `约 ${Math.floor(t / 60)} 分 ${t % 60} 秒`;
|
|
1151
1157
|
}
|
|
1152
1158
|
// src/react/useTaskDetail.ts
|
|
1153
|
-
function
|
|
1154
|
-
let t = i(() => e ?
|
|
1155
|
-
return l(
|
|
1159
|
+
function Nt(e) {
|
|
1160
|
+
let t = i(() => e ? et().find((t) => t.id === e) : void 0, [e]);
|
|
1161
|
+
return l($e, t);
|
|
1156
1162
|
}
|
|
1157
1163
|
// src/components/BatchExportButton.tsx
|
|
1158
|
-
var
|
|
1164
|
+
var Pt = ({ title: t, fieldSchemas: n, selectedRows: r, disabled: i }) => {
|
|
1159
1165
|
let [a, o] = c(!1);
|
|
1160
|
-
return /* @__PURE__ */
|
|
1166
|
+
return /* @__PURE__ */ O(h, {
|
|
1161
1167
|
type: "default",
|
|
1162
|
-
icon: /* @__PURE__ */
|
|
1168
|
+
icon: /* @__PURE__ */ O(d, {}),
|
|
1163
1169
|
loading: a,
|
|
1164
1170
|
disabled: i ?? r.length === 0,
|
|
1165
1171
|
onClick: async () => {
|
|
1166
1172
|
if (r.length === 0) return;
|
|
1167
1173
|
if (r.length > 2e4) {
|
|
1168
|
-
E.error(`导出数据 ${r.length.toLocaleString()} 条,超过上限 ${
|
|
1174
|
+
E.error(`导出数据 ${r.length.toLocaleString()} 条,超过上限 ${he} 条,请分批导出`);
|
|
1169
1175
|
return;
|
|
1170
1176
|
}
|
|
1171
1177
|
let i = `${t}_${e().format("YYYYMMDDHHmmss")}`;
|
|
@@ -1182,7 +1188,7 @@ var Mt = ({ title: t, fieldSchemas: n, selectedRows: r, disabled: i }) => {
|
|
|
1182
1188
|
});
|
|
1183
1189
|
};
|
|
1184
1190
|
// src/components/ExportTaskModal.tsx
|
|
1185
|
-
function
|
|
1191
|
+
function Ft(e) {
|
|
1186
1192
|
if (e.canceling) return "正在取消";
|
|
1187
1193
|
if (e.finalizing) return "正在生成文件";
|
|
1188
1194
|
switch (e.status) {
|
|
@@ -1193,27 +1199,27 @@ function Nt(e) {
|
|
|
1193
1199
|
case "canceled": return "已取消";
|
|
1194
1200
|
}
|
|
1195
1201
|
}
|
|
1196
|
-
function
|
|
1202
|
+
function It(e) {
|
|
1197
1203
|
if (e.canceling) return "warning";
|
|
1198
1204
|
if (e.finalizing) return "processing";
|
|
1199
1205
|
}
|
|
1200
|
-
function
|
|
1206
|
+
function Lt(e) {
|
|
1201
1207
|
switch (e.status) {
|
|
1202
1208
|
case "failed": return "exception";
|
|
1203
1209
|
case "completed": return "success";
|
|
1204
1210
|
default: return "normal";
|
|
1205
1211
|
}
|
|
1206
1212
|
}
|
|
1207
|
-
var
|
|
1208
|
-
let n =
|
|
1213
|
+
var Rt = ({ taskId: e, onClose: t }) => {
|
|
1214
|
+
let n = Nt(e), { message: r } = m.useApp();
|
|
1209
1215
|
if (!n) return null;
|
|
1210
|
-
let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a =
|
|
1211
|
-
|
|
1216
|
+
let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = At(n), o = () => {
|
|
1217
|
+
Ct(n.id), t();
|
|
1212
1218
|
}, s = () => {
|
|
1213
|
-
|
|
1214
|
-
}, c =
|
|
1215
|
-
return /* @__PURE__ */
|
|
1216
|
-
title:
|
|
1219
|
+
Tt(n.id) || r.error("文件不存在");
|
|
1220
|
+
}, c = Ft(n);
|
|
1221
|
+
return /* @__PURE__ */ O(y, {
|
|
1222
|
+
title: n.title,
|
|
1217
1223
|
open: !0,
|
|
1218
1224
|
maskClosable: !1,
|
|
1219
1225
|
closable: i,
|
|
@@ -1221,90 +1227,80 @@ var It = ({ taskId: e, onClose: t }) => {
|
|
|
1221
1227
|
onCancel: () => {
|
|
1222
1228
|
i && o();
|
|
1223
1229
|
},
|
|
1224
|
-
footer: i ? /* @__PURE__ */
|
|
1230
|
+
footer: i ? /* @__PURE__ */ k(g, {
|
|
1225
1231
|
justify: "flex-end",
|
|
1226
1232
|
gap: 8,
|
|
1227
|
-
children: [n.status === "completed" ? /* @__PURE__ */
|
|
1233
|
+
children: [n.status === "completed" ? /* @__PURE__ */ O(h, {
|
|
1228
1234
|
onClick: s,
|
|
1229
1235
|
children: "重新下载"
|
|
1230
|
-
}) : null, /* @__PURE__ */
|
|
1236
|
+
}) : null, /* @__PURE__ */ O(h, {
|
|
1231
1237
|
type: "primary",
|
|
1232
1238
|
onClick: o,
|
|
1233
1239
|
children: "关闭"
|
|
1234
1240
|
})]
|
|
1235
|
-
}) : /* @__PURE__ */
|
|
1241
|
+
}) : /* @__PURE__ */ O(g, {
|
|
1236
1242
|
justify: "flex-end",
|
|
1237
|
-
children: /* @__PURE__ */
|
|
1243
|
+
children: /* @__PURE__ */ O(h, {
|
|
1238
1244
|
danger: !0,
|
|
1239
1245
|
loading: n.canceling,
|
|
1240
1246
|
disabled: n.canceling || n.finalizing,
|
|
1241
|
-
onClick: () =>
|
|
1242
|
-
children: n.canceling ? "取消中" :
|
|
1247
|
+
onClick: () => St(n.id),
|
|
1248
|
+
children: n.canceling ? "取消中" : "取消任务"
|
|
1243
1249
|
})
|
|
1244
1250
|
}),
|
|
1245
|
-
children: /* @__PURE__ */
|
|
1251
|
+
children: /* @__PURE__ */ k(g, {
|
|
1246
1252
|
vertical: !0,
|
|
1247
1253
|
gap: 12,
|
|
1248
1254
|
children: [
|
|
1249
|
-
/* @__PURE__ */
|
|
1255
|
+
/* @__PURE__ */ k(g, {
|
|
1250
1256
|
justify: "space-between",
|
|
1251
1257
|
align: "center",
|
|
1252
1258
|
gap: 12,
|
|
1253
|
-
children: [/* @__PURE__ */
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1260
|
+
type: "secondary",
|
|
1261
|
+
children: [
|
|
1262
|
+
"已导出 ",
|
|
1263
|
+
Ot(n).toLocaleString(),
|
|
1264
|
+
" / 总数 ",
|
|
1265
|
+
n.total > 0 ? n.total.toLocaleString() : "--"
|
|
1266
|
+
]
|
|
1267
|
+
}), /* @__PURE__ */ O(w, {
|
|
1268
|
+
color: It(n),
|
|
1259
1269
|
children: c
|
|
1260
1270
|
})]
|
|
1261
1271
|
}),
|
|
1262
|
-
/* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ O(x, {
|
|
1263
1273
|
percent: a,
|
|
1264
|
-
format: () =>
|
|
1265
|
-
status:
|
|
1274
|
+
format: () => jt(a),
|
|
1275
|
+
status: Lt(n),
|
|
1266
1276
|
size: "small"
|
|
1267
1277
|
}),
|
|
1268
|
-
/* @__PURE__ */ O(
|
|
1269
|
-
|
|
1270
|
-
children:
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
n.total > 0 ? n.total.toLocaleString() : "--"
|
|
1278
|
-
]
|
|
1279
|
-
}),
|
|
1280
|
-
n.finalizing ? /* @__PURE__ */ D(T.Text, {
|
|
1281
|
-
type: "secondary",
|
|
1282
|
-
children: "正在生成文件..."
|
|
1283
|
-
}) : null,
|
|
1284
|
-
n.canceling ? /* @__PURE__ */ D(T.Text, {
|
|
1285
|
-
type: "secondary",
|
|
1286
|
-
children: "正在取消..."
|
|
1287
|
-
}) : null
|
|
1288
|
-
]
|
|
1289
|
-
}),
|
|
1290
|
-
n.errorMessage ? /* @__PURE__ */ D(T.Text, {
|
|
1278
|
+
n.finalizing ? /* @__PURE__ */ O(T.Text, {
|
|
1279
|
+
type: "secondary",
|
|
1280
|
+
children: "正在生成文件..."
|
|
1281
|
+
}) : null,
|
|
1282
|
+
n.canceling ? /* @__PURE__ */ O(T.Text, {
|
|
1283
|
+
type: "secondary",
|
|
1284
|
+
children: "正在取消..."
|
|
1285
|
+
}) : null,
|
|
1286
|
+
n.errorMessage ? /* @__PURE__ */ O(T.Text, {
|
|
1291
1287
|
type: "danger",
|
|
1292
1288
|
children: n.errorMessage
|
|
1293
1289
|
}) : null
|
|
1294
1290
|
]
|
|
1295
1291
|
})
|
|
1296
1292
|
});
|
|
1297
|
-
},
|
|
1293
|
+
}, zt = ({ title: t, buttonText: n = "导出", fieldSchemas: r, filters: i, totalCount: o, disabled: l, fetchPage: u }) => {
|
|
1298
1294
|
let { message: f } = m.useApp(), [p, g] = c(), _ = s(void 0);
|
|
1299
1295
|
return a(() => {
|
|
1300
1296
|
_.current = p;
|
|
1301
1297
|
}, [p]), a(() => () => {
|
|
1302
|
-
_.current &&
|
|
1303
|
-
}, []), /* @__PURE__ */
|
|
1298
|
+
_.current && Ct(_.current);
|
|
1299
|
+
}, []), /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(te, {
|
|
1304
1300
|
title: "导出 Excel",
|
|
1305
|
-
children: /* @__PURE__ */
|
|
1301
|
+
children: /* @__PURE__ */ O(h, {
|
|
1306
1302
|
type: "default",
|
|
1307
|
-
icon: /* @__PURE__ */
|
|
1303
|
+
icon: /* @__PURE__ */ O(d, {}),
|
|
1308
1304
|
disabled: l,
|
|
1309
1305
|
onClick: () => {
|
|
1310
1306
|
if (o === 0) {
|
|
@@ -1312,11 +1308,11 @@ var It = ({ taskId: e, onClose: t }) => {
|
|
|
1312
1308
|
return;
|
|
1313
1309
|
}
|
|
1314
1310
|
if (o > 2e4) {
|
|
1315
|
-
f.error(`导出数据共 ${o.toLocaleString()} 条, 超过上限 ${
|
|
1311
|
+
f.error(`导出数据共 ${o.toLocaleString()} 条, 超过上限 ${he} 条, 请缩小筛选范围后分批导出`);
|
|
1316
1312
|
return;
|
|
1317
1313
|
}
|
|
1318
1314
|
let n = `${t}_${e().format("YYYYMMDDHHmmss")}`;
|
|
1319
|
-
g(
|
|
1315
|
+
g(mt({
|
|
1320
1316
|
title: `${t}导出`,
|
|
1321
1317
|
fileName: n,
|
|
1322
1318
|
fieldSchemas: r,
|
|
@@ -1328,17 +1324,17 @@ var It = ({ taskId: e, onClose: t }) => {
|
|
|
1328
1324
|
},
|
|
1329
1325
|
children: n
|
|
1330
1326
|
})
|
|
1331
|
-
}), p ? /* @__PURE__ */
|
|
1327
|
+
}), p ? /* @__PURE__ */ O(Rt, {
|
|
1332
1328
|
taskId: p,
|
|
1333
1329
|
onClose: () => g(void 0)
|
|
1334
1330
|
}) : null] });
|
|
1335
|
-
}, { Text:
|
|
1331
|
+
}, { Text: Bt } = T, Vt = ({ missingTitles: e, headerMessages: t }) => /* @__PURE__ */ k(g, {
|
|
1336
1332
|
vertical: !0,
|
|
1337
1333
|
gap: 4,
|
|
1338
|
-
children: [e.length > 0 ? /* @__PURE__ */
|
|
1334
|
+
children: [e.length > 0 ? /* @__PURE__ */ O(Bt, { children: `缺少必填列: ${e.join(", ")}` }) : null, t.map((e, t) => /* @__PURE__ */ O(Bt, { children: e }, t))]
|
|
1339
1335
|
});
|
|
1340
1336
|
// src/react/useDebouncedValue.ts
|
|
1341
|
-
function
|
|
1337
|
+
function Ht(e, t) {
|
|
1342
1338
|
let [n, r] = c(e);
|
|
1343
1339
|
return a(() => {
|
|
1344
1340
|
let n = setTimeout(() => r(e), t);
|
|
@@ -1346,7 +1342,7 @@ function Bt(e, t) {
|
|
|
1346
1342
|
}, [e, t]), n;
|
|
1347
1343
|
}
|
|
1348
1344
|
// src/react/useThrottledValue.ts
|
|
1349
|
-
function
|
|
1345
|
+
function Ut(e, t) {
|
|
1350
1346
|
let [n, r] = c(e), i = s(e), o = s(0), l = s(null);
|
|
1351
1347
|
return i.current = e, a(() => {
|
|
1352
1348
|
let n = Date.now() - o.current;
|
|
@@ -1358,12 +1354,12 @@ function Vt(e, t) {
|
|
|
1358
1354
|
}, []), n;
|
|
1359
1355
|
}
|
|
1360
1356
|
// src/components/ImportPreviewModal.tsx
|
|
1361
|
-
function
|
|
1362
|
-
return e == null || e === "" ? "" : Array.isArray(e) ?
|
|
1357
|
+
function Wt(e) {
|
|
1358
|
+
return e == null || e === "" ? "" : Array.isArray(e) ? P(e) : String(e);
|
|
1363
1359
|
}
|
|
1364
|
-
var
|
|
1360
|
+
var Gt = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
1365
1361
|
let { token: a } = ne.useToken(), [o, s] = c(!1), [l, u] = c(!1), d = t.values[e.key];
|
|
1366
|
-
if (o && !n) return e.type === "boolean" ? /* @__PURE__ */
|
|
1362
|
+
if (o && !n) return e.type === "boolean" ? /* @__PURE__ */ O(S, {
|
|
1367
1363
|
autoFocus: !0,
|
|
1368
1364
|
open: !0,
|
|
1369
1365
|
size: "small",
|
|
@@ -1380,7 +1376,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1380
1376
|
r(e), i(e), s(!1);
|
|
1381
1377
|
},
|
|
1382
1378
|
onBlur: () => s(!1)
|
|
1383
|
-
}) : e.type === "single_choice" ? /* @__PURE__ */
|
|
1379
|
+
}) : e.type === "single_choice" ? /* @__PURE__ */ O(S, {
|
|
1384
1380
|
autoFocus: !0,
|
|
1385
1381
|
open: !0,
|
|
1386
1382
|
size: "small",
|
|
@@ -1394,7 +1390,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1394
1390
|
r(e), i(e), s(!1);
|
|
1395
1391
|
},
|
|
1396
1392
|
onBlur: () => s(!1)
|
|
1397
|
-
}) : e.type === "multiple_choice" ? /* @__PURE__ */
|
|
1393
|
+
}) : e.type === "multiple_choice" ? /* @__PURE__ */ O(S, {
|
|
1398
1394
|
autoFocus: !0,
|
|
1399
1395
|
open: !0,
|
|
1400
1396
|
mode: "multiple",
|
|
@@ -1409,7 +1405,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1409
1405
|
onBlur: () => {
|
|
1410
1406
|
s(!1), i(d);
|
|
1411
1407
|
}
|
|
1412
|
-
}) : e.type === "number" ? /* @__PURE__ */
|
|
1408
|
+
}) : e.type === "number" ? /* @__PURE__ */ O(v, {
|
|
1413
1409
|
autoFocus: !0,
|
|
1414
1410
|
size: "small",
|
|
1415
1411
|
style: { width: "100%" },
|
|
@@ -1421,7 +1417,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1421
1417
|
onPressEnter: () => {
|
|
1422
1418
|
s(!1), i(d);
|
|
1423
1419
|
}
|
|
1424
|
-
}) : /* @__PURE__ */
|
|
1420
|
+
}) : /* @__PURE__ */ O(_, {
|
|
1425
1421
|
autoFocus: !0,
|
|
1426
1422
|
size: "small",
|
|
1427
1423
|
value: typeof d == "string" ? d : "",
|
|
@@ -1434,8 +1430,8 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1434
1430
|
s(!1), i(d);
|
|
1435
1431
|
}
|
|
1436
1432
|
});
|
|
1437
|
-
let f =
|
|
1438
|
-
return /* @__PURE__ */
|
|
1433
|
+
let f = Wt(d);
|
|
1434
|
+
return /* @__PURE__ */ O("div", {
|
|
1439
1435
|
title: f || void 0,
|
|
1440
1436
|
style: {
|
|
1441
1437
|
height: 24,
|
|
@@ -1456,7 +1452,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1456
1452
|
onClick: () => {
|
|
1457
1453
|
n || s(!0);
|
|
1458
1454
|
},
|
|
1459
|
-
children: /* @__PURE__ */
|
|
1455
|
+
children: /* @__PURE__ */ O("span", {
|
|
1460
1456
|
style: {
|
|
1461
1457
|
minWidth: 0,
|
|
1462
1458
|
overflow: "hidden",
|
|
@@ -1467,7 +1463,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1467
1463
|
})
|
|
1468
1464
|
});
|
|
1469
1465
|
};
|
|
1470
|
-
function
|
|
1466
|
+
function Kt(e) {
|
|
1471
1467
|
if (e.canceling) return {
|
|
1472
1468
|
label: "正在取消",
|
|
1473
1469
|
color: "warning"
|
|
@@ -1495,21 +1491,21 @@ function Wt(e) {
|
|
|
1495
1491
|
};
|
|
1496
1492
|
}
|
|
1497
1493
|
}
|
|
1498
|
-
function
|
|
1494
|
+
function qt(e, t) {
|
|
1499
1495
|
if (e.canceling) return "正在取消...";
|
|
1500
1496
|
switch (e.status) {
|
|
1501
|
-
case "running": return `预计剩余 ${
|
|
1497
|
+
case "running": return `预计剩余 ${Mt(t)}`;
|
|
1502
1498
|
default: return null;
|
|
1503
1499
|
}
|
|
1504
1500
|
}
|
|
1505
|
-
function
|
|
1501
|
+
function Jt(e) {
|
|
1506
1502
|
switch (e.status) {
|
|
1507
1503
|
case "failed": return "exception";
|
|
1508
1504
|
case "completed": return "success";
|
|
1509
1505
|
default: return "normal";
|
|
1510
1506
|
}
|
|
1511
1507
|
}
|
|
1512
|
-
var
|
|
1508
|
+
var Yt = {
|
|
1513
1509
|
valid: {
|
|
1514
1510
|
label: "已校验",
|
|
1515
1511
|
color: "success"
|
|
@@ -1518,7 +1514,7 @@ var qt = {
|
|
|
1518
1514
|
label: "校验失败",
|
|
1519
1515
|
color: "error"
|
|
1520
1516
|
}
|
|
1521
|
-
},
|
|
1517
|
+
}, Xt = {
|
|
1522
1518
|
pending: {
|
|
1523
1519
|
label: "待导入",
|
|
1524
1520
|
color: "default"
|
|
@@ -1540,10 +1536,10 @@ var qt = {
|
|
|
1540
1536
|
color: "warning"
|
|
1541
1537
|
}
|
|
1542
1538
|
};
|
|
1543
|
-
function
|
|
1539
|
+
function Zt(e) {
|
|
1544
1540
|
return Object.keys(e.errors).length > 0 ? "invalid" : "valid";
|
|
1545
1541
|
}
|
|
1546
|
-
function
|
|
1542
|
+
function Qt(e, t, n) {
|
|
1547
1543
|
if (!t || e.taskIndex === void 0) return "pending";
|
|
1548
1544
|
switch (n?.rowStates?.[e.taskIndex]?.status) {
|
|
1549
1545
|
case "running": return "running";
|
|
@@ -1553,19 +1549,19 @@ function Xt(e, t, n) {
|
|
|
1553
1549
|
default: return "pending";
|
|
1554
1550
|
}
|
|
1555
1551
|
}
|
|
1556
|
-
var
|
|
1557
|
-
let [m, v] = c("all"), [C, te] = c("all"), [E, ne] = c(""),
|
|
1552
|
+
var $t = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys: a, onChangeCell: s, onSaveCell: l, onDelete: d, onConfirm: f, onClose: p }) => {
|
|
1553
|
+
let [m, v] = c("all"), [C, te] = c("all"), [E, ne] = c(""), re = Ht(E, 300), A = () => {
|
|
1558
1554
|
v("all"), te("all"), ne("");
|
|
1559
|
-
},
|
|
1560
|
-
|
|
1561
|
-
let
|
|
1555
|
+
}, j = Nt(i), [M, ie] = c(), ae = o(() => new Set(a), [a]), oe = n.filter((e) => ae.has(e.key));
|
|
1556
|
+
j && j !== M && ie(j);
|
|
1557
|
+
let N = j ?? (M?.id === i ? M : void 0), se = N ? Kt(N) : void 0, ce = !!(N && N.status !== "completed" && N.status !== "failed" && N.status !== "canceled"), le = Ut(N?.status === "running" ? Dt(N) : null, 1e3), ue = N ? qt(N, le) : null, P = (e) => e.taskIndex === void 0 ? void 0 : N?.rowStates?.[e.taskIndex], F = !(!j || j.status !== "failed" && j.status !== "paused"), de = (e) => {
|
|
1562
1558
|
if (!i) return !0;
|
|
1563
|
-
let t =
|
|
1564
|
-
return
|
|
1565
|
-
},
|
|
1559
|
+
let t = P(e)?.status;
|
|
1560
|
+
return F && (t === "queued" || t === "failed") ? !0 : F && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
|
|
1561
|
+
}, fe = (e) => !i || j?.status === "paused" && P(e)?.status === "queued", pe = o(() => ["valid", "invalid"].map((e) => ({
|
|
1566
1562
|
value: e,
|
|
1567
|
-
label:
|
|
1568
|
-
})), []),
|
|
1563
|
+
label: Yt[e].label
|
|
1564
|
+
})), []), me = o(() => [
|
|
1569
1565
|
"pending",
|
|
1570
1566
|
"running",
|
|
1571
1567
|
"completed",
|
|
@@ -1573,33 +1569,33 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1573
1569
|
"canceled"
|
|
1574
1570
|
].map((e) => ({
|
|
1575
1571
|
value: e,
|
|
1576
|
-
label:
|
|
1577
|
-
})), []),
|
|
1578
|
-
if (!
|
|
1579
|
-
let e =
|
|
1580
|
-
return r.filter((t) =>
|
|
1572
|
+
label: Xt[e].label
|
|
1573
|
+
})), []), I = N?.status === "running", L = I ? "" : re, R = !I && m !== "all" && pe.some((e) => e.value === m) ? m : "all", z = !I && C !== "all" && me.some((e) => e.value === C) ? C : "all", B = R !== "all" || L.trim() !== "", V = z !== "all", H = B || V, U = o(() => {
|
|
1574
|
+
if (!B) return r;
|
|
1575
|
+
let e = L.trim().toLowerCase();
|
|
1576
|
+
return r.filter((t) => R !== "all" && Zt(t) !== R ? !1 : !e || Object.values(t.values).some((t) => (Array.isArray(t) ? t.join(" ") : String(t ?? "")).toLowerCase().includes(e)));
|
|
1581
1577
|
}, [
|
|
1582
1578
|
r,
|
|
1583
|
-
I,
|
|
1584
|
-
ge,
|
|
1585
|
-
_e
|
|
1586
|
-
]), ve = Vt(M, 300), ye = R ? ve : void 0, be = o(() => R ? B.filter((e) => Xt(e, i, ye) === L) : i && M ? B.slice() : B, [
|
|
1587
|
-
B,
|
|
1588
|
-
L,
|
|
1589
1579
|
R,
|
|
1590
|
-
|
|
1591
|
-
|
|
1580
|
+
L,
|
|
1581
|
+
B
|
|
1582
|
+
]), he = Ut(N, 300), ge = V ? he : void 0, _e = o(() => V ? U.filter((e) => Qt(e, i, ge) === z) : i && N ? U.slice() : U, [
|
|
1583
|
+
U,
|
|
1584
|
+
z,
|
|
1585
|
+
V,
|
|
1586
|
+
ge,
|
|
1587
|
+
N,
|
|
1592
1588
|
i
|
|
1593
|
-
]),
|
|
1589
|
+
]), ve = (e) => {
|
|
1594
1590
|
let t = Object.entries(e.errors);
|
|
1595
|
-
return /* @__PURE__ */
|
|
1591
|
+
return /* @__PURE__ */ O(g, {
|
|
1596
1592
|
vertical: !0,
|
|
1597
1593
|
gap: 4,
|
|
1598
1594
|
style: { maxWidth: 320 },
|
|
1599
1595
|
children: t.map(([e, t]) => {
|
|
1600
1596
|
let r = n.find((t) => t.key === e)?.title ?? e;
|
|
1601
|
-
return /* @__PURE__ */
|
|
1602
|
-
/* @__PURE__ */
|
|
1597
|
+
return /* @__PURE__ */ k(T.Text, { children: [
|
|
1598
|
+
/* @__PURE__ */ O(T.Text, {
|
|
1603
1599
|
strong: !0,
|
|
1604
1600
|
children: r
|
|
1605
1601
|
}),
|
|
@@ -1608,45 +1604,45 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1608
1604
|
] }, e);
|
|
1609
1605
|
})
|
|
1610
1606
|
});
|
|
1611
|
-
},
|
|
1612
|
-
let t =
|
|
1613
|
-
return t === "invalid" ? /* @__PURE__ */
|
|
1607
|
+
}, ye = (e) => {
|
|
1608
|
+
let t = Zt(e), n = Yt[t];
|
|
1609
|
+
return t === "invalid" ? /* @__PURE__ */ O(b, {
|
|
1614
1610
|
trigger: "hover",
|
|
1615
1611
|
placement: "topRight",
|
|
1616
1612
|
title: "错误信息",
|
|
1617
|
-
content:
|
|
1618
|
-
children: /* @__PURE__ */
|
|
1613
|
+
content: ve(e),
|
|
1614
|
+
children: /* @__PURE__ */ O(w, {
|
|
1619
1615
|
color: n.color,
|
|
1620
1616
|
children: n.label
|
|
1621
1617
|
})
|
|
1622
|
-
}) : /* @__PURE__ */
|
|
1618
|
+
}) : /* @__PURE__ */ O(w, {
|
|
1623
1619
|
color: n.color,
|
|
1624
1620
|
children: n.label
|
|
1625
1621
|
});
|
|
1626
|
-
},
|
|
1627
|
-
let t =
|
|
1628
|
-
if (r.length === 0) return /* @__PURE__ */
|
|
1622
|
+
}, be = (e) => {
|
|
1623
|
+
let t = P(e), r = t?.fieldErrors ?? [], i = t?.message;
|
|
1624
|
+
if (r.length === 0) return /* @__PURE__ */ O(T.Text, { children: i ?? "导入失败" });
|
|
1629
1625
|
let a = /* @__PURE__ */ new Map();
|
|
1630
1626
|
r.forEach((e) => {
|
|
1631
1627
|
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) ?? [];
|
|
1632
1628
|
o.push(r), a.set(i, o);
|
|
1633
1629
|
});
|
|
1634
1630
|
let o = [...a.entries()], s = o.slice(0, 3), c = o.length - s.length;
|
|
1635
|
-
return /* @__PURE__ */
|
|
1631
|
+
return /* @__PURE__ */ k(g, {
|
|
1636
1632
|
vertical: !0,
|
|
1637
1633
|
gap: 8,
|
|
1638
1634
|
style: { maxWidth: 360 },
|
|
1639
1635
|
children: [
|
|
1640
|
-
i ? /* @__PURE__ */
|
|
1641
|
-
s.map(([e, t]) => /* @__PURE__ */
|
|
1636
|
+
i ? /* @__PURE__ */ O(T.Text, { children: i }) : null,
|
|
1637
|
+
s.map(([e, t]) => /* @__PURE__ */ k(g, {
|
|
1642
1638
|
vertical: !0,
|
|
1643
1639
|
gap: 2,
|
|
1644
|
-
children: [/* @__PURE__ */
|
|
1640
|
+
children: [/* @__PURE__ */ O(T.Text, {
|
|
1645
1641
|
strong: !0,
|
|
1646
1642
|
children: e
|
|
1647
|
-
}), t.map((e, t) => /* @__PURE__ */
|
|
1643
|
+
}), t.map((e, t) => /* @__PURE__ */ k(T.Text, { children: ["• ", e] }, t))]
|
|
1648
1644
|
}, e)),
|
|
1649
|
-
c > 0 ? /* @__PURE__ */
|
|
1645
|
+
c > 0 ? /* @__PURE__ */ k(T.Text, {
|
|
1650
1646
|
type: "secondary",
|
|
1651
1647
|
children: [
|
|
1652
1648
|
"还有 ",
|
|
@@ -1656,36 +1652,36 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1656
1652
|
}) : null
|
|
1657
1653
|
]
|
|
1658
1654
|
});
|
|
1659
|
-
},
|
|
1660
|
-
let t =
|
|
1655
|
+
}, xe = (e) => {
|
|
1656
|
+
let t = Qt(e, i, N), n = Xt[t];
|
|
1661
1657
|
if (t === "failed") {
|
|
1662
|
-
let t =
|
|
1663
|
-
return /* @__PURE__ */
|
|
1658
|
+
let t = P(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
|
|
1659
|
+
return /* @__PURE__ */ O(b, {
|
|
1664
1660
|
trigger: "hover",
|
|
1665
1661
|
placement: "topRight",
|
|
1666
1662
|
title: "错误信息",
|
|
1667
|
-
content:
|
|
1668
|
-
children: /* @__PURE__ */
|
|
1663
|
+
content: be(e),
|
|
1664
|
+
children: /* @__PURE__ */ O(w, {
|
|
1669
1665
|
color: n.color,
|
|
1670
1666
|
children: i
|
|
1671
1667
|
})
|
|
1672
1668
|
});
|
|
1673
1669
|
}
|
|
1674
|
-
return /* @__PURE__ */
|
|
1670
|
+
return /* @__PURE__ */ O(w, {
|
|
1675
1671
|
color: n.color,
|
|
1676
1672
|
children: n.label
|
|
1677
1673
|
});
|
|
1678
|
-
},
|
|
1674
|
+
}, Se = (e) => /* @__PURE__ */ O(h, {
|
|
1679
1675
|
type: "primary",
|
|
1680
1676
|
danger: !0,
|
|
1681
1677
|
size: "small",
|
|
1682
|
-
disabled: !
|
|
1683
|
-
icon: /* @__PURE__ */
|
|
1678
|
+
disabled: !fe(e),
|
|
1679
|
+
icon: /* @__PURE__ */ O(u, {}),
|
|
1684
1680
|
onClick: () => {
|
|
1685
|
-
d(e),
|
|
1681
|
+
d(e), j && e.taskIndex !== void 0 && bt(j.id, [e.taskIndex]);
|
|
1686
1682
|
},
|
|
1687
1683
|
children: "删除"
|
|
1688
|
-
}),
|
|
1684
|
+
}), Ce = [
|
|
1689
1685
|
{
|
|
1690
1686
|
key: "rowNumber",
|
|
1691
1687
|
title: "行号",
|
|
@@ -1693,15 +1689,15 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1693
1689
|
width: 60,
|
|
1694
1690
|
fixed: "left"
|
|
1695
1691
|
},
|
|
1696
|
-
...
|
|
1692
|
+
...oe.map((e) => ({
|
|
1697
1693
|
key: e.key,
|
|
1698
1694
|
title: e.title,
|
|
1699
1695
|
dataIndex: e.key,
|
|
1700
1696
|
width: 160,
|
|
1701
|
-
render: (t, n) => /* @__PURE__ */
|
|
1697
|
+
render: (t, n) => /* @__PURE__ */ O(Gt, {
|
|
1702
1698
|
field: e,
|
|
1703
1699
|
record: n,
|
|
1704
|
-
disabled: !
|
|
1700
|
+
disabled: !de(n),
|
|
1705
1701
|
onChange: (t) => s(n, e, t),
|
|
1706
1702
|
onSave: (t) => l(n, e, t)
|
|
1707
1703
|
})
|
|
@@ -1711,24 +1707,24 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1711
1707
|
title: "数据状态",
|
|
1712
1708
|
width: 100,
|
|
1713
1709
|
fixed: "right",
|
|
1714
|
-
render: (e, t) =>
|
|
1710
|
+
render: (e, t) => ye(t)
|
|
1715
1711
|
},
|
|
1716
1712
|
{
|
|
1717
1713
|
key: "importStatus",
|
|
1718
1714
|
title: "导入状态",
|
|
1719
1715
|
width: 110,
|
|
1720
1716
|
fixed: "right",
|
|
1721
|
-
render: (e, t) =>
|
|
1717
|
+
render: (e, t) => xe(t)
|
|
1722
1718
|
},
|
|
1723
1719
|
{
|
|
1724
1720
|
key: "action",
|
|
1725
1721
|
title: "操作",
|
|
1726
1722
|
width: 80,
|
|
1727
1723
|
fixed: "right",
|
|
1728
|
-
render: (e, t) =>
|
|
1724
|
+
render: (e, t) => Se(t)
|
|
1729
1725
|
}
|
|
1730
|
-
],
|
|
1731
|
-
return /* @__PURE__ */ D
|
|
1726
|
+
], we = Math.max(1200, 60 + oe.length * 160 + 100 + 110 + 80), Te = N && N.total > 0 ? At(N) : 0, Ee = N?.failureCount ?? N?.failures?.length ?? 0, De = N?.validationFailedCount ?? r.filter((e) => Object.keys(e.errors).length > 0).length, Oe = r.filter((e) => Object.keys(e.errors).length > 0).length, ke = r.length > 0 && Oe === r.length;
|
|
1727
|
+
return /* @__PURE__ */ O(D, { children: /* @__PURE__ */ k(y, {
|
|
1732
1728
|
title: i ? `${t}导入` : `${t}导入预览`,
|
|
1733
1729
|
open: e,
|
|
1734
1730
|
width: "min(1400px, 96vw)",
|
|
@@ -1736,68 +1732,68 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1736
1732
|
closable: !1,
|
|
1737
1733
|
keyboard: !1,
|
|
1738
1734
|
onCancel: () => {
|
|
1739
|
-
|
|
1735
|
+
ce || p();
|
|
1740
1736
|
},
|
|
1741
1737
|
footer: (() => {
|
|
1742
|
-
if (!i) return /* @__PURE__ */
|
|
1738
|
+
if (!i) return /* @__PURE__ */ k(g, {
|
|
1743
1739
|
justify: "space-between",
|
|
1744
1740
|
align: "center",
|
|
1745
1741
|
gap: 8,
|
|
1746
1742
|
wrap: !0,
|
|
1747
|
-
children: [/* @__PURE__ */
|
|
1743
|
+
children: [/* @__PURE__ */ O("span", { children: r.length > 0 && Oe > 0 ? /* @__PURE__ */ O(T.Text, {
|
|
1748
1744
|
type: ke ? "danger" : "secondary",
|
|
1749
|
-
children: ke ? "全部行校验失败, 请先修正后再导入" : `有 ${
|
|
1750
|
-
}) : null }), /* @__PURE__ */
|
|
1745
|
+
children: ke ? "全部行校验失败, 请先修正后再导入" : `有 ${Oe} 行校验失败, 不会导入`
|
|
1746
|
+
}) : null }), /* @__PURE__ */ k(g, {
|
|
1751
1747
|
gap: 8,
|
|
1752
|
-
children: [/* @__PURE__ */
|
|
1748
|
+
children: [/* @__PURE__ */ O(h, {
|
|
1753
1749
|
onClick: p,
|
|
1754
1750
|
children: "取消"
|
|
1755
|
-
}), /* @__PURE__ */
|
|
1751
|
+
}), /* @__PURE__ */ O(h, {
|
|
1756
1752
|
type: "primary",
|
|
1757
1753
|
disabled: r.length === 0 || ke,
|
|
1758
1754
|
onClick: () => {
|
|
1759
|
-
|
|
1755
|
+
A(), f();
|
|
1760
1756
|
},
|
|
1761
1757
|
children: "开始导入"
|
|
1762
1758
|
})]
|
|
1763
1759
|
})]
|
|
1764
1760
|
});
|
|
1765
|
-
if (!
|
|
1761
|
+
if (!j || !N) return /* @__PURE__ */ O(g, {
|
|
1766
1762
|
justify: "flex-end",
|
|
1767
|
-
children: /* @__PURE__ */
|
|
1763
|
+
children: /* @__PURE__ */ O(h, {
|
|
1768
1764
|
onClick: p,
|
|
1769
1765
|
children: "关闭"
|
|
1770
1766
|
})
|
|
1771
1767
|
});
|
|
1772
|
-
let e =
|
|
1773
|
-
return /* @__PURE__ */
|
|
1768
|
+
let e = N.status === "running", t = N.status === "paused";
|
|
1769
|
+
return /* @__PURE__ */ k(g, {
|
|
1774
1770
|
justify: "flex-end",
|
|
1775
1771
|
gap: 8,
|
|
1776
1772
|
children: [
|
|
1777
|
-
e ? /* @__PURE__ */
|
|
1773
|
+
e ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(h, {
|
|
1778
1774
|
danger: !0,
|
|
1779
|
-
loading:
|
|
1780
|
-
disabled:
|
|
1781
|
-
onClick: () =>
|
|
1782
|
-
children:
|
|
1783
|
-
}), /* @__PURE__ */
|
|
1784
|
-
loading:
|
|
1785
|
-
disabled:
|
|
1786
|
-
onClick: () =>
|
|
1775
|
+
loading: N.canceling,
|
|
1776
|
+
disabled: N.canceling,
|
|
1777
|
+
onClick: () => St(N.id),
|
|
1778
|
+
children: N.canceling ? "取消中" : "取消任务"
|
|
1779
|
+
}), /* @__PURE__ */ O(h, {
|
|
1780
|
+
loading: N.pausing,
|
|
1781
|
+
disabled: N.canceling,
|
|
1782
|
+
onClick: () => _t(N.id),
|
|
1787
1783
|
children: "暂停"
|
|
1788
1784
|
})] }) : null,
|
|
1789
|
-
t ? /* @__PURE__ */
|
|
1785
|
+
t ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(h, {
|
|
1790
1786
|
danger: !0,
|
|
1791
|
-
onClick: () =>
|
|
1787
|
+
onClick: () => St(N.id),
|
|
1792
1788
|
children: "取消任务"
|
|
1793
|
-
}), /* @__PURE__ */
|
|
1789
|
+
}), /* @__PURE__ */ O(h, {
|
|
1794
1790
|
type: "primary",
|
|
1795
1791
|
onClick: () => {
|
|
1796
|
-
|
|
1792
|
+
A(), gt(N.id);
|
|
1797
1793
|
},
|
|
1798
1794
|
children: "继续导入"
|
|
1799
1795
|
})] }) : null,
|
|
1800
|
-
!e && !t ? /* @__PURE__ */
|
|
1796
|
+
!e && !t ? /* @__PURE__ */ O(h, {
|
|
1801
1797
|
type: "primary",
|
|
1802
1798
|
onClick: p,
|
|
1803
1799
|
children: "关闭"
|
|
@@ -1806,181 +1802,181 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1806
1802
|
});
|
|
1807
1803
|
})(),
|
|
1808
1804
|
children: [
|
|
1809
|
-
|
|
1805
|
+
N && se ? /* @__PURE__ */ k(g, {
|
|
1810
1806
|
vertical: !0,
|
|
1811
1807
|
gap: 4,
|
|
1812
1808
|
style: { marginBottom: 12 },
|
|
1813
|
-
children: [/* @__PURE__ */
|
|
1809
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1814
1810
|
justify: "space-between",
|
|
1815
1811
|
align: "center",
|
|
1816
|
-
children: [/* @__PURE__ */
|
|
1812
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1817
1813
|
type: "secondary",
|
|
1818
1814
|
children: [
|
|
1819
1815
|
"已导入 ",
|
|
1820
|
-
|
|
1816
|
+
Ot(N).toLocaleString(),
|
|
1821
1817
|
" / 总数 ",
|
|
1822
|
-
|
|
1818
|
+
N.total.toLocaleString()
|
|
1823
1819
|
]
|
|
1824
|
-
}), /* @__PURE__ */
|
|
1820
|
+
}), /* @__PURE__ */ k(g, {
|
|
1825
1821
|
align: "center",
|
|
1826
1822
|
gap: 8,
|
|
1827
1823
|
children: [
|
|
1828
|
-
|
|
1824
|
+
ue ? /* @__PURE__ */ O(T.Text, {
|
|
1829
1825
|
type: "secondary",
|
|
1830
|
-
children:
|
|
1826
|
+
children: ue
|
|
1831
1827
|
}) : null,
|
|
1832
|
-
|
|
1828
|
+
De > 0 ? /* @__PURE__ */ k(w, {
|
|
1833
1829
|
color: "error",
|
|
1834
1830
|
children: [
|
|
1835
1831
|
"校验失败 ",
|
|
1836
|
-
|
|
1832
|
+
De,
|
|
1837
1833
|
" 条"
|
|
1838
1834
|
]
|
|
1839
1835
|
}) : null,
|
|
1840
|
-
|
|
1836
|
+
Ee > 0 ? /* @__PURE__ */ k(w, {
|
|
1841
1837
|
color: "error",
|
|
1842
1838
|
children: [
|
|
1843
1839
|
"导入失败 ",
|
|
1844
|
-
|
|
1840
|
+
Ee,
|
|
1845
1841
|
" 条"
|
|
1846
1842
|
]
|
|
1847
1843
|
}) : null,
|
|
1848
|
-
/* @__PURE__ */
|
|
1849
|
-
color:
|
|
1850
|
-
children:
|
|
1844
|
+
/* @__PURE__ */ O(w, {
|
|
1845
|
+
color: se.color,
|
|
1846
|
+
children: se.label
|
|
1851
1847
|
})
|
|
1852
1848
|
]
|
|
1853
1849
|
})]
|
|
1854
|
-
}), /* @__PURE__ */
|
|
1855
|
-
percent:
|
|
1856
|
-
format: () =>
|
|
1857
|
-
status:
|
|
1850
|
+
}), /* @__PURE__ */ O(x, {
|
|
1851
|
+
percent: Te,
|
|
1852
|
+
format: () => jt(Te),
|
|
1853
|
+
status: Jt(N),
|
|
1858
1854
|
size: "small"
|
|
1859
1855
|
})]
|
|
1860
|
-
}) : i ? null : /* @__PURE__ */
|
|
1856
|
+
}) : i ? null : /* @__PURE__ */ k(g, {
|
|
1861
1857
|
vertical: !0,
|
|
1862
1858
|
gap: 4,
|
|
1863
1859
|
style: { marginBottom: 12 },
|
|
1864
|
-
children: [/* @__PURE__ */
|
|
1860
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1865
1861
|
justify: "space-between",
|
|
1866
1862
|
align: "center",
|
|
1867
|
-
children: [/* @__PURE__ */
|
|
1863
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1868
1864
|
type: "secondary",
|
|
1869
1865
|
children: ["总数 ", r.length.toLocaleString()]
|
|
1870
|
-
}), /* @__PURE__ */
|
|
1866
|
+
}), /* @__PURE__ */ k(g, {
|
|
1871
1867
|
align: "center",
|
|
1872
1868
|
gap: 8,
|
|
1873
|
-
children: [
|
|
1869
|
+
children: [De > 0 ? /* @__PURE__ */ k(w, {
|
|
1874
1870
|
color: "error",
|
|
1875
1871
|
children: [
|
|
1876
1872
|
"校验失败 ",
|
|
1877
|
-
|
|
1873
|
+
De,
|
|
1878
1874
|
" 条"
|
|
1879
1875
|
]
|
|
1880
|
-
}) : null, /* @__PURE__ */
|
|
1876
|
+
}) : null, /* @__PURE__ */ O(w, { children: "待导入" })]
|
|
1881
1877
|
})]
|
|
1882
|
-
}), /* @__PURE__ */
|
|
1878
|
+
}), /* @__PURE__ */ O(x, {
|
|
1883
1879
|
percent: 0,
|
|
1884
1880
|
format: () => "0.0%",
|
|
1885
1881
|
size: "small"
|
|
1886
1882
|
})]
|
|
1887
1883
|
}),
|
|
1888
|
-
/* @__PURE__ */
|
|
1884
|
+
/* @__PURE__ */ k(g, {
|
|
1889
1885
|
justify: "space-between",
|
|
1890
1886
|
align: "center",
|
|
1891
1887
|
gap: 8,
|
|
1892
1888
|
wrap: !0,
|
|
1893
1889
|
style: { marginBottom: 8 },
|
|
1894
|
-
children: [/* @__PURE__ */
|
|
1890
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1895
1891
|
align: "center",
|
|
1896
1892
|
gap: 8,
|
|
1897
1893
|
wrap: !0,
|
|
1898
1894
|
children: [
|
|
1899
|
-
/* @__PURE__ */
|
|
1895
|
+
/* @__PURE__ */ O(_, {
|
|
1900
1896
|
allowClear: !0,
|
|
1901
|
-
disabled:
|
|
1897
|
+
disabled: I,
|
|
1902
1898
|
placeholder: "搜索所有字段",
|
|
1903
|
-
value:
|
|
1899
|
+
value: I ? "" : E,
|
|
1904
1900
|
style: { width: 260 },
|
|
1905
1901
|
onChange: (e) => {
|
|
1906
1902
|
ne(e.target.value);
|
|
1907
1903
|
}
|
|
1908
1904
|
}),
|
|
1909
|
-
/* @__PURE__ */
|
|
1905
|
+
/* @__PURE__ */ O(S, {
|
|
1910
1906
|
allowClear: !0,
|
|
1911
|
-
disabled:
|
|
1907
|
+
disabled: I,
|
|
1912
1908
|
placeholder: "数据状态",
|
|
1913
|
-
value:
|
|
1914
|
-
options:
|
|
1909
|
+
value: R === "all" ? void 0 : R,
|
|
1910
|
+
options: pe,
|
|
1915
1911
|
style: { width: 140 },
|
|
1916
1912
|
onChange: (e) => {
|
|
1917
1913
|
v(e ?? "all");
|
|
1918
1914
|
}
|
|
1919
1915
|
}),
|
|
1920
|
-
/* @__PURE__ */
|
|
1916
|
+
/* @__PURE__ */ O(S, {
|
|
1921
1917
|
allowClear: !0,
|
|
1922
|
-
disabled:
|
|
1918
|
+
disabled: I,
|
|
1923
1919
|
placeholder: "导入状态",
|
|
1924
|
-
value:
|
|
1925
|
-
options:
|
|
1920
|
+
value: z === "all" ? void 0 : z,
|
|
1921
|
+
options: me,
|
|
1926
1922
|
style: { width: 140 },
|
|
1927
1923
|
onChange: (e) => {
|
|
1928
1924
|
te(e ?? "all");
|
|
1929
1925
|
}
|
|
1930
1926
|
})
|
|
1931
1927
|
]
|
|
1932
|
-
}),
|
|
1928
|
+
}), H ? /* @__PURE__ */ k(T.Text, {
|
|
1933
1929
|
type: "secondary",
|
|
1934
1930
|
children: [
|
|
1935
1931
|
"筛选出 ",
|
|
1936
|
-
|
|
1932
|
+
_e.length,
|
|
1937
1933
|
" 条"
|
|
1938
1934
|
]
|
|
1939
1935
|
}) : null]
|
|
1940
1936
|
}),
|
|
1941
|
-
/* @__PURE__ */
|
|
1937
|
+
/* @__PURE__ */ O(ee, {
|
|
1942
1938
|
rowKey: "key",
|
|
1943
1939
|
size: "middle",
|
|
1944
1940
|
tableLayout: "fixed",
|
|
1945
1941
|
virtual: !0,
|
|
1946
|
-
columns:
|
|
1947
|
-
dataSource:
|
|
1942
|
+
columns: Ce,
|
|
1943
|
+
dataSource: _e,
|
|
1948
1944
|
pagination: !1,
|
|
1949
1945
|
scroll: {
|
|
1950
|
-
x:
|
|
1946
|
+
x: we,
|
|
1951
1947
|
y: 520
|
|
1952
1948
|
},
|
|
1953
|
-
locale: { emptyText:
|
|
1949
|
+
locale: { emptyText: H ? "没有符合条件的行" : void 0 }
|
|
1954
1950
|
})
|
|
1955
1951
|
]
|
|
1956
1952
|
}) });
|
|
1957
|
-
},
|
|
1953
|
+
}, en = "缺少列: ", tn = [
|
|
1958
1954
|
/期望为一个包含物件的列表/,
|
|
1959
1955
|
/expected a list/i,
|
|
1960
1956
|
/得到的类型是/,
|
|
1961
1957
|
/not a list/i
|
|
1962
1958
|
];
|
|
1963
|
-
function
|
|
1964
|
-
return
|
|
1959
|
+
function nn(e) {
|
|
1960
|
+
return tn.some((t) => t.test(e)) ? "数据格式不正确, 请检查导入内容" : e;
|
|
1965
1961
|
}
|
|
1966
|
-
function
|
|
1962
|
+
function rn(e) {
|
|
1967
1963
|
if (Object.keys(e).length === 0) return { success: !0 };
|
|
1968
1964
|
let t = [], n;
|
|
1969
1965
|
return Object.entries(e).forEach(([e, r]) => {
|
|
1970
1966
|
let i = Array.isArray(r) ? r : [r];
|
|
1971
|
-
e === "detail" || e === "non_field_errors" ? n = i.map((e) =>
|
|
1967
|
+
e === "detail" || e === "non_field_errors" ? n = i.map((e) => nn(String(e))).join("; ") : i.forEach((n) => t.push({ [e]: nn(String(n)) }));
|
|
1972
1968
|
}), {
|
|
1973
1969
|
success: !1,
|
|
1974
1970
|
...n ? { message: n } : {},
|
|
1975
1971
|
...t.length > 0 ? { fieldErrors: t } : {}
|
|
1976
1972
|
};
|
|
1977
1973
|
}
|
|
1978
|
-
function
|
|
1974
|
+
function an(e) {
|
|
1979
1975
|
if (!Ue(e)) return "导入失败, 任务已暂停";
|
|
1980
1976
|
let t = We(e);
|
|
1981
1977
|
return t === void 0 ? "网络异常, 任务已暂停" : t === 401 ? "登录已过期, 任务已暂停" : t === 403 ? "没有导入权限, 任务已暂停" : t === 404 ? "导入接口不存在, 任务已暂停" : t === 400 ? "请求参数错误, 任务已暂停" : t >= 500 ? "服务器错误, 任务已暂停" : "导入失败, 任务已暂停";
|
|
1982
1978
|
}
|
|
1983
|
-
function
|
|
1979
|
+
function on(e) {
|
|
1984
1980
|
let t = Ge(e);
|
|
1985
1981
|
if (t && typeof t == "object") {
|
|
1986
1982
|
let e = t;
|
|
@@ -1993,41 +1989,41 @@ function rn(e) {
|
|
|
1993
1989
|
}
|
|
1994
1990
|
return "导入数据校验失败";
|
|
1995
1991
|
}
|
|
1996
|
-
var
|
|
1997
|
-
let [i, l] = c(!1), [u, d] = c([]), [g, _] = c(), [v, y] = c("empty"), [b, x] = c(!1), [S, ee] = c(!1), [w, T] = c([]), { modal: ne } = m.useApp(),
|
|
1992
|
+
var sn = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
1993
|
+
let [i, l] = c(!1), [u, d] = c([]), [g, _] = c(), [v, y] = c("empty"), [b, x] = c(!1), [S, ee] = c(!1), [w, T] = c([]), { modal: ne } = m.useApp(), re = s(null), A = s(void 0), j = o(() => ce(t), [t]);
|
|
1998
1994
|
a(() => {
|
|
1999
|
-
|
|
1995
|
+
A.current = g;
|
|
2000
1996
|
}, [g]), a(() => () => {
|
|
2001
|
-
|
|
1997
|
+
A.current && Ct(A.current);
|
|
2002
1998
|
}, []);
|
|
2003
|
-
let
|
|
1999
|
+
let M = () => re.current?.click(), ie = (e, t) => {
|
|
2004
2000
|
ne.warning({
|
|
2005
2001
|
title: t ?? (e.missingTitles.length > 0 ? "文件表头不完整" : "文件检查未通过"),
|
|
2006
2002
|
width: 480,
|
|
2007
|
-
content: /* @__PURE__ */
|
|
2003
|
+
content: /* @__PURE__ */ O(Vt, { ...e }),
|
|
2008
2004
|
okCancel: !0,
|
|
2009
2005
|
okText: "重新选择文件",
|
|
2010
2006
|
cancelText: "关闭",
|
|
2011
2007
|
closable: !0,
|
|
2012
|
-
onOk:
|
|
2008
|
+
onOk: M
|
|
2013
2009
|
});
|
|
2014
|
-
},
|
|
2010
|
+
}, ae = async (e) => {
|
|
2015
2011
|
if (e.size > 20971520) E.error("文件大小超过 20MB, 请拆分后再导入");
|
|
2016
2012
|
else {
|
|
2017
2013
|
_(void 0), T([]), x(!0);
|
|
2018
2014
|
try {
|
|
2019
|
-
let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await He(e,
|
|
2015
|
+
let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await He(e, j);
|
|
2020
2016
|
if (n.length > 0) {
|
|
2021
|
-
|
|
2017
|
+
ie({
|
|
2022
2018
|
missingTitles: [],
|
|
2023
2019
|
headerMessages: n
|
|
2024
2020
|
}, "文件里的公式还没有计算结果");
|
|
2025
2021
|
return;
|
|
2026
2022
|
}
|
|
2027
2023
|
if (t.length > 0) {
|
|
2028
|
-
|
|
2029
|
-
missingTitles: t.filter((e) => e.startsWith(
|
|
2030
|
-
headerMessages: t.filter((e) => !e.startsWith(
|
|
2024
|
+
ie({
|
|
2025
|
+
missingTitles: t.filter((e) => e.startsWith(en)).map((e) => e.slice(5)),
|
|
2026
|
+
headerMessages: t.filter((e) => !e.startsWith(en))
|
|
2031
2027
|
});
|
|
2032
2028
|
return;
|
|
2033
2029
|
}
|
|
@@ -2043,29 +2039,29 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2043
2039
|
}
|
|
2044
2040
|
}
|
|
2045
2041
|
};
|
|
2046
|
-
return /* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */
|
|
2042
|
+
return /* @__PURE__ */ k(D, { children: [
|
|
2043
|
+
/* @__PURE__ */ k(C.Compact, {
|
|
2048
2044
|
block: !0,
|
|
2049
|
-
children: [/* @__PURE__ */
|
|
2045
|
+
children: [/* @__PURE__ */ O(te, {
|
|
2050
2046
|
title: "Excel 导入",
|
|
2051
|
-
children: /* @__PURE__ */
|
|
2047
|
+
children: /* @__PURE__ */ O(h, {
|
|
2052
2048
|
type: "default",
|
|
2053
|
-
icon: /* @__PURE__ */
|
|
2049
|
+
icon: /* @__PURE__ */ O(p, {}),
|
|
2054
2050
|
loading: b,
|
|
2055
2051
|
disabled: b,
|
|
2056
|
-
onClick:
|
|
2052
|
+
onClick: M,
|
|
2057
2053
|
children: "导入"
|
|
2058
2054
|
})
|
|
2059
|
-
}), /* @__PURE__ */
|
|
2055
|
+
}), /* @__PURE__ */ O(te, {
|
|
2060
2056
|
title: "Excel 导入模板",
|
|
2061
|
-
children: /* @__PURE__ */
|
|
2057
|
+
children: /* @__PURE__ */ O(h, {
|
|
2062
2058
|
type: "default",
|
|
2063
|
-
icon: /* @__PURE__ */
|
|
2059
|
+
icon: /* @__PURE__ */ O(f, {}),
|
|
2064
2060
|
loading: S,
|
|
2065
2061
|
onClick: async () => {
|
|
2066
2062
|
ee(!0);
|
|
2067
2063
|
try {
|
|
2068
|
-
await Ve(
|
|
2064
|
+
await Ve(j, `${e}导入模板`);
|
|
2069
2065
|
} catch (e) {
|
|
2070
2066
|
console.error(`模板下载失败: ${e}`), E.error("模板下载失败");
|
|
2071
2067
|
} finally {
|
|
@@ -2076,26 +2072,26 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2076
2072
|
})
|
|
2077
2073
|
})]
|
|
2078
2074
|
}),
|
|
2079
|
-
/* @__PURE__ */
|
|
2080
|
-
ref:
|
|
2075
|
+
/* @__PURE__ */ O("input", {
|
|
2076
|
+
ref: re,
|
|
2081
2077
|
type: "file",
|
|
2082
2078
|
accept: ".xlsx",
|
|
2083
2079
|
style: { display: "none" },
|
|
2084
2080
|
onChange: (e) => {
|
|
2085
2081
|
let t = e.target.files?.[0];
|
|
2086
|
-
e.target.value = "", t &&
|
|
2082
|
+
e.target.value = "", t && ae(t);
|
|
2087
2083
|
}
|
|
2088
2084
|
}),
|
|
2089
|
-
/* @__PURE__ */
|
|
2085
|
+
/* @__PURE__ */ O($t, {
|
|
2090
2086
|
open: i,
|
|
2091
2087
|
title: e,
|
|
2092
|
-
fieldSchemas:
|
|
2088
|
+
fieldSchemas: j,
|
|
2093
2089
|
rows: u,
|
|
2094
2090
|
taskId: g,
|
|
2095
2091
|
includedKeys: w,
|
|
2096
2092
|
onChangeCell: (e, t, n) => {
|
|
2097
2093
|
if (!w.includes(t.key)) return;
|
|
2098
|
-
let r =
|
|
2094
|
+
let r = be(t, n), i = H(r.trim() === "" ? null : r, t);
|
|
2099
2095
|
d((r) => r.map((r) => {
|
|
2100
2096
|
if (r.key !== e.key) return r;
|
|
2101
2097
|
let a = { ...r.errors };
|
|
@@ -2115,9 +2111,9 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2115
2111
|
...e.values,
|
|
2116
2112
|
[t.key]: n
|
|
2117
2113
|
}, i = {};
|
|
2118
|
-
|
|
2114
|
+
j.forEach((e) => {
|
|
2119
2115
|
if (!w.includes(e.key)) return;
|
|
2120
|
-
let t =
|
|
2116
|
+
let t = be(e, r[e.key]), n = H(t.trim() === "" ? null : t, e);
|
|
2121
2117
|
n.validateSuccess || (i[e.key] = n.validateMessage);
|
|
2122
2118
|
});
|
|
2123
2119
|
let a = {
|
|
@@ -2125,7 +2121,7 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2125
2121
|
values: r,
|
|
2126
2122
|
errors: i
|
|
2127
2123
|
};
|
|
2128
|
-
d((t) => t.map((t) => t.key === e.key ? a : t)), g && e.taskIndex !== void 0 && (
|
|
2124
|
+
d((t) => t.map((t) => t.key === e.key ? a : t)), g && e.taskIndex !== void 0 && (xt(g, e.taskIndex, t.key), yt(g, e.taskIndex, i), vt(g, e.taskIndex, a));
|
|
2129
2125
|
},
|
|
2130
2126
|
onDelete: (e) => {
|
|
2131
2127
|
d((t) => t.filter((t) => t.key !== e.key));
|
|
@@ -2145,18 +2141,18 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2145
2141
|
taskIndex: t
|
|
2146
2142
|
}));
|
|
2147
2143
|
d(i);
|
|
2148
|
-
let a =
|
|
2144
|
+
let a = ht({
|
|
2149
2145
|
title: `${e}导入`,
|
|
2150
2146
|
rows: i,
|
|
2151
|
-
fieldSchemas:
|
|
2147
|
+
fieldSchemas: j,
|
|
2152
2148
|
includedKeys: w,
|
|
2153
2149
|
importRows: async (e, t) => {
|
|
2154
2150
|
try {
|
|
2155
|
-
let r = await n(e.map((e) =>
|
|
2151
|
+
let r = await n(e.map((e) => xe(e, j, w)), t);
|
|
2156
2152
|
if (r.length !== e.length) throw new W("导入接口返回结果数量不正确, 任务已暂停");
|
|
2157
|
-
return r.map(
|
|
2153
|
+
return r.map(rn);
|
|
2158
2154
|
} catch (e) {
|
|
2159
|
-
throw t.aborted || e instanceof W ? e : We(e) === 422 ? Error(
|
|
2155
|
+
throw t.aborted || e instanceof W ? e : We(e) === 422 ? Error(on(e)) : new W(an(e));
|
|
2160
2156
|
}
|
|
2161
2157
|
},
|
|
2162
2158
|
onFinished: r
|
|
@@ -2164,9 +2160,9 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2164
2160
|
_(a);
|
|
2165
2161
|
},
|
|
2166
2162
|
onClose: () => {
|
|
2167
|
-
g &&
|
|
2163
|
+
g && Ct(g), l(!1), _(void 0), d([]), T([]);
|
|
2168
2164
|
}
|
|
2169
2165
|
}, v)
|
|
2170
2166
|
] });
|
|
2171
2167
|
};
|
|
2172
|
-
export {
|
|
2168
|
+
export { Pt as BatchExportButton, zt as ExcelExportButton, sn as ExcelImportButton, Rt as ExportTaskModal, W as ImportPauseError, he as MAX_EXPORT_ROWS, ge as MAX_IMPORT_FILE_SIZE, U as MAX_IMPORT_ROWS, le as MULTI_VALUE_SEPARATOR, Ne as autoAdjustColumnWidths, ze as buildExportBlob, xe as buildImportPayload, St as cancelTask, xt as clearImportRowFieldError, gt as continueTask, bt as deleteImportRows, Ct as dismissTask, Ve as downloadImportTemplate, Tt as downloadTask, mt as enqueueExport, ht as enqueueImport, Be as exportExcel, jt as formatTaskPercent, Mt as formatTaskRemainingSeconds, At as getTaskDisplayPercent, Dt as getTaskRemainingSeconds, Ot as getTaskSuccessCount, et as getTasksSnapshot, ce as importableFields, P as joinMultiValues, He as parseImportFile, _t as pauseTask, Et as resetTasks, yt as setImportRowValidation, F as splitMultiValues, $e as subscribeTasks, vt as updateImportRowData, Nt as useTaskDetail, me as validateBooleanField, I as validateDateField, R as validateDateTimeField, H as validateField, z as validateListField, V as validateMultipleChoiceField, pe as validateNumberField, B as validateSingleChoiceField, fe as validateTextField, L as validateTimeField };
|