@rytass/bpm-core-react 0.4.1 → 0.5.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.
Files changed (147) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +3 -0
  3. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +1 -0
  4. package/dist/chunks/FormBuilderView-D8DrQOXD.js +1090 -0
  5. package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +1 -0
  6. package/dist/chunks/{approval-instance-list-page-C5ZKPHdA.cjs → approval-instance-list-page-BMUKxzcz.cjs} +2 -2
  7. package/dist/chunks/{approval-instance-list-page-C5ZKPHdA.cjs.map → approval-instance-list-page-BMUKxzcz.cjs.map} +1 -1
  8. package/dist/chunks/{approval-instance-list-page-BF2r5D2-.js → approval-instance-list-page-YZcGGDD8.js} +2 -2
  9. package/dist/chunks/{approval-instance-list-page-BF2r5D2-.js.map → approval-instance-list-page-YZcGGDD8.js.map} +1 -1
  10. package/dist/chunks/compose-PMrmi-LE.js +451 -0
  11. package/dist/chunks/compose-PMrmi-LE.js.map +1 -0
  12. package/dist/chunks/compose-ziVbRYdo.cjs +2 -0
  13. package/dist/chunks/compose-ziVbRYdo.cjs.map +1 -0
  14. package/dist/chunks/{dashboard-page-Ib8srCMy.js → dashboard-page-DJ9vOPga.js} +2 -2
  15. package/dist/chunks/{dashboard-page-Ib8srCMy.js.map → dashboard-page-DJ9vOPga.js.map} +1 -1
  16. package/dist/chunks/{dashboard-page-CddG1MnK.cjs → dashboard-page-DwHQY6Ki.cjs} +2 -2
  17. package/dist/chunks/{dashboard-page-CddG1MnK.cjs.map → dashboard-page-DwHQY6Ki.cjs.map} +1 -1
  18. package/dist/chunks/designer-DCn6_v4b.cjs +65 -0
  19. package/dist/chunks/designer-DCn6_v4b.cjs.map +1 -0
  20. package/dist/chunks/designer-mOMxJ0Py.js +2576 -0
  21. package/dist/chunks/designer-mOMxJ0Py.js.map +1 -0
  22. package/dist/chunks/detail-Bml-vXHX.js +1622 -0
  23. package/dist/chunks/detail-Bml-vXHX.js.map +1 -0
  24. package/dist/chunks/detail-CWeCrmtC.cjs +2 -0
  25. package/dist/chunks/detail-CWeCrmtC.cjs.map +1 -0
  26. package/dist/chunks/{routes-config-dxahImVe.js → routes-config-RBYQtUd0.js} +2 -3
  27. package/dist/chunks/routes-config-RBYQtUd0.js.map +1 -0
  28. package/dist/chunks/routes-config-fDVHmvXi.cjs +2 -0
  29. package/dist/chunks/routes-config-fDVHmvXi.cjs.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +268 -128
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/routes-config.d.ts +6 -4
  35. package/dist/next/index.cjs +1 -1
  36. package/dist/next/index.js +1 -1
  37. package/dist/next/workflow-chat-route.cjs +19 -0
  38. package/dist/next/workflow-chat-route.cjs.map +1 -0
  39. package/dist/next/workflow-chat-route.d.ts +17 -0
  40. package/dist/next/workflow-chat-route.js +31 -0
  41. package/dist/next/workflow-chat-route.js.map +1 -0
  42. package/dist/pages/instances/detail/index.cjs +1 -1
  43. package/dist/pages/instances/detail/index.js +1 -1
  44. package/dist/pages/templates/compose/index.cjs +2 -0
  45. package/dist/pages/templates/compose/index.cjs.map +1 -0
  46. package/dist/pages/templates/compose/index.d.ts +13 -0
  47. package/dist/pages/templates/compose/index.js +14 -0
  48. package/dist/pages/templates/compose/index.js.map +1 -0
  49. package/dist/pages/templates/designer/index.cjs +1 -1
  50. package/dist/pages/templates/designer/index.cjs.map +1 -1
  51. package/dist/pages/templates/designer/index.js +7 -2
  52. package/dist/pages/templates/designer/index.js.map +1 -1
  53. package/dist/pages/templates/index.cjs +1 -1
  54. package/dist/pages/templates/index.cjs.map +1 -1
  55. package/dist/pages/templates/index.js +3 -3
  56. package/dist/pages/templates/index.js.map +1 -1
  57. package/dist/views/cc/index.cjs +1 -1
  58. package/dist/views/cc/index.js +1 -1
  59. package/dist/views/dashboard/index.cjs +1 -1
  60. package/dist/views/dashboard/index.js +1 -1
  61. package/dist/views/forms/builder/FormBuilderView.d.ts +13 -4
  62. package/dist/views/forms/builder/index.cjs +1 -1
  63. package/dist/views/forms/builder/index.js +1 -1
  64. package/dist/views/forms/builder/json-code-editor.d.ts +1 -1
  65. package/dist/views/inbox/index.cjs +1 -1
  66. package/dist/views/inbox/index.js +1 -1
  67. package/dist/views/instances/detail/InstanceDetailView.d.ts +11 -1
  68. package/dist/views/instances/detail/index.cjs +1 -1
  69. package/dist/views/instances/detail/index.d.ts +5 -0
  70. package/dist/views/instances/detail/index.js +2 -2
  71. package/dist/views/instances/detail/sections/InstanceAttachmentsSection.d.ts +15 -0
  72. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +33 -0
  73. package/dist/views/instances/detail/sections/InstanceHistorySection.d.ts +29 -0
  74. package/dist/views/instances/detail/sections/InstanceSignaturesSection.d.ts +14 -0
  75. package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +44 -0
  76. package/dist/views/instances/detail/sections/container-helpers.d.ts +8 -0
  77. package/dist/views/instances/detail/sections/shared.d.ts +103 -0
  78. package/dist/views/instances/new/index.cjs +1 -1
  79. package/dist/views/instances/new/index.js +1 -1
  80. package/dist/views/search/index.cjs +1 -1
  81. package/dist/views/search/index.js +1 -1
  82. package/dist/views/sent/index.cjs +1 -1
  83. package/dist/views/sent/index.js +1 -1
  84. package/dist/views/templates/TemplatesView.d.ts +5 -0
  85. package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +8 -0
  86. package/dist/views/templates/compose/index.cjs +1 -0
  87. package/dist/views/templates/compose/index.d.ts +2 -0
  88. package/dist/views/templates/compose/index.js +2 -0
  89. package/dist/views/templates/compose/steps/ComposeFormStep.d.ts +15 -0
  90. package/dist/views/templates/compose/steps/ComposeReviewStep.d.ts +12 -0
  91. package/dist/views/templates/compose/steps/ComposeWorkflowStep.d.ts +11 -0
  92. package/dist/views/templates/compose/use-template-compose-wizard.d.ts +46 -0
  93. package/dist/views/templates/designer/TemplateDesignerView.d.ts +60 -2
  94. package/dist/views/templates/designer/chrome-workflow-chat.d.ts +12 -0
  95. package/dist/views/templates/designer/index.cjs +1 -51
  96. package/dist/views/templates/designer/index.js +2 -2272
  97. package/dist/views/templates/designer/use-workflow-chat.d.ts +21 -0
  98. package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +41 -0
  99. package/dist/views/templates/designer/workflow-chat-drawer.d.ts +16 -0
  100. package/dist/views/templates/index.cjs +2 -1
  101. package/dist/views/templates/index.cjs.map +1 -0
  102. package/dist/views/templates/index.js +265 -4
  103. package/dist/views/templates/index.js.map +1 -0
  104. package/dist/views/templates/versions/index.cjs +1 -1
  105. package/dist/views/templates/versions/index.cjs.map +1 -1
  106. package/dist/views/templates/versions/index.js +38 -42
  107. package/dist/views/templates/versions/index.js.map +1 -1
  108. package/package.json +22 -19
  109. package/dist/chunks/builder-BLVnnpnP.js +0 -1300
  110. package/dist/chunks/builder-BLVnnpnP.js.map +0 -1
  111. package/dist/chunks/builder-DVE9zIKH.cjs +0 -3
  112. package/dist/chunks/builder-DVE9zIKH.cjs.map +0 -1
  113. package/dist/chunks/detail-Dcr5mM8g.cjs +0 -2
  114. package/dist/chunks/detail-Dcr5mM8g.cjs.map +0 -1
  115. package/dist/chunks/detail-u9DdLhDW.js +0 -1518
  116. package/dist/chunks/detail-u9DdLhDW.js.map +0 -1
  117. package/dist/chunks/form-name-modal-C3OEvkCV.js +0 -64
  118. package/dist/chunks/form-name-modal-C3OEvkCV.js.map +0 -1
  119. package/dist/chunks/form-name-modal-uZCHbtRH.cjs +0 -2
  120. package/dist/chunks/form-name-modal-uZCHbtRH.cjs.map +0 -1
  121. package/dist/chunks/routes-config-2aKbWq2H.cjs +0 -2
  122. package/dist/chunks/routes-config-2aKbWq2H.cjs.map +0 -1
  123. package/dist/chunks/routes-config-dxahImVe.js.map +0 -1
  124. package/dist/chunks/templates-D44FSB46.js +0 -380
  125. package/dist/chunks/templates-D44FSB46.js.map +0 -1
  126. package/dist/chunks/templates-w96t83N-.cjs +0 -2
  127. package/dist/chunks/templates-w96t83N-.cjs.map +0 -1
  128. package/dist/pages/forms/builder/index.cjs +0 -2
  129. package/dist/pages/forms/builder/index.cjs.map +0 -1
  130. package/dist/pages/forms/builder/index.d.ts +0 -21
  131. package/dist/pages/forms/builder/index.js +0 -15
  132. package/dist/pages/forms/builder/index.js.map +0 -1
  133. package/dist/pages/forms/index.cjs +0 -2
  134. package/dist/pages/forms/index.cjs.map +0 -1
  135. package/dist/pages/forms/index.d.ts +0 -17
  136. package/dist/pages/forms/index.js +0 -14
  137. package/dist/pages/forms/index.js.map +0 -1
  138. package/dist/views/forms/FormsView.d.ts +0 -2
  139. package/dist/views/forms/form-name-modal.d.ts +0 -12
  140. package/dist/views/forms/index.cjs +0 -2
  141. package/dist/views/forms/index.cjs.map +0 -1
  142. package/dist/views/forms/index.d.ts +0 -2
  143. package/dist/views/forms/index.js +0 -186
  144. package/dist/views/forms/index.js.map +0 -1
  145. package/dist/views/templates/designer/index.cjs.map +0 -1
  146. package/dist/views/templates/designer/index.js.map +0 -1
  147. package/dist/views/templates/template-name-modal.d.ts +0 -22
@@ -1,2272 +1,2 @@
1
- "use client";
2
- import { r as e } from "../../../chunks/router-adapter-DftlFTOd.js";
3
- import { r as t } from "../../../chunks/routes-config-dxahImVe.js";
4
- import { a as n, n as r, o as i, r as a } from "../../../chunks/admin-pickers-DLlG_1du.js";
5
- import { t as o } from "../../../chunks/bpm-form-field-Cao0rMol.js";
6
- import { useCallback as s, useEffect as c, useMemo as l, useRef as ee, useState as u } from "react";
7
- import { AutoComplete as te, Button as d, Icon as ne, Input as re, Modal as ie, PageHeader as ae, Section as oe, SectionGroup as se, Select as f, Textarea as ce, Toggle as le, Typography as p } from "@mezzanine-ui/react";
8
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
9
- import ue from "@mezzanine-ui/react/ContentHeader";
10
- import { CheckedIcon as de, DotGridIcon as fe, EyeIcon as pe, FilterIcon as me, MailIcon as he, SaveIcon as ge, TrashIcon as _e, UserIcon as ve } from "@mezzanine-ui/icons";
11
- import { readOrganizationDashboard as ye } from "@rytass/bpm-core-client/organization";
12
- import { Background as be, ConnectionMode as xe, ControlButton as Se, Controls as Ce, Handle as _, MiniMap as we, Panel as v, Position as y, ReactFlow as Te, applyNodeChanges as Ee, getViewportForBounds as De } from "@xyflow/react";
13
- import * as Oe from "dagre";
14
- import { dryRunApprovalWorkflow as ke, forkApprovalTemplate as Ae, publishApprovalTemplateVersion as je, readTemplateDesigner as Me, resolveMemberOptions as Ne, searchMemberOptions as Pe, searchPublishedFormVersionOptions as Fe, updateApprovalTemplateDraft as Ie } from "@rytass/bpm-core-client/template";
15
- //#region src/views/templates/designer/TemplateDesignerView.tsx
16
- var Le = {
17
- display: "grid",
18
- gap: 16
19
- }, Re = {
20
- alignItems: "start",
21
- display: "grid",
22
- gap: 16,
23
- gridTemplateColumns: "minmax(0, 1fr) 420px"
24
- }, ze = {
25
- border: "1px solid var(--mzn-color-border-neutral)",
26
- borderRadius: 6,
27
- height: 620,
28
- minWidth: 0,
29
- overflow: "hidden"
30
- }, Be = {
31
- alignItems: "center",
32
- boxSizing: "border-box",
33
- color: "var(--mzn-color-text-error)",
34
- display: "flex",
35
- height: 26,
36
- justifyContent: "center",
37
- lineHeight: 0,
38
- padding: 0,
39
- width: 26
40
- }, Ve = {
41
- alignItems: "center",
42
- display: "flex",
43
- height: "100%",
44
- justifyContent: "center",
45
- width: "100%"
46
- }, He = "workflow-designer-side-panel", b = 96, Ue = `
47
- .${He} .mzn-form-field--stretch .mzn-form-field__label-area,
48
- .${He} .mzn-form-field--horizontal .mzn-form-field__label-area {
49
- flex: 0 0 ${b}px;
50
- width: ${b}px;
51
- }
52
-
53
- .${He} .mzn-form-field--stretch .mzn-form-field__data-entry,
54
- .${He} .mzn-form-field--horizontal .mzn-form-field__data-entry {
55
- min-width: 0;
56
- }
57
- `, We = "#2563eb", x = "#64748b", Ge = "var(--mzn-color-text-error, #dc2626)", Ke = "drop-shadow(0 0 3px rgba(0, 87, 255, 0.85)) drop-shadow(0 0 9px rgba(0, 87, 255, 0.36))", qe = `
58
- .workflow-selection-delete-control.react-flow__controls-button {
59
- align-items: center !important;
60
- display: flex !important;
61
- height: 26px !important;
62
- justify-content: center !important;
63
- padding: 0 !important;
64
- width: 26px !important;
65
- }
66
-
67
- .workflow-selection-delete-control .mzn-icon {
68
- align-items: center;
69
- display: flex;
70
- justify-content: center;
71
- }
72
-
73
- .workflow-selection-delete-control .mzn-icon svg {
74
- height: 16px !important;
75
- max-height: none !important;
76
- max-width: none !important;
77
- width: 16px !important;
78
- }
79
-
80
- .workflow-edge--selected .react-flow__edge-path,
81
- .react-flow__edge-path.workflow-edge--selected {
82
- filter: ${Ke};
83
- opacity: 1 !important;
84
- stroke: ${x} !important;
85
- stroke-opacity: 1 !important;
86
- stroke-width: 1.5px !important;
87
- }
88
-
89
- .workflow-edge--selected {
90
- --xy-edge-stroke: ${x};
91
- --xy-edge-stroke-selected: ${x};
92
- --xy-edge-stroke-width: 1.5px;
93
- }
94
-
95
- `, Je = {
96
- display: "grid",
97
- gap: 12
98
- }, S = {
99
- display: "grid",
100
- gap: 12
101
- }, Ye = {
102
- border: "1px solid var(--mzn-color-border-neutral)",
103
- borderRadius: 6,
104
- display: "grid",
105
- gap: 8,
106
- maxHeight: 360,
107
- overflow: "auto",
108
- padding: 12
109
- }, Xe = {
110
- borderBottom: "1px solid var(--mzn-color-border-neutral)",
111
- display: "grid",
112
- gap: 4,
113
- padding: "0 0 8px"
114
- }, Ze = {
115
- display: "flex",
116
- flexWrap: "wrap",
117
- gap: 8
118
- }, Qe = {
119
- display: "grid",
120
- gap: 8
121
- }, C = {
122
- alignContent: "center",
123
- background: "var(--mzn-color-bg-surface)",
124
- border: "1px solid var(--mzn-color-border-neutral)",
125
- borderRadius: 6,
126
- boxShadow: "0 8px 20px rgba(15, 23, 42, 0.08)",
127
- boxSizing: "border-box",
128
- display: "grid",
129
- gap: 4,
130
- height: "100%",
131
- minWidth: 132,
132
- overflow: "visible",
133
- padding: "10px 12px",
134
- textAlign: "center",
135
- width: "100%"
136
- }, $e = "0 8px 20px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--mzn-color-primary, #0057ff), 0 0 10px rgba(0, 87, 255, 0.3)", et = 64, w = 160, T = 20, E = 64, D = 180, O = {
137
- ...C,
138
- display: "grid",
139
- gap: 8,
140
- padding: "10px 12px"
141
- }, tt = {
142
- ...O,
143
- background: "#eff6ff",
144
- border: "1px solid #2563eb"
145
- }, k = {
146
- ...O,
147
- background: "#f0fdfa",
148
- border: "1px solid #0f766e"
149
- }, nt = {
150
- ...C,
151
- background: "#ffffff"
152
- }, A = {
153
- ...C,
154
- background: "#ecfdf3",
155
- border: "1px solid #2f855a"
156
- }, rt = {
157
- ...C,
158
- background: "#fff4ed",
159
- border: "1px solid #c2410c"
160
- }, it = {
161
- display: "block",
162
- maxWidth: "100%",
163
- minWidth: 0
164
- }, at = {
165
- display: "grid",
166
- gap: 2,
167
- minWidth: 0
168
- }, j = "input", ot = "output", st = {
169
- endEvent: "結束",
170
- exclusiveGateway: "條件分流",
171
- parallelGateway: "並行處理",
172
- serviceTask: "系統",
173
- startEvent: "開始",
174
- userTask: "簽核"
175
- }, ct = [{
176
- icon: ve,
177
- label: "簽核節點",
178
- type: "userTask"
179
- }, {
180
- icon: he,
181
- label: "知會節點",
182
- type: "serviceTask"
183
- }], lt = [{
184
- icon: me,
185
- label: "條件分流",
186
- type: "exclusiveGateway"
187
- }], ut = [{
188
- id: "AND",
189
- name: "全部前置完成"
190
- }, {
191
- id: "OR",
192
- name: "任一前置完成"
193
- }], dt = [{
194
- id: "RESTART",
195
- name: "重新送出後從開始重跑"
196
- }, {
197
- id: "FROM_RETURN_POINT",
198
- name: "重新送出後回到退回節點"
199
- }], ft = [
200
- {
201
- id: "DIRECT",
202
- name: "指定會員"
203
- },
204
- {
205
- id: "ORG_MANAGER",
206
- name: "發起人主管"
207
- },
208
- {
209
- id: "ORG_UNIT_MANAGER",
210
- name: "指定組織主管"
211
- },
212
- {
213
- id: "ORG_UNIT_MEMBER",
214
- name: "組織任一人"
215
- },
216
- {
217
- id: "ORG_UNIT_POSITION",
218
- name: "組織特定職位"
219
- },
220
- {
221
- id: "POSITION",
222
- name: "指定職位"
223
- }
224
- ], M = [
225
- {
226
- id: "1",
227
- name: "直屬主管",
228
- value: 1
229
- },
230
- {
231
- id: "2",
232
- name: "第二層主管",
233
- value: 2
234
- },
235
- {
236
- id: "3",
237
- name: "第三層主管",
238
- value: 3
239
- }
240
- ], pt = [{
241
- id: "NONE",
242
- name: "停止流程並提示"
243
- }, {
244
- id: "DIRECT",
245
- name: "固定改派"
246
- }], mt = [
247
- {
248
- id: "EQUALS",
249
- name: "等於"
250
- },
251
- {
252
- id: "NOT_EQUALS",
253
- name: "不等於"
254
- },
255
- {
256
- id: "GREATER_THAN",
257
- name: "大於"
258
- },
259
- {
260
- id: "GREATER_THAN_OR_EQUALS",
261
- name: "大於等於"
262
- },
263
- {
264
- id: "LESS_THAN",
265
- name: "小於"
266
- },
267
- {
268
- id: "LESS_THAN_OR_EQUALS",
269
- name: "小於等於"
270
- },
271
- {
272
- id: "IS_FILLED",
273
- name: "已填寫"
274
- },
275
- {
276
- id: "IS_EMPTY",
277
- name: "未填寫"
278
- }
279
- ], ht = [
280
- "EQUALS",
281
- "GREATER_THAN",
282
- "GREATER_THAN_OR_EQUALS",
283
- "LESS_THAN",
284
- "LESS_THAN_OR_EQUALS",
285
- "NOT_EQUALS"
286
- ], gt = [
287
- {
288
- id: "NONE",
289
- name: "未設定"
290
- },
291
- {
292
- id: "ALL",
293
- name: "所有人"
294
- },
295
- {
296
- id: "ORG_UNIT",
297
- name: "指定組織"
298
- },
299
- {
300
- id: "ORG_UNIT_POSITION",
301
- name: "指定組織職位"
302
- }
303
- ], _t = {
304
- id: "CUSTOM",
305
- name: "既有自訂規則"
306
- }, vt = "member-001", yt = {
307
- endEvent: N,
308
- exclusiveGateway: N,
309
- parallelGateway: N,
310
- serviceTask: N,
311
- startEvent: N,
312
- userTask: N
313
- };
314
- function bt({ templateId: n }) {
315
- let i = e(), fe = t(), [me, he] = u(null), [ve, _] = u(null), [v, y] = u(zt()), [De, Oe] = u(""), [b, We] = u(null), [x, Ke] = u(null), [C, $e] = u(null), [et, w] = u(null), [T, E] = u("start"), [D, O] = u([]), [tt, k] = u(null), [nt, A] = u(null), [rt, it] = u(!0), [at, j] = u(!1), [ot, mt] = u(!1), [ht, bt] = u([]), N = l(() => JSON.stringify({
316
- formDefinitionVersionId: b,
317
- initiatorPolicyCel: x,
318
- workflowDefinition: v
319
- }), [
320
- b,
321
- x,
322
- v
323
- ]), St = !!De && N !== De, [Ct, wt] = u(!1), [P, F] = u([]), [I, Et] = u([]), [L, jt] = u([]), [Mt, It] = u([]), [Lt, Rt] = u(!1), [Zt, en] = u(!1), [nn, B] = u("{}"), [V, cn] = u(null), [fn, mn] = u(null), [H, U] = u(void 0), Tn = ee(null);
324
- c(() => {
325
- Qn();
326
- }, [n]), c(() => {
327
- function e(e) {
328
- St && (e.preventDefault(), e.returnValue = "");
329
- }
330
- return window.addEventListener("beforeunload", e), () => {
331
- window.removeEventListener("beforeunload", e);
332
- };
333
- }, [St]), c(() => {
334
- nr(v);
335
- }, [v, P]), c(() => {
336
- y((e) => At(e));
337
- }, [v.edges, v.nodes]);
338
- function En() {
339
- St && !window.confirm("目前有尚未儲存的流程草稿,確定要離開嗎?") || i.push(fe.templates());
340
- }
341
- let W = l(() => v.nodes.find((e) => e.id === T) ?? null, [T, v.nodes]), Dn = W ? sn(W) : !1, kn = D.length > 0 || Dn, Mn = s(() => {
342
- let e = W && sn(W) ? W.id : null;
343
- y((t) => ({
344
- ...t,
345
- edges: t.edges.filter((t) => !D.includes(t.id) && t.source !== e && t.target !== e),
346
- nodes: e ? t.nodes.filter((t) => t.id !== e) : t.nodes
347
- })), O([]), k(null), e && E("start");
348
- }, [D, W]);
349
- c(() => {
350
- if (!kn) return;
351
- function e(e) {
352
- e.key !== "Delete" && e.key !== "Backspace" || ln(e.target) || (e.preventDefault(), Mn());
353
- }
354
- return window.addEventListener("keydown", e), () => {
355
- window.removeEventListener("keydown", e);
356
- };
357
- }, [kn, Mn]);
358
- let Nn = l(() => v.edges.find((e) => e.id === tt) ?? null, [tt, v.edges]), Pn = l(() => D.length === 1 ? v.edges.find((e) => e.id === D[0]) ?? null : null, [D, v.edges]), Fn = l(() => D.map((e) => v.edges.find((t) => t.id === e) ?? null).filter((e) => !!e), [D, v.edges]), G = l(() => et ?? Qt(x, C), [
359
- x,
360
- et,
361
- C
362
- ]), Rn = l(() => v.nodes.map((e) => Tt(e, P, I, L, e.id === T, G)), [
363
- G,
364
- P,
365
- I,
366
- L,
367
- T,
368
- v.nodes
369
- ]), Wn = l(() => v.edges.map((e) => Dt(e, v.nodes, D.includes(e.id))), [
370
- D,
371
- v.edges,
372
- v.nodes
373
- ]), K = l(() => z(ht, b) ?? z(un(me?.formVersions ?? []), b), [
374
- b,
375
- ht,
376
- me?.formVersions
377
- ]), Xn = l(() => _n(ht, K), [ht, K]), q = l(() => Ln(v), [v]), J = l(() => zn(v), [v]), Y = l(() => $t(G), [G]);
378
- async function Qn() {
379
- it(!0), A(null);
380
- try {
381
- let [e, t] = await Promise.all([Me(n), ye()]), r = e.versions.find((e) => e.status === "DRAFT") ?? null, i = r ?? e.versions[0] ?? null;
382
- he(e), _(r), Et(t.orgUnits), jt(t.positions), It(t.memberships), bt(un(e.formVersions));
383
- let a = i?.workflowDefinition ?? zt(), o = i?.formDefinitionVersionId ?? e.formVersions[0]?.id ?? null, s = i?.initiatorPolicyCel ?? null;
384
- y(a), We(o), Ke(s), Oe(JSON.stringify({
385
- formDefinitionVersionId: o,
386
- initiatorPolicyCel: s,
387
- workflowDefinition: a
388
- })), $e(i && !e.template.currentVersionId && !i.initiatorPolicyCel && Bt(i.workflowDefinition) ? "NONE" : null), w(null), E(i?.workflowDefinition.nodes[0]?.id ?? "start"), O([]), k(null);
389
- } catch (e) {
390
- A(Q(e));
391
- } finally {
392
- it(!1);
393
- }
394
- }
395
- async function er(e) {
396
- mt(!0), A(null);
397
- try {
398
- bt(_n(un(await Fe(e)), K));
399
- } catch (e) {
400
- A(Q(e));
401
- } finally {
402
- mt(!1);
403
- }
404
- }
405
- async function Z(e) {
406
- wt(!0), A(null);
407
- try {
408
- let t = await Pe(e);
409
- F((e) => An(e, vn(t)));
410
- } catch (e) {
411
- A(Q(e));
412
- } finally {
413
- wt(!1);
414
- }
415
- }
416
- async function nr(e) {
417
- let t = jn(e).filter((e) => !P.some((t) => t.memberId === e));
418
- if (t.length !== 0) try {
419
- let e = await Ne(t);
420
- F((t) => An(t, vn(e)));
421
- } catch {
422
- F((e) => An(e, t.map(yn)));
423
- }
424
- }
425
- async function rr() {
426
- j(!0), A(null);
427
- try {
428
- let e = Ln(v), t = $t(G);
429
- if (e || t) {
430
- let n = e ?? t ?? "流程設定未完成";
431
- throw A(n), Error(n);
432
- }
433
- let r = await Ie({
434
- formDefinitionVersionId: b,
435
- initiatorPolicyCel: x,
436
- versionId: (ve ?? await Ae(n)).id,
437
- workflowDefinition: v
438
- });
439
- return _(r), await Qn(), r;
440
- } catch (e) {
441
- throw A(Q(e)), e;
442
- } finally {
443
- j(!1);
444
- }
445
- }
446
- async function ir() {
447
- j(!0), A(null);
448
- try {
449
- await je((await rr()).id), await Qn();
450
- } catch (e) {
451
- A(Q(e));
452
- } finally {
453
- j(!1);
454
- }
455
- }
456
- function ar() {
457
- B(JSON.stringify(dn(K), null, 2)), cn(null), mn(null), Rt(!0);
458
- }
459
- function or() {
460
- Zt || Rt(!1);
461
- }
462
- async function sr() {
463
- en(!0), mn(null), cn(null);
464
- try {
465
- cn(await ke({
466
- formData: pn(nn),
467
- initiatorMemberId: vt,
468
- initiatorMetadataSnapshot: wn(vt, Mt),
469
- workflowDefinition: v
470
- }));
471
- } catch (e) {
472
- mn(Q(e));
473
- } finally {
474
- en(!1);
475
- }
476
- }
477
- function cr(e) {
478
- let t = Ee(e, Rn);
479
- y((e) => ({
480
- ...e,
481
- nodes: e.nodes.map((e) => {
482
- let n = t.find((t) => t.id === e.id);
483
- return n ? {
484
- ...e,
485
- position: n.position
486
- } : e;
487
- })
488
- }));
489
- }
490
- function lr(e) {
491
- if (!an(e, v.nodes)) return;
492
- let t = v.nodes.some((t) => t.id === e.source && t.type === "exclusiveGateway"), n = R(e.source, e.target, {});
493
- y((e) => ({
494
- ...e,
495
- edges: [...e.edges, n]
496
- })), E(null), O([n.id]), k(t ? n.id : null);
497
- }
498
- function ur(e, t) {
499
- e.stopPropagation(), O((n) => e.shiftKey || e.metaKey || e.ctrlKey ? on(n, t.id) : [t.id]), E(null);
500
- }
501
- function dr() {
502
- k(null);
503
- }
504
- function fr(e) {
505
- let t = Ft({
506
- definition: v,
507
- node: Nt(e, Pt(v.nodes, e)),
508
- selectedEdgeId: D.length === 1 ? D[0] : null,
509
- selectedNodeId: T
510
- }), n = Vt(t.definition), r = In(n, Tn.current);
511
- y(n), E(t.selectedNodeId), O(t.selectedEdgeIds), k(t.editingEdgeId), r && U(r);
512
- }
513
- function pr(e) {
514
- W && vr(W.id, (t) => Ot(t, e));
515
- }
516
- function $(e) {
517
- !W || W.type !== "userTask" || vr(W.id, (t) => t.type === "userTask" ? {
518
- ...t,
519
- data: {
520
- ...t.data,
521
- approverResolver: e,
522
- decisionPolicy: { type: "SINGLE" }
523
- }
524
- } : t);
525
- }
526
- function mr(e) {
527
- !W || W.type !== "userTask" || vr(W.id, (t) => t.type === "userTask" ? {
528
- ...t,
529
- data: {
530
- ...t.data,
531
- returnBehavior: {
532
- ...t.data.returnBehavior,
533
- resubmitStrategy: e
534
- }
535
- }
536
- } : t);
537
- }
538
- function hr(e) {
539
- !W || W.type !== "serviceTask" || vr(W.id, (t) => t.type === "serviceTask" ? {
540
- ...t,
541
- data: {
542
- ...t.data,
543
- action: e
544
- }
545
- } : t);
546
- }
547
- function gr(e) {
548
- w(e.mode === "ALL" || e.mode === "CUSTOM" ? null : e), $e(e.mode === "ALL" || e.mode === "CUSTOM" ? null : e.mode), Ke(tn(e, I));
549
- }
550
- function _r(e) {
551
- !W || W.type === "startEvent" || vr(W.id, (t) => kt(t, e));
552
- }
553
- function vr(e, t) {
554
- y((n) => ({
555
- ...n,
556
- nodes: n.nodes.map((n) => n.id === e ? t(n) : n)
557
- }));
558
- }
559
- function yr(e, t) {
560
- y((n) => ({
561
- ...n,
562
- edges: n.edges.map((n) => n.id === e ? t(n) : n)
563
- }));
564
- }
565
- function br(e, t) {
566
- y((n) => {
567
- let r = n.edges.find((t) => t.id === e);
568
- return r ? {
569
- ...n,
570
- edges: n.edges.map((e) => t && e.source === r.source && e.id !== r.id && X(e, n.nodes) ? {
571
- ...e,
572
- data: {
573
- ...e.data,
574
- isDefault: !1
575
- }
576
- } : e.id === r.id ? {
577
- ...e,
578
- data: {
579
- ...e.data,
580
- isDefault: t
581
- }
582
- } : e)
583
- } : n;
584
- });
585
- }
586
- function xr({ edgeId: e, fieldKey: t, operator: n, value: r }) {
587
- let i = K?.schema ?? null;
588
- yr(e, (e) => {
589
- let a = Vn(i, t ?? e.data.conditionFieldKey ?? null), o = Kn(a, n ?? e.data.conditionOperator ?? null), s = qn(a, o, r ?? e.data.conditionValue ?? null), c = Yn(a, o, s);
590
- return {
591
- ...e,
592
- data: {
593
- ...e.data,
594
- condition: Zn(a, o, s),
595
- conditionFieldKey: a?.fieldKey,
596
- conditionOperator: o,
597
- conditionValue: s,
598
- isDefault: !1,
599
- label: c
600
- }
601
- };
602
- });
603
- }
604
- function Sr() {
605
- let e = Vt(v), t = In(e, Tn.current);
606
- y(e), t && U(t);
607
- }
608
- return /* @__PURE__ */ g(m, { children: [
609
- /* @__PURE__ */ h("style", { children: Ue }),
610
- /* @__PURE__ */ h(ae, { children: /* @__PURE__ */ g(ue, {
611
- description: `${ve ? `草稿 v${ve.version}` : "尚未建立草稿"} ·${me?.template.currentVersionId ? " 已發布版本" : " 尚未發布"}`,
612
- onBackClick: En,
613
- title: me?.template.name ?? "流程設計器",
614
- children: [
615
- /* @__PURE__ */ h(d, {
616
- "aria-label": "儲存草稿",
617
- disabled: at || !!q || !!Y,
618
- icon: ge,
619
- iconType: "icon-only",
620
- onClick: () => void rr(),
621
- variant: "base-secondary",
622
- children: "儲存草稿"
623
- }),
624
- /* @__PURE__ */ h(d, {
625
- disabled: rt || !!q || !!Y,
626
- icon: pe,
627
- iconType: "leading",
628
- onClick: ar,
629
- variant: "base-secondary",
630
- children: "試跑流程"
631
- }),
632
- /* @__PURE__ */ h(d, {
633
- disabled: at || !ve || !!q || !!Y,
634
- icon: de,
635
- iconType: "leading",
636
- onClick: () => void ir(),
637
- variant: "base-primary",
638
- children: "發布版本"
639
- })
640
- ]
641
- }) }),
642
- /* @__PURE__ */ h(se, { children: /* @__PURE__ */ h(oe, { children: /* @__PURE__ */ g("div", {
643
- style: Le,
644
- children: [
645
- nt ? /* @__PURE__ */ h(p, {
646
- color: "text-error",
647
- variant: "body",
648
- children: nt
649
- }) : null,
650
- q ? /* @__PURE__ */ h(p, {
651
- color: "text-error",
652
- variant: "body",
653
- children: q
654
- }) : null,
655
- Y ? /* @__PURE__ */ h(p, {
656
- color: "text-error",
657
- variant: "body",
658
- children: Y
659
- }) : null,
660
- /* @__PURE__ */ h("div", {
661
- style: S,
662
- children: /* @__PURE__ */ h(o, {
663
- hintText: J ? "已設定條件分流條件。請先移除所有條件,才能更換綁定表單版本。" : void 0,
664
- label: "綁定表單版本",
665
- name: "formDefinitionVersionId",
666
- required: !0,
667
- children: /* @__PURE__ */ h(te, {
668
- asyncData: !0,
669
- disabled: rt || J,
670
- disabledOptionsFilter: !0,
671
- emptyText: "沒有符合的已發布表單版本",
672
- isForceClearable: !!b && !J,
673
- loading: ot,
674
- loadingText: "搜尋表單版本中...",
675
- mode: "single",
676
- onChange: (e) => {
677
- J || We(e?.id ?? null);
678
- },
679
- onClear: () => {
680
- J || We(null);
681
- },
682
- onSearch: er,
683
- onVisibilityChange: (e) => {
684
- e && !J && er("");
685
- },
686
- options: [...Xn],
687
- placeholder: "選擇已發布表單版本",
688
- searchDebounceTime: 300,
689
- value: K
690
- })
691
- })
692
- }),
693
- /* @__PURE__ */ g("div", {
694
- style: Re,
695
- children: [/* @__PURE__ */ h("div", {
696
- ref: Tn,
697
- style: ze,
698
- children: /* @__PURE__ */ g(Te, {
699
- connectionMode: xe.Strict,
700
- edges: Wn,
701
- fitView: !0,
702
- isValidConnection: (e) => an(e, v.nodes),
703
- nodeTypes: yt,
704
- nodes: Rn,
705
- deleteKeyCode: null,
706
- multiSelectionKeyCode: [
707
- "Shift",
708
- "Meta",
709
- "Control"
710
- ],
711
- onConnect: lr,
712
- onEdgeClick: ur,
713
- onNodeClick: (e, t) => {
714
- E(t.id), O([]);
715
- },
716
- onNodesChange: cr,
717
- onPaneClick: () => {
718
- E(null), O([]);
719
- },
720
- onViewportChange: U,
721
- viewport: H,
722
- children: [
723
- /* @__PURE__ */ h(be, {}),
724
- /* @__PURE__ */ h("style", { children: qe }),
725
- /* @__PURE__ */ h(Ce, { children: kn ? /* @__PURE__ */ h(Se, {
726
- "aria-label": "刪除選取項目",
727
- className: "workflow-selection-delete-control",
728
- onClick: Mn,
729
- style: Be,
730
- title: "刪除選取項目",
731
- children: /* @__PURE__ */ h("span", {
732
- style: Ve,
733
- children: /* @__PURE__ */ h(ne, {
734
- color: "error",
735
- icon: _e,
736
- size: 16
737
- })
738
- })
739
- }) : null }),
740
- /* @__PURE__ */ h(xt, { onApplyAutoLayout: Sr }),
741
- /* @__PURE__ */ h(we, {})
742
- ]
743
- })
744
- }), /* @__PURE__ */ g("div", {
745
- className: He,
746
- style: Je,
747
- children: [
748
- /* @__PURE__ */ h(p, {
749
- component: "h2",
750
- variant: "h3",
751
- children: "流程工具"
752
- }),
753
- /* @__PURE__ */ g("div", {
754
- style: Qe,
755
- children: [/* @__PURE__ */ h(p, {
756
- color: "text-neutral",
757
- variant: "caption",
758
- children: "動作節點"
759
- }), /* @__PURE__ */ h("div", {
760
- style: Ze,
761
- children: ct.map((e) => /* @__PURE__ */ h(d, {
762
- icon: e.icon,
763
- iconType: "leading",
764
- onClick: () => fr(e.type),
765
- size: "sub",
766
- variant: "base-secondary",
767
- children: e.label
768
- }, e.type))
769
- })]
770
- }),
771
- /* @__PURE__ */ g("div", {
772
- style: Qe,
773
- children: [/* @__PURE__ */ h(p, {
774
- color: "text-neutral",
775
- variant: "caption",
776
- children: "流程控制"
777
- }), /* @__PURE__ */ h("div", {
778
- style: Ze,
779
- children: lt.map((e) => /* @__PURE__ */ h(d, {
780
- icon: e.icon,
781
- iconType: "leading",
782
- onClick: () => fr(e.type),
783
- size: "sub",
784
- variant: "base-secondary",
785
- children: e.label
786
- }, e.type))
787
- })]
788
- }),
789
- Fn.length > 1 ? kr(Fn) : null,
790
- Fn.length === 1 && Pn ? Ar(Pn) : null,
791
- Fn.length === 0 && W ? wr(W) : null
792
- ]
793
- })]
794
- })
795
- ]
796
- }) }) }),
797
- jr(Nn),
798
- Cr()
799
- ] });
800
- function Cr() {
801
- return /* @__PURE__ */ h(ie, {
802
- cancelText: "關閉",
803
- confirmText: "執行試跑",
804
- loading: Zt,
805
- modalType: "standard",
806
- onCancel: or,
807
- onClose: or,
808
- onConfirm: () => void sr(),
809
- open: Lt,
810
- showModalFooter: !0,
811
- showModalHeader: !0,
812
- size: "wide",
813
- supportingText: `使用 ${vt} 與範例表單資料模擬目前畫布流程,不會建立案件。`,
814
- title: "試跑流程",
815
- children: /* @__PURE__ */ g("div", {
816
- style: S,
817
- children: [
818
- /* @__PURE__ */ h(o, {
819
- label: "表單資料 JSON",
820
- name: "dryRunFormDataJson",
821
- required: !0,
822
- children: /* @__PURE__ */ h(ce, {
823
- onChange: (e) => B(e.target.value),
824
- resize: "vertical",
825
- rows: 8,
826
- value: nn
827
- })
828
- }),
829
- fn ? /* @__PURE__ */ h(p, {
830
- color: "text-error",
831
- variant: "body",
832
- children: fn
833
- }) : null,
834
- V ? /* @__PURE__ */ g("div", {
835
- style: Ye,
836
- children: [
837
- /* @__PURE__ */ h(p, {
838
- color: V.valid ? "text-success" : "text-error",
839
- variant: "label-primary-highlight",
840
- children: V.valid ? "試跑通過" : "試跑失敗"
841
- }),
842
- V.errors.map((e) => /* @__PURE__ */ h(p, {
843
- color: "text-error",
844
- variant: "body",
845
- children: e
846
- }, e)),
847
- V.steps.map((e) => /* @__PURE__ */ g("div", {
848
- style: Xe,
849
- children: [
850
- /* @__PURE__ */ g(p, {
851
- variant: "label-primary-highlight",
852
- children: [
853
- e.nodeLabel,
854
- " · ",
855
- hn(e.status)
856
- ]
857
- }),
858
- /* @__PURE__ */ g(p, {
859
- color: "text-neutral",
860
- variant: "caption",
861
- children: [
862
- gn(e.nodeType),
863
- e.assigneeMemberId ? ` · 處理者:${e.assigneeMemberId}` : "",
864
- e.edgeLabel ? ` · 來源線段:${e.edgeLabel}` : ""
865
- ]
866
- }),
867
- e.edgeReason ? /* @__PURE__ */ h(p, {
868
- color: "text-neutral",
869
- variant: "caption",
870
- children: e.edgeReason
871
- }) : null,
872
- e.entryCondition ? /* @__PURE__ */ g(p, {
873
- color: "text-neutral",
874
- variant: "caption",
875
- children: [
876
- "進入條件:",
877
- e.entryConditionMatched ? "符合" : "不符合",
878
- " ·",
879
- " ",
880
- e.entryCondition
881
- ]
882
- }) : null,
883
- /* @__PURE__ */ h(p, {
884
- color: "text-neutral",
885
- variant: "body",
886
- children: e.message
887
- })
888
- ]
889
- }, e.id))
890
- ]
891
- }) : null
892
- ]
893
- })
894
- });
895
- }
896
- function wr(e) {
897
- return /* @__PURE__ */ g("div", {
898
- style: S,
899
- children: [
900
- /* @__PURE__ */ h(p, {
901
- component: "h2",
902
- variant: "h3",
903
- children: "節點屬性"
904
- }),
905
- /* @__PURE__ */ g(p, {
906
- color: "text-neutral",
907
- variant: "body",
908
- children: [
909
- st[e.type],
910
- " · ",
911
- e.id
912
- ]
913
- }),
914
- /* @__PURE__ */ h(o, {
915
- label: "顯示名稱",
916
- name: "nodeLabel",
917
- required: !0,
918
- children: /* @__PURE__ */ h(re, {
919
- onChange: (e) => pr(e.target.value),
920
- value: e.data.label,
921
- variant: "base"
922
- })
923
- }),
924
- e.type === "startEvent" ? Tr() : null,
925
- e.type === "startEvent" ? null : Er(e),
926
- e.type === "userTask" ? Dr(e) : null,
927
- e.type === "serviceTask" ? Or(e) : null
928
- ]
929
- });
930
- }
931
- function Tr() {
932
- let e = G.mode === "CUSTOM" ? [...gt, _t] : [...gt], t = G.mode === "ORG_UNIT" || G.mode === "ORG_UNIT_POSITION" ? Sn(I, G.orgUnitId ?? "") : null, n = G.mode === "ORG_UNIT_POSITION" ? Cn(L, G.positionId ?? "") : null, i = G.mode === "ORG_UNIT_POSITION" ? On({
933
- includeDescendants: !!G.includeDescendants,
934
- memberships: Mt,
935
- orgUnitId: G.orgUnitId ?? "",
936
- orgUnits: I,
937
- positions: L
938
- }) : [];
939
- return /* @__PURE__ */ g(m, { children: [
940
- /* @__PURE__ */ h(o, {
941
- hintText: G.mode === "CUSTOM" ? "這是舊版表達式規則;切換成標準選項後會改由 UI 管理。" : void 0,
942
- label: "發起權限",
943
- name: "initiatorPolicyMode",
944
- required: !0,
945
- children: /* @__PURE__ */ h(f, {
946
- clearable: !1,
947
- onChange: (e) => {
948
- if (e?.id === "CUSTOM") {
949
- $e(null), w(null);
950
- return;
951
- }
952
- let t = Xt(e?.id ?? null), n = rn(t);
953
- $e(t === "ALL" ? null : t), w(t === "ALL" ? null : n), Ke(tn(n, I));
954
- },
955
- options: e,
956
- placeholder: "選擇誰可以發起",
957
- value: z(e, G.mode)
958
- })
959
- }),
960
- G.mode === "ORG_UNIT" || G.mode === "ORG_UNIT_POSITION" ? /* @__PURE__ */ h(o, {
961
- label: "組織",
962
- name: "initiatorOrgUnitId",
963
- required: !0,
964
- children: /* @__PURE__ */ h(r, {
965
- name: "initiatorOrgUnitId",
966
- onChange: (e) => gr({
967
- ...G,
968
- orgUnitId: e?.id ?? "",
969
- positionId: "",
970
- value: e?.id ?? ""
971
- }),
972
- orgUnits: I,
973
- placeholder: "選擇組織",
974
- value: t
975
- })
976
- }) : null,
977
- G.mode === "ORG_UNIT" || G.mode === "ORG_UNIT_POSITION" ? /* @__PURE__ */ h(o, {
978
- label: "包含下層",
979
- name: "initiatorIncludeDescendants",
980
- children: /* @__PURE__ */ h(le, {
981
- checked: !!G.includeDescendants,
982
- onChange: (e) => gr({
983
- ...G,
984
- includeDescendants: e.target.checked,
985
- ...G.mode === "ORG_UNIT_POSITION" ? { positionId: "" } : {}
986
- })
987
- })
988
- }) : null,
989
- G.mode === "ORG_UNIT_POSITION" ? /* @__PURE__ */ h(o, {
990
- label: "職位",
991
- name: "initiatorPositionId",
992
- required: !0,
993
- children: /* @__PURE__ */ h(a, {
994
- disabled: !G.orgUnitId?.trim(),
995
- name: "initiatorPositionId",
996
- onChange: (e) => gr({
997
- ...G,
998
- positionId: e?.id ?? ""
999
- }),
1000
- placeholder: G.orgUnitId?.trim() ? "選擇職位" : "請先選擇組織",
1001
- positions: i,
1002
- value: n
1003
- })
1004
- }) : null
1005
- ] });
1006
- }
1007
- function Er(e) {
1008
- let t = v.edges.filter((t) => t.target === e.id).length, n = t < 2, r = n ? "AND" : e.data.triggerMode ?? "AND";
1009
- return /* @__PURE__ */ h(o, {
1010
- hintText: n ? "需要至少兩條前置連線,才可切換為任一前置完成。" : t > 1 ? `${t} 條前置連線會依此規則觸發。` : "只有一條前置連線時,兩種設定效果相同。",
1011
- label: "前置條件",
1012
- name: "triggerMode",
1013
- required: !0,
1014
- children: /* @__PURE__ */ h(f, {
1015
- clearable: !1,
1016
- onChange: (e) => n ? void 0 : _r(Ht(e?.id ?? null)),
1017
- options: [...ut],
1018
- readOnly: n,
1019
- value: z(ut, r)
1020
- })
1021
- });
1022
- }
1023
- function Dr(e) {
1024
- let t = e.data.approverResolver, n = Wt(t.type), i = t.type === "DIRECT" ? xn(t.memberIds, P) : null, s = t.type === "ORG_UNIT_MANAGER" || t.type === "ORG_UNIT_MEMBER" || t.type === "ORG_UNIT_POSITION" ? Sn(I, t.orgUnitId) : null, c = t.type === "POSITION" || t.type === "ORG_UNIT_POSITION" ? Cn(L, t.positionId) : null, l = t.type === "ORG_UNIT_POSITION" ? On({
1025
- includeDescendants: !!t.includeDescendants,
1026
- memberships: Mt,
1027
- orgUnitId: t.orgUnitId,
1028
- orgUnits: I,
1029
- positions: L
1030
- }) : [], ee = t.type === "ORG_MANAGER" ? Jt(t.levelsUp) : M[0], u = t.type === "ORG_MANAGER" || t.type === "ORG_UNIT_MANAGER" ? t.fallback ?? { type: "NONE" } : { type: "NONE" }, d = u.type === "DIRECT" ? bn(P, u.memberId) : null, ne = e.data.returnBehavior.resubmitStrategy ?? "RESTART";
1031
- return /* @__PURE__ */ g(m, { children: [
1032
- /* @__PURE__ */ h(o, {
1033
- label: "簽核來源",
1034
- name: "approverResolverType",
1035
- required: !0,
1036
- children: /* @__PURE__ */ h(f, {
1037
- clearable: !1,
1038
- onChange: (e) => $(Gt(e?.id ?? null)),
1039
- options: [...ft],
1040
- value: z(ft, n)
1041
- })
1042
- }),
1043
- t.type === "DIRECT" ? /* @__PURE__ */ h(o, {
1044
- label: "簽核者",
1045
- name: "memberId",
1046
- required: !0,
1047
- children: /* @__PURE__ */ h(te, {
1048
- asyncData: !0,
1049
- disabledOptionsFilter: !0,
1050
- emptyText: "沒有符合的成員",
1051
- inputProps: {
1052
- autoCapitalize: "none",
1053
- autoCorrect: "off",
1054
- name: "workflow-approver-search",
1055
- spellCheck: !1
1056
- },
1057
- loading: Ct,
1058
- loadingText: "搜尋成員中...",
1059
- mode: "single",
1060
- onChange: (e) => $({
1061
- memberIds: e?.id ? [e.id] : [],
1062
- type: "DIRECT"
1063
- }),
1064
- onSearch: Z,
1065
- onVisibilityChange: (e) => {
1066
- e && Z("");
1067
- },
1068
- options: [...P],
1069
- placeholder: "搜尋姓名或信箱",
1070
- searchDebounceTime: 300,
1071
- value: i
1072
- })
1073
- }) : null,
1074
- t.type === "ORG_MANAGER" ? /* @__PURE__ */ h(o, {
1075
- hintText: "依發起人的有效會員歸屬與主管解析規則決定簽核人。",
1076
- label: "主管層級",
1077
- name: "managerLevelsUp",
1078
- required: !0,
1079
- children: /* @__PURE__ */ h(f, {
1080
- clearable: !1,
1081
- onChange: (e) => $({
1082
- baseFromInitiator: !0,
1083
- levelsUp: Yt(e?.id ?? null).value,
1084
- type: "ORG_MANAGER"
1085
- }),
1086
- options: [...M],
1087
- value: ee
1088
- })
1089
- }) : null,
1090
- t.type === "ORG_UNIT_MANAGER" || t.type === "ORG_UNIT_MEMBER" || t.type === "ORG_UNIT_POSITION" ? /* @__PURE__ */ h(o, {
1091
- hintText: t.type === "ORG_UNIT_MANAGER" ? "依指定組織或其上層的主管解析規則決定簽核人。" : "依指定組織目前有效會員歸屬建立候選簽核人。",
1092
- label: "組織",
1093
- name: "orgUnitId",
1094
- required: !0,
1095
- children: /* @__PURE__ */ h(r, {
1096
- name: "orgUnitId",
1097
- onChange: (e) => $(t.type === "ORG_UNIT_MEMBER" ? {
1098
- includeDescendants: t.includeDescendants,
1099
- orgUnitId: e?.id ?? "",
1100
- type: "ORG_UNIT_MEMBER"
1101
- } : t.type === "ORG_UNIT_POSITION" ? {
1102
- includeDescendants: t.includeDescendants,
1103
- orgUnitId: e?.id ?? "",
1104
- positionId: "",
1105
- type: "ORG_UNIT_POSITION"
1106
- } : {
1107
- fallback: t.fallback,
1108
- orgUnitId: e?.id ?? "",
1109
- type: "ORG_UNIT_MANAGER"
1110
- }),
1111
- orgUnits: I,
1112
- placeholder: "選擇組織",
1113
- value: s
1114
- })
1115
- }) : null,
1116
- t.type === "ORG_MANAGER" || t.type === "ORG_UNIT_MANAGER" ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(o, {
1117
- hintText: "預設會停止流程並提示;若設定固定人,找不到主管時會改派給該會員。",
1118
- label: "無主管時",
1119
- name: "approverFallbackMode",
1120
- required: !0,
1121
- children: /* @__PURE__ */ h(f, {
1122
- clearable: !1,
1123
- onChange: (e) => $(qt(t, Kt(e?.id ?? null) === "DIRECT" ? {
1124
- memberId: "",
1125
- type: "DIRECT"
1126
- } : { type: "NONE" })),
1127
- options: [...pt],
1128
- value: z(pt, u.type)
1129
- })
1130
- }), u.type === "DIRECT" ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(o, {
1131
- label: "改派人員",
1132
- name: "approverFallbackMemberId",
1133
- required: !0,
1134
- children: /* @__PURE__ */ h(te, {
1135
- asyncData: !0,
1136
- disabledOptionsFilter: !0,
1137
- emptyText: "沒有符合的成員",
1138
- inputProps: {
1139
- autoCapitalize: "none",
1140
- autoCorrect: "off",
1141
- name: "workflow-approver-fallback-search",
1142
- spellCheck: !1
1143
- },
1144
- loading: Ct,
1145
- loadingText: "搜尋成員中...",
1146
- mode: "single",
1147
- onChange: (e) => $(qt(t, {
1148
- allowInitiatorSelfApproval: u.allowInitiatorSelfApproval,
1149
- memberId: e?.id ?? "",
1150
- type: "DIRECT"
1151
- })),
1152
- onSearch: Z,
1153
- onVisibilityChange: (e) => {
1154
- e && Z("");
1155
- },
1156
- options: [...P],
1157
- placeholder: "搜尋姓名或信箱",
1158
- searchDebounceTime: 300,
1159
- value: d
1160
- })
1161
- }), /* @__PURE__ */ h(o, {
1162
- hintText: "預設禁止申請人簽自己的案件;只有此流程允許自簽時才開啟。",
1163
- label: "允許自簽",
1164
- name: "allowInitiatorSelfApproval",
1165
- children: /* @__PURE__ */ h(le, {
1166
- checked: !!u.allowInitiatorSelfApproval,
1167
- onChange: (e) => $(qt(t, {
1168
- allowInitiatorSelfApproval: e.target.checked,
1169
- memberId: u.memberId,
1170
- type: "DIRECT"
1171
- }))
1172
- })
1173
- })] }) : null] }) : null,
1174
- t.type === "ORG_UNIT_MEMBER" || t.type === "ORG_UNIT_POSITION" ? /* @__PURE__ */ h(o, {
1175
- label: "包含下層",
1176
- name: "includeDescendants",
1177
- children: /* @__PURE__ */ h(le, {
1178
- checked: !!t.includeDescendants,
1179
- onChange: (e) => $({
1180
- ...t,
1181
- includeDescendants: e.target.checked,
1182
- ...t.type === "ORG_UNIT_POSITION" ? { positionId: "" } : {}
1183
- })
1184
- })
1185
- }) : null,
1186
- t.type === "POSITION" ? /* @__PURE__ */ h(o, {
1187
- hintText: "指派給目前有效歸屬中擁有此職位的會員;主要歸屬優先。",
1188
- label: "職位",
1189
- name: "positionId",
1190
- required: !0,
1191
- children: /* @__PURE__ */ h(a, {
1192
- name: "positionId",
1193
- onChange: (e) => $({
1194
- positionId: e?.id ?? "",
1195
- type: "POSITION"
1196
- }),
1197
- placeholder: "選擇職位",
1198
- positions: L,
1199
- value: c
1200
- })
1201
- }) : null,
1202
- t.type === "ORG_UNIT_POSITION" ? /* @__PURE__ */ h(o, {
1203
- hintText: "只納入指定組織範圍內擁有此職位的有效會員。",
1204
- label: "職位",
1205
- name: "orgUnitPositionId",
1206
- required: !0,
1207
- children: /* @__PURE__ */ h(a, {
1208
- disabled: !t.orgUnitId.trim(),
1209
- name: "orgUnitPositionId",
1210
- onChange: (e) => $({
1211
- includeDescendants: t.includeDescendants,
1212
- orgUnitId: t.orgUnitId,
1213
- positionId: e?.id ?? "",
1214
- type: "ORG_UNIT_POSITION"
1215
- }),
1216
- placeholder: t.orgUnitId.trim() ? "選擇職位" : "請先選擇組織",
1217
- positions: l,
1218
- value: c
1219
- })
1220
- }) : null,
1221
- e.data.returnBehavior.allowReturn ? /* @__PURE__ */ h(o, {
1222
- hintText: "退回發起人後,重新送出時要從流程開始重跑,或直接回到退回的簽核節點。",
1223
- label: "重送策略",
1224
- name: "returnResubmitStrategy",
1225
- required: !0,
1226
- children: /* @__PURE__ */ h(f, {
1227
- clearable: !1,
1228
- onChange: (e) => mr(Ut(e?.id ?? null)),
1229
- options: [...dt],
1230
- value: z(dt, ne)
1231
- })
1232
- }) : null
1233
- ] });
1234
- }
1235
- function Or(e) {
1236
- let t = tr(e.data.action).map((e) => bn(P, e));
1237
- return /* @__PURE__ */ h(o, {
1238
- label: "知會對象",
1239
- name: "notifyMemberIds",
1240
- required: !0,
1241
- children: /* @__PURE__ */ h(te, {
1242
- asyncData: !0,
1243
- disabledOptionsFilter: !0,
1244
- emptyText: "沒有符合的成員",
1245
- loading: Ct,
1246
- loadingText: "搜尋成員中...",
1247
- mode: "multiple",
1248
- onChange: (e) => hr({
1249
- channels: ["IN_APP"],
1250
- recipients: {
1251
- memberIds: e.map((e) => e.id),
1252
- type: "DIRECT"
1253
- },
1254
- type: "NOTIFY"
1255
- }),
1256
- onSearch: Z,
1257
- onVisibilityChange: (e) => {
1258
- e && Z("");
1259
- },
1260
- options: [...P],
1261
- overflowStrategy: "wrap",
1262
- placeholder: "搜尋姓名或信箱",
1263
- searchDebounceTime: 300,
1264
- value: [...t]
1265
- })
1266
- });
1267
- }
1268
- function kr(e) {
1269
- return /* @__PURE__ */ g("div", {
1270
- style: S,
1271
- children: [/* @__PURE__ */ h(p, {
1272
- component: "h2",
1273
- variant: "h3",
1274
- children: "已選取線段"
1275
- }), /* @__PURE__ */ g(p, {
1276
- color: "text-neutral",
1277
- variant: "body",
1278
- children: [
1279
- "已選取 ",
1280
- e.length,
1281
- " 條線段,可使用 Delete 或控制面板刪除。"
1282
- ]
1283
- })]
1284
- });
1285
- }
1286
- function Ar(e) {
1287
- let t = X(e, v.nodes);
1288
- return /* @__PURE__ */ g("div", {
1289
- style: S,
1290
- children: [
1291
- /* @__PURE__ */ h(p, {
1292
- component: "h2",
1293
- variant: "h3",
1294
- children: t ? "條件設定" : "線段屬性"
1295
- }),
1296
- /* @__PURE__ */ g(p, {
1297
- color: "text-neutral",
1298
- variant: "body",
1299
- children: [
1300
- e.source,
1301
- " → ",
1302
- e.target
1303
- ]
1304
- }),
1305
- t ? Mr(e) : /* @__PURE__ */ h(p, {
1306
- color: "text-neutral",
1307
- variant: "body",
1308
- children: "這條線會直接把流程送到下一個節點。"
1309
- })
1310
- ]
1311
- });
1312
- }
1313
- function jr(e) {
1314
- return !e || !X(e, v.nodes) ? null : /* @__PURE__ */ h(ie, {
1315
- cancelText: "取消",
1316
- confirmButtonProps: { disabled: !e.data.isDefault && !e.data.condition },
1317
- confirmText: "完成",
1318
- modalType: "standard",
1319
- onCancel: dr,
1320
- onClose: dr,
1321
- onConfirm: dr,
1322
- open: !!tt,
1323
- showModalFooter: !0,
1324
- showModalHeader: !0,
1325
- size: "regular",
1326
- supportingText: "條件分流的輸出連線需要指定條件,條件會直接顯示在線上。",
1327
- title: "條件設定",
1328
- children: Mr(e)
1329
- });
1330
- }
1331
- function Mr(e) {
1332
- let t = $n(e, v.nodes), n = Bn(K?.schema ?? null), r = Vn(K?.schema ?? null, e.data.conditionFieldKey ?? null), i = Hn(r), a = Gn(r), s = z(i, e.data.conditionOperator ?? null);
1333
- return /* @__PURE__ */ g("div", {
1334
- style: S,
1335
- children: [
1336
- /* @__PURE__ */ g(p, {
1337
- color: "text-neutral",
1338
- variant: "body",
1339
- children: [
1340
- "畫布上的這條線目前會顯示「",
1341
- /* @__PURE__ */ h("span", {
1342
- style: { color: !e.data.isDefault && !e.data.condition ? Ge : void 0 },
1343
- children: t ?? "請設定條件"
1344
- }),
1345
- "」。"
1346
- ]
1347
- }),
1348
- /* @__PURE__ */ h(le, {
1349
- checked: !!e.data.isDefault,
1350
- label: "其他情況走這條",
1351
- onChange: (t) => br(e.id, t.target.checked)
1352
- }),
1353
- e.data.isDefault ? /* @__PURE__ */ h(p, {
1354
- color: "text-neutral",
1355
- variant: "body",
1356
- children: "其他條件都不符合時,流程會走這條線。"
1357
- }) : /* @__PURE__ */ g(m, { children: [
1358
- K ? null : /* @__PURE__ */ h(p, {
1359
- color: "text-neutral",
1360
- variant: "body",
1361
- children: "請先綁定表單版本,才能選擇條件欄位。"
1362
- }),
1363
- /* @__PURE__ */ h(o, {
1364
- label: "條件欄位",
1365
- name: "edgeConditionField",
1366
- required: !0,
1367
- children: /* @__PURE__ */ h(f, {
1368
- clearable: !1,
1369
- onChange: (t) => xr({
1370
- edgeId: e.id,
1371
- fieldKey: t?.id ?? null,
1372
- operator: null,
1373
- value: null
1374
- }),
1375
- options: [...n],
1376
- placeholder: "選擇條件欄位",
1377
- value: z(n, e.data.conditionFieldKey ?? null)
1378
- })
1379
- }),
1380
- /* @__PURE__ */ h(o, {
1381
- label: "條件判斷",
1382
- name: "edgeConditionOperator",
1383
- required: !0,
1384
- children: /* @__PURE__ */ h(f, {
1385
- clearable: !1,
1386
- onChange: (t) => xr({
1387
- edgeId: e.id,
1388
- operator: Un(t?.id ?? null),
1389
- value: null
1390
- }),
1391
- options: [...i],
1392
- placeholder: "選擇判斷方式",
1393
- value: s
1394
- })
1395
- }),
1396
- s && Jn(s.id) ? /* @__PURE__ */ h(o, {
1397
- label: "條件值",
1398
- name: "edgeConditionValue",
1399
- required: !0,
1400
- children: a.length > 0 ? /* @__PURE__ */ h(f, {
1401
- clearable: !1,
1402
- onChange: (t) => xr({
1403
- edgeId: e.id,
1404
- value: t?.id ?? null
1405
- }),
1406
- options: [...a],
1407
- placeholder: "選擇條件值",
1408
- value: z(a, e.data.conditionValue ?? null)
1409
- }) : /* @__PURE__ */ h(re, {
1410
- onChange: (t) => xr({
1411
- edgeId: e.id,
1412
- value: t.target.value
1413
- }),
1414
- placeholder: "輸入要比對的值",
1415
- value: e.data.conditionValue ?? "",
1416
- variant: "base"
1417
- })
1418
- }) : null
1419
- ] })
1420
- ]
1421
- });
1422
- }
1423
- }
1424
- function xt({ onApplyAutoLayout: e }) {
1425
- function t() {
1426
- e();
1427
- }
1428
- return /* @__PURE__ */ h(v, {
1429
- position: "top-right",
1430
- children: /* @__PURE__ */ h(d, {
1431
- icon: fe,
1432
- iconType: "leading",
1433
- onClick: t,
1434
- size: "sub",
1435
- variant: "base-secondary",
1436
- children: "自動排版"
1437
- })
1438
- });
1439
- }
1440
- function N({ data: e, selected: t, type: n }) {
1441
- let r = e.approverLines ?? [e.approverSummary ?? e.label], i = St(e);
1442
- return /* @__PURE__ */ g("div", {
1443
- style: Ct(n, t),
1444
- children: [
1445
- P(e),
1446
- /* @__PURE__ */ h("div", {
1447
- style: at,
1448
- children: r.map((e, t) => /* @__PURE__ */ h(p, {
1449
- component: "span",
1450
- ellipsis: !0,
1451
- style: it,
1452
- title: e,
1453
- variant: "label-primary",
1454
- children: e
1455
- }, `${e}_${t}`))
1456
- }),
1457
- /* @__PURE__ */ h(p, {
1458
- color: "text-neutral",
1459
- component: "span",
1460
- ellipsis: !0,
1461
- style: it,
1462
- title: i,
1463
- variant: "caption",
1464
- children: i
1465
- })
1466
- ]
1467
- });
1468
- }
1469
- function St(e) {
1470
- return e.nodeKind === "startEvent" ? e.initiatorPolicySummary ?? "所有人" : e.approverSummary || e.approverLines ? e.label : e.nodeKind === "exclusiveGateway" ? "條件在線上" : e.nodeKind === "parallelGateway" ? "多條路徑同時進行" : st[e.nodeKind];
1471
- }
1472
- function Ct(e, t) {
1473
- let n = wt(e);
1474
- return t ? {
1475
- ...n,
1476
- border: "1px solid var(--mzn-color-primary, #0057ff)",
1477
- boxShadow: $e
1478
- } : n;
1479
- }
1480
- function wt(e) {
1481
- return e === "exclusiveGateway" ? tt : e === "parallelGateway" ? k : e === "startEvent" ? A : e === "endEvent" ? rt : e === "userTask" ? nt : C;
1482
- }
1483
- function P(e) {
1484
- return !e.hasInput && e.hasOutput ? /* @__PURE__ */ h(_, {
1485
- id: ot,
1486
- position: y.Right,
1487
- type: "source"
1488
- }) : e.hasInput && !e.hasOutput ? /* @__PURE__ */ h(_, {
1489
- id: j,
1490
- position: y.Left,
1491
- type: "target"
1492
- }) : !e.hasInput && !e.hasOutput ? null : [/* @__PURE__ */ h(_, {
1493
- id: j,
1494
- position: y.Left,
1495
- type: "target"
1496
- }, "target"), /* @__PURE__ */ h(_, {
1497
- id: ot,
1498
- position: y.Right,
1499
- type: "source"
1500
- }, "source")];
1501
- }
1502
- function Tt(e, t, n, r, i, a) {
1503
- let o = F(e);
1504
- return {
1505
- data: {
1506
- approverLines: Pn(e, t),
1507
- approverSummary: Mn(e, t, n, r),
1508
- hasInput: B(e),
1509
- hasOutput: V(e),
1510
- initiatorPolicySummary: e.type === "startEvent" ? nn(a, n, r) : null,
1511
- label: e.data.label,
1512
- nodeKind: e.type
1513
- },
1514
- height: o.height,
1515
- handles: I(e),
1516
- id: e.id,
1517
- initialHeight: o.height,
1518
- initialWidth: o.width,
1519
- position: e.position,
1520
- selected: i,
1521
- sourcePosition: y.Right,
1522
- targetPosition: y.Left,
1523
- type: e.type,
1524
- width: o.width
1525
- };
1526
- }
1527
- function F(e) {
1528
- return e.type === "exclusiveGateway" || e.type === "parallelGateway" ? {
1529
- height: E,
1530
- width: D
1531
- } : e.type === "serviceTask" ? {
1532
- height: et + (Math.max(1, tr(e.data.action).length) - 1) * T,
1533
- width: w
1534
- } : {
1535
- height: et,
1536
- width: w
1537
- };
1538
- }
1539
- function I(e) {
1540
- let t = F(e);
1541
- return [...B(e) ? [Et(t)] : [], ...V(e) ? [L(t)] : []];
1542
- }
1543
- function Et({ height: e }) {
1544
- let t = e / 2 - 9 / 2;
1545
- return {
1546
- height: 9,
1547
- id: j,
1548
- position: y.Left,
1549
- type: "target",
1550
- width: 9,
1551
- x: -9 / 2,
1552
- y: t
1553
- };
1554
- }
1555
- function L({ height: e, width: t }) {
1556
- let n = e / 2 - 9 / 2;
1557
- return {
1558
- height: 9,
1559
- id: ot,
1560
- position: y.Right,
1561
- type: "source",
1562
- width: 9,
1563
- x: t - 9 / 2,
1564
- y: n
1565
- };
1566
- }
1567
- function Dt(e, t, n) {
1568
- let r = $n(e, t), i = X(e, t), a = i && !e.data.isDefault && !e.data.condition, o = a ? Ge : i ? We : "#475569", s = a ? "#fef2f2" : i ? "#eff6ff" : "#ffffff", c = a ? Ge : i ? We : x;
1569
- return {
1570
- className: n ? "workflow-edge--selected" : void 0,
1571
- data: e.data,
1572
- id: e.id,
1573
- label: r,
1574
- labelBgBorderRadius: 6,
1575
- labelBgPadding: [8, 4],
1576
- labelBgStyle: {
1577
- fill: s,
1578
- stroke: c,
1579
- strokeWidth: 1
1580
- },
1581
- labelShowBg: !!r,
1582
- labelStyle: {
1583
- fill: o,
1584
- fontSize: 12,
1585
- fontWeight: 600
1586
- },
1587
- selected: n,
1588
- source: e.source,
1589
- sourceHandle: e.sourceHandle,
1590
- style: {
1591
- filter: n ? Ke : void 0,
1592
- opacity: 1,
1593
- stroke: x,
1594
- strokeOpacity: 1,
1595
- strokeWidth: 1.5
1596
- },
1597
- target: e.target,
1598
- targetHandle: e.targetHandle,
1599
- type: e.type ?? "smoothstep"
1600
- };
1601
- }
1602
- function Ot(e, t) {
1603
- return e.type === "startEvent" || e.type === "endEvent" || e.type === "userTask" || e.type === "serviceTask" || e.type, {
1604
- ...e,
1605
- data: {
1606
- ...e.data,
1607
- label: t
1608
- }
1609
- };
1610
- }
1611
- function kt(e, t) {
1612
- return e.type === "startEvent" ? e : (e.type === "endEvent" || e.type === "userTask" || e.type === "serviceTask" || e.type, {
1613
- ...e,
1614
- data: {
1615
- ...e.data,
1616
- triggerMode: t
1617
- }
1618
- });
1619
- }
1620
- function At(e) {
1621
- return Mt(jt(e));
1622
- }
1623
- function jt(e) {
1624
- let t = new Set(e.nodes.filter((e) => cn(e)).map((e) => e.id)), n = e.edges.filter((e) => !t.has(e.source));
1625
- return n.length === e.edges.length ? e : {
1626
- ...e,
1627
- edges: n
1628
- };
1629
- }
1630
- function Mt(e) {
1631
- let t = e.edges.reduce((e, t) => ({
1632
- ...e,
1633
- [t.target]: (e[t.target] ?? 0) + 1
1634
- }), {}), n = e.nodes.map((e) => e.type === "startEvent" ? e : (t[e.id] ?? 0) < 2 && e.data.triggerMode !== "AND" ? kt(e, "AND") : e);
1635
- return n.some((t, n) => t !== e.nodes[n]) ? {
1636
- ...e,
1637
- nodes: n
1638
- } : e;
1639
- }
1640
- function Nt(e, t) {
1641
- let n = {
1642
- id: `${e}_${t}`,
1643
- position: {
1644
- x: 260 + t * 48,
1645
- y: 120 + t * 42
1646
- }
1647
- };
1648
- return e === "userTask" ? {
1649
- ...n,
1650
- data: {
1651
- allowAddSigner: !1,
1652
- allowReject: !0,
1653
- allowTransfer: !0,
1654
- approverResolver: {
1655
- memberIds: ["member-001"],
1656
- type: "DIRECT"
1657
- },
1658
- decisionPolicy: { type: "SINGLE" },
1659
- label: `簽核節點 ${t}`,
1660
- returnBehavior: {
1661
- allowReturn: !0,
1662
- allowedTargets: "INITIATOR",
1663
- resubmitStrategy: "RESTART"
1664
- },
1665
- triggerMode: "AND"
1666
- },
1667
- type: e
1668
- } : e === "serviceTask" ? {
1669
- ...n,
1670
- data: {
1671
- action: {
1672
- channels: ["IN_APP"],
1673
- recipients: {
1674
- memberIds: ["member-001"],
1675
- type: "DIRECT"
1676
- },
1677
- type: "NOTIFY"
1678
- },
1679
- label: `知會節點 ${t}`,
1680
- triggerMode: "AND"
1681
- },
1682
- type: e
1683
- } : {
1684
- ...n,
1685
- data: {
1686
- direction: "split",
1687
- label: `條件分流 ${t}`,
1688
- triggerMode: "AND"
1689
- },
1690
- type: e
1691
- };
1692
- }
1693
- function Pt(e, t) {
1694
- let n = new Set(e.filter((e) => e.type === t).map((e) => Number(e.id.replace(`${t}_`, ""))).filter((e) => Number.isInteger(e) && e > 0));
1695
- return Array.from({ length: e.length + 1 }, (e, t) => t + 1).find((e) => !n.has(e)) ?? e.length + 1;
1696
- }
1697
- function Ft({ definition: e, node: t, selectedEdgeId: n, selectedNodeId: r }) {
1698
- let i = n ? e.edges.find((e) => e.id === n) ?? null : null, a = r ? e.nodes.find((e) => e.id === r) ?? null : null;
1699
- return i ? It(e, t, i) : a ? Lt(e, t, a) : {
1700
- definition: {
1701
- ...e,
1702
- nodes: [...e.nodes, t]
1703
- },
1704
- editingEdgeId: null,
1705
- selectedEdgeIds: [],
1706
- selectedNodeId: t.id
1707
- };
1708
- }
1709
- function It(e, t, n) {
1710
- if (!B(t)) return {
1711
- definition: e,
1712
- editingEdgeId: null,
1713
- selectedEdgeIds: [n.id],
1714
- selectedNodeId: null
1715
- };
1716
- if (!V(t)) {
1717
- let r = R(n.source, t.id, {});
1718
- return {
1719
- definition: {
1720
- ...e,
1721
- edges: [...e.edges, r],
1722
- nodes: [...e.nodes, t]
1723
- },
1724
- editingEdgeId: null,
1725
- selectedEdgeIds: [],
1726
- selectedNodeId: t.id
1727
- };
1728
- }
1729
- let r = R(n.source, t.id, n.data), i = R(t.id, n.target, Rt(t, n)), a = X(i, [...e.nodes, t]);
1730
- return {
1731
- definition: {
1732
- ...e,
1733
- edges: e.edges.flatMap((e) => e.id === n.id ? [r, i] : [e]),
1734
- nodes: [...e.nodes, t]
1735
- },
1736
- editingEdgeId: a ? i.id : null,
1737
- selectedEdgeIds: a ? [i.id] : [],
1738
- selectedNodeId: a ? null : t.id
1739
- };
1740
- }
1741
- function Lt(e, t, n) {
1742
- if (!V(n)) return {
1743
- definition: {
1744
- ...e,
1745
- nodes: [...e.nodes, t]
1746
- },
1747
- editingEdgeId: null,
1748
- selectedEdgeIds: [],
1749
- selectedNodeId: t.id
1750
- };
1751
- let r = e.edges.find((e) => e.source === n.id) ?? null;
1752
- if (r && V(t)) return It(e, t, r);
1753
- let i = e.nodes.find((e) => e.type === "endEvent");
1754
- if (i && n.id !== i.id && V(t)) {
1755
- let r = R(n.id, t.id, {}), a = R(t.id, i.id, Rt(t, r)), o = X(a, [...e.nodes, t]);
1756
- return {
1757
- definition: {
1758
- ...e,
1759
- edges: [
1760
- ...e.edges,
1761
- r,
1762
- a
1763
- ],
1764
- nodes: [...e.nodes, t]
1765
- },
1766
- editingEdgeId: o ? a.id : null,
1767
- selectedEdgeIds: o ? [a.id] : [],
1768
- selectedNodeId: o ? null : t.id
1769
- };
1770
- }
1771
- let a = R(n.id, t.id, {});
1772
- return {
1773
- definition: {
1774
- ...e,
1775
- edges: [...e.edges, a],
1776
- nodes: [...e.nodes, t]
1777
- },
1778
- editingEdgeId: null,
1779
- selectedEdgeIds: [],
1780
- selectedNodeId: t.id
1781
- };
1782
- }
1783
- function R(e, t, n) {
1784
- return {
1785
- data: n,
1786
- id: `edge_${e}_${t}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
1787
- source: e,
1788
- sourceHandle: ot,
1789
- target: t,
1790
- targetHandle: j,
1791
- type: "smoothstep"
1792
- };
1793
- }
1794
- function Rt(e, t) {
1795
- return e.type === "exclusiveGateway" ? {
1796
- isDefault: !0,
1797
- label: "其他情況"
1798
- } : {};
1799
- }
1800
- function zt() {
1801
- return {
1802
- edges: [],
1803
- meta: { schemaVersion: 1 },
1804
- nodes: [{
1805
- data: { label: "開始" },
1806
- id: "start",
1807
- position: {
1808
- x: 80,
1809
- y: 160
1810
- },
1811
- type: "startEvent"
1812
- }, {
1813
- data: {
1814
- endState: "APPROVED",
1815
- label: "完成",
1816
- triggerMode: "AND"
1817
- },
1818
- id: "end",
1819
- position: {
1820
- x: 560,
1821
- y: 160
1822
- },
1823
- type: "endEvent"
1824
- }]
1825
- };
1826
- }
1827
- function Bt(e) {
1828
- return e.edges.length === 0 && e.nodes.length === 2 && e.nodes.some((e) => e.type === "startEvent") && e.nodes.some((e) => e.type === "endEvent");
1829
- }
1830
- function Vt(e) {
1831
- let t = new Oe.graphlib.Graph();
1832
- return t.setDefaultEdgeLabel(() => ({})), t.setGraph({
1833
- rankdir: "LR",
1834
- ranksep: 120
1835
- }), e.nodes.forEach((e) => {
1836
- t.setNode(e.id, F(e));
1837
- }), e.edges.forEach((e) => {
1838
- t.setEdge(e.source, e.target);
1839
- }), Oe.layout(t), {
1840
- ...e,
1841
- nodes: e.nodes.map((e) => {
1842
- let n = t.node(e.id);
1843
- return n ? {
1844
- ...e,
1845
- position: {
1846
- x: n.x - F(e).width / 2,
1847
- y: n.y - F(e).height / 2
1848
- }
1849
- } : e;
1850
- })
1851
- };
1852
- }
1853
- function z(e, t) {
1854
- return t ? e.find((e) => e.id === t) ?? null : null;
1855
- }
1856
- function Ht(e) {
1857
- return e === "OR" ? "OR" : "AND";
1858
- }
1859
- function Ut(e) {
1860
- return e === "FROM_RETURN_POINT" ? "FROM_RETURN_POINT" : "RESTART";
1861
- }
1862
- function Wt(e) {
1863
- return e === "ORG_MANAGER" || e === "ORG_UNIT_MANAGER" || e === "ORG_UNIT_MEMBER" || e === "ORG_UNIT_POSITION" || e === "POSITION" ? e : "DIRECT";
1864
- }
1865
- function Gt(e) {
1866
- let t = Wt(e ?? "DIRECT");
1867
- return t === "ORG_MANAGER" ? {
1868
- baseFromInitiator: !0,
1869
- levelsUp: 1,
1870
- type: "ORG_MANAGER"
1871
- } : t === "ORG_UNIT_MANAGER" ? {
1872
- orgUnitId: "",
1873
- type: "ORG_UNIT_MANAGER"
1874
- } : t === "ORG_UNIT_MEMBER" ? {
1875
- includeDescendants: !1,
1876
- orgUnitId: "",
1877
- type: "ORG_UNIT_MEMBER"
1878
- } : t === "ORG_UNIT_POSITION" ? {
1879
- includeDescendants: !1,
1880
- orgUnitId: "",
1881
- positionId: "",
1882
- type: "ORG_UNIT_POSITION"
1883
- } : t === "POSITION" ? {
1884
- positionId: "",
1885
- type: "POSITION"
1886
- } : {
1887
- memberIds: [],
1888
- type: "DIRECT"
1889
- };
1890
- }
1891
- function Kt(e) {
1892
- return e === "DIRECT" ? "DIRECT" : "NONE";
1893
- }
1894
- function qt(e, t) {
1895
- return e.type === "ORG_MANAGER" || e.type === "ORG_UNIT_MANAGER" ? {
1896
- ...e,
1897
- fallback: t
1898
- } : e;
1899
- }
1900
- function Jt(e) {
1901
- return M.find((t) => t.value === e) ?? M[0];
1902
- }
1903
- function Yt(e) {
1904
- return M.find((t) => t.id === e) ?? M[0];
1905
- }
1906
- function Xt(e) {
1907
- return e === "ORG_UNIT" || e === "ORG_UNIT_POSITION" || e === "NONE" ? e : "ALL";
1908
- }
1909
- function Zt(e) {
1910
- let t = e?.trim();
1911
- if (!t) return {
1912
- mode: "ALL",
1913
- value: ""
1914
- };
1915
- let n = en(t, /"([^"]+)" in subject\.orgUnitIds/gu), r = en(t, /"([^"]+)" in subject\.positionIds/gu);
1916
- return n.length > 0 && r.length > 0 ? {
1917
- includeDescendants: n.length > 1,
1918
- mode: "ORG_UNIT_POSITION",
1919
- orgUnitId: n[0],
1920
- positionId: r[0],
1921
- value: n[0] ?? ""
1922
- } : n.length > 0 ? {
1923
- includeDescendants: n.length > 1,
1924
- mode: "ORG_UNIT",
1925
- orgUnitId: n[0],
1926
- value: n[0] ?? ""
1927
- } : {
1928
- mode: "CUSTOM",
1929
- value: t
1930
- };
1931
- }
1932
- function Qt(e, t) {
1933
- let n = Zt(e);
1934
- return !t || t === "ALL" || t === "NONE" ? t === "ALL" || t === "NONE" ? {
1935
- mode: t,
1936
- value: ""
1937
- } : n : n.mode === t ? n : rn(t);
1938
- }
1939
- function $t(e) {
1940
- return e.mode === "NONE" ? "發起權限需要選擇誰可以發起。" : (e.mode === "ORG_UNIT" || e.mode === "ORG_UNIT_POSITION") && !e.orgUnitId?.trim() ? "指定組織發起時,需要選擇組織。" : e.mode === "ORG_UNIT_POSITION" && !e.positionId?.trim() ? "指定組織職位發起時,需要選擇職位。" : null;
1941
- }
1942
- function en(e, t) {
1943
- return [...e.matchAll(t)].map((e) => e[1]).filter((e) => !!e);
1944
- }
1945
- function tn(e, t) {
1946
- if (e.mode === "ALL" || e.mode === "NONE") return null;
1947
- let n = e.orgUnitId?.trim() ?? "";
1948
- if (!n) return null;
1949
- let r = kn(t, n, !!e.includeDescendants).map((e) => `${JSON.stringify(e)} in subject.orgUnitIds`).join(" || ");
1950
- if (e.mode === "ORG_UNIT") return r ? `(${r})` : null;
1951
- let i = e.positionId?.trim() ?? "";
1952
- return i && r ? `(${r}) && ${JSON.stringify(i)} in subject.positionIds` : null;
1953
- }
1954
- function nn(e, t, n) {
1955
- return e.mode === "NONE" ? "未設定" : e.mode === "ORG_UNIT" ? e.orgUnitId ? `組織:${H(t, e.orgUnitId)}` : "指定組織" : e.mode === "ORG_UNIT_POSITION" ? e.orgUnitId && e.positionId ? `組織職位:${H(t, e.orgUnitId)} / ${U(n, e.positionId)}` : "指定組織職位" : e.mode === "CUSTOM" ? "既有自訂規則" : "所有人";
1956
- }
1957
- function rn(e) {
1958
- return {
1959
- includeDescendants: !0,
1960
- mode: e,
1961
- orgUnitId: "",
1962
- positionId: "",
1963
- value: ""
1964
- };
1965
- }
1966
- function an(e, t) {
1967
- let n = e.source ? t.find((t) => t.id === e.source) ?? null : null, r = e.target ? t.find((t) => t.id === e.target) ?? null : null;
1968
- return !!n && !!r && e.source !== e.target && e.sourceHandle === ot && e.targetHandle === j && !!(n && V(n)) && !!(r && B(r));
1969
- }
1970
- function on(e, t) {
1971
- return e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
1972
- }
1973
- function sn(e) {
1974
- return e.type !== "startEvent" && e.type !== "endEvent";
1975
- }
1976
- function B(e) {
1977
- return e.type !== "startEvent";
1978
- }
1979
- function V(e) {
1980
- return e.type !== "endEvent" && !cn(e);
1981
- }
1982
- function cn(e) {
1983
- return e.type === "serviceTask" && e.data.action.type === "NOTIFY";
1984
- }
1985
- function ln(e) {
1986
- return e instanceof HTMLElement ? e.isContentEditable || e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.tagName === "SELECT" || !!e.closest("[contenteditable=\"true\"]") : !1;
1987
- }
1988
- function un(e) {
1989
- return e.map((e) => ({
1990
- id: e.id,
1991
- name: `${e.formName} | v${e.version}`,
1992
- schema: e.schema
1993
- }));
1994
- }
1995
- function dn(e) {
1996
- return (e?.schema.fields ?? []).reduce((e, t) => ({
1997
- ...e,
1998
- [t.fieldKey]: fn(t)
1999
- }), {});
2000
- }
2001
- function fn(e) {
2002
- return e.type === "number" ? 1e3 : e.type === "boolean" ? !0 : e.type === "select" ? e.options[0]?.value ?? "" : e.type === "checkbox" ? e.options[0] ? [e.options[0].value] : [] : e.type === "date" ? "2026-05-08" : e.type === "datetime" ? "2026-05-08T09:00:00+08:00" : e.placeholder ?? e.label;
2003
- }
2004
- function pn(e) {
2005
- let t = JSON.parse(e);
2006
- if (!mn(t)) throw Error("表單資料 JSON 必須是物件。");
2007
- return t;
2008
- }
2009
- function mn(e) {
2010
- return typeof e == "object" && !!e && !Array.isArray(e);
2011
- }
2012
- function hn(e) {
2013
- return e === "COMPLETED" ? "完成" : e === "PASSED" ? "通過" : e === "SKIPPED" ? "略過" : e === "STOPPED" ? "已停止" : e === "WAITING" ? "將等待簽核" : e;
2014
- }
2015
- function gn(e) {
2016
- return e in st ? st[e] : e;
2017
- }
2018
- function _n(e, t) {
2019
- return t && !e.some((e) => e.id === t.id) ? [t, ...e] : e;
2020
- }
2021
- function vn(e) {
2022
- return e.map((e) => ({
2023
- displayName: e.name,
2024
- email: e.email,
2025
- id: e.memberId,
2026
- memberId: e.memberId,
2027
- name: G(e.name, e.email)
2028
- }));
2029
- }
2030
- function yn(e) {
2031
- return {
2032
- displayName: "未知會員",
2033
- email: "",
2034
- id: e,
2035
- memberId: e,
2036
- name: "未知會員"
2037
- };
2038
- }
2039
- function bn(e, t) {
2040
- return e.find((e) => e.memberId === t) ?? yn(t);
2041
- }
2042
- function xn(e, t) {
2043
- let n = e[0];
2044
- return n ? bn(t, n) : null;
2045
- }
2046
- function Sn(e, t) {
2047
- let r = e.find((e) => e.id === t);
2048
- return r ? n(r) : null;
2049
- }
2050
- function Cn(e, t) {
2051
- let n = e.find((e) => e.id === t);
2052
- return n ? i(n) : null;
2053
- }
2054
- function H(e, t) {
2055
- return Sn(e, t)?.name ?? "未指定組織";
2056
- }
2057
- function U(e, t) {
2058
- return Cn(e, t)?.name ?? "未指定職位";
2059
- }
2060
- function wn(e, t) {
2061
- let n = Tn(), r = t.filter((t) => t.memberId === e && En(t, n)), i = r.reduce((e, t) => e && W(e, t) <= 0 ? e : t, null);
2062
- return {
2063
- customFields: {},
2064
- managerMemberId: "member-002",
2065
- memberId: e,
2066
- orgCode: "HQ",
2067
- orgUnitIds: Dn(r.map((e) => e.orgUnitId)),
2068
- positionId: i?.positionId ?? null,
2069
- positionIds: Dn(r.map((e) => e.positionId)),
2070
- primaryOrgUnitId: i?.orgUnitId ?? null,
2071
- roles: ["manager"]
2072
- };
2073
- }
2074
- function Tn() {
2075
- return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2076
- }
2077
- function En(e, t) {
2078
- return e.effectiveFrom <= t && (!e.effectiveTo || e.effectiveTo >= t);
2079
- }
2080
- function W(e, t) {
2081
- return e.isPrimary === t.isPrimary ? t.effectiveFrom.localeCompare(e.effectiveFrom) : e.isPrimary ? -1 : 1;
2082
- }
2083
- function Dn(e) {
2084
- return e.reduce((e, t) => t && !e.includes(t) ? [...e, t] : e, []);
2085
- }
2086
- function On({ includeDescendants: e, memberships: t, orgUnitId: n, orgUnits: r, positions: i }) {
2087
- let a = new Set(kn(r, n, e)), o = new Set(t.filter((e) => a.has(e.orgUnitId)).map((e) => e.positionId).filter((e) => !!e));
2088
- return i.filter((e) => o.has(e.id));
2089
- }
2090
- function kn(e, t, n) {
2091
- let r = e.find((e) => e.id === t);
2092
- return r ? n ? e.filter((e) => e.id === r.id || e.path.startsWith(`${r.path}.`)).map((e) => e.id) : [r.id] : t.trim() ? [t] : [];
2093
- }
2094
- function An(e, t) {
2095
- let n = new Set(e.map((e) => e.memberId)), r = t.filter((e) => !n.has(e.memberId));
2096
- return [...e, ...r];
2097
- }
2098
- function jn(e) {
2099
- return [...new Set(e.nodes.flatMap((e) => e.type === "userTask" ? e.data.approverResolver.type === "DIRECT" ? e.data.approverResolver.memberIds : [] : e.type === "serviceTask" ? tr(e.data.action) : []))];
2100
- }
2101
- function Mn(e, t, n, r) {
2102
- return e.type === "userTask" ? Nn(e.data.approverResolver, t, n, r) : null;
2103
- }
2104
- function Nn(e, t, n, r) {
2105
- return e.type === "DIRECT" ? Fn(e.memberIds, t, "未指定簽核者") : e.type === "ORG_MANAGER" ? Jt(e.levelsUp).name : e.type === "ORG_UNIT_MANAGER" ? `組織主管:${H(n, e.orgUnitId)}` : e.type === "ORG_UNIT_MEMBER" ? `組織任一人:${H(n, e.orgUnitId)}` : e.type === "ORG_UNIT_POSITION" ? `組織職位:${H(n, e.orgUnitId)} / ${U(r, e.positionId)}` : e.type === "POSITION" ? `職位:${U(r, e.positionId)}` : e.type === "DYNAMIC_FORM" ? `表單欄位:${e.formPath || "未設定"}` : "自訂表達式";
2106
- }
2107
- function Pn(e, t) {
2108
- if (e.type !== "serviceTask") return null;
2109
- let n = tr(e.data.action);
2110
- return n.length === 0 ? ["未指定知會對象"] : n.map((e) => bn(t, e).name);
2111
- }
2112
- function Fn(e, t, n) {
2113
- let r = e.map((e) => bn(t, e).name);
2114
- return r.length === 0 ? n : r.length <= 2 ? r.join("、") : `${r.slice(0, 2).join("、")} 等 ${r.length} 人`;
2115
- }
2116
- function G(e, t) {
2117
- return `${e} (${t})`;
2118
- }
2119
- function In(e, t) {
2120
- let n = t?.getBoundingClientRect();
2121
- if (!n || e.nodes.length === 0) return null;
2122
- let r = e.nodes.reduce((e, t) => {
2123
- let n = F(t);
2124
- return {
2125
- maxX: Math.max(e.maxX, t.position.x + n.width),
2126
- maxY: Math.max(e.maxY, t.position.y + n.height),
2127
- minX: Math.min(e.minX, t.position.x),
2128
- minY: Math.min(e.minY, t.position.y)
2129
- };
2130
- }, {
2131
- maxX: -Infinity,
2132
- maxY: -Infinity,
2133
- minX: Infinity,
2134
- minY: Infinity
2135
- });
2136
- return De({
2137
- height: r.maxY - r.minY,
2138
- width: r.maxX - r.minX,
2139
- x: r.minX,
2140
- y: r.minY
2141
- }, n.width, n.height, .1, 1, .2);
2142
- }
2143
- function Ln(e) {
2144
- let t = e.nodes.find((e) => e.type === "userTask" && !!Rn(e.data.approverResolver)), n = e.nodes.find((e) => e.type === "serviceTask" && e.data.action.type === "NOTIFY" && tr(e.data.action).length === 0), r = e.edges.find((t) => X(t, e.nodes) && !t.data.isDefault && !t.data.condition);
2145
- return t && t.type === "userTask" ? Rn(t.data.approverResolver) : n ? "知會節點需要至少一位知會對象。" : r ? "條件分流的每條輸出連線都需要先設定條件。" : null;
2146
- }
2147
- function Rn(e) {
2148
- return e.type === "DIRECT" && e.memberIds.length === 0 ? "簽核節點需要指定簽核會員。" : e.type === "ORG_MANAGER" && e.levelsUp < 1 ? "簽核節點需要指定有效的主管層級。" : e.type === "ORG_UNIT_MANAGER" && !e.orgUnitId.trim() || e.type === "ORG_UNIT_MEMBER" && !e.orgUnitId.trim() ? "簽核節點需要指定組織。" : e.type === "ORG_UNIT_POSITION" && (!e.orgUnitId.trim() || !e.positionId.trim()) ? "簽核節點需要指定組織與職位。" : (e.type === "ORG_MANAGER" || e.type === "ORG_UNIT_MANAGER") && e.fallback?.type === "DIRECT" && !e.fallback.memberId.trim() ? "簽核節點需要指定改派固定人。" : e.type === "POSITION" && !e.positionId.trim() ? "簽核節點需要指定職位。" : null;
2149
- }
2150
- function zn(e) {
2151
- return e.edges.some((t) => X(t, e.nodes) && !!(t.data.condition || t.data.conditionFieldKey || t.data.conditionOperator || t.data.conditionValue));
2152
- }
2153
- function Bn(e) {
2154
- return e?.fields.map((e) => ({
2155
- fieldType: e.type,
2156
- id: e.fieldKey,
2157
- name: `${e.label} (${e.fieldKey})`
2158
- })) ?? [];
2159
- }
2160
- function Vn(e, t) {
2161
- return t ? e?.fields.find((e) => e.fieldKey === t) ?? null : null;
2162
- }
2163
- function Hn(e) {
2164
- if (!e) return [];
2165
- let t = Wn(e);
2166
- return mt.filter((e) => t.includes(e.id));
2167
- }
2168
- function Un(e) {
2169
- return mt.some((t) => t.id === e) ? e : null;
2170
- }
2171
- function Wn(e) {
2172
- return e.type === "file_upload" ? ["IS_FILLED", "IS_EMPTY"] : e.type === "boolean" ? [
2173
- "EQUALS",
2174
- "NOT_EQUALS",
2175
- "IS_FILLED",
2176
- "IS_EMPTY"
2177
- ] : e.type === "date" || e.type === "datetime" || e.type === "money" || e.type === "number" ? [
2178
- "EQUALS",
2179
- "NOT_EQUALS",
2180
- "GREATER_THAN",
2181
- "GREATER_THAN_OR_EQUALS",
2182
- "LESS_THAN",
2183
- "LESS_THAN_OR_EQUALS",
2184
- "IS_FILLED",
2185
- "IS_EMPTY"
2186
- ] : [
2187
- "EQUALS",
2188
- "NOT_EQUALS",
2189
- "IS_FILLED",
2190
- "IS_EMPTY"
2191
- ];
2192
- }
2193
- function Gn(e) {
2194
- return e ? e.type === "boolean" ? [{
2195
- id: "true",
2196
- name: "是"
2197
- }, {
2198
- id: "false",
2199
- name: "否"
2200
- }] : e.type === "checkbox" || e.type === "radio" || e.type === "select" ? e.options.map((e) => ({
2201
- id: e.value,
2202
- name: e.label
2203
- })) : [] : [];
2204
- }
2205
- function Kn(e, t) {
2206
- if (!e) return;
2207
- let n = Wn(e);
2208
- return t && n.includes(t) ? t : n[0];
2209
- }
2210
- function qn(e, t, n) {
2211
- if (!e || !t || !Jn(t)) return;
2212
- let r = Gn(e);
2213
- return r.length === 0 || r.some((e) => e.id === n) ? n ?? void 0 : r[0]?.id;
2214
- }
2215
- function Jn(e) {
2216
- return ht.includes(e);
2217
- }
2218
- function Yn(e, t, n) {
2219
- if (!e || !t) return;
2220
- let r = K(t);
2221
- if (!Jn(t)) return `${e.label} ${r}`;
2222
- if (n) return `${e.label} ${r} ${Xn(e, n)}`;
2223
- }
2224
- function K(e) {
2225
- return mt.find((t) => t.id === e)?.name ?? e;
2226
- }
2227
- function Xn(e, t) {
2228
- return e.type === "boolean" ? t === "true" ? "是" : "否" : e.type === "checkbox" || e.type === "radio" || e.type === "select" ? q(e.options, t)?.label ?? t : t;
2229
- }
2230
- function q(e, t) {
2231
- return e.find((e) => e.value === t) ?? null;
2232
- }
2233
- function Zn(e, t, n) {
2234
- if (!e || !t) return;
2235
- let r = J(e.fieldKey);
2236
- if (t === "IS_FILLED") return `${r} != null && ${r} != ""`;
2237
- if (t === "IS_EMPTY") return `${r} == null || ${r} == ""`;
2238
- if (n) return `${r} ${Y(t)} ${Qn(e, n)}`;
2239
- }
2240
- function J(e) {
2241
- return /^[A-Za-z_][A-Za-z0-9_]*$/u.test(e) ? `form.${e}` : `form[${JSON.stringify(e)}]`;
2242
- }
2243
- function Y(e) {
2244
- return e === "EQUALS" ? "==" : e === "NOT_EQUALS" ? "!=" : e === "GREATER_THAN" ? ">" : e === "GREATER_THAN_OR_EQUALS" ? ">=" : e === "LESS_THAN" ? "<" : "<=";
2245
- }
2246
- function Qn(e, t) {
2247
- return e.type === "boolean" ? t === "true" ? "true" : "false" : (e.type === "money" || e.type === "number") && Number.isFinite(Number(t)) ? t : JSON.stringify(t);
2248
- }
2249
- function $n(e, t) {
2250
- if (e.data.label) return e.data.label;
2251
- if (X(e, t)) return er(e);
2252
- if (Z(e, t)) return "同時進行";
2253
- }
2254
- function er(e) {
2255
- return e.data.isDefault ? "其他情況" : "請設定條件";
2256
- }
2257
- function X(e, t) {
2258
- return t.some((t) => t.id === e.source && t.type === "exclusiveGateway");
2259
- }
2260
- function Z(e, t) {
2261
- return t.some((t) => t.id === e.source && t.type === "parallelGateway");
2262
- }
2263
- function tr(e) {
2264
- return e.type === "NOTIFY" && e.recipients.type === "DIRECT" ? e.recipients.memberIds : [];
2265
- }
2266
- function Q(e) {
2267
- return e instanceof Error ? e.message : "發生未知錯誤";
2268
- }
2269
- //#endregion
2270
- export { bt as TemplateDesignerView };
2271
-
2272
- //# sourceMappingURL=index.js.map
1
+ import { t as e } from "../../../chunks/designer-mOMxJ0Py.js";
2
+ export { e as TemplateDesignerView };