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

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";
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) => {
1
+ import { jsx as c, jsxs as m, Fragment as Ee } from "react/jsx-runtime";
2
+ import { useState as f, useRef as V, useEffect as M, useId as Ae } from "react";
3
+ import { ApprovalStatus as Ne } from "./react.mjs";
4
+ import { isApprovalSystemField as Oe } from "./index.mjs";
5
+ const v = (e) => !!e && typeof e == "object" && !Array.isArray(e), g = (e) => typeof e == "string" && e.trim().length > 0, Te = ["APPROVE", "REJECT", "RETURN", "SUBMIT"], F = (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
+ }, Ie = (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)), Se = (e) => {
13
+ if (!v(e) || !Te.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;
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
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))
18
+ if (!v(e) || !g(e.taskId) || !g(e.processInstanceId) || !g(e.taskName) || !g(e.processStatus) || !Array.isArray(e.fields) || !e.fields.every(Ie) || !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 = F(s?.viewPermission), d = F(s?.editPermission);
25
+ if (a.some((p) => !r.includes(p)) || d.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(Se) || 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,315 @@ 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: d }
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
+ }, D = (e) => {
44
+ const r = new Set(
45
+ F(e.fieldPermission?.viewPermission)
46
+ ), s = new Set(
47
+ F(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) && !Oe(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 z = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.actionType === "SUBMIT" && e.commentPolicy === "REQUIRED", Re = (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
+ ), le = (e, r, s, a, d = "") => {
67
+ const n = e.actions.find((l) => l.actionType === r);
68
+ if (!n)
69
+ throw new b("当前节点不允许此操作,请刷新详情");
70
+ const p = r === "RETURN" ? {} : s, y = new Set(
71
+ D(e).filter((l) => l.editable).map((l) => l.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((l) => !y.has(l)))
74
+ throw new b("字段权限已变化,请重新加载详情");
75
+ if (z(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 && d && d !== 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
+ }, W = (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((d, n) => W(d, 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((d) => Object.hasOwn(a, d) && W(s[d], a[d]));
109
+ }, de = {
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
+ }, Q = (e, r) => e.taskId === r.reference.taskId && e.processInstanceId === r.reference.processInstanceId, je = ({
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__ */ m("section", { className: "make-app-approval-detail", "aria-label": "审批详情", children: [
120
+ /* @__PURE__ */ m("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__ */ c("div", { className: "make-app-approval-detail-content", children: s }),
125
+ a && /* @__PURE__ */ c("footer", { className: "make-app-approval-detail-footer", children: a })
126
+ ] }), me = (e) => /* @__PURE__ */ m("div", { className: "make-app-approval-detail-title", children: [
127
+ /* @__PURE__ */ c("h2", { children: "审批详情" }),
128
+ e && /* @__PURE__ */ c(Ne, { value: e })
129
+ ] }), Pe = (e) => {
130
+ const [r, s] = f(0), [a, d] = f(), n = V(e);
131
+ n.current = e, M(() => {
132
+ const y = 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(), y.signal.aborted) return;
136
+ const l = pe(
137
+ await o.provider.loadDetail(o.reference, {
138
+ signal: y.signal
133
139
  })
134
140
  );
135
- if (l.signal.aborted) return;
136
- if (!H(c, k))
141
+ if (y.signal.aborted) return;
142
+ if (!Q(l, o))
137
143
  throw new Error("Task identity mismatch");
138
- p({ revision: t, detail: c }), f(k.logger, { operation: "detail", phase: "success" });
144
+ d({ revision: r, detail: l }), u(o.logger, { operation: "detail", phase: "success" });
139
145
  } catch {
140
- if (l.signal.aborted) return;
141
- p({ revision: t, error: !0 }), f(k.logger, { operation: "detail", phase: "error" });
146
+ if (y.signal.aborted) return;
147
+ d({ revision: r, error: !0 }), u(o.logger, { operation: "detail", phase: "error" });
142
148
  }
143
149
  })(), () => {
144
- l.abort(), f(k.logger, { operation: "detail", phase: "cancel" });
150
+ y.abort(), u(o.logger, { operation: "detail", phase: "cancel" });
145
151
  };
146
- }, [t]);
147
- const i = o?.revision === t ? o : void 0;
148
- return /* @__PURE__ */ s(
149
- Pe,
152
+ }, [r]);
153
+ const p = a?.revision === r ? a : void 0;
154
+ return /* @__PURE__ */ c(
155
+ De,
150
156
  {
151
157
  ...e,
152
- data: i?.detail,
153
- loadError: i?.error === !0,
154
- reload: () => r((l) => l + 1)
158
+ data: p?.detail,
159
+ loadError: p?.error === !0,
160
+ reload: () => s((y) => y + 1)
155
161
  },
156
- t
162
+ r
157
163
  );
158
- }, Pe = (e) => {
164
+ }, De = (e) => {
159
165
  const {
160
- components: { Button: t, Select: r, TextArea: o },
161
- renderField: p,
166
+ components: { Button: r, TextArea: s },
167
+ renderField: a,
162
168
  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, {
169
+ } = e, n = Ae(), [p, y] = f(), o = p ?? e.data, [l, C] = f({}), [G, T] = f(), [q, H] = f(""), [j, B] = f({}), [X, E] = f(""), [Y, U] = f(""), [$, he] = f(), [I, Z] = f(!1), [S, ye] = f(!1), [O, fe] = f(!1), K = V(!1), L = V(new AbortController());
170
+ M(() => (L.current = new AbortController(), () => L.current.abort()), []);
171
+ const _ = o ? D(o) : [], ee = o?.actions.find((t) => t.actionType === G), re = ee ? z(ee) : !1, te = o?.actions.filter(z) ?? [], ae = I || S || O, se = e.renderLayout ?? je;
172
+ M(() => {
173
+ $ && document.getElementById(`${n}-${$.key}`)?.focus();
174
+ }, [$, n]);
175
+ const ue = async (t) => {
176
+ if (!o || K.current || S || O) return;
177
+ T(t), U(""), K.current = !0, Z(!0), E(""), B({});
178
+ const k = L.current.signal;
179
+ let A = !1;
180
+ u(e.logger, {
171
181
  operation: "action",
172
182
  phase: "start",
173
- actionType: y
183
+ actionType: t
174
184
  });
175
185
  try {
176
- le(c, y, g, L, x);
177
- const m = pe(
178
- await e.provider.loadDetail(e.reference, { signal: a })
186
+ le(o, t, l, q);
187
+ const i = pe(
188
+ await e.provider.loadDetail(e.reference, { signal: k })
179
189
  );
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, {
190
+ if (k.aborted) return;
191
+ if (!Q(i, e)) throw new Error("Task identity mismatch");
192
+ const P = D(o), x = D(i);
193
+ if (JSON.stringify(P) !== JSON.stringify(x) || JSON.stringify(o.actions) !== JSON.stringify(i.actions)) {
194
+ y(i), C({}), T(void 0), H(""), E("当前节点的字段或操作权限已变化,请核对后重新操作"), u(e.logger, {
185
195
  operation: "action",
186
196
  phase: "skip",
187
- actionType: y
197
+ actionType: t
188
198
  });
189
199
  return;
190
200
  }
191
- const oe = M.filter(
192
- (h) => !G(c.formData[h.key], m.formData[h.key])
201
+ const oe = x.filter(
202
+ (h) => !W(o.formData[h.key], i.formData[h.key])
193
203
  );
194
204
  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 });
205
+ const h = new Set(oe.map((N) => N.key)), J = Object.keys(l).some((N) => h.has(N));
206
+ y(i), C(Object.fromEntries(Object.entries(l).filter(([N]) => !h.has(N)))), T(void 0), E(J ? "申请内容已更新,冲突字段的本地修改已清除,其他修改已保留,请核对后重新操作" : "申请内容已更新,您的修改已保留,请核对后重新操作"), u(e.logger, { operation: "action", phase: "skip", actionType: t });
197
207
  return;
198
208
  }
199
- const P = M.filter(
209
+ const R = t === "RETURN" ? [] : x.filter(
200
210
  (h) => h.editable && h.required === !0
201
211
  ), ne = Object.fromEntries(
202
- P.map((h) => [
212
+ R.map((h) => [
203
213
  h.key,
204
- Object.hasOwn(g, h.key) ? g[h.key] : m.formData[h.key]
214
+ Object.hasOwn(l, h.key) ? l[h.key] : i.formData[h.key]
205
215
  ])
206
- ), se = Se(
207
- P,
216
+ ), ie = Re(
217
+ R,
208
218
  ne
209
219
  );
210
- if (Object.keys(se).length)
211
- throw new A(
220
+ if (Object.keys(ie).length)
221
+ throw new b(
212
222
  "请检查表单中标红的字段",
213
- se
223
+ ie
214
224
  );
215
- const ge = P.length ? await e.validateFields({
216
- fields: P,
225
+ const we = R.length ? await e.validateFields({
226
+ fields: R,
217
227
  values: ne,
218
- actionType: y,
219
- signal: a
228
+ actionType: t,
229
+ signal: k
220
230
  }) : {};
221
- if (a.aborted) return;
222
- const ie = Object.fromEntries(
223
- Object.entries(ge).filter(
224
- ([h, z]) => P.some((O) => O.key === h) && !!z
231
+ if (k.aborted) return;
232
+ const ce = Object.fromEntries(
233
+ Object.entries(we).filter(
234
+ ([h, J]) => R.some((N) => N.key === h) && !!J
225
235
  )
226
236
  );
227
- if (Object.keys(ie).length)
228
- throw new A(
237
+ if (Object.keys(ce).length)
238
+ throw new b(
229
239
  "请检查表单中标红的字段",
230
- ie
240
+ ce
231
241
  );
232
242
  const ve = le(
233
- m,
234
- y,
235
- g,
236
- L,
237
- x
243
+ i,
244
+ t,
245
+ l,
246
+ q
238
247
  );
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())
248
+ A = !0;
249
+ const w = await e.provider.submitAction(ve, { signal: k });
250
+ if (k.aborted) return;
251
+ if (!w || !Q(w, e) || w.actionType !== t || typeof w.processEnded != "boolean" || typeof w.processStatus != "string" || !w.processStatus.trim())
243
252
  throw new Error("Action result mismatch");
244
- ye(!0), S(void 0), k({ ...m, processStatus: E.processStatus }), v("处理成功"), f(e.logger, {
253
+ fe(!0), T(void 0), y({ ...i, processStatus: w.processStatus }), E("处理成功"), u(e.logger, {
245
254
  operation: "action",
246
255
  phase: "success",
247
- actionType: y
248
- }), f(e.logger, {
256
+ actionType: t
257
+ }), u(e.logger, {
249
258
  operation: "notify",
250
259
  phase: "start",
251
- actionType: y
260
+ actionType: t
252
261
  });
253
262
  try {
254
- await e.onActionSuccess(E), f(e.logger, {
263
+ await e.onActionSuccess(w), u(e.logger, {
255
264
  operation: "notify",
256
265
  phase: "success",
257
- actionType: y
266
+ actionType: t
258
267
  });
259
268
  } catch {
260
- a.aborted || v("处理已成功,但页面刷新未完成,请刷新列表确认"), f(e.logger, {
269
+ k.aborted || E("处理已成功,但页面刷新未完成,请刷新列表确认"), u(e.logger, {
261
270
  operation: "notify",
262
271
  phase: "error",
263
- actionType: y
272
+ actionType: t
264
273
  });
265
274
  }
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, {
275
+ } catch (i) {
276
+ if (k.aborted) return;
277
+ if (!A && i instanceof b) {
278
+ B(i.fieldErrors);
279
+ const P = i.control === "comment" ? "comment" : Object.keys(i.fieldErrors)[0];
280
+ P && he({ key: P }), i.control === "comment" ? U(i.message) : Object.keys(i.fieldErrors).length || E(i.message);
281
+ } else
282
+ ye(!0), T(void 0), E(
283
+ A ? "操作结果尚未确认,请重新加载详情核查,勿重复提交" : "审批权限或字段校验暂不可用,请重新加载详情"
284
+ );
285
+ u(e.logger, {
271
286
  operation: "action",
272
287
  phase: "error",
273
- actionType: y
288
+ actionType: t
274
289
  });
275
290
  } finally {
276
- K.current = !1, a.aborted ? f(e.logger, {
291
+ K.current = !1, k.aborted ? u(e.logger, {
277
292
  operation: "action",
278
293
  phase: "cancel",
279
- actionType: y
294
+ actionType: t
280
295
  }) : Z(!1);
281
296
  }
282
297
  };
283
- if (!c)
284
- return re({
285
- title: ce(),
298
+ if (!o)
299
+ return se({
300
+ title: me(),
286
301
  actions: null,
287
302
  footer: null,
288
- content: e.loadError ? /* @__PURE__ */ n("div", { className: "make-app-approval-detail-section", role: "alert", children: [
303
+ content: e.loadError ? /* @__PURE__ */ m("div", { className: "make-app-approval-detail-section", role: "alert", children: [
289
304
  "审批详情加载失败,请重试",
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: "正在加载审批详情…" })
305
+ /* @__PURE__ */ c(r, { htmlType: "button", variant: "default", onClick: d, children: "重新加载详情" })
306
+ ] }) : /* @__PURE__ */ m("div", { className: "make-app-approval-detail-loading", role: "status", children: [
307
+ /* @__PURE__ */ c("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
308
+ /* @__PURE__ */ c("span", { children: "正在加载审批详情…" })
294
309
  ] })
295
310
  });
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,
311
+ const ke = !S && !O && o.actions.length > 0 ? /* @__PURE__ */ c("div", { className: "make-app-approval-detail-actions", "aria-label": "审批操作", children: o.actions.map((t) => /* @__PURE__ */ c(
312
+ r,
298
313
  {
314
+ actionType: t.actionType,
299
315
  htmlType: "button",
300
- variant: a.actionType === "APPROVE" || a.actionType === "SUBMIT" ? "primary" : "default",
301
- disabled: w,
316
+ variant: t.actionType === "APPROVE" || t.actionType === "SUBMIT" ? "primary" : "default",
317
+ disabled: I,
318
+ loading: I && G === t.actionType,
302
319
  onClick: () => {
303
- S(a.actionType), F(""), v(""), document.getElementById(`${i}-comment`)?.focus();
320
+ ue(t.actionType);
304
321
  },
305
- children: D[a.actionType]
322
+ children: de[t.actionType]
306
323
  },
307
- a.actionType
308
- )) }) : null, ue = /* @__PURE__ */ n("div", { className: "make-app-approval-detail-content", "aria-busy": w, children: [
309
- /* @__PURE__ */ n(
324
+ t.actionType
325
+ )) }) : null, be = /* @__PURE__ */ m("div", { className: "make-app-approval-detail-content", "aria-busy": I, children: [
326
+ /* @__PURE__ */ m(
310
327
  "section",
311
328
  {
312
329
  className: "make-app-approval-detail-section",
313
330
  "aria-label": "申请信息",
314
331
  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(
332
+ /* @__PURE__ */ c("h3", { children: "申请信息" }),
333
+ /* @__PURE__ */ m("div", { className: "make-app-approval-detail-fields", children: [
334
+ _.length === 0 && /* @__PURE__ */ c("p", { children: "当前节点未配置可见字段" }),
335
+ _.map((t) => /* @__PURE__ */ m(
319
336
  "div",
320
337
  {
321
338
  className: "make-app-approval-detail-field",
322
- "data-invalid": !!C[a.key],
323
- "data-readonly": !a.editable,
324
- "data-full-width": !!a.fullWidth,
339
+ "data-invalid": !!j[t.key],
340
+ "data-readonly": !t.editable,
341
+ "data-full-width": !!t.fullWidth,
325
342
  children: [
326
- /* @__PURE__ */ n("label", { htmlFor: `${i}-${a.key}`, children: [
327
- e.renderFieldLabel?.(a) ?? a.label,
328
- a.required && a.editable ? /* @__PURE__ */ n(
343
+ /* @__PURE__ */ m("label", { htmlFor: `${n}-${t.key}`, children: [
344
+ e.renderFieldLabel?.(t) ?? t.label,
345
+ t.required && t.editable ? /* @__PURE__ */ m(
329
346
  "span",
330
347
  {
331
348
  className: "make-app-approval-required",
@@ -337,156 +354,98 @@ const Q = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.act
337
354
  }
338
355
  ) : null
339
356
  ] }),
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,
357
+ /* @__PURE__ */ m("div", { className: "make-app-approval-detail-value", children: [
358
+ a({
359
+ field: t,
360
+ id: `${n}-${t.key}`,
361
+ value: Object.hasOwn(l, t.key) ? l[t.key] : o.formData[t.key],
362
+ readOnly: !t.editable,
346
363
  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;
364
+ error: j[t.key],
365
+ ...t.editable && !ae ? {
366
+ onChange: (k) => {
367
+ C((A) => ({
368
+ ...A,
369
+ [t.key]: k
370
+ })), B((A) => {
371
+ const i = { ...A };
372
+ return delete i[t.key], i;
356
373
  });
357
374
  }
358
375
  } : {}
359
376
  }),
360
- C[a.key] && /* @__PURE__ */ s("p", { role: "alert", className: "make-app-approval-detail-error", children: C[a.key] })
377
+ j[t.key] && /* @__PURE__ */ c("p", { role: "alert", className: "make-app-approval-detail-error", children: j[t.key] })
361
378
  ] })
362
379
  ]
363
380
  },
364
- a.key
381
+ t.key
365
382
  ))
366
383
  ] })
367
384
  ]
368
385
  }
369
386
  ),
370
- e.history != null && /* @__PURE__ */ n(
387
+ X && /* @__PURE__ */ c(
388
+ "p",
389
+ {
390
+ role: O ? "status" : "alert",
391
+ className: `make-app-approval-detail-message${O ? "" : " make-app-approval-detail-error"}`,
392
+ children: X
393
+ }
394
+ ),
395
+ S && /* @__PURE__ */ c("div", { className: "make-app-approval-detail-message", children: /* @__PURE__ */ c(r, { htmlType: "button", variant: "default", onClick: d, children: "重新加载详情" }) }),
396
+ e.history != null && /* @__PURE__ */ m(
371
397
  "section",
372
398
  {
373
399
  className: "make-app-approval-detail-section make-app-approval-detail-history",
374
400
  "aria-label": "审批流程",
375
401
  children: [
376
- /* @__PURE__ */ s("h3", { children: "审批流程" }),
402
+ /* @__PURE__ */ c("h3", { children: "审批流程" }),
377
403
  e.history
378
404
  ]
379
405
  }
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: [
406
+ )
407
+ ] }), ge = !S && !O && o.actions.length > 0 ? /* @__PURE__ */ m("div", { className: "make-app-approval-detail-section make-app-approval-detail-opinion", children: [
408
+ /* @__PURE__ */ m("label", { htmlFor: `${n}-comment`, children: [
392
409
  "审批意见",
393
- ee && /* @__PURE__ */ n("span", { className: "make-app-approval-required", "aria-label": "必填", children: [
410
+ re && /* @__PURE__ */ m("span", { className: "make-app-approval-required", "aria-label": "必填", children: [
394
411
  " ",
395
412
  "*"
396
413
  ] })
397
414
  ] }),
398
- /* @__PURE__ */ s(
399
- o,
415
+ /* @__PURE__ */ c(
416
+ s,
400
417
  {
401
- id: `${i}-comment`,
418
+ id: `${n}-comment`,
402
419
  ariaLabel: "审批意见",
403
- value: L,
404
- onChange: X,
405
- placeholder: te.length ? `请输入审批意见,${te.map((a) => D[a.actionType]).join("、")}时必填` : "请输入审批意见",
406
- disabled: w,
407
- required: ee,
420
+ value: q,
421
+ onChange: (t) => {
422
+ H(t), U("");
423
+ },
424
+ placeholder: te.length ? `请输入审批意见,${te.map((t) => de[t.actionType]).join("、")}时必填` : "请输入审批意见",
425
+ disabled: I,
426
+ required: re,
408
427
  maxLength: 1024
409
428
  }
410
429
  ),
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
- )
430
+ Y && /* @__PURE__ */ c("p", { role: "alert", className: "make-app-approval-detail-error", children: Y })
472
431
  ] }) : null;
473
- return re({
474
- title: ce(c.processStatus),
475
- actions: fe,
476
- content: /* @__PURE__ */ n(we, { children: [
477
- ue,
478
- ke
432
+ return se({
433
+ title: me(o.processStatus),
434
+ actions: ke,
435
+ content: /* @__PURE__ */ m(Ee, { children: [
436
+ be,
437
+ ge
479
438
  ] }),
480
439
  footer: null
481
440
  });
482
- }, $e = (e) => {
441
+ }, Ue = (e) => {
483
442
  if (!e.scopeKey.trim() || !e.reference.taskId.trim() || !e.reference.processInstanceId.trim())
484
443
  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,
444
+ for (const r of ["Button", "TextArea"])
445
+ if (!e.components?.[r])
446
+ throw new Error(`ApprovalTaskDetail requires components.${r}`);
447
+ return /* @__PURE__ */ c(
448
+ Pe,
490
449
  {
491
450
  ...e
492
451
  },
@@ -498,9 +457,9 @@ const Q = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.act
498
457
  );
499
458
  };
500
459
  export {
501
- $e as ApprovalTaskDetail,
502
- A as ApprovalTaskValidationError,
460
+ Ue as ApprovalTaskDetail,
461
+ b as ApprovalTaskValidationError,
503
462
  le as buildApprovalTaskAction,
504
- q as getApprovalTaskFields,
463
+ D as getApprovalTaskFields,
505
464
  pe as readApprovalTaskDetail
506
465
  };