@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/dist/list.mjs CHANGED
@@ -1,103 +1,103 @@
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
- import { getApprovalStatusDisplay as pe } from "./index.mjs";
4
- const re = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : pe(e).label, I = (e, a) => {
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
- }, 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((h) => h.id)).size !== e.rows.length)
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: h, loadPage: F, onChange: W, retryViewport: B, onReload: O, logger: z }) => {
15
- const d = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set();
16
- let C = [];
17
- const p = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set();
18
- let v = h, f = h.total, i = 0, k = !1, S = !1, R;
19
- const L = (r) => Number.isSafeInteger(r) && r >= 0 && r * a.pageSize < f, m = (r, t, c) => I(z, { operation: "list", phase: t, tab: a.tab, page: r + 1, pageSize: a.pageSize, rowCount: c }), g = () => {
20
- k || W({ total: f, rows: C, failed: S || u.size > 0, loading: d.size > 0 });
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(), m(r.page, "cancel"));
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
- i = r;
25
- const t = e.getPagesInView() ?? [], c = new Set([i, ...t].flatMap((n) => [n - 1, n, n + 1]).filter(L));
26
- for (const n of d.values()) c.has(n.page) || N(n);
27
- for (const n of u) c.has(n) || u.delete(n);
28
- }, D = (r, t, c) => {
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: re(b.processStatus) };
31
- return p.set(o, b), o;
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, c)) {
34
- m(r, "skip");
33
+ if (!e.setVirtualPageData(n, r, t.total, p)) {
34
+ h(r, "skip");
35
35
  return;
36
36
  }
37
- f = t.total;
37
+ v = t.total;
38
38
  try {
39
- C = Q({ rows: e.getTableData() ?? [], total: f }, Number.MAX_SAFE_INTEGER).rows.map((b) => p.get(b) ?? b);
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, C = [], v = void 0, R && clearTimeout(R), R = void 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
- v && v.total !== f && (v = void 0), u.delete(r);
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, f - 1)), m(r, "success", t.rows.length);
48
- }, $ = () => {
49
- if (k || R) return;
50
- const r = [...d.values()].filter((t) => !t.running && !t.finished).sort((t, c) => Math.abs(t.page - i) - Math.abs(c.page - i) || t.page - c.page);
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 (A.size >= 2) break;
53
- t.running = !0, A.add(t), m(t.page, "start"), (async () => {
52
+ if (I.size >= 2) break;
53
+ t.running = !0, I.add(t), h(t.page, "start"), (async () => {
54
54
  try {
55
- const c = await F({ ...a, page: t.page + 1 }, { signal: t.controller.signal });
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(c, a.pageSize);
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), m(t.page, "error"), e.markPageLoadFailed(t.page, t.request));
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)), A.delete(t), g(), $();
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
- g();
67
- }, x = () => {
68
- R && clearTimeout(R), R = setTimeout(() => {
69
- R = void 0, $();
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), m(r, "skip");
75
+ e.markPageLoadFailed(r, t), h(r, "skip");
76
76
  return;
77
77
  }
78
- const c = d.get(r);
79
- if (c?.request === t && !c.finished) return;
80
- if (c && N(c), l(r), r === 0 && v) {
81
- const b = v;
82
- v = void 0;
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), m(r, "error");
86
+ u.add(r), e.markPageLoadFailed(r, t), h(r, "error");
87
87
  }
88
- g();
88
+ f();
89
89
  return;
90
90
  }
91
91
  const n = { page: r, request: t, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
92
- } }, K = () => {
93
- N(n), g();
92
+ } }, W = () => {
93
+ N(n), f();
94
94
  };
95
- t.signal.addEventListener("abort", K, { once: !0 }), n.removeAbort = () => t.signal.removeEventListener("abort", K), d.set(r, n), x(), g();
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 && x(), g());
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(), g());
108
+ u.size !== 0 && (u.clear(), B(), f());
109
109
  }
110
110
  },
111
111
  dispose() {
112
- k = !0, R && clearTimeout(R), R = void 0;
112
+ k = !0, T && clearTimeout(T), T = void 0;
113
113
  for (const r of d.values()) N(r);
114
- C = [], u.clear(), v = void 0;
114
+ P = [], u.clear(), m = void 0;
115
115
  }
116
116
  };
117
117
  }, fe = [
118
- { key: "applicationNo", title: "申请单编号", width: 260 },
119
- { key: "applicationType", title: "申请单类型", width: 180 },
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: (h) => {
132
- a.current = { query: e.query, position: h };
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: h, provider: F, themeKey: W, onOpen: B, onReload: O, logger: z, restoreScroll: d, rememberScroll: A }) => {
137
- const C = M(null), p = M(null), u = M(null), [v, f] = V(!1), [i, k] = V(0), [S, R] = 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 };
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 = C.current;
141
+ const l = P.current;
143
142
  if (!l) return;
144
- let D = !1, $, x, r, t = a.total;
145
- I(g.current.logger, { operation: "table", phase: "start" });
146
- const c = () => {
147
- D || (f(!0), I(g.current.logger, { operation: "table", phase: "error" }));
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 K = () => {
152
- const o = p.current, y = o?.getScrollState();
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
- }, 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
- if (p.current) {
170
- p.current.updateProps({ canvasWidth: o, canvasHeight: y, style: Z, virtualOptions: q }), p.current.updateCanvasSize(o, y, !0), K();
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
- p.current = new n.CanvasTableComponent(l, {
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, P) => P + 1 },
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: P, height: Y, rowData: G }) => {
192
- const se = G?.id, _ = new n.RectShape({ name: "approval-open", x: P, y: Y / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
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((le) => le.id === se);
200
- ee && g.current.onOpen(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 = p.current, X = ue({
204
+ const H = i.current, X = ue({
206
205
  table: H,
207
- query: h,
206
+ query: g,
208
207
  initialPage: a,
209
208
  // 公开滚动同步事件会重新检测缺页,不移动视口,也不复用失败身份。
210
- retryViewport: K,
211
- onReload: () => g.current.onReload(),
212
- loadPage: (w, P) => g.current.provider.loadPage(w, P),
213
- logger: (w) => I(g.current.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, R((P) => P.total === w.total && P.failed === w.failed && P.loading === w.loading && P.rows.length === w.rows.length && P.rows.every((Y, G) => Y === w.rows[G]) ? P : w));
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, x = n.globalEventBus.onWithNamespace("data:load", H.tableId, (w, P) => X.load(w, P)), 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" });
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
- c();
219
+ p();
221
220
  }
222
221
  };
223
- N.current = b, $ = new ResizeObserver(b), $.observe(l), b();
224
- }).catch(c), () => {
225
- D = !0, $?.disconnect(), N.current = () => {
226
- }, p.current && (m.current = p.current.getScrollState(), m.current && g.current.rememberScroll(m.current)), x?.(), r?.(), u.current?.dispose(), u.current = null, p.current?.destroy(), p.current = null, I(g.current.logger, { operation: "table", phase: "destroy" });
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, h, i]), j(() => {
227
+ }, [a, g, c]), j(() => {
229
228
  N.current();
230
- }, [W]), /* @__PURE__ */ T("div", { className: "make-app-approval-table-frame", "aria-busy": S.loading, children: [
231
- /* @__PURE__ */ s("div", { ref: C, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
232
- v && /* @__PURE__ */ T("div", { className: "make-app-approval-overlay", role: "alert", children: [
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
- f(!1), k((l) => l + 1);
234
+ v(!1), k((l) => l + 1);
236
235
  }, children: "重新加载表格" })
237
236
  ] }),
238
- !v && S.failed && /* @__PURE__ */ T("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
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
- !v && !S.failed && S.loading && /* @__PURE__ */ T("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
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__ */ T("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
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__ */ T("li", { children: [
249
- /* @__PURE__ */ T("span", { children: [
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__ */ T(e, { htmlType: "button", variant: "text", onClick: () => B(l), children: [
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, h, F) => {
270
- const [W, B] = V(0), [O, z] = V(), d = M({ provider: e, logger: F });
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 A = ie(() => ({}), [a, h, W]);
269
+ const I = le(() => ({}), [a, g, $]);
273
270
  j(() => {
274
- const p = 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
- let i = !1;
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
- const k = await u.loadPage(a, { signal: p.signal });
280
- if (p.signal.aborted) return;
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
- i = !0, z({ ...S, token: A, status: "success" }), I(v, { ...f, phase: "success", rowCount: S.rows.length });
280
+ c = !0, C({ ...S, token: I, status: "success" }), A(m, { ...v, phase: "success", rowCount: S.rows.length });
283
281
  } catch {
284
- if (p.signal.aborted) return;
285
- i = !0, z({ token: A, status: "error", rows: me, total: 0 }), I(v, { ...f, phase: "error" });
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
- p.abort(), i || I(v, { ...f, phase: "cancel" });
286
+ i.abort(), c || A(m, { ...v, phase: "cancel" });
289
287
  };
290
- }, [a, A]);
291
- const C = O?.token === A ? O : void 0;
288
+ }, [a, I]);
289
+ const P = O?.token === I ? O : void 0;
292
290
  return {
293
- initialPage: C?.status === "success" ? C : void 0,
294
- total: C?.total ?? 0,
295
- status: C?.status ?? "loading",
296
- reload: () => B((p) => p + 1)
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: "待我处理" }, { value: "approved", label: "已审批" }], ae = (e) => {
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: h, statusOptions: F = [], pageSize: W = 20, refreshKey: B, themeKey: O, logger: z, className: d }) => {
304
- const { Input: A, Select: C, DateRangePicker: p, Button: u, Tabs: v } = e, f = ce(), [i, k] = V(U), [S, R] = 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), c = M(!0);
305
- j(() => (c.current = !0, () => {
306
- c.current = !1;
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 = x === "loading", K = async (o) => {
306
+ const n = K === "loading", W = async (o) => {
309
307
  if (!t.current) {
310
- t.current = !0, N(""), I(z, { operation: "open", phase: "start" });
308
+ t.current = !0, N(""), A(C, { operation: "open", phase: "start" });
311
309
  try {
312
- await h(o), I(z, { operation: "open", phase: "success" });
310
+ await g(o), A(C, { operation: "open", phase: "success" });
313
311
  } catch {
314
- c.current && N("审批详情打开失败,请重试"), I(z, { operation: "open", phase: "error" });
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 && (m(""), N(""), D((y) => ({ ...y, tab: o, page: 1 })));
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__ */ T(v, { items: be, value: l.tab, onChange: b, ariaLabel: "审批分类", children: [
323
- /* @__PURE__ */ T("form", { className: "make-app-approval-filters", onSubmit: (o) => {
324
- if (o.preventDefault(), !ae(i.startDate) || !ae(i.endDate)) {
325
- m("请选择有效日期");
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 (i.startDate && i.endDate && i.startDate > i.endDate) {
329
- m("开始日期不能晚于结束日期");
326
+ if (c.startDate && c.endDate && c.startDate > c.endDate) {
327
+ h("开始日期不能晚于结束日期");
330
328
  return;
331
329
  }
332
- m(""), N(""), D((y) => ({ ...y, ...i, keyword: i.keyword.trim(), page: 1 }));
330
+ h(""), N(""), D((y) => ({ ...y, ...c, keyword: c.keyword.trim(), page: 1 }));
333
331
  }, children: [
334
- /* @__PURE__ */ T("div", { className: "make-app-approval-filter-field", children: [
335
- /* @__PURE__ */ s("label", { htmlFor: `${f}-keyword`, children: "申请单号或申请人" }),
336
- /* @__PURE__ */ s(A, { id: `${f}-keyword`, ariaLabel: "申请单号或申请人", placeholder: "搜索申请单号、申请人", value: i.keyword, onChange: (o) => k((y) => ({ ...y, keyword: o })) })
337
- ] }),
338
- /* @__PURE__ */ T("div", { className: "make-app-approval-filter-field", children: [
339
- /* @__PURE__ */ s("label", { htmlFor: `${f}-status`, children: "流程状态" }),
340
- /* @__PURE__ */ s(C, { id: `${f}-status`, ariaLabel: "流程状态", value: i.processStatus, options: [{ value: "", label: "全部流程状态" }, ...F], onChange: (o) => k((y) => ({ ...y, processStatus: o })) })
341
- ] }),
342
- /* @__PURE__ */ T("fieldset", { className: "make-app-approval-date-field", children: [
343
- /* @__PURE__ */ s("legend", { children: "申请时间" }),
344
- /* @__PURE__ */ s("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ s(
345
- p,
346
- {
347
- id: `${f}-period`,
348
- ariaLabel: "申请时间",
349
- placeholder: ["开始日期", "结束日期"],
350
- value: [i.startDate, i.endDate],
351
- onChange: ([o, y]) => k((E) => ({ ...E, startDate: o, endDate: y }))
352
- },
353
- S
354
- ) })
355
- ] }),
356
- /* @__PURE__ */ T("div", { className: "make-app-approval-filter-actions", children: [
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), R((o) => o + 1), m(""), N(""), D((o) => ({ ...o, ...U, page: 1 }));
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
- g && /* @__PURE__ */ s("p", { role: "alert", className: "make-app-approval-error", children: g }),
366
- /* @__PURE__ */ T("div", { className: "make-app-approval-results", "aria-busy": n, children: [
367
- /* @__PURE__ */ s(ge, { components: e, initialPage: $, query: l, provider: a, onOpen: (o) => {
368
- K(o);
369
- }, onReload: r, themeKey: O, logger: z }),
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
- x === "error" && /* @__PURE__ */ T("div", { className: "make-app-approval-overlay", role: "alert", children: [
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 h of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
381
- if (!e.components?.[h]) throw new Error(`MyApprovalsPage requires components.${h}`);
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
  };