antd-import-export 1.0.1 → 1.0.2
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 +399 -394
- 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,41 @@ 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
|
-
let t =
|
|
1145
|
+
function At(e) {
|
|
1146
|
+
let t = kt(e);
|
|
1142
1147
|
return t >= 100 ? 100 : Math.trunc(t * 10) / 10;
|
|
1143
1148
|
}
|
|
1144
|
-
function
|
|
1149
|
+
function jt(e) {
|
|
1145
1150
|
return `${(Math.trunc(e * 10) / 10).toFixed(1)}%`;
|
|
1146
1151
|
}
|
|
1147
|
-
function
|
|
1152
|
+
function Mt(e) {
|
|
1148
1153
|
if (e === null) return "计算中...";
|
|
1149
1154
|
let t = Math.ceil(e);
|
|
1150
1155
|
return t < 60 ? `约 ${t} 秒` : `约 ${Math.floor(t / 60)} 分 ${t % 60} 秒`;
|
|
1151
1156
|
}
|
|
1152
1157
|
// src/react/useTaskDetail.ts
|
|
1153
|
-
function
|
|
1154
|
-
let t = i(() => e ?
|
|
1155
|
-
return l(
|
|
1158
|
+
function Nt(e) {
|
|
1159
|
+
let t = i(() => e ? et().find((t) => t.id === e) : void 0, [e]);
|
|
1160
|
+
return l($e, t);
|
|
1156
1161
|
}
|
|
1157
1162
|
// src/components/BatchExportButton.tsx
|
|
1158
|
-
var
|
|
1163
|
+
var Pt = ({ title: t, fieldSchemas: n, selectedRows: r, disabled: i }) => {
|
|
1159
1164
|
let [a, o] = c(!1);
|
|
1160
|
-
return /* @__PURE__ */
|
|
1165
|
+
return /* @__PURE__ */ O(h, {
|
|
1161
1166
|
type: "default",
|
|
1162
|
-
icon: /* @__PURE__ */
|
|
1167
|
+
icon: /* @__PURE__ */ O(d, {}),
|
|
1163
1168
|
loading: a,
|
|
1164
1169
|
disabled: i ?? r.length === 0,
|
|
1165
1170
|
onClick: async () => {
|
|
1166
1171
|
if (r.length === 0) return;
|
|
1167
1172
|
if (r.length > 2e4) {
|
|
1168
|
-
E.error(`导出数据 ${r.length.toLocaleString()} 条,超过上限 ${
|
|
1173
|
+
E.error(`导出数据 ${r.length.toLocaleString()} 条,超过上限 ${he} 条,请分批导出`);
|
|
1169
1174
|
return;
|
|
1170
1175
|
}
|
|
1171
1176
|
let i = `${t}_${e().format("YYYYMMDDHHmmss")}`;
|
|
@@ -1182,7 +1187,7 @@ var Mt = ({ title: t, fieldSchemas: n, selectedRows: r, disabled: i }) => {
|
|
|
1182
1187
|
});
|
|
1183
1188
|
};
|
|
1184
1189
|
// src/components/ExportTaskModal.tsx
|
|
1185
|
-
function
|
|
1190
|
+
function Ft(e) {
|
|
1186
1191
|
if (e.canceling) return "正在取消";
|
|
1187
1192
|
if (e.finalizing) return "正在生成文件";
|
|
1188
1193
|
switch (e.status) {
|
|
@@ -1193,26 +1198,26 @@ function Nt(e) {
|
|
|
1193
1198
|
case "canceled": return "已取消";
|
|
1194
1199
|
}
|
|
1195
1200
|
}
|
|
1196
|
-
function
|
|
1201
|
+
function It(e) {
|
|
1197
1202
|
if (e.canceling) return "warning";
|
|
1198
1203
|
if (e.finalizing) return "processing";
|
|
1199
1204
|
}
|
|
1200
|
-
function
|
|
1205
|
+
function Lt(e) {
|
|
1201
1206
|
switch (e.status) {
|
|
1202
1207
|
case "failed": return "exception";
|
|
1203
1208
|
case "completed": return "success";
|
|
1204
1209
|
default: return "normal";
|
|
1205
1210
|
}
|
|
1206
1211
|
}
|
|
1207
|
-
var
|
|
1208
|
-
let n =
|
|
1212
|
+
var Rt = ({ taskId: e, onClose: t }) => {
|
|
1213
|
+
let n = Nt(e), { message: r } = m.useApp();
|
|
1209
1214
|
if (!n) return null;
|
|
1210
|
-
let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a =
|
|
1211
|
-
|
|
1215
|
+
let i = n.status === "completed" || n.status === "failed" || n.status === "canceled", a = At(n), o = () => {
|
|
1216
|
+
Ct(n.id), t();
|
|
1212
1217
|
}, s = () => {
|
|
1213
|
-
|
|
1214
|
-
}, c =
|
|
1215
|
-
return /* @__PURE__ */
|
|
1218
|
+
Tt(n.id) || r.error("文件不存在");
|
|
1219
|
+
}, c = Ft(n);
|
|
1220
|
+
return /* @__PURE__ */ O(y, {
|
|
1216
1221
|
title: "导出任务",
|
|
1217
1222
|
open: !0,
|
|
1218
1223
|
maskClosable: !1,
|
|
@@ -1221,90 +1226,90 @@ var It = ({ taskId: e, onClose: t }) => {
|
|
|
1221
1226
|
onCancel: () => {
|
|
1222
1227
|
i && o();
|
|
1223
1228
|
},
|
|
1224
|
-
footer: i ? /* @__PURE__ */
|
|
1229
|
+
footer: i ? /* @__PURE__ */ k(g, {
|
|
1225
1230
|
justify: "flex-end",
|
|
1226
1231
|
gap: 8,
|
|
1227
|
-
children: [n.status === "completed" ? /* @__PURE__ */
|
|
1232
|
+
children: [n.status === "completed" ? /* @__PURE__ */ O(h, {
|
|
1228
1233
|
onClick: s,
|
|
1229
1234
|
children: "重新下载"
|
|
1230
|
-
}) : null, /* @__PURE__ */
|
|
1235
|
+
}) : null, /* @__PURE__ */ O(h, {
|
|
1231
1236
|
type: "primary",
|
|
1232
1237
|
onClick: o,
|
|
1233
1238
|
children: "关闭"
|
|
1234
1239
|
})]
|
|
1235
|
-
}) : /* @__PURE__ */
|
|
1240
|
+
}) : /* @__PURE__ */ O(g, {
|
|
1236
1241
|
justify: "flex-end",
|
|
1237
|
-
children: /* @__PURE__ */
|
|
1242
|
+
children: /* @__PURE__ */ O(h, {
|
|
1238
1243
|
danger: !0,
|
|
1239
1244
|
loading: n.canceling,
|
|
1240
1245
|
disabled: n.canceling || n.finalizing,
|
|
1241
|
-
onClick: () =>
|
|
1242
|
-
children: n.canceling ? "取消中" :
|
|
1246
|
+
onClick: () => St(n.id),
|
|
1247
|
+
children: n.canceling ? "取消中" : "取消任务"
|
|
1243
1248
|
})
|
|
1244
1249
|
}),
|
|
1245
|
-
children: /* @__PURE__ */
|
|
1250
|
+
children: /* @__PURE__ */ k(g, {
|
|
1246
1251
|
vertical: !0,
|
|
1247
1252
|
gap: 12,
|
|
1248
1253
|
children: [
|
|
1249
|
-
/* @__PURE__ */
|
|
1254
|
+
/* @__PURE__ */ k(g, {
|
|
1250
1255
|
justify: "space-between",
|
|
1251
1256
|
align: "center",
|
|
1252
1257
|
gap: 12,
|
|
1253
|
-
children: [/* @__PURE__ */
|
|
1258
|
+
children: [/* @__PURE__ */ O(T.Text, {
|
|
1254
1259
|
strong: !0,
|
|
1255
1260
|
ellipsis: !0,
|
|
1256
1261
|
children: n.title
|
|
1257
|
-
}), /* @__PURE__ */
|
|
1258
|
-
color:
|
|
1262
|
+
}), /* @__PURE__ */ O(w, {
|
|
1263
|
+
color: It(n),
|
|
1259
1264
|
children: c
|
|
1260
1265
|
})]
|
|
1261
1266
|
}),
|
|
1262
|
-
/* @__PURE__ */
|
|
1267
|
+
/* @__PURE__ */ O(x, {
|
|
1263
1268
|
percent: a,
|
|
1264
|
-
format: () =>
|
|
1265
|
-
status:
|
|
1269
|
+
format: () => jt(a),
|
|
1270
|
+
status: Lt(n),
|
|
1266
1271
|
size: "small"
|
|
1267
1272
|
}),
|
|
1268
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ k(g, {
|
|
1269
1274
|
justify: "space-between",
|
|
1270
1275
|
children: [
|
|
1271
|
-
/* @__PURE__ */
|
|
1276
|
+
/* @__PURE__ */ k(T.Text, {
|
|
1272
1277
|
type: "secondary",
|
|
1273
1278
|
children: [
|
|
1274
1279
|
"已导出 ",
|
|
1275
|
-
|
|
1280
|
+
Ot(n).toLocaleString(),
|
|
1276
1281
|
" / 总数 ",
|
|
1277
1282
|
n.total > 0 ? n.total.toLocaleString() : "--"
|
|
1278
1283
|
]
|
|
1279
1284
|
}),
|
|
1280
|
-
n.finalizing ? /* @__PURE__ */
|
|
1285
|
+
n.finalizing ? /* @__PURE__ */ O(T.Text, {
|
|
1281
1286
|
type: "secondary",
|
|
1282
1287
|
children: "正在生成文件..."
|
|
1283
1288
|
}) : null,
|
|
1284
|
-
n.canceling ? /* @__PURE__ */
|
|
1289
|
+
n.canceling ? /* @__PURE__ */ O(T.Text, {
|
|
1285
1290
|
type: "secondary",
|
|
1286
1291
|
children: "正在取消..."
|
|
1287
1292
|
}) : null
|
|
1288
1293
|
]
|
|
1289
1294
|
}),
|
|
1290
|
-
n.errorMessage ? /* @__PURE__ */
|
|
1295
|
+
n.errorMessage ? /* @__PURE__ */ O(T.Text, {
|
|
1291
1296
|
type: "danger",
|
|
1292
1297
|
children: n.errorMessage
|
|
1293
1298
|
}) : null
|
|
1294
1299
|
]
|
|
1295
1300
|
})
|
|
1296
1301
|
});
|
|
1297
|
-
},
|
|
1302
|
+
}, zt = ({ title: t, buttonText: n = "导出", fieldSchemas: r, filters: i, totalCount: o, disabled: l, fetchPage: u }) => {
|
|
1298
1303
|
let { message: f } = m.useApp(), [p, g] = c(), _ = s(void 0);
|
|
1299
1304
|
return a(() => {
|
|
1300
1305
|
_.current = p;
|
|
1301
1306
|
}, [p]), a(() => () => {
|
|
1302
|
-
_.current &&
|
|
1303
|
-
}, []), /* @__PURE__ */
|
|
1307
|
+
_.current && Ct(_.current);
|
|
1308
|
+
}, []), /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(te, {
|
|
1304
1309
|
title: "导出 Excel",
|
|
1305
|
-
children: /* @__PURE__ */
|
|
1310
|
+
children: /* @__PURE__ */ O(h, {
|
|
1306
1311
|
type: "default",
|
|
1307
|
-
icon: /* @__PURE__ */
|
|
1312
|
+
icon: /* @__PURE__ */ O(d, {}),
|
|
1308
1313
|
disabled: l,
|
|
1309
1314
|
onClick: () => {
|
|
1310
1315
|
if (o === 0) {
|
|
@@ -1312,11 +1317,11 @@ var It = ({ taskId: e, onClose: t }) => {
|
|
|
1312
1317
|
return;
|
|
1313
1318
|
}
|
|
1314
1319
|
if (o > 2e4) {
|
|
1315
|
-
f.error(`导出数据共 ${o.toLocaleString()} 条, 超过上限 ${
|
|
1320
|
+
f.error(`导出数据共 ${o.toLocaleString()} 条, 超过上限 ${he} 条, 请缩小筛选范围后分批导出`);
|
|
1316
1321
|
return;
|
|
1317
1322
|
}
|
|
1318
1323
|
let n = `${t}_${e().format("YYYYMMDDHHmmss")}`;
|
|
1319
|
-
g(
|
|
1324
|
+
g(mt({
|
|
1320
1325
|
title: `${t}导出`,
|
|
1321
1326
|
fileName: n,
|
|
1322
1327
|
fieldSchemas: r,
|
|
@@ -1328,17 +1333,17 @@ var It = ({ taskId: e, onClose: t }) => {
|
|
|
1328
1333
|
},
|
|
1329
1334
|
children: n
|
|
1330
1335
|
})
|
|
1331
|
-
}), p ? /* @__PURE__ */
|
|
1336
|
+
}), p ? /* @__PURE__ */ O(Rt, {
|
|
1332
1337
|
taskId: p,
|
|
1333
1338
|
onClose: () => g(void 0)
|
|
1334
1339
|
}) : null] });
|
|
1335
|
-
}, { Text:
|
|
1340
|
+
}, { Text: Bt } = T, Vt = ({ missingTitles: e, headerMessages: t }) => /* @__PURE__ */ k(g, {
|
|
1336
1341
|
vertical: !0,
|
|
1337
1342
|
gap: 4,
|
|
1338
|
-
children: [e.length > 0 ? /* @__PURE__ */
|
|
1343
|
+
children: [e.length > 0 ? /* @__PURE__ */ O(Bt, { children: `缺少必填列: ${e.join(", ")}` }) : null, t.map((e, t) => /* @__PURE__ */ O(Bt, { children: e }, t))]
|
|
1339
1344
|
});
|
|
1340
1345
|
// src/react/useDebouncedValue.ts
|
|
1341
|
-
function
|
|
1346
|
+
function Ht(e, t) {
|
|
1342
1347
|
let [n, r] = c(e);
|
|
1343
1348
|
return a(() => {
|
|
1344
1349
|
let n = setTimeout(() => r(e), t);
|
|
@@ -1346,7 +1351,7 @@ function Bt(e, t) {
|
|
|
1346
1351
|
}, [e, t]), n;
|
|
1347
1352
|
}
|
|
1348
1353
|
// src/react/useThrottledValue.ts
|
|
1349
|
-
function
|
|
1354
|
+
function Ut(e, t) {
|
|
1350
1355
|
let [n, r] = c(e), i = s(e), o = s(0), l = s(null);
|
|
1351
1356
|
return i.current = e, a(() => {
|
|
1352
1357
|
let n = Date.now() - o.current;
|
|
@@ -1358,12 +1363,12 @@ function Vt(e, t) {
|
|
|
1358
1363
|
}, []), n;
|
|
1359
1364
|
}
|
|
1360
1365
|
// src/components/ImportPreviewModal.tsx
|
|
1361
|
-
function
|
|
1362
|
-
return e == null || e === "" ? "" : Array.isArray(e) ?
|
|
1366
|
+
function Wt(e) {
|
|
1367
|
+
return e == null || e === "" ? "" : Array.isArray(e) ? P(e) : String(e);
|
|
1363
1368
|
}
|
|
1364
|
-
var
|
|
1369
|
+
var Gt = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
1365
1370
|
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__ */
|
|
1371
|
+
if (o && !n) return e.type === "boolean" ? /* @__PURE__ */ O(S, {
|
|
1367
1372
|
autoFocus: !0,
|
|
1368
1373
|
open: !0,
|
|
1369
1374
|
size: "small",
|
|
@@ -1380,7 +1385,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1380
1385
|
r(e), i(e), s(!1);
|
|
1381
1386
|
},
|
|
1382
1387
|
onBlur: () => s(!1)
|
|
1383
|
-
}) : e.type === "single_choice" ? /* @__PURE__ */
|
|
1388
|
+
}) : e.type === "single_choice" ? /* @__PURE__ */ O(S, {
|
|
1384
1389
|
autoFocus: !0,
|
|
1385
1390
|
open: !0,
|
|
1386
1391
|
size: "small",
|
|
@@ -1394,7 +1399,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1394
1399
|
r(e), i(e), s(!1);
|
|
1395
1400
|
},
|
|
1396
1401
|
onBlur: () => s(!1)
|
|
1397
|
-
}) : e.type === "multiple_choice" ? /* @__PURE__ */
|
|
1402
|
+
}) : e.type === "multiple_choice" ? /* @__PURE__ */ O(S, {
|
|
1398
1403
|
autoFocus: !0,
|
|
1399
1404
|
open: !0,
|
|
1400
1405
|
mode: "multiple",
|
|
@@ -1409,7 +1414,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1409
1414
|
onBlur: () => {
|
|
1410
1415
|
s(!1), i(d);
|
|
1411
1416
|
}
|
|
1412
|
-
}) : e.type === "number" ? /* @__PURE__ */
|
|
1417
|
+
}) : e.type === "number" ? /* @__PURE__ */ O(v, {
|
|
1413
1418
|
autoFocus: !0,
|
|
1414
1419
|
size: "small",
|
|
1415
1420
|
style: { width: "100%" },
|
|
@@ -1421,7 +1426,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1421
1426
|
onPressEnter: () => {
|
|
1422
1427
|
s(!1), i(d);
|
|
1423
1428
|
}
|
|
1424
|
-
}) : /* @__PURE__ */
|
|
1429
|
+
}) : /* @__PURE__ */ O(_, {
|
|
1425
1430
|
autoFocus: !0,
|
|
1426
1431
|
size: "small",
|
|
1427
1432
|
value: typeof d == "string" ? d : "",
|
|
@@ -1434,8 +1439,8 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1434
1439
|
s(!1), i(d);
|
|
1435
1440
|
}
|
|
1436
1441
|
});
|
|
1437
|
-
let f =
|
|
1438
|
-
return /* @__PURE__ */
|
|
1442
|
+
let f = Wt(d);
|
|
1443
|
+
return /* @__PURE__ */ O("div", {
|
|
1439
1444
|
title: f || void 0,
|
|
1440
1445
|
style: {
|
|
1441
1446
|
height: 24,
|
|
@@ -1456,7 +1461,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1456
1461
|
onClick: () => {
|
|
1457
1462
|
n || s(!0);
|
|
1458
1463
|
},
|
|
1459
|
-
children: /* @__PURE__ */
|
|
1464
|
+
children: /* @__PURE__ */ O("span", {
|
|
1460
1465
|
style: {
|
|
1461
1466
|
minWidth: 0,
|
|
1462
1467
|
overflow: "hidden",
|
|
@@ -1467,7 +1472,7 @@ var Ut = ({ field: e, record: t, disabled: n, onChange: r, onSave: i }) => {
|
|
|
1467
1472
|
})
|
|
1468
1473
|
});
|
|
1469
1474
|
};
|
|
1470
|
-
function
|
|
1475
|
+
function Kt(e) {
|
|
1471
1476
|
if (e.canceling) return {
|
|
1472
1477
|
label: "正在取消",
|
|
1473
1478
|
color: "warning"
|
|
@@ -1495,21 +1500,21 @@ function Wt(e) {
|
|
|
1495
1500
|
};
|
|
1496
1501
|
}
|
|
1497
1502
|
}
|
|
1498
|
-
function
|
|
1503
|
+
function qt(e, t) {
|
|
1499
1504
|
if (e.canceling) return "正在取消...";
|
|
1500
1505
|
switch (e.status) {
|
|
1501
|
-
case "running": return `预计剩余 ${
|
|
1506
|
+
case "running": return `预计剩余 ${Mt(t)}`;
|
|
1502
1507
|
default: return null;
|
|
1503
1508
|
}
|
|
1504
1509
|
}
|
|
1505
|
-
function
|
|
1510
|
+
function Jt(e) {
|
|
1506
1511
|
switch (e.status) {
|
|
1507
1512
|
case "failed": return "exception";
|
|
1508
1513
|
case "completed": return "success";
|
|
1509
1514
|
default: return "normal";
|
|
1510
1515
|
}
|
|
1511
1516
|
}
|
|
1512
|
-
var
|
|
1517
|
+
var Yt = {
|
|
1513
1518
|
valid: {
|
|
1514
1519
|
label: "已校验",
|
|
1515
1520
|
color: "success"
|
|
@@ -1518,7 +1523,7 @@ var qt = {
|
|
|
1518
1523
|
label: "校验失败",
|
|
1519
1524
|
color: "error"
|
|
1520
1525
|
}
|
|
1521
|
-
},
|
|
1526
|
+
}, Xt = {
|
|
1522
1527
|
pending: {
|
|
1523
1528
|
label: "待导入",
|
|
1524
1529
|
color: "default"
|
|
@@ -1540,10 +1545,10 @@ var qt = {
|
|
|
1540
1545
|
color: "warning"
|
|
1541
1546
|
}
|
|
1542
1547
|
};
|
|
1543
|
-
function
|
|
1548
|
+
function Zt(e) {
|
|
1544
1549
|
return Object.keys(e.errors).length > 0 ? "invalid" : "valid";
|
|
1545
1550
|
}
|
|
1546
|
-
function
|
|
1551
|
+
function Qt(e, t, n) {
|
|
1547
1552
|
if (!t || e.taskIndex === void 0) return "pending";
|
|
1548
1553
|
switch (n?.rowStates?.[e.taskIndex]?.status) {
|
|
1549
1554
|
case "running": return "running";
|
|
@@ -1553,19 +1558,19 @@ function Xt(e, t, n) {
|
|
|
1553
1558
|
default: return "pending";
|
|
1554
1559
|
}
|
|
1555
1560
|
}
|
|
1556
|
-
var
|
|
1557
|
-
let [m, v] = c("all"), [C, te] = c("all"), [E, ne] = c(""),
|
|
1561
|
+
var $t = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys: a, onChangeCell: s, onSaveCell: l, onDelete: d, onConfirm: f, onClose: p }) => {
|
|
1562
|
+
let [m, v] = c("all"), [C, te] = c("all"), [E, ne] = c(""), re = Ht(E, 300), A = () => {
|
|
1558
1563
|
v("all"), te("all"), ne("");
|
|
1559
|
-
},
|
|
1560
|
-
|
|
1561
|
-
let
|
|
1564
|
+
}, j = Nt(i), [M, ie] = c(), ae = o(() => new Set(a), [a]), oe = n.filter((e) => ae.has(e.key));
|
|
1565
|
+
j && j !== M && ie(j);
|
|
1566
|
+
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
1567
|
if (!i) return !0;
|
|
1563
|
-
let t =
|
|
1564
|
-
return
|
|
1565
|
-
},
|
|
1568
|
+
let t = P(e)?.status;
|
|
1569
|
+
return F && (t === "queued" || t === "failed") ? !0 : F && e.taskIndex === void 0 && Object.keys(e.errors).length > 0;
|
|
1570
|
+
}, fe = (e) => !i || j?.status === "paused" && P(e)?.status === "queued", pe = o(() => ["valid", "invalid"].map((e) => ({
|
|
1566
1571
|
value: e,
|
|
1567
|
-
label:
|
|
1568
|
-
})), []),
|
|
1572
|
+
label: Yt[e].label
|
|
1573
|
+
})), []), me = o(() => [
|
|
1569
1574
|
"pending",
|
|
1570
1575
|
"running",
|
|
1571
1576
|
"completed",
|
|
@@ -1573,33 +1578,33 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1573
1578
|
"canceled"
|
|
1574
1579
|
].map((e) => ({
|
|
1575
1580
|
value: e,
|
|
1576
|
-
label:
|
|
1577
|
-
})), []),
|
|
1578
|
-
if (!
|
|
1579
|
-
let e =
|
|
1580
|
-
return r.filter((t) =>
|
|
1581
|
+
label: Xt[e].label
|
|
1582
|
+
})), []), 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(() => {
|
|
1583
|
+
if (!B) return r;
|
|
1584
|
+
let e = L.trim().toLowerCase();
|
|
1585
|
+
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
1586
|
}, [
|
|
1582
1587
|
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
1588
|
R,
|
|
1590
|
-
|
|
1591
|
-
|
|
1589
|
+
L,
|
|
1590
|
+
B
|
|
1591
|
+
]), 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, [
|
|
1592
|
+
U,
|
|
1593
|
+
z,
|
|
1594
|
+
V,
|
|
1595
|
+
ge,
|
|
1596
|
+
N,
|
|
1592
1597
|
i
|
|
1593
|
-
]),
|
|
1598
|
+
]), ve = (e) => {
|
|
1594
1599
|
let t = Object.entries(e.errors);
|
|
1595
|
-
return /* @__PURE__ */
|
|
1600
|
+
return /* @__PURE__ */ O(g, {
|
|
1596
1601
|
vertical: !0,
|
|
1597
1602
|
gap: 4,
|
|
1598
1603
|
style: { maxWidth: 320 },
|
|
1599
1604
|
children: t.map(([e, t]) => {
|
|
1600
1605
|
let r = n.find((t) => t.key === e)?.title ?? e;
|
|
1601
|
-
return /* @__PURE__ */
|
|
1602
|
-
/* @__PURE__ */
|
|
1606
|
+
return /* @__PURE__ */ k(T.Text, { children: [
|
|
1607
|
+
/* @__PURE__ */ O(T.Text, {
|
|
1603
1608
|
strong: !0,
|
|
1604
1609
|
children: r
|
|
1605
1610
|
}),
|
|
@@ -1608,45 +1613,45 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1608
1613
|
] }, e);
|
|
1609
1614
|
})
|
|
1610
1615
|
});
|
|
1611
|
-
},
|
|
1612
|
-
let t =
|
|
1613
|
-
return t === "invalid" ? /* @__PURE__ */
|
|
1616
|
+
}, ye = (e) => {
|
|
1617
|
+
let t = Zt(e), n = Yt[t];
|
|
1618
|
+
return t === "invalid" ? /* @__PURE__ */ O(b, {
|
|
1614
1619
|
trigger: "hover",
|
|
1615
1620
|
placement: "topRight",
|
|
1616
1621
|
title: "错误信息",
|
|
1617
|
-
content:
|
|
1618
|
-
children: /* @__PURE__ */
|
|
1622
|
+
content: ve(e),
|
|
1623
|
+
children: /* @__PURE__ */ O(w, {
|
|
1619
1624
|
color: n.color,
|
|
1620
1625
|
children: n.label
|
|
1621
1626
|
})
|
|
1622
|
-
}) : /* @__PURE__ */
|
|
1627
|
+
}) : /* @__PURE__ */ O(w, {
|
|
1623
1628
|
color: n.color,
|
|
1624
1629
|
children: n.label
|
|
1625
1630
|
});
|
|
1626
|
-
},
|
|
1627
|
-
let t =
|
|
1628
|
-
if (r.length === 0) return /* @__PURE__ */
|
|
1631
|
+
}, be = (e) => {
|
|
1632
|
+
let t = P(e), r = t?.fieldErrors ?? [], i = t?.message;
|
|
1633
|
+
if (r.length === 0) return /* @__PURE__ */ O(T.Text, { children: i ?? "导入失败" });
|
|
1629
1634
|
let a = /* @__PURE__ */ new Map();
|
|
1630
1635
|
r.forEach((e) => {
|
|
1631
1636
|
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
1637
|
o.push(r), a.set(i, o);
|
|
1633
1638
|
});
|
|
1634
1639
|
let o = [...a.entries()], s = o.slice(0, 3), c = o.length - s.length;
|
|
1635
|
-
return /* @__PURE__ */
|
|
1640
|
+
return /* @__PURE__ */ k(g, {
|
|
1636
1641
|
vertical: !0,
|
|
1637
1642
|
gap: 8,
|
|
1638
1643
|
style: { maxWidth: 360 },
|
|
1639
1644
|
children: [
|
|
1640
|
-
i ? /* @__PURE__ */
|
|
1641
|
-
s.map(([e, t]) => /* @__PURE__ */
|
|
1645
|
+
i ? /* @__PURE__ */ O(T.Text, { children: i }) : null,
|
|
1646
|
+
s.map(([e, t]) => /* @__PURE__ */ k(g, {
|
|
1642
1647
|
vertical: !0,
|
|
1643
1648
|
gap: 2,
|
|
1644
|
-
children: [/* @__PURE__ */
|
|
1649
|
+
children: [/* @__PURE__ */ O(T.Text, {
|
|
1645
1650
|
strong: !0,
|
|
1646
1651
|
children: e
|
|
1647
|
-
}), t.map((e, t) => /* @__PURE__ */
|
|
1652
|
+
}), t.map((e, t) => /* @__PURE__ */ k(T.Text, { children: ["• ", e] }, t))]
|
|
1648
1653
|
}, e)),
|
|
1649
|
-
c > 0 ? /* @__PURE__ */
|
|
1654
|
+
c > 0 ? /* @__PURE__ */ k(T.Text, {
|
|
1650
1655
|
type: "secondary",
|
|
1651
1656
|
children: [
|
|
1652
1657
|
"还有 ",
|
|
@@ -1656,36 +1661,36 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1656
1661
|
}) : null
|
|
1657
1662
|
]
|
|
1658
1663
|
});
|
|
1659
|
-
},
|
|
1660
|
-
let t =
|
|
1664
|
+
}, xe = (e) => {
|
|
1665
|
+
let t = Qt(e, i, N), n = Xt[t];
|
|
1661
1666
|
if (t === "failed") {
|
|
1662
|
-
let t =
|
|
1663
|
-
return /* @__PURE__ */
|
|
1667
|
+
let t = P(e), r = (t?.fieldErrors?.length ?? 0) + +!!t?.message, i = r > 0 ? `导入失败(${r})` : n.label;
|
|
1668
|
+
return /* @__PURE__ */ O(b, {
|
|
1664
1669
|
trigger: "hover",
|
|
1665
1670
|
placement: "topRight",
|
|
1666
1671
|
title: "错误信息",
|
|
1667
|
-
content:
|
|
1668
|
-
children: /* @__PURE__ */
|
|
1672
|
+
content: be(e),
|
|
1673
|
+
children: /* @__PURE__ */ O(w, {
|
|
1669
1674
|
color: n.color,
|
|
1670
1675
|
children: i
|
|
1671
1676
|
})
|
|
1672
1677
|
});
|
|
1673
1678
|
}
|
|
1674
|
-
return /* @__PURE__ */
|
|
1679
|
+
return /* @__PURE__ */ O(w, {
|
|
1675
1680
|
color: n.color,
|
|
1676
1681
|
children: n.label
|
|
1677
1682
|
});
|
|
1678
|
-
},
|
|
1683
|
+
}, Se = (e) => /* @__PURE__ */ O(h, {
|
|
1679
1684
|
type: "primary",
|
|
1680
1685
|
danger: !0,
|
|
1681
1686
|
size: "small",
|
|
1682
|
-
disabled: !
|
|
1683
|
-
icon: /* @__PURE__ */
|
|
1687
|
+
disabled: !fe(e),
|
|
1688
|
+
icon: /* @__PURE__ */ O(u, {}),
|
|
1684
1689
|
onClick: () => {
|
|
1685
|
-
d(e),
|
|
1690
|
+
d(e), j && e.taskIndex !== void 0 && bt(j.id, [e.taskIndex]);
|
|
1686
1691
|
},
|
|
1687
1692
|
children: "删除"
|
|
1688
|
-
}),
|
|
1693
|
+
}), Ce = [
|
|
1689
1694
|
{
|
|
1690
1695
|
key: "rowNumber",
|
|
1691
1696
|
title: "行号",
|
|
@@ -1693,15 +1698,15 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1693
1698
|
width: 60,
|
|
1694
1699
|
fixed: "left"
|
|
1695
1700
|
},
|
|
1696
|
-
...
|
|
1701
|
+
...oe.map((e) => ({
|
|
1697
1702
|
key: e.key,
|
|
1698
1703
|
title: e.title,
|
|
1699
1704
|
dataIndex: e.key,
|
|
1700
1705
|
width: 160,
|
|
1701
|
-
render: (t, n) => /* @__PURE__ */
|
|
1706
|
+
render: (t, n) => /* @__PURE__ */ O(Gt, {
|
|
1702
1707
|
field: e,
|
|
1703
1708
|
record: n,
|
|
1704
|
-
disabled: !
|
|
1709
|
+
disabled: !de(n),
|
|
1705
1710
|
onChange: (t) => s(n, e, t),
|
|
1706
1711
|
onSave: (t) => l(n, e, t)
|
|
1707
1712
|
})
|
|
@@ -1711,24 +1716,24 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1711
1716
|
title: "数据状态",
|
|
1712
1717
|
width: 100,
|
|
1713
1718
|
fixed: "right",
|
|
1714
|
-
render: (e, t) =>
|
|
1719
|
+
render: (e, t) => ye(t)
|
|
1715
1720
|
},
|
|
1716
1721
|
{
|
|
1717
1722
|
key: "importStatus",
|
|
1718
1723
|
title: "导入状态",
|
|
1719
1724
|
width: 110,
|
|
1720
1725
|
fixed: "right",
|
|
1721
|
-
render: (e, t) =>
|
|
1726
|
+
render: (e, t) => xe(t)
|
|
1722
1727
|
},
|
|
1723
1728
|
{
|
|
1724
1729
|
key: "action",
|
|
1725
1730
|
title: "操作",
|
|
1726
1731
|
width: 80,
|
|
1727
1732
|
fixed: "right",
|
|
1728
|
-
render: (e, t) =>
|
|
1733
|
+
render: (e, t) => Se(t)
|
|
1729
1734
|
}
|
|
1730
|
-
],
|
|
1731
|
-
return /* @__PURE__ */ D
|
|
1735
|
+
], 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;
|
|
1736
|
+
return /* @__PURE__ */ O(D, { children: /* @__PURE__ */ k(y, {
|
|
1732
1737
|
title: i ? `${t}导入` : `${t}导入预览`,
|
|
1733
1738
|
open: e,
|
|
1734
1739
|
width: "min(1400px, 96vw)",
|
|
@@ -1736,68 +1741,68 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1736
1741
|
closable: !1,
|
|
1737
1742
|
keyboard: !1,
|
|
1738
1743
|
onCancel: () => {
|
|
1739
|
-
|
|
1744
|
+
ce || p();
|
|
1740
1745
|
},
|
|
1741
1746
|
footer: (() => {
|
|
1742
|
-
if (!i) return /* @__PURE__ */
|
|
1747
|
+
if (!i) return /* @__PURE__ */ k(g, {
|
|
1743
1748
|
justify: "space-between",
|
|
1744
1749
|
align: "center",
|
|
1745
1750
|
gap: 8,
|
|
1746
1751
|
wrap: !0,
|
|
1747
|
-
children: [/* @__PURE__ */
|
|
1752
|
+
children: [/* @__PURE__ */ O("span", { children: r.length > 0 && Oe > 0 ? /* @__PURE__ */ O(T.Text, {
|
|
1748
1753
|
type: ke ? "danger" : "secondary",
|
|
1749
|
-
children: ke ? "全部行校验失败, 请先修正后再导入" : `有 ${
|
|
1750
|
-
}) : null }), /* @__PURE__ */
|
|
1754
|
+
children: ke ? "全部行校验失败, 请先修正后再导入" : `有 ${Oe} 行校验失败, 不会导入`
|
|
1755
|
+
}) : null }), /* @__PURE__ */ k(g, {
|
|
1751
1756
|
gap: 8,
|
|
1752
|
-
children: [/* @__PURE__ */
|
|
1757
|
+
children: [/* @__PURE__ */ O(h, {
|
|
1753
1758
|
onClick: p,
|
|
1754
1759
|
children: "取消"
|
|
1755
|
-
}), /* @__PURE__ */
|
|
1760
|
+
}), /* @__PURE__ */ O(h, {
|
|
1756
1761
|
type: "primary",
|
|
1757
1762
|
disabled: r.length === 0 || ke,
|
|
1758
1763
|
onClick: () => {
|
|
1759
|
-
|
|
1764
|
+
A(), f();
|
|
1760
1765
|
},
|
|
1761
1766
|
children: "开始导入"
|
|
1762
1767
|
})]
|
|
1763
1768
|
})]
|
|
1764
1769
|
});
|
|
1765
|
-
if (!
|
|
1770
|
+
if (!j || !N) return /* @__PURE__ */ O(g, {
|
|
1766
1771
|
justify: "flex-end",
|
|
1767
|
-
children: /* @__PURE__ */
|
|
1772
|
+
children: /* @__PURE__ */ O(h, {
|
|
1768
1773
|
onClick: p,
|
|
1769
1774
|
children: "关闭"
|
|
1770
1775
|
})
|
|
1771
1776
|
});
|
|
1772
|
-
let e =
|
|
1773
|
-
return /* @__PURE__ */
|
|
1777
|
+
let e = N.status === "running", t = N.status === "paused";
|
|
1778
|
+
return /* @__PURE__ */ k(g, {
|
|
1774
1779
|
justify: "flex-end",
|
|
1775
1780
|
gap: 8,
|
|
1776
1781
|
children: [
|
|
1777
|
-
e ? /* @__PURE__ */
|
|
1782
|
+
e ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(h, {
|
|
1778
1783
|
danger: !0,
|
|
1779
|
-
loading:
|
|
1780
|
-
disabled:
|
|
1781
|
-
onClick: () =>
|
|
1782
|
-
children:
|
|
1783
|
-
}), /* @__PURE__ */
|
|
1784
|
-
loading:
|
|
1785
|
-
disabled:
|
|
1786
|
-
onClick: () =>
|
|
1784
|
+
loading: N.canceling,
|
|
1785
|
+
disabled: N.canceling,
|
|
1786
|
+
onClick: () => St(N.id),
|
|
1787
|
+
children: N.canceling ? "取消中" : "取消任务"
|
|
1788
|
+
}), /* @__PURE__ */ O(h, {
|
|
1789
|
+
loading: N.pausing,
|
|
1790
|
+
disabled: N.canceling,
|
|
1791
|
+
onClick: () => _t(N.id),
|
|
1787
1792
|
children: "暂停"
|
|
1788
1793
|
})] }) : null,
|
|
1789
|
-
t ? /* @__PURE__ */
|
|
1794
|
+
t ? /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(h, {
|
|
1790
1795
|
danger: !0,
|
|
1791
|
-
onClick: () =>
|
|
1796
|
+
onClick: () => St(N.id),
|
|
1792
1797
|
children: "取消任务"
|
|
1793
|
-
}), /* @__PURE__ */
|
|
1798
|
+
}), /* @__PURE__ */ O(h, {
|
|
1794
1799
|
type: "primary",
|
|
1795
1800
|
onClick: () => {
|
|
1796
|
-
|
|
1801
|
+
A(), gt(N.id);
|
|
1797
1802
|
},
|
|
1798
1803
|
children: "继续导入"
|
|
1799
1804
|
})] }) : null,
|
|
1800
|
-
!e && !t ? /* @__PURE__ */
|
|
1805
|
+
!e && !t ? /* @__PURE__ */ O(h, {
|
|
1801
1806
|
type: "primary",
|
|
1802
1807
|
onClick: p,
|
|
1803
1808
|
children: "关闭"
|
|
@@ -1806,181 +1811,181 @@ var Zt = ({ open: e, title: t, fieldSchemas: n, rows: r, taskId: i, includedKeys
|
|
|
1806
1811
|
});
|
|
1807
1812
|
})(),
|
|
1808
1813
|
children: [
|
|
1809
|
-
|
|
1814
|
+
N && se ? /* @__PURE__ */ k(g, {
|
|
1810
1815
|
vertical: !0,
|
|
1811
1816
|
gap: 4,
|
|
1812
1817
|
style: { marginBottom: 12 },
|
|
1813
|
-
children: [/* @__PURE__ */
|
|
1818
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1814
1819
|
justify: "space-between",
|
|
1815
1820
|
align: "center",
|
|
1816
|
-
children: [/* @__PURE__ */
|
|
1821
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1817
1822
|
type: "secondary",
|
|
1818
1823
|
children: [
|
|
1819
1824
|
"已导入 ",
|
|
1820
|
-
|
|
1825
|
+
Ot(N).toLocaleString(),
|
|
1821
1826
|
" / 总数 ",
|
|
1822
|
-
|
|
1827
|
+
N.total.toLocaleString()
|
|
1823
1828
|
]
|
|
1824
|
-
}), /* @__PURE__ */
|
|
1829
|
+
}), /* @__PURE__ */ k(g, {
|
|
1825
1830
|
align: "center",
|
|
1826
1831
|
gap: 8,
|
|
1827
1832
|
children: [
|
|
1828
|
-
|
|
1833
|
+
ue ? /* @__PURE__ */ O(T.Text, {
|
|
1829
1834
|
type: "secondary",
|
|
1830
|
-
children:
|
|
1835
|
+
children: ue
|
|
1831
1836
|
}) : null,
|
|
1832
|
-
|
|
1837
|
+
De > 0 ? /* @__PURE__ */ k(w, {
|
|
1833
1838
|
color: "error",
|
|
1834
1839
|
children: [
|
|
1835
1840
|
"校验失败 ",
|
|
1836
|
-
|
|
1841
|
+
De,
|
|
1837
1842
|
" 条"
|
|
1838
1843
|
]
|
|
1839
1844
|
}) : null,
|
|
1840
|
-
|
|
1845
|
+
Ee > 0 ? /* @__PURE__ */ k(w, {
|
|
1841
1846
|
color: "error",
|
|
1842
1847
|
children: [
|
|
1843
1848
|
"导入失败 ",
|
|
1844
|
-
|
|
1849
|
+
Ee,
|
|
1845
1850
|
" 条"
|
|
1846
1851
|
]
|
|
1847
1852
|
}) : null,
|
|
1848
|
-
/* @__PURE__ */
|
|
1849
|
-
color:
|
|
1850
|
-
children:
|
|
1853
|
+
/* @__PURE__ */ O(w, {
|
|
1854
|
+
color: se.color,
|
|
1855
|
+
children: se.label
|
|
1851
1856
|
})
|
|
1852
1857
|
]
|
|
1853
1858
|
})]
|
|
1854
|
-
}), /* @__PURE__ */
|
|
1855
|
-
percent:
|
|
1856
|
-
format: () =>
|
|
1857
|
-
status:
|
|
1859
|
+
}), /* @__PURE__ */ O(x, {
|
|
1860
|
+
percent: Te,
|
|
1861
|
+
format: () => jt(Te),
|
|
1862
|
+
status: Jt(N),
|
|
1858
1863
|
size: "small"
|
|
1859
1864
|
})]
|
|
1860
|
-
}) : i ? null : /* @__PURE__ */
|
|
1865
|
+
}) : i ? null : /* @__PURE__ */ k(g, {
|
|
1861
1866
|
vertical: !0,
|
|
1862
1867
|
gap: 4,
|
|
1863
1868
|
style: { marginBottom: 12 },
|
|
1864
|
-
children: [/* @__PURE__ */
|
|
1869
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1865
1870
|
justify: "space-between",
|
|
1866
1871
|
align: "center",
|
|
1867
|
-
children: [/* @__PURE__ */
|
|
1872
|
+
children: [/* @__PURE__ */ k(T.Text, {
|
|
1868
1873
|
type: "secondary",
|
|
1869
1874
|
children: ["总数 ", r.length.toLocaleString()]
|
|
1870
|
-
}), /* @__PURE__ */
|
|
1875
|
+
}), /* @__PURE__ */ k(g, {
|
|
1871
1876
|
align: "center",
|
|
1872
1877
|
gap: 8,
|
|
1873
|
-
children: [
|
|
1878
|
+
children: [De > 0 ? /* @__PURE__ */ k(w, {
|
|
1874
1879
|
color: "error",
|
|
1875
1880
|
children: [
|
|
1876
1881
|
"校验失败 ",
|
|
1877
|
-
|
|
1882
|
+
De,
|
|
1878
1883
|
" 条"
|
|
1879
1884
|
]
|
|
1880
|
-
}) : null, /* @__PURE__ */
|
|
1885
|
+
}) : null, /* @__PURE__ */ O(w, { children: "待导入" })]
|
|
1881
1886
|
})]
|
|
1882
|
-
}), /* @__PURE__ */
|
|
1887
|
+
}), /* @__PURE__ */ O(x, {
|
|
1883
1888
|
percent: 0,
|
|
1884
1889
|
format: () => "0.0%",
|
|
1885
1890
|
size: "small"
|
|
1886
1891
|
})]
|
|
1887
1892
|
}),
|
|
1888
|
-
/* @__PURE__ */
|
|
1893
|
+
/* @__PURE__ */ k(g, {
|
|
1889
1894
|
justify: "space-between",
|
|
1890
1895
|
align: "center",
|
|
1891
1896
|
gap: 8,
|
|
1892
1897
|
wrap: !0,
|
|
1893
1898
|
style: { marginBottom: 8 },
|
|
1894
|
-
children: [/* @__PURE__ */
|
|
1899
|
+
children: [/* @__PURE__ */ k(g, {
|
|
1895
1900
|
align: "center",
|
|
1896
1901
|
gap: 8,
|
|
1897
1902
|
wrap: !0,
|
|
1898
1903
|
children: [
|
|
1899
|
-
/* @__PURE__ */
|
|
1904
|
+
/* @__PURE__ */ O(_, {
|
|
1900
1905
|
allowClear: !0,
|
|
1901
|
-
disabled:
|
|
1906
|
+
disabled: I,
|
|
1902
1907
|
placeholder: "搜索所有字段",
|
|
1903
|
-
value:
|
|
1908
|
+
value: I ? "" : E,
|
|
1904
1909
|
style: { width: 260 },
|
|
1905
1910
|
onChange: (e) => {
|
|
1906
1911
|
ne(e.target.value);
|
|
1907
1912
|
}
|
|
1908
1913
|
}),
|
|
1909
|
-
/* @__PURE__ */
|
|
1914
|
+
/* @__PURE__ */ O(S, {
|
|
1910
1915
|
allowClear: !0,
|
|
1911
|
-
disabled:
|
|
1916
|
+
disabled: I,
|
|
1912
1917
|
placeholder: "数据状态",
|
|
1913
|
-
value:
|
|
1914
|
-
options:
|
|
1918
|
+
value: R === "all" ? void 0 : R,
|
|
1919
|
+
options: pe,
|
|
1915
1920
|
style: { width: 140 },
|
|
1916
1921
|
onChange: (e) => {
|
|
1917
1922
|
v(e ?? "all");
|
|
1918
1923
|
}
|
|
1919
1924
|
}),
|
|
1920
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ O(S, {
|
|
1921
1926
|
allowClear: !0,
|
|
1922
|
-
disabled:
|
|
1927
|
+
disabled: I,
|
|
1923
1928
|
placeholder: "导入状态",
|
|
1924
|
-
value:
|
|
1925
|
-
options:
|
|
1929
|
+
value: z === "all" ? void 0 : z,
|
|
1930
|
+
options: me,
|
|
1926
1931
|
style: { width: 140 },
|
|
1927
1932
|
onChange: (e) => {
|
|
1928
1933
|
te(e ?? "all");
|
|
1929
1934
|
}
|
|
1930
1935
|
})
|
|
1931
1936
|
]
|
|
1932
|
-
}),
|
|
1937
|
+
}), H ? /* @__PURE__ */ k(T.Text, {
|
|
1933
1938
|
type: "secondary",
|
|
1934
1939
|
children: [
|
|
1935
1940
|
"筛选出 ",
|
|
1936
|
-
|
|
1941
|
+
_e.length,
|
|
1937
1942
|
" 条"
|
|
1938
1943
|
]
|
|
1939
1944
|
}) : null]
|
|
1940
1945
|
}),
|
|
1941
|
-
/* @__PURE__ */
|
|
1946
|
+
/* @__PURE__ */ O(ee, {
|
|
1942
1947
|
rowKey: "key",
|
|
1943
1948
|
size: "middle",
|
|
1944
1949
|
tableLayout: "fixed",
|
|
1945
1950
|
virtual: !0,
|
|
1946
|
-
columns:
|
|
1947
|
-
dataSource:
|
|
1951
|
+
columns: Ce,
|
|
1952
|
+
dataSource: _e,
|
|
1948
1953
|
pagination: !1,
|
|
1949
1954
|
scroll: {
|
|
1950
|
-
x:
|
|
1955
|
+
x: we,
|
|
1951
1956
|
y: 520
|
|
1952
1957
|
},
|
|
1953
|
-
locale: { emptyText:
|
|
1958
|
+
locale: { emptyText: H ? "没有符合条件的行" : void 0 }
|
|
1954
1959
|
})
|
|
1955
1960
|
]
|
|
1956
1961
|
}) });
|
|
1957
|
-
},
|
|
1962
|
+
}, en = "缺少列: ", tn = [
|
|
1958
1963
|
/期望为一个包含物件的列表/,
|
|
1959
1964
|
/expected a list/i,
|
|
1960
1965
|
/得到的类型是/,
|
|
1961
1966
|
/not a list/i
|
|
1962
1967
|
];
|
|
1963
|
-
function
|
|
1964
|
-
return
|
|
1968
|
+
function nn(e) {
|
|
1969
|
+
return tn.some((t) => t.test(e)) ? "数据格式不正确, 请检查导入内容" : e;
|
|
1965
1970
|
}
|
|
1966
|
-
function
|
|
1971
|
+
function rn(e) {
|
|
1967
1972
|
if (Object.keys(e).length === 0) return { success: !0 };
|
|
1968
1973
|
let t = [], n;
|
|
1969
1974
|
return Object.entries(e).forEach(([e, r]) => {
|
|
1970
1975
|
let i = Array.isArray(r) ? r : [r];
|
|
1971
|
-
e === "detail" || e === "non_field_errors" ? n = i.map((e) =>
|
|
1976
|
+
e === "detail" || e === "non_field_errors" ? n = i.map((e) => nn(String(e))).join("; ") : i.forEach((n) => t.push({ [e]: nn(String(n)) }));
|
|
1972
1977
|
}), {
|
|
1973
1978
|
success: !1,
|
|
1974
1979
|
...n ? { message: n } : {},
|
|
1975
1980
|
...t.length > 0 ? { fieldErrors: t } : {}
|
|
1976
1981
|
};
|
|
1977
1982
|
}
|
|
1978
|
-
function
|
|
1983
|
+
function an(e) {
|
|
1979
1984
|
if (!Ue(e)) return "导入失败, 任务已暂停";
|
|
1980
1985
|
let t = We(e);
|
|
1981
1986
|
return t === void 0 ? "网络异常, 任务已暂停" : t === 401 ? "登录已过期, 任务已暂停" : t === 403 ? "没有导入权限, 任务已暂停" : t === 404 ? "导入接口不存在, 任务已暂停" : t === 400 ? "请求参数错误, 任务已暂停" : t >= 500 ? "服务器错误, 任务已暂停" : "导入失败, 任务已暂停";
|
|
1982
1987
|
}
|
|
1983
|
-
function
|
|
1988
|
+
function on(e) {
|
|
1984
1989
|
let t = Ge(e);
|
|
1985
1990
|
if (t && typeof t == "object") {
|
|
1986
1991
|
let e = t;
|
|
@@ -1993,41 +1998,41 @@ function rn(e) {
|
|
|
1993
1998
|
}
|
|
1994
1999
|
return "导入数据校验失败";
|
|
1995
2000
|
}
|
|
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(),
|
|
2001
|
+
var sn = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
2002
|
+
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
2003
|
a(() => {
|
|
1999
|
-
|
|
2004
|
+
A.current = g;
|
|
2000
2005
|
}, [g]), a(() => () => {
|
|
2001
|
-
|
|
2006
|
+
A.current && Ct(A.current);
|
|
2002
2007
|
}, []);
|
|
2003
|
-
let
|
|
2008
|
+
let M = () => re.current?.click(), ie = (e, t) => {
|
|
2004
2009
|
ne.warning({
|
|
2005
2010
|
title: t ?? (e.missingTitles.length > 0 ? "文件表头不完整" : "文件检查未通过"),
|
|
2006
2011
|
width: 480,
|
|
2007
|
-
content: /* @__PURE__ */
|
|
2012
|
+
content: /* @__PURE__ */ O(Vt, { ...e }),
|
|
2008
2013
|
okCancel: !0,
|
|
2009
2014
|
okText: "重新选择文件",
|
|
2010
2015
|
cancelText: "关闭",
|
|
2011
2016
|
closable: !0,
|
|
2012
|
-
onOk:
|
|
2017
|
+
onOk: M
|
|
2013
2018
|
});
|
|
2014
|
-
},
|
|
2019
|
+
}, ae = async (e) => {
|
|
2015
2020
|
if (e.size > 20971520) E.error("文件大小超过 20MB, 请拆分后再导入");
|
|
2016
2021
|
else {
|
|
2017
2022
|
_(void 0), T([]), x(!0);
|
|
2018
2023
|
try {
|
|
2019
|
-
let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await He(e,
|
|
2024
|
+
let { headerMessages: t, formulaMessages: n, rows: r, includedKeys: i } = await He(e, j);
|
|
2020
2025
|
if (n.length > 0) {
|
|
2021
|
-
|
|
2026
|
+
ie({
|
|
2022
2027
|
missingTitles: [],
|
|
2023
2028
|
headerMessages: n
|
|
2024
2029
|
}, "文件里的公式还没有计算结果");
|
|
2025
2030
|
return;
|
|
2026
2031
|
}
|
|
2027
2032
|
if (t.length > 0) {
|
|
2028
|
-
|
|
2029
|
-
missingTitles: t.filter((e) => e.startsWith(
|
|
2030
|
-
headerMessages: t.filter((e) => !e.startsWith(
|
|
2033
|
+
ie({
|
|
2034
|
+
missingTitles: t.filter((e) => e.startsWith(en)).map((e) => e.slice(5)),
|
|
2035
|
+
headerMessages: t.filter((e) => !e.startsWith(en))
|
|
2031
2036
|
});
|
|
2032
2037
|
return;
|
|
2033
2038
|
}
|
|
@@ -2043,29 +2048,29 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2043
2048
|
}
|
|
2044
2049
|
}
|
|
2045
2050
|
};
|
|
2046
|
-
return /* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */
|
|
2051
|
+
return /* @__PURE__ */ k(D, { children: [
|
|
2052
|
+
/* @__PURE__ */ k(C.Compact, {
|
|
2048
2053
|
block: !0,
|
|
2049
|
-
children: [/* @__PURE__ */
|
|
2054
|
+
children: [/* @__PURE__ */ O(te, {
|
|
2050
2055
|
title: "Excel 导入",
|
|
2051
|
-
children: /* @__PURE__ */
|
|
2056
|
+
children: /* @__PURE__ */ O(h, {
|
|
2052
2057
|
type: "default",
|
|
2053
|
-
icon: /* @__PURE__ */
|
|
2058
|
+
icon: /* @__PURE__ */ O(p, {}),
|
|
2054
2059
|
loading: b,
|
|
2055
2060
|
disabled: b,
|
|
2056
|
-
onClick:
|
|
2061
|
+
onClick: M,
|
|
2057
2062
|
children: "导入"
|
|
2058
2063
|
})
|
|
2059
|
-
}), /* @__PURE__ */
|
|
2064
|
+
}), /* @__PURE__ */ O(te, {
|
|
2060
2065
|
title: "Excel 导入模板",
|
|
2061
|
-
children: /* @__PURE__ */
|
|
2066
|
+
children: /* @__PURE__ */ O(h, {
|
|
2062
2067
|
type: "default",
|
|
2063
|
-
icon: /* @__PURE__ */
|
|
2068
|
+
icon: /* @__PURE__ */ O(f, {}),
|
|
2064
2069
|
loading: S,
|
|
2065
2070
|
onClick: async () => {
|
|
2066
2071
|
ee(!0);
|
|
2067
2072
|
try {
|
|
2068
|
-
await Ve(
|
|
2073
|
+
await Ve(j, `${e}导入模板`);
|
|
2069
2074
|
} catch (e) {
|
|
2070
2075
|
console.error(`模板下载失败: ${e}`), E.error("模板下载失败");
|
|
2071
2076
|
} finally {
|
|
@@ -2076,26 +2081,26 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2076
2081
|
})
|
|
2077
2082
|
})]
|
|
2078
2083
|
}),
|
|
2079
|
-
/* @__PURE__ */
|
|
2080
|
-
ref:
|
|
2084
|
+
/* @__PURE__ */ O("input", {
|
|
2085
|
+
ref: re,
|
|
2081
2086
|
type: "file",
|
|
2082
2087
|
accept: ".xlsx",
|
|
2083
2088
|
style: { display: "none" },
|
|
2084
2089
|
onChange: (e) => {
|
|
2085
2090
|
let t = e.target.files?.[0];
|
|
2086
|
-
e.target.value = "", t &&
|
|
2091
|
+
e.target.value = "", t && ae(t);
|
|
2087
2092
|
}
|
|
2088
2093
|
}),
|
|
2089
|
-
/* @__PURE__ */
|
|
2094
|
+
/* @__PURE__ */ O($t, {
|
|
2090
2095
|
open: i,
|
|
2091
2096
|
title: e,
|
|
2092
|
-
fieldSchemas:
|
|
2097
|
+
fieldSchemas: j,
|
|
2093
2098
|
rows: u,
|
|
2094
2099
|
taskId: g,
|
|
2095
2100
|
includedKeys: w,
|
|
2096
2101
|
onChangeCell: (e, t, n) => {
|
|
2097
2102
|
if (!w.includes(t.key)) return;
|
|
2098
|
-
let r =
|
|
2103
|
+
let r = be(t, n), i = H(r.trim() === "" ? null : r, t);
|
|
2099
2104
|
d((r) => r.map((r) => {
|
|
2100
2105
|
if (r.key !== e.key) return r;
|
|
2101
2106
|
let a = { ...r.errors };
|
|
@@ -2115,9 +2120,9 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2115
2120
|
...e.values,
|
|
2116
2121
|
[t.key]: n
|
|
2117
2122
|
}, i = {};
|
|
2118
|
-
|
|
2123
|
+
j.forEach((e) => {
|
|
2119
2124
|
if (!w.includes(e.key)) return;
|
|
2120
|
-
let t =
|
|
2125
|
+
let t = be(e, r[e.key]), n = H(t.trim() === "" ? null : t, e);
|
|
2121
2126
|
n.validateSuccess || (i[e.key] = n.validateMessage);
|
|
2122
2127
|
});
|
|
2123
2128
|
let a = {
|
|
@@ -2125,7 +2130,7 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2125
2130
|
values: r,
|
|
2126
2131
|
errors: i
|
|
2127
2132
|
};
|
|
2128
|
-
d((t) => t.map((t) => t.key === e.key ? a : t)), g && e.taskIndex !== void 0 && (
|
|
2133
|
+
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
2134
|
},
|
|
2130
2135
|
onDelete: (e) => {
|
|
2131
2136
|
d((t) => t.filter((t) => t.key !== e.key));
|
|
@@ -2145,18 +2150,18 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2145
2150
|
taskIndex: t
|
|
2146
2151
|
}));
|
|
2147
2152
|
d(i);
|
|
2148
|
-
let a =
|
|
2153
|
+
let a = ht({
|
|
2149
2154
|
title: `${e}导入`,
|
|
2150
2155
|
rows: i,
|
|
2151
|
-
fieldSchemas:
|
|
2156
|
+
fieldSchemas: j,
|
|
2152
2157
|
includedKeys: w,
|
|
2153
2158
|
importRows: async (e, t) => {
|
|
2154
2159
|
try {
|
|
2155
|
-
let r = await n(e.map((e) =>
|
|
2160
|
+
let r = await n(e.map((e) => xe(e, j, w)), t);
|
|
2156
2161
|
if (r.length !== e.length) throw new W("导入接口返回结果数量不正确, 任务已暂停");
|
|
2157
|
-
return r.map(
|
|
2162
|
+
return r.map(rn);
|
|
2158
2163
|
} catch (e) {
|
|
2159
|
-
throw t.aborted || e instanceof W ? e : We(e) === 422 ? Error(
|
|
2164
|
+
throw t.aborted || e instanceof W ? e : We(e) === 422 ? Error(on(e)) : new W(an(e));
|
|
2160
2165
|
}
|
|
2161
2166
|
},
|
|
2162
2167
|
onFinished: r
|
|
@@ -2164,9 +2169,9 @@ var an = ({ title: e, fieldSchemas: t, importRows: n, onImported: r }) => {
|
|
|
2164
2169
|
_(a);
|
|
2165
2170
|
},
|
|
2166
2171
|
onClose: () => {
|
|
2167
|
-
g &&
|
|
2172
|
+
g && Ct(g), l(!1), _(void 0), d([]), T([]);
|
|
2168
2173
|
}
|
|
2169
2174
|
}, v)
|
|
2170
2175
|
] });
|
|
2171
2176
|
};
|
|
2172
|
-
export {
|
|
2177
|
+
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 };
|