@qfei-design/make-app-approval 0.2.14 → 0.2.16

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