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