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