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

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