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