@qfei-design/make-app-approval 0.2.1 → 0.2.3

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/detail.mjs CHANGED
@@ -1,31 +1,31 @@
1
- import { jsx as s, jsxs as n, Fragment as we } from "react/jsx-runtime";
2
- import { useState as u, useRef as W, useEffect as de, useId as Te } from "react";
3
- import { ApprovalStatus as Ee } from "./react.mjs";
1
+ import { jsx as l, jsxs as d, Fragment as we } from "react/jsx-runtime";
2
+ import { useState as y, useRef as J, useEffect as M, useId as Ee } from "react";
3
+ import { ApprovalStatus as ve } from "./react.mjs";
4
4
  import { isApprovalSystemField as Ae } from "./index.mjs";
5
- const N = (e) => !!e && typeof e == "object" && !Array.isArray(e), b = (e) => typeof e == "string" && e.trim().length > 0, Ne = ["APPROVE", "REJECT", "RETURN", "SUBMIT"], $ = (e) => {
5
+ const v = (e) => !!e && typeof e == "object" && !Array.isArray(e), g = (e) => typeof e == "string" && e.trim().length > 0, Oe = ["APPROVE", "REJECT", "RETURN", "SUBMIT"], D = (e) => {
6
6
  if (e === void 0) return [];
7
- if (!N(e)) throw new Error("审批字段权限格式无效");
7
+ if (!v(e)) throw new Error("审批字段权限格式无效");
8
8
  if (e.scope === "NONE" && e.fields === void 0) return [];
9
- if (e.scope !== "FIELDS" || !Array.isArray(e.fields) || !e.fields.every(b) || new Set(e.fields).size !== e.fields.length)
9
+ if (e.scope !== "FIELDS" || !Array.isArray(e.fields) || !e.fields.every(g) || new Set(e.fields).size !== e.fields.length)
10
10
  throw new Error("审批字段权限范围无效");
11
11
  return e.fields;
12
- }, Ie = (e) => N(e) && b(e.key) && b(e.label) && (e.required === void 0 || typeof e.required == "boolean") && (e.fullWidth === void 0 || typeof e.fullWidth == "boolean") && (e.schema === void 0 || N(e.schema)), Oe = (e) => {
13
- if (!N(e) || !Ne.some((r) => r === e.actionType) || e.commentPolicy !== "REQUIRED" && e.commentPolicy !== "OPTIONAL")
12
+ }, Ne = (e) => v(e) && g(e.key) && g(e.label) && (e.required === void 0 || typeof e.required == "boolean") && (e.fullWidth === void 0 || typeof e.fullWidth == "boolean") && (e.schema === void 0 || v(e.schema)), Ie = (e) => {
13
+ if (!v(e) || !Oe.some((s) => s === e.actionType) || e.commentPolicy !== "REQUIRED" && e.commentPolicy !== "OPTIONAL")
14
14
  return !1;
15
- const t = e.returnTargets;
16
- return t === void 0 || Array.isArray(t) && t.every((r) => N(r) && b(r.nodeKey) && b(r.nodeName)) && new Set(t.map((r) => r.nodeKey)).size === t.length;
17
- }, pe = (e) => {
18
- if (!N(e) || !b(e.taskId) || !b(e.processInstanceId) || !b(e.taskName) || !b(e.processStatus) || !Array.isArray(e.fields) || !e.fields.every(Ie) || !N(e.formData))
15
+ const r = e.returnTargets;
16
+ return r === void 0 || Array.isArray(r) && r.every((s) => v(s) && g(s.nodeKey) && g(s.nodeName)) && new Set(r.map((s) => s.nodeKey)).size === r.length;
17
+ }, me = (e) => {
18
+ if (!v(e) || !g(e.taskId) || !g(e.processInstanceId) || !g(e.taskName) || !g(e.processStatus) || !Array.isArray(e.fields) || !e.fields.every(Ne) || !v(e.formData))
19
19
  throw new Error("审批详情数据不完整");
20
- const t = e.fields.map((i) => i.key);
21
- if (new Set(t).size !== t.length) throw new Error("审批字段标识重复");
22
- if (e.fieldPermission !== void 0 && !N(e.fieldPermission))
20
+ const r = e.fields.map((p) => p.key);
21
+ if (new Set(r).size !== r.length) throw new Error("审批字段标识重复");
22
+ if (e.fieldPermission !== void 0 && !v(e.fieldPermission))
23
23
  throw new Error("审批字段权限格式无效");
24
- const r = e.fieldPermission, o = $(r?.viewPermission), p = $(r?.editPermission);
25
- if (o.some((i) => !t.includes(i)) || p.some((i) => !o.includes(i)))
24
+ const s = e.fieldPermission, a = D(s?.viewPermission), m = D(s?.editPermission);
25
+ if (a.some((p) => !r.includes(p)) || m.some((p) => !a.includes(p)))
26
26
  throw new Error("审批字段元数据或权限不一致");
27
- const d = e.actions ?? [];
28
- if (!Array.isArray(d) || !d.every(Oe) || new Set(d.map((i) => i.actionType)).size !== d.length)
27
+ const n = e.actions ?? [];
28
+ if (!Array.isArray(n) || !n.every(Ie) || new Set(n.map((p) => p.actionType)).size !== n.length)
29
29
  throw new Error("审批操作配置无效");
30
30
  return {
31
31
  taskId: e.taskId,
@@ -34,298 +34,324 @@ const N = (e) => !!e && typeof e == "object" && !Array.isArray(e), b = (e) => ty
34
34
  processStatus: e.processStatus,
35
35
  fields: e.fields,
36
36
  formData: e.formData,
37
- actions: d,
37
+ actions: n,
38
38
  fieldPermission: {
39
- viewPermission: { scope: "FIELDS", fields: o },
40
- editPermission: { scope: "FIELDS", fields: p }
39
+ viewPermission: { scope: "FIELDS", fields: a },
40
+ editPermission: { scope: "FIELDS", fields: m }
41
41
  }
42
42
  };
43
- }, q = (e) => {
44
- const t = new Set(
45
- $(e.fieldPermission?.viewPermission)
46
- ), r = new Set(
47
- $(e.fieldPermission?.editPermission)
43
+ }, P = (e) => {
44
+ const r = new Set(
45
+ D(e.fieldPermission?.viewPermission)
46
+ ), s = new Set(
47
+ D(e.fieldPermission?.editPermission)
48
48
  );
49
- return e.fields.filter((o) => t.has(o.key)).map((o) => ({
50
- ...o,
51
- editable: r.has(o.key) && !Ae(o.key)
49
+ return e.fields.filter((a) => r.has(a.key)).map((a) => ({
50
+ ...a,
51
+ editable: s.has(a.key) && !Ae(a.key)
52
52
  }));
53
53
  };
54
- class A extends Error {
55
- constructor(t, r = {}) {
56
- super(t), this.fieldErrors = r, this.name = "ApprovalTaskValidationError";
54
+ class b extends Error {
55
+ constructor(r, s = {}, a) {
56
+ super(r), this.fieldErrors = s, this.control = a, this.name = "ApprovalTaskValidationError";
57
57
  }
58
58
  fieldErrors;
59
+ control;
59
60
  }
60
- const Q = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.actionType === "SUBMIT" && e.commentPolicy === "REQUIRED", Se = (e, t) => Object.fromEntries(
61
- e.filter((r) => {
62
- const o = t[r.key];
63
- return o == null || typeof o == "string" && !o.trim() || Array.isArray(o) && o.length === 0;
64
- }).map((r) => [r.key, `请填写${r.label}`])
65
- ), le = (e, t, r, o, p) => {
66
- const d = e.actions.find((l) => l.actionType === t);
67
- if (!d)
68
- throw new A("当前节点不允许此操作,请刷新详情");
69
- const i = new Set(
70
- q(e).filter((l) => l.editable).map((l) => l.key)
61
+ const V = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.actionType === "SUBMIT" && e.commentPolicy === "REQUIRED", Te = (e, r) => Object.fromEntries(
62
+ e.filter((s) => {
63
+ const a = r[s.key];
64
+ return a == null || typeof a == "string" && !a.trim() || Array.isArray(a) && a.length === 0;
65
+ }).map((s) => [s.key, `请填写${s.label}`])
66
+ ), ce = (e, r, s, a, m = "") => {
67
+ const n = e.actions.find((c) => c.actionType === r);
68
+ if (!n)
69
+ throw new b("当前节点不允许此操作,请刷新详情");
70
+ const p = r === "RETURN" ? {} : s, f = new Set(
71
+ P(e).filter((c) => c.editable).map((c) => c.key)
71
72
  );
72
- if (Object.keys(r).some((l) => !i.has(l)))
73
- throw new A("字段权限已变化,请重新加载详情");
74
- if (Q(d) && !o.trim())
75
- throw new A("请填写审批意见");
76
- if (o.length > 1024)
77
- throw new A("审批意见不能超过 1024 个字符");
78
- if (t === "RETURN" && !d.returnTargets?.some((l) => l.nodeKey === p))
79
- throw new A("请选择后台配置的退回节点");
73
+ if (Object.keys(p).some((c) => !f.has(c)))
74
+ throw new b("字段权限已变化,请重新加载详情");
75
+ if (V(n) && !a.trim())
76
+ throw new b("请填写审批意见", {}, "comment");
77
+ if (a.length > 1024)
78
+ throw new b("审批意见不能超过 1024 个字符", {}, "comment");
79
+ const o = r === "RETURN" && n.returnTargets?.length === 1 ? n.returnTargets[0] : void 0;
80
+ if (r === "RETURN" && !o)
81
+ throw new b(
82
+ n.returnTargets?.length ? "退回目标配置不唯一,请联系管理员检查流程配置" : "退回目标配置缺失,请联系管理员检查流程配置"
83
+ );
84
+ if (o && m && m !== o.nodeKey)
85
+ throw new b("退回目标与当前节点配置不一致,请重新加载详情");
80
86
  return {
81
87
  taskId: e.taskId,
82
88
  processInstanceId: e.processInstanceId,
83
- actionType: t,
84
- comment: o.trim(),
85
- recordPatch: { ...r },
86
- ...t === "RETURN" ? { targetNodeKey: p } : {}
89
+ actionType: r,
90
+ comment: a.trim(),
91
+ recordPatch: { ...p },
92
+ ...o ? { targetNodeKey: o.nodeKey } : {}
87
93
  };
88
- }, f = (e, t) => {
94
+ }, u = (e, r) => {
89
95
  try {
90
- e ? e(t) : t.phase === "error" ? console.warn("[make-app-approval]", t) : console.info("[make-app-approval]", t);
96
+ e ? e(r) : r.phase === "error" ? console.warn("[make-app-approval]", r) : console.info("[make-app-approval]", r);
91
97
  } catch {
92
98
  console.warn("[make-app-approval] diagnostic sink failed");
93
99
  }
94
- }, G = (e, t) => {
95
- if (Object.is(e, t)) return !0;
96
- if (e instanceof Date && t instanceof Date)
97
- return Object.is(e.getTime(), t.getTime());
98
- if (Array.isArray(e) || Array.isArray(t))
99
- return Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((p, d) => G(p, t[d]));
100
- if (!e || !t || typeof e != "object" || typeof t != "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(e)) || ![Object.prototype, null].includes(Object.getPrototypeOf(t))) return !1;
101
- const r = e, o = t;
102
- return Object.keys(r).length === Object.keys(o).length && Object.keys(r).every((p) => Object.hasOwn(o, p) && G(r[p], o[p]));
103
- }, D = {
100
+ }, z = (e, r) => {
101
+ if (Object.is(e, r)) return !0;
102
+ if (e instanceof Date && r instanceof Date)
103
+ return Object.is(e.getTime(), r.getTime());
104
+ if (Array.isArray(e) || Array.isArray(r))
105
+ return Array.isArray(e) && Array.isArray(r) && e.length === r.length && e.every((m, n) => z(m, r[n]));
106
+ if (!e || !r || typeof e != "object" || typeof r != "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(e)) || ![Object.prototype, null].includes(Object.getPrototypeOf(r))) return !1;
107
+ const s = e, a = r;
108
+ return Object.keys(s).length === Object.keys(a).length && Object.keys(s).every((m) => Object.hasOwn(a, m) && z(s[m], a[m]));
109
+ }, le = {
104
110
  APPROVE: "同意",
105
111
  REJECT: "拒绝",
106
112
  RETURN: "退回修改",
107
113
  SUBMIT: "提交"
108
- }, H = (e, t) => e.taskId === t.reference.taskId && e.processInstanceId === t.reference.processInstanceId, je = ({
114
+ }, W = (e, r) => e.taskId === r.reference.taskId && e.processInstanceId === r.reference.processInstanceId, Re = ({
109
115
  title: e,
110
- actions: t,
111
- content: r,
112
- footer: o
113
- }) => /* @__PURE__ */ n("section", { className: "make-app-approval-detail", "aria-label": "审批详情", children: [
114
- /* @__PURE__ */ n("header", { className: "make-app-approval-detail-header", children: [
116
+ actions: r,
117
+ content: s,
118
+ footer: a
119
+ }) => /* @__PURE__ */ d("section", { className: "make-app-approval-detail", "aria-label": "审批详情", children: [
120
+ /* @__PURE__ */ d("header", { className: "make-app-approval-detail-header", children: [
115
121
  e,
116
- t
122
+ r
117
123
  ] }),
118
- /* @__PURE__ */ s("div", { className: "make-app-approval-detail-content", children: r }),
119
- o && /* @__PURE__ */ s("footer", { className: "make-app-approval-detail-footer", children: o })
120
- ] }), ce = (e) => /* @__PURE__ */ n("div", { className: "make-app-approval-detail-title", children: [
121
- /* @__PURE__ */ s("h2", { children: "审批详情" }),
122
- e && /* @__PURE__ */ s(Ee, { value: e })
123
- ] }), Re = (e) => {
124
- const [t, r] = u(0), [o, p] = u(), d = W(e);
125
- d.current = e, de(() => {
126
- const l = new AbortController(), k = d.current;
127
- return f(k.logger, { operation: "detail", phase: "start" }), (async () => {
124
+ /* @__PURE__ */ l("div", { className: "make-app-approval-detail-content", children: s }),
125
+ a && /* @__PURE__ */ l("footer", { className: "make-app-approval-detail-footer", children: a })
126
+ ] }), de = (e) => /* @__PURE__ */ d("div", { className: "make-app-approval-detail-title", children: [
127
+ /* @__PURE__ */ l("h2", { children: "审批详情" }),
128
+ e && /* @__PURE__ */ l(ve, { value: e })
129
+ ] }), Se = (e) => {
130
+ const [r, s] = y(0), [a, m] = y(), n = J(e);
131
+ n.current = e, M(() => {
132
+ const f = new AbortController(), o = n.current;
133
+ return u(o.logger, { operation: "detail", phase: "start" }), (async () => {
128
134
  try {
129
- if (await Promise.resolve(), l.signal.aborted) return;
130
- const c = pe(
131
- await k.provider.loadDetail(k.reference, {
132
- signal: l.signal
135
+ if (await Promise.resolve(), f.signal.aborted) return;
136
+ const c = me(
137
+ await o.provider.loadDetail(o.reference, {
138
+ signal: f.signal
133
139
  })
134
140
  );
135
- if (l.signal.aborted) return;
136
- if (!H(c, k))
141
+ if (f.signal.aborted) return;
142
+ if (!W(c, o))
137
143
  throw new Error("Task identity mismatch");
138
- p({ revision: t, detail: c }), f(k.logger, { operation: "detail", phase: "success" });
139
- } catch {
140
- if (l.signal.aborted) return;
141
- p({ revision: t, error: !0 }), f(k.logger, { operation: "detail", phase: "error" });
144
+ m({ revision: r, detail: c }), u(o.logger, { operation: "detail", phase: "success" });
145
+ } catch (c) {
146
+ if (f.signal.aborted) return;
147
+ m({ revision: r, error: !0 }), u(o.logger, { operation: "detail", phase: "error" }), o.onRequestError?.(c, {
148
+ operation: "detail",
149
+ resultUnknown: !1,
150
+ message: "审批详情加载失败,请重新加载详情"
151
+ });
142
152
  }
143
153
  })(), () => {
144
- l.abort(), f(k.logger, { operation: "detail", phase: "cancel" });
154
+ f.abort(), u(o.logger, { operation: "detail", phase: "cancel" });
145
155
  };
146
- }, [t]);
147
- const i = o?.revision === t ? o : void 0;
148
- return /* @__PURE__ */ s(
149
- Pe,
156
+ }, [r]);
157
+ const p = a?.revision === r ? a : void 0;
158
+ return /* @__PURE__ */ l(
159
+ je,
150
160
  {
151
161
  ...e,
152
- data: i?.detail,
153
- loadError: i?.error === !0,
154
- reload: () => r((l) => l + 1)
162
+ data: p?.detail,
163
+ loadError: p?.error === !0,
164
+ reload: () => s((f) => f + 1)
155
165
  },
156
- t
166
+ r
157
167
  );
158
- }, Pe = (e) => {
168
+ }, je = (e) => {
159
169
  const {
160
- components: { Button: t, Select: r, TextArea: o },
161
- renderField: p,
162
- reload: d
163
- } = e, i = Te(), [l, k] = u(), c = l ?? e.data, [g, B] = u({}), [U, S] = u(), [L, X] = u(""), [x, F] = u(""), [C, J] = u({}), [Y, v] = u(""), [w, Z] = u(!1), [R, me] = u(!1), [j, ye] = u(!1), K = W(!1), V = W(new AbortController());
164
- de(() => (V.current = new AbortController(), () => V.current.abort()), []);
165
- const _ = c ? q(c) : [], T = c?.actions.find((a) => a.actionType === U), ee = T ? Q(T) : !1, te = c?.actions.filter(Q) ?? [], ae = w || R || j, re = e.renderLayout ?? je, he = async () => {
166
- if (!c || !U || K.current || R || j) return;
167
- K.current = !0, Z(!0), v(""), J({});
168
- const a = V.current.signal, y = U;
169
- let I = !1;
170
- f(e.logger, {
170
+ components: { Button: r, TextArea: s },
171
+ renderField: a,
172
+ reload: m
173
+ } = e, n = Ee(), [p, f] = y(), o = p ?? e.data, [c, q] = y({}), [Q, T] = y(), [F, G] = y(""), [j, C] = y({}), [H, A] = y(""), [X, U] = y(""), [B, pe] = y(), [R, Y] = y(!1), [I, he] = y(!1), $ = J(!1), K = J(new AbortController());
174
+ M(() => (K.current = new AbortController(), () => K.current.abort()), []);
175
+ const Z = o ? P(o) : [], _ = o?.actions.find((t) => t.actionType === Q), ee = _ ? V(_) : !1, re = o?.actions.filter(V) ?? [], te = R || I, ae = e.renderLayout ?? Re;
176
+ M(() => {
177
+ B && document.getElementById(`${n}-${B.key}`)?.focus();
178
+ }, [B, n]);
179
+ const fe = async (t) => {
180
+ if (!o || $.current || I) return;
181
+ T(t), U(""), $.current = !0, Y(!0), A(""), C({});
182
+ const k = K.current.signal;
183
+ let w = !1;
184
+ u(e.logger, {
171
185
  operation: "action",
172
186
  phase: "start",
173
- actionType: y
187
+ actionType: t
174
188
  });
175
189
  try {
176
- le(c, y, g, L, x);
177
- const m = pe(
178
- await e.provider.loadDetail(e.reference, { signal: a })
190
+ ce(o, t, c, F);
191
+ const i = me(
192
+ await e.provider.loadDetail(e.reference, { signal: k })
179
193
  );
180
- if (a.aborted) return;
181
- if (!H(m, e)) throw new Error("Task identity mismatch");
182
- const be = q(c), M = q(m);
183
- if (JSON.stringify(be) !== JSON.stringify(M) || JSON.stringify(c.actions) !== JSON.stringify(m.actions)) {
184
- k(m), B({}), S(void 0), X(""), F(""), v("当前节点的字段或操作权限已变化,请核对后重新操作"), f(e.logger, {
194
+ if (k.aborted) return;
195
+ if (!W(i, e)) throw new Error("Task identity mismatch");
196
+ const O = P(o), L = P(i);
197
+ if (JSON.stringify(O) !== JSON.stringify(L) || JSON.stringify(o.actions) !== JSON.stringify(i.actions)) {
198
+ f(i), q({}), T(void 0), G(""), A("当前节点的字段或操作权限已变化,请核对后重新操作"), u(e.logger, {
185
199
  operation: "action",
186
200
  phase: "skip",
187
- actionType: y
201
+ actionType: t
188
202
  });
189
203
  return;
190
204
  }
191
- const oe = M.filter(
192
- (h) => !G(c.formData[h.key], m.formData[h.key])
205
+ const se = L.filter(
206
+ (h) => !z(o.formData[h.key], i.formData[h.key])
193
207
  );
194
- if (oe.length) {
195
- const h = new Set(oe.map((O) => O.key)), z = Object.keys(g).some((O) => h.has(O));
196
- k(m), B(Object.fromEntries(Object.entries(g).filter(([O]) => !h.has(O)))), S(void 0), F(""), v(z ? "申请内容已更新,冲突字段的本地修改已清除,其他修改已保留,请核对后重新操作" : "申请内容已更新,您的修改已保留,请核对后重新操作"), f(e.logger, { operation: "action", phase: "skip", actionType: y });
208
+ if (se.length) {
209
+ const h = new Set(se.map((N) => N.key)), x = Object.keys(c).some((N) => h.has(N));
210
+ f(i), q(Object.fromEntries(Object.entries(c).filter(([N]) => !h.has(N)))), T(void 0), A(x ? "申请内容已更新,冲突字段的本地修改已清除,其他修改已保留,请核对后重新操作" : "申请内容已更新,您的修改已保留,请核对后重新操作"), u(e.logger, { operation: "action", phase: "skip", actionType: t });
197
211
  return;
198
212
  }
199
- const P = M.filter(
213
+ const S = t === "RETURN" ? [] : L.filter(
200
214
  (h) => h.editable && h.required === !0
201
- ), ne = Object.fromEntries(
202
- P.map((h) => [
215
+ ), oe = Object.fromEntries(
216
+ S.map((h) => [
203
217
  h.key,
204
- Object.hasOwn(g, h.key) ? g[h.key] : m.formData[h.key]
218
+ Object.hasOwn(c, h.key) ? c[h.key] : i.formData[h.key]
205
219
  ])
206
- ), se = Se(
207
- P,
208
- ne
220
+ ), ne = Te(
221
+ S,
222
+ oe
209
223
  );
210
- if (Object.keys(se).length)
211
- throw new A(
224
+ if (Object.keys(ne).length)
225
+ throw new b(
212
226
  "请检查表单中标红的字段",
213
- se
227
+ ne
214
228
  );
215
- const ge = P.length ? await e.validateFields({
216
- fields: P,
217
- values: ne,
218
- actionType: y,
219
- signal: a
229
+ const be = S.length ? await e.validateFields({
230
+ fields: S,
231
+ values: oe,
232
+ actionType: t,
233
+ signal: k
220
234
  }) : {};
221
- if (a.aborted) return;
235
+ if (k.aborted) return;
222
236
  const ie = Object.fromEntries(
223
- Object.entries(ge).filter(
224
- ([h, z]) => P.some((O) => O.key === h) && !!z
237
+ Object.entries(be).filter(
238
+ ([h, x]) => S.some((N) => N.key === h) && !!x
225
239
  )
226
240
  );
227
241
  if (Object.keys(ie).length)
228
- throw new A(
242
+ throw new b(
229
243
  "请检查表单中标红的字段",
230
244
  ie
231
245
  );
232
- const ve = le(
233
- m,
234
- y,
235
- g,
236
- L,
237
- x
246
+ const ge = ce(
247
+ i,
248
+ t,
249
+ c,
250
+ F
238
251
  );
239
- I = !0;
240
- const E = await e.provider.submitAction(ve, { signal: a });
241
- if (a.aborted) return;
242
- if (!E || !H(E, e) || E.actionType !== y || typeof E.processEnded != "boolean" || typeof E.processStatus != "string" || !E.processStatus.trim())
252
+ w = !0;
253
+ const E = await e.provider.submitAction(ge, { signal: k });
254
+ if (k.aborted) return;
255
+ if (!E || !W(E, e) || E.actionType !== t || typeof E.processEnded != "boolean" || typeof E.processStatus != "string" || !E.processStatus.trim())
243
256
  throw new Error("Action result mismatch");
244
- ye(!0), S(void 0), k({ ...m, processStatus: E.processStatus }), v("处理成功"), f(e.logger, {
257
+ he(!0), T(void 0), f({ ...i, processStatus: E.processStatus }), A("处理成功"), u(e.logger, {
245
258
  operation: "action",
246
259
  phase: "success",
247
- actionType: y
248
- }), f(e.logger, {
260
+ actionType: t
261
+ }), u(e.logger, {
249
262
  operation: "notify",
250
263
  phase: "start",
251
- actionType: y
264
+ actionType: t
252
265
  });
253
266
  try {
254
- await e.onActionSuccess(E), f(e.logger, {
267
+ await e.onActionSuccess(E), u(e.logger, {
255
268
  operation: "notify",
256
269
  phase: "success",
257
- actionType: y
270
+ actionType: t
258
271
  });
259
272
  } catch {
260
- a.aborted || v("处理已成功,但页面刷新未完成,请刷新列表确认"), f(e.logger, {
273
+ k.aborted || A("处理已成功,但页面刷新未完成,请刷新列表确认"), u(e.logger, {
261
274
  operation: "notify",
262
275
  phase: "error",
263
- actionType: y
276
+ actionType: t
264
277
  });
265
278
  }
266
- } catch (m) {
267
- if (a.aborted) return;
268
- !I && m instanceof A ? (v(m.message), J(m.fieldErrors)) : (me(!0), S(void 0), v(
269
- I ? "操作结果尚未确认,请重新加载详情核查,勿重复提交" : "审批权限或字段校验暂不可用,请重新加载详情"
270
- )), f(e.logger, {
279
+ } catch (i) {
280
+ if (k.aborted) return;
281
+ if (!w && i instanceof b) {
282
+ C(i.fieldErrors);
283
+ const O = i.control === "comment" ? "comment" : Object.keys(i.fieldErrors)[0];
284
+ O && pe({ key: O }), i.control === "comment" ? U(i.message) : Object.keys(i.fieldErrors).length || A(i.message);
285
+ } else {
286
+ T(void 0);
287
+ const O = w ? "操作结果尚未确认,再次操作前将重新核查任务状态" : "审批信息或字段校验暂不可用,请稍后再次操作";
288
+ e.onRequestError ? e.onRequestError(i, {
289
+ operation: "action",
290
+ resultUnknown: w,
291
+ message: O
292
+ }) : A(O);
293
+ }
294
+ u(e.logger, {
271
295
  operation: "action",
272
296
  phase: "error",
273
- actionType: y
297
+ actionType: t
274
298
  });
275
299
  } finally {
276
- K.current = !1, a.aborted ? f(e.logger, {
300
+ $.current = !1, k.aborted ? u(e.logger, {
277
301
  operation: "action",
278
302
  phase: "cancel",
279
- actionType: y
280
- }) : Z(!1);
303
+ actionType: t
304
+ }) : Y(!1);
281
305
  }
282
306
  };
283
- if (!c)
284
- return re({
285
- title: ce(),
307
+ if (!o)
308
+ return ae({
309
+ title: de(),
286
310
  actions: null,
287
311
  footer: null,
288
- content: e.loadError ? /* @__PURE__ */ n("div", { className: "make-app-approval-detail-section", role: "alert", children: [
289
- "审批详情加载失败,请重试",
290
- /* @__PURE__ */ s(t, { htmlType: "button", variant: "default", onClick: d, children: "重新加载详情" })
291
- ] }) : /* @__PURE__ */ n("div", { className: "make-app-approval-detail-loading", role: "status", children: [
292
- /* @__PURE__ */ s("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
293
- /* @__PURE__ */ s("span", { children: "正在加载审批详情…" })
312
+ content: e.loadError ? /* @__PURE__ */ d("div", { className: "make-app-approval-detail-section", role: e.onRequestError ? void 0 : "alert", children: [
313
+ !e.onRequestError && "审批详情加载失败,请重试",
314
+ /* @__PURE__ */ l(r, { htmlType: "button", variant: "default", onClick: m, children: "重新加载详情" })
315
+ ] }) : /* @__PURE__ */ d("div", { className: "make-app-approval-detail-loading", role: "status", children: [
316
+ /* @__PURE__ */ l("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
317
+ /* @__PURE__ */ l("span", { children: "正在加载审批详情…" })
294
318
  ] })
295
319
  });
296
- const fe = !R && !j && c.actions.length > 0 ? /* @__PURE__ */ s("div", { className: "make-app-approval-detail-actions", "aria-label": "审批操作", children: c.actions.map((a) => /* @__PURE__ */ s(
297
- t,
320
+ const ue = !I && o.actions.length > 0 ? /* @__PURE__ */ l("div", { className: "make-app-approval-detail-actions", "aria-label": "审批操作", children: o.actions.map((t) => /* @__PURE__ */ l(
321
+ r,
298
322
  {
323
+ actionType: t.actionType,
299
324
  htmlType: "button",
300
- variant: a.actionType === "APPROVE" || a.actionType === "SUBMIT" ? "primary" : "default",
301
- disabled: w,
325
+ variant: t.actionType === "APPROVE" || t.actionType === "SUBMIT" ? "primary" : "default",
326
+ disabled: R,
327
+ loading: R && Q === t.actionType,
302
328
  onClick: () => {
303
- S(a.actionType), F(""), v(""), document.getElementById(`${i}-comment`)?.focus();
329
+ fe(t.actionType);
304
330
  },
305
- children: D[a.actionType]
331
+ children: le[t.actionType]
306
332
  },
307
- a.actionType
308
- )) }) : null, ue = /* @__PURE__ */ n("div", { className: "make-app-approval-detail-content", "aria-busy": w, children: [
309
- /* @__PURE__ */ n(
333
+ t.actionType
334
+ )) }) : null, ye = /* @__PURE__ */ d("div", { className: "make-app-approval-detail-content", "aria-busy": R, children: [
335
+ /* @__PURE__ */ d(
310
336
  "section",
311
337
  {
312
338
  className: "make-app-approval-detail-section",
313
339
  "aria-label": "申请信息",
314
340
  children: [
315
- /* @__PURE__ */ s("h3", { children: "申请信息" }),
316
- /* @__PURE__ */ n("div", { className: "make-app-approval-detail-fields", children: [
317
- _.length === 0 && /* @__PURE__ */ s("p", { children: "当前节点未配置可见字段" }),
318
- _.map((a) => /* @__PURE__ */ n(
341
+ /* @__PURE__ */ l("h3", { children: "申请信息" }),
342
+ /* @__PURE__ */ d("div", { className: "make-app-approval-detail-fields", children: [
343
+ Z.length === 0 && /* @__PURE__ */ l("p", { children: "当前节点未配置可见字段" }),
344
+ Z.map((t) => /* @__PURE__ */ d(
319
345
  "div",
320
346
  {
321
347
  className: "make-app-approval-detail-field",
322
- "data-invalid": !!C[a.key],
323
- "data-readonly": !a.editable,
324
- "data-full-width": !!a.fullWidth,
348
+ "data-invalid": !!j[t.key],
349
+ "data-readonly": !t.editable,
350
+ "data-full-width": !!t.fullWidth,
325
351
  children: [
326
- /* @__PURE__ */ n("label", { htmlFor: `${i}-${a.key}`, children: [
327
- e.renderFieldLabel?.(a) ?? a.label,
328
- a.required && a.editable ? /* @__PURE__ */ n(
352
+ /* @__PURE__ */ d("label", { htmlFor: `${n}-${t.key}`, children: [
353
+ e.renderFieldLabel?.(t) ?? t.label,
354
+ t.required && t.editable ? /* @__PURE__ */ d(
329
355
  "span",
330
356
  {
331
357
  className: "make-app-approval-required",
@@ -337,156 +363,97 @@ const Q = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.act
337
363
  }
338
364
  ) : null
339
365
  ] }),
340
- /* @__PURE__ */ n("div", { className: "make-app-approval-detail-value", children: [
341
- p({
342
- field: a,
343
- id: `${i}-${a.key}`,
344
- value: Object.hasOwn(g, a.key) ? g[a.key] : c.formData[a.key],
345
- readOnly: !a.editable,
346
- disabled: ae,
347
- error: C[a.key],
348
- ...a.editable && !ae ? {
349
- onChange: (y) => {
350
- B((I) => ({
351
- ...I,
352
- [a.key]: y
353
- })), J((I) => {
354
- const m = { ...I };
355
- return delete m[a.key], m;
366
+ /* @__PURE__ */ d("div", { className: "make-app-approval-detail-value", children: [
367
+ a({
368
+ field: t,
369
+ id: `${n}-${t.key}`,
370
+ value: Object.hasOwn(c, t.key) ? c[t.key] : o.formData[t.key],
371
+ readOnly: !t.editable,
372
+ disabled: te,
373
+ error: j[t.key],
374
+ ...t.editable && !te ? {
375
+ onChange: (k) => {
376
+ q((w) => ({
377
+ ...w,
378
+ [t.key]: k
379
+ })), C((w) => {
380
+ const i = { ...w };
381
+ return delete i[t.key], i;
356
382
  });
357
383
  }
358
384
  } : {}
359
385
  }),
360
- C[a.key] && /* @__PURE__ */ s("p", { role: "alert", className: "make-app-approval-detail-error", children: C[a.key] })
386
+ j[t.key] && /* @__PURE__ */ l("p", { role: "alert", className: "make-app-approval-detail-error", children: j[t.key] })
361
387
  ] })
362
388
  ]
363
389
  },
364
- a.key
390
+ t.key
365
391
  ))
366
392
  ] })
367
393
  ]
368
394
  }
369
395
  ),
370
- e.history != null && /* @__PURE__ */ n(
396
+ H && /* @__PURE__ */ l(
397
+ "p",
398
+ {
399
+ role: I ? "status" : "alert",
400
+ className: `make-app-approval-detail-message${I ? "" : " make-app-approval-detail-error"}`,
401
+ children: H
402
+ }
403
+ ),
404
+ e.history != null && /* @__PURE__ */ d(
371
405
  "section",
372
406
  {
373
407
  className: "make-app-approval-detail-section make-app-approval-detail-history",
374
408
  "aria-label": "审批流程",
375
409
  children: [
376
- /* @__PURE__ */ s("h3", { children: "审批流程" }),
410
+ /* @__PURE__ */ l("h3", { children: "审批流程" }),
377
411
  e.history
378
412
  ]
379
413
  }
380
- ),
381
- Y && /* @__PURE__ */ s(
382
- "p",
383
- {
384
- role: j ? "status" : "alert",
385
- className: `make-app-approval-detail-message${j ? "" : " make-app-approval-detail-error"}`,
386
- children: Y
387
- }
388
- ),
389
- R && /* @__PURE__ */ s("div", { className: "make-app-approval-detail-message", children: /* @__PURE__ */ s(t, { htmlType: "button", variant: "default", onClick: d, children: "重新加载详情" }) })
390
- ] }), ke = !R && !j && c.actions.length > 0 ? /* @__PURE__ */ n("div", { className: "make-app-approval-detail-section make-app-approval-detail-opinion", children: [
391
- /* @__PURE__ */ n("label", { htmlFor: `${i}-comment`, children: [
414
+ )
415
+ ] }), ke = !I && o.actions.length > 0 ? /* @__PURE__ */ d("div", { className: "make-app-approval-detail-section make-app-approval-detail-opinion", children: [
416
+ /* @__PURE__ */ d("label", { htmlFor: `${n}-comment`, children: [
392
417
  "审批意见",
393
- ee && /* @__PURE__ */ n("span", { className: "make-app-approval-required", "aria-label": "必填", children: [
418
+ ee && /* @__PURE__ */ d("span", { className: "make-app-approval-required", "aria-label": "必填", children: [
394
419
  " ",
395
420
  "*"
396
421
  ] })
397
422
  ] }),
398
- /* @__PURE__ */ s(
399
- o,
423
+ /* @__PURE__ */ l(
424
+ s,
400
425
  {
401
- id: `${i}-comment`,
426
+ id: `${n}-comment`,
402
427
  ariaLabel: "审批意见",
403
- value: L,
404
- onChange: X,
405
- placeholder: te.length ? `请输入审批意见,${te.map((a) => D[a.actionType]).join("、")}时必填` : "请输入审批意见",
406
- disabled: w,
428
+ value: F,
429
+ onChange: (t) => {
430
+ G(t), U("");
431
+ },
432
+ placeholder: re.length ? `请输入审批意见,${re.map((t) => le[t.actionType]).join("、")}时必填` : "请输入审批意见",
433
+ disabled: R,
407
434
  required: ee,
408
435
  maxLength: 1024
409
436
  }
410
437
  ),
411
- T && /* @__PURE__ */ n(
412
- "section",
413
- {
414
- className: "make-app-approval-action-confirm",
415
- "aria-label": `确认${D[T.actionType]}`,
416
- children: [
417
- /* @__PURE__ */ n("h3", { children: [
418
- "确认",
419
- D[T.actionType]
420
- ] }),
421
- T.actionType === "RETURN" && /* @__PURE__ */ n("div", { className: "make-app-approval-detail-target", children: [
422
- /* @__PURE__ */ s("label", { htmlFor: `${i}-target`, children: "退回节点" }),
423
- /* @__PURE__ */ s(
424
- r,
425
- {
426
- id: `${i}-target`,
427
- ariaLabel: "退回节点",
428
- value: x,
429
- onChange: F,
430
- disabled: w,
431
- options: [
432
- { value: "", label: "请选择退回节点" },
433
- ...(T.returnTargets ?? []).map((a) => ({
434
- value: a.nodeKey,
435
- label: a.nodeName
436
- }))
437
- ]
438
- }
439
- )
440
- ] }),
441
- /* @__PURE__ */ n("div", { className: "make-app-approval-detail-actions", children: [
442
- /* @__PURE__ */ n(
443
- t,
444
- {
445
- htmlType: "button",
446
- variant: "primary",
447
- disabled: w,
448
- loading: w,
449
- onClick: () => {
450
- he();
451
- },
452
- children: [
453
- "确认",
454
- D[T.actionType]
455
- ]
456
- }
457
- ),
458
- /* @__PURE__ */ s(
459
- t,
460
- {
461
- htmlType: "button",
462
- variant: "default",
463
- disabled: w,
464
- onClick: () => S(void 0),
465
- children: "取消"
466
- }
467
- )
468
- ] })
469
- ]
470
- }
471
- )
438
+ X && /* @__PURE__ */ l("p", { role: "alert", className: "make-app-approval-detail-error", children: X })
472
439
  ] }) : null;
473
- return re({
474
- title: ce(c.processStatus),
475
- actions: fe,
476
- content: /* @__PURE__ */ n(we, { children: [
477
- ue,
440
+ return ae({
441
+ title: de(o.processStatus),
442
+ actions: ue,
443
+ content: /* @__PURE__ */ d(we, { children: [
444
+ ye,
478
445
  ke
479
446
  ] }),
480
447
  footer: null
481
448
  });
482
- }, $e = (e) => {
449
+ }, Ce = (e) => {
483
450
  if (!e.scopeKey.trim() || !e.reference.taskId.trim() || !e.reference.processInstanceId.trim())
484
451
  throw new Error("ApprovalTaskDetail requires scopeKey and task reference");
485
- for (const t of ["Button", "Select", "TextArea"])
486
- if (!e.components?.[t])
487
- throw new Error(`ApprovalTaskDetail requires components.${t}`);
488
- return /* @__PURE__ */ s(
489
- Re,
452
+ for (const r of ["Button", "TextArea"])
453
+ if (!e.components?.[r])
454
+ throw new Error(`ApprovalTaskDetail requires components.${r}`);
455
+ return /* @__PURE__ */ l(
456
+ Se,
490
457
  {
491
458
  ...e
492
459
  },
@@ -498,9 +465,9 @@ const Q = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.act
498
465
  );
499
466
  };
500
467
  export {
501
- $e as ApprovalTaskDetail,
502
- A as ApprovalTaskValidationError,
503
- le as buildApprovalTaskAction,
504
- q as getApprovalTaskFields,
505
- pe as readApprovalTaskDetail
468
+ Ce as ApprovalTaskDetail,
469
+ b as ApprovalTaskValidationError,
470
+ ce as buildApprovalTaskAction,
471
+ P as getApprovalTaskFields,
472
+ me as readApprovalTaskDetail
506
473
  };