@qfei-design/make-app-approval 0.2.7 → 0.2.9

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