@donglegeyu/company-ui 2.17.0 → 2.18.0

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.
@@ -0,0 +1,797 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/template-components/ApprovalActionBar/index.tsx
30
+ var ApprovalActionBar_exports = {};
31
+ __export(ApprovalActionBar_exports, {
32
+ ApprovalActionBar: () => ApprovalActionBar,
33
+ ApprovalFlowDrawer: () => ApprovalFlowDrawer,
34
+ FlowLink: () => FlowLink,
35
+ FlowStep: () => FlowStep,
36
+ approvalActionText: () => approvalActionText,
37
+ approvalFmtDuration: () => approvalFmtDuration,
38
+ approvalFmtTime: () => approvalFmtTime
39
+ });
40
+ module.exports = __toCommonJS(ApprovalActionBar_exports);
41
+ var import_react = require("react");
42
+ var import_antd = require("antd");
43
+ var import_basic_components = require("../../basic-components");
44
+ var import_shared_components = require("../../shared-components");
45
+ var import_theme = require("../../theme");
46
+ var import_DrawerDetailTemplate = __toESM(require("../DrawerDetailTemplate"));
47
+ var import_DrawerFormTemplate = __toESM(require("../DrawerFormTemplate"));
48
+ var import_index = require("./index.scss");
49
+ var import_jsx_runtime = require("react/jsx-runtime");
50
+ var ACTION_TITLE = {
51
+ agree: "同意",
52
+ reject: "驳回",
53
+ transfer: "转办",
54
+ addSign: "加签"
55
+ };
56
+ var DEFAULT_PHRASES = {
57
+ approve: ["同意,按此执行", "情况属实,同意", "符合要求,同意"],
58
+ reject: ["材料不完整,请补充后重新提交", "信息有误,请核实后重新提交", "不符合审批条件,驳回"]
59
+ };
60
+ function dash(value) {
61
+ return value == null || value === "" ? "-" : value;
62
+ }
63
+ function approvalFmtTime(value) {
64
+ return value ? value.replace("T", " ").slice(0, 19) : "-";
65
+ }
66
+ function approvalFmtDuration(ms) {
67
+ if (ms == null || ms < 0)
68
+ return "";
69
+ const minutes = Math.floor(ms / 6e4);
70
+ if (minutes < 1)
71
+ return "不到 1 分钟";
72
+ if (minutes < 60)
73
+ return `${minutes} 分钟`;
74
+ const hours = Math.floor(minutes / 60);
75
+ if (hours < 24) {
76
+ return minutes % 60 ? `${hours} 小时 ${minutes % 60} 分钟` : `${hours} 小时`;
77
+ }
78
+ const days = Math.floor(hours / 24);
79
+ return hours % 24 ? `${days} 天 ${hours % 24} 小时` : `${days} 天`;
80
+ }
81
+ function approvalActionText(action) {
82
+ if (action === "approve")
83
+ return "同意";
84
+ if (action === "reject")
85
+ return "驳回";
86
+ if (action === "reject_back")
87
+ return "退回节点";
88
+ if (action === "transfer")
89
+ return "转办";
90
+ if (action === "add_sign")
91
+ return "加签";
92
+ return action || "-";
93
+ }
94
+ function FlowStep({
95
+ label,
96
+ status,
97
+ sub,
98
+ width = 92,
99
+ focus = false,
100
+ stepNo,
101
+ duration,
102
+ comment
103
+ }) {
104
+ const { token } = import_antd.theme.useToken();
105
+ const meta = {
106
+ done: {
107
+ color: token.colorPrimary,
108
+ bg: token.colorPrimaryBg,
109
+ border: token.colorPrimaryBg,
110
+ icon: "✓"
111
+ },
112
+ active: {
113
+ color: token.colorTextLightSolid,
114
+ bg: token.colorPrimary,
115
+ border: token.colorPrimary,
116
+ icon: stepNo ?? ""
117
+ },
118
+ pending: {
119
+ color: token.colorTextQuaternary,
120
+ bg: token.colorFillTertiary,
121
+ border: token.colorFillTertiary,
122
+ icon: stepNo ?? ""
123
+ },
124
+ rejected: {
125
+ color: token.colorError,
126
+ bg: token.colorErrorBg,
127
+ border: token.colorError,
128
+ icon: "✕"
129
+ }
130
+ }[status];
131
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
132
+ "div",
133
+ {
134
+ "data-flow-focus": focus || void 0,
135
+ style: { flex: `0 0 ${width}px`, width, textAlign: "center" },
136
+ children: [
137
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
138
+ "div",
139
+ {
140
+ style: {
141
+ width: 26,
142
+ height: 26,
143
+ margin: "0 auto 6px",
144
+ borderRadius: "50%",
145
+ display: "flex",
146
+ alignItems: "center",
147
+ justifyContent: "center",
148
+ fontSize: 12,
149
+ lineHeight: 1,
150
+ color: meta.color,
151
+ background: meta.bg,
152
+ border: `1px solid ${meta.border}`
153
+ },
154
+ children: meta.icon
155
+ }
156
+ ),
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
+ import_shared_components.EllipsisText,
159
+ {
160
+ style: {
161
+ fontSize: 12,
162
+ color: status === "pending" ? token.colorTextTertiary : token.colorText
163
+ },
164
+ children: label
165
+ }
166
+ ),
167
+ sub ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.EllipsisText, { style: { fontSize: 11, color: token.colorTextTertiary }, children: sub }) : null,
168
+ duration ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.EllipsisText, { style: { fontSize: 11, color: token.colorTextQuaternary }, children: duration }) : null,
169
+ comment ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
170
+ import_shared_components.EllipsisText,
171
+ {
172
+ style: {
173
+ fontSize: 11,
174
+ color: token.colorTextSecondary,
175
+ lineHeight: 1.5,
176
+ display: "-webkit-box",
177
+ WebkitLineClamp: 2,
178
+ WebkitBoxOrient: "vertical",
179
+ overflow: "hidden"
180
+ },
181
+ title: comment,
182
+ children: [
183
+ "“",
184
+ comment,
185
+ "”"
186
+ ]
187
+ }
188
+ ) : null
189
+ ]
190
+ }
191
+ );
192
+ }
193
+ function FlowLink({ done }) {
194
+ const { token } = import_antd.theme.useToken();
195
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
196
+ "div",
197
+ {
198
+ style: {
199
+ flex: "1 0 14px",
200
+ minWidth: 14,
201
+ height: 1,
202
+ marginTop: 13,
203
+ background: done ? token.colorPrimary : token.colorBorder
204
+ }
205
+ }
206
+ );
207
+ }
208
+ function TimelineDot({ tone }) {
209
+ const { token } = import_antd.theme.useToken();
210
+ const meta = {
211
+ done: { bg: token.colorPrimaryBg, border: token.colorPrimary },
212
+ error: { bg: token.colorErrorBg, border: token.colorError },
213
+ active: { bg: token.colorPrimary, border: token.colorPrimary }
214
+ }[tone];
215
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
+ "span",
217
+ {
218
+ style: {
219
+ display: "inline-block",
220
+ width: 10,
221
+ height: 10,
222
+ borderRadius: "50%",
223
+ background: meta.bg,
224
+ border: `1px solid ${meta.border}`,
225
+ boxSizing: "border-box",
226
+ verticalAlign: "middle"
227
+ }
228
+ }
229
+ );
230
+ }
231
+ function ApprovalFlowDrawer(props) {
232
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ApprovalFlowDrawerInner, { ...props }) });
233
+ }
234
+ function ApprovalFlowDrawerInner({ open, onClose, width = 480, flow }) {
235
+ var _a, _b;
236
+ const { token } = import_antd.theme.useToken();
237
+ const elapsedText = (0, import_react.useMemo)(() => {
238
+ if (!(flow == null ? void 0 : flow.startTime))
239
+ return "";
240
+ const start = new Date(flow.startTime).getTime();
241
+ const end = flow.endTime ? new Date(flow.endTime).getTime() : Date.now();
242
+ if (Number.isNaN(start) || Number.isNaN(end))
243
+ return "";
244
+ return approvalFmtDuration(Math.max(0, end - start));
245
+ }, [flow]);
246
+ const flowFocusKey = (0, import_react.useMemo)(() => {
247
+ const steps = (flow == null ? void 0 : flow.steps) ?? [];
248
+ const active = steps.find((step) => step.status === "active");
249
+ if (active)
250
+ return active.key;
251
+ const rejected = steps.find((step) => step.status === "rejected");
252
+ if (rejected)
253
+ return rejected.key;
254
+ return steps.length ? steps[steps.length - 1].key : "";
255
+ }, [flow]);
256
+ const flowNodeWidth = ((flow == null ? void 0 : flow.steps.length) ?? 0) > 7 ? 76 : 92;
257
+ const flowScrollRef = (0, import_react.useRef)(null);
258
+ const [flowEdge, setFlowEdge] = (0, import_react.useState)({ left: false, right: false });
259
+ const updateFlowEdge = () => {
260
+ const el = flowScrollRef.current;
261
+ if (!el)
262
+ return;
263
+ const maxLeft = el.scrollWidth - el.clientWidth;
264
+ setFlowEdge({ left: el.scrollLeft > 4, right: maxLeft - el.scrollLeft > 4 });
265
+ };
266
+ const flowFocusedRef = (0, import_react.useRef)(false);
267
+ (0, import_react.useEffect)(() => {
268
+ if (!open) {
269
+ flowFocusedRef.current = false;
270
+ return;
271
+ }
272
+ let observer = null;
273
+ let rafId = 0;
274
+ let tries = 0;
275
+ const focusAndMeasure = () => {
276
+ const el = flowScrollRef.current;
277
+ if (!el)
278
+ return;
279
+ if (!flowFocusedRef.current) {
280
+ flowFocusedRef.current = true;
281
+ const target = el.querySelector('[data-flow-focus="true"]');
282
+ if (target) {
283
+ const rect = target.getBoundingClientRect();
284
+ const hostRect = el.getBoundingClientRect();
285
+ const offset = rect.left - hostRect.left + el.scrollLeft - (el.clientWidth - rect.width) / 2;
286
+ el.scrollTo({ left: Math.max(0, offset), behavior: "smooth" });
287
+ }
288
+ }
289
+ updateFlowEdge();
290
+ };
291
+ const attach = () => {
292
+ if (!flowScrollRef.current) {
293
+ if (tries++ < 60)
294
+ rafId = requestAnimationFrame(attach);
295
+ return;
296
+ }
297
+ observer = new ResizeObserver(focusAndMeasure);
298
+ observer.observe(flowScrollRef.current);
299
+ };
300
+ attach();
301
+ return () => {
302
+ cancelAnimationFrame(rafId);
303
+ observer == null ? void 0 : observer.disconnect();
304
+ };
305
+ }, [open, flow]);
306
+ const timelineItems = (0, import_react.useMemo)(() => {
307
+ if (!flow)
308
+ return [];
309
+ const noteStyle = {
310
+ margin: "4px 0",
311
+ padding: "6px 10px",
312
+ background: token.colorFillTertiary,
313
+ borderRadius: 6,
314
+ fontSize: 13,
315
+ color: token.colorText,
316
+ whiteSpace: "pre-wrap",
317
+ wordBreak: "break-all"
318
+ };
319
+ const nodeNameByKey = new Map(flow.steps.map((step) => [step.key, step.label]));
320
+ const items = [];
321
+ flow.timeline.forEach((record) => {
322
+ const rejected = record.tone ? record.tone === "error" : record.action === "reject" || record.action === "reject_back";
323
+ items.push({
324
+ key: record.key ?? `${record.time ?? ""}-${record.node ?? ""}`,
325
+ dot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimelineDot, { tone: rejected ? "error" : "done" }),
326
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
327
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 14, fontWeight: 500, color: token.colorText }, children: record.node ? nodeNameByKey.get(record.node) ?? record.node : "审批" }),
328
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: 13, marginTop: 2 }, children: [
329
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorTextTertiary }, children: "审批人:" }),
330
+ dash(record.operator),
331
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
332
+ "span",
333
+ {
334
+ style: { marginLeft: 6, color: rejected ? token.colorError : token.colorPrimary },
335
+ children: approvalActionText(record.action)
336
+ }
337
+ )
338
+ ] }),
339
+ record.comment ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: noteStyle, children: record.comment }) : null,
340
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { color: token.colorTextTertiary, fontSize: 12, marginTop: 2 }, children: approvalFmtTime(record.time) })
341
+ ] })
342
+ });
343
+ });
344
+ if (flow.activeNodeName) {
345
+ items.push({
346
+ key: "current-node",
347
+ dot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimelineDot, { tone: "active" }),
348
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
349
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 14, fontWeight: 500, color: token.colorText }, children: flow.activeNodeName }),
350
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: 13, marginTop: 2 }, children: [
351
+ flow.activeAssignee ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
352
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorTextTertiary }, children: "审批人:" }),
353
+ flow.activeAssignee
354
+ ] }) : null,
355
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorPrimary, marginLeft: flow.activeAssignee ? 6 : 0 }, children: "审批中" })
356
+ ] })
357
+ ] })
358
+ });
359
+ }
360
+ items.unshift({
361
+ key: "submit-start",
362
+ dot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimelineDot, { tone: "done" }),
363
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
364
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 14, fontWeight: 500, color: token.colorText }, children: "提交申请" }),
365
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: 13, marginTop: 2 }, children: [
366
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorTextTertiary }, children: "发起人:" }),
367
+ dash(flow.applicantName)
368
+ ] }),
369
+ flow.submitNote ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: noteStyle, children: flow.submitNote }) : null,
370
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { color: token.colorTextTertiary, fontSize: 12, marginTop: 2 }, children: approvalFmtTime(flow.startTime) })
371
+ ] })
372
+ });
373
+ return items.reverse();
374
+ }, [flow, token]);
375
+ if (!open)
376
+ return null;
377
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
378
+ import_DrawerDetailTemplate.default,
379
+ {
380
+ open,
381
+ onClose,
382
+ title: "审批流程",
383
+ width,
384
+ classNames: { body: "approval-flow-drawer" },
385
+ children: flow ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 20, minWidth: 0 }, children: [
386
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: 13, color: token.colorTextSecondary }, children: [
387
+ dash(flow.applicantName),
388
+ " 发起 · ",
389
+ approvalFmtTime(flow.startTime),
390
+ elapsedText ? ` · ${flow.running ? "已耗时" : "总耗时"} ${elapsedText}` : ""
391
+ ] }),
392
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { position: "relative", minWidth: 0 }, children: [
393
+ flowEdge.left && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
394
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
395
+ "div",
396
+ {
397
+ style: {
398
+ position: "absolute",
399
+ left: 0,
400
+ top: 0,
401
+ bottom: 0,
402
+ width: 28,
403
+ zIndex: 1,
404
+ pointerEvents: "none",
405
+ background: `linear-gradient(to right, ${token.colorBgContainer}, transparent)`
406
+ }
407
+ }
408
+ ),
409
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
410
+ import_basic_components.CompanyButton,
411
+ {
412
+ shape: "circle",
413
+ size: "small",
414
+ onClick: () => {
415
+ var _a2;
416
+ return (_a2 = flowScrollRef.current) == null ? void 0 : _a2.scrollBy({ left: -180, behavior: "smooth" });
417
+ },
418
+ style: {
419
+ position: "absolute",
420
+ left: 0,
421
+ top: 1,
422
+ zIndex: 2,
423
+ fontSize: 14,
424
+ fontWeight: 500
425
+ },
426
+ children: "‹"
427
+ }
428
+ )
429
+ ] }),
430
+ flowEdge.right && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
431
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
432
+ "div",
433
+ {
434
+ style: {
435
+ position: "absolute",
436
+ right: 0,
437
+ top: 0,
438
+ bottom: 0,
439
+ width: 28,
440
+ zIndex: 1,
441
+ pointerEvents: "none",
442
+ background: `linear-gradient(to left, ${token.colorBgContainer}, transparent)`
443
+ }
444
+ }
445
+ ),
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
447
+ import_basic_components.CompanyButton,
448
+ {
449
+ shape: "circle",
450
+ size: "small",
451
+ onClick: () => {
452
+ var _a2;
453
+ return (_a2 = flowScrollRef.current) == null ? void 0 : _a2.scrollBy({ left: 180, behavior: "smooth" });
454
+ },
455
+ style: {
456
+ position: "absolute",
457
+ right: 0,
458
+ top: 1,
459
+ zIndex: 2,
460
+ fontSize: 14,
461
+ fontWeight: 500
462
+ },
463
+ children: "›"
464
+ }
465
+ )
466
+ ] }),
467
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
468
+ "div",
469
+ {
470
+ ref: flowScrollRef,
471
+ onScroll: updateFlowEdge,
472
+ className: "approval-flow-scroll",
473
+ style: {
474
+ display: "flex",
475
+ alignItems: "flex-start",
476
+ overflowX: "auto",
477
+ paddingBottom: 12
478
+ },
479
+ children: flow.steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
480
+ index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FlowLink, { done: flow.steps[index - 1].status === "done" }),
481
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
482
+ FlowStep,
483
+ {
484
+ label: step.label,
485
+ status: step.status,
486
+ sub: step.sub,
487
+ duration: step.duration,
488
+ comment: step.comment,
489
+ width: flowNodeWidth,
490
+ focus: step.key === flowFocusKey,
491
+ stepNo: index + 1
492
+ }
493
+ )
494
+ ] }, step.key))
495
+ }
496
+ )
497
+ ] }),
498
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 13, fontWeight: 500, marginBottom: 10 }, children: "处理记录" }),
500
+ timelineItems.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTimeline, { items: timelineItems }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
501
+ import_basic_components.CompanyEmpty,
502
+ {
503
+ image: import_basic_components.CompanyEmpty.PRESENTED_IMAGE_SIMPLE,
504
+ description: "暂无处理记录"
505
+ }
506
+ )
507
+ ] }),
508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
509
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 13, fontWeight: 500, marginBottom: 6 }, children: "抄送人" }),
510
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
511
+ "div",
512
+ {
513
+ style: {
514
+ fontSize: 13,
515
+ color: ((_a = flow.ccUsers) == null ? void 0 : _a.length) ? token.colorText : token.colorTextTertiary
516
+ },
517
+ children: ((_b = flow.ccUsers) == null ? void 0 : _b.length) ? flow.ccUsers.join("、") : "无"
518
+ }
519
+ )
520
+ ] })
521
+ ] }) : null
522
+ }
523
+ );
524
+ }
525
+ function ApprovalActionBar(props) {
526
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ApprovalActionBarInner, { ...props }) });
527
+ }
528
+ function ApprovalActionBarInner({
529
+ actions,
530
+ users = [],
531
+ usersLoading = false,
532
+ rejectNodeOptions = [],
533
+ currentNodeName,
534
+ flow,
535
+ phrases,
536
+ onViewFlow,
537
+ onAgree,
538
+ onReject,
539
+ onTransfer,
540
+ onAddSign
541
+ }) {
542
+ const { token } = import_antd.theme.useToken();
543
+ const [activeAction, setActiveAction] = (0, import_react.useState)(
544
+ null
545
+ );
546
+ const [flowOpen, setFlowOpen] = (0, import_react.useState)(false);
547
+ const [comment, setComment] = (0, import_react.useState)("");
548
+ const [rejectMode, setRejectMode] = (0, import_react.useState)("terminate");
549
+ const [rejectNodeKey, setRejectNodeKey] = (0, import_react.useState)();
550
+ const [targetValue, setTargetValue] = (0, import_react.useState)();
551
+ const [ccValues, setCcValues] = (0, import_react.useState)([]);
552
+ const [submitting, setSubmitting] = (0, import_react.useState)(false);
553
+ const approvePhrases = (phrases == null ? void 0 : phrases.approve) ?? DEFAULT_PHRASES.approve;
554
+ const rejectPhrases = (phrases == null ? void 0 : phrases.reject) ?? DEFAULT_PHRASES.reject;
555
+ const actionList = (0, import_react.useMemo)(() => {
556
+ const list = actions ?? ["viewFlow", "transfer", "addSign", "reject", "agree"];
557
+ return list.map(
558
+ (item) => typeof item === "string" ? { key: item, type: item } : item
559
+ );
560
+ }, [actions]);
561
+ const openAction = (kind) => {
562
+ setComment("");
563
+ setTargetValue(void 0);
564
+ setCcValues([]);
565
+ setRejectMode("terminate");
566
+ setRejectNodeKey(void 0);
567
+ setActiveAction(kind);
568
+ };
569
+ const handleButtonClick = (item) => {
570
+ if (item.onClick) {
571
+ item.onClick();
572
+ return;
573
+ }
574
+ if (item.type === "viewFlow") {
575
+ if (onViewFlow)
576
+ onViewFlow();
577
+ else if (flow)
578
+ setFlowOpen(true);
579
+ return;
580
+ }
581
+ if (item.type)
582
+ openAction(item.type);
583
+ };
584
+ const submitAction = async () => {
585
+ var _a, _b;
586
+ if (activeAction == null)
587
+ return;
588
+ if (activeAction === "reject" && rejectMode === "node" && !rejectNodeKey) {
589
+ import_basic_components.CompanyMessage.warning("请选择退回节点");
590
+ return;
591
+ }
592
+ if ((activeAction === "transfer" || activeAction === "addSign") && targetValue == null) {
593
+ import_basic_components.CompanyMessage.warning("请选择目标处理人");
594
+ return;
595
+ }
596
+ const ccUsers = ccValues.map((value) => {
597
+ var _a2;
598
+ return {
599
+ id: value,
600
+ label: ((_a2 = users.find((user) => user.value === value)) == null ? void 0 : _a2.label) ?? String(value)
601
+ };
602
+ });
603
+ setSubmitting(true);
604
+ try {
605
+ if (activeAction === "agree") {
606
+ await (onAgree == null ? void 0 : onAgree({ type: "agree", comment, ccUsers }));
607
+ } else if (activeAction === "reject") {
608
+ await (onReject == null ? void 0 : onReject({
609
+ type: "reject",
610
+ comment,
611
+ ccUsers,
612
+ mode: rejectMode,
613
+ nodeKey: rejectMode === "node" ? rejectNodeKey : void 0
614
+ }));
615
+ } else if (activeAction === "transfer") {
616
+ await (onTransfer == null ? void 0 : onTransfer({
617
+ type: "transfer",
618
+ comment,
619
+ ccUsers,
620
+ targetId: targetValue,
621
+ targetLabel: (_a = users.find((user) => user.value === targetValue)) == null ? void 0 : _a.label
622
+ }));
623
+ } else {
624
+ await (onAddSign == null ? void 0 : onAddSign({
625
+ type: "addSign",
626
+ comment,
627
+ ccUsers,
628
+ targetId: targetValue,
629
+ targetLabel: (_b = users.find((user) => user.value === targetValue)) == null ? void 0 : _b.label
630
+ }));
631
+ }
632
+ setActiveAction(null);
633
+ } catch {
634
+ } finally {
635
+ setSubmitting(false);
636
+ }
637
+ };
638
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanySpace, { size: 8, wrap: true, children: actionList.map((item) => {
640
+ const builtinLabel = item.type ? ACTION_TITLE[item.type] : void 0;
641
+ const label = item.label ?? (item.type === "viewFlow" ? "查看流程" : builtinLabel ?? item.key);
642
+ const isPrimary = item.type === "agree" || item.type === "reject";
643
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
644
+ import_basic_components.CompanyButton,
645
+ {
646
+ ...item.primary && !item.onClick ? { type: "primary" } : isPrimary && !item.onClick ? { color: "primary", variant: "outlined" } : {},
647
+ danger: item.danger,
648
+ loading: item.loading,
649
+ disabled: submitting && !item.loading,
650
+ onClick: () => handleButtonClick(item),
651
+ children: label
652
+ },
653
+ item.key
654
+ );
655
+ }) }),
656
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
657
+ import_DrawerFormTemplate.default,
658
+ {
659
+ open: activeAction != null,
660
+ onClose: () => setActiveAction(null),
661
+ title: activeAction ? ACTION_TITLE[activeAction] : "",
662
+ width: 480,
663
+ submitLoading: submitting,
664
+ submitText: activeAction === "reject" && rejectMode === "node" ? "确认退回" : `确认${activeAction ? ACTION_TITLE[activeAction] : ""}`,
665
+ onSubmit: () => void submitAction(),
666
+ children: activeAction != null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 20 }, children: [
667
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { color: token.colorTextSecondary, fontSize: 13 }, children: [
668
+ "当前节点:",
669
+ dash(currentNodeName)
670
+ ] }),
671
+ (activeAction === "transfer" || activeAction === "addSign") && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
672
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginBottom: 8 }, children: [
673
+ "目标处理人",
674
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorError, marginLeft: 4 }, children: "*" })
675
+ ] }),
676
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
677
+ import_basic_components.CompanySelect,
678
+ {
679
+ style: { width: "100%" },
680
+ placeholder: "请选择目标处理人",
681
+ loading: usersLoading,
682
+ value: targetValue,
683
+ options: users,
684
+ onChange: (value) => setTargetValue(Number(value)),
685
+ showSearch: true,
686
+ optionFilterProp: "label"
687
+ }
688
+ )
689
+ ] }),
690
+ activeAction === "reject" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
691
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginBottom: 8 }, children: "驳回方式" }),
692
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
693
+ import_basic_components.CompanyRadio.Group,
694
+ {
695
+ value: rejectMode,
696
+ onChange: (event) => {
697
+ const mode = event.target.value;
698
+ setRejectMode(mode);
699
+ if (mode === "terminate")
700
+ setRejectNodeKey(void 0);
701
+ },
702
+ children: [
703
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyRadio, { value: "terminate", children: "驳回并终止流程" }),
704
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyRadio, { value: "node", children: "退回到指定节点" })
705
+ ]
706
+ }
707
+ ),
708
+ rejectMode === "node" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 12 }, children: [
709
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
710
+ import_basic_components.CompanySelect,
711
+ {
712
+ style: { width: "100%" },
713
+ placeholder: "请选择退回节点",
714
+ value: rejectNodeKey,
715
+ options: rejectNodeOptions,
716
+ onChange: (value) => setRejectNodeKey(value),
717
+ showSearch: true,
718
+ optionFilterProp: "label"
719
+ }
720
+ ),
721
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: 6, color: token.colorTextTertiary, fontSize: 12 }, children: "退回后流程继续流转,不会终止审批;「退回发起人」后申请人可修改并重新提交。" })
722
+ ] })
723
+ ] }),
724
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
725
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginBottom: 8 }, children: [
726
+ activeAction === "transfer" ? "转办说明" : activeAction === "addSign" ? "加签说明" : "审批意见",
727
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorTextTertiary, marginLeft: 4, fontSize: 12 }, children: "(选填)" })
728
+ ] }),
729
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
730
+ import_basic_components.CompanyInput.TextArea,
731
+ {
732
+ placeholder: "请输入说明或意见",
733
+ rows: 3,
734
+ maxLength: 255,
735
+ style: { resize: "none" },
736
+ value: comment,
737
+ onChange: (event) => setComment(event.target.value)
738
+ }
739
+ ),
740
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanySpace, { size: 8, wrap: true, style: { marginTop: 8 }, children: (activeAction === "reject" ? rejectPhrases : approvePhrases).map((phrase) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
741
+ import_basic_components.CompanyButton,
742
+ {
743
+ size: "small",
744
+ color: "default",
745
+ variant: "filled",
746
+ onClick: () => setComment(phrase),
747
+ children: phrase
748
+ },
749
+ phrase
750
+ )) })
751
+ ] }),
752
+ (activeAction === "agree" || activeAction === "reject") && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
753
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginBottom: 8 }, children: [
754
+ "抄送人",
755
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: token.colorTextTertiary, marginLeft: 4, fontSize: 12 }, children: "(选填)" })
756
+ ] }),
757
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
758
+ import_basic_components.CompanySelect,
759
+ {
760
+ mode: "multiple",
761
+ style: { width: "100%" },
762
+ placeholder: "请选择抄送人",
763
+ loading: usersLoading,
764
+ value: ccValues,
765
+ options: users,
766
+ onChange: (value) => setCcValues(value),
767
+ showSearch: true,
768
+ optionFilterProp: "label",
769
+ maxTagCount: "responsive",
770
+ allowClear: true
771
+ }
772
+ )
773
+ ] })
774
+ ] })
775
+ }
776
+ ),
777
+ !onViewFlow && flow ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
778
+ ApprovalFlowDrawer,
779
+ {
780
+ open: flowOpen,
781
+ onClose: () => setFlowOpen(false),
782
+ width: 480,
783
+ flow
784
+ }
785
+ ) : null
786
+ ] });
787
+ }
788
+ // Annotate the CommonJS export names for ESM import in node:
789
+ 0 && (module.exports = {
790
+ ApprovalActionBar,
791
+ ApprovalFlowDrawer,
792
+ FlowLink,
793
+ FlowStep,
794
+ approvalActionText,
795
+ approvalFmtDuration,
796
+ approvalFmtTime
797
+ });