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