@rytass/bpm-core-react 0.13.3 → 0.13.5

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.
Files changed (148) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +1 -0
  3. package/dist/chunks/{FormBuilderView-D4xIuPYB.js → FormBuilderView-BYLN6W-P.js} +2 -2
  4. package/dist/chunks/{FormBuilderView-D4xIuPYB.js.map → FormBuilderView-BYLN6W-P.js.map} +1 -1
  5. package/dist/chunks/{FormBuilderView-CLFlfDGe.cjs → FormBuilderView-VmdPVbg7.cjs} +2 -2
  6. package/dist/chunks/{FormBuilderView-CLFlfDGe.cjs.map → FormBuilderView-VmdPVbg7.cjs.map} +1 -1
  7. package/dist/chunks/FormRendererView-Bs8lTb4k.cjs +2 -0
  8. package/dist/chunks/{FormRendererView-BxGT16z0.cjs.map → FormRendererView-Bs8lTb4k.cjs.map} +1 -1
  9. package/dist/chunks/{FormRendererView-DUceSOXe.js → FormRendererView-UPowZZgw.js} +3 -3
  10. package/dist/chunks/{FormRendererView-DUceSOXe.js.map → FormRendererView-UPowZZgw.js.map} +1 -1
  11. package/dist/chunks/{approval-instance-list-page-BjX2kaoF.js → approval-instance-list-page-CPXMP3PL.js} +2 -2
  12. package/dist/chunks/{approval-instance-list-page-BjX2kaoF.js.map → approval-instance-list-page-CPXMP3PL.js.map} +1 -1
  13. package/dist/chunks/{approval-instance-list-page-CWiQvnfE.cjs → approval-instance-list-page-ax0pm8bt.cjs} +2 -2
  14. package/dist/chunks/{approval-instance-list-page-CWiQvnfE.cjs.map → approval-instance-list-page-ax0pm8bt.cjs.map} +1 -1
  15. package/dist/chunks/{compose-Bb-REfoB.js → compose-6P64PO1i.js} +5 -5
  16. package/dist/chunks/{compose-Bb-REfoB.js.map → compose-6P64PO1i.js.map} +1 -1
  17. package/dist/chunks/{compose-DzRYZcqe.cjs → compose-BnSRL4ml.cjs} +2 -2
  18. package/dist/chunks/{compose-DzRYZcqe.cjs.map → compose-BnSRL4ml.cjs.map} +1 -1
  19. package/dist/chunks/{dashboard-page-DJ9vOPga.js → dashboard-page-CeCLV1tp.js} +2 -2
  20. package/dist/chunks/{dashboard-page-DJ9vOPga.js.map → dashboard-page-CeCLV1tp.js.map} +1 -1
  21. package/dist/chunks/{dashboard-page-CH87L5nx.cjs → dashboard-page-DooFJsxM.cjs} +2 -2
  22. package/dist/chunks/{dashboard-page-CH87L5nx.cjs.map → dashboard-page-DooFJsxM.cjs.map} +1 -1
  23. package/dist/chunks/{delegations-vpLtus9g.cjs → delegations-8LsxcQM4.cjs} +2 -2
  24. package/dist/chunks/{delegations-vpLtus9g.cjs.map → delegations-8LsxcQM4.cjs.map} +1 -1
  25. package/dist/chunks/{delegations-0MbJ7CWj.js → delegations-B8gLSt0i.js} +4 -5
  26. package/dist/chunks/{delegations-0MbJ7CWj.js.map → delegations-B8gLSt0i.js.map} +1 -1
  27. package/dist/chunks/{delegations-DyMGIDpp.js → delegations-DRupxJ4_.js} +4 -5
  28. package/dist/chunks/{delegations-DyMGIDpp.js.map → delegations-DRupxJ4_.js.map} +1 -1
  29. package/dist/chunks/{delegations-Bc9psOZ3.cjs → delegations-DlYwMiAW.cjs} +2 -2
  30. package/dist/chunks/{delegations-Bc9psOZ3.cjs.map → delegations-DlYwMiAW.cjs.map} +1 -1
  31. package/dist/chunks/{designer-C6oIO9Kq.js → designer-C3s2kSna.js} +1342 -841
  32. package/dist/chunks/designer-C3s2kSna.js.map +1 -0
  33. package/dist/chunks/designer-_g58R6rQ.cjs +65 -0
  34. package/dist/chunks/designer-_g58R6rQ.cjs.map +1 -0
  35. package/dist/chunks/detail-Db-UOELp.cjs +2 -0
  36. package/dist/chunks/detail-Db-UOELp.cjs.map +1 -0
  37. package/dist/chunks/detail-pYEIk-jW.js +2325 -0
  38. package/dist/chunks/detail-pYEIk-jW.js.map +1 -0
  39. package/dist/chunks/{login-9bCXyjbX.cjs → login-AtVxZBsC.cjs} +2 -2
  40. package/dist/chunks/{login-9bCXyjbX.cjs.map → login-AtVxZBsC.cjs.map} +1 -1
  41. package/dist/chunks/{login-BKxpLibd.js → login-C6qlTC6F.js} +2 -2
  42. package/dist/chunks/{login-BKxpLibd.js.map → login-C6qlTC6F.js.map} +1 -1
  43. package/dist/chunks/{orgs-Cr_7zsAD.js → orgs-BpqVu5ka.js} +2 -2
  44. package/dist/chunks/{orgs-Cr_7zsAD.js.map → orgs-BpqVu5ka.js.map} +1 -1
  45. package/dist/chunks/orgs-D0-5BaHT.cjs +2 -0
  46. package/dist/chunks/{orgs-Bz8hBMoQ.cjs.map → orgs-D0-5BaHT.cjs.map} +1 -1
  47. package/dist/chunks/providers-DHtDZFNA.cjs +2 -0
  48. package/dist/chunks/{providers-BsEn3ikK.cjs.map → providers-DHtDZFNA.cjs.map} +1 -1
  49. package/dist/chunks/{providers-DjLh4oLY.js → providers-J5eyByQj.js} +7 -7
  50. package/dist/chunks/{providers-DjLh4oLY.js.map → providers-J5eyByQj.js.map} +1 -1
  51. package/dist/chunks/{routes-config-fDVHmvXi.cjs → routes-config-C1j_vFKo.cjs} +2 -2
  52. package/dist/chunks/routes-config-C1j_vFKo.cjs.map +1 -0
  53. package/dist/chunks/{routes-config-RBYQtUd0.js → routes-config-yZbESPlw.js} +3 -2
  54. package/dist/chunks/routes-config-yZbESPlw.js.map +1 -0
  55. package/dist/chunks/use-bpm-member-D57LKe_u.js +20 -0
  56. package/dist/chunks/use-bpm-member-D57LKe_u.js.map +1 -0
  57. package/dist/chunks/use-bpm-member-DpNAQtNC.cjs +2 -0
  58. package/dist/chunks/use-bpm-member-DpNAQtNC.cjs.map +1 -0
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.js +19 -24
  62. package/dist/index.js.map +1 -1
  63. package/dist/lib/routes-config.d.ts +2 -0
  64. package/dist/lib/use-bpm-member.d.ts +6 -0
  65. package/dist/next/index.cjs +1 -1
  66. package/dist/next/index.js +2 -2
  67. package/dist/pages/admin/delegations/index.cjs +1 -1
  68. package/dist/pages/admin/delegations/index.js +1 -1
  69. package/dist/pages/admin/orgs/index.cjs +1 -1
  70. package/dist/pages/admin/orgs/index.js +1 -1
  71. package/dist/pages/admin/webhook-endpoints/index.cjs +2 -0
  72. package/dist/pages/admin/webhook-endpoints/index.cjs.map +1 -0
  73. package/dist/pages/admin/webhook-endpoints/index.d.ts +4 -0
  74. package/dist/pages/admin/webhook-endpoints/index.js +14 -0
  75. package/dist/pages/admin/webhook-endpoints/index.js.map +1 -0
  76. package/dist/pages/delegations/index.cjs +1 -1
  77. package/dist/pages/delegations/index.js +1 -1
  78. package/dist/pages/instances/detail/index.cjs +1 -1
  79. package/dist/pages/instances/detail/index.js +1 -1
  80. package/dist/pages/login/index.cjs +1 -1
  81. package/dist/pages/login/index.js +1 -1
  82. package/dist/pages/templates/compose/index.cjs +1 -1
  83. package/dist/pages/templates/compose/index.js +1 -1
  84. package/dist/pages/templates/designer/index.cjs +1 -1
  85. package/dist/pages/templates/designer/index.js +1 -1
  86. package/dist/style.css +1 -1
  87. package/dist/views/admin/delegations/index.cjs +1 -1
  88. package/dist/views/admin/delegations/index.js +1 -1
  89. package/dist/views/admin/index.cjs +1 -1
  90. package/dist/views/admin/index.d.ts +1 -0
  91. package/dist/views/admin/index.js +4 -3
  92. package/dist/views/admin/orgs/index.cjs +1 -1
  93. package/dist/views/admin/orgs/index.js +1 -1
  94. package/dist/views/admin/webhook-endpoints/AdminWebhookEndpointsView.d.ts +8 -0
  95. package/dist/views/admin/webhook-endpoints/index.cjs +2 -0
  96. package/dist/views/admin/webhook-endpoints/index.cjs.map +1 -0
  97. package/dist/views/admin/webhook-endpoints/index.d.ts +1 -0
  98. package/dist/views/admin/webhook-endpoints/index.js +729 -0
  99. package/dist/views/admin/webhook-endpoints/index.js.map +1 -0
  100. package/dist/views/cc/index.cjs +1 -1
  101. package/dist/views/cc/index.js +1 -1
  102. package/dist/views/dashboard/index.cjs +1 -1
  103. package/dist/views/dashboard/index.js +1 -1
  104. package/dist/views/delegations/index.cjs +1 -1
  105. package/dist/views/delegations/index.js +1 -1
  106. package/dist/views/forms/builder/index.cjs +1 -1
  107. package/dist/views/forms/builder/index.js +1 -1
  108. package/dist/views/forms/renderer/index.cjs +1 -1
  109. package/dist/views/forms/renderer/index.js +1 -1
  110. package/dist/views/inbox/index.cjs +1 -1
  111. package/dist/views/inbox/index.js +1 -1
  112. package/dist/views/instances/detail/InstanceDetailView.d.ts +6 -1
  113. package/dist/views/instances/detail/index.cjs +1 -1
  114. package/dist/views/instances/detail/index.d.ts +1 -0
  115. package/dist/views/instances/detail/index.js +2 -2
  116. package/dist/views/instances/detail/sections/InstanceWebhookDeliveriesSection.d.ts +20 -0
  117. package/dist/views/instances/detail/sections/shared.d.ts +37 -4
  118. package/dist/views/instances/new/index.cjs +1 -1
  119. package/dist/views/instances/new/index.js +2 -2
  120. package/dist/views/login/index.cjs +1 -1
  121. package/dist/views/login/index.js +1 -1
  122. package/dist/views/search/index.cjs +1 -1
  123. package/dist/views/search/index.js +1 -1
  124. package/dist/views/sent/index.cjs +1 -1
  125. package/dist/views/sent/index.js +1 -1
  126. package/dist/views/templates/compose/index.cjs +1 -1
  127. package/dist/views/templates/compose/index.js +1 -1
  128. package/dist/views/templates/designer/NotifyWebhookTargetsEditor.d.ts +20 -0
  129. package/dist/views/templates/designer/index.cjs +1 -1
  130. package/dist/views/templates/designer/index.js +1 -1
  131. package/dist/views/templates/designer/notify-webhook-designer.d.ts +74 -0
  132. package/dist/views/templates/index.cjs +1 -1
  133. package/dist/views/templates/index.js +1 -1
  134. package/dist/views/templates/versions/index.cjs +1 -1
  135. package/dist/views/templates/versions/index.js +1 -1
  136. package/package.json +13 -3
  137. package/dist/chunks/FormRendererView-BxGT16z0.cjs +0 -2
  138. package/dist/chunks/designer-C6oIO9Kq.js.map +0 -1
  139. package/dist/chunks/designer-gFUdImeZ.cjs +0 -65
  140. package/dist/chunks/designer-gFUdImeZ.cjs.map +0 -1
  141. package/dist/chunks/detail-BgKgMvYx.js +0 -2044
  142. package/dist/chunks/detail-BgKgMvYx.js.map +0 -1
  143. package/dist/chunks/detail-Dnz5aaI-.cjs +0 -2
  144. package/dist/chunks/detail-Dnz5aaI-.cjs.map +0 -1
  145. package/dist/chunks/orgs-Bz8hBMoQ.cjs +0 -2
  146. package/dist/chunks/providers-BsEn3ikK.cjs +0 -2
  147. package/dist/chunks/routes-config-RBYQtUd0.js.map +0 -1
  148. package/dist/chunks/routes-config-fDVHmvXi.cjs.map +0 -1
@@ -1,2044 +0,0 @@
1
- "use client";
2
- import { n as e } from "./auth-provider-B5oPmvk2.js";
3
- import { t } from "./format-date-time-CB-LxzqT.js";
4
- import { t as n } from "./bpm-form-field-Cao0rMol.js";
5
- import { i as r, t as i } from "./FormRendererView-DUceSOXe.js";
6
- import '../style.css';import '../detail.css';/* empty css */
7
- import { Fragment as a, forwardRef as o, useCallback as s, useEffect as c, useImperativeHandle as l, useMemo as u, useRef as d, useState as f } from "react";
8
- import { AutoComplete as p, Button as m, Input as ee, Modal as h, PageHeader as te, Section as g, SectionGroup as _, Select as ne, Stepper as v, Table as re, Textarea as y, Tooltip as b, Typography as x } from "@mezzanine-ui/react";
9
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
10
- import { cancelAdhocDirective as T, cancelApprovalInstance as ie, configureAdhocCompletionNotification as ae, configureAdhocStageNotification as oe, decideTask as se, listAdhocDirectives as ce, listAttachments as le, listTaskDecisions as ue, readApprovalInstance as de, readAttachmentDownloadUrl as fe, readAttachmentPreviewUrl as pe, readInstanceSignatures as me, requestAdhocCountersign as he, requestAdhocPreApproval as ge, resolveMemberProfiles as _e, resubmitApprovalInstance as ve, searchMembers as ye, uploadAttachment as be } from "@rytass/bpm-core-client/workflow";
11
- import xe from "@mezzanine-ui/react/ContentHeader";
12
- import { CheckedIcon as Se, ChevronLeftIcon as Ce, ChevronRightIcon as E, DangerousOutlineIcon as we, DownloadIcon as D, FileSearchIcon as O, NotificationUnreadIcon as Te, PlusIcon as Ee, RefreshCcwIcon as De, ShareIcon as Oe, UserIcon as ke, ZoomInIcon as Ae, ZoomOutIcon as je } from "@mezzanine-ui/icons";
13
- import { buildFormRendererValues as Me, focusFormRendererField as Ne, readFormDataSourceErrorMessage as Pe, validateFormRendererValues as Fe } from "@rytass/bpm-core-client/form";
14
- import { Background as Ie, Controls as Le, Handle as Re, Position as k, ReactFlow as ze } from "@xyflow/react";
15
- import * as A from "dagre";
16
- import { Document as Be, Page as Ve } from "react-pdf";
17
- import { stepClasses as j } from "@mezzanine-ui/core/stepper";
18
- var M = {
19
- root: "bpm_root_ehm7w",
20
- toolbar: "bpm_toolbar_R-tis",
21
- pageControls: "bpm_pageControls_jM-rC",
22
- zoomControls: "bpm_zoomControls_7RAbJ",
23
- counter: "bpm_counter_ILUsD",
24
- viewport: "bpm_viewport_DQXms",
25
- page: "bpm_page_Cv5Rg",
26
- state: "bpm_state_bpgp3"
27
- }, N = 760, P = 920, He = 320, Ue = 32, F = .75, We = 1.75, I = .25;
28
- function Ge({ filename: e, fileUrl: t, onDownload: n }) {
29
- let r = d(null), [i, a] = f(null), [o, l] = f(1), [p, ee] = f(1), [h, te] = f(N);
30
- c(() => {
31
- let e = r.current;
32
- if (!e || typeof ResizeObserver > "u") return;
33
- let t = new ResizeObserver((e) => {
34
- let t = e[0]?.contentRect.width;
35
- t && te(t);
36
- });
37
- return t.observe(e), () => t.disconnect();
38
- }, []), c(() => {
39
- a(null), l(1), ee(1);
40
- }, [t]);
41
- let g = u(() => {
42
- let e = Math.max(He, h - Ue);
43
- return Math.round(Math.min(P, e) * p);
44
- }, [p, h]), _ = s((e) => {
45
- a(e.numPages), l(1);
46
- }, []), ne = o > 1, v = i !== null && o < i, re = p > F, y = p < We, b = i === null ? `第 ${o} 頁` : `第 ${o} / ${i} 頁`, S = `${Math.round(p * 100)}%`;
47
- return /* @__PURE__ */ w("section", {
48
- "aria-label": `${e} PDF 預覽`,
49
- className: M.root,
50
- children: [/* @__PURE__ */ w("div", {
51
- className: M.toolbar,
52
- children: [
53
- /* @__PURE__ */ w("div", {
54
- className: M.pageControls,
55
- "aria-label": "頁面切換",
56
- children: [
57
- /* @__PURE__ */ C(m, {
58
- "aria-label": "上一頁",
59
- disabled: !ne,
60
- icon: Ce,
61
- onClick: () => {
62
- l((e) => Math.max(1, e - 1));
63
- },
64
- size: "minor",
65
- variant: "base-secondary"
66
- }),
67
- /* @__PURE__ */ C(x, {
68
- className: M.counter,
69
- component: "span",
70
- variant: "body",
71
- children: b
72
- }),
73
- /* @__PURE__ */ C(m, {
74
- "aria-label": "下一頁",
75
- disabled: !v,
76
- icon: E,
77
- onClick: () => {
78
- l((e) => i === null ? e : Math.min(i, e + 1));
79
- },
80
- size: "minor",
81
- variant: "base-secondary"
82
- })
83
- ]
84
- }),
85
- /* @__PURE__ */ w("div", {
86
- className: M.zoomControls,
87
- "aria-label": "縮放",
88
- children: [
89
- /* @__PURE__ */ C(m, {
90
- "aria-label": "縮小",
91
- disabled: !re,
92
- icon: je,
93
- onClick: () => {
94
- ee((e) => Math.max(F, e - I));
95
- },
96
- size: "minor",
97
- variant: "base-secondary"
98
- }),
99
- /* @__PURE__ */ C(x, {
100
- className: M.counter,
101
- component: "span",
102
- variant: "body",
103
- children: S
104
- }),
105
- /* @__PURE__ */ C(m, {
106
- "aria-label": "放大",
107
- disabled: !y,
108
- icon: Ae,
109
- onClick: () => {
110
- ee((e) => Math.min(We, e + I));
111
- },
112
- size: "minor",
113
- variant: "base-secondary"
114
- })
115
- ]
116
- }),
117
- n ? /* @__PURE__ */ C(m, {
118
- icon: D,
119
- iconType: "leading",
120
- onClick: n,
121
- size: "minor",
122
- variant: "base-primary",
123
- children: "下載"
124
- }) : null
125
- ]
126
- }), /* @__PURE__ */ C("div", {
127
- className: M.viewport,
128
- ref: r,
129
- children: /* @__PURE__ */ C(Be, {
130
- error: /* @__PURE__ */ C(L, { message: "PDF 無法載入。" }),
131
- file: t,
132
- loading: /* @__PURE__ */ C(L, { message: "正在載入 PDF..." }),
133
- noData: /* @__PURE__ */ C(L, { message: "沒有可預覽的 PDF。" }),
134
- onLoadSuccess: _,
135
- children: /* @__PURE__ */ C(Ve, {
136
- className: M.page,
137
- loading: /* @__PURE__ */ C(L, { message: "正在載入頁面..." }),
138
- pageNumber: o,
139
- renderAnnotationLayer: !0,
140
- renderTextLayer: !0,
141
- width: g
142
- })
143
- })
144
- })]
145
- });
146
- }
147
- function L({ message: e }) {
148
- return /* @__PURE__ */ C("div", {
149
- className: M.state,
150
- children: /* @__PURE__ */ C(x, {
151
- color: "text-neutral",
152
- variant: "body",
153
- children: e
154
- })
155
- });
156
- }
157
- //#endregion
158
- //#region src/views/instances/detail/sections/shared.ts
159
- function R(e) {
160
- let t = B(e, "from"), n = B(e, "to"), r = B(e, "reason");
161
- return !t || !n || !r ? null : {
162
- from: t,
163
- reason: r,
164
- ruleId: B(e, "ruleId"),
165
- to: n
166
- };
167
- }
168
- function z(e) {
169
- try {
170
- let t = JSON.parse(e);
171
- return Array.isArray(t) ? t.map((e) => W(e) ? R(e) : null).filter((e) => e !== null) : [];
172
- } catch {
173
- return [];
174
- }
175
- }
176
- function B(e, t) {
177
- let n = e[t];
178
- return typeof n == "string" ? n : null;
179
- }
180
- function V(e, t) {
181
- let n = e[t];
182
- return Array.isArray(n) ? n.filter((e) => typeof e == "string") : [];
183
- }
184
- function H(e, t) {
185
- let n = e[t];
186
- return typeof n == "number" ? n : null;
187
- }
188
- function U(e) {
189
- return typeof e == "string" && e.trim().length > 0;
190
- }
191
- function W(e) {
192
- return typeof e == "object" && !!e;
193
- }
194
- function Ke(e) {
195
- return e.status === "PENDING" || e.status === "IN_PROGRESS";
196
- }
197
- function G(e) {
198
- return Pe(e) || (e instanceof Error ? e.message : "發生未知錯誤");
199
- }
200
- function qe(e) {
201
- return !Number.isFinite(e) || e <= 0 ? "-" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
202
- }
203
- function Je(e) {
204
- return e.length > 16 ? `${e.slice(0, 12)}...` : e;
205
- }
206
- function Ye(e) {
207
- return e === "APPROVED" ? "已同意" : e === "CANCELLED" ? "已取消" : e === "DRAFT" ? "草稿" : e === "EXPIRED" ? "已逾期" : e === "REJECTED" ? "已拒絕" : e === "RETURNED" ? "已退回" : e === "RUNNING" ? "進行中" : e;
208
- }
209
- function K(e) {
210
- return e === "PENDING" ? "待處理" : e === "IN_PROGRESS" ? "處理中" : e === "COMPLETED" ? "已完成" : e === "CANCELLED" ? "已取消" : e === "TRANSFERRED" ? "已轉派" : e;
211
- }
212
- function Xe(e) {
213
- return e === "APPROVED" ? "同意" : e === "REJECTED" ? "拒絕" : e === "RETURNED" ? "退回" : e === "TRANSFERRED" ? "轉派" : e;
214
- }
215
- function q(e) {
216
- return e === "startEvent" ? "開始" : e === "endEvent" ? "完成" : e === "userTask" ? "簽核節點" : e === "serviceTask" ? "知會節點" : e === "exclusiveGateway" ? "條件分流" : "平行處理";
217
- }
218
- function J(e, t) {
219
- return t?.nodes.find((t) => t.id === e)?.data.label ?? e;
220
- }
221
- function Y(e, t) {
222
- if (!e) return "-";
223
- let n = t.get(e);
224
- return n ? `${n.name}(${n.email})` : e;
225
- }
226
- function Ze(e, t = /* @__PURE__ */ new Map()) {
227
- let n = z(e.delegationChainJson);
228
- if (!e.assigneeMemberId) return e.candidateMemberIds.length ? `候選 ${e.candidateMemberIds.map((e) => Y(e, t)).join("、")}` : "未指定";
229
- let r = Y(e.assigneeMemberId, t), i = Y(e.originalAssigneeMemberId, t);
230
- return n.length === 0 || e.originalAssigneeMemberId === e.assigneeMemberId ? r : `${r}(原:${i})`;
231
- }
232
- function Qe(e, t) {
233
- return t ? e.assigneeMemberId === t || e.candidateMemberIds.includes(t) : !1;
234
- }
235
- function $e(e, t) {
236
- if (t.type !== "userTask" || !t.data.returnBehavior.allowReturn) return [];
237
- if (t.data.returnBehavior.allowedTargets === "ANY") return e.nodes.filter((e) => e.id !== t.id).map((e) => ({
238
- id: e.id,
239
- name: `${e.data.label}(${q(e.type)})`
240
- }));
241
- let n = t.data.returnBehavior.allowedTargets === "INITIATOR" ? e.nodes.find((e) => e.type === "startEvent")?.id : e.edges.find((e) => e.target === t.id)?.source, r = e.nodes.find((e) => e.id === n);
242
- return r ? [{
243
- id: r.id,
244
- name: `${r.data.label}(${q(r.type)})`
245
- }] : [];
246
- }
247
- function et(e) {
248
- return {
249
- email: e.email,
250
- id: e.memberId,
251
- name: `${e.name} · ${e.email}`
252
- };
253
- }
254
- function tt(e) {
255
- if (!W(e)) return null;
256
- let t = e.email, n = e.id, r = e.name;
257
- return typeof n == "string" && typeof r == "string" ? {
258
- email: typeof t == "string" ? t : null,
259
- id: n,
260
- name: r
261
- } : null;
262
- }
263
- function nt(e, t) {
264
- let n = e.trim().toLocaleLowerCase();
265
- if (!n) return null;
266
- let r = t.filter((e) => [
267
- e.id,
268
- e.name,
269
- e.email ?? ""
270
- ].some((e) => e.toLocaleLowerCase().includes(n)));
271
- return r.length === 1 ? r[0] ?? null : null;
272
- }
273
- function X(e) {
274
- return U(e) ? {
275
- text: e,
276
- type: "text"
277
- } : null;
278
- }
279
- function rt(e) {
280
- return U(e) ? {
281
- text: e,
282
- type: "dangerText"
283
- } : null;
284
- }
285
- function it(e, t, n, r) {
286
- let i = t ? n.get(t) : null;
287
- return {
288
- email: i?.email ?? null,
289
- label: i?.name ?? r,
290
- memberId: t,
291
- prefix: e,
292
- type: "member"
293
- };
294
- }
295
- function Z(e) {
296
- return !!e;
297
- }
298
- function at(e) {
299
- let t = e.findIndex((e) => e.id.startsWith("pending-task-") || e.id.startsWith("future-node-"));
300
- return t === -1 ? e.length : t;
301
- }
302
- function ot(e) {
303
- return e.eventType === "INSTANCE_STARTED" || e.eventType === "TASK_DECIDED" || e.eventType === "SLA_TRIGGERED";
304
- }
305
- function st(e) {
306
- return e === "APPROVED" ? "已同意" : e === "REJECTED" ? "已拒絕" : e === "RETURNED" ? "已退回" : e === "TRANSFERRED" ? "已轉派" : "簽核已決議";
307
- }
308
- function ct(e, t) {
309
- return e === "INSTANCE_STARTED" ? "案件已發起" : e === "TOKEN_CREATED" ? "流程路徑已建立" : e === "ENGINE_PROCESS_REQUESTED" ? "流程引擎已處理" : e === "TOKEN_ADVANCED" ? "流程已前進" : e === "TASK_CREATED" ? "待簽任務已建立" : e === "TASK_DECIDED" ? st(B(t, "action")) : e === "SLA_TRIGGERED" ? "時限提醒已觸發" : e;
310
- }
311
- function lt(e) {
312
- try {
313
- let t = JSON.parse(e.payloadJson);
314
- return W(t) ? t : {};
315
- } catch {
316
- return {};
317
- }
318
- }
319
- function ut(e, t) {
320
- return e.eventType === "SLA_TRIGGERED" || B(t, "action") === "REJECTED" || B(t, "instanceState") === "REJECTED";
321
- }
322
- function dt(e) {
323
- return t(e);
324
- }
325
- function ft(e, t, n, r) {
326
- if (e.eventType === "TASK_CREATED") {
327
- let e = B(t, "assigneeMemberId"), n = B(t, "originalAssigneeMemberId");
328
- if (!e) {
329
- let e = V(t, "candidateMemberIds");
330
- return e.length ? `候選簽核人:${e.map((e) => Y(e, r)).join("、")}` : null;
331
- }
332
- let i = Y(e, r), a = Y(n, r);
333
- return n && n !== e ? `待簽人:${i}(原簽核人:${a})` : `待簽人:${i}`;
334
- }
335
- if (e.eventType === "TASK_DECIDED") {
336
- let e = B(t, "action"), n = B(t, "comment"), i = e ? `決議:${Xe(e)}` : null, a = B(t, "transferToMemberId");
337
- return e === "REJECTED" && n ? [i, `拒絕原因:${n}`].filter(U).join(" · ") : e === "APPROVED" && n ? [i, `同意說明:${n}`].filter(U).join(" · ") : e === "TRANSFERRED" ? [i, `轉派給:${Y(a, r)}`].filter(U).join(" · ") : i;
338
- }
339
- if (e.eventType === "TOKEN_ADVANCED") {
340
- let e = B(t, "action");
341
- if (e) return `流程結果:${Xe(e)}`;
342
- let r = H(t, "arrivedCount"), i = H(t, "requiredCount");
343
- if (r !== null && i !== null) return `等待匯合:${r}/${i}`;
344
- let a = B(t, "fromNodeId"), o = B(t, "toNodeId");
345
- if (a && o) return `由 ${J(a, n)} 前進至 ${J(o, n)}`;
346
- }
347
- if (e.eventType === "ENGINE_PROCESS_REQUESTED") {
348
- let e = B(t, "state");
349
- return e ? `案件狀態:${Ye(e)}` : null;
350
- }
351
- return null;
352
- }
353
- function pt(e, t, n, r, i, a, o) {
354
- if (e.eventType !== "TASK_DECIDED") return [X(ft(e, t, n, o))].filter(Z);
355
- let s = e.taskId ? r.get(e.taskId) : null, c = B(t, "action") ?? s?.action ?? null, l = B(t, "comment") ?? s?.comment ?? null, u = B(t, "transferToMemberId") ?? s?.transferToMemberId ?? null, d = B(t, "signatureId") ?? s?.signatureId ?? null, f = d ? i.get(d) : null;
356
- return [
357
- X(c ? `決議:${Xe(c)}` : null),
358
- c === "REJECTED" ? rt(`拒絕原因:${l ?? "-"}`) : null,
359
- c === "APPROVED" && l ? X(`同意說明:${l}`) : null,
360
- c === "RETURNED" ? X(`退回說明:${l ?? "-"}`) : null,
361
- c === "TRANSFERRED" ? X(`轉派給:${Y(u, o)}`) : null,
362
- c === "TRANSFERRED" ? X(`轉派說明:${l ?? "-"}`) : null,
363
- f ? X(a?.valid ? `簽章:已驗證(${Je(f.signedPayloadHash)})` : `簽章:待檢查(${Je(f.signedPayloadHash)})`) : null
364
- ].filter(Z);
365
- }
366
- function mt(e, t, n, r, i) {
367
- if (e.type === "startEvent" || i.has(e.id)) return !1;
368
- if (r === "REJECTED") return !0;
369
- let a = xt(e, t, n, r);
370
- return a.tone === "neutral" || a.tone === "waiting";
371
- }
372
- function Q(e, t, n, r, i) {
373
- if (r !== "RUNNING" && r !== "REJECTED") return [];
374
- let a = e.nodes.filter((e) => mt(e, t, n, r, i)), o = ht(e, a, t, n, i), s = new Map(e.nodes.map((e, t) => [e.id, t]));
375
- return a.filter((e) => o.has(e.id)).sort((e, t) => {
376
- let n = o.get(e.id) ?? 0, r = o.get(t.id) ?? 0;
377
- return n === r ? e.position.x === t.position.x ? e.position.y === t.position.y ? (s.get(e.id) ?? 0) - (s.get(t.id) ?? 0) : e.position.y - t.position.y : e.position.x - t.position.x : n - r;
378
- });
379
- }
380
- function ht(e, t, n, r, i) {
381
- let a = new Set(t.map((e) => e.id)), o = e.edges.reduce((e, t) => {
382
- let n = [...e.get(t.source) ?? [], t.target];
383
- return new Map(e).set(t.source, n);
384
- }, /* @__PURE__ */ new Map());
385
- return gt(e, n, r, i).reduce((e, t) => yt(e, _t(t, o, a)), /* @__PURE__ */ new Map());
386
- }
387
- function gt(e, t, n, r) {
388
- let i = n.filter((e) => e.status === "ACTIVE" || e.status === "WAITING").map((e) => e.currentNodeId), a = t.filter(Ke).map((e) => e.nodeId), o = e.nodes.filter((e) => r.has(e.id)).map((e) => e.id), s = [.../* @__PURE__ */ new Set([
389
- ...i,
390
- ...a,
391
- ...o
392
- ])], c = e.nodes.filter((e) => e.type === "startEvent").map((e) => e.id);
393
- return s.length > 0 ? s : c;
394
- }
395
- function _t(e, t, n) {
396
- return vt([{
397
- distance: 0,
398
- nodeId: e
399
- }], t, n);
400
- }
401
- function vt(e, t, n, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map()) {
402
- let [a, ...o] = e;
403
- if (!a) return i;
404
- if (r.has(a.nodeId)) return vt(o, t, n, r, i);
405
- let s = new Set(r).add(a.nodeId), c = n.has(a.nodeId) ? new Map(i).set(a.nodeId, Math.min(i.get(a.nodeId) ?? a.distance, a.distance)) : i;
406
- return vt([...o, ...(t.get(a.nodeId) ?? []).map((e) => ({
407
- distance: a.distance + 1,
408
- nodeId: e
409
- }))], t, n, s, c);
410
- }
411
- function yt(e, t) {
412
- return [...t.entries()].reduce((e, [t, n]) => new Map(e).set(t, Math.min(e.get(t) ?? n, n)), e);
413
- }
414
- function $(e) {
415
- return e.type === "userTask" ? `未來簽核:${e.data.label}` : e.type === "serviceTask" ? `未來知會:${e.data.label}` : e.type === "exclusiveGateway" ? `未來分流:${e.data.label}` : e.type === "parallelGateway" ? `未來匯合:${e.data.label}` : e.type === "endEvent" ? `流程完成:${e.data.label}` : `未來節點:${e.data.label}`;
416
- }
417
- function bt(e, t, n, r, i, a, o, s, c) {
418
- let l = e.filter(ot).map((e) => {
419
- let t = lt(e), n = e.nodeId ? J(e.nodeId, r) : null;
420
- return {
421
- descriptionParts: [
422
- X(n ? `節點:${n}` : "節點:全流程"),
423
- it("操作者", e.actorMemberId, a, "系統"),
424
- X(`時間:${dt(e.createdAt)}`),
425
- ...pt(e, t, r, o, s, c, a)
426
- ].filter(Z),
427
- error: ut(e, t),
428
- id: e.id,
429
- title: ct(e.eventType, t)
430
- };
431
- }), u = t.filter(Ke).map((e) => ({
432
- descriptionParts: [
433
- X(`節點:${J(e.nodeId, r)}`),
434
- it("處理者", e.assigneeMemberId, a, "未指定"),
435
- X(`建立時間:${dt(e.createdAt)}`)
436
- ].filter(Z),
437
- error: !1,
438
- id: `pending-task-${e.id}`,
439
- title: e.status === "IN_PROGRESS" ? "簽核處理中" : "等待簽核處理"
440
- })), d = new Set([...e.filter(ot).map((e) => e.nodeId), ...t.map((e) => e.nodeId)].filter(U)), f = r ? Q(r, t, n, i, d).map((e) => ({
441
- descriptionParts: [X(`${q(e.type)} · 尚未抵達`)].filter(Z),
442
- error: !1,
443
- forcePending: !0,
444
- id: `future-node-${e.id}`,
445
- title: $(e)
446
- })) : [];
447
- return [
448
- ...l,
449
- ...u,
450
- ...f
451
- ];
452
- }
453
- function xt(e, t, n, r) {
454
- let i = t.filter((t) => t.nodeId === e.id), a = i.find((e) => e.status === "PENDING" || e.status === "IN_PROGRESS"), o = i.find((e) => e.status === "CANCELLED"), s = i.find((e) => e.status === "COMPLETED"), c = n.filter((t) => t.currentNodeId === e.id), l = c.find((e) => e.status === "ACTIVE"), u = c.find((e) => e.status === "WAITING");
455
- return a ? {
456
- secondaryLabel: `處理者 ${Ze(a)}`,
457
- statusLabel: "待處理",
458
- tone: "current"
459
- } : o ? {
460
- secondaryLabel: `已取消 ${Ze(o)}`,
461
- statusLabel: "已取消",
462
- tone: "cancelled"
463
- } : s ? {
464
- secondaryLabel: `已完成 ${Ze(s)}`,
465
- statusLabel: "已完成",
466
- tone: "completed"
467
- } : l ? {
468
- secondaryLabel: `token ${l.id}`,
469
- statusLabel: "執行中",
470
- tone: "current"
471
- } : u ? {
472
- secondaryLabel: `token ${u.id}`,
473
- statusLabel: "等待前置",
474
- tone: "waiting"
475
- } : e.type === "startEvent" ? {
476
- secondaryLabel: "流程已發起",
477
- statusLabel: "已發起",
478
- tone: "completed"
479
- } : e.type === "endEvent" && r !== "RUNNING" ? {
480
- secondaryLabel: r,
481
- statusLabel: r === "REJECTED" ? "已拒絕" : "已完成",
482
- tone: r === "REJECTED" ? "cancelled" : "completed"
483
- } : {
484
- secondaryLabel: q(e.type),
485
- statusLabel: "未抵達",
486
- tone: "neutral"
487
- };
488
- }
489
- //#endregion
490
- //#region src/views/instances/detail/sections/container-helpers.ts
491
- async function St({ activityLogs: e, adhocDirectives: t = [], tasks: n }) {
492
- let r = [...new Set([
493
- ...e.map((e) => e.actorMemberId),
494
- ...n.map((e) => e.assigneeMemberId),
495
- ...n.map((e) => e.originalAssigneeMemberId),
496
- ...n.flatMap((e) => e.candidateMemberIds),
497
- ...n.flatMap((e) => z(e.delegationChainJson).flatMap((e) => [e.from, e.to])),
498
- ...t.flatMap((e) => [e.createdByMemberId, ...Ct(e.targetValueJson)])
499
- ].filter(U))];
500
- try {
501
- return await _e(r);
502
- } catch {
503
- return [];
504
- }
505
- }
506
- function Ct(e) {
507
- try {
508
- return (JSON.parse(e).memberIds ?? []).filter((e) => typeof e == "string");
509
- } catch {
510
- return [];
511
- }
512
- }
513
- async function wt(e) {
514
- return (await Promise.all(e.map((e) => ue(e.id)))).flat();
515
- }
516
- function Tt(e) {
517
- return e.reduce((e, t) => {
518
- let n = e.get(t.taskId), r = !n || new Date(t.decidedAt).getTime() > new Date(n.decidedAt).getTime() ? t : n;
519
- return new Map(e).set(t.taskId, r);
520
- }, /* @__PURE__ */ new Map());
521
- }
522
- //#endregion
523
- //#region src/views/instances/detail/sections/InstanceFormSection.tsx
524
- var Et = {
525
- display: "grid",
526
- gap: 16
527
- }, Dt = {
528
- display: "flex",
529
- flexWrap: "wrap",
530
- gap: 8
531
- };
532
- function Ot({ canResubmitInstance: e, deciding: t, error: n, instance: r, loading: a, onDataSourceStateChange: o, onResubmitFormChange: s, onResubmitInstance: c, onUploadAttachment: l, resubmitFormData: u, resubmitFormErrors: d }) {
533
- return /* @__PURE__ */ w("div", {
534
- style: Et,
535
- children: [
536
- n ? /* @__PURE__ */ C(x, {
537
- color: "text-error",
538
- variant: "body",
539
- children: n
540
- }) : null,
541
- a ? /* @__PURE__ */ C(x, {
542
- color: "text-neutral",
543
- variant: "body",
544
- children: "載入中..."
545
- }) : null,
546
- r?.formDefinitionSnapshot.schema && r.formDefinitionSnapshot.uiSchema ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(i, {
547
- dataSourceContext: e ? {
548
- instanceId: r.id,
549
- kind: "runtime"
550
- } : void 0,
551
- dataSourceInitialValues: r.formData,
552
- errors: d,
553
- onChange: (e) => {
554
- s(e);
555
- },
556
- onDataSourceStateChange: o,
557
- onUploadAttachment: e ? l : void 0,
558
- optionSnapshots: r.formDataOptionSnapshot,
559
- readonly: !e,
560
- schema: r.formDefinitionSnapshot.schema,
561
- uiSchema: r.formDefinitionSnapshot.uiSchema,
562
- value: e ? u : r.formData
563
- }), e ? /* @__PURE__ */ C("div", {
564
- style: Dt,
565
- children: /* @__PURE__ */ C(m, {
566
- disabled: t,
567
- icon: De,
568
- iconType: "leading",
569
- onClick: c,
570
- variant: "base-primary",
571
- children: "重新送出"
572
- })
573
- }) : null] }) : /* @__PURE__ */ C(x, {
574
- color: "text-neutral",
575
- variant: "body",
576
- children: "此案件沒有可顯示的表單快照。"
577
- })
578
- ]
579
- });
580
- }
581
- //#endregion
582
- //#region src/views/instances/detail/sections/InstanceAttachmentsSection.tsx
583
- var kt = {
584
- display: "grid",
585
- gap: 16
586
- };
587
- function At({ attachments: e, onDownload: n, onPreview: r }) {
588
- let i = u(() => e.map((e) => ({
589
- attachment: e,
590
- createdAt: e.createdAt,
591
- filename: e.filename,
592
- id: e.id,
593
- key: e.id,
594
- mimeType: e.mimeType,
595
- sizeLabel: qe(Number(e.sizeBytes))
596
- })), [e]), a = u(() => [
597
- {
598
- dataIndex: "filename",
599
- key: "filename",
600
- title: "檔名",
601
- width: 260
602
- },
603
- {
604
- dataIndex: "mimeType",
605
- key: "mimeType",
606
- title: "類型",
607
- width: 180
608
- },
609
- {
610
- dataIndex: "sizeLabel",
611
- key: "sizeLabel",
612
- title: "大小",
613
- width: 120
614
- },
615
- {
616
- key: "createdAt",
617
- render: (e) => /* @__PURE__ */ C(x, {
618
- component: "span",
619
- variant: "body",
620
- children: t(e.createdAt)
621
- }),
622
- title: "上傳時間",
623
- width: 220
624
- }
625
- ], []), o = u(() => ({
626
- render: (e) => [...e.mimeType === "application/pdf" ? [{
627
- icon: O,
628
- iconType: "leading",
629
- name: "預覽",
630
- onClick: () => {
631
- r(e.attachment);
632
- }
633
- }] : [], {
634
- icon: D,
635
- iconType: "leading",
636
- name: "下載",
637
- onClick: () => {
638
- n(e.attachment);
639
- }
640
- }],
641
- variant: "base-secondary",
642
- width: 160
643
- }), [n, r]);
644
- return /* @__PURE__ */ w("div", {
645
- style: kt,
646
- children: [/* @__PURE__ */ C(x, {
647
- component: "h2",
648
- variant: "h3",
649
- children: "附件"
650
- }), i.length > 0 ? /* @__PURE__ */ C(re, {
651
- actions: o,
652
- columns: a,
653
- dataSource: i,
654
- fullWidth: !0
655
- }) : /* @__PURE__ */ C(x, {
656
- color: "text-neutral",
657
- variant: "body",
658
- children: "此案件沒有附件。"
659
- })]
660
- });
661
- }
662
- //#endregion
663
- //#region src/views/instances/detail/sections/InstanceTasksSection.tsx
664
- var jt = {
665
- display: "grid",
666
- gap: 12,
667
- width: "100%"
668
- }, Mt = {
669
- minWidth: "100%",
670
- width: "100%"
671
- }, Nt = {
672
- display: "grid",
673
- gap: 12,
674
- width: "100%"
675
- }, Pt = { marginTop: 12 }, Ft = { marginTop: 24 };
676
- function It(e) {
677
- e && (e.style.width = "100%");
678
- }
679
- var Lt = {
680
- COMPLETION_NOTIFY: "結案通知",
681
- COUNTERSIGN: "臨時會簽",
682
- PRE_APPROVAL: "臨時加簽",
683
- STAGE_NOTIFY: "階段完成通知"
684
- }, Rt = {
685
- COMPLETION_NOTIFY: "本張單到達結案狀態(核准 / 拒絕 / 取消)後,通知指定對象。",
686
- COUNTERSIGN: "指定對象會併入下一層簽核,下一層需所有人都完成才會繼續。",
687
- PRE_APPROVAL: "指定對象需先完成加簽,本階段才會往下一層繼續。",
688
- STAGE_NOTIFY: "本階段完成後(不論通過與否)通知指定對象。"
689
- }, zt = [{
690
- id: "REJECT_INSTANCE",
691
- name: "加簽拒絕時整單駁回"
692
- }, {
693
- id: "RETURN_TO_ORIGIN",
694
- name: "加簽拒絕時退回給我重新處理"
695
- }], Bt = [{
696
- id: "MEMBER",
697
- name: "指定成員"
698
- }, {
699
- id: "WEBHOOK",
700
- name: "Webhook"
701
- }], Vt = o(function({ adhocDirectives: e, currentMemberId: r, instance: i, memberProfilesById: a, onChanged: o, tasks: s }, c) {
702
- let [d, te] = f(!1), [g, _] = f(null), [v, b] = f(""), [ie, ce] = f(!1), [le, ue] = f(""), [de, fe] = f(null), [pe, me] = f(!1), [_e, ve] = f(""), [be, xe] = f(!1), [Se, Ce] = f(null), [E, we] = f(""), [D, O] = f(null), [Te, Ee] = f(!1), [De, Oe] = f([]), [ke, Ae] = f(!1), [je, Me] = f(""), [Ne, Pe] = f(null), [Fe, Ie] = f(!1), [Le, Re] = f([]), [k, ze] = f(!1), [A, Be] = f("COUNTERSIGN"), [Ve, j] = f("REJECT_INSTANCE"), [M, N] = f(!1), [P, He] = f("MEMBER"), [Ue, F] = f(""), We = le.trim(), I = _e.trim(), Ge = E.trim(), L = u(() => s.find((e) => Qe(e, r) && (e.status === "PENDING" || e.status === "IN_PROGRESS")) ?? null, [r, s]), R = u(() => L && i ? i.workflowSnapshot.nodes.find((e) => e.id === L.nodeId) ?? null : null, [L, i]), z = u(() => R && i ? $e(i.workflowSnapshot, R) : [], [R, i]), B = R?.type === "userTask" && R.data.returnBehavior.allowReturn, V = R?.type === "userTask" && R.data.allowReject !== !1, H = R?.type === "userTask" && R.data.allowTransfer !== !1, U = R?.type === "userTask" && R.data.returnBehavior.requireComment === !0, W = R?.type === "userTask" && R.data.allowAddSigner, Ke = u(() => e.filter((e) => e.status === "PENDING"), [e]), qe = z.find((e) => e.id === Se) ?? z[0] ?? null, Je = u(() => s.map((e) => ({
703
- ...e,
704
- assigneeLabel: Ze(e, a),
705
- key: e.id,
706
- nodeLabel: `${J(e.nodeId, i?.workflowSnapshot ?? null)}${e.isAdhoc ? e.adhocType === "COUNTERSIGN" ? "(臨時會簽)" : "(臨時加簽)" : ""}`,
707
- statusLabel: K(e.status)
708
- })), [
709
- i,
710
- a,
711
- s
712
- ]), Ye = u(() => [
713
- {
714
- dataIndex: "nodeLabel",
715
- key: "nodeLabel",
716
- title: "節點",
717
- width: 180
718
- },
719
- {
720
- key: "assigneeMemberId",
721
- title: "處理者",
722
- render: (e) => /* @__PURE__ */ C(x, {
723
- component: "span",
724
- variant: "body",
725
- children: e.assigneeLabel
726
- }),
727
- width: 180
728
- },
729
- {
730
- dataIndex: "statusLabel",
731
- key: "statusLabel",
732
- title: "狀態",
733
- width: 120
734
- },
735
- {
736
- key: "createdAt",
737
- render: (e) => /* @__PURE__ */ C(x, {
738
- component: "span",
739
- variant: "body",
740
- children: t(e.createdAt)
741
- }),
742
- title: "建立時間",
743
- width: 220
744
- }
745
- ], []), Xe = u(() => Ke.map((e) => ({
746
- ...e,
747
- createdByLabel: Y(e.createdByMemberId, a),
748
- key: e.id,
749
- targetLabel: Ht(e, a),
750
- typeLabel: Lt[e.type]
751
- })), [a, Ke]), q = u(() => [
752
- {
753
- dataIndex: "typeLabel",
754
- key: "typeLabel",
755
- title: "類型",
756
- width: 180
757
- },
758
- {
759
- key: "targetLabel",
760
- render: (e) => /* @__PURE__ */ C(x, {
761
- component: "span",
762
- variant: "body",
763
- children: e.targetLabel
764
- }),
765
- title: "對象",
766
- width: 220
767
- },
768
- {
769
- key: "createdByLabel",
770
- render: (e) => /* @__PURE__ */ C(x, {
771
- component: "span",
772
- variant: "body",
773
- children: e.createdByLabel
774
- }),
775
- title: "設定者",
776
- width: 180
777
- },
778
- {
779
- key: "createdAt",
780
- render: (e) => /* @__PURE__ */ C(x, {
781
- component: "span",
782
- variant: "body",
783
- children: t(e.createdAt)
784
- }),
785
- title: "建立時間",
786
- width: 220
787
- },
788
- {
789
- key: "actions",
790
- render: (e) => e.createdByMemberId === r ? /* @__PURE__ */ C(m, {
791
- disabled: M,
792
- onClick: () => void yt(e.id),
793
- size: "minor",
794
- variant: "destructive-secondary",
795
- children: "撤回"
796
- }) : /* @__PURE__ */ C(S, {}),
797
- title: "操作",
798
- width: 100
799
- }
800
- ], [M, r]);
801
- async function X({ action: e, comment: t, returnToNodeId: n = null, transferToMemberId: i = null }) {
802
- if (!r || !L || e === "REJECTED" && !V || e === "TRANSFERRED" && !H) return !1;
803
- te(!0), _(null);
804
- try {
805
- await se({
806
- action: e,
807
- comment: t,
808
- decidedByMemberId: r,
809
- returnToNodeId: n,
810
- taskId: L.id,
811
- transferToMemberId: i
812
- }), me(!1), xe(!1), Ae(!1), ue(""), ve(""), we(""), O(null), Ce(null), fe(null);
813
- } catch (e) {
814
- return _(G(e)), te(!1), !1;
815
- }
816
- try {
817
- await o();
818
- } catch (e) {
819
- _(G(e));
820
- } finally {
821
- te(!1);
822
- }
823
- return !0;
824
- }
825
- function rt() {
826
- !r || !L || (_(null), b(""), ce(!0));
827
- }
828
- function it() {
829
- d || (ce(!1), b(""));
830
- }
831
- async function Z() {
832
- d || await X({
833
- action: "APPROVED",
834
- comment: v.trim() || null
835
- }) && (ce(!1), b(""));
836
- }
837
- function at() {
838
- V && (ue(""), fe(null), me(!0));
839
- }
840
- function ot() {
841
- d || (me(!1), ue(""), fe(null));
842
- }
843
- function st() {
844
- ve(""), Ce(z[0]?.id ?? null), xe(!0);
845
- }
846
- function ct() {
847
- d || (xe(!1), ve(""), Ce(null));
848
- }
849
- function lt() {
850
- H && (we(""), O(null), Ae(!0), dt(""));
851
- }
852
- function ut() {
853
- d || (Ae(!1), we(""), O(null));
854
- }
855
- async function dt(e) {
856
- Ee(!0);
857
- try {
858
- Oe((await ye(e)).filter((e) => e.memberId !== r).map(et));
859
- } catch (e) {
860
- _(G(e));
861
- } finally {
862
- Ee(!1);
863
- }
864
- }
865
- async function ft() {
866
- if (V) {
867
- if (!We) {
868
- fe("請輸入拒絕原因");
869
- return;
870
- }
871
- await X({
872
- action: "REJECTED",
873
- comment: We
874
- });
875
- }
876
- }
877
- async function pt() {
878
- if (H) {
879
- if (!D) {
880
- _("請選擇轉派對象");
881
- return;
882
- }
883
- await X({
884
- action: "TRANSFERRED",
885
- comment: Ge || null,
886
- transferToMemberId: D.id
887
- });
888
- }
889
- }
890
- async function mt() {
891
- await X({
892
- action: "RETURNED",
893
- comment: I || null,
894
- returnToNodeId: qe?.id ?? null
895
- });
896
- }
897
- function Q() {
898
- Me(""), Pe(null), j("REJECT_INSTANCE"), He("MEMBER"), F("");
899
- }
900
- function ht(e) {
901
- Be(e), Q(), ze(!0), _t("");
902
- }
903
- function gt() {
904
- M || (ze(!1), Q());
905
- }
906
- async function _t(e) {
907
- Ie(!0);
908
- try {
909
- Re((await ye(e)).map(et));
910
- } catch (e) {
911
- _(G(e));
912
- } finally {
913
- Ie(!1);
914
- }
915
- }
916
- async function vt() {
917
- if (!L) return;
918
- let e = (A === "STAGE_NOTIFY" || A === "COMPLETION_NOTIFY") && P === "WEBHOOK", t = Ue.trim(), n = Ne;
919
- if (e && !t) {
920
- _("請輸入 Webhook URL");
921
- return;
922
- }
923
- if (!e && !n) {
924
- _("請選擇對象成員");
925
- return;
926
- }
927
- let r = e || !n ? {
928
- kind: "WEBHOOK",
929
- webhookUrl: t
930
- } : {
931
- kind: "MEMBER",
932
- memberIds: [n.id]
933
- }, i = je.trim() || null;
934
- N(!0), _(null);
935
- try {
936
- A === "COUNTERSIGN" ? await he({
937
- comment: i,
938
- target: r,
939
- taskId: L.id
940
- }) : A === "PRE_APPROVAL" ? await ge({
941
- comment: i,
942
- onReject: Ve,
943
- target: r,
944
- taskId: L.id
945
- }) : A === "STAGE_NOTIFY" ? await oe({
946
- target: r,
947
- taskId: L.id
948
- }) : await ae({
949
- target: r,
950
- taskId: L.id
951
- }), ze(!1), Q(), await o();
952
- } catch (e) {
953
- _(G(e));
954
- } finally {
955
- N(!1);
956
- }
957
- }
958
- async function yt(e) {
959
- N(!0), _(null);
960
- try {
961
- await T(e), await o();
962
- } catch (e) {
963
- _(G(e));
964
- } finally {
965
- N(!1);
966
- }
967
- }
968
- l(c, () => ({
969
- canAddSignerCurrentTask: W,
970
- canRejectCurrentTask: V,
971
- canReturnCurrentTask: B,
972
- canTransferCurrentTask: H,
973
- deciding: d,
974
- handleApprove: rt,
975
- hasCurrentTask: L !== null,
976
- openAdhocModal: ht,
977
- openRejectModal: at,
978
- openReturnModal: st,
979
- openTransferModal: lt
980
- }), [
981
- W,
982
- V,
983
- B,
984
- H,
985
- r,
986
- L,
987
- d
988
- ]);
989
- let $ = A === "STAGE_NOTIFY" || A === "COMPLETION_NOTIFY", bt = $ && P === "WEBHOOK" ? !Ue.trim() : !Ne, xt = zt.find((e) => e.id === Ve) ?? zt[0], St = Bt.find((e) => e.id === P) ?? Bt[0];
990
- return /* @__PURE__ */ w(S, { children: [
991
- /* @__PURE__ */ C(x, {
992
- component: "h2",
993
- variant: "h3",
994
- children: "任務"
995
- }),
996
- g ? /* @__PURE__ */ C(x, {
997
- color: "text-error",
998
- variant: "body",
999
- children: g
1000
- }) : null,
1001
- /* @__PURE__ */ C("div", {
1002
- style: Pt,
1003
- children: /* @__PURE__ */ C(re, {
1004
- columns: Ye,
1005
- dataSource: Je,
1006
- fullWidth: !0
1007
- })
1008
- }),
1009
- Ke.length > 0 ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(x, {
1010
- component: "h3",
1011
- style: Ft,
1012
- variant: "h3",
1013
- children: "待生效的臨時設定"
1014
- }), /* @__PURE__ */ C("div", {
1015
- style: Pt,
1016
- children: /* @__PURE__ */ C(re, {
1017
- columns: q,
1018
- dataSource: Xe,
1019
- fullWidth: !0
1020
- })
1021
- })] }) : null,
1022
- /* @__PURE__ */ w(h, {
1023
- cancelText: "取消",
1024
- confirmText: "送出同意",
1025
- loading: d,
1026
- modalType: "standard",
1027
- onCancel: it,
1028
- onClose: it,
1029
- onConfirm: () => void Z(),
1030
- open: ie,
1031
- showModalFooter: !0,
1032
- showModalHeader: !0,
1033
- size: "regular",
1034
- supportingText: "可以留下同意的說明,內容會記錄在簽核歷程;不填也可以直接送出。",
1035
- title: "簽核意見",
1036
- children: [g ? /* @__PURE__ */ C(x, {
1037
- color: "text-error",
1038
- role: "alert",
1039
- variant: "body",
1040
- children: g
1041
- }) : null, /* @__PURE__ */ C("div", {
1042
- style: jt,
1043
- children: /* @__PURE__ */ C(n, {
1044
- label: "簽核意見",
1045
- name: "approveComment",
1046
- children: /* @__PURE__ */ C(y, {
1047
- autoFocus: !0,
1048
- onChange: (e) => b(e.target.value),
1049
- placeholder: "選填,例如補充核准的條件或提醒事項",
1050
- ref: It,
1051
- resize: "vertical",
1052
- rows: 4,
1053
- style: Mt,
1054
- value: v
1055
- })
1056
- })
1057
- })]
1058
- }),
1059
- /* @__PURE__ */ C(h, {
1060
- cancelText: "取消",
1061
- confirmButtonProps: {
1062
- disabled: !We,
1063
- variant: "destructive-primary"
1064
- },
1065
- confirmText: "送出拒絕",
1066
- loading: d,
1067
- modalStatusType: "error",
1068
- modalType: "standard",
1069
- onCancel: ot,
1070
- onClose: ot,
1071
- onConfirm: () => void ft(),
1072
- open: pe,
1073
- showModalFooter: !0,
1074
- showModalHeader: !0,
1075
- size: "regular",
1076
- supportingText: "拒絕案件時必須留下原因,供發起人與後續追蹤查看。",
1077
- title: "拒絕原因",
1078
- children: /* @__PURE__ */ w("div", {
1079
- style: jt,
1080
- children: [/* @__PURE__ */ C(n, {
1081
- label: "拒絕原因",
1082
- name: "rejectReason",
1083
- required: !0,
1084
- children: /* @__PURE__ */ C(y, {
1085
- autoFocus: !0,
1086
- onChange: (e) => {
1087
- ue(e.target.value), fe(null);
1088
- },
1089
- placeholder: "請說明拒絕原因",
1090
- ref: It,
1091
- resize: "vertical",
1092
- rows: 4,
1093
- style: Mt,
1094
- type: de ? "error" : "default",
1095
- value: le
1096
- })
1097
- }), de ? /* @__PURE__ */ C(x, {
1098
- color: "text-error",
1099
- variant: "body",
1100
- children: de
1101
- }) : null]
1102
- })
1103
- }),
1104
- /* @__PURE__ */ C(h, {
1105
- cancelText: "取消",
1106
- confirmButtonProps: { disabled: !D },
1107
- confirmText: "送出轉派",
1108
- loading: d,
1109
- modalType: "standard",
1110
- onCancel: ut,
1111
- onClose: ut,
1112
- onConfirm: () => void pt(),
1113
- open: ke,
1114
- showModalFooter: !0,
1115
- showModalHeader: !0,
1116
- size: "regular",
1117
- supportingText: "轉派後,原任務會保留轉派紀錄,新的待簽任務會指派給指定成員。",
1118
- title: "轉派簽核",
1119
- children: /* @__PURE__ */ w("div", {
1120
- style: Nt,
1121
- children: [/* @__PURE__ */ C(n, {
1122
- label: "轉派對象",
1123
- name: "transferToMemberId",
1124
- required: !0,
1125
- children: /* @__PURE__ */ C(p, {
1126
- asyncData: !0,
1127
- disabledOptionsFilter: !0,
1128
- emptyText: "沒有符合的成員",
1129
- inputProps: {
1130
- autoCapitalize: "none",
1131
- autoCorrect: "off",
1132
- name: "transfer-member-search",
1133
- spellCheck: !1
1134
- },
1135
- loading: Te,
1136
- loadingText: "搜尋成員中...",
1137
- mode: "single",
1138
- onChange: (e) => O(tt(e)),
1139
- onSearch: dt,
1140
- onSearchTextChange: (e) => O(nt(e, De)),
1141
- onVisibilityChange: (e) => {
1142
- e && dt("");
1143
- },
1144
- options: [...De],
1145
- placeholder: "搜尋姓名或信箱",
1146
- searchDebounceTime: 300,
1147
- value: D
1148
- })
1149
- }), /* @__PURE__ */ C(n, {
1150
- label: "轉派說明",
1151
- name: "transferComment",
1152
- children: /* @__PURE__ */ C(y, {
1153
- onChange: (e) => we(e.target.value),
1154
- placeholder: "可補充轉派原因",
1155
- ref: It,
1156
- resize: "vertical",
1157
- rows: 4,
1158
- style: Mt,
1159
- value: E
1160
- })
1161
- })]
1162
- })
1163
- }),
1164
- /* @__PURE__ */ C(h, {
1165
- cancelText: "取消",
1166
- confirmButtonProps: { disabled: !qe || U && !I },
1167
- confirmText: "送出退回",
1168
- loading: d,
1169
- modalType: "standard",
1170
- onCancel: ct,
1171
- onClose: ct,
1172
- onConfirm: () => void mt(),
1173
- open: be,
1174
- showModalFooter: !0,
1175
- showModalHeader: !0,
1176
- size: "regular",
1177
- supportingText: "退回後,流程會回到指定節點並等待重新處理。",
1178
- title: "退回簽核",
1179
- children: /* @__PURE__ */ w("div", {
1180
- style: Nt,
1181
- children: [/* @__PURE__ */ C(n, {
1182
- label: "退回節點",
1183
- name: "returnTargetNodeId",
1184
- required: !0,
1185
- children: /* @__PURE__ */ C(ne, {
1186
- clearable: !1,
1187
- fullWidth: !0,
1188
- onChange: (e) => Ce(e?.id ?? null),
1189
- options: [...z],
1190
- placeholder: "選擇退回節點",
1191
- value: qe
1192
- })
1193
- }), /* @__PURE__ */ C(n, {
1194
- hintText: U ? "此關卡設定退回時必須填寫意見。" : void 0,
1195
- label: "退回說明",
1196
- name: "returnComment",
1197
- required: U,
1198
- children: /* @__PURE__ */ C(y, {
1199
- onChange: (e) => ve(e.target.value),
1200
- placeholder: U ? "請說明退回原因" : "可補充需要修改的內容",
1201
- ref: It,
1202
- resize: "vertical",
1203
- rows: 4,
1204
- style: Mt,
1205
- value: _e
1206
- })
1207
- })]
1208
- })
1209
- }),
1210
- /* @__PURE__ */ C(h, {
1211
- cancelText: "取消",
1212
- confirmButtonProps: { disabled: bt },
1213
- confirmText: "送出",
1214
- loading: M,
1215
- modalType: "standard",
1216
- onCancel: gt,
1217
- onClose: gt,
1218
- onConfirm: () => void vt(),
1219
- open: k,
1220
- showModalFooter: !0,
1221
- showModalHeader: !0,
1222
- size: "regular",
1223
- supportingText: Rt[A],
1224
- title: Lt[A],
1225
- children: /* @__PURE__ */ w("div", {
1226
- style: Nt,
1227
- children: [
1228
- $ ? /* @__PURE__ */ C(n, {
1229
- label: "通知時機",
1230
- name: "adhocNotifyMode",
1231
- required: !0,
1232
- children: /* @__PURE__ */ C(ne, {
1233
- clearable: !1,
1234
- fullWidth: !0,
1235
- onChange: (e) => Be(e?.id === "COMPLETION_NOTIFY" ? "COMPLETION_NOTIFY" : "STAGE_NOTIFY"),
1236
- options: [{
1237
- id: "STAGE_NOTIFY",
1238
- name: Lt.STAGE_NOTIFY
1239
- }, {
1240
- id: "COMPLETION_NOTIFY",
1241
- name: Lt.COMPLETION_NOTIFY
1242
- }],
1243
- value: {
1244
- id: A,
1245
- name: Lt[A]
1246
- }
1247
- })
1248
- }) : null,
1249
- $ ? /* @__PURE__ */ C(n, {
1250
- label: "通知對象類型",
1251
- name: "adhocTargetKind",
1252
- required: !0,
1253
- children: /* @__PURE__ */ C(ne, {
1254
- clearable: !1,
1255
- fullWidth: !0,
1256
- onChange: (e) => He(e?.id === "WEBHOOK" ? "WEBHOOK" : "MEMBER"),
1257
- options: [...Bt],
1258
- value: St
1259
- })
1260
- }) : null,
1261
- $ && P === "WEBHOOK" ? /* @__PURE__ */ C(n, {
1262
- label: "Webhook URL",
1263
- name: "adhocWebhookUrl",
1264
- required: !0,
1265
- children: /* @__PURE__ */ C(ee, {
1266
- fullWidth: !0,
1267
- onChange: (e) => F(e.target.value),
1268
- placeholder: "https://example.com/webhook",
1269
- value: Ue
1270
- })
1271
- }) : /* @__PURE__ */ C(n, {
1272
- label: $ ? "通知對象" : "簽核對象",
1273
- name: "adhocMemberId",
1274
- required: !0,
1275
- children: /* @__PURE__ */ C(p, {
1276
- asyncData: !0,
1277
- disabledOptionsFilter: !0,
1278
- emptyText: "沒有符合的成員",
1279
- inputProps: {
1280
- autoCapitalize: "none",
1281
- autoCorrect: "off",
1282
- name: "adhoc-member-search",
1283
- spellCheck: !1
1284
- },
1285
- loading: Fe,
1286
- loadingText: "搜尋成員中...",
1287
- mode: "single",
1288
- onChange: (e) => Pe(tt(e)),
1289
- onSearch: _t,
1290
- onSearchTextChange: (e) => Pe(nt(e, Le)),
1291
- onVisibilityChange: (e) => {
1292
- e && _t("");
1293
- },
1294
- options: [...Le],
1295
- placeholder: "搜尋姓名或信箱",
1296
- searchDebounceTime: 300,
1297
- value: Ne
1298
- })
1299
- }),
1300
- A === "PRE_APPROVAL" ? /* @__PURE__ */ C(n, {
1301
- label: "拒簽處理方式",
1302
- name: "adhocOnReject",
1303
- required: !0,
1304
- children: /* @__PURE__ */ C(ne, {
1305
- clearable: !1,
1306
- fullWidth: !0,
1307
- onChange: (e) => j(e?.id === "RETURN_TO_ORIGIN" ? "RETURN_TO_ORIGIN" : "REJECT_INSTANCE"),
1308
- options: [...zt],
1309
- value: xt
1310
- })
1311
- }) : null,
1312
- $ ? null : /* @__PURE__ */ C(n, {
1313
- label: "說明",
1314
- name: "adhocComment",
1315
- children: /* @__PURE__ */ C(y, {
1316
- onChange: (e) => Me(e.target.value),
1317
- placeholder: "可補充原因",
1318
- ref: It,
1319
- resize: "vertical",
1320
- rows: 3,
1321
- style: Mt,
1322
- value: je
1323
- })
1324
- })
1325
- ]
1326
- })
1327
- })
1328
- ] });
1329
- });
1330
- function Ht(e, t) {
1331
- try {
1332
- let n = JSON.parse(e.targetValueJson);
1333
- if (n.memberIds?.length) return n.memberIds.map((e) => Y(e, t)).join("、");
1334
- if (n.webhookUrl) return n.webhookUrl;
1335
- if (n.positionId) return `職位 ${n.positionId}`;
1336
- if (n.orgUnitId) return `部門 ${n.orgUnitId}`;
1337
- } catch {}
1338
- return e.targetKind;
1339
- }
1340
- //#endregion
1341
- //#region src/views/instances/detail/sections/InstanceSignaturesSection.tsx
1342
- var Ut = {
1343
- display: "grid",
1344
- gap: 16
1345
- };
1346
- function Wt({ signatureVerification: e, signatures: n }) {
1347
- let r = u(() => n.map((e) => ({
1348
- algorithm: e.algorithm,
1349
- hashLabel: Je(e.signedPayloadHash),
1350
- key: e.id,
1351
- keyVersion: e.keyVersion,
1352
- signedAtLabel: t(e.signedAt),
1353
- signerMemberId: e.signerMemberId
1354
- })), [n]), i = u(() => [
1355
- {
1356
- dataIndex: "signerMemberId",
1357
- key: "signerMemberId",
1358
- title: "簽章者",
1359
- width: 160
1360
- },
1361
- {
1362
- dataIndex: "algorithm",
1363
- key: "algorithm",
1364
- title: "演算法",
1365
- width: 150
1366
- },
1367
- {
1368
- dataIndex: "keyVersion",
1369
- key: "keyVersion",
1370
- title: "Key 版本",
1371
- width: 100
1372
- },
1373
- {
1374
- dataIndex: "hashLabel",
1375
- key: "hashLabel",
1376
- title: "Payload Hash",
1377
- width: 180
1378
- },
1379
- {
1380
- dataIndex: "signedAtLabel",
1381
- key: "signedAtLabel",
1382
- title: "簽章時間",
1383
- width: 220
1384
- }
1385
- ], []);
1386
- return /* @__PURE__ */ w("div", {
1387
- style: Ut,
1388
- children: [
1389
- /* @__PURE__ */ C(x, {
1390
- component: "h2",
1391
- variant: "h3",
1392
- children: "簽章"
1393
- }),
1394
- /* @__PURE__ */ C(x, {
1395
- color: e?.valid ? "text-success" : "text-error",
1396
- variant: "body",
1397
- children: e ? e.valid ? `簽章鏈已驗證,共 ${e.checkedCount} 筆。` : `簽章鏈驗證失敗:${e.errors.join("、")}` : "尚無簽章紀錄。"
1398
- }),
1399
- r.length > 0 ? /* @__PURE__ */ C(re, {
1400
- columns: i,
1401
- dataSource: r,
1402
- fullWidth: !0
1403
- }) : null
1404
- ]
1405
- });
1406
- }
1407
- //#endregion
1408
- //#region src/views/instances/detail/sections/InstanceHistorySection.tsx
1409
- var Gt = {
1410
- display: "grid",
1411
- gap: 16
1412
- }, Kt = {
1413
- cursor: "help",
1414
- textDecoration: "underline dotted",
1415
- textUnderlineOffset: 3
1416
- }, qt = { color: "var(--mzn-color-text-error)" };
1417
- function Jt(...e) {
1418
- return e.filter((e) => U(e ?? null)).join(" ");
1419
- }
1420
- var Yt = o(function({ className: e, descriptionParts: t, error: n, forcePending: r = !1, index: i = 0, orientation: o, status: s = "pending", title: c, type: l = "number", ...u }, d) {
1421
- let f = r ? "pending" : s;
1422
- return /* @__PURE__ */ w("div", {
1423
- ...u,
1424
- className: Jt(j.host, l === "dot" ? j.dot : null, n && f !== "processing" ? j.error : null, o === "horizontal" ? j.horizontal : null, l === "number" ? j.number : null, f === "pending" ? j.pending : null, f === "processing" ? j.processing : null, n && f === "processing" ? j.processingError : null, !n && f === "succeeded" ? j.succeeded : null, o === "vertical" ? j.vertical : null, e),
1425
- ref: d,
1426
- children: [l === "dot" ? /* @__PURE__ */ C("span", { className: Jt(j.statusIndicator, j.statusIndicatorDot) }) : /* @__PURE__ */ C("span", {
1427
- className: j.statusIndicator,
1428
- children: i + 1
1429
- }), /* @__PURE__ */ w("div", {
1430
- className: j.textContainer,
1431
- children: [/* @__PURE__ */ w(x, {
1432
- className: j.title,
1433
- variant: "label-primary-highlight",
1434
- children: [c, /* @__PURE__ */ C("span", { className: j.titleConnectLine })]
1435
- }), t.length > 0 ? /* @__PURE__ */ C(x, {
1436
- className: j.description,
1437
- variant: "caption",
1438
- children: t.map((e, t) => /* @__PURE__ */ w(a, { children: [t > 0 ? " · " : null, Xt(e)] }, `${e.type}-${t}`))
1439
- }) : null]
1440
- })]
1441
- });
1442
- });
1443
- function Xt(e) {
1444
- return e.type === "text" ? e.text : e.type === "dangerText" ? /* @__PURE__ */ C("span", {
1445
- style: qt,
1446
- children: e.text
1447
- }) : e.email ? /* @__PURE__ */ w(S, { children: [
1448
- e.prefix,
1449
- ":",
1450
- /* @__PURE__ */ C(b, {
1451
- title: e.email,
1452
- children: ({ onMouseEnter: t, onMouseLeave: n, ref: r }) => /* @__PURE__ */ C("span", {
1453
- "data-testid": e.memberId ? `member-tooltip-${e.memberId}` : void 0,
1454
- onMouseEnter: t,
1455
- onMouseLeave: n,
1456
- ref: r,
1457
- style: Kt,
1458
- children: e.label
1459
- })
1460
- })
1461
- ] }) : `${e.prefix}:${e.label}`;
1462
- }
1463
- function Zt({ activityLogs: e, instanceState: t, memberProfilesById: n, signatureVerification: r, signaturesById: i, taskDecisionsByTaskId: a, tasks: o, workflowSnapshot: s, workflowTokens: c }) {
1464
- let l = bt(e, o, c, s, t, n, a, i, r), u = at(l), d = l.map((e) => ({
1465
- ...e,
1466
- descriptionParts: e.descriptionParts.filter(Z)
1467
- }));
1468
- return /* @__PURE__ */ w("div", {
1469
- style: Gt,
1470
- children: [/* @__PURE__ */ C(x, {
1471
- component: "h2",
1472
- variant: "h3",
1473
- children: "歷程"
1474
- }), d.length > 0 ? /* @__PURE__ */ C(v, {
1475
- currentStep: u,
1476
- orientation: "vertical",
1477
- type: "dot",
1478
- children: d.map((e) => /* @__PURE__ */ C(Yt, {
1479
- descriptionParts: e.descriptionParts,
1480
- error: e.error,
1481
- forcePending: e.forcePending,
1482
- title: e.title
1483
- }, e.id))
1484
- }) : /* @__PURE__ */ C(x, {
1485
- color: "text-neutral",
1486
- variant: "body",
1487
- children: "尚無歷程紀錄。"
1488
- })]
1489
- });
1490
- }
1491
- //#endregion
1492
- //#region src/views/instances/detail/InstanceDetailView.tsx
1493
- var Qt = 184, $t = 96, en = {
1494
- display: "grid",
1495
- gap: 16
1496
- }, tn = {
1497
- background: "#f8fafc",
1498
- border: "1px solid #e2e8f0",
1499
- borderRadius: 8,
1500
- height: "min(64vh, 620px)",
1501
- minHeight: 440,
1502
- overflow: "hidden",
1503
- width: "min(80vw, 1040px)"
1504
- }, nn = {
1505
- background: "#ffffff",
1506
- border: "1px solid #cbd5e1",
1507
- borderRadius: 8,
1508
- boxShadow: "0 8px 18px rgba(15, 23, 42, 0.08)",
1509
- display: "grid",
1510
- gap: 6,
1511
- minHeight: 82,
1512
- padding: 12,
1513
- width: 184
1514
- }, rn = {
1515
- borderRadius: 999,
1516
- fontSize: 12,
1517
- fontWeight: 600,
1518
- justifySelf: "start",
1519
- lineHeight: "18px",
1520
- padding: "0 8px"
1521
- }, an = {
1522
- color: "#64748b",
1523
- fontSize: 12,
1524
- overflow: "hidden",
1525
- textOverflow: "ellipsis",
1526
- whiteSpace: "nowrap"
1527
- }, on = { opacity: 0 }, sn = {
1528
- display: "flex",
1529
- flexWrap: "wrap",
1530
- gap: 8
1531
- }, cn = {
1532
- alignItems: "center",
1533
- background: "#ffffff",
1534
- border: "1px solid #cbd5e1",
1535
- borderRadius: 8,
1536
- color: "#334155",
1537
- display: "inline-flex",
1538
- fontSize: 12,
1539
- fontWeight: 600,
1540
- gap: 6,
1541
- lineHeight: "20px",
1542
- padding: "4px 8px"
1543
- }, ln = {
1544
- display: "grid",
1545
- gap: 16
1546
- }, un = { workflowRuntime: bn };
1547
- function dn({ instanceId: i, showAttachments: a = !0, showForm: o = !0, showHistory: l = !0, showSignatures: p = !0, showTasks: ee = !0 }) {
1548
- let { member: ne } = e(), v = ne?.memberId ?? null, [re, b] = f([]), [T, ae] = f(null), [oe, se] = f([]), [ue, he] = f([]), [ge, _e] = f([]), [ye, Ce] = f(null), [E, D] = f([]), [O, Ae] = f([]), [je, Pe] = f([]), [Re, k] = f(null), [A, Be] = f(!0), [Ve, j] = f(!1), [M, N] = f(!1), [P, He] = f(""), [Ue, F] = f(!1), [We, I] = f({}), [L, R] = f({}), [z, B] = f({}), [V, H] = f(null), [U, W] = f(null), [Ke, qe] = f([]), Je = P.trim(), K = d(null);
1549
- c(() => {
1550
- ct();
1551
- }, [v, i]), c(() => {
1552
- R(T?.formData ?? {}), B({});
1553
- }, [T]);
1554
- let Xe = s((e, t) => {
1555
- B((n) => {
1556
- let r = n[e];
1557
- return r?.hasValue === t.hasValue && r.status === t.status ? n : {
1558
- ...n,
1559
- [e]: {
1560
- hasValue: t.hasValue,
1561
- status: t.status
1562
- }
1563
- };
1564
- });
1565
- }, []), q = u(() => E.find((e) => Qe(e, v) && (e.status === "PENDING" || e.status === "IN_PROGRESS")) ?? null, [v, E]), J = u(() => q && T ? T.workflowSnapshot.nodes.find((e) => e.id === q.nodeId) ?? null : null, [q, T]), Y = J?.type === "userTask" && J.data.returnBehavior.allowReturn, Ze = J?.type === "userTask" && J.data.allowReject !== !1, $e = J?.type === "userTask" && J.data.allowTransfer !== !1, et = J?.type === "userTask" && J.data.allowAddSigner, tt = !!(T && T.initiatorMemberId === v && (T.state === "RUNNING" || T.state === "RETURNED")), nt = !!(T && T.initiatorMemberId === v && T.state === "RETURNED"), X = u(() => new Map(je.map((e) => [e.memberId, e])), [je]), rt = u(() => Tt(oe), [oe]), it = u(() => new Map(ge.map((e) => [e.id, e])), [ge]), Z = u(() => T ? gn(T.workflowSnapshot) : null, [T]), at = u(() => T && Z ? hn(Z, E, O, T.state) : [], [
1566
- T,
1567
- Z,
1568
- E,
1569
- O
1570
- ]), ot = u(() => Z ? _n(Z) : [], [Z]), st = u(() => T ? pn(T.workflowSnapshot) : [], [T]);
1571
- async function ct() {
1572
- Be(!0), k(null);
1573
- try {
1574
- let e = await de(i);
1575
- b(e.activityLogs), ae(e.instance), D(e.tasks), Ae(e.workflowTokens);
1576
- let t = await ce(e.instance.id), [n, r, a, o] = await Promise.all([
1577
- wt(e.tasks),
1578
- St({
1579
- ...e,
1580
- adhocDirectives: t
1581
- }),
1582
- le(e.instance.id),
1583
- me(e.instance.id)
1584
- ]);
1585
- se(n), Pe(r), he(a), _e(o.signatures), Ce(o.verification), qe(t);
1586
- } catch (e) {
1587
- k(G(e));
1588
- } finally {
1589
- Be(!1);
1590
- }
1591
- }
1592
- async function lt(e, t) {
1593
- if (!v) throw Error("尚未登入,無法上傳附件");
1594
- return { id: (await be({
1595
- file: t,
1596
- formFieldPath: `form.${e.fieldKey}`
1597
- })).id };
1598
- }
1599
- async function ut(e) {
1600
- if (!v) return;
1601
- let t = await fe({ id: e.id });
1602
- window.open(t, "_blank", "noopener,noreferrer");
1603
- }
1604
- async function dt(e) {
1605
- if (!v) return;
1606
- let t = await pe({ id: e.id });
1607
- H(e), W(t);
1608
- }
1609
- async function ft() {
1610
- if (!(!v || !T || !tt)) {
1611
- j(!0), k(null), I({});
1612
- try {
1613
- await ie({
1614
- cancelledByMemberId: v,
1615
- comment: Je || null,
1616
- instanceId: T.id
1617
- }), He(""), F(!1), await ct();
1618
- } catch (e) {
1619
- k(G(e));
1620
- } finally {
1621
- j(!1);
1622
- }
1623
- }
1624
- }
1625
- async function pt() {
1626
- if (!v || !T || !nt) return;
1627
- j(!0), k(null), I({});
1628
- let e = r(Object.values(z));
1629
- if (e) {
1630
- k(e), j(!1);
1631
- return;
1632
- }
1633
- let t = T.formDefinitionSnapshot.schema ? Me(T.formDefinitionSnapshot.schema.fields, L) : L;
1634
- if (T.formDefinitionSnapshot.schema && T.formDefinitionSnapshot.uiSchema) {
1635
- let e = Fe({
1636
- schema: T.formDefinitionSnapshot.schema,
1637
- uiSchema: T.formDefinitionSnapshot.uiSchema,
1638
- values: t
1639
- });
1640
- if (!e.valid) {
1641
- I(e.errors), k("請先補齊必填欄位。"), e.firstInvalidFieldKey && Ne(e.firstInvalidFieldKey), j(!1);
1642
- return;
1643
- }
1644
- }
1645
- try {
1646
- await ve({
1647
- formData: t,
1648
- initiatorMemberId: v,
1649
- instanceId: T.id,
1650
- title: T.title
1651
- }), await ct();
1652
- } catch (e) {
1653
- k(G(e));
1654
- } finally {
1655
- j(!1);
1656
- }
1657
- }
1658
- let mt = K.current?.deciding ?? !1, Q = Ve || mt;
1659
- return /* @__PURE__ */ w(S, { children: [
1660
- /* @__PURE__ */ C(te, { children: /* @__PURE__ */ w(xe, {
1661
- description: T ? `${Ye(T.state)} · ${t(T.startedAt)}` : "載入案件內容。",
1662
- title: T?.title ?? "簽核案件",
1663
- children: [
1664
- T ? /* @__PURE__ */ C(m, {
1665
- "aria-label": "查看流程圖",
1666
- icon: Oe,
1667
- iconType: "icon-only",
1668
- onClick: () => N(!0),
1669
- title: "查看流程圖",
1670
- variant: "base-secondary",
1671
- children: "流程圖"
1672
- }) : null,
1673
- tt ? /* @__PURE__ */ C(m, {
1674
- disabled: Q,
1675
- icon: we,
1676
- iconType: "leading",
1677
- onClick: () => F(!0),
1678
- variant: "destructive-secondary",
1679
- children: "取消案件"
1680
- }) : null,
1681
- q ? /* @__PURE__ */ w(S, { children: [
1682
- et ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(m, {
1683
- disabled: Q,
1684
- icon: Ee,
1685
- iconType: "leading",
1686
- onClick: () => K.current?.openAdhocModal("COUNTERSIGN"),
1687
- variant: "base-secondary",
1688
- children: "會簽"
1689
- }, "adhoc-countersign"), /* @__PURE__ */ C(m, {
1690
- disabled: Q,
1691
- icon: Ee,
1692
- iconType: "leading",
1693
- onClick: () => K.current?.openAdhocModal("PRE_APPROVAL"),
1694
- variant: "base-secondary",
1695
- children: "加簽"
1696
- }, "adhoc-pre-approval")] }) : null,
1697
- /* @__PURE__ */ C(m, {
1698
- disabled: Q,
1699
- icon: Te,
1700
- iconType: "leading",
1701
- onClick: () => K.current?.openAdhocModal("STAGE_NOTIFY"),
1702
- variant: "base-secondary",
1703
- children: "通知設定"
1704
- }, "adhoc-notify"),
1705
- Y ? /* @__PURE__ */ C(m, {
1706
- disabled: Q,
1707
- icon: De,
1708
- iconType: "leading",
1709
- onClick: () => K.current?.openReturnModal(),
1710
- variant: "base-secondary",
1711
- children: "退回"
1712
- }, "task-return") : null,
1713
- $e ? /* @__PURE__ */ C(m, {
1714
- disabled: Q,
1715
- icon: ke,
1716
- iconType: "leading",
1717
- onClick: () => K.current?.openTransferModal(),
1718
- variant: "base-secondary",
1719
- children: "轉派"
1720
- }, "task-transfer") : null,
1721
- Ze ? /* @__PURE__ */ C(m, {
1722
- disabled: Q,
1723
- icon: we,
1724
- iconType: "leading",
1725
- onClick: () => K.current?.openRejectModal(),
1726
- variant: "destructive-secondary",
1727
- children: "拒絕"
1728
- }, "task-reject") : null,
1729
- /* @__PURE__ */ C(m, {
1730
- disabled: Q,
1731
- icon: Se,
1732
- iconType: "leading",
1733
- onClick: () => K.current?.handleApprove(),
1734
- variant: "base-primary",
1735
- children: "同意"
1736
- }, "task-approve")
1737
- ] }) : null
1738
- ]
1739
- }) }),
1740
- /* @__PURE__ */ w(_, { children: [
1741
- o ? /* @__PURE__ */ C(g, { children: /* @__PURE__ */ C(Ot, {
1742
- canResubmitInstance: nt,
1743
- deciding: Ve,
1744
- error: Re,
1745
- instance: T,
1746
- loading: A,
1747
- onDataSourceStateChange: Xe,
1748
- onResubmitFormChange: (e) => {
1749
- R(e), I({});
1750
- },
1751
- onResubmitInstance: () => void pt(),
1752
- onUploadAttachment: lt,
1753
- resubmitFormData: L,
1754
- resubmitFormErrors: We
1755
- }) }) : null,
1756
- a ? /* @__PURE__ */ C(g, { children: /* @__PURE__ */ C(At, {
1757
- attachments: ue,
1758
- onDownload: (e) => {
1759
- ut(e);
1760
- },
1761
- onPreview: (e) => {
1762
- dt(e);
1763
- }
1764
- }) }) : null,
1765
- ee ? /* @__PURE__ */ C(g, { children: /* @__PURE__ */ C(Vt, {
1766
- adhocDirectives: Ke,
1767
- currentMemberId: v,
1768
- instance: T,
1769
- memberProfilesById: X,
1770
- onChanged: ct,
1771
- ref: K,
1772
- tasks: E
1773
- }) }) : null,
1774
- p ? /* @__PURE__ */ C(g, { children: /* @__PURE__ */ C(Wt, {
1775
- signatureVerification: ye,
1776
- signatures: ge
1777
- }) }) : null,
1778
- l ? /* @__PURE__ */ C(g, { children: /* @__PURE__ */ C(Zt, {
1779
- activityLogs: re,
1780
- instanceState: T?.state ?? "RUNNING",
1781
- memberProfilesById: X,
1782
- signatureVerification: ye,
1783
- signaturesById: it,
1784
- taskDecisionsByTaskId: rt,
1785
- tasks: E,
1786
- workflowSnapshot: T?.workflowSnapshot ?? null,
1787
- workflowTokens: O
1788
- }) }) : null
1789
- ] }),
1790
- T ? /* @__PURE__ */ C(h, {
1791
- modalType: "standard",
1792
- onClose: () => N(!1),
1793
- open: M,
1794
- showModalHeader: !0,
1795
- size: "wide",
1796
- supportingText: `${Ye(T.state)} · ${t(T.startedAt)}`,
1797
- title: "流程圖",
1798
- children: /* @__PURE__ */ w("div", {
1799
- style: en,
1800
- children: [/* @__PURE__ */ C("div", {
1801
- style: tn,
1802
- children: /* @__PURE__ */ w(ze, {
1803
- edges: ot,
1804
- fitView: !0,
1805
- fitViewOptions: { padding: .18 },
1806
- maxZoom: 1.2,
1807
- minZoom: .2,
1808
- nodes: at,
1809
- nodesDraggable: !1,
1810
- nodesFocusable: !1,
1811
- nodeTypes: un,
1812
- panOnDrag: !0,
1813
- proOptions: { hideAttribution: !0 },
1814
- children: [/* @__PURE__ */ C(Ie, {}), /* @__PURE__ */ C(Le, { showInteractive: !1 })]
1815
- })
1816
- }), st.length > 0 ? /* @__PURE__ */ C("div", {
1817
- style: sn,
1818
- children: st.map((e) => /* @__PURE__ */ C("span", {
1819
- style: cn,
1820
- children: e
1821
- }, e))
1822
- }) : null]
1823
- })
1824
- }) : null,
1825
- /* @__PURE__ */ C(h, {
1826
- modalType: "standard",
1827
- onClose: () => {
1828
- H(null), W(null);
1829
- },
1830
- open: !!(V && U),
1831
- showModalHeader: !0,
1832
- size: "wide",
1833
- supportingText: V?.filename ?? void 0,
1834
- title: "PDF 預覽",
1835
- children: U ? /* @__PURE__ */ C(Ge, {
1836
- filename: V?.filename ?? "PDF 預覽",
1837
- fileUrl: U,
1838
- onDownload: V ? () => void ut(V) : void 0
1839
- }) : null
1840
- }),
1841
- /* @__PURE__ */ C(h, {
1842
- cancelText: "保留案件",
1843
- confirmButtonProps: { variant: "destructive-primary" },
1844
- confirmText: "確認取消",
1845
- loading: Ve,
1846
- modalStatusType: "error",
1847
- modalType: "standard",
1848
- onCancel: () => F(!1),
1849
- onClose: () => F(!1),
1850
- onConfirm: () => void ft(),
1851
- open: Ue,
1852
- showModalFooter: !0,
1853
- showModalHeader: !0,
1854
- supportingText: "取消後會關閉目前待簽任務與候選簽核人。",
1855
- title: "取消案件",
1856
- children: /* @__PURE__ */ w("div", {
1857
- style: ln,
1858
- children: [/* @__PURE__ */ w(x, {
1859
- variant: "body",
1860
- children: [
1861
- "確定要取消「",
1862
- T?.title ?? "",
1863
- "」嗎?"
1864
- ]
1865
- }), /* @__PURE__ */ C(n, {
1866
- label: "取消原因",
1867
- name: "cancelComment",
1868
- children: /* @__PURE__ */ C(y, {
1869
- onChange: (e) => He(e.target.value),
1870
- placeholder: "可填寫取消原因",
1871
- resize: "vertical",
1872
- rows: 3,
1873
- value: P
1874
- })
1875
- })]
1876
- })
1877
- })
1878
- ] });
1879
- }
1880
- function fn(e) {
1881
- return e.data.label ? e.data.label : e.data.isDefault ? "其他情況" : e.data.condition ?? "";
1882
- }
1883
- function pn(e) {
1884
- return e.edges.map(fn).filter((e) => e.trim().length > 0);
1885
- }
1886
- function mn(e) {
1887
- return e === "startEvent" ? "開始" : e === "endEvent" ? "完成" : e === "userTask" ? "簽核節點" : e === "serviceTask" ? "知會節點" : e === "exclusiveGateway" ? "條件分流" : "平行處理";
1888
- }
1889
- function hn(e, t, n, r) {
1890
- return e.nodes.map((e) => {
1891
- let i = xt(e, t, n, r);
1892
- return {
1893
- data: {
1894
- kindLabel: mn(e.type),
1895
- label: e.data.label,
1896
- secondaryLabel: i.secondaryLabel,
1897
- statusLabel: i.statusLabel,
1898
- tone: i.tone
1899
- },
1900
- id: e.id,
1901
- position: e.position,
1902
- sourcePosition: k.Right,
1903
- targetPosition: k.Left,
1904
- type: "workflowRuntime"
1905
- };
1906
- });
1907
- }
1908
- function gn(e) {
1909
- let t = new A.graphlib.Graph();
1910
- return t.setDefaultEdgeLabel(() => ({})), t.setGraph({
1911
- nodesep: 56,
1912
- rankdir: "LR",
1913
- ranksep: 120
1914
- }), e.nodes.forEach((e) => {
1915
- t.setNode(e.id, {
1916
- height: $t,
1917
- width: Qt
1918
- });
1919
- }), e.edges.forEach((e) => {
1920
- t.setEdge(e.source, e.target);
1921
- }), A.layout(t), {
1922
- ...e,
1923
- nodes: e.nodes.map((e) => {
1924
- let n = t.node(e.id);
1925
- return n ? {
1926
- ...e,
1927
- position: {
1928
- x: n.x - Qt / 2,
1929
- y: n.y - $t / 2
1930
- }
1931
- } : e;
1932
- })
1933
- };
1934
- }
1935
- function _n(e) {
1936
- return e.edges.map((e) => {
1937
- let t = fn(e);
1938
- return {
1939
- animated: !1,
1940
- id: e.id,
1941
- label: t,
1942
- labelBgBorderRadius: 6,
1943
- labelBgPadding: [8, 4],
1944
- labelBgStyle: {
1945
- fill: e.data.isDefault ? "#f8fafc" : "#eff6ff",
1946
- stroke: e.data.isDefault ? "#64748b" : "#2563eb",
1947
- strokeWidth: 1
1948
- },
1949
- labelShowBg: !!t,
1950
- labelStyle: {
1951
- fill: e.data.isDefault ? "#475569" : "#2563eb",
1952
- fontSize: 12,
1953
- fontWeight: 600
1954
- },
1955
- source: e.source,
1956
- style: {
1957
- stroke: "#475569",
1958
- strokeWidth: 1.5
1959
- },
1960
- target: e.target,
1961
- type: e.type ?? "smoothstep"
1962
- };
1963
- });
1964
- }
1965
- function vn(e) {
1966
- return e === "current" ? {
1967
- ...nn,
1968
- border: "1px solid var(--mzn-color-primary, #0057ff)",
1969
- boxShadow: "0 0 0 3px rgba(0, 87, 255, 0.14)"
1970
- } : e === "completed" ? {
1971
- ...nn,
1972
- border: "1px solid #16a34a"
1973
- } : e === "cancelled" ? {
1974
- ...nn,
1975
- border: "1px solid #dc2626",
1976
- opacity: .72
1977
- } : e === "waiting" ? {
1978
- ...nn,
1979
- border: "1px dashed #64748b"
1980
- } : nn;
1981
- }
1982
- function yn(e) {
1983
- let t = rn;
1984
- return e === "current" ? {
1985
- ...t,
1986
- background: "#eff6ff",
1987
- color: "#2563eb"
1988
- } : e === "completed" ? {
1989
- ...t,
1990
- background: "#f0fdf4",
1991
- color: "#15803d"
1992
- } : e === "cancelled" ? {
1993
- ...t,
1994
- background: "#fef2f2",
1995
- color: "#dc2626"
1996
- } : e === "waiting" ? {
1997
- ...t,
1998
- background: "#f8fafc",
1999
- color: "#475569"
2000
- } : {
2001
- ...t,
2002
- background: "#f1f5f9",
2003
- color: "#64748b"
2004
- };
2005
- }
2006
- function bn({ data: e }) {
2007
- return /* @__PURE__ */ w("div", {
2008
- style: vn(e.tone),
2009
- children: [
2010
- /* @__PURE__ */ C(Re, {
2011
- isConnectable: !1,
2012
- position: k.Left,
2013
- style: on,
2014
- type: "target"
2015
- }),
2016
- /* @__PURE__ */ C(x, {
2017
- component: "span",
2018
- ellipsis: !0,
2019
- title: e.label,
2020
- variant: "label-primary",
2021
- children: e.label
2022
- }),
2023
- /* @__PURE__ */ C("span", {
2024
- style: yn(e.tone),
2025
- children: e.statusLabel
2026
- }),
2027
- /* @__PURE__ */ C("span", {
2028
- title: e.secondaryLabel,
2029
- style: an,
2030
- children: e.secondaryLabel || e.kindLabel
2031
- }),
2032
- /* @__PURE__ */ C(Re, {
2033
- isConnectable: !1,
2034
- position: k.Right,
2035
- style: on,
2036
- type: "source"
2037
- })
2038
- ]
2039
- });
2040
- }
2041
- //#endregion
2042
- export { At as a, Vt as i, Zt as n, Ot as o, Wt as r, dn as t };
2043
-
2044
- //# sourceMappingURL=detail-BgKgMvYx.js.map