@qfei-design/make-app-approval 0.2.6 → 0.2.8

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