@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/dist/list.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { jsx as n, jsxs as N } from "react/jsx-runtime";
2
- import { useRef as E, useState as x, useEffect as j, useMemo as ie, useId as ce } from "react";
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((m) => m.id)).size !== e.rows.length)
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: m, loadPage: F, onChange: H, retryViewport: $, onReload: B, logger: R }) => {
15
- const f = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Set();
16
- let T = [];
17
- const i = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Set();
18
- let b = m, d = m.total, c = 0, k = !1, S = !1, w;
19
- const M = (r) => Number.isSafeInteger(r) && r >= 0 && r * a.pageSize < d, v = (r, t, g) => I(R, { operation: "list", phase: t, tab: a.tab, page: r + 1, pageSize: a.pageSize, rowCount: g }), p = () => {
20
- k || H({ total: d, rows: T, failed: S || h.size > 0, loading: f.size > 0 });
21
- }, C = (r) => {
22
- r.finished || (r.finished = !0, r.removeAbort(), f.get(r.page) === r && f.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), v(r.page, "cancel"));
23
- }, u = (r) => {
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() ?? [], g = new Set([c, ...t].flatMap((s) => [s - 1, s, s + 1]).filter(M));
26
- for (const s of f.values()) g.has(s.page) || C(s);
27
- for (const s of h) g.has(s) || h.delete(s);
28
- }, D = (r, t, g) => {
29
- const s = t.rows.map((o) => {
30
- const A = { ...o, statusLabel: re(o.processStatus) };
31
- return i.set(A, o), A;
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(s, r, t.total, g)) {
34
- v(r, "skip");
33
+ if (!e.setVirtualPageData(n, r, t.total, p)) {
34
+ m(r, "skip");
35
35
  return;
36
36
  }
37
- d = t.total;
37
+ f = t.total;
38
38
  try {
39
- T = Q({ rows: e.getTableData() ?? [], total: d }, Number.MAX_SAFE_INTEGER).rows.map((o) => i.get(o) ?? o);
40
- } catch (o) {
41
- S = !0, T = [], b = void 0, w && clearTimeout(w), w = void 0;
42
- for (const A of f.values()) C(A);
43
- throw o;
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
- b && b.total !== d && (b = void 0), h.delete(r);
46
- for (const o of f.values()) M(o.page) || C(o);
47
- !M(r) && r > 0 && e.scrollToRow(Math.max(0, d - 1)), v(r, "success", t.rows.length);
48
- }, L = () => {
49
- if (k || w) return;
50
- const r = [...f.values()].filter((t) => !t.running && !t.finished).sort((t, g) => Math.abs(t.page - c) - Math.abs(g.page - c) || t.page - g.page);
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 (z.size >= 2) break;
53
- t.running = !0, z.add(t), v(t.page, "start"), (async () => {
52
+ if (A.size >= 2) break;
53
+ t.running = !0, A.add(t), m(t.page, "start"), (async () => {
54
54
  try {
55
- const g = 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 s = Q(g, a.pageSize);
58
- t.finished = !0, t.removeAbort(), f.delete(t.page), D(t.page, s, t.request);
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 && (h.add(t.page), v(t.page, "error"), e.markPageLoadFailed(t.page, t.request));
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(), f.get(t.page) === t && f.delete(t.page)), z.delete(t), p(), L();
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
- p();
67
- }, O = () => {
68
- w && clearTimeout(w), w = setTimeout(() => {
69
- w = void 0, L();
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 || !M(r)) {
75
- e.markPageLoadFailed(r, t), v(r, "skip");
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 g = f.get(r);
79
- if (g?.request === t && !g.finished) return;
80
- if (g && C(g), u(r), r === 0 && b) {
81
- const o = b;
82
- b = 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 && v) {
81
+ const b = v;
82
+ v = void 0;
83
83
  try {
84
- D(0, o, t);
84
+ D(0, b, t);
85
85
  } catch {
86
- h.add(r), e.markPageLoadFailed(r, t), v(r, "error");
86
+ u.add(r), e.markPageLoadFailed(r, t), m(r, "error");
87
87
  }
88
- p();
88
+ g();
89
89
  return;
90
90
  }
91
- const s = { page: r, request: t, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
92
- } }, l = () => {
93
- C(s), p();
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", l, { once: !0 }), s.removeAbort = () => t.signal.removeEventListener("abort", l), f.set(r, s), O(), p();
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 && (u(r[0]), f.size && O(), p());
100
+ r?.length && (l(r[0]), d.size && x(), g());
101
101
  },
102
102
  retry() {
103
103
  if (!k) {
104
104
  if (S) {
105
- B();
105
+ O();
106
106
  return;
107
107
  }
108
- h.size !== 0 && (h.clear(), $(), p());
108
+ u.size !== 0 && (u.clear(), B(), g());
109
109
  }
110
110
  },
111
111
  dispose() {
112
- k = !0, w && clearTimeout(w), w = void 0;
113
- for (const r of f.values()) C(r);
114
- T = [], h.clear(), b = void 0;
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, he = (e) => {
124
- const a = E(void 0);
125
- return e.initialPage ? /* @__PURE__ */ n(
126
- ge,
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: (m) => {
132
- a.current = { query: e.query, position: m };
131
+ rememberScroll: (h) => {
132
+ a.current = { query: e.query, position: h };
133
133
  }
134
134
  }
135
- ) : /* @__PURE__ */ n("div", { className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" });
136
- }, ge = ({ components: { Button: e }, initialPage: a, query: m, provider: F, themeKey: H, onOpen: $, onReload: B, logger: R, restoreScroll: f, rememberScroll: z }) => {
137
- const T = E(null), i = E(null), h = E(null), [b, d] = x(!1), [c, k] = x(0), [S, w] = x({ ...a, failed: !1, loading: !1 }), M = E(a.rows), v = E(f), p = E({ provider: F, onOpen: $, onReload: B, logger: R, rememberScroll: z });
138
- p.current = { provider: F, onOpen: $, onReload: B, logger: R, rememberScroll: z };
139
- const C = E(() => {
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 u = T.current;
143
- if (!u) return;
144
- let D = !1, L, O, r, t = a.total;
145
- I(p.current.logger, { operation: "table", phase: "start" });
146
- const g = () => {
147
- D || (d(!0), I(p.current.logger, { operation: "table", phase: "error" }));
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((s) => {
149
+ return import("@qfei-design/canvas-table").then((n) => {
150
150
  if (D) return;
151
- const l = () => {
152
- const A = i.current, W = A?.getScrollState();
153
- A && W && s.globalEventBus.emitWithNamespace("scroll:change", A.tableId, W);
154
- }, o = () => {
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: A, height: W } = u.getBoundingClientRect();
158
- if (A <= 0 || W <= 0) return;
159
- const V = getComputedStyle(u), Z = {
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: V.fontFamily || "Arial, sans-serif",
164
- ...V.color ? { textColor: V.color } : {},
165
- ...V.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: V.getPropertyValue("--make-approval-bg").trim() } : {},
166
- ...V.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: V.getPropertyValue("--make-approval-header").trim() } : {},
167
- ...V.getPropertyValue("--make-approval-border").trim() ? { borderColor: V.getPropertyValue("--make-approval-border").trim() } : {}
168
- }, ne = Math.max(Math.ceil(300 / m.pageSize), Math.ceil(W * 3 / te / m.pageSize) + 2) * m.pageSize, q = { enabled: !0, totalRowCount: t, pageSize: m.pageSize, maxCachedRows: ne };
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: A, canvasHeight: W, style: Z, virtualOptions: q }), i.current.updateCanvasSize(A, W, !0), l();
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 s.CanvasTableComponent(u, {
173
+ i.current = new n.CanvasTableComponent(l, {
174
174
  columns: fe,
175
- canvasWidth: A,
176
- canvasHeight: W,
175
+ canvasWidth: o,
176
+ canvasHeight: y,
177
177
  style: Z,
178
178
  rowKey: "id",
179
- showSN: { enabled: !0, width: 64, formatter: (y, P) => P + 1 },
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: (y) => {
185
- y.cancel();
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: y, x: P, height: Y, rowData: G }) => {
192
- const se = G?.id, _ = new s.RectShape({ name: "approval-open", x: P, y: Y / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
193
- _.addChild(new s.ImgShape({ name: "approval-open-icon", x: 3, y: 3, attrs: {
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="${V.color || "#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
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 = M.current.find((le) => le.id === se);
200
- ee && p.current.onOpen(ee);
201
- }), y.addChild(_);
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 K = i.current, X = ue({
206
- table: K,
207
- query: m,
205
+ const H = i.current, X = ue({
206
+ table: H,
207
+ query: h,
208
208
  initialPage: a,
209
209
  // 公开滚动同步事件会重新检测缺页,不移动视口,也不复用失败身份。
210
- retryViewport: l,
211
- onReload: () => p.current.onReload(),
212
- loadPage: (y, P) => p.current.provider.loadPage(y, P),
213
- logger: (y) => I(p.current.logger, y),
214
- onChange: (y) => {
215
- D || (t = y.total, M.current = y.rows, w((P) => P.total === y.total && P.failed === y.failed && P.loading === y.loading && P.rows.length === y.rows.length && P.rows.every((Y, G) => Y === y.rows[G]) ? P : y));
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
- h.current = X, O = s.globalEventBus.onWithNamespace("data:load", K.tableId, (y, P) => X.load(y, P)), r = s.globalEventBus.onWithNamespace("scroll:change", K.tableId, () => X.viewportChanged()), v.current && K.scrollTo(v.current.scrollX, v.current.scrollY), d(!1), I(p.current.logger, { operation: "table", phase: "success" });
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
- g();
220
+ p();
221
221
  }
222
222
  };
223
- C.current = o, L = new ResizeObserver(o), L.observe(u), o();
224
- }).catch(g), () => {
225
- D = !0, L?.disconnect(), C.current = () => {
226
- }, i.current && (v.current = i.current.getScrollState(), v.current && p.current.rememberScroll(v.current)), O?.(), r?.(), h.current?.dispose(), h.current = null, i.current?.destroy(), i.current = null, I(p.current.logger, { operation: "table", phase: "destroy" });
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, m, c]), j(() => {
229
- C.current();
230
- }, [H]), /* @__PURE__ */ N("div", { className: "make-app-approval-table-frame", "aria-busy": S.loading, children: [
231
- /* @__PURE__ */ n("div", { ref: T, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
232
- b && /* @__PURE__ */ N("div", { className: "make-app-approval-overlay", role: "alert", children: [
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__ */ n(e, { htmlType: "button", variant: "default", onClick: () => {
235
- d(!1), k((u) => u + 1);
234
+ /* @__PURE__ */ s(e, { htmlType: "button", variant: "default", onClick: () => {
235
+ f(!1), k((l) => l + 1);
236
236
  }, children: "重新加载表格" })
237
237
  ] }),
238
- !b && S.failed && /* @__PURE__ */ N("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
238
+ !v && S.failed && /* @__PURE__ */ T("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
239
239
  "部分审批记录加载失败 ",
240
- /* @__PURE__ */ n(e, { htmlType: "button", variant: "default", onClick: () => h.current?.retry(), children: "重试加载" })
240
+ /* @__PURE__ */ s(e, { htmlType: "button", variant: "default", onClick: () => u.current?.retry(), children: "重试加载" })
241
241
  ] }),
242
- !b && !S.failed && S.loading && /* @__PURE__ */ N("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
243
- /* @__PURE__ */ n("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
244
- /* @__PURE__ */ n("span", { children: "加载中" })
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__ */ N("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
247
- S.total === 0 && /* @__PURE__ */ n("li", { children: "暂无审批记录" }),
248
- S.rows.map((u) => /* @__PURE__ */ N("li", { children: [
249
- /* @__PURE__ */ N("span", { children: [
250
- u.applicationNo,
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
- u.applicationType,
252
+ l.applicationType,
253
253
  ",",
254
- u.applicantName,
254
+ l.applicantName,
255
255
  ",",
256
- u.applicationTime,
256
+ l.applicationTime,
257
257
  ",",
258
- re(u.processStatus),
258
+ re(l.processStatus),
259
259
  "。"
260
260
  ] }),
261
- /* @__PURE__ */ N(e, { htmlType: "button", variant: "text", onClick: () => $(u), children: [
261
+ /* @__PURE__ */ T(e, { htmlType: "button", variant: "text", onClick: () => B(l), children: [
262
262
  "打开 ",
263
- u.applicationNo || u.applicationType,
263
+ l.applicationNo || l.applicationType,
264
264
  " 的审批详情"
265
265
  ] })
266
- ] }, u.id))
266
+ ] }, l.id))
267
267
  ] })
268
268
  ] });
269
- }, me = [], ve = (e, a, m, F) => {
270
- const [H, $] = x(0), [B, R] = x(), f = E({ provider: e, logger: F });
271
- f.current = { provider: e, logger: F };
272
- const z = ie(() => ({}), [a, m, H]);
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: h, logger: b } = f.current, d = { operation: "list", tab: a.tab, page: a.page, pageSize: a.pageSize };
275
- I(b, { ...d, phase: "start" });
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
- const k = await h.loadPage(a, { signal: i.signal });
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, R({ ...S, token: z, status: "success" }), I(b, { ...d, phase: "success", rowCount: S.rows.length });
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, R({ token: z, status: "error", rows: me, total: 0 }), I(b, { ...d, phase: "error" });
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(b, { ...d, phase: "cancel" });
289
+ i.abort(), c || I(v, { ...f, phase: "cancel" });
289
290
  };
290
- }, [a, z]);
291
- const T = B?.token === z ? B : void 0;
291
+ }, [a, A]);
292
+ const R = O?.token === A ? O : void 0;
292
293
  return {
293
- initialPage: T?.status === "success" ? T : void 0,
294
- total: T?.total ?? 0,
295
- status: T?.status ?? "loading",
296
- reload: () => $((i) => i + 1)
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: m, statusOptions: F = [], pageSize: H = 20, refreshKey: $, themeKey: B, logger: R, className: f }) => {
304
- const { Input: z, Select: T, DatePicker: i, Button: h, Tabs: b } = e, d = ce(), [c, k] = x(U), [S, w] = x(""), [M, v] = x(""), [p, C] = x({ ...U, tab: "pending", page: 1, pageSize: H }), { initialPage: u, status: D, reload: L } = ve(a, p, $, R), O = E(!1), r = E(!0);
305
- j(() => (r.current = !0, () => {
306
- r.current = !1;
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 t = D === "loading", g = async (l) => {
309
- if (!O.current) {
310
- O.current = !0, v(""), I(R, { operation: "open", phase: "start" });
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 m(l), I(R, { operation: "open", phase: "success" });
313
+ await h(o), I(z, { operation: "open", phase: "success" });
313
314
  } catch {
314
- r.current && v("审批详情打开失败,请重试"), I(R, { operation: "open", phase: "error" });
315
+ p.current && N("审批详情打开失败,请重试"), I(z, { operation: "open", phase: "error" });
315
316
  } finally {
316
- O.current = !1;
317
+ t.current = !1;
317
318
  }
318
319
  }
319
- }, s = (l) => {
320
- l !== p.tab && (w(""), v(""), C((o) => ({ ...o, tab: l, page: 1 })));
320
+ }, b = (o) => {
321
+ o !== l.tab && (m(""), N(""), D((y) => ({ ...y, tab: o, page: 1 })));
321
322
  };
322
- return /* @__PURE__ */ n("section", { className: ["make-app-approval", f].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */ N(b, { items: be, value: p.tab, onChange: s, ariaLabel: "审批分类", children: [
323
- /* @__PURE__ */ N("form", { className: "make-app-approval-filters", onSubmit: (l) => {
324
- if (l.preventDefault(), !ae(c.startDate) || !ae(c.endDate)) {
325
- w("请选择有效日期");
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
- w("开始日期不能晚于结束日期");
330
+ m("开始日期不能晚于结束日期");
330
331
  return;
331
332
  }
332
- w(""), v(""), C((o) => ({ ...o, ...c, keyword: c.keyword.trim(), page: 1 }));
333
+ m(""), N(""), D((y) => ({ ...y, ...c, keyword: c.keyword.trim(), page: 1 }));
333
334
  }, children: [
334
- /* @__PURE__ */ N("div", { className: "make-app-approval-filter-field", children: [
335
- /* @__PURE__ */ n("label", { htmlFor: `${d}-keyword`, children: "申请单号或申请人" }),
336
- /* @__PURE__ */ n(z, { id: `${d}-keyword`, ariaLabel: "申请单号或申请人", placeholder: "搜索申请单号、申请人", value: c.keyword, onChange: (l) => k((o) => ({ ...o, keyword: l })) })
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__ */ N("div", { className: "make-app-approval-filter-field", children: [
339
- /* @__PURE__ */ n("label", { htmlFor: `${d}-status`, children: "流程状态" }),
340
- /* @__PURE__ */ n(T, { id: `${d}-status`, ariaLabel: "流程状态", value: c.processStatus, options: [{ value: "", label: "全部流程状态" }, ...F], onChange: (l) => k((o) => ({ ...o, processStatus: l })) })
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__ */ N("fieldset", { className: "make-app-approval-date-field", children: [
343
- /* @__PURE__ */ n("legend", { children: "申请时间" }),
344
- /* @__PURE__ */ N("div", { className: "make-app-approval-date-range", children: [
345
- /* @__PURE__ */ n("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ n(i, { id: `${d}-start`, ariaLabel: "申请开始日期", placeholder: "开始日期", value: c.startDate, onChange: (l) => k((o) => ({ ...o, startDate: l })) }) }),
346
- /* @__PURE__ */ n("span", { children: "至" }),
347
- /* @__PURE__ */ n("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ n(i, { id: `${d}-end`, ariaLabel: "申请结束日期", placeholder: "结束日期", value: c.endDate, onChange: (l) => k((o) => ({ ...o, endDate: l })) }) })
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__ */ N("div", { className: "make-app-approval-filter-actions", children: [
351
- /* @__PURE__ */ n(h, { htmlType: "submit", variant: "primary", children: "查询" }),
352
- /* @__PURE__ */ n(h, { htmlType: "button", variant: "default", onClick: () => {
353
- k(U), w(""), v(""), C((l) => ({ ...l, ...U, page: 1 }));
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__ */ n(h, { htmlType: "button", variant: "default", disabled: t, loading: t, onClick: L, children: "刷新" })
362
+ /* @__PURE__ */ s(u, { htmlType: "button", variant: "default", disabled: n, loading: n, onClick: r, children: "刷新" })
356
363
  ] })
357
364
  ] }),
358
- S && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: S }),
359
- M && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: M }),
360
- /* @__PURE__ */ N("div", { className: "make-app-approval-results", "aria-busy": t, children: [
361
- /* @__PURE__ */ n(he, { components: e, initialPage: u, query: p, provider: a, onOpen: (l) => {
362
- g(l);
363
- }, onReload: L, themeKey: B, logger: R }),
364
- t && /* @__PURE__ */ n("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
365
- D === "error" && /* @__PURE__ */ N("div", { className: "make-app-approval-overlay", role: "alert", children: [
366
- /* @__PURE__ */ n("span", { children: "审批列表加载失败,请重试" }),
367
- /* @__PURE__ */ n(h, { htmlType: "button", variant: "default", onClick: L, children: "重试" })
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 m of ["Input", "Select", "DatePicker", "Button", "Tabs"])
375
- if (!e.components?.[m]) throw new Error(`MyApprovalsPage requires components.${m}`);
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__ */ n(we, { ...e, pageSize: a }, JSON.stringify([e.scopeKey, a]));
384
+ return /* @__PURE__ */ s(we, { ...e, pageSize: a }, JSON.stringify([e.scopeKey, a]));
378
385
  };
379
386
  export {
380
387
  Ne as MyApprovalsPage