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