@qfei-design/make-app-approval 0.2.12 → 0.2.13

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,80 +1,84 @@
1
- import { jsxs as T, jsx as n } from "react/jsx-runtime";
2
- import { useState as L, useRef as V, useEffect as J, useMemo as me, useId as ge } from "react";
3
- import { getApprovalStatusDisplay as fe } from "./index.mjs";
4
- const de = (e) => typeof e == "object" && e !== null, ve = (e) => de(e) ? ["id", "entityKey", "recordId"].every((t) => typeof e[t] == "string" && e[t].trim().length > 0) && ["applicationNo", "applicationType", "applicantName", "applicationTime"].every((t) => typeof e[t] == "string") && ["taskId", "processInstanceId"].every((t) => e[t] === void 0 || typeof e[t] == "string" && e[t].trim().length > 0) && ["completionTime", "completionResult"].every((t) => e[t] === void 0 || typeof e[t] == "string") && (typeof e.processStatus == "string" || e.processStatus === null) : !1, ee = (e, t) => {
5
- if (!de(e) || !Array.isArray(e.rows) || !e.rows.every(ve) || typeof e.total != "number" || !Number.isSafeInteger(e.total) || e.total < 0 || e.rows.length > t || e.rows.length > e.total || new Set(e.rows.map((h) => h.id)).size !== e.rows.length)
1
+ import { jsxs as N, jsx as n } from "react/jsx-runtime";
2
+ import { useState as D, useRef as O, useEffect as J, useMemo as be, useId as we } from "react";
3
+ import { getApprovalStatusDisplay as ke } from "./index.mjs";
4
+ const ue = (e) => typeof e == "object" && e !== null, ye = (e) => ue(e) ? ["id", "entityKey", "recordId"].every((t) => typeof e[t] == "string" && e[t].trim().length > 0) && ["applicationNo", "applicationType", "applicantName", "applicationTime"].every((t) => typeof e[t] == "string") && ["taskId", "processInstanceId"].every((t) => e[t] === void 0 || typeof e[t] == "string" && e[t].trim().length > 0) && ["completionTime", "completionResult"].every((t) => e[t] === void 0 || typeof e[t] == "string") && (e.referenceType === void 0 || e.referenceType === "task" || e.referenceType === "instance") && (e.referenceType !== "instance" || typeof e.processInstanceId == "string" && e.processInstanceId.trim().length > 0) && (typeof e.processStatus == "string" || e.processStatus === null) : !1, ee = (e, t) => {
5
+ if (!ue(e) || !Array.isArray(e.rows) || !e.rows.every(ye) || typeof e.total != "number" || !Number.isSafeInteger(e.total) || e.total < 0 || e.rows.length > t || e.rows.length > e.total || new Set(e.rows.map((l) => l.id)).size !== e.rows.length)
6
6
  throw new Error("Invalid approval page contract");
7
7
  return { rows: e.rows, total: e.total };
8
- }, I = (e, t) => {
8
+ }, A = (e, t) => {
9
9
  try {
10
10
  e ? e(t) : t.phase === "error" ? console.warn("[make-app-approval]", t) : console.info("[make-app-approval]", t);
11
11
  } catch {
12
12
  console.warn("[make-app-approval] diagnostic sink failed");
13
13
  }
14
- }, be = ({ initialPage: e, query: t, provider: h, components: H, onOpen: j, onReload: B, logger: E }) => {
15
- const [g, w] = L(e), [f, z] = L(2), [d, N] = L("idle"), s = V(void 0), [M, R] = L(!1), c = V(void 0);
14
+ }, ne = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : ke(e).label, Se = ({ initialPage: e, query: t, provider: l, components: P, onOpen: H, onReload: I, logger: E }) => {
15
+ const [g, y] = D(e), [b, x] = D(2), [p, T] = D("idle"), h = O(void 0), [S, L] = D(!1), C = O(void 0);
16
16
  J(() => () => {
17
- c.current?.abort();
17
+ C.current?.abort();
18
18
  }, []);
19
- const k = async () => {
20
- if (c.current || g.rows.length >= g.total) return;
19
+ const c = async () => {
20
+ if (C.current || g.rows.length >= g.total) return;
21
21
  const o = new AbortController();
22
- c.current = o, N("loading");
23
- const l = { operation: "list", tab: t.tab, page: f, pageSize: t.pageSize };
24
- I(E, { ...l, phase: "start" });
22
+ C.current = o, T("loading");
23
+ const u = { operation: "list", tab: t.tab, page: b, pageSize: t.pageSize };
24
+ A(E, { ...u, phase: "start" });
25
25
  try {
26
- const y = ee(await h.loadPage({ ...t, page: f }, { signal: o.signal }), t.pageSize);
26
+ const d = ee(await l.loadPage({ ...t, page: b }, { signal: o.signal }), t.pageSize);
27
27
  if (o.signal.aborted) return;
28
- if (y.total < g.total) {
29
- I(E, { ...l, phase: "skip", rowCount: y.rows.length }), B();
28
+ if (d.total < g.total) {
29
+ A(E, { ...u, phase: "skip", rowCount: d.rows.length }), I();
30
30
  return;
31
31
  }
32
- const p = new Set(g.rows.map((C) => C.id));
33
- if (!y.rows.length || y.rows.some((C) => p.has(C.id))) throw new Error("Invalid append page");
34
- w({ rows: [...g.rows, ...y.rows], total: y.total }), z((C) => C + 1), N("idle"), I(E, { ...l, phase: "success", rowCount: y.rows.length });
32
+ const m = new Set(g.rows.map((M) => M.id));
33
+ if (!d.rows.length || d.rows.some((M) => m.has(M.id))) throw new Error("Invalid append page");
34
+ y({ rows: [...g.rows, ...d.rows], total: d.total }), x((M) => M + 1), T("idle"), A(E, { ...u, phase: "success", rowCount: d.rows.length });
35
35
  } catch {
36
- o.signal.aborted || (N("error"), I(E, { ...l, phase: "error" }));
36
+ o.signal.aborted || (T("error"), A(E, { ...u, phase: "error" }));
37
37
  } finally {
38
- c.current === o && (c.current = void 0);
38
+ C.current === o && (C.current = void 0);
39
39
  }
40
- }, x = (o) => {
41
- const { scrollHeight: l, scrollTop: y, clientHeight: p } = o.currentTarget;
42
- d === "idle" && l - y - p < 120 && k();
43
- }, { Button: O } = H;
44
- return /* @__PURE__ */ T(
40
+ }, R = (o) => {
41
+ const { scrollHeight: u, scrollTop: d, clientHeight: m } = o.currentTarget;
42
+ p === "idle" && u - d - m < 120 && c();
43
+ }, { Button: V } = P;
44
+ return /* @__PURE__ */ N(
45
45
  "div",
46
46
  {
47
47
  className: "make-app-approval-mobile-list",
48
- onScroll: x,
48
+ onScroll: R,
49
49
  onTouchStart: (o) => {
50
- s.current = o.currentTarget.scrollTop <= 0 && o.touches.length === 1 && d !== "loading" ? { start: o.touches[0].clientY, distance: 0 } : void 0;
50
+ h.current = o.currentTarget.scrollTop <= 0 && o.touches.length === 1 && p !== "loading" ? { start: o.touches[0].clientY, distance: 0 } : void 0;
51
51
  },
52
52
  onTouchMove: (o) => {
53
- !s.current || o.touches.length !== 1 || (s.current.distance = o.touches[0].clientY - s.current.start, R(s.current.distance >= 60));
53
+ !h.current || o.touches.length !== 1 || (h.current.distance = o.touches[0].clientY - h.current.start, L(h.current.distance >= 60));
54
54
  },
55
55
  onTouchEnd: () => {
56
- const o = (s.current?.distance ?? 0) >= 60;
57
- s.current = void 0, R(!1), o && B();
56
+ const o = (h.current?.distance ?? 0) >= 60;
57
+ h.current = void 0, L(!1), o && I();
58
58
  },
59
59
  onTouchCancel: () => {
60
- s.current = void 0, R(!1);
60
+ h.current = void 0, L(!1);
61
61
  },
62
62
  "aria-label": "审批卡片列表",
63
- "aria-busy": d === "loading",
63
+ "aria-busy": p === "loading",
64
64
  children: [
65
- M && /* @__PURE__ */ n("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "松开刷新" }),
66
- g.rows.map((o) => /* @__PURE__ */ T("button", { type: "button", className: "make-app-approval-mobile-card", onClick: () => j(o), "aria-label": `打开 ${o.applicationNo} 的审批详情`, children: [
65
+ S && /* @__PURE__ */ n("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "松开刷新" }),
66
+ g.rows.map((o) => /* @__PURE__ */ N("button", { type: "button", className: "make-app-approval-mobile-card", onClick: () => H(o), "aria-label": `打开 ${o.applicationNo} 的审批详情`, children: [
67
67
  /* @__PURE__ */ n("strong", { children: o.applicationType || "审批申请" }),
68
- /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
68
+ /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-line", children: [
69
69
  /* @__PURE__ */ n("span", { children: "申请单ID:" }),
70
70
  /* @__PURE__ */ n("span", { children: o.applicationNo })
71
71
  ] }),
72
- t.tab === "approved" && /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
72
+ t.tab === "approved" && /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-line", children: [
73
73
  /* @__PURE__ */ n("span", { children: "审批结果:" }),
74
74
  /* @__PURE__ */ n("span", { children: o.completionResult || "—" })
75
75
  ] }),
76
- /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-footer", children: [
77
- /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-person", children: [
76
+ t.tab === "initiated" && /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-line", children: [
77
+ /* @__PURE__ */ n("span", { children: "流程状态:" }),
78
+ /* @__PURE__ */ n("span", { children: ne(o.processStatus) })
79
+ ] }),
80
+ /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-footer", children: [
81
+ /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-person", children: [
78
82
  /* @__PURE__ */ n("span", { className: "make-app-approval-mobile-avatar", "aria-hidden": "true", children: o.applicantName.slice(-2) }),
79
83
  /* @__PURE__ */ n("span", { children: o.applicantName || "—" })
80
84
  ] }),
@@ -82,443 +86,445 @@ const de = (e) => typeof e == "object" && e !== null, ve = (e) => de(e) ? ["id",
82
86
  ] })
83
87
  ] }, o.id)),
84
88
  !g.rows.length && /* @__PURE__ */ n("p", { className: "make-app-approval-mobile-feedback", children: "暂无审批记录" }),
85
- d === "error" ? /* @__PURE__ */ T("div", { role: "alert", className: "make-app-approval-mobile-feedback", children: [
89
+ p === "error" ? /* @__PURE__ */ N("div", { role: "alert", className: "make-app-approval-mobile-feedback", children: [
86
90
  "部分审批记录加载失败",
87
- /* @__PURE__ */ n(O, { htmlType: "button", variant: "text", onClick: () => {
88
- k();
91
+ /* @__PURE__ */ n(V, { htmlType: "button", variant: "text", onClick: () => {
92
+ c();
89
93
  }, children: "重试加载" })
90
- ] }) : d === "loading" ? /* @__PURE__ */ n("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "加载中" }) : g.rows.length < g.total ? /* @__PURE__ */ n(O, { htmlType: "button", variant: "text", onClick: () => {
91
- k();
94
+ ] }) : p === "loading" ? /* @__PURE__ */ n("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "加载中" }) : g.rows.length < g.total ? /* @__PURE__ */ n(V, { htmlType: "button", variant: "text", onClick: () => {
95
+ c();
92
96
  }, children: "加载更多" }) : g.rows.length > 0 && /* @__PURE__ */ n("p", { className: "make-app-approval-mobile-feedback", children: "没有更多了" })
93
97
  ]
94
98
  }
95
99
  );
96
- }, we = {
100
+ }, Ne = {
97
101
  applicationNo: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-fingerprint-pattern" aria-hidden="true"><path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"></path><path d="M14 13.12c0 2.38 0 6.38-1 8.88"></path><path d="M17.29 21.02c.12-.6.43-2.3.5-3.02"></path><path d="M2 12a10 10 0 0 1 18-6"></path><path d="M2 16h.01"></path><path d="M21.8 16c.2-2 .131-5.354 0-6"></path><path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"></path><path d="M8.65 22c.21-.66.45-1.32.57-2"></path><path d="M9 6.8a6 6 0 0 1 9 5.2v2"></path></svg>',
98
102
  applicationType: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-type" aria-hidden="true"><path d="M12 4v16"></path><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"></path><path d="M9 20h6"></path></svg>',
99
103
  applicantName: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-round" aria-hidden="true"><circle cx="12" cy="8" r="5"></circle><path d="M20 21a8 8 0 0 0-16 0"></path></svg>',
100
104
  applicationTime: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock" aria-hidden="true"><path d="M16 14v2.2l1.6 1"></path><path d="M16 2v3"></path><path d="M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338"></path><path d="M3 9h5.859"></path><path d="M8 2v3"></path><circle cx="16" cy="16" r="6"></circle></svg>'
101
- }, ke = Object.fromEntries(
102
- Object.entries(we).map(([e, t]) => [e, `data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`])
103
- ), oe = 64, ne = [
105
+ }, ce = Object.fromEntries(
106
+ Object.entries(Ne).map(([e, t]) => [e, `data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`])
107
+ ), oe = 64, pe = [
104
108
  { key: "applicationNo", title: "申请单ID", width: 260 },
105
109
  { key: "applicationType", title: "业务表单", width: 180 },
106
110
  { key: "applicantName", title: "申请人", width: 170 },
107
111
  { key: "applicationTime", title: "申请时间", width: 220 }
108
- ], ye = ne.reduce((e, t) => e + t.width, oe), ce = (e) => {
109
- const t = Math.max(0, e - ye) / ne.length;
110
- return ne.map((h) => ({
111
- ...h,
112
- width: h.width + t,
112
+ ], de = (e, t) => {
113
+ const l = t === "initiated" ? [...pe, { key: "statusLabel", title: "流程状态", width: 140 }] : pe, P = l.reduce((I, E) => I + E.width, oe), H = Math.max(0, e - P) / l.length;
114
+ return l.map((I) => ({
115
+ ...I,
116
+ width: I.width + H,
113
117
  showEllipsis: !0,
114
118
  sortable: !1,
115
- prefixRender: () => ({ icon: ke[h.key] })
119
+ prefixRender: () => ({ icon: ce[I.key] ?? ce.applicationType })
116
120
  }));
117
- }, Se = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : fe(e).label, Ne = ({ table: e, query: t, initialPage: h, loadPage: H, onChange: j, retryViewport: B, onReload: E, logger: g }) => {
118
- const w = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set();
119
- let z = [];
120
- const d = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new Set();
121
- let s = h, M = h.total, R = 0, c = !1, k = !1, x;
122
- const O = (r) => Number.isSafeInteger(r) && r >= 0 && r * t.pageSize < M, o = (r, a, u) => I(g, { operation: "list", phase: a, tab: t.tab, page: r + 1, pageSize: t.pageSize, rowCount: u }), l = () => {
123
- c || j({ total: M, rows: z, failed: k || N.size > 0, loading: w.size > 0 });
124
- }, y = (r) => {
125
- r.finished || (r.finished = !0, r.removeAbort(), w.get(r.page) === r && w.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), o(r.page, "cancel"));
126
- }, p = (r) => {
127
- R = r;
128
- const a = e.getPagesInView() ?? [], u = new Set([R, ...a].flatMap((v) => [v - 1, v, v + 1]).filter(O));
129
- for (const v of w.values()) u.has(v.page) || y(v);
130
- for (const v of N) u.has(v) || N.delete(v);
131
- }, C = (r, a, u) => {
132
- const v = a.rows.map((S) => {
133
- const K = { ...S, statusLabel: Se(S.processStatus) };
134
- return d.set(K, S), K;
121
+ }, Te = ({ table: e, query: t, initialPage: l, loadPage: P, onChange: H, retryViewport: I, onReload: E, logger: g }) => {
122
+ const y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
123
+ let x = [];
124
+ const p = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new Set();
125
+ let h = l, S = l.total, L = 0, C = !1, c = !1, R;
126
+ const V = (r) => Number.isSafeInteger(r) && r >= 0 && r * t.pageSize < S, o = (r, a, f) => A(g, { operation: "list", phase: a, tab: t.tab, page: r + 1, pageSize: t.pageSize, rowCount: f }), u = () => {
127
+ C || H({ total: S, rows: x, failed: c || T.size > 0, loading: y.size > 0 });
128
+ }, d = (r) => {
129
+ r.finished || (r.finished = !0, r.removeAbort(), y.get(r.page) === r && y.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), o(r.page, "cancel"));
130
+ }, m = (r) => {
131
+ L = r;
132
+ const a = e.getPagesInView() ?? [], f = new Set([L, ...a].flatMap((w) => [w - 1, w, w + 1]).filter(V));
133
+ for (const w of y.values()) f.has(w.page) || d(w);
134
+ for (const w of T) f.has(w) || T.delete(w);
135
+ }, M = (r, a, f) => {
136
+ const w = a.rows.map((v) => {
137
+ const W = { ...v, statusLabel: ne(v.processStatus) };
138
+ return p.set(W, v), W;
135
139
  });
136
- if (!e.setVirtualPageData(v, r, a.total, u)) {
140
+ if (!e.setVirtualPageData(w, r, a.total, f)) {
137
141
  o(r, "skip");
138
142
  return;
139
143
  }
140
- M = a.total;
144
+ S = a.total;
141
145
  try {
142
- z = ee({ rows: e.getTableData() ?? [], total: M }, Number.MAX_SAFE_INTEGER).rows.map((S) => d.get(S) ?? S);
143
- } catch (S) {
144
- k = !0, z = [], s = void 0, x && clearTimeout(x), x = void 0;
145
- for (const K of w.values()) y(K);
146
- throw S;
146
+ x = ee({ rows: e.getTableData() ?? [], total: S }, Number.MAX_SAFE_INTEGER).rows.map((v) => p.get(v) ?? v);
147
+ } catch (v) {
148
+ c = !0, x = [], h = void 0, R && clearTimeout(R), R = void 0;
149
+ for (const W of y.values()) d(W);
150
+ throw v;
147
151
  }
148
- s && s.total !== M && (s = void 0), N.delete(r);
149
- for (const S of w.values()) O(S.page) || y(S);
150
- !O(r) && r > 0 && e.scrollToRow(Math.max(0, M - 1)), o(r, "success", a.rows.length);
151
- }, D = () => {
152
- if (c || x) return;
153
- const r = [...w.values()].filter((a) => !a.running && !a.finished).sort((a, u) => Math.abs(a.page - R) - Math.abs(u.page - R) || a.page - u.page);
152
+ h && h.total !== S && (h = void 0), T.delete(r);
153
+ for (const v of y.values()) V(v.page) || d(v);
154
+ !V(r) && r > 0 && e.scrollToRow(Math.max(0, S - 1)), o(r, "success", a.rows.length);
155
+ }, B = () => {
156
+ if (C || R) return;
157
+ const r = [...y.values()].filter((a) => !a.running && !a.finished).sort((a, f) => Math.abs(a.page - L) - Math.abs(f.page - L) || a.page - f.page);
154
158
  for (const a of r) {
155
- if (f.size >= 2) break;
156
- a.running = !0, f.add(a), o(a.page, "start"), (async () => {
159
+ if (b.size >= 2) break;
160
+ a.running = !0, b.add(a), o(a.page, "start"), (async () => {
157
161
  try {
158
- const u = await H({ ...t, page: a.page + 1 }, { signal: a.controller.signal });
159
- if (c || a.finished || a.controller.signal.aborted) return;
160
- const v = ee(u, t.pageSize);
161
- a.finished = !0, a.removeAbort(), w.delete(a.page), C(a.page, v, a.request);
162
+ const f = await P({ ...t, page: a.page + 1 }, { signal: a.controller.signal });
163
+ if (C || a.finished || a.controller.signal.aborted) return;
164
+ const w = ee(f, t.pageSize);
165
+ a.finished = !0, a.removeAbort(), y.delete(a.page), M(a.page, w, a.request);
162
166
  } catch {
163
- !c && !a.controller.signal.aborted && (N.add(a.page), o(a.page, "error"), e.markPageLoadFailed(a.page, a.request));
167
+ !C && !a.controller.signal.aborted && (T.add(a.page), o(a.page, "error"), e.markPageLoadFailed(a.page, a.request));
164
168
  } finally {
165
- a.finished || (a.finished = !0, a.removeAbort(), w.get(a.page) === a && w.delete(a.page)), f.delete(a), l(), D();
169
+ a.finished || (a.finished = !0, a.removeAbort(), y.get(a.page) === a && y.delete(a.page)), b.delete(a), u(), B();
166
170
  }
167
171
  })();
168
172
  }
169
- l();
170
- }, F = () => {
171
- x && clearTimeout(x), x = setTimeout(() => {
172
- x = void 0, D();
173
+ u();
174
+ }, $ = () => {
175
+ R && clearTimeout(R), R = setTimeout(() => {
176
+ R = void 0, B();
173
177
  }, 120);
174
178
  };
175
179
  return {
176
180
  load(r, a) {
177
- if (a.useRequestIdentity(), c || k || a.signal.aborted || !O(r)) {
181
+ if (a.useRequestIdentity(), C || c || a.signal.aborted || !V(r)) {
178
182
  e.markPageLoadFailed(r, a), o(r, "skip");
179
183
  return;
180
184
  }
181
- const u = w.get(r);
182
- if (u?.request === a && !u.finished) return;
183
- if (u && y(u), p(r), r === 0 && s) {
184
- const S = s;
185
- s = void 0;
185
+ const f = y.get(r);
186
+ if (f?.request === a && !f.finished) return;
187
+ if (f && d(f), m(r), r === 0 && h) {
188
+ const v = h;
189
+ h = void 0;
186
190
  try {
187
- C(0, S, a);
191
+ M(0, v, a);
188
192
  } catch {
189
- N.add(r), e.markPageLoadFailed(r, a), o(r, "error");
193
+ T.add(r), e.markPageLoadFailed(r, a), o(r, "error");
190
194
  }
191
- l();
195
+ u();
192
196
  return;
193
197
  }
194
- const v = { page: r, request: a, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
195
- } }, $ = () => {
196
- y(v), l();
198
+ const w = { page: r, request: a, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
199
+ } }, F = () => {
200
+ d(w), u();
197
201
  };
198
- a.signal.addEventListener("abort", $, { once: !0 }), v.removeAbort = () => a.signal.removeEventListener("abort", $), w.set(r, v), F(), l();
202
+ a.signal.addEventListener("abort", F, { once: !0 }), w.removeAbort = () => a.signal.removeEventListener("abort", F), y.set(r, w), $(), u();
199
203
  },
200
204
  viewportChanged() {
201
- if (c) return;
205
+ if (C) return;
202
206
  const r = e.getPagesInView();
203
- r?.length && (p(r[0]), w.size && F(), l());
207
+ r?.length && (m(r[0]), y.size && $(), u());
204
208
  },
205
209
  retry() {
206
- if (!c) {
207
- if (k) {
210
+ if (!C) {
211
+ if (c) {
208
212
  E();
209
213
  return;
210
214
  }
211
- N.size !== 0 && (N.clear(), B(), l());
215
+ T.size !== 0 && (T.clear(), I(), u());
212
216
  }
213
217
  },
214
218
  dispose() {
215
- c = !0, x && clearTimeout(x), x = void 0;
216
- for (const r of w.values()) y(r);
217
- z = [], N.clear(), s = void 0;
219
+ C = !0, R && clearTimeout(R), R = void 0;
220
+ for (const r of y.values()) d(r);
221
+ x = [], T.clear(), h = void 0;
218
222
  }
219
223
  };
220
- }, pe = 40, Te = (e) => {
221
- const t = V(void 0);
224
+ }, he = 40, Ce = (e) => {
225
+ const t = O(void 0);
222
226
  return e.initialPage ? /* @__PURE__ */ n(
223
- Ce,
227
+ Me,
224
228
  {
225
229
  ...e,
226
230
  initialPage: e.initialPage,
227
231
  restoreScroll: t.current?.query === e.query ? t.current.position : void 0,
228
- rememberScroll: (h) => {
229
- t.current = { query: e.query, position: h };
232
+ rememberScroll: (l) => {
233
+ t.current = { query: e.query, position: l };
230
234
  }
231
235
  }
232
236
  ) : /* @__PURE__ */ n("div", { className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" });
233
- }, Ce = ({ components: { Button: e }, initialPage: t, query: h, provider: H, themeKey: j, onOpen: B, onReload: E, logger: g, restoreScroll: w, rememberScroll: f }) => {
234
- const z = V(null), d = V(null), N = V(null), [s, M] = L(!1), [R, c] = L(0), [k, x] = L({ ...t, failed: !1, loading: !1 }), O = V(t.rows), o = V(w), l = V({ provider: H, onOpen: B, onReload: E, logger: g, rememberScroll: f });
235
- l.current = { provider: H, onOpen: B, onReload: E, logger: g, rememberScroll: f };
236
- const y = V(() => {
237
+ }, Me = ({ components: { Button: e }, initialPage: t, query: l, provider: P, themeKey: H, onOpen: I, onReload: E, logger: g, restoreScroll: y, rememberScroll: b }) => {
238
+ const x = O(null), p = O(null), T = O(null), [h, S] = D(!1), [L, C] = D(0), [c, R] = D({ ...t, failed: !1, loading: !1 }), V = O(t.rows), o = O(y), u = O({ provider: P, onOpen: I, onReload: E, logger: g, rememberScroll: b });
239
+ u.current = { provider: P, onOpen: I, onReload: E, logger: g, rememberScroll: b };
240
+ const d = O(() => {
237
241
  });
238
242
  return J(() => {
239
- const p = z.current;
240
- if (!p) return;
241
- let C = !1, D, F, r, a, u, v = t.total;
242
- I(l.current.logger, { operation: "table", phase: "start" });
243
- const $ = () => {
244
- C || (M(!0), I(l.current.logger, { operation: "table", phase: "error" }));
243
+ const m = x.current;
244
+ if (!m) return;
245
+ let M = !1, B, $, r, a, f, w = t.total;
246
+ A(u.current.logger, { operation: "table", phase: "start" });
247
+ const F = () => {
248
+ M || (S(!0), A(u.current.logger, { operation: "table", phase: "error" }));
245
249
  };
246
- return import("@qfei-design/canvas-table").then((S) => {
247
- if (C) return;
248
- const K = () => {
249
- const m = d.current, A = m?.getScrollState();
250
- m && A && S.globalEventBus.emitWithNamespace("scroll:change", m.tableId, A);
251
- }, U = (m = !1) => {
252
- if (!C)
250
+ return import("@qfei-design/canvas-table").then((v) => {
251
+ if (M) return;
252
+ const W = () => {
253
+ const i = p.current, s = i?.getScrollState();
254
+ i && s && v.globalEventBus.emitWithNamespace("scroll:change", i.tableId, s);
255
+ }, X = (i = !1) => {
256
+ if (!M)
253
257
  try {
254
- const { width: A, height: Y } = p.getBoundingClientRect();
255
- if (A <= 0 || Y <= 0 || !m && u?.width === A && u.height === Y) return;
256
- const W = getComputedStyle(p), ie = {
257
- rowHeight: pe,
258
+ const { width: s, height: K } = m.getBoundingClientRect();
259
+ if (s <= 0 || K <= 0 || !i && f?.width === s && f.height === K) return;
260
+ const j = getComputedStyle(m), ie = {
261
+ rowHeight: he,
258
262
  headerHeight: 40,
259
263
  fontSize: 14,
260
- fontFamily: W.fontFamily || "Arial, sans-serif",
261
- ...W.color ? { textColor: W.color } : {},
262
- ...W.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: W.getPropertyValue("--make-approval-bg").trim() } : {},
263
- ...W.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: W.getPropertyValue("--make-approval-header").trim() } : {},
264
- ...W.getPropertyValue("--make-approval-border").trim() ? { borderColor: W.getPropertyValue("--make-approval-border").trim() } : {}
265
- }, he = Math.max(Math.ceil(300 / h.pageSize), Math.ceil(Y * 3 / pe / h.pageSize) + 2) * h.pageSize, le = { enabled: !0, totalRowCount: v, pageSize: h.pageSize, maxCachedRows: he };
266
- if (d.current) {
267
- const b = u?.width !== A ? ce(A) : void 0;
268
- if (d.current.updateProps({
269
- canvasWidth: A,
270
- canvasHeight: Y,
264
+ fontFamily: j.fontFamily || "Arial, sans-serif",
265
+ ...j.color ? { textColor: j.color } : {},
266
+ ...j.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: j.getPropertyValue("--make-approval-bg").trim() } : {},
267
+ ...j.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: j.getPropertyValue("--make-approval-header").trim() } : {},
268
+ ...j.getPropertyValue("--make-approval-border").trim() ? { borderColor: j.getPropertyValue("--make-approval-border").trim() } : {}
269
+ }, ge = Math.max(Math.ceil(300 / l.pageSize), Math.ceil(K * 3 / he / l.pageSize) + 2) * l.pageSize, se = { enabled: !0, totalRowCount: w, pageSize: l.pageSize, maxCachedRows: ge };
270
+ if (p.current) {
271
+ const k = f?.width !== s ? de(s, l.tab) : void 0;
272
+ if (p.current.updateProps({
273
+ canvasWidth: s,
274
+ canvasHeight: K,
271
275
  style: ie,
272
- virtualOptions: le,
273
- ...b ? { columns: b } : {}
274
- }), b) {
275
- const P = d.current.getScrollState(), X = Math.max(0, b.reduce((_, ae) => _ + ae.width, oe) - A);
276
- P && P.scrollX > X && d.current.scrollTo(X, P.scrollY, !1);
276
+ virtualOptions: se,
277
+ ...k ? { columns: k } : {}
278
+ }), k) {
279
+ const z = p.current.getScrollState(), U = Math.max(0, k.reduce((_, ae) => _ + ae.width, oe) - s);
280
+ z && z.scrollX > U && p.current.scrollTo(U, z.scrollY, !1);
277
281
  }
278
- u = { width: A, height: Y }, K();
282
+ f = { width: s, height: K }, W();
279
283
  return;
280
284
  }
281
- d.current = new S.CanvasTableComponent(p, {
282
- columns: ce(A),
283
- canvasWidth: A,
284
- canvasHeight: Y,
285
+ p.current = new v.CanvasTableComponent(m, {
286
+ columns: de(s, l.tab),
287
+ canvasWidth: s,
288
+ canvasHeight: K,
285
289
  style: ie,
286
290
  rowKey: "id",
287
- showSN: { enabled: !0, width: oe, formatter: (b, P) => P + 1 },
288
- virtualOptions: le,
291
+ showSN: { enabled: !0, width: oe, formatter: (k, z) => z + 1 },
292
+ virtualOptions: se,
289
293
  selectable: { enabled: !1 },
290
294
  rowSortable: { enabled: !1 },
291
295
  editApplyMode: "controlled",
292
- customEdit: (b) => {
293
- b.cancel();
296
+ customEdit: (k) => {
297
+ k.cancel();
294
298
  },
295
299
  emptyStateOptions: { text: "暂无审批记录" },
296
300
  bodyRowHeadSuffixOptions: {
297
301
  enabled: !0,
298
302
  width: 20,
299
- render: ({ group: b, x: P, height: X, rowData: _ }) => {
300
- const ae = _?.id, Q = new S.RectShape({ name: "approval-open", x: P, y: X / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
301
- Q.addChild(new S.ImgShape({ name: "approval-open-icon", x: 3, y: 3, attrs: {
303
+ render: ({ group: k, x: z, height: U, rowData: _ }) => {
304
+ const ae = _?.id, Q = new v.RectShape({ name: "approval-open", x: z, y: U / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
305
+ Q.addChild(new v.ImgShape({ name: "approval-open-icon", x: 3, y: 3, attrs: {
302
306
  width: 14,
303
307
  height: 14,
304
- 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="${W.color || "#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
308
+ 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="${j.color || "#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
305
309
  } })), Q.on("mousedown", (re) => re.stopPropagation?.()), Q.on("click", (re) => {
306
310
  re.stopPropagation?.();
307
- const se = O.current.find((ue) => ue.id === ae);
308
- se && l.current.onOpen(se);
309
- }), b.addChild(Q);
311
+ const le = V.current.find((ve) => ve.id === ae);
312
+ le && u.current.onOpen(le);
313
+ }), k.addChild(Q);
310
314
  }
311
315
  }
312
316
  });
313
- const G = d.current;
314
- u = { width: A, height: Y };
315
- const te = Ne({
317
+ const G = p.current;
318
+ f = { width: s, height: K };
319
+ const te = Te({
316
320
  table: G,
317
- query: h,
321
+ query: l,
318
322
  initialPage: t,
319
323
  // 公开滚动同步事件会重新检测缺页,不移动视口,也不复用失败身份。
320
- retryViewport: K,
321
- onReload: () => l.current.onReload(),
322
- loadPage: (b, P) => l.current.provider.loadPage(b, P),
323
- logger: (b) => I(l.current.logger, b),
324
- onChange: (b) => {
325
- C || (v = b.total, O.current = b.rows, x((P) => P.total === b.total && P.failed === b.failed && P.loading === b.loading && P.rows.length === b.rows.length && P.rows.every((X, _) => X === b.rows[_]) ? P : b));
324
+ retryViewport: W,
325
+ onReload: () => u.current.onReload(),
326
+ loadPage: (k, z) => u.current.provider.loadPage(k, z),
327
+ logger: (k) => A(u.current.logger, k),
328
+ onChange: (k) => {
329
+ M || (w = k.total, V.current = k.rows, R((z) => z.total === k.total && z.failed === k.failed && z.loading === k.loading && z.rows.length === k.rows.length && z.rows.every((U, _) => U === k.rows[_]) ? z : k));
326
330
  }
327
331
  });
328
- N.current = te, F = S.globalEventBus.onWithNamespace("data:load", G.tableId, (b, P) => te.load(b, P)), r = S.globalEventBus.onWithNamespace("scroll:change", G.tableId, () => te.viewportChanged()), o.current && G.scrollTo(o.current.scrollX, o.current.scrollY), M(!1), I(l.current.logger, { operation: "table", phase: "success" });
332
+ T.current = te, $ = v.globalEventBus.onWithNamespace("data:load", G.tableId, (k, z) => te.load(k, z)), r = v.globalEventBus.onWithNamespace("scroll:change", G.tableId, () => te.viewportChanged()), o.current && G.scrollTo(o.current.scrollX, o.current.scrollY), S(!1), A(u.current.logger, { operation: "table", phase: "success" });
329
333
  } catch {
330
- $();
334
+ F();
331
335
  }
332
336
  };
333
- y.current = () => U(!0);
334
- const i = () => U();
335
- D = new ResizeObserver(i), D.observe(p), window.addEventListener("resize", i), a = () => window.removeEventListener("resize", i), U();
336
- }).catch($), () => {
337
- C = !0, D?.disconnect(), a?.(), y.current = () => {
338
- }, d.current && (o.current = d.current.getScrollState(), o.current && l.current.rememberScroll(o.current)), F?.(), r?.(), N.current?.dispose(), N.current = null, d.current?.destroy(), d.current = null, I(l.current.logger, { operation: "table", phase: "destroy" });
337
+ d.current = () => X(!0);
338
+ const Y = () => X();
339
+ B = new ResizeObserver(Y), B.observe(m), window.addEventListener("resize", Y), a = () => window.removeEventListener("resize", Y), X();
340
+ }).catch(F), () => {
341
+ M = !0, B?.disconnect(), a?.(), d.current = () => {
342
+ }, p.current && (o.current = p.current.getScrollState(), o.current && u.current.rememberScroll(o.current)), $?.(), r?.(), T.current?.dispose(), T.current = null, p.current?.destroy(), p.current = null, A(u.current.logger, { operation: "table", phase: "destroy" });
339
343
  };
340
- }, [t, h, R]), J(() => {
341
- y.current();
342
- }, [j]), /* @__PURE__ */ T("div", { className: "make-app-approval-table-frame", "aria-busy": k.loading, children: [
343
- /* @__PURE__ */ n("div", { ref: z, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
344
- s && /* @__PURE__ */ T("div", { className: "make-app-approval-overlay", role: "alert", children: [
344
+ }, [t, l, L]), J(() => {
345
+ d.current();
346
+ }, [H]), /* @__PURE__ */ N("div", { className: "make-app-approval-table-frame", "aria-busy": c.loading, children: [
347
+ /* @__PURE__ */ n("div", { ref: x, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
348
+ h && /* @__PURE__ */ N("div", { className: "make-app-approval-overlay", role: "alert", children: [
345
349
  "表格加载失败 ",
346
350
  /* @__PURE__ */ n(e, { htmlType: "button", variant: "default", onClick: () => {
347
- M(!1), c((p) => p + 1);
351
+ S(!1), C((m) => m + 1);
348
352
  }, children: "重新加载表格" })
349
353
  ] }),
350
- !s && k.failed && /* @__PURE__ */ T("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
354
+ !h && c.failed && /* @__PURE__ */ N("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
351
355
  "部分审批记录加载失败 ",
352
- /* @__PURE__ */ n(e, { htmlType: "button", variant: "default", onClick: () => N.current?.retry(), children: "重试加载" })
356
+ /* @__PURE__ */ n(e, { htmlType: "button", variant: "default", onClick: () => T.current?.retry(), children: "重试加载" })
353
357
  ] }),
354
- !s && !k.failed && k.loading && /* @__PURE__ */ T("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
358
+ !h && !c.failed && c.loading && /* @__PURE__ */ N("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
355
359
  /* @__PURE__ */ n("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
356
360
  /* @__PURE__ */ n("span", { children: "加载中" })
357
361
  ] }),
358
- /* @__PURE__ */ T("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
359
- k.total === 0 && /* @__PURE__ */ n("li", { children: "暂无审批记录" }),
360
- k.rows.map((p) => /* @__PURE__ */ T("li", { children: [
361
- /* @__PURE__ */ T("span", { children: [
362
- p.applicationNo,
362
+ /* @__PURE__ */ N("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
363
+ c.total === 0 && /* @__PURE__ */ n("li", { children: "暂无审批记录" }),
364
+ c.rows.map((m) => /* @__PURE__ */ N("li", { children: [
365
+ /* @__PURE__ */ N("span", { children: [
366
+ m.applicationNo,
363
367
  ",",
364
- p.applicationType,
368
+ m.applicationType,
365
369
  ",",
366
- p.applicantName,
370
+ m.applicantName,
367
371
  ",",
368
- p.applicationTime,
372
+ m.applicationTime,
373
+ l.tab === "initiated" ? `,${ne(m.processStatus)}` : "",
369
374
  "。"
370
375
  ] }),
371
- /* @__PURE__ */ T(e, { htmlType: "button", variant: "text", onClick: () => B(p), children: [
376
+ /* @__PURE__ */ N(e, { htmlType: "button", variant: "text", onClick: () => I(m), children: [
372
377
  "打开 ",
373
- p.applicationNo || p.applicationType,
378
+ m.applicationNo || m.applicationType,
374
379
  " 的审批详情"
375
380
  ] })
376
- ] }, p.id))
381
+ ] }, m.id))
377
382
  ] })
378
383
  ] });
379
- }, Me = [], Re = (e, t, h, H) => {
380
- const [j, B] = L(0), [E, g] = L(), w = V({ provider: e, logger: H });
381
- w.current = { provider: e, logger: H };
382
- const f = me(() => ({}), [t, h, j]);
384
+ }, Re = [], Ie = (e, t, l, P) => {
385
+ const [H, I] = D(0), [E, g] = D(), y = O({ provider: e, logger: P });
386
+ y.current = { provider: e, logger: P };
387
+ const b = be(() => ({}), [t, l, H]);
383
388
  J(() => {
384
- const d = new AbortController(), { provider: N, logger: s } = w.current, M = { operation: "list", tab: t.tab, page: t.page, pageSize: t.pageSize };
385
- I(s, { ...M, phase: "start" });
386
- let R = !1;
389
+ const p = new AbortController(), { provider: T, logger: h } = y.current, S = { operation: "list", tab: t.tab, page: t.page, pageSize: t.pageSize };
390
+ A(h, { ...S, phase: "start" });
391
+ let L = !1;
387
392
  return (async () => {
388
393
  try {
389
- if (await Promise.resolve(), d.signal.aborted) return;
390
- const c = await N.loadPage(t, { signal: d.signal });
391
- if (d.signal.aborted) return;
392
- const k = ee(c, t.pageSize);
393
- R = !0, g({ ...k, token: f, status: "success" }), I(s, { ...M, phase: "success", rowCount: k.rows.length });
394
+ if (await Promise.resolve(), p.signal.aborted) return;
395
+ const C = await T.loadPage(t, { signal: p.signal });
396
+ if (p.signal.aborted) return;
397
+ const c = ee(C, t.pageSize);
398
+ L = !0, g({ ...c, token: b, status: "success" }), A(h, { ...S, phase: "success", rowCount: c.rows.length });
394
399
  } catch {
395
- if (d.signal.aborted) return;
396
- R = !0, g({ token: f, status: "error", rows: Me, total: 0 }), I(s, { ...M, phase: "error" });
400
+ if (p.signal.aborted) return;
401
+ L = !0, g({ token: b, status: "error", rows: Re, total: 0 }), A(h, { ...S, phase: "error" });
397
402
  }
398
403
  })(), () => {
399
- d.abort(), R || I(s, { ...M, phase: "cancel" });
404
+ p.abort(), L || A(h, { ...S, phase: "cancel" });
400
405
  };
401
- }, [t, f]);
402
- const z = E?.token === f ? E : void 0;
406
+ }, [t, b]);
407
+ const x = E?.token === b ? E : void 0;
403
408
  return {
404
- initialPage: z?.status === "success" ? z : void 0,
405
- total: z?.total ?? 0,
406
- status: z?.status ?? "loading",
407
- reload: () => B((d) => d + 1)
409
+ initialPage: x?.status === "success" ? x : void 0,
410
+ total: x?.total ?? 0,
411
+ status: x?.status ?? "loading",
412
+ reload: () => I((p) => p + 1)
408
413
  };
409
- }, Z = { keyword: "", applicantId: "", processStatus: "", startDate: "", endDate: "" }, Pe = [{ value: "pending", label: "待处理" }, { value: "approved", label: "已完成" }], q = (e) => {
414
+ }, Z = { keyword: "", applicantId: "", processStatus: "", startDate: "", endDate: "" }, me = ["pending", "approved"], fe = { pending: "待处理", approved: "已完成", initiated: "已发起" }, q = (e) => {
410
415
  if (e === "") return !0;
411
416
  if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
412
417
  const t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
413
418
  return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
414
- }, xe = ({ components: e, provider: t, onOpenApproval: h, applicantOptions: H = [], pageSize: j = 20, refreshKey: B, themeKey: E, logger: g, className: w, presentation: f = "desktop" }) => {
415
- const { Input: z, Select: d, DateRangePicker: N, Button: s, Tabs: M } = e, R = ge(), [c, k] = L(Z), [x, O] = L(0), [o, l] = L(""), [y, p] = L(""), [C, D] = L({ ...Z, tab: "pending", page: 1, pageSize: j }), { initialPage: F, status: r, reload: a } = Re(t, C, B, g), u = V(!1), v = V(!0);
416
- J(() => (v.current = !0, () => {
417
- v.current = !1;
419
+ }, Pe = ({ components: e, provider: t, onOpenApproval: l, applicantOptions: P = [], pageSize: H = 20, refreshKey: I, themeKey: E, logger: g, className: y, presentation: b = "desktop", tabs: x = me }) => {
420
+ const { Input: p, Select: T, DateRangePicker: h, Button: S, Tabs: L } = e, C = we(), [c, R] = D(Z), [V, o] = D(0), [u, d] = D(""), [m, M] = D(""), [B, $] = D({ ...Z, tab: x[0], page: 1, pageSize: H }), { initialPage: r, status: a, reload: f } = Ie(t, B, I, g), w = O(!1), F = O(!0);
421
+ J(() => (F.current = !0, () => {
422
+ F.current = !1;
418
423
  }), []);
419
- const $ = r === "loading", S = async (i) => {
420
- if (!u.current) {
421
- u.current = !0, p(""), I(g, { operation: "open", phase: "start" });
424
+ const v = a === "loading", W = async (i) => {
425
+ if (!w.current) {
426
+ w.current = !0, M(""), A(g, { operation: "open", phase: "start" });
422
427
  try {
423
- await h(i), I(g, { operation: "open", phase: "success" });
428
+ await l(i), A(g, { operation: "open", phase: "success" });
424
429
  } catch {
425
- v.current && p("审批详情打开失败,请重试"), I(g, { operation: "open", phase: "error" });
430
+ F.current && M("审批详情打开失败,请重试"), A(g, { operation: "open", phase: "error" });
426
431
  } finally {
427
- u.current = !1;
432
+ w.current = !1;
428
433
  }
429
434
  }
430
- }, K = (i) => {
431
- i !== C.tab && (l(""), p(""), D((m) => ({ ...m, tab: i, page: 1 })));
432
- }, U = (i) => {
433
- k((m) => ({ ...m, ...i })), f === "mobile" && (l(""), p(""), D((m) => ({ ...m, ...i, page: 1 })));
435
+ }, X = (i) => {
436
+ i === B.tab || !x.includes(i) || (d(""), M(""), i === "initiated" && R((s) => ({ ...s, keyword: "", applicantId: "", processStatus: "" })), $((s) => ({ ...s, ...i === "initiated" ? { keyword: "", applicantId: "", processStatus: "" } : {}, tab: i, page: 1 })));
437
+ }, Y = (i) => {
438
+ R((s) => ({ ...s, ...i })), b === "mobile" && (d(""), M(""), $((s) => ({ ...s, ...i, page: 1 })));
434
439
  };
435
- return /* @__PURE__ */ n("section", { className: ["make-app-approval", f === "mobile" && "make-app-approval--mobile", w].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */ T(M, { items: Pe, value: C.tab, onChange: K, ariaLabel: "审批分类", children: [
436
- /* @__PURE__ */ T("form", { className: "make-app-approval-filters", onSubmit: (i) => {
437
- if (i.preventDefault(), f === "mobile") {
438
- l(""), p(""), D((m) => ({ ...m, keyword: c.keyword.trim(), page: 1 }));
440
+ return /* @__PURE__ */ n("section", { className: ["make-app-approval", b === "mobile" && "make-app-approval--mobile", y].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */ N(L, { items: x.map((i) => ({ value: i, label: fe[i] })), value: B.tab, onChange: X, ariaLabel: "审批分类", children: [
441
+ /* @__PURE__ */ N("form", { className: "make-app-approval-filters", onSubmit: (i) => {
442
+ if (i.preventDefault(), b === "mobile") {
443
+ d(""), M(""), $((s) => ({ ...s, keyword: c.keyword.trim(), page: 1 }));
439
444
  return;
440
445
  }
441
446
  if (!q(c.startDate) || !q(c.endDate)) {
442
- l("请选择有效日期");
447
+ d("请选择有效日期");
443
448
  return;
444
449
  }
445
450
  if (c.startDate && c.endDate && c.startDate > c.endDate) {
446
- l("开始日期不能晚于结束日期");
451
+ d("开始日期不能晚于结束日期");
447
452
  return;
448
453
  }
449
- l(""), p(""), D((m) => ({ ...m, ...c, keyword: c.keyword.trim(), page: 1 }));
454
+ d(""), M(""), $((s) => ({ ...s, ...c, keyword: c.keyword.trim(), page: 1 }));
450
455
  }, children: [
451
- /* @__PURE__ */ T("div", { className: "make-app-approval-filter-field", children: [
452
- f === "mobile" && /* @__PURE__ */ n(s, { htmlType: "submit", variant: "text", ariaLabel: "搜索申请单ID", children: /* @__PURE__ */ T("svg", { "aria-hidden": "true", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: [
456
+ B.tab !== "initiated" && /* @__PURE__ */ N("div", { className: "make-app-approval-filter-field", children: [
457
+ b === "mobile" && /* @__PURE__ */ n(S, { htmlType: "submit", variant: "text", ariaLabel: "搜索申请单ID", children: /* @__PURE__ */ N("svg", { "aria-hidden": "true", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: [
453
458
  /* @__PURE__ */ n("circle", { cx: "10.5", cy: "10.5", r: "6.5" }),
454
459
  /* @__PURE__ */ n("path", { d: "m16 16 5 5" })
455
460
  ] }) }),
456
- /* @__PURE__ */ n(z, { id: `${R}-keyword`, ariaLabel: "申请单ID", placeholder: "搜索申请单ID", value: c.keyword, onChange: (i) => {
457
- k((m) => ({ ...m, keyword: i })), f === "mobile" && !i && D((m) => ({ ...m, keyword: "", page: 1 }));
461
+ /* @__PURE__ */ n(p, { id: `${C}-keyword`, ariaLabel: "申请单ID", placeholder: "搜索申请单ID", value: c.keyword, onChange: (i) => {
462
+ R((s) => ({ ...s, keyword: i })), b === "mobile" && !i && $((s) => ({ ...s, keyword: "", page: 1 }));
458
463
  } })
459
464
  ] }),
460
465
  /* @__PURE__ */ n("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ n(
461
- N,
466
+ h,
462
467
  {
463
- id: `${R}-period`,
468
+ id: `${C}-period`,
464
469
  ariaLabel: "申请时间",
465
470
  placeholder: ["开始日期", "结束日期"],
466
471
  value: [c.startDate, c.endDate],
467
- onChange: ([i, m]) => {
468
- if (f === "mobile" && (!q(i) || !q(m) || i && m && i > m)) {
469
- l("请选择有效日期范围");
472
+ onChange: ([i, s]) => {
473
+ if (b === "mobile" && (!q(i) || !q(s) || i && s && i > s)) {
474
+ d("请选择有效日期范围");
470
475
  return;
471
476
  }
472
- if (f === "mobile" && !!i != !!m) {
473
- k((A) => ({ ...A, startDate: i, endDate: m }));
477
+ if (b === "mobile" && !!i != !!s) {
478
+ R((K) => ({ ...K, startDate: i, endDate: s }));
474
479
  return;
475
480
  }
476
- U({ startDate: i, endDate: m });
481
+ Y({ startDate: i, endDate: s });
477
482
  }
478
483
  },
479
- x
484
+ V
480
485
  ) }),
481
- /* @__PURE__ */ n("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ n(
482
- d,
486
+ B.tab !== "initiated" && /* @__PURE__ */ n("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ n(
487
+ T,
483
488
  {
484
- id: `${R}-applicant`,
489
+ id: `${C}-applicant`,
485
490
  ariaLabel: "申请人",
486
491
  purpose: "applicant",
487
492
  value: c.applicantId ?? "",
488
- options: [{ value: "", label: "全部申请人" }, ...H.filter((i) => i.value !== "")],
489
- onChange: (i) => U({ applicantId: i })
493
+ options: [{ value: "", label: "全部申请人" }, ...P.filter((i) => i.value !== "")],
494
+ onChange: (i) => Y({ applicantId: i })
490
495
  }
491
496
  ) }),
492
- f !== "mobile" && /* @__PURE__ */ T("div", { className: "make-app-approval-filter-actions", children: [
493
- /* @__PURE__ */ n(s, { htmlType: "submit", variant: "primary", children: "查询" }),
494
- /* @__PURE__ */ n(s, { htmlType: "button", variant: "default", onClick: () => {
495
- k(Z), O((i) => i + 1), l(""), p(""), D((i) => ({ ...i, ...Z, page: 1 }));
497
+ b !== "mobile" && /* @__PURE__ */ N("div", { className: "make-app-approval-filter-actions", children: [
498
+ /* @__PURE__ */ n(S, { htmlType: "submit", variant: "primary", children: "查询" }),
499
+ /* @__PURE__ */ n(S, { htmlType: "button", variant: "default", onClick: () => {
500
+ R(Z), o((i) => i + 1), d(""), M(""), $((i) => ({ ...i, ...Z, page: 1 }));
496
501
  }, children: "重置" }),
497
- /* @__PURE__ */ n(s, { htmlType: "button", variant: "default", disabled: $, loading: $, onClick: a, children: "刷新" })
502
+ /* @__PURE__ */ n(S, { htmlType: "button", variant: "default", disabled: v, loading: v, onClick: f, children: "刷新" })
498
503
  ] })
499
504
  ] }),
500
- o && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: o }),
501
- y && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: y }),
502
- /* @__PURE__ */ T("div", { className: "make-app-approval-results", "aria-busy": $, children: [
503
- f === "mobile" ? F && /* @__PURE__ */ n(be, { initialPage: F, query: C, provider: t, onReload: a, components: e, onOpen: (i) => {
504
- S(i);
505
- }, logger: g }, JSON.stringify([C, B, F])) : /* @__PURE__ */ n(Te, { components: e, initialPage: F, query: C, provider: t, onOpen: (i) => {
506
- S(i);
507
- }, onReload: a, themeKey: E, logger: g }),
508
- $ && /* @__PURE__ */ n("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
509
- r === "error" && /* @__PURE__ */ T("div", { className: "make-app-approval-overlay", role: "alert", children: [
505
+ u && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: u }),
506
+ m && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: m }),
507
+ /* @__PURE__ */ N("div", { className: "make-app-approval-results", "aria-busy": v, children: [
508
+ b === "mobile" ? r && /* @__PURE__ */ n(Se, { initialPage: r, query: B, provider: t, onReload: f, components: e, onOpen: (i) => {
509
+ W(i);
510
+ }, logger: g }, JSON.stringify([B, I, r])) : /* @__PURE__ */ n(Ce, { components: e, initialPage: r, query: B, provider: t, onOpen: (i) => {
511
+ W(i);
512
+ }, onReload: f, themeKey: E, logger: g }),
513
+ v && /* @__PURE__ */ n("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
514
+ a === "error" && /* @__PURE__ */ N("div", { className: "make-app-approval-overlay", role: "alert", children: [
510
515
  /* @__PURE__ */ n("span", { children: "审批列表加载失败,请重试" }),
511
- /* @__PURE__ */ n(s, { htmlType: "button", variant: "default", onClick: a, children: "重试" })
516
+ /* @__PURE__ */ n(S, { htmlType: "button", variant: "default", onClick: f, children: "重试" })
512
517
  ] })
513
518
  ] })
514
519
  ] }) });
515
520
  }, Ee = (e) => {
516
- const t = e.pageSize ?? 20;
521
+ const t = e.pageSize ?? 20, l = e.tabs ?? me;
522
+ if (!l.length || new Set(l).size !== l.length || l.some((P) => !Object.hasOwn(fe, P))) throw new Error("MyApprovalsPage requires valid unique tabs");
517
523
  if (!e.scopeKey.trim()) throw new Error("MyApprovalsPage requires scopeKey");
518
- for (const h of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
519
- if (!e.components?.[h]) throw new Error(`MyApprovalsPage requires components.${h}`);
524
+ for (const P of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
525
+ if (!e.components?.[P]) throw new Error(`MyApprovalsPage requires components.${P}`);
520
526
  if (!Number.isSafeInteger(t) || t < 1 || t > 200) throw new Error("pageSize must be an integer from 1 to 200");
521
- return /* @__PURE__ */ n(xe, { ...e, pageSize: t }, JSON.stringify([e.scopeKey, t]));
527
+ return /* @__PURE__ */ n(Pe, { ...e, tabs: l, pageSize: t }, JSON.stringify([e.scopeKey, t, l]));
522
528
  };
523
529
  export {
524
530
  Ee as MyApprovalsPage