@qfei-design/make-app-approval 0.2.11 → 0.2.13
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 +19 -7
- package/README.md +8 -4
- package/capabilities.json +2 -2
- package/dist/detail/approval-instance-detail.d.ts +3 -0
- package/dist/detail/index.d.ts +3 -0
- package/dist/detail/instance-policy.d.ts +3 -0
- package/dist/detail/instance-types.d.ts +42 -0
- package/dist/detail/task-policy.d.ts +3 -0
- package/dist/detail/types.d.ts +3 -1
- package/dist/detail.cjs +1 -1
- package/dist/detail.mjs +343 -272
- package/dist/list/approval-columns.d.ts +2 -1
- package/dist/list/types.d.ts +5 -1
- package/dist/list.cjs +1 -1
- package/dist/list.mjs +302 -296
- package/dist/styles.css +13 -0
- package/docs/host-integration.md +7 -6
- package/docs/publishing.md +2 -2
- package/examples/antd-components.tsx +4 -1
- package/examples/detail-integration.tsx +2 -2
- package/package.ai.json +3 -4
- package/package.json +1 -1
- package/recipes.json +2 -1
package/dist/detail.mjs
CHANGED
|
@@ -1,358 +1,359 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { ApprovalStatus as
|
|
4
|
-
import { isApprovalSystemField as
|
|
5
|
-
const
|
|
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 (!
|
|
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(
|
|
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
|
-
},
|
|
13
|
-
if (!
|
|
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
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
if (!
|
|
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
|
|
21
|
-
if (new Set(
|
|
22
|
-
if (e.fieldPermission !== void 0 && !
|
|
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 =
|
|
25
|
-
if (a.some((
|
|
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
|
|
28
|
-
if (!Array.isArray(
|
|
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
|
|
30
|
+
const h = e.summary;
|
|
31
31
|
return {
|
|
32
32
|
taskId: e.taskId,
|
|
33
33
|
processInstanceId: e.processInstanceId,
|
|
34
34
|
taskName: e.taskName,
|
|
35
|
-
...
|
|
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:
|
|
39
|
+
actions: s,
|
|
40
40
|
fieldPermission: {
|
|
41
41
|
viewPermission: { scope: "FIELDS", fields: a },
|
|
42
|
-
editPermission: { scope: "FIELDS", fields:
|
|
42
|
+
editPermission: { scope: "FIELDS", fields: c }
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
},
|
|
46
|
-
const
|
|
47
|
-
|
|
45
|
+
}, K = (e) => {
|
|
46
|
+
const t = new Set(
|
|
47
|
+
B(e.fieldPermission?.viewPermission)
|
|
48
48
|
), o = new Set(
|
|
49
|
-
|
|
49
|
+
B(e.fieldPermission?.editPermission)
|
|
50
50
|
);
|
|
51
|
-
return e.fields.filter((a) =>
|
|
51
|
+
return e.fields.filter((a) => t.has(a.key)).map((a) => ({
|
|
52
52
|
...a,
|
|
53
|
-
editable: o.has(a.key) && !
|
|
53
|
+
editable: o.has(a.key) && !Re(a.key)
|
|
54
54
|
}));
|
|
55
55
|
};
|
|
56
|
-
class
|
|
57
|
-
constructor(
|
|
58
|
-
super(
|
|
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
|
|
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 =
|
|
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,
|
|
69
|
-
const
|
|
70
|
-
if (!
|
|
71
|
-
throw new
|
|
72
|
-
const
|
|
73
|
-
|
|
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(
|
|
76
|
-
throw new
|
|
77
|
-
if (
|
|
78
|
-
throw new
|
|
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
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
throw new
|
|
84
|
-
|
|
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 (
|
|
87
|
-
throw new
|
|
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:
|
|
91
|
+
actionType: t,
|
|
92
92
|
comment: a.trim(),
|
|
93
|
-
recordPatch: { ...
|
|
94
|
-
...
|
|
93
|
+
recordPatch: { ...h },
|
|
94
|
+
...n ? { targetNodeKey: n.nodeKey } : {}
|
|
95
95
|
};
|
|
96
|
-
},
|
|
96
|
+
}, f = (e, t) => {
|
|
97
97
|
try {
|
|
98
|
-
e ? e(
|
|
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
|
-
},
|
|
103
|
-
if (Object.is(e,
|
|
104
|
-
if (e instanceof Date &&
|
|
105
|
-
return Object.is(e.getTime(),
|
|
106
|
-
if (Array.isArray(e) || Array.isArray(
|
|
107
|
-
return Array.isArray(e) && Array.isArray(
|
|
108
|
-
if (!e || !
|
|
109
|
-
const o = e, a =
|
|
110
|
-
return Object.keys(o).length === Object.keys(a).length && Object.keys(o).every((
|
|
111
|
-
},
|
|
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
|
-
},
|
|
116
|
+
}, Y = (e, t) => e.taskId === t.reference.taskId && e.processInstanceId === t.reference.processInstanceId, qe = ({
|
|
117
117
|
title: e,
|
|
118
|
-
actions:
|
|
118
|
+
actions: t,
|
|
119
119
|
content: o,
|
|
120
120
|
footer: a
|
|
121
|
-
}) => /* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
124
|
+
t
|
|
125
125
|
] }),
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
-
a && /* @__PURE__ */
|
|
128
|
-
] }),
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
e && /* @__PURE__ */
|
|
131
|
-
] }),
|
|
132
|
-
const [
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
return
|
|
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(),
|
|
138
|
-
const
|
|
139
|
-
await
|
|
140
|
-
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 (
|
|
144
|
-
if (!
|
|
143
|
+
if (l.signal.aborted) return;
|
|
144
|
+
if (!Y(p, n))
|
|
145
145
|
throw new Error("Task identity mismatch");
|
|
146
|
-
|
|
147
|
-
} catch (
|
|
148
|
-
if (
|
|
149
|
-
|
|
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
|
-
|
|
156
|
+
l.abort(), f(n.logger, { operation: "detail", phase: "cancel" });
|
|
157
157
|
};
|
|
158
|
-
}, [
|
|
159
|
-
const
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
|
|
158
|
+
}, [t]);
|
|
159
|
+
const h = a?.revision === t ? a : void 0;
|
|
160
|
+
return /* @__PURE__ */ i(
|
|
161
|
+
Ce,
|
|
162
162
|
{
|
|
163
163
|
...e,
|
|
164
|
-
data:
|
|
165
|
-
loadError:
|
|
166
|
-
reload: () => o((
|
|
164
|
+
data: h?.detail,
|
|
165
|
+
loadError: h?.error === !0,
|
|
166
|
+
reload: () => o((l) => l + 1)
|
|
167
167
|
},
|
|
168
|
-
|
|
168
|
+
t
|
|
169
169
|
);
|
|
170
|
-
},
|
|
170
|
+
}, Ce = (e) => {
|
|
171
171
|
const {
|
|
172
|
-
components: { Button:
|
|
172
|
+
components: { Button: t, TextArea: o },
|
|
173
173
|
renderField: a,
|
|
174
|
-
reload:
|
|
175
|
-
} = e,
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}, [
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
let
|
|
186
|
-
|
|
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:
|
|
189
|
+
actionType: r
|
|
190
190
|
});
|
|
191
191
|
try {
|
|
192
|
-
fe(
|
|
193
|
-
const
|
|
194
|
-
await e.provider.loadDetail(e.reference, { signal:
|
|
192
|
+
fe(n, r, p, F);
|
|
193
|
+
const m = we(
|
|
194
|
+
await e.provider.loadDetail(e.reference, { signal: g })
|
|
195
195
|
);
|
|
196
|
-
if (
|
|
197
|
-
if (!
|
|
198
|
-
const
|
|
199
|
-
if (JSON.stringify(
|
|
200
|
-
|
|
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:
|
|
203
|
+
actionType: r
|
|
204
204
|
});
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
const
|
|
208
|
-
(
|
|
207
|
+
const pe = W.filter(
|
|
208
|
+
(u) => !X(n.formData[u.key], m.formData[u.key])
|
|
209
209
|
);
|
|
210
|
-
if (
|
|
211
|
-
const
|
|
212
|
-
|
|
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
|
|
216
|
-
(
|
|
215
|
+
const $ = r === "RETURN" ? [] : W.filter(
|
|
216
|
+
(u) => u.editable && u.required === !0
|
|
217
217
|
), me = Object.fromEntries(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
Object.hasOwn(
|
|
218
|
+
$.map((u) => [
|
|
219
|
+
u.key,
|
|
220
|
+
Object.hasOwn(p, u.key) ? p[u.key] : m.formData[u.key]
|
|
221
221
|
])
|
|
222
|
-
),
|
|
223
|
-
|
|
222
|
+
), he = je(
|
|
223
|
+
$,
|
|
224
224
|
me
|
|
225
225
|
);
|
|
226
|
-
if (Object.keys(
|
|
227
|
-
throw new
|
|
226
|
+
if (Object.keys(he).length)
|
|
227
|
+
throw new v(
|
|
228
228
|
"请检查表单中标红的字段",
|
|
229
|
-
|
|
229
|
+
he
|
|
230
230
|
);
|
|
231
|
-
const
|
|
232
|
-
fields:
|
|
231
|
+
const Te = $.length ? await e.validateFields({
|
|
232
|
+
fields: $,
|
|
233
233
|
values: me,
|
|
234
|
-
actionType:
|
|
235
|
-
signal:
|
|
234
|
+
actionType: r,
|
|
235
|
+
signal: g
|
|
236
236
|
}) : {};
|
|
237
|
-
if (
|
|
237
|
+
if (g.aborted) return;
|
|
238
238
|
const ye = Object.fromEntries(
|
|
239
|
-
Object.entries(
|
|
240
|
-
([
|
|
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
|
|
244
|
+
throw new v(
|
|
245
245
|
"请检查表单中标红的字段",
|
|
246
246
|
ye
|
|
247
247
|
);
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
const Se = fe(
|
|
249
|
+
m,
|
|
250
|
+
r,
|
|
251
|
+
p,
|
|
252
|
+
F
|
|
253
253
|
);
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
if (!
|
|
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
|
-
|
|
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:
|
|
263
|
-
}),
|
|
262
|
+
actionType: r
|
|
263
|
+
}), f(e.logger, {
|
|
264
264
|
operation: "notify",
|
|
265
265
|
phase: "start",
|
|
266
|
-
actionType:
|
|
266
|
+
actionType: r
|
|
267
267
|
});
|
|
268
268
|
try {
|
|
269
|
-
await e.onActionSuccess(
|
|
269
|
+
await e.onActionSuccess(N), f(e.logger, {
|
|
270
270
|
operation: "notify",
|
|
271
271
|
phase: "success",
|
|
272
|
-
actionType:
|
|
272
|
+
actionType: r
|
|
273
273
|
});
|
|
274
274
|
} catch {
|
|
275
|
-
|
|
275
|
+
g.aborted || S("处理已成功,但页面刷新未完成,请刷新列表确认"), f(e.logger, {
|
|
276
276
|
operation: "notify",
|
|
277
277
|
phase: "error",
|
|
278
|
-
actionType:
|
|
278
|
+
actionType: r
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
|
-
} catch (
|
|
282
|
-
if (
|
|
283
|
-
if (!
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
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
|
-
|
|
289
|
-
const
|
|
290
|
-
e.onRequestError ? e.onRequestError(
|
|
288
|
+
I(void 0);
|
|
289
|
+
const D = A ? "操作结果尚未确认,再次操作前将重新核查任务状态" : "审批信息或字段校验暂不可用,请稍后再次操作";
|
|
290
|
+
e.onRequestError ? e.onRequestError(m, {
|
|
291
291
|
operation: "action",
|
|
292
|
-
resultUnknown:
|
|
293
|
-
message:
|
|
294
|
-
}) :
|
|
292
|
+
resultUnknown: A,
|
|
293
|
+
message: D
|
|
294
|
+
}) : S(D);
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
f(e.logger, {
|
|
297
297
|
operation: "action",
|
|
298
298
|
phase: "error",
|
|
299
|
-
actionType:
|
|
299
|
+
actionType: r
|
|
300
300
|
});
|
|
301
301
|
} finally {
|
|
302
|
-
|
|
302
|
+
V.current = !1, g.aborted ? f(e.logger, {
|
|
303
303
|
operation: "action",
|
|
304
304
|
phase: "cancel",
|
|
305
|
-
actionType:
|
|
306
|
-
}) :
|
|
305
|
+
actionType: r
|
|
306
|
+
}) : _(!1);
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
|
-
if (!
|
|
310
|
-
return
|
|
311
|
-
title:
|
|
309
|
+
if (!n)
|
|
310
|
+
return oe({
|
|
311
|
+
title: ue(),
|
|
312
312
|
actions: null,
|
|
313
313
|
footer: null,
|
|
314
|
-
content: e.loadError ? /* @__PURE__ */
|
|
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__ */
|
|
317
|
-
] }) : /* @__PURE__ */
|
|
318
|
-
/* @__PURE__ */
|
|
319
|
-
/* @__PURE__ */
|
|
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
|
|
323
|
-
|
|
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:
|
|
325
|
+
actionType: r.actionType,
|
|
326
326
|
htmlType: "button",
|
|
327
|
-
variant:
|
|
328
|
-
disabled:
|
|
329
|
-
loading:
|
|
327
|
+
variant: r.actionType === "APPROVE" || r.actionType === "SUBMIT" ? "primary" : "default",
|
|
328
|
+
disabled: O,
|
|
329
|
+
loading: O && q === r.actionType,
|
|
330
330
|
onClick: () => {
|
|
331
|
-
|
|
331
|
+
se(r.actionType);
|
|
332
332
|
},
|
|
333
|
-
children:
|
|
333
|
+
children: G[r.actionType]
|
|
334
334
|
},
|
|
335
|
-
|
|
336
|
-
)) }) : null,
|
|
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
|
+
"data-presentation": e.presentation === "mobile" ? "mobile" : void 0,
|
|
341
342
|
children: [
|
|
342
|
-
/* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
|
|
345
|
-
|
|
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(
|
|
346
347
|
"div",
|
|
347
348
|
{
|
|
348
349
|
className: "make-app-approval-detail-field",
|
|
349
|
-
"data-invalid": !!
|
|
350
|
-
"data-readonly": !
|
|
351
|
-
"data-full-width": !!
|
|
350
|
+
"data-invalid": !!b[r.key],
|
|
351
|
+
"data-readonly": !r.editable,
|
|
352
|
+
"data-full-width": !!r.fullWidth,
|
|
352
353
|
children: [
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
-
e.renderFieldLabel?.(
|
|
355
|
-
|
|
354
|
+
/* @__PURE__ */ d("label", { htmlFor: `${s}-${r.key}`, children: [
|
|
355
|
+
e.renderFieldLabel?.(r) ?? r.label,
|
|
356
|
+
r.required && r.editable ? /* @__PURE__ */ d(
|
|
356
357
|
"span",
|
|
357
358
|
{
|
|
358
359
|
className: "make-app-approval-required",
|
|
@@ -364,109 +365,109 @@ const W = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.act
|
|
|
364
365
|
}
|
|
365
366
|
) : null
|
|
366
367
|
] }),
|
|
367
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ d("div", { className: "make-app-approval-detail-value", children: [
|
|
368
369
|
a({
|
|
369
|
-
field:
|
|
370
|
-
id: `${
|
|
371
|
-
value: Object.hasOwn(
|
|
372
|
-
readOnly: !
|
|
373
|
-
disabled:
|
|
374
|
-
error:
|
|
375
|
-
...
|
|
376
|
-
onChange: (
|
|
377
|
-
|
|
378
|
-
...
|
|
379
|
-
[
|
|
380
|
-
})),
|
|
381
|
-
const
|
|
382
|
-
return delete
|
|
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;
|
|
383
384
|
});
|
|
384
385
|
}
|
|
385
386
|
} : {}
|
|
386
387
|
}),
|
|
387
|
-
|
|
388
|
+
b[r.key] && /* @__PURE__ */ i("p", { role: "alert", className: "make-app-approval-detail-error", children: b[r.key] })
|
|
388
389
|
] })
|
|
389
390
|
]
|
|
390
391
|
},
|
|
391
|
-
|
|
392
|
+
r.key
|
|
392
393
|
))
|
|
393
394
|
] })
|
|
394
395
|
]
|
|
395
396
|
}
|
|
396
|
-
),
|
|
397
|
+
), le = C && /* @__PURE__ */ i(
|
|
397
398
|
"p",
|
|
398
399
|
{
|
|
399
|
-
role:
|
|
400
|
-
className: `make-app-approval-detail-message${
|
|
401
|
-
children:
|
|
400
|
+
role: R ? "status" : "alert",
|
|
401
|
+
className: `make-app-approval-detail-message${R ? "" : " make-app-approval-detail-error"}`,
|
|
402
|
+
children: C
|
|
402
403
|
}
|
|
403
|
-
), ce = e.history != null && /* @__PURE__ */
|
|
404
|
+
), ce = e.history != null && /* @__PURE__ */ d(
|
|
404
405
|
"section",
|
|
405
406
|
{
|
|
406
407
|
className: "make-app-approval-detail-section make-app-approval-detail-history",
|
|
407
408
|
"aria-label": "审批流程",
|
|
408
409
|
children: [
|
|
409
|
-
/* @__PURE__ */
|
|
410
|
+
/* @__PURE__ */ i("h3", { children: "审批流程" }),
|
|
410
411
|
e.history
|
|
411
412
|
]
|
|
412
413
|
}
|
|
413
|
-
),
|
|
414
|
-
ne,
|
|
414
|
+
), Ne = /* @__PURE__ */ d("div", { className: "make-app-approval-detail-content", "aria-busy": O, children: [
|
|
415
415
|
ie,
|
|
416
|
+
le,
|
|
416
417
|
ce
|
|
417
|
-
] }),
|
|
418
|
-
/* @__PURE__ */
|
|
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: [
|
|
419
420
|
"审批意见",
|
|
420
|
-
|
|
421
|
+
re && /* @__PURE__ */ d("span", { className: "make-app-approval-required", "aria-label": "必填", children: [
|
|
421
422
|
" ",
|
|
422
423
|
"*"
|
|
423
424
|
] })
|
|
424
425
|
] }),
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
+
/* @__PURE__ */ i(
|
|
426
427
|
o,
|
|
427
428
|
{
|
|
428
|
-
id: `${
|
|
429
|
+
id: `${s}-comment`,
|
|
429
430
|
ariaLabel: "审批意见",
|
|
430
|
-
value:
|
|
431
|
-
onChange: (
|
|
432
|
-
|
|
431
|
+
value: F,
|
|
432
|
+
onChange: (r) => {
|
|
433
|
+
y(r), J("");
|
|
433
434
|
},
|
|
434
|
-
placeholder:
|
|
435
|
-
disabled:
|
|
436
|
-
required:
|
|
435
|
+
placeholder: ae.length ? `请输入审批意见,${ae.map((r) => G[r.actionType]).join("、")}时必填` : "请输入审批意见",
|
|
436
|
+
disabled: O,
|
|
437
|
+
required: re,
|
|
437
438
|
maxLength: 1024
|
|
438
439
|
}
|
|
439
440
|
),
|
|
440
|
-
|
|
441
|
+
Z && /* @__PURE__ */ i("p", { role: "alert", className: "make-app-approval-detail-error", children: Z })
|
|
441
442
|
] }) : null;
|
|
442
|
-
return
|
|
443
|
-
title:
|
|
444
|
-
detail:
|
|
445
|
-
sections: { application:
|
|
446
|
-
actionItems:
|
|
447
|
-
actionType:
|
|
448
|
-
label:
|
|
449
|
-
disabled:
|
|
450
|
-
loading:
|
|
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,
|
|
451
452
|
onClick: () => {
|
|
452
|
-
|
|
453
|
+
se(r.actionType);
|
|
453
454
|
}
|
|
454
455
|
})),
|
|
455
|
-
actions:
|
|
456
|
-
content: /* @__PURE__ */
|
|
457
|
-
|
|
458
|
-
|
|
456
|
+
actions: Ae,
|
|
457
|
+
content: /* @__PURE__ */ d(Oe, { children: [
|
|
458
|
+
Ne,
|
|
459
|
+
de
|
|
459
460
|
] }),
|
|
460
461
|
footer: null
|
|
461
462
|
});
|
|
462
|
-
},
|
|
463
|
+
}, Me = (e) => {
|
|
463
464
|
if (!e.scopeKey.trim() || !e.reference.taskId.trim() || !e.reference.processInstanceId.trim())
|
|
464
465
|
throw new Error("ApprovalTaskDetail requires scopeKey and task reference");
|
|
465
|
-
for (const
|
|
466
|
-
if (!e.components?.[
|
|
467
|
-
throw new Error(`ApprovalTaskDetail requires components.${
|
|
468
|
-
return /* @__PURE__ */
|
|
469
|
-
|
|
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,
|
|
470
471
|
{
|
|
471
472
|
...e
|
|
472
473
|
},
|
|
@@ -476,11 +477,81 @@ const W = (e) => e.actionType === "RETURN" || e.actionType === "REJECT" || e.act
|
|
|
476
477
|
e.reference.taskId
|
|
477
478
|
])
|
|
478
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]));
|
|
479
548
|
};
|
|
480
549
|
export {
|
|
481
|
-
|
|
482
|
-
|
|
550
|
+
Ve as ApprovalInstanceDetail,
|
|
551
|
+
Me as ApprovalTaskDetail,
|
|
552
|
+
v as ApprovalTaskValidationError,
|
|
483
553
|
fe as buildApprovalTaskAction,
|
|
484
|
-
|
|
485
|
-
|
|
554
|
+
K as getApprovalTaskFields,
|
|
555
|
+
$e as readApprovalInstanceDetail,
|
|
556
|
+
we as readApprovalTaskDetail
|
|
486
557
|
};
|