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