@qfei-design/make-app-approval 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PUBLIC_API.md +33 -14
- package/README.md +9 -5
- package/dist/detail/task-policy.d.ts +4 -2
- package/dist/detail/types.d.ts +14 -3
- package/dist/detail.cjs +1 -1
- package/dist/detail.mjs +280 -315
- package/dist/list/index.d.ts +1 -1
- package/dist/list/types.d.ts +11 -2
- package/dist/list/ui-components.d.ts +4 -2
- package/dist/list.cjs +1 -1
- package/dist/list.mjs +173 -174
- package/dist/styles.css +41 -30
- package/dist/withdrawal.d.ts +0 -1
- package/docs/host-integration.md +64 -38
- package/docs/implementation-plan.md +15 -12
- package/docs/publishing.md +1 -1
- package/examples/detail-integration.tsx +7 -4
- package/examples/host-integration.tsx +5 -4
- package/package.ai.json +7 -3
- package/package.json +1 -1
- package/recipes.json +6 -6
package/dist/list.mjs
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
2
|
-
import { useRef as M, useState as V, useEffect as j, useMemo as
|
|
3
|
-
import { getApprovalStatusDisplay as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as s, jsxs as z } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as M, useState as V, useEffect as j, useMemo as le, useId as ie } from "react";
|
|
3
|
+
import { getApprovalStatusDisplay as ce } from "./index.mjs";
|
|
4
|
+
const A = (e, a) => {
|
|
5
5
|
try {
|
|
6
6
|
e ? e(a) : a.phase === "error" ? console.warn("[make-app-approval]", a) : console.info("[make-app-approval]", a);
|
|
7
7
|
} catch {
|
|
8
8
|
console.warn("[make-app-approval] diagnostic sink failed");
|
|
9
9
|
}
|
|
10
|
-
},
|
|
11
|
-
if (!
|
|
10
|
+
}, pe = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : ce(e).label, re = (e) => typeof e == "object" && e !== null, de = (e) => re(e) ? ["id", "entityKey", "recordId"].every((a) => typeof e[a] == "string" && e[a].trim().length > 0) && ["applicationNo", "applicationType", "applicantName", "applicationTime"].every((a) => typeof e[a] == "string") && ["taskId", "processInstanceId"].every((a) => e[a] === void 0 || typeof e[a] == "string" && e[a].trim().length > 0) && (typeof e.processStatus == "string" || e.processStatus === null) : !1, Q = (e, a) => {
|
|
11
|
+
if (!re(e) || !Array.isArray(e.rows) || !e.rows.every(de) || typeof e.total != "number" || !Number.isSafeInteger(e.total) || e.total < 0 || e.rows.length > a || e.rows.length > e.total || new Set(e.rows.map((g) => g.id)).size !== e.rows.length)
|
|
12
12
|
throw new Error("Invalid approval page contract");
|
|
13
13
|
return { rows: e.rows, total: e.total };
|
|
14
|
-
}, ue = ({ table: e, query: a, initialPage:
|
|
15
|
-
const d = /* @__PURE__ */ new Map(),
|
|
16
|
-
let
|
|
17
|
-
const
|
|
18
|
-
let
|
|
19
|
-
const L = (r) => Number.isSafeInteger(r) && r >= 0 && r * a.pageSize <
|
|
20
|
-
k ||
|
|
14
|
+
}, ue = ({ table: e, query: a, initialPage: g, loadPage: F, onChange: $, retryViewport: B, onReload: O, logger: C }) => {
|
|
15
|
+
const d = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Set();
|
|
16
|
+
let P = [];
|
|
17
|
+
const i = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set();
|
|
18
|
+
let m = g, v = g.total, c = 0, k = !1, S = !1, T;
|
|
19
|
+
const L = (r) => Number.isSafeInteger(r) && r >= 0 && r * a.pageSize < v, h = (r, t, p) => A(C, { operation: "list", phase: t, tab: a.tab, page: r + 1, pageSize: a.pageSize, rowCount: p }), f = () => {
|
|
20
|
+
k || $({ total: v, rows: P, failed: S || u.size > 0, loading: d.size > 0 });
|
|
21
21
|
}, N = (r) => {
|
|
22
|
-
r.finished || (r.finished = !0, r.removeAbort(), d.get(r.page) === r && d.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(),
|
|
22
|
+
r.finished || (r.finished = !0, r.removeAbort(), d.get(r.page) === r && d.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), h(r.page, "cancel"));
|
|
23
23
|
}, l = (r) => {
|
|
24
|
-
|
|
25
|
-
const t = e.getPagesInView() ?? [],
|
|
26
|
-
for (const n of d.values())
|
|
27
|
-
for (const n of u)
|
|
28
|
-
}, D = (r, t,
|
|
24
|
+
c = r;
|
|
25
|
+
const t = e.getPagesInView() ?? [], p = new Set([c, ...t].flatMap((n) => [n - 1, n, n + 1]).filter(L));
|
|
26
|
+
for (const n of d.values()) p.has(n.page) || N(n);
|
|
27
|
+
for (const n of u) p.has(n) || u.delete(n);
|
|
28
|
+
}, D = (r, t, p) => {
|
|
29
29
|
const n = t.rows.map((b) => {
|
|
30
|
-
const o = { ...b, statusLabel:
|
|
31
|
-
return
|
|
30
|
+
const o = { ...b, statusLabel: pe(b.processStatus) };
|
|
31
|
+
return i.set(o, b), o;
|
|
32
32
|
});
|
|
33
|
-
if (!e.setVirtualPageData(n, r, t.total,
|
|
34
|
-
|
|
33
|
+
if (!e.setVirtualPageData(n, r, t.total, p)) {
|
|
34
|
+
h(r, "skip");
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
v = t.total;
|
|
38
38
|
try {
|
|
39
|
-
|
|
39
|
+
P = Q({ rows: e.getTableData() ?? [], total: v }, Number.MAX_SAFE_INTEGER).rows.map((b) => i.get(b) ?? b);
|
|
40
40
|
} catch (b) {
|
|
41
|
-
S = !0,
|
|
41
|
+
S = !0, P = [], m = void 0, T && clearTimeout(T), T = void 0;
|
|
42
42
|
for (const o of d.values()) N(o);
|
|
43
43
|
throw b;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
m && m.total !== v && (m = void 0), u.delete(r);
|
|
46
46
|
for (const b of d.values()) L(b.page) || N(b);
|
|
47
|
-
!L(r) && r > 0 && e.scrollToRow(Math.max(0,
|
|
48
|
-
},
|
|
49
|
-
if (k ||
|
|
50
|
-
const r = [...d.values()].filter((t) => !t.running && !t.finished).sort((t,
|
|
47
|
+
!L(r) && r > 0 && e.scrollToRow(Math.max(0, v - 1)), h(r, "success", t.rows.length);
|
|
48
|
+
}, x = () => {
|
|
49
|
+
if (k || T) return;
|
|
50
|
+
const r = [...d.values()].filter((t) => !t.running && !t.finished).sort((t, p) => Math.abs(t.page - c) - Math.abs(p.page - c) || t.page - p.page);
|
|
51
51
|
for (const t of r) {
|
|
52
|
-
if (
|
|
53
|
-
t.running = !0,
|
|
52
|
+
if (I.size >= 2) break;
|
|
53
|
+
t.running = !0, I.add(t), h(t.page, "start"), (async () => {
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
55
|
+
const p = await F({ ...a, page: t.page + 1 }, { signal: t.controller.signal });
|
|
56
56
|
if (k || t.finished || t.controller.signal.aborted) return;
|
|
57
|
-
const n = Q(
|
|
57
|
+
const n = Q(p, a.pageSize);
|
|
58
58
|
t.finished = !0, t.removeAbort(), d.delete(t.page), D(t.page, n, t.request);
|
|
59
59
|
} catch {
|
|
60
|
-
!k && !t.controller.signal.aborted && (u.add(t.page),
|
|
60
|
+
!k && !t.controller.signal.aborted && (u.add(t.page), h(t.page, "error"), e.markPageLoadFailed(t.page, t.request));
|
|
61
61
|
} finally {
|
|
62
|
-
t.finished || (t.finished = !0, t.removeAbort(), d.get(t.page) === t && d.delete(t.page)),
|
|
62
|
+
t.finished || (t.finished = !0, t.removeAbort(), d.get(t.page) === t && d.delete(t.page)), I.delete(t), f(), x();
|
|
63
63
|
}
|
|
64
64
|
})();
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
f();
|
|
67
|
+
}, K = () => {
|
|
68
|
+
T && clearTimeout(T), T = setTimeout(() => {
|
|
69
|
+
T = void 0, x();
|
|
70
70
|
}, 120);
|
|
71
71
|
};
|
|
72
72
|
return {
|
|
73
73
|
load(r, t) {
|
|
74
74
|
if (t.useRequestIdentity(), k || S || t.signal.aborted || !L(r)) {
|
|
75
|
-
e.markPageLoadFailed(r, t),
|
|
75
|
+
e.markPageLoadFailed(r, t), h(r, "skip");
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
if (
|
|
81
|
-
const b =
|
|
82
|
-
|
|
78
|
+
const p = d.get(r);
|
|
79
|
+
if (p?.request === t && !p.finished) return;
|
|
80
|
+
if (p && N(p), l(r), r === 0 && m) {
|
|
81
|
+
const b = m;
|
|
82
|
+
m = void 0;
|
|
83
83
|
try {
|
|
84
84
|
D(0, b, t);
|
|
85
85
|
} catch {
|
|
86
|
-
u.add(r), e.markPageLoadFailed(r, t),
|
|
86
|
+
u.add(r), e.markPageLoadFailed(r, t), h(r, "error");
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
f();
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
const n = { page: r, request: t, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
|
|
92
|
-
} },
|
|
93
|
-
N(n),
|
|
92
|
+
} }, W = () => {
|
|
93
|
+
N(n), f();
|
|
94
94
|
};
|
|
95
|
-
t.signal.addEventListener("abort",
|
|
95
|
+
t.signal.addEventListener("abort", W, { once: !0 }), n.removeAbort = () => t.signal.removeEventListener("abort", W), d.set(r, n), K(), f();
|
|
96
96
|
},
|
|
97
97
|
viewportChanged() {
|
|
98
98
|
if (k) return;
|
|
99
99
|
const r = e.getPagesInView();
|
|
100
|
-
r?.length && (l(r[0]), d.size &&
|
|
100
|
+
r?.length && (l(r[0]), d.size && K(), f());
|
|
101
101
|
},
|
|
102
102
|
retry() {
|
|
103
103
|
if (!k) {
|
|
@@ -105,21 +105,20 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
105
105
|
O();
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
u.size !== 0 && (u.clear(), B(),
|
|
108
|
+
u.size !== 0 && (u.clear(), B(), f());
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
dispose() {
|
|
112
|
-
k = !0,
|
|
112
|
+
k = !0, T && clearTimeout(T), T = void 0;
|
|
113
113
|
for (const r of d.values()) N(r);
|
|
114
|
-
|
|
114
|
+
P = [], u.clear(), m = void 0;
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
}, fe = [
|
|
118
|
-
{ key: "applicationNo", title: "
|
|
119
|
-
{ key: "applicationType", title: "
|
|
118
|
+
{ key: "applicationNo", title: "申请单ID", width: 260 },
|
|
119
|
+
{ key: "applicationType", title: "业务表单", width: 180 },
|
|
120
120
|
{ key: "applicantName", title: "申请人", width: 170 },
|
|
121
|
-
{ key: "applicationTime", title: "申请时间", width: 220 }
|
|
122
|
-
{ key: "statusLabel", title: "流程状态", width: 140 }
|
|
121
|
+
{ key: "applicationTime", title: "申请时间", width: 220 }
|
|
123
122
|
].map((e) => ({ ...e, showEllipsis: !0, sortable: !1 })), te = 40, ge = (e) => {
|
|
124
123
|
const a = M(void 0);
|
|
125
124
|
return e.initialPage ? /* @__PURE__ */ s(
|
|
@@ -128,28 +127,28 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
128
127
|
...e,
|
|
129
128
|
initialPage: e.initialPage,
|
|
130
129
|
restoreScroll: a.current?.query === e.query ? a.current.position : void 0,
|
|
131
|
-
rememberScroll: (
|
|
132
|
-
a.current = { query: e.query, position:
|
|
130
|
+
rememberScroll: (g) => {
|
|
131
|
+
a.current = { query: e.query, position: g };
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
) : /* @__PURE__ */ s("div", { className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" });
|
|
136
|
-
}, he = ({ components: { Button: e }, initialPage: a, query:
|
|
137
|
-
const
|
|
138
|
-
|
|
135
|
+
}, he = ({ components: { Button: e }, initialPage: a, query: g, provider: F, themeKey: $, onOpen: B, onReload: O, logger: C, restoreScroll: d, rememberScroll: I }) => {
|
|
136
|
+
const P = M(null), i = M(null), u = M(null), [m, v] = V(!1), [c, k] = V(0), [S, T] = V({ ...a, failed: !1, loading: !1 }), L = M(a.rows), h = M(d), f = M({ provider: F, onOpen: B, onReload: O, logger: C, rememberScroll: I });
|
|
137
|
+
f.current = { provider: F, onOpen: B, onReload: O, logger: C, rememberScroll: I };
|
|
139
138
|
const N = M(() => {
|
|
140
139
|
});
|
|
141
140
|
return j(() => {
|
|
142
|
-
const l =
|
|
141
|
+
const l = P.current;
|
|
143
142
|
if (!l) return;
|
|
144
|
-
let D = !1,
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
D || (
|
|
143
|
+
let D = !1, x, K, r, t = a.total;
|
|
144
|
+
A(f.current.logger, { operation: "table", phase: "start" });
|
|
145
|
+
const p = () => {
|
|
146
|
+
D || (v(!0), A(f.current.logger, { operation: "table", phase: "error" }));
|
|
148
147
|
};
|
|
149
148
|
return import("@qfei-design/canvas-table").then((n) => {
|
|
150
149
|
if (D) return;
|
|
151
|
-
const
|
|
152
|
-
const o =
|
|
150
|
+
const W = () => {
|
|
151
|
+
const o = i.current, y = o?.getScrollState();
|
|
153
152
|
o && y && n.globalEventBus.emitWithNamespace("scroll:change", o.tableId, y);
|
|
154
153
|
}, b = () => {
|
|
155
154
|
if (!D)
|
|
@@ -165,18 +164,18 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
165
164
|
...E.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: E.getPropertyValue("--make-approval-bg").trim() } : {},
|
|
166
165
|
...E.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: E.getPropertyValue("--make-approval-header").trim() } : {},
|
|
167
166
|
...E.getPropertyValue("--make-approval-border").trim() ? { borderColor: E.getPropertyValue("--make-approval-border").trim() } : {}
|
|
168
|
-
},
|
|
169
|
-
if (
|
|
170
|
-
|
|
167
|
+
}, oe = Math.max(Math.ceil(300 / g.pageSize), Math.ceil(y * 3 / te / g.pageSize) + 2) * g.pageSize, q = { enabled: !0, totalRowCount: t, pageSize: g.pageSize, maxCachedRows: oe };
|
|
168
|
+
if (i.current) {
|
|
169
|
+
i.current.updateProps({ canvasWidth: o, canvasHeight: y, style: Z, virtualOptions: q }), i.current.updateCanvasSize(o, y, !0), W();
|
|
171
170
|
return;
|
|
172
171
|
}
|
|
173
|
-
|
|
172
|
+
i.current = new n.CanvasTableComponent(l, {
|
|
174
173
|
columns: fe,
|
|
175
174
|
canvasWidth: o,
|
|
176
175
|
canvasHeight: y,
|
|
177
176
|
style: Z,
|
|
178
177
|
rowKey: "id",
|
|
179
|
-
showSN: { enabled: !0, width: 64, formatter: (w,
|
|
178
|
+
showSN: { enabled: !0, width: 64, formatter: (w, R) => R + 1 },
|
|
180
179
|
virtualOptions: q,
|
|
181
180
|
selectable: { enabled: !1 },
|
|
182
181
|
rowSortable: { enabled: !1 },
|
|
@@ -188,65 +187,65 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
188
187
|
bodyRowHeadSuffixOptions: {
|
|
189
188
|
enabled: !0,
|
|
190
189
|
width: 20,
|
|
191
|
-
render: ({ group: w, x:
|
|
192
|
-
const
|
|
190
|
+
render: ({ group: w, x: R, height: Y, rowData: G }) => {
|
|
191
|
+
const ne = G?.id, _ = new n.RectShape({ name: "approval-open", x: R, y: Y / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
|
|
193
192
|
_.addChild(new n.ImgShape({ name: "approval-open-icon", x: 3, y: 3, attrs: {
|
|
194
193
|
width: 14,
|
|
195
194
|
height: 14,
|
|
196
195
|
img: "data:image/svg+xml;charset=utf-8," + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${E.color || "#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
|
|
197
196
|
} })), _.on("mousedown", (J) => J.stopPropagation?.()), _.on("click", (J) => {
|
|
198
197
|
J.stopPropagation?.();
|
|
199
|
-
const ee = L.current.find((
|
|
200
|
-
ee &&
|
|
198
|
+
const ee = L.current.find((se) => se.id === ne);
|
|
199
|
+
ee && f.current.onOpen(ee);
|
|
201
200
|
}), w.addChild(_);
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
203
|
});
|
|
205
|
-
const H =
|
|
204
|
+
const H = i.current, X = ue({
|
|
206
205
|
table: H,
|
|
207
|
-
query:
|
|
206
|
+
query: g,
|
|
208
207
|
initialPage: a,
|
|
209
208
|
// 公开滚动同步事件会重新检测缺页,不移动视口,也不复用失败身份。
|
|
210
|
-
retryViewport:
|
|
211
|
-
onReload: () =>
|
|
212
|
-
loadPage: (w,
|
|
213
|
-
logger: (w) =>
|
|
209
|
+
retryViewport: W,
|
|
210
|
+
onReload: () => f.current.onReload(),
|
|
211
|
+
loadPage: (w, R) => f.current.provider.loadPage(w, R),
|
|
212
|
+
logger: (w) => A(f.current.logger, w),
|
|
214
213
|
onChange: (w) => {
|
|
215
|
-
D || (t = w.total, L.current = w.rows,
|
|
214
|
+
D || (t = w.total, L.current = w.rows, T((R) => R.total === w.total && R.failed === w.failed && R.loading === w.loading && R.rows.length === w.rows.length && R.rows.every((Y, G) => Y === w.rows[G]) ? R : w));
|
|
216
215
|
}
|
|
217
216
|
});
|
|
218
|
-
u.current = X,
|
|
217
|
+
u.current = X, K = n.globalEventBus.onWithNamespace("data:load", H.tableId, (w, R) => X.load(w, R)), r = n.globalEventBus.onWithNamespace("scroll:change", H.tableId, () => X.viewportChanged()), h.current && H.scrollTo(h.current.scrollX, h.current.scrollY), v(!1), A(f.current.logger, { operation: "table", phase: "success" });
|
|
219
218
|
} catch {
|
|
220
|
-
|
|
219
|
+
p();
|
|
221
220
|
}
|
|
222
221
|
};
|
|
223
|
-
N.current = b,
|
|
224
|
-
}).catch(
|
|
225
|
-
D = !0,
|
|
226
|
-
},
|
|
222
|
+
N.current = b, x = new ResizeObserver(b), x.observe(l), b();
|
|
223
|
+
}).catch(p), () => {
|
|
224
|
+
D = !0, x?.disconnect(), N.current = () => {
|
|
225
|
+
}, i.current && (h.current = i.current.getScrollState(), h.current && f.current.rememberScroll(h.current)), K?.(), r?.(), u.current?.dispose(), u.current = null, i.current?.destroy(), i.current = null, A(f.current.logger, { operation: "table", phase: "destroy" });
|
|
227
226
|
};
|
|
228
|
-
}, [a,
|
|
227
|
+
}, [a, g, c]), j(() => {
|
|
229
228
|
N.current();
|
|
230
|
-
}, [
|
|
231
|
-
/* @__PURE__ */ s("div", { ref:
|
|
232
|
-
|
|
229
|
+
}, [$]), /* @__PURE__ */ z("div", { className: "make-app-approval-table-frame", "aria-busy": S.loading, children: [
|
|
230
|
+
/* @__PURE__ */ s("div", { ref: P, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
|
|
231
|
+
m && /* @__PURE__ */ z("div", { className: "make-app-approval-overlay", role: "alert", children: [
|
|
233
232
|
"表格加载失败 ",
|
|
234
233
|
/* @__PURE__ */ s(e, { htmlType: "button", variant: "default", onClick: () => {
|
|
235
|
-
|
|
234
|
+
v(!1), k((l) => l + 1);
|
|
236
235
|
}, children: "重新加载表格" })
|
|
237
236
|
] }),
|
|
238
|
-
!
|
|
237
|
+
!m && S.failed && /* @__PURE__ */ z("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
|
|
239
238
|
"部分审批记录加载失败 ",
|
|
240
239
|
/* @__PURE__ */ s(e, { htmlType: "button", variant: "default", onClick: () => u.current?.retry(), children: "重试加载" })
|
|
241
240
|
] }),
|
|
242
|
-
!
|
|
241
|
+
!m && !S.failed && S.loading && /* @__PURE__ */ z("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
|
|
243
242
|
/* @__PURE__ */ s("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
|
|
244
243
|
/* @__PURE__ */ s("span", { children: "加载中" })
|
|
245
244
|
] }),
|
|
246
|
-
/* @__PURE__ */
|
|
245
|
+
/* @__PURE__ */ z("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
|
|
247
246
|
S.total === 0 && /* @__PURE__ */ s("li", { children: "暂无审批记录" }),
|
|
248
|
-
S.rows.map((l) => /* @__PURE__ */
|
|
249
|
-
/* @__PURE__ */
|
|
247
|
+
S.rows.map((l) => /* @__PURE__ */ z("li", { children: [
|
|
248
|
+
/* @__PURE__ */ z("span", { children: [
|
|
250
249
|
l.applicationNo,
|
|
251
250
|
",",
|
|
252
251
|
l.applicationType,
|
|
@@ -254,11 +253,9 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
254
253
|
l.applicantName,
|
|
255
254
|
",",
|
|
256
255
|
l.applicationTime,
|
|
257
|
-
",",
|
|
258
|
-
re(l.processStatus),
|
|
259
256
|
"。"
|
|
260
257
|
] }),
|
|
261
|
-
/* @__PURE__ */
|
|
258
|
+
/* @__PURE__ */ z(e, { htmlType: "button", variant: "text", onClick: () => B(l), children: [
|
|
262
259
|
"打开 ",
|
|
263
260
|
l.applicationNo || l.applicationType,
|
|
264
261
|
" 的审批详情"
|
|
@@ -266,109 +263,111 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
266
263
|
] }, l.id))
|
|
267
264
|
] })
|
|
268
265
|
] });
|
|
269
|
-
}, me = [], ve = (e, a,
|
|
270
|
-
const [
|
|
266
|
+
}, me = [], ve = (e, a, g, F) => {
|
|
267
|
+
const [$, B] = V(0), [O, C] = V(), d = M({ provider: e, logger: F });
|
|
271
268
|
d.current = { provider: e, logger: F };
|
|
272
|
-
const
|
|
269
|
+
const I = le(() => ({}), [a, g, $]);
|
|
273
270
|
j(() => {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
let
|
|
271
|
+
const i = new AbortController(), { provider: u, logger: m } = d.current, v = { operation: "list", tab: a.tab, page: a.page, pageSize: a.pageSize };
|
|
272
|
+
A(m, { ...v, phase: "start" });
|
|
273
|
+
let c = !1;
|
|
277
274
|
return (async () => {
|
|
278
275
|
try {
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
if (await Promise.resolve(), i.signal.aborted) return;
|
|
277
|
+
const k = await u.loadPage(a, { signal: i.signal });
|
|
278
|
+
if (i.signal.aborted) return;
|
|
281
279
|
const S = Q(k, a.pageSize);
|
|
282
|
-
|
|
280
|
+
c = !0, C({ ...S, token: I, status: "success" }), A(m, { ...v, phase: "success", rowCount: S.rows.length });
|
|
283
281
|
} catch {
|
|
284
|
-
if (
|
|
285
|
-
|
|
282
|
+
if (i.signal.aborted) return;
|
|
283
|
+
c = !0, C({ token: I, status: "error", rows: me, total: 0 }), A(m, { ...v, phase: "error" });
|
|
286
284
|
}
|
|
287
285
|
})(), () => {
|
|
288
|
-
|
|
286
|
+
i.abort(), c || A(m, { ...v, phase: "cancel" });
|
|
289
287
|
};
|
|
290
|
-
}, [a,
|
|
291
|
-
const
|
|
288
|
+
}, [a, I]);
|
|
289
|
+
const P = O?.token === I ? O : void 0;
|
|
292
290
|
return {
|
|
293
|
-
initialPage:
|
|
294
|
-
total:
|
|
295
|
-
status:
|
|
296
|
-
reload: () => B((
|
|
291
|
+
initialPage: P?.status === "success" ? P : void 0,
|
|
292
|
+
total: P?.total ?? 0,
|
|
293
|
+
status: P?.status ?? "loading",
|
|
294
|
+
reload: () => B((i) => i + 1)
|
|
297
295
|
};
|
|
298
|
-
}, U = { keyword: "", processStatus: "", startDate: "", endDate: "" }, be = [{ value: "pending", label: "
|
|
296
|
+
}, U = { keyword: "", applicantId: "", processStatus: "", startDate: "", endDate: "" }, be = [{ value: "pending", label: "待处理" }, { value: "approved", label: "已完成" }], ae = (e) => {
|
|
299
297
|
if (e === "") return !0;
|
|
300
298
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
|
|
301
299
|
const a = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
302
300
|
return Number.isFinite(a.getTime()) && a.toISOString().slice(0, 10) === e;
|
|
303
|
-
}, we = ({ components: e, provider: a, onOpenApproval:
|
|
304
|
-
const { Input:
|
|
305
|
-
j(() => (
|
|
306
|
-
|
|
301
|
+
}, we = ({ components: e, provider: a, onOpenApproval: g, applicantOptions: F = [], pageSize: $ = 20, refreshKey: B, themeKey: O, logger: C, className: d }) => {
|
|
302
|
+
const { Input: I, Select: P, DateRangePicker: i, Button: u, Tabs: m } = e, v = ie(), [c, k] = V(U), [S, T] = V(0), [L, h] = V(""), [f, N] = V(""), [l, D] = V({ ...U, tab: "pending", page: 1, pageSize: $ }), { initialPage: x, status: K, reload: r } = ve(a, l, B, C), t = M(!1), p = M(!0);
|
|
303
|
+
j(() => (p.current = !0, () => {
|
|
304
|
+
p.current = !1;
|
|
307
305
|
}), []);
|
|
308
|
-
const n =
|
|
306
|
+
const n = K === "loading", W = async (o) => {
|
|
309
307
|
if (!t.current) {
|
|
310
|
-
t.current = !0, N(""),
|
|
308
|
+
t.current = !0, N(""), A(C, { operation: "open", phase: "start" });
|
|
311
309
|
try {
|
|
312
|
-
await
|
|
310
|
+
await g(o), A(C, { operation: "open", phase: "success" });
|
|
313
311
|
} catch {
|
|
314
|
-
|
|
312
|
+
p.current && N("审批详情打开失败,请重试"), A(C, { operation: "open", phase: "error" });
|
|
315
313
|
} finally {
|
|
316
314
|
t.current = !1;
|
|
317
315
|
}
|
|
318
316
|
}
|
|
319
317
|
}, b = (o) => {
|
|
320
|
-
o !== l.tab && (
|
|
318
|
+
o !== l.tab && (h(""), N(""), D((y) => ({ ...y, tab: o, page: 1 })));
|
|
321
319
|
};
|
|
322
|
-
return /* @__PURE__ */ s("section", { className: ["make-app-approval", d].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
if (o.preventDefault(), !ae(
|
|
325
|
-
|
|
320
|
+
return /* @__PURE__ */ s("section", { className: ["make-app-approval", d].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */ z(m, { items: be, value: l.tab, onChange: b, ariaLabel: "审批分类", children: [
|
|
321
|
+
/* @__PURE__ */ z("form", { className: "make-app-approval-filters", onSubmit: (o) => {
|
|
322
|
+
if (o.preventDefault(), !ae(c.startDate) || !ae(c.endDate)) {
|
|
323
|
+
h("请选择有效日期");
|
|
326
324
|
return;
|
|
327
325
|
}
|
|
328
|
-
if (
|
|
329
|
-
|
|
326
|
+
if (c.startDate && c.endDate && c.startDate > c.endDate) {
|
|
327
|
+
h("开始日期不能晚于结束日期");
|
|
330
328
|
return;
|
|
331
329
|
}
|
|
332
|
-
|
|
330
|
+
h(""), N(""), D((y) => ({ ...y, ...c, keyword: c.keyword.trim(), page: 1 }));
|
|
333
331
|
}, children: [
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
332
|
+
/* @__PURE__ */ s("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ s(I, { id: `${v}-keyword`, ariaLabel: "申请单ID", placeholder: "搜索申请单ID", value: c.keyword, onChange: (o) => k((y) => ({ ...y, keyword: o })) }) }),
|
|
333
|
+
/* @__PURE__ */ s("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ s(
|
|
334
|
+
i,
|
|
335
|
+
{
|
|
336
|
+
id: `${v}-period`,
|
|
337
|
+
ariaLabel: "申请时间",
|
|
338
|
+
placeholder: ["开始日期", "结束日期"],
|
|
339
|
+
value: [c.startDate, c.endDate],
|
|
340
|
+
onChange: ([o, y]) => k((E) => ({ ...E, startDate: o, endDate: y }))
|
|
341
|
+
},
|
|
342
|
+
S
|
|
343
|
+
) }),
|
|
344
|
+
/* @__PURE__ */ s("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ s(
|
|
345
|
+
P,
|
|
346
|
+
{
|
|
347
|
+
id: `${v}-applicant`,
|
|
348
|
+
ariaLabel: "申请人",
|
|
349
|
+
purpose: "applicant",
|
|
350
|
+
value: c.applicantId ?? "",
|
|
351
|
+
options: [{ value: "", label: "全部申请人" }, ...F.filter((o) => o.value !== "")],
|
|
352
|
+
onChange: (o) => k((y) => ({ ...y, applicantId: o }))
|
|
353
|
+
}
|
|
354
|
+
) }),
|
|
355
|
+
/* @__PURE__ */ z("div", { className: "make-app-approval-filter-actions", children: [
|
|
357
356
|
/* @__PURE__ */ s(u, { htmlType: "submit", variant: "primary", children: "查询" }),
|
|
358
357
|
/* @__PURE__ */ s(u, { htmlType: "button", variant: "default", onClick: () => {
|
|
359
|
-
k(U),
|
|
358
|
+
k(U), T((o) => o + 1), h(""), N(""), D((o) => ({ ...o, ...U, page: 1 }));
|
|
360
359
|
}, children: "重置" }),
|
|
361
360
|
/* @__PURE__ */ s(u, { htmlType: "button", variant: "default", disabled: n, loading: n, onClick: r, children: "刷新" })
|
|
362
361
|
] })
|
|
363
362
|
] }),
|
|
364
363
|
L && /* @__PURE__ */ s("p", { role: "alert", className: "make-app-approval-error", children: L }),
|
|
365
|
-
|
|
366
|
-
/* @__PURE__ */
|
|
367
|
-
/* @__PURE__ */ s(ge, { components: e, initialPage:
|
|
368
|
-
|
|
369
|
-
}, onReload: r, themeKey: O, logger:
|
|
364
|
+
f && /* @__PURE__ */ s("p", { role: "alert", className: "make-app-approval-error", children: f }),
|
|
365
|
+
/* @__PURE__ */ z("div", { className: "make-app-approval-results", "aria-busy": n, children: [
|
|
366
|
+
/* @__PURE__ */ s(ge, { components: e, initialPage: x, query: l, provider: a, onOpen: (o) => {
|
|
367
|
+
W(o);
|
|
368
|
+
}, onReload: r, themeKey: O, logger: C }),
|
|
370
369
|
n && /* @__PURE__ */ s("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
|
|
371
|
-
|
|
370
|
+
K === "error" && /* @__PURE__ */ z("div", { className: "make-app-approval-overlay", role: "alert", children: [
|
|
372
371
|
/* @__PURE__ */ s("span", { children: "审批列表加载失败,请重试" }),
|
|
373
372
|
/* @__PURE__ */ s(u, { htmlType: "button", variant: "default", onClick: r, children: "重试" })
|
|
374
373
|
] })
|
|
@@ -377,8 +376,8 @@ const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).labe
|
|
|
377
376
|
}, Ne = (e) => {
|
|
378
377
|
const a = e.pageSize ?? 20;
|
|
379
378
|
if (!e.scopeKey.trim()) throw new Error("MyApprovalsPage requires scopeKey");
|
|
380
|
-
for (const
|
|
381
|
-
if (!e.components?.[
|
|
379
|
+
for (const g of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
|
|
380
|
+
if (!e.components?.[g]) throw new Error(`MyApprovalsPage requires components.${g}`);
|
|
382
381
|
if (!Number.isSafeInteger(a) || a < 1 || a > 200) throw new Error("pageSize must be an integer from 1 to 200");
|
|
383
382
|
return /* @__PURE__ */ s(we, { ...e, pageSize: a }, JSON.stringify([e.scopeKey, a]));
|
|
384
383
|
};
|