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