openxiangda 2.62.1 → 2.65.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 (197) hide show
  1. package/dist/browser/AuthoritativeSelector.d.ts +4 -3
  2. package/dist/browser/AuthoritativeSelector.d.ts.map +1 -1
  3. package/dist/browser/AuthoritativeSelector.js +25 -16
  4. package/dist/browser/AuthoritativeSelector.js.map +1 -1
  5. package/dist/browser/admin-contributions.d.ts +26 -0
  6. package/dist/browser/admin-contributions.d.ts.map +1 -1
  7. package/dist/browser/admin-contributions.js +30 -0
  8. package/dist/browser/admin-contributions.js.map +1 -1
  9. package/dist/browser/components/platform-fields/AttachmentFileList.d.ts +2 -1
  10. package/dist/browser/components/platform-fields/AttachmentFileList.d.ts.map +1 -1
  11. package/dist/browser/components/platform-fields/AttachmentFileList.js +3 -3
  12. package/dist/browser/components/platform-fields/AttachmentFileList.js.map +1 -1
  13. package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts +4 -2
  14. package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts.map +1 -1
  15. package/dist/browser/components/platform-fields/ResourceReferenceField.js +4 -4
  16. package/dist/browser/components/platform-fields/ResourceReferenceField.js.map +1 -1
  17. package/dist/browser/components/platform-fields/address-value.d.ts +2 -12
  18. package/dist/browser/components/platform-fields/address-value.d.ts.map +1 -1
  19. package/dist/browser/components/platform-fields/address-value.js +1 -69
  20. package/dist/browser/components/platform-fields/address-value.js.map +1 -1
  21. package/dist/browser/components/platform-fields/cascade-value.d.ts +2 -5
  22. package/dist/browser/components/platform-fields/cascade-value.d.ts.map +1 -1
  23. package/dist/browser/components/platform-fields/cascade-value.js +1 -46
  24. package/dist/browser/components/platform-fields/cascade-value.js.map +1 -1
  25. package/dist/browser/components/platform-fields/resource-query.d.ts +3 -19
  26. package/dist/browser/components/platform-fields/resource-query.d.ts.map +1 -1
  27. package/dist/browser/components/platform-fields/resource-query.js +2 -153
  28. package/dist/browser/components/platform-fields/resource-query.js.map +1 -1
  29. package/dist/browser/components/resource/GeneratedResourceCrud.d.ts +393 -2
  30. package/dist/browser/components/resource/GeneratedResourceCrud.d.ts.map +1 -1
  31. package/dist/browser/components/resource/GeneratedResourceCrud.js +148 -71
  32. package/dist/browser/components/resource/GeneratedResourceCrud.js.map +1 -1
  33. package/dist/browser/components/resource/GeneratedResourceForm.d.ts.map +1 -1
  34. package/dist/browser/components/resource/GeneratedResourceForm.js +7 -1
  35. package/dist/browser/components/resource/GeneratedResourceForm.js.map +1 -1
  36. package/dist/browser/components/resource/RecordDetailFrame.d.ts +4 -1
  37. package/dist/browser/components/resource/RecordDetailFrame.d.ts.map +1 -1
  38. package/dist/browser/components/resource/RecordDetailFrame.js +4 -2
  39. package/dist/browser/components/resource/RecordDetailFrame.js.map +1 -1
  40. package/dist/browser/components/resource/SurfaceFields.d.ts +4 -1
  41. package/dist/browser/components/resource/SurfaceFields.d.ts.map +1 -1
  42. package/dist/browser/components/resource/SurfaceFields.js +8 -8
  43. package/dist/browser/components/resource/SurfaceFields.js.map +1 -1
  44. package/dist/browser/components/resource/useResourceFormDrafts.d.ts.map +1 -1
  45. package/dist/browser/components/workflow/StandardWorkflowPages.d.ts +5 -2
  46. package/dist/browser/components/workflow/StandardWorkflowPages.d.ts.map +1 -1
  47. package/dist/browser/components/workflow/StandardWorkflowPages.js +107 -64
  48. package/dist/browser/components/workflow/StandardWorkflowPages.js.map +1 -1
  49. package/dist/browser/components/workflow/WorkflowBusinessStepEditor.d.ts +11 -0
  50. package/dist/browser/components/workflow/WorkflowBusinessStepEditor.d.ts.map +1 -0
  51. package/dist/browser/components/workflow/WorkflowBusinessStepEditor.js +55 -0
  52. package/dist/browser/components/workflow/WorkflowBusinessStepEditor.js.map +1 -0
  53. package/dist/browser/components/workflow/WorkflowBusinessStepRecoveryPanel.d.ts.map +1 -1
  54. package/dist/browser/components/workflow/WorkflowBusinessStepRecoveryPanel.js +13 -8
  55. package/dist/browser/components/workflow/WorkflowBusinessStepRecoveryPanel.js.map +1 -1
  56. package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.d.ts +18 -0
  57. package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.d.ts.map +1 -0
  58. package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.js +30 -0
  59. package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.js.map +1 -0
  60. package/dist/browser/components/workflow/WorkflowConditionEditor.d.ts +9 -0
  61. package/dist/browser/components/workflow/WorkflowConditionEditor.d.ts.map +1 -0
  62. package/dist/browser/components/workflow/WorkflowConditionEditor.js +33 -0
  63. package/dist/browser/components/workflow/WorkflowConditionEditor.js.map +1 -0
  64. package/dist/browser/components/workflow/WorkflowConditionExamples.d.ts +11 -0
  65. package/dist/browser/components/workflow/WorkflowConditionExamples.d.ts.map +1 -0
  66. package/dist/browser/components/workflow/WorkflowConditionExamples.js +52 -0
  67. package/dist/browser/components/workflow/WorkflowConditionExamples.js.map +1 -0
  68. package/dist/browser/components/workflow/WorkflowDesigner.d.ts +14 -0
  69. package/dist/browser/components/workflow/WorkflowDesigner.d.ts.map +1 -0
  70. package/dist/browser/components/workflow/WorkflowDesigner.js +586 -0
  71. package/dist/browser/components/workflow/WorkflowDesigner.js.map +1 -0
  72. package/dist/browser/components/workflow/WorkflowDesignerAssistant.d.ts +16 -0
  73. package/dist/browser/components/workflow/WorkflowDesignerAssistant.d.ts.map +1 -0
  74. package/dist/browser/components/workflow/WorkflowDesignerAssistant.js +75 -0
  75. package/dist/browser/components/workflow/WorkflowDesignerAssistant.js.map +1 -0
  76. package/dist/browser/components/workflow/WorkflowDiagram.d.ts +8 -2
  77. package/dist/browser/components/workflow/WorkflowDiagram.d.ts.map +1 -1
  78. package/dist/browser/components/workflow/WorkflowDiagram.js +6 -6
  79. package/dist/browser/components/workflow/WorkflowDiagram.js.map +1 -1
  80. package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.d.ts +19 -0
  81. package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.d.ts.map +1 -0
  82. package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.js +22 -0
  83. package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.js.map +1 -0
  84. package/dist/browser/components/workflow/WorkflowFlowCanvas.d.ts +7 -0
  85. package/dist/browser/components/workflow/WorkflowFlowCanvas.d.ts.map +1 -1
  86. package/dist/browser/components/workflow/WorkflowFlowCanvas.js +84 -23
  87. package/dist/browser/components/workflow/WorkflowFlowCanvas.js.map +1 -1
  88. package/dist/browser/components/workflow/WorkflowNodeCard.d.ts +2 -1
  89. package/dist/browser/components/workflow/WorkflowNodeCard.d.ts.map +1 -1
  90. package/dist/browser/components/workflow/WorkflowNodeCard.js +12 -10
  91. package/dist/browser/components/workflow/WorkflowNodeCard.js.map +1 -1
  92. package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.d.ts +13 -2
  93. package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.d.ts.map +1 -1
  94. package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.js +70 -23
  95. package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.js.map +1 -1
  96. package/dist/browser/components/workflow/WorkflowNotificationEditor.d.ts +20 -0
  97. package/dist/browser/components/workflow/WorkflowNotificationEditor.d.ts.map +1 -0
  98. package/dist/browser/components/workflow/WorkflowNotificationEditor.js +18 -0
  99. package/dist/browser/components/workflow/WorkflowNotificationEditor.js.map +1 -0
  100. package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.d.ts +10 -0
  101. package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.d.ts.map +1 -0
  102. package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.js +24 -0
  103. package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.js.map +1 -0
  104. package/dist/browser/components/workflow/WorkflowPeopleSourceEditor.d.ts +9 -0
  105. package/dist/browser/components/workflow/WorkflowPeopleSourceEditor.d.ts.map +1 -0
  106. package/dist/browser/components/workflow/WorkflowPeopleSourceEditor.js +13 -0
  107. package/dist/browser/components/workflow/WorkflowPeopleSourceEditor.js.map +1 -0
  108. package/dist/browser/components/workflow/WorkflowReminderEditor.d.ts +9 -0
  109. package/dist/browser/components/workflow/WorkflowReminderEditor.d.ts.map +1 -0
  110. package/dist/browser/components/workflow/WorkflowReminderEditor.js +23 -0
  111. package/dist/browser/components/workflow/WorkflowReminderEditor.js.map +1 -0
  112. package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.d.ts +8 -0
  113. package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.d.ts.map +1 -0
  114. package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.js +34 -0
  115. package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.js.map +1 -0
  116. package/dist/browser/components/workflow/WorkflowTaskForm.d.ts +1 -4
  117. package/dist/browser/components/workflow/WorkflowTaskForm.d.ts.map +1 -1
  118. package/dist/browser/components/workflow/WorkflowTaskForm.js +5 -6
  119. package/dist/browser/components/workflow/WorkflowTaskForm.js.map +1 -1
  120. package/dist/browser/components/workflow/workflow-approval-presentation.d.ts +13 -0
  121. package/dist/browser/components/workflow/workflow-approval-presentation.d.ts.map +1 -0
  122. package/dist/browser/components/workflow/workflow-approval-presentation.js +21 -0
  123. package/dist/browser/components/workflow/workflow-approval-presentation.js.map +1 -0
  124. package/dist/browser/components/workflow/workflow-designer-presentation.d.ts +13 -0
  125. package/dist/browser/components/workflow/workflow-designer-presentation.d.ts.map +1 -0
  126. package/dist/browser/components/workflow/workflow-designer-presentation.js +69 -0
  127. package/dist/browser/components/workflow/workflow-designer-presentation.js.map +1 -0
  128. package/dist/browser/components/workflow/workflow-flow-layout.d.ts +21 -11
  129. package/dist/browser/components/workflow/workflow-flow-layout.d.ts.map +1 -1
  130. package/dist/browser/components/workflow/workflow-flow-layout.js +28 -18
  131. package/dist/browser/components/workflow/workflow-flow-layout.js.map +1 -1
  132. package/dist/browser/components/workflow/workflow-operation-layout.d.ts +6 -0
  133. package/dist/browser/components/workflow/workflow-operation-layout.d.ts.map +1 -0
  134. package/dist/browser/components/workflow/workflow-operation-layout.js +17 -0
  135. package/dist/browser/components/workflow/workflow-operation-layout.js.map +1 -0
  136. package/dist/browser/components/workflow/workflow-parallel-layout.d.ts +37 -0
  137. package/dist/browser/components/workflow/workflow-parallel-layout.d.ts.map +1 -0
  138. package/dist/browser/components/workflow/workflow-parallel-layout.js +176 -0
  139. package/dist/browser/components/workflow/workflow-parallel-layout.js.map +1 -0
  140. package/dist/browser/platform-client.d.ts +71 -3
  141. package/dist/browser/platform-client.d.ts.map +1 -1
  142. package/dist/browser/platform-client.js +54 -4
  143. package/dist/browser/platform-client.js.map +1 -1
  144. package/dist/browser/record-detail.css +4 -3
  145. package/dist/browser/styles.css +386 -1
  146. package/dist/browser/workflow-approval.css +205 -0
  147. package/dist/browser/workflow-operation-input.d.ts.map +1 -1
  148. package/dist/browser/workflow-operation-input.js +1 -0
  149. package/dist/browser/workflow-operation-input.js.map +1 -1
  150. package/dist/config.d.ts +1 -0
  151. package/dist/config.d.ts.map +1 -1
  152. package/dist/core.d.ts +1 -0
  153. package/dist/core.d.ts.map +1 -1
  154. package/dist/core.js +1 -0
  155. package/dist/core.js.map +1 -1
  156. package/dist/react.d.ts +1 -0
  157. package/dist/react.d.ts.map +1 -1
  158. package/dist/react.js +1 -0
  159. package/dist/react.js.map +1 -1
  160. package/dist/resource.d.ts +22 -0
  161. package/dist/resource.d.ts.map +1 -0
  162. package/dist/resource.js +18 -0
  163. package/dist/resource.js.map +1 -0
  164. package/documentation/AGENTS.md +1 -1
  165. package/documentation/application-templates.md +37 -0
  166. package/documentation/field-components.md +10 -1
  167. package/documentation/frontend.md +14 -4
  168. package/documentation/getting-started.md +9 -7
  169. package/documentation/manifest.json +13 -7
  170. package/documentation/reference/cli.md +2 -0
  171. package/documentation/reference/mcp.md +238 -0
  172. package/documentation/workflow-events.md +33 -0
  173. package/package.json +26 -26
  174. package/releases/2.64.0.json +30 -0
  175. package/releases/2.65.0.json +30 -0
  176. package/skills/manifest.json +1 -1
  177. package/skills/openxiangda-v2/SKILL.md +7 -7
  178. package/skills/openxiangda-v2/references/application-templates.md +37 -0
  179. package/skills/openxiangda-v2/references/cli.md +2 -0
  180. package/skills/openxiangda-v2/references/field-components.md +10 -1
  181. package/skills/openxiangda-v2/references/frontend.md +14 -4
  182. package/skills/openxiangda-v2/references/getting-started.md +9 -7
  183. package/skills/openxiangda-v2/references/mcp.md +238 -0
  184. package/skills/openxiangda-v2/references/workflow-events.md +33 -0
  185. package/releases/2.20.1.json +0 -30
  186. package/releases/2.20.2.json +0 -30
  187. package/releases/2.20.3.json +0 -29
  188. package/releases/2.20.4.json +0 -30
  189. package/releases/2.31.5.json +0 -33
  190. package/releases/2.59.3.json +0 -36
  191. package/releases/2.60.0.json +0 -38
  192. package/releases/2.61.0.json +0 -39
  193. package/releases/2.61.1.json +0 -37
  194. package/releases/2.61.2.json +0 -32
  195. package/releases/2.61.3.json +0 -33
  196. package/releases/2.62.0.json +0 -40
  197. package/releases/2.62.1.json +0 -34
@@ -0,0 +1,586 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { workflowAuthoringCatalog, workflowCanvasBindingKey, createWorkflowHumanNode, pruneWorkflowCanvasBindings, validateWorkflowBusinessSteps } from 'openxiangda-contracts/browser';
3
+ import { WorkflowBusinessStepEditor } from './WorkflowBusinessStepEditor';
4
+ import { WorkflowParallelConfigurationEditor } from './WorkflowParallelConfigurationEditor.js';
5
+ import { WorkflowReminderEditor } from './WorkflowReminderEditor.js';
6
+ import { WorkflowNotificationEditor } from './WorkflowNotificationEditor.js';
7
+ import { WorkflowReturnPolicyEditor } from './WorkflowReturnPolicyEditor.js';
8
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
+ import { Alert, App, Button, Checkbox, Collapse, Drawer, Input, Modal, Popconfirm, Radio, Segmented, Select, Skeleton, Space, Spin, Table, Tag, Tooltip } from 'antd';
10
+ import { ArrowLeftOutlined, CheckCircleOutlined, CloseOutlined, HistoryOutlined, MenuFoldOutlined, MenuUnfoldOutlined, RedoOutlined, RobotOutlined, SafetyOutlined, UndoOutlined, UserOutlined, FormOutlined, CodeOutlined, CopyOutlined, BranchesOutlined, BellOutlined, PlayCircleOutlined } from '@ant-design/icons';
11
+ import { workflowReturnTargets, formatWorkflowSupervisorChain, isWorkflowPlatformNotify, WORKFLOW_PLATFORM_NOTIFY_HANDLER, WORKFLOW_PLATFORM_NOTIFY_INPUT_SCHEMA, WORKFLOW_PLATFORM_NOTIFY_OUTPUT_SCHEMA, editWorkflowDesignerDefinition, projectWorkflowGraph, validateWorkflowDesignerDocument, workflowDesignerVariables } from 'openxiangda-contracts/browser';
12
+ import { OpenXiangdaPlatformRequestError, loadWorkflowDesignerDraft, loadWorkflowNodeConfigurations, loadApplicationAdministrationContext, saveWorkflowDesignerDraft, previewWorkflowDesignerPublication, publishWorkflowDesigner, loadWorkflowDesignerPublication, listWorkflowDesignerPublications, restoreWorkflowDesignerVersion, controlWorkflowDesignerPublication, searchWorkflowDesignerHoldCandidates } from '../../platform-client';
13
+ import { createBrowserUuid } from '../../uuid';
14
+ import { WorkflowDiagram } from './WorkflowDiagram';
15
+ import { workflowDesignerDisplayGraph, workflowDesignerOutlineRows, workflowDesignerStartId } from './workflow-designer-presentation';
16
+ import { WorkflowDraftHandlingEditor } from './WorkflowDraftHandlingEditor';
17
+ import { WorkflowNodeConfigurationEditor } from './WorkflowNodeConfigurationEditor';
18
+ import { WorkflowDesignerAssistant } from './WorkflowDesignerAssistant';
19
+ import { defaultWorkflowCondition } from './WorkflowConditionEditor';
20
+ import { WorkflowConditionConfigurationEditor } from './WorkflowConditionConfigurationEditor';
21
+ const kinds = { handle: '办理节点', approval: '审批节点', condition: '条件分支', parallel: '并行分支', join: '汇合', cc: '抄送', action: '已发布业务步骤', correction: '补正', end: '结束' };
22
+ const id = () => `node_${createBrowserUuid().replaceAll('-', '').slice(0, 12)}`;
23
+ const outcomeLabels = { eligible: '可更新', migrated: '已更新', deferred: '等待步骤完成', excepted: '需单独处理', held: '保留原版本', failed: '更新失败', completed: '已结束', superseded: '已替代' };
24
+ const refused = (error) => error instanceof OpenXiangdaPlatformRequestError && error.status >= 400 && error.status < 500;
25
+ const canonical = (value) => Array.isArray(value) ? value.map(canonical) : value && typeof value === 'object' ? Object.fromEntries(Object.keys(value).sort().map(key => [key, canonical(value[key])])) : value;
26
+ const same = (left, right) => JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
27
+ /** Canonical authoring. The graph is a projection; coordinates never become executable state. */
28
+ export function WorkflowDesigner({ workflowCode, onPublished, onDirtyChange, onStateChange, onBack }) {
29
+ const { message } = App.useApp();
30
+ const [draft, setDraft] = useState();
31
+ const [definition, setDefinition] = useState();
32
+ const [stepInputInvalid, setStepInputInvalid] = useState(false);
33
+ const [reminderDirty, setReminderDirty] = useState(false);
34
+ const [binding, setBinding] = useState();
35
+ const [nativeHeadRevision, setNativeHeadRevision] = useState();
36
+ const [configurations, setConfigurations] = useState();
37
+ const [selected, setSelected] = useState('');
38
+ const [selectedEdge, setSelectedEdge] = useState();
39
+ const [publishedView, setPublishedView] = useState(false);
40
+ const [outline, setOutline] = useState(true);
41
+ const [detailInspector, setDetailInspector] = useState(true);
42
+ const [inspector, setInspector] = useState(true);
43
+ const [narrow, setNarrow] = useState(() => typeof matchMedia !== 'undefined' && matchMedia('(max-width: 899px)').matches);
44
+ const inspectorElement = useRef(null);
45
+ useEffect(() => { const media = matchMedia('(max-width: 899px)'); const update = () => setNarrow(media.matches); media.addEventListener('change', update); return () => media.removeEventListener('change', update); }, []);
46
+ const [liveState, setLiveState] = useState({ dirty: false, busy: false, unknown: false });
47
+ const leaveHandling = useRef(undefined);
48
+ const handlingGuardChanged = useCallback((guard) => { leaveHandling.current = guard; }, []);
49
+ const handlingStateChanged = useCallback((state) => setLiveState(state), []);
50
+ const [outlineKeyword, setOutlineKeyword] = useState('');
51
+ const [checksOpen, setChecksOpen] = useState(false);
52
+ const [structureKeys, setStructureKeys] = useState([]);
53
+ const attemptedAutosave = useRef(undefined);
54
+ const [error, setError] = useState();
55
+ const [busy, setBusy] = useState(false);
56
+ const [history, setHistory] = useState([]);
57
+ const [future, setFuture] = useState([]);
58
+ const [insert, setInsert] = useState();
59
+ const [template, setTemplate] = useState('condition');
60
+ const [nodeTitle, setNodeTitle] = useState('');
61
+ const [assistantContext, setAssistantContext] = useState('');
62
+ const [assistantOpen, setAssistantOpen] = useState(false);
63
+ const [assistantState, setAssistantState] = useState({ busy: false, unknown: false });
64
+ const [versionsOpen, setVersionsOpen] = useState(false);
65
+ const [versions, setVersions] = useState([]);
66
+ const [publication, setPublication] = useState(false);
67
+ const [holdCandidates, setHoldCandidates] = useState([]);
68
+ const [preview, setPreview] = useState();
69
+ const [scope, setScope] = useState('running_and_new');
70
+ const [releaseIds, setReleaseIds] = useState([]);
71
+ const [releaseReason, setReleaseReason] = useState('');
72
+ const [reason, setReason] = useState('');
73
+ const [holdNodeIds, setHoldNodeIds] = useState([]);
74
+ const [holdIds, setHoldIds] = useState([]);
75
+ const [holdReason, setHoldReason] = useState('');
76
+ const [acknowledge, setAcknowledge] = useState(false);
77
+ const [receipt, setReceipt] = useState();
78
+ const frozenSave = useRef(undefined);
79
+ const frozenPublish = useRef(undefined);
80
+ const frozenAux = useRef(undefined);
81
+ const alive = useRef(true);
82
+ const load = useCallback(async () => {
83
+ const [value, configuration, context] = await Promise.all([loadWorkflowDesignerDraft(workflowCode), loadWorkflowNodeConfigurations(workflowCode), loadApplicationAdministrationContext()]);
84
+ if (context.headRevision == null)
85
+ throw new Error('当前应用没有可用的办理配置版本');
86
+ if (!alive.current)
87
+ return;
88
+ setDraft(value);
89
+ setDefinition(value.definition);
90
+ setBinding(value.binding);
91
+ setConfigurations(configuration);
92
+ setNativeHeadRevision(context.headRevision);
93
+ setSelected(value.definition.startAt);
94
+ setHistory([]);
95
+ setFuture([]);
96
+ setError(undefined);
97
+ }, [workflowCode]);
98
+ useEffect(() => { alive.current = true; void load().catch(error => setError(String(error.message))); return () => { alive.current = false; }; }, [load]);
99
+ const refreshHandling = async () => {
100
+ const [configuration, context] = await Promise.all([loadWorkflowNodeConfigurations(workflowCode), loadApplicationAdministrationContext()]);
101
+ if (context.headRevision == null)
102
+ throw new Error('当前应用没有可用的办理配置版本');
103
+ setConfigurations(configuration);
104
+ setNativeHeadRevision(context.headRevision);
105
+ };
106
+ const dirty = !!draft && !!definition && (!same(draft.definition, definition) || !same(draft.binding, binding) || stepInputInvalid || reminderDirty);
107
+ useEffect(() => { const unknown = !!frozenSave.current || !!frozenPublish.current || !!frozenAux.current || assistantState.unknown || liveState.unknown; onDirtyChange?.(dirty || liveState.dirty || unknown); onStateChange?.({ dirty: dirty || liveState.dirty, busy: busy || assistantState.busy || liveState.busy, unknown }); }, [dirty, busy, assistantState, liveState, onDirtyChange, onStateChange]);
108
+ useEffect(() => { const guard = (event) => { if (dirty || frozenSave.current || frozenPublish.current || frozenAux.current || assistantState.unknown) {
109
+ event.preventDefault();
110
+ event.returnValue = '';
111
+ } }; addEventListener('beforeunload', guard); return () => removeEventListener('beforeunload', guard); }, [dirty, assistantState.unknown]);
112
+ useEffect(() => {
113
+ if (!receipt || receipt.status !== 'running' || publication)
114
+ return;
115
+ let active = true;
116
+ const poll = setInterval(() => { void loadWorkflowDesignerPublication(workflowCode, receipt.publicationId).then(value => { if (active)
117
+ setReceipt(value); }, () => { }); }, 3000);
118
+ return () => { active = false; clearInterval(poll); };
119
+ }, [workflowCode, receipt?.publicationId, receipt?.status, publication]);
120
+ const shown = publishedView ? draft?.publishedDefinition : definition;
121
+ const graph = useMemo(() => shown ? projectWorkflowGraph(shown, 'draft') : undefined, [shown]);
122
+ const displayGraph = useMemo(() => {
123
+ const activeReturn = structureKeys.includes('return') ? shown?.nodes[selected] : undefined;
124
+ return graph ? workflowDesignerDisplayGraph(graph, activeReturn?.id, activeReturn && ['approval', 'handle'].includes(activeReturn.kind) ? workflowReturnTargets(activeReturn) : []) : undefined;
125
+ }, [graph, structureKeys, selected, shown]);
126
+ const outlineNodes = useMemo(() => displayGraph ? workflowDesignerOutlineRows(displayGraph) : [], [displayGraph]);
127
+ useEffect(() => { if (shown && selected !== workflowDesignerStartId && !shown.nodes[selected])
128
+ setSelected(shown.startAt); }, [shown, selected]);
129
+ const catalog = useMemo(() => draft?.capabilities || (draft ? workflowAuthoringCatalog(draft.publishedDefinition, draft.publishedBinding) : undefined), [draft]);
130
+ const variables = useMemo(() => definition ? workflowDesignerVariables(definition) : [], [definition]);
131
+ const errors = useMemo(() => definition ? [...validateWorkflowDesignerDocument(definition), ...validateWorkflowBusinessSteps(definition), ...Object.values(definition.nodes).flatMap(node => {
132
+ if (!('binding' in node))
133
+ return [];
134
+ const entry = binding?.bindings[node.binding];
135
+ return !entry || entry.provider === 'fixed_users' && !entry.users?.length || entry.provider === 'app_role' && !entry.roleCode && !entry.roleCodes?.length ? [`WORKFLOW_DESIGNER_PEOPLE_REQUIRED:${node.id}`] : [];
136
+ })] : [], [definition, binding]);
137
+ const node = shown?.nodes[selected];
138
+ const liveNode = configurations?.nodes.find(item => item.nodeId === selected);
139
+ const disabled = busy || assistantState.busy || assistantState.unknown || publishedView || !!frozenSave.current || !!frozenPublish.current || !!frozenAux.current;
140
+ const mutate = (next, nextBinding = binding) => {
141
+ if (!definition || !binding || !nextBinding || disabled)
142
+ return;
143
+ setHistory(current => {
144
+ const bounded = [...current, { definition, binding }].slice(-25);
145
+ while (bounded.length > 1 && bounded.reduce((bytes, item) => bytes + JSON.stringify(item).length, 0) > 4 * 1024 * 1024)
146
+ bounded.shift();
147
+ return bounded;
148
+ });
149
+ setFuture([]);
150
+ setDefinition(next);
151
+ setBinding(pruneWorkflowCanvasBindings(next, nextBinding, draft.publishedBinding));
152
+ setError(undefined);
153
+ };
154
+ const patch = (patch) => { if (definition && node)
155
+ mutate(editWorkflowDesignerDefinition(definition, { type: 'node', nodeId: node.id, patch })); };
156
+ const save = async (quiet = false) => {
157
+ if (!draft || !definition)
158
+ return undefined;
159
+ if (reminderDirty && !frozenSave.current) {
160
+ message.warning('请先确定或取消办理提醒的修改。');
161
+ return undefined;
162
+ }
163
+ if (stepInputInvalid && !frozenSave.current) {
164
+ setError('业务步骤固定值不是有效 JSON,请修正后再保存。');
165
+ return undefined;
166
+ }
167
+ setBusy(true);
168
+ try {
169
+ frozenSave.current ||= { expectedRevision: draft.revision, expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), definition, binding: binding };
170
+ const saved = await saveWorkflowDesignerDraft(workflowCode, frozenSave.current);
171
+ frozenSave.current = undefined;
172
+ setDraft(saved);
173
+ setDefinition(saved.definition);
174
+ setBinding(saved.binding);
175
+ setError(undefined);
176
+ if (!quiet)
177
+ message.success('流程草稿已保存');
178
+ return saved;
179
+ }
180
+ catch (error) {
181
+ if (refused(error))
182
+ frozenSave.current = undefined;
183
+ setError(`${String(error.message)}${refused(error) ? '。修改已保留,可修正后再次保存。' : '。结果待确认,请重试原保存请求。'}`);
184
+ return undefined;
185
+ }
186
+ finally {
187
+ setBusy(false);
188
+ }
189
+ };
190
+ const autosave = useRef(save);
191
+ autosave.current = save;
192
+ useEffect(() => {
193
+ if (!dirty || !definition || stepInputInvalid || reminderDirty || busy || publishedView || frozenSave.current || frozenPublish.current || frozenAux.current || attemptedAutosave.current === JSON.stringify({ definition, binding }))
194
+ return;
195
+ let timer;
196
+ const persist = () => {
197
+ if (inspectorElement.current?.querySelector('[role="combobox"][aria-expanded="true"]')) {
198
+ timer = setTimeout(persist, 300);
199
+ return;
200
+ }
201
+ attemptedAutosave.current = JSON.stringify({ definition, binding });
202
+ void autosave.current(true);
203
+ };
204
+ timer = setTimeout(persist, 900);
205
+ return () => clearTimeout(timer);
206
+ }, [dirty, definition, binding, busy, publishedView, stepInputInvalid, reminderDirty]);
207
+ const inspectorReady = () => {
208
+ if (stepInputInvalid) {
209
+ message.warning('业务步骤固定值不是有效 JSON,请先修正,或切换此输入来源以放弃该值。');
210
+ return false;
211
+ }
212
+ if (reminderDirty) {
213
+ message.warning('请先确定或取消办理提醒的修改。');
214
+ return false;
215
+ }
216
+ return true;
217
+ };
218
+ const closeInspector = () => { if (!inspectorReady())
219
+ return; const close = () => setInspector(false); if (leaveHandling.current)
220
+ leaveHandling.current(close);
221
+ else
222
+ close(); };
223
+ const selectNode = (value, edgeId) => {
224
+ if (value !== selected && !inspectorReady())
225
+ return;
226
+ const next = () => { setSelected(value); setSelectedEdge(edgeId); if (value !== selected)
227
+ setStructureKeys([]); setInspector(value !== workflowDesignerStartId); };
228
+ if (value !== selected && leaveHandling.current)
229
+ leaveHandling.current(next);
230
+ else
231
+ next();
232
+ };
233
+ const selectEdge = (value) => {
234
+ const edge = displayGraph?.edges.find(edge => edge.id === value);
235
+ if (edge && ['branch', 'default'].includes(edge.kind))
236
+ selectNode(edge.from, value);
237
+ else
238
+ setSelectedEdge(value);
239
+ };
240
+ useEffect(() => {
241
+ if (!narrow || !inspector)
242
+ return;
243
+ const previous = document.activeElement;
244
+ const element = inspectorElement.current;
245
+ const keydown = (event) => {
246
+ if (!element || !element.contains(event.target) || event.defaultPrevented)
247
+ return;
248
+ if (event.key === 'Escape' && ![...element.querySelectorAll('[aria-expanded="true"]')].some(item => item.getClientRects().length)) {
249
+ event.preventDefault();
250
+ closeInspector();
251
+ }
252
+ if (event.key === 'Tab') {
253
+ const focusable = [...element.querySelectorAll('button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex="0"]')].filter(item => item.getClientRects().length);
254
+ const target = event.shiftKey && document.activeElement === focusable[0] ? focusable.at(-1) : !event.shiftKey && document.activeElement === focusable.at(-1) ? focusable[0] : undefined;
255
+ if (target) {
256
+ event.preventDefault();
257
+ target.focus();
258
+ }
259
+ }
260
+ };
261
+ element?.querySelector('button')?.focus();
262
+ document.addEventListener('keydown', keydown);
263
+ return () => { document.removeEventListener('keydown', keydown); previous?.focus({ preventScroll: true }); };
264
+ }, [narrow, inspector, stepInputInvalid, reminderDirty]);
265
+ const switchVersion = (value) => {
266
+ if (!inspectorReady())
267
+ return;
268
+ const next = () => { setPublishedView(value === 'published'); };
269
+ if (leaveHandling.current)
270
+ leaveHandling.current(next);
271
+ else
272
+ next();
273
+ };
274
+ const goBack = () => {
275
+ if (!inspectorReady())
276
+ return;
277
+ const next = () => { if (dirty) {
278
+ void save(true).then(saved => { if (saved) {
279
+ if (onBack)
280
+ onBack();
281
+ else {
282
+ const url = new URL(location.href);
283
+ url.searchParams.delete('design');
284
+ location.assign(url.href);
285
+ }
286
+ } });
287
+ return;
288
+ } if (onBack)
289
+ onBack();
290
+ else {
291
+ const url = new URL(location.href);
292
+ url.searchParams.delete('design');
293
+ location.assign(url.href);
294
+ } };
295
+ if (leaveHandling.current)
296
+ leaveHandling.current(next);
297
+ else
298
+ next();
299
+ };
300
+ const holds = () => holdIds.length || holdNodeIds.length ? [{ instanceIds: holdIds, nodeIds: holdNodeIds, reason: holdReason.trim() }] : [];
301
+ const check = async (value = draft, selectedHolds = holds()) => {
302
+ if (!value)
303
+ return;
304
+ setBusy(true);
305
+ setPreview(undefined);
306
+ try {
307
+ const result = await previewWorkflowDesignerPublication(workflowCode, { expectedRevision: value.revision, holds: selectedHolds });
308
+ setPreview(result);
309
+ setHoldCandidates(result.items);
310
+ setError(undefined);
311
+ }
312
+ catch (error) {
313
+ setError(String(error.message));
314
+ }
315
+ finally {
316
+ setBusy(false);
317
+ }
318
+ };
319
+ const openPublication = async () => {
320
+ const saved = dirty || frozenSave.current ? await save() : draft;
321
+ if (!saved)
322
+ return;
323
+ setScope('running_and_new');
324
+ setHoldIds([]);
325
+ setHoldNodeIds([]);
326
+ setHoldReason('');
327
+ setReason('');
328
+ setAcknowledge(false);
329
+ setPublication(true);
330
+ setPreview(undefined);
331
+ await check(saved, []);
332
+ };
333
+ const publish = async () => {
334
+ if (!draft || !reason.trim() || scope === 'running_and_new' && (holdIds.length || holdNodeIds.length) && !holdReason.trim())
335
+ return;
336
+ setBusy(true);
337
+ try {
338
+ frozenPublish.current ||= { expectedRevision: draft.revision, expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), reason: reason.trim(), scope, holds: scope === 'running_and_new' ? holds() : [], acknowledgeExceptions: acknowledge };
339
+ const result = await publishWorkflowDesigner(workflowCode, frozenPublish.current);
340
+ frozenPublish.current = undefined;
341
+ setReceipt(result);
342
+ setPublication(false);
343
+ await load();
344
+ onPublished?.(result);
345
+ message.success('流程版本已发布并启用');
346
+ }
347
+ catch (error) {
348
+ if (refused(error))
349
+ frozenPublish.current = undefined;
350
+ setError(`${String(error.message)}${refused(error) ? '。草稿已保留。' : '。结果待确认,重试将使用原发布请求。'}`);
351
+ }
352
+ finally {
353
+ setBusy(false);
354
+ }
355
+ };
356
+ const openAssistant = async () => {
357
+ if (disabled || !inspectorReady())
358
+ return;
359
+ if (dirty || frozenSave.current) {
360
+ const saved = await save();
361
+ if (!saved)
362
+ return;
363
+ }
364
+ setInspector(true);
365
+ setAssistantOpen(true);
366
+ };
367
+ const showVersions = async () => {
368
+ setVersionsOpen(true);
369
+ setBusy(true);
370
+ try {
371
+ setVersions(await listWorkflowDesignerPublications(workflowCode));
372
+ }
373
+ catch (error) {
374
+ setError(String(error.message));
375
+ }
376
+ finally {
377
+ setBusy(false);
378
+ }
379
+ };
380
+ const retryAux = async () => {
381
+ if (!frozenAux.current)
382
+ return;
383
+ setBusy(true);
384
+ try {
385
+ await frozenAux.current();
386
+ frozenAux.current = undefined;
387
+ setError(undefined);
388
+ }
389
+ catch (error) {
390
+ if (refused(error))
391
+ frozenAux.current = undefined;
392
+ setError(`${String(error.message)}${refused(error) ? '。输入已保留。' : '。结果待确认,请重试原操作。'}`);
393
+ }
394
+ finally {
395
+ setBusy(false);
396
+ }
397
+ };
398
+ const restore = async (version) => {
399
+ if (!draft || frozenAux.current)
400
+ return;
401
+ const input = { version, expectedRevision: draft.revision, expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid() };
402
+ frozenAux.current = async () => {
403
+ const restored = await restoreWorkflowDesignerVersion(workflowCode, input);
404
+ setDraft(restored);
405
+ setDefinition(restored.definition);
406
+ setBinding(restored.binding);
407
+ setHistory([]);
408
+ setFuture([]);
409
+ setVersionsOpen(false);
410
+ message.success('历史版本已恢复到草稿,检查后可发布');
411
+ };
412
+ await retryAux();
413
+ };
414
+ const control = async (action) => {
415
+ if (!receipt || !draft || frozenAux.current)
416
+ return;
417
+ const publicationId = receipt.publicationId;
418
+ const input = { expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), action, reason: action === 'pause' ? '管理员暂停更新' : action === 'retry_failed' ? '管理员重试更新失败的申请' : '管理员继续更新' };
419
+ frozenAux.current = async () => { setReceipt(await controlWorkflowDesignerPublication(workflowCode, publicationId, input)); };
420
+ await retryAux();
421
+ };
422
+ const searchHolds = async (keyword) => {
423
+ try {
424
+ setHoldCandidates(await searchWorkflowDesignerHoldCandidates(workflowCode, keyword));
425
+ }
426
+ catch (error) {
427
+ setError(String(error.message));
428
+ }
429
+ };
430
+ const releaseHolds = async () => {
431
+ if (!receipt || !draft || !releaseIds.length || !releaseReason.trim() || frozenAux.current)
432
+ return;
433
+ const publicationId = receipt.publicationId;
434
+ const input = { expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), action: 'release_holds', instanceIds: releaseIds, reason: releaseReason.trim() };
435
+ frozenAux.current = async () => { setReceipt(await controlWorkflowDesignerPublication(workflowCode, publicationId, input)); setReleaseIds([]); setReleaseReason(''); };
436
+ await retryAux();
437
+ };
438
+ const insertNode = (chosenTemplate = template, chosenTitle = nodeTitle, edgeId = insert) => {
439
+ const edge = displayGraph?.edges.find(item => item.id === edgeId);
440
+ if (!edge || !definition || !chosenTitle.trim())
441
+ return;
442
+ const nodeId = id();
443
+ if (chosenTemplate === 'parallel') {
444
+ const joinId = id(), branches = [{ id: 'branch_1', title: '分支 1' }, { id: 'branch_2', title: '分支 2' }];
445
+ try {
446
+ const next = edge.from === workflowDesignerStartId ? { ...definition, startAt: nodeId, nodes: { ...definition.nodes,
447
+ [nodeId]: { id: nodeId, kind: 'parallel', title: chosenTitle.trim(), join: joinId, branches: branches.map(branch => ({ ...branch, target: joinId })) },
448
+ [joinId]: { id: joinId, kind: 'join', title: '全部完成后继续', parallel: nodeId, next: edge.to } } } :
449
+ editWorkflowDesignerDefinition(definition, { type: 'insert_parallel', from: edge.from, target: edge.to, id: nodeId, joinId, title: chosenTitle.trim(), branches, edge: edge.kind === 'branch' ? (edge.priority || 1) - 1 : edge.kind === 'default' ? 'default' : edge.kind });
450
+ mutate(next);
451
+ setSelected(nodeId);
452
+ setInspector(true);
453
+ setStructureKeys([]);
454
+ setInsert(undefined);
455
+ }
456
+ catch (failure) {
457
+ message.error(failure instanceof Error ? failure.message : '并行分支添加失败');
458
+ }
459
+ return;
460
+ }
461
+ let next;
462
+ let nextBinding = binding;
463
+ let insertionDefinition = definition;
464
+ if (chosenTemplate === 'condition')
465
+ next = { id: nodeId, kind: 'condition', title: chosenTitle.trim(), branches: [{ label: '条件 1', when: defaultWorkflowCondition(variables), target: edge.to }], otherwise: edge.to };
466
+ else if (chosenTemplate === 'platform_notify')
467
+ next = { id: nodeId, kind: 'action', title: chosenTitle.trim(), next: edge.to,
468
+ handler: { code: WORKFLOW_PLATFORM_NOTIFY_HANDLER, version: 1, mode: 'reconciled-effect' },
469
+ inputSchema: structuredClone(WORKFLOW_PLATFORM_NOTIFY_INPUT_SCHEMA), outputSchema: structuredClone(WORKFLOW_PLATFORM_NOTIFY_OUTPUT_SCHEMA),
470
+ inputs: { text: { source: 'literal', value: '请关注此申请的最新进展。' } }, notification: { template: 'workflow_message', recipients: { provider: 'initiator' } } };
471
+ else if (['approval', 'handle', 'cc'].includes(chosenTemplate)) {
472
+ let reject = Object.values(definition.nodes).find(node => node.kind === 'end' && node.outcome === 'rejected')?.id;
473
+ if (chosenTemplate === 'approval' && !reject) {
474
+ reject = id();
475
+ insertionDefinition = { ...definition, nodes: { ...definition.nodes, [reject]: { id: reject, kind: 'end', title: '申请已拒绝', outcome: 'rejected' } } };
476
+ }
477
+ next = createWorkflowHumanNode(nodeId, chosenTemplate, chosenTitle.trim(), edge.to, undefined, catalog?.taskPages, reject);
478
+ nextBinding = { ...binding, bindings: { ...binding.bindings, [workflowCanvasBindingKey(nodeId)]: { provider: 'fixed_users', users: [] } } };
479
+ }
480
+ else if (chosenTemplate === 'action') {
481
+ const step = catalog?.steps[0];
482
+ if (!step) {
483
+ message.info('应用还没有发布可选业务步骤,请通过 AI 助手准备新能力。');
484
+ setAssistantContext('当前应用没有可选业务步骤。请提出需要由应用开发新增并发布的步骤能力方案,不要假设未发布代码已经可以执行。');
485
+ setAssistantOpen(true);
486
+ setInspector(true);
487
+ return;
488
+ }
489
+ next = { ...structuredClone(step), id: nodeId, kind: 'action', next: edge.to, inputs: {} };
490
+ }
491
+ else {
492
+ const source = draft?.publishedDefinition.nodes[chosenTemplate];
493
+ if (!source || !['approval', 'handle', 'cc', 'action'].includes(source.kind))
494
+ return;
495
+ if (source.kind === 'approval' || source.kind === 'handle' || source.kind === 'cc') {
496
+ next = createWorkflowHumanNode(nodeId, source.kind, chosenTitle.trim(), edge.to, 'taskPageCode' in source ? source.taskPageCode : undefined, catalog.taskPages, source.kind === 'approval' ? source.onReject : undefined);
497
+ if (next.kind === 'approval' || next.kind === 'handle')
498
+ next.mode = source.kind === 'approval' || source.kind === 'handle' ? source.mode : 'single';
499
+ nextBinding = { ...binding, bindings: { ...binding.bindings, [workflowCanvasBindingKey(nodeId)]: structuredClone(draft.publishedBinding.bindings[source.binding]) } };
500
+ }
501
+ else if (source.kind === 'action')
502
+ next = { ...structuredClone(source), id: nodeId, title: chosenTitle.trim(), next: edge.to };
503
+ else
504
+ return;
505
+ }
506
+ try {
507
+ mutate(edge.from === workflowDesignerStartId ? { ...insertionDefinition, startAt: next.id, nodes: { ...insertionDefinition.nodes, [next.id]: next } } : editWorkflowDesignerDefinition(insertionDefinition, { type: 'insert', from: edge.from, target: edge.to, node: next, edge: edge.kind === 'branch' ? (edge.priority || 1) - 1 : edge.kind === 'default' ? 'default' : edge.kind }), nextBinding);
508
+ setSelected(nodeId);
509
+ setInspector(true);
510
+ setStructureKeys([]);
511
+ setInsert(undefined);
512
+ }
513
+ catch (error) {
514
+ setError(String(error.message));
515
+ }
516
+ };
517
+ if (!draft || !definition || !graph || nativeHeadRevision == null)
518
+ return error ? _jsx(Alert, { type: "error", title: "\u6D41\u7A0B\u8BBE\u8BA1\u672A\u80FD\u8F7D\u5165", description: error, action: _jsx(Button, { onClick: () => void load().catch(error => setError(String(error.message))), children: "\u91CD\u65B0\u8F7D\u5165" }) }) : _jsx(Skeleton, { active: true });
519
+ const targets = Object.values(definition.nodes).filter(item => item.id !== selected).map(item => ({ value: item.id, label: item.title || item.id }));
520
+ const typeIcons = { approval: UserOutlined, handle: FormOutlined, condition: BranchesOutlined, parallel: BranchesOutlined, join: CheckCircleOutlined, action: CodeOutlined, cc: CopyOutlined, correction: FormOutlined, end: CheckCircleOutlined, start: PlayCircleOutlined };
521
+ const NodeIcon = isWorkflowPlatformNotify(node) ? BellOutlined : typeIcons[node?.kind] || CodeOutlined;
522
+ const summaries = Object.fromEntries((configurations?.nodes || []).map(item => {
523
+ const binding = item.effective.binding;
524
+ const source = binding?.provider === 'fixed_users' ? `指定成员:${(binding.users || []).map(user => configurations?.principals.users.find(person => person.value === user)?.label || '成员').join('、')}` : ['app_role', 'app_role_in_scope'].includes(binding?.provider || '') ? `应用角色:${(binding?.roleCodes || (binding?.roleCode ? [binding.roleCode] : [])).map(code => configurations?.principals.roles.find(role => role.code === code)?.name || '已配置角色').join('、')}` : binding?.provider === 'supervisor_chain' ? formatWorkflowSupervisorChain(binding) : '按已配置的人员规则';
525
+ const mode = { single: '单人', any: '或签', all: '会签', sequence: '依次审批' }[item.effective.mode || ''] || '';
526
+ return [item.nodeId, `${mode}${mode ? ' · ' : ''}${source}`];
527
+ }));
528
+ const human = node?.kind === 'approval' || node?.kind === 'handle';
529
+ const panel = _jsxs("div", { className: "oxa-workflow-designer-inspector", children: [_jsxs("header", { children: [_jsx("span", { className: `oxa-designer-inspector-icon kind-${node?.kind || 'start'}`, children: _jsx(NodeIcon, {}) }), _jsx("h2", { children: node?.title || '流程发起' }), _jsx(Tag, { children: isWorkflowPlatformNotify(node) ? '通知节点' : kinds[node?.kind || ''] || '发起' }), _jsx(Button, { type: "text", icon: _jsx(CloseOutlined, {}), "aria-label": "\u5173\u95ED\u8282\u70B9\u8BBE\u7F6E", onClick: closeInspector })] }), node ? _jsxs(_Fragment, { children: [_jsx("div", { hidden: human && structureKeys.includes('return'), children: liveNode && configurations && ['approval', 'handle', 'cc'].includes(node.kind) ? _jsx(WorkflowNodeConfigurationEditor, { workflowCode: workflowCode, node: liveNode, principals: configurations.principals, expectedHeadRevision: nativeHeadRevision, presentation: "inline", readOnly: publishedView, compact: !detailInspector && !narrow, onExpand: () => { setDetailInspector(true); setOutline(false); }, onClose: closeInspector, onStateChange: handlingStateChanged, onLeaveGuardChange: handlingGuardChanged, returnSummary: human && (node.returnPolicy?.targets || node.returnTargets || []).length ? _jsxs("div", { children: [_jsx(Tag, { color: "gold", children: "\u968F\u8349\u7A3F\u53D1\u5E03" }), _jsx("div", { children: (node.returnPolicy?.targets || (node.returnTargets || []).map(nodeId => ({ nodeId, defaultRoute: 'replay' }))).map(target => _jsxs("p", { children: [definition.nodes[target.nodeId]?.title || '退回目标', " \u00B7 ", target.defaultRoute === 'resume' ? '重新提交后直接回到本节点' : '重新提交后重新按流程流转'] }, target.nodeId)) }), _jsx(Button, { type: "link", size: "small", onClick: () => setStructureKeys(['return']), children: "\u7F16\u8F91\u9000\u56DE\u8BBE\u7F6E" })] }) : undefined, onSaved: () => { void refreshHandling().catch(failure => setError(`办理设置已保存,重新读取失败:${String(failure.message)}`)); } }, `${liveNode.nodeId}:${liveNode.configuration.revision}`) : draft.publishedDefinition.nodes[node.id] && ['approval', 'handle', 'cc'].includes(node.kind) ? _jsx(Alert, { type: "warning", showIcon: true, title: "\u5DF2\u53D1\u5E03\u8282\u70B9\u7684\u529E\u7406\u8BBE\u7F6E\u672A\u80FD\u8F7D\u5165", description: "\u6B64\u8282\u70B9\u4E0D\u662F\u65B0\u589E\u8349\u7A3F\u8282\u70B9\uFF0C\u8BF7\u91CD\u65B0\u8BFB\u53D6\u914D\u7F6E\u540E\u4FEE\u6539\u3002", action: _jsx(Button, { onClick: () => void refreshHandling().catch(failure => setError(String(failure.message))), children: "\u91CD\u65B0\u8BFB\u53D6\u529E\u7406\u8BBE\u7F6E" }) }) : ['approval', 'handle', 'cc'].includes(node.kind) && _jsx(WorkflowDraftHandlingEditor, { node: node, baseline: node, bindingOptions: Object.keys(draft.publishedBinding.bindings).map(value => ({ value, label: value })), binding: binding?.bindings['binding' in node ? node.binding : ''], sources: catalog.peopleSources, principals: configurations?.principals || { users: [], roles: [] }, disabled: disabled, onBindingChange: entry => { if (!('binding' in node) || !binding)
530
+ return; mutate({ ...definition, nodes: { ...definition.nodes, [node.id]: { ...node, ...(entry.provider === 'supervisor_chain' && entry.continuous !== false ? { mode: 'sequence' } : {}) } } }, { ...binding, bindings: { ...binding.bindings, [node.binding]: entry } }); }, onChange: patch }) }), node.kind === 'action' && !isWorkflowPlatformNotify(node) && catalog && _jsx(WorkflowBusinessStepEditor, { node: node, catalog: catalog, variables: variables, disabled: disabled, onValidityChange: setStepInputInvalid, onChange: patch, onAssistant: () => { setAssistantContext(`当前步骤:${node.title}(${node.handler.code} v${node.handler.version})。需要新增业务能力时,请提出源代码与发布契约的改造方案,不要假设新能力已经发布。`); setAssistantOpen(true); setInspector(true); } }, `${node.id}:${node.handler.code}`), node.kind === 'parallel' && _jsx(WorkflowParallelConfigurationEditor, { node: node, selectedBranch: node.branches[(graph.edges.find(edge => edge.id === selectedEdge && edge.from === node.id)?.priority || 0) - 1]?.id, variables: variables, disabled: disabled, onChange: value => patch({ branches: value.branches }), onRemove: branchId => mutate(editWorkflowDesignerDefinition(definition, { type: 'remove_parallel_branch', nodeId: node.id, branchId })) }, node.id), node.kind === 'join' && _jsx(Alert, { type: "info", showIcon: true, title: "\u672C\u6B21\u8FDB\u5165\u7684\u5168\u90E8\u5206\u652F\u5B8C\u6210\u540E\u7EE7\u7EED", description: "\u6C47\u5408\u70B9\u4E0E\u5E76\u884C\u5206\u652F\u6210\u5BF9\u7EF4\u62A4\u3002\u82E5\u8981\u5220\u9664\u6574\u4E2A\u5E76\u884C\u533A\u57DF\uFF0C\u8BF7\u5728\u5E76\u884C\u8282\u70B9\u8BBE\u7F6E\u4E2D\u64CD\u4F5C\u3002" }), node.kind === 'condition' && _jsx(WorkflowConditionConfigurationEditor, { node: node, variables: variables, targets: targets, selectedBranch: graph.edges.find(edge => edge.id === selectedEdge && edge.from === node.id && edge.kind === 'branch')?.priority ? graph.edges.find(edge => edge.id === selectedEdge).priority - 1 : undefined, disabled: disabled, onChange: value => patch({ branches: value.branches, otherwise: value.otherwise }) }, node.id), human && structureKeys.includes('return') && _jsxs(_Fragment, { children: [_jsx(Button, { type: "link", className: "oxa-designer-return-back", icon: _jsx(ArrowLeftOutlined, {}), onClick: () => setStructureKeys([]), children: "\u8FD4\u56DE\u8282\u70B9\u914D\u7F6E" }), _jsx(WorkflowReturnPolicyEditor, { definition: definition, node: node, disabled: disabled, onChange: returnPolicy => patch({ returnPolicy, returnTargets: returnPolicy.targets.map(target => target.nodeId) }) })] }), _jsxs("section", { className: "oxa-designer-draft-band", hidden: human && structureKeys.includes('return'), children: [_jsx("h3", { children: "\u6D41\u7A0B\u7ED3\u6784 \u00B7 \u968F\u8349\u7A3F\u53D1\u5E03" }), _jsx(Collapse, { ghost: true, activeKey: structureKeys, onChange: keys => setStructureKeys(Array.isArray(keys) ? keys : [keys]), items: [
531
+ { key: 'name', label: '节点名称', extra: _jsx("span", { children: node.title || '未命名节点' }), children: _jsxs("label", { children: ["\u8282\u70B9\u540D\u79F0", _jsx(Input, { disabled: disabled, value: node.title || '', onChange: event => patch({ title: event.target.value }) })] }) },
532
+ ...(human ? [{ key: 'return', label: '退回设置', extra: _jsx("span", { children: (node.returnPolicy?.targets || node.returnTargets || []).length ? `可退回 ${(node.returnPolicy?.targets || node.returnTargets || []).length} 个节点` : '未配置退回目标' }), children: null }] : []),
533
+ ...(['approval', 'handle', 'correction'].includes(node.kind) ? [{ key: 'reminder', label: '办理提醒', extra: _jsx("span", { children: 'reminders' in node && node.reminders ? `${node.reminders.afterSeconds >= 3600 ? `${node.reminders.afterSeconds / 3600} 小时` : `${node.reminders.afterSeconds / 60} 分钟`}后提醒` : '未设置提醒' }), children: _jsx(_Fragment, { children: ['approval', 'handle', 'correction'].includes(node.kind) && _jsx(WorkflowReminderEditor, { rule: 'reminders' in node ? node.reminders : undefined, disabled: disabled, onDirtyChange: setReminderDirty, onChange: reminders => patch({ reminders }) }, node.id) }) }] : []),
534
+ ...((human || 'taskPageCode' in node) ? [{ key: 'page', label: '本节点表单', extra: _jsx("span", { children: definition.taskPages?.[node.taskPageCode || '']?.title || '应用自定义页面' }), children: _jsxs(_Fragment, { children: [human && !liveNode ? _jsx(Select, { "aria-label": "\u672C\u8282\u70B9\u8868\u5355", allowClear: true, disabled: disabled, value: node.taskPageCode, placeholder: "\u6807\u51C6\u53EA\u8BFB\u8BE6\u60C5\uFF08\u4E0D\u4FDD\u5B58\u8868\u5355\uFF09", options: Object.entries(catalog.taskPages).map(([value, page]) => ({ value, label: page.title })), onChange: pageCode => { const standard = createWorkflowHumanNode(node.id, node.kind, node.title, node.kind === 'approval' ? node.onApprove : node.next, pageCode, catalog.taskPages, node.kind === 'approval' ? node.onReject : undefined); patch({ taskPageCode: pageCode, fieldPolicy: 'fieldPolicy' in standard ? standard.fieldPolicy : undefined, administration: 'administration' in standard ? standard.administration : undefined, allowedOperations: 'allowedOperations' in standard ? standard.allowedOperations : undefined, requiredOperations: 'requiredOperations' in standard ? standard.requiredOperations : undefined, operationPolicy: 'operationPolicy' in standard ? standard.operationPolicy : undefined }); } }) : null, _jsx("p", { children: "\u9875\u9762\u5185\u5BB9\u4E0E\u53EF\u7F16\u8F91\u5B57\u6BB5\u4E0A\u9650\u6765\u81EA\u5E94\u7528\u53D1\u5E03\u7684\u9875\u9762\uFF1B\u6CA1\u6709\u4EFB\u52A1\u8868\u5355\u65F6\u4F7F\u7528\u6807\u51C6\u53EA\u8BFB\u8BE6\u60C5\uFF0C\u4E0D\u63D0\u4F9B\u8868\u5355\u4FDD\u5B58\u3002" })] }) }] : []),
535
+ { key: 'advanced', label: human ? '人员规则与流转路径' : '节点配置', children: _jsxs(_Fragment, { children: [_jsxs("label", { children: ["\u8282\u70B9\u540D\u79F0", _jsx(Input, { disabled: disabled, value: node.title || '', onChange: event => patch({ title: event.target.value }) })] }), (node.kind === 'approval' || node.kind === 'handle') && _jsxs(_Fragment, { children: [_jsxs("label", { children: [node.kind === "handle" ? "办理完成后" : "通过后", _jsx(Select, { disabled: disabled, value: node.kind === "handle" ? node.next : node.onApprove, options: targets, onChange: target => patch(node.kind === "handle" ? { next: target } : { onApprove: target }) })] }), node.kind === "approval" && _jsxs("label", { children: ["\u62D2\u7EDD\u540E", _jsx(Select, { disabled: disabled, value: node.onReject, options: targets, onChange: onReject => patch({ onReject }) })] })] }), node.kind === 'action' && isWorkflowPlatformNotify(node) && _jsx(WorkflowNotificationEditor, { node: node, variables: variables, roles: configurations?.principals.roles || [], users: configurations?.principals.users || [], disabled: disabled, onChange: patch }), 'next' in node && _jsxs("label", { children: ["\u5B8C\u6210\u540E", _jsx(Select, { disabled: disabled, value: node.next, options: targets, onChange: next => patch({ next }) })] }), 'taskPageCode' in node && _jsxs("p", { children: ["\u672C\u8282\u70B9\u9875\u9762\uFF1A", definition.taskPages?.[node.taskPageCode || '']?.title || '按应用页面规则填写' || '标准审批页面'] }), !['end', 'correction', 'join'].includes(node.kind) && _jsx(Popconfirm, { title: node.kind === 'parallel' ? '删除并行区域及其中的所有节点?' : '删除节点并连接后续路径?', onConfirm: () => { if (!inspectorReady())
536
+ return; try {
537
+ const next = editWorkflowDesignerDefinition(definition, { type: 'remove', nodeId: node.id, ...(node.kind === 'condition' ? { reconnectTo: node.otherwise } : {}) });
538
+ mutate(next);
539
+ setSelected(next.startAt);
540
+ }
541
+ catch {
542
+ message.error('此节点有多个出口,请先选择明确的后续节点。');
543
+ } }, children: _jsx(Button, { danger: true, disabled: disabled, children: "\u5220\u9664\u8282\u70B9" }) })] }) },
544
+ ] })] })] }) : _jsx("p", { children: "\u53D1\u8D77\u540E\u6309\u6D41\u7A0B\u7ED3\u6784\u8FDB\u5165\u7B2C\u4E00\u4E2A\u8282\u70B9\u3002" })] });
545
+ const diagnostic = (error) => {
546
+ const [code, nodeId] = error.split(':');
547
+ const title = nodeId ? definition.nodes[nodeId]?.title || '节点' : '流程';
548
+ const messages = { WORKFLOW_DESIGNER_CYCLE: '后续路径形成循环', WORKFLOW_DESIGNER_TARGET_MISSING: '后续节点不存在', WORKFLOW_DESIGNER_UNREACHABLE: '尚未连接到流程', WORKFLOW_DESIGNER_CONDITION_TYPE: '条件变量与比较值类型不一致', WORKFLOW_DESIGNER_VARIABLE_UNKNOWN: '条件变量来源无法确认', WORKFLOW_DESIGNER_CONDITION_BOOLEAN: '条件需要产生满足或不满足的判断', WORKFLOW_DESIGNER_BRANCH_LIMIT: '条件分支数量超出限制' };
549
+ return `${title}:${messages[code || ''] || '配置需要调整'}`;
550
+ };
551
+ return _jsxs("section", { className: "oxa-workflow-designer", "aria-label": "\u6D41\u7A0B\u8BBE\u8BA1\u5668", children: [_jsxs("header", { className: "oxa-designer-toolbar", children: [_jsxs("div", { className: "oxa-designer-toolbar-identity", children: [_jsx(Tooltip, { title: "\u8FD4\u56DE\u6D41\u7A0B\u56FE", children: _jsx(Button, { icon: _jsx(ArrowLeftOutlined, {}), "aria-label": "\u8FD4\u56DE\u6D41\u7A0B\u56FE", disabled: busy || assistantState.unknown || liveState.busy || liveState.unknown, onClick: goBack }) }), _jsx("span", { className: "oxa-designer-toolbar-label", children: "\u6D41\u7A0B\u8BBE\u8BA1" }), _jsx("strong", { children: definition.title }), _jsx(Tag, { color: "blue", children: draft.environmentKey === 'production' ? '正式环境' : '测试环境' }), _jsx(Segmented, { "aria-label": "\u6D41\u7A0B\u8BBE\u8BA1\u67E5\u770B\u7248\u672C", value: publishedView ? 'published' : 'draft', onChange: switchVersion, options: [{ value: 'published', label: `已发布 v${draft.definitionVersion}` }, { value: 'draft', label: '草稿' }] }), _jsx("span", { className: "oxa-designer-save-state", children: busy && frozenSave.current ? '正在保存…' : dirty ? errors.length ? '修改待检查' : '草稿未保存' : `${draft.updatedAt ? '草稿已自动保存' : '草稿与已发布版本一致'}${draft.updatedAt ? ` ${new Date(draft.updatedAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}` : ''}` }), (frozenSave.current || dirty && error) && _jsx(Button, { type: "link", disabled: busy, onClick: () => void save(), children: frozenSave.current ? '重试原保存请求' : '重试保存' })] }), _jsxs(Space, { size: 8, className: "oxa-designer-toolbar-actions", children: [_jsx(Tooltip, { title: "\u64A4\u9500", children: _jsx(Button, { icon: _jsx(UndoOutlined, {}), "aria-label": "\u64A4\u9500", disabled: disabled || stepInputInvalid || reminderDirty || !history.length, onClick: () => { const previous = history.at(-1); if (previous) {
552
+ setFuture(current => [...current, { definition, binding: binding }]);
553
+ setHistory(current => current.slice(0, -1));
554
+ setDefinition(previous.definition);
555
+ setBinding(previous.binding);
556
+ } }, children: "\u64A4\u9500" }) }), _jsx(Tooltip, { title: "\u91CD\u505A", children: _jsx(Button, { icon: _jsx(RedoOutlined, {}), "aria-label": "\u91CD\u505A", disabled: disabled || stepInputInvalid || reminderDirty || !future.length, onClick: () => { const next = future.at(-1); if (next) {
557
+ setHistory(current => [...current, { definition, binding: binding }]);
558
+ setFuture(current => current.slice(0, -1));
559
+ setDefinition(next.definition);
560
+ setBinding(next.binding);
561
+ } }, children: "\u91CD\u505A" }) }), _jsx(Button, { icon: _jsx(SafetyOutlined, {}), onClick: () => setChecksOpen(true), children: "\u7ED3\u6784\u68C0\u67E5" }), _jsx(Button, { icon: _jsx(HistoryOutlined, {}), onClick: () => void showVersions(), children: "\u7248\u672C\u8BB0\u5F55" }), _jsx(Button, { icon: _jsx(RobotOutlined, {}), disabled: disabled || liveState.busy || liveState.unknown, onClick: () => { const open = () => void openAssistant(); if (leaveHandling.current)
562
+ leaveHandling.current(open);
563
+ else
564
+ open(); }, children: "AI \u52A9\u624B" }), _jsx(Button, { type: "primary", disabled: disabled || stepInputInvalid || reminderDirty || errors.length > 0 || liveState.dirty || liveState.busy || liveState.unknown, onClick: () => void openPublication(), children: "\u53D1\u5E03\u5E76\u542F\u7528" })] })] }), error && _jsx(Alert, { type: "error", title: error, action: frozenSave.current ? _jsx(Button, { onClick: () => void save(), children: "\u91CD\u8BD5\u4FDD\u5B58" }) : frozenAux.current ? _jsx(Button, { onClick: () => void retryAux(), children: "\u91CD\u8BD5\u539F\u64CD\u4F5C" }) : undefined }), receipt && _jsxs(_Fragment, { children: [_jsx(Alert, { type: receipt.counts.failed || receipt.counts.excepted ? 'warning' : 'success', title: `已发布 v${receipt.definitionVersion} · ${receipt.status === 'running' ? '正在更新进行中的申请' : '更新处理结束'}`, description: Object.entries(receipt.counts).map(([key, count]) => `${outcomeLabels[key] || key} ${count}`).join(' · '), action: _jsxs(Space, { children: [receipt.status === 'running' && _jsx(Button, { disabled: busy, onClick: () => void control('pause'), children: "\u6682\u505C\u66F4\u65B0" }), receipt.status === 'paused' && _jsx(Button, { disabled: busy, onClick: () => void control('resume'), children: "\u7EE7\u7EED\u66F4\u65B0" }), !!receipt.counts.failed && _jsx(Button, { disabled: busy, onClick: () => void control('retry_failed'), children: "\u91CD\u8BD5\u5931\u8D25\u7684\u7533\u8BF7" })] }) }), receipt.items?.length ? _jsxs("details", { children: [_jsx("summary", { children: "\u67E5\u770B\u7533\u8BF7\u66F4\u65B0\u8BB0\u5F55" }), _jsx(Table, { size: "small", rowKey: "instanceId", dataSource: receipt.items, pagination: { pageSize: 5 }, columns: [{ title: '申请', dataIndex: 'business_key' }, { title: '结果', render: (_, item) => outcomeLabels[item.outcome] || item.outcome }, { title: '原因', dataIndex: 'reason' }] }), receipt.items.some(item => item.outcome === 'held') && _jsxs("div", { style: { padding: 12 }, children: [_jsxs("label", { children: ["\u89E3\u9664\u539F\u7248\u672C\u4FDD\u7559", _jsx(Select, { mode: "multiple", style: { width: '100%' }, value: releaseIds, disabled: busy || !!frozenAux.current, options: receipt.items.filter(item => item.outcome === 'held').map(item => ({ value: item.instanceId, label: item.business_key })), onChange: setReleaseIds })] }), _jsx(Input, { "aria-label": "\u89E3\u9664\u4FDD\u7559\u8BF4\u660E", maxLength: 1000, value: releaseReason, disabled: busy || !!frozenAux.current, onChange: event => setReleaseReason(event.target.value), placeholder: "\u8BF4\u660E\u4E3A\u4EC0\u4E48\u5C06\u8FD9\u4E9B\u7533\u8BF7\u66F4\u65B0\u5230\u5F53\u524D\u7248\u672C" }), _jsx(Button, { disabled: busy || !!frozenAux.current || !releaseIds.length || !releaseReason.trim(), onClick: () => void releaseHolds(), children: "\u89E3\u9664\u4FDD\u7559\u5E76\u66F4\u65B0" })] })] }) : null] }), _jsxs("div", { className: `oxa-designer-workspace ${outline ? '' : 'without-outline'} ${inspector ? '' : 'without-inspector'} ${detailInspector ? 'detail-inspector' : ''}`, children: [_jsxs("aside", { className: "oxa-designer-outline", "aria-label": "\u6D41\u7A0B\u5927\u7EB2", children: [_jsxs("div", { className: "oxa-designer-outline-heading", children: [outline && _jsx("strong", { children: "\u6D41\u7A0B\u5927\u7EB2" }), _jsx(Button, { type: "text", icon: outline ? _jsx(MenuFoldOutlined, {}) : _jsx(MenuUnfoldOutlined, {}), "aria-label": outline ? '收起流程大纲' : '展开流程大纲', onClick: () => { const toggle = () => { if (!outline)
565
+ setDetailInspector(false); setOutline(value => !value); }; if (!outline && leaveHandling.current)
566
+ leaveHandling.current(toggle);
567
+ else
568
+ toggle(); } })] }), outline && _jsx(Input.Search, { size: "small", "aria-label": "\u641C\u7D22\u6D41\u7A0B\u8282\u70B9", placeholder: "\u641C\u7D22\u8282\u70B9", value: outlineKeyword, allowClear: true, onChange: event => setOutlineKeyword(event.target.value) }), _jsx("nav", { children: outlineNodes.filter(item => !outlineKeyword || item.title.includes(outlineKeyword)).map(item => {
569
+ const Icon = item.presentation === 'notification' ? BellOutlined : typeIcons[item.kind] || CodeOutlined;
570
+ return _jsx(Tooltip, { title: !outline ? item.title : undefined, placement: "right", children: _jsxs("button", { type: "button", className: `kind-${item.kind}`, "aria-label": item.title, "aria-pressed": item.edgeId ? selectedEdge === item.edgeId : selected === item.nodeId, style: outline && item.depth ? { paddingLeft: 14 + item.depth * 16 } : undefined, onClick: () => item.edgeId ? selectEdge(item.edgeId) : selectNode(item.nodeId), children: [_jsx(Icon, {}), outline && _jsx("span", { children: item.title })] }) }, item.id);
571
+ }) }), outline && _jsxs("footer", { children: [_jsx("strong", { children: "\u68C0\u67E5\u7ED3\u679C" }), _jsxs("button", { type: "button", onClick: () => setChecksOpen(true), children: [_jsx(CheckCircleOutlined, {}), " ", errors.length ? `发现 ${errors.length} 项问题` : '未发现问题'] })] })] }), _jsxs("main", { children: [_jsxs("div", { className: "oxa-designer-banner", children: [publishedView ? `正在查看已发布 v${draft.definitionVersion}` : '正在编辑草稿', " \u00B7 \u53D1\u5E03\u5E76\u542F\u7528\u65F6\u53EF\u66F4\u65B0\u8FDB\u884C\u4E2D\u7684\u7533\u8BF7"] }), _jsx(WorkflowDiagram, { graph: displayGraph, summaries: summaries, selectedNodeId: selected, selectedEdgeId: selectedEdge, onSelectEdge: selectEdge, onSelectNode: selectNode, presentation: "designer", insertionOptions: [{ value: 'approval', label: '审批', kind: 'approval' }, { value: 'handle', label: '办理', kind: 'handle' }, { value: 'cc', label: '抄送', kind: 'cc' }, ...(variables.length ? [{ value: 'condition', label: '条件分支', kind: 'condition' }] : []), { value: 'parallel', label: '并行分支', kind: 'parallel' }, { value: 'action', label: '业务步骤', kind: 'action' }, { value: 'platform_notify', label: '发送通知', kind: 'notification' }], onInsertEdge: disabled || stepInputInvalid || reminderDirty ? undefined : (value, chosenTemplate) => { const open = () => { if (chosenTemplate) {
572
+ const title = chosenTemplate === 'parallel' ? '并行分支' : chosenTemplate === 'condition' ? '条件分支' : chosenTemplate === 'platform_notify' ? '发送通知' : kinds[chosenTemplate] || draft.publishedDefinition.nodes[chosenTemplate]?.title || '新增节点';
573
+ insertNode(chosenTemplate, title, value);
574
+ }
575
+ else {
576
+ setInsert(value);
577
+ setNodeTitle('');
578
+ setTemplate('approval');
579
+ } }; if (leaveHandling.current)
580
+ leaveHandling.current(open);
581
+ else
582
+ open(); } }), !inspector && _jsx(Button, { className: "oxa-designer-show-inspector", onClick: () => setInspector(true), children: "\u8282\u70B9\u8BBE\u7F6E" }), _jsxs(Button, { className: "oxa-designer-mobile-inspector", onClick: () => setInspector(true), children: ["\u7F16\u8F91 ", node?.title || '节点'] })] }), inspector && narrow && _jsx("button", { type: "button", className: "oxa-designer-inspector-backdrop", "aria-label": "\u5173\u95ED\u8282\u70B9\u8BBE\u7F6E", onClick: closeInspector }), _jsxs("aside", { style: { display: inspector ? undefined : 'none' }, ref: inspectorElement, className: "oxa-designer-desktop-inspector", role: narrow ? 'dialog' : undefined, "aria-modal": narrow ? true : undefined, "aria-label": assistantOpen ? 'AI 助手' : '节点设置', children: [_jsx("div", { hidden: assistantOpen, children: panel }), _jsx(WorkflowDesignerAssistant, { presentation: "panel", workflowCode: workflowCode, draft: draft, context: assistantContext, open: assistantOpen, canApply: !dirty && !busy && !liveState.dirty && !liveState.busy && !liveState.unknown && !frozenSave.current && !frozenPublish.current && !frozenAux.current, onClose: () => setAssistantOpen(false), onApplied: value => { setPublishedView(false); setDraft(value); setDefinition(value.definition); setBinding(value.binding); setHistory(current => { const snapshots = [...current, { definition, binding: binding }].slice(-25); while (snapshots.length > 1 && snapshots.reduce((bytes, item) => bytes + JSON.stringify(item).length, 0) > 4 * 1024 * 1024)
583
+ snapshots.shift(); return snapshots; }); setFuture([]); setError(undefined); }, onStateChange: setAssistantState })] })] }), _jsx(Drawer, { open: checksOpen, title: "\u6D41\u7A0B\u7ED3\u6784\u68C0\u67E5", width: 440, onClose: () => setChecksOpen(false), children: _jsx(Alert, { showIcon: true, type: errors.length ? 'warning' : 'success', title: errors.length ? `发现 ${errors.length} 项待修正的问题` : '未发现结构问题', description: errors.length ? errors.map(diagnostic).join(';') : '节点与流转路径已通过结构校验。发布时还会检查当前应用的人员规则、页面和业务步骤。' }) }), _jsxs(Modal, { open: !!insert, title: "\u65B0\u589E\u8282\u70B9", onCancel: () => setInsert(undefined), onOk: () => insertNode(), okText: "\u6DFB\u52A0", okButtonProps: { disabled: !nodeTitle.trim() || !template }, children: [_jsx("p", { children: "\u65B0\u589E\u7A7A\u767D\u8282\u70B9\u540E\u81EA\u884C\u914D\u7F6E\u4EBA\u5458\u3001\u6309\u94AE\u548C\u63D0\u9192\u3002\u4E1A\u52A1\u6B65\u9AA4\u4F7F\u7528\u5E94\u7528\u5DF2\u53D1\u5E03\u7684\u80FD\u529B\u3002" }), _jsxs("label", { children: ["\u8282\u70B9\u7C7B\u578B", _jsx(Select, { style: { width: '100%' }, value: template, onChange: setTemplate, options: [{ value: 'approval', label: '审批(空白)' }, { value: 'handle', label: '办理(空白)' }, { value: 'cc', label: '抄送(空白)' }, { value: 'action', label: '已发布业务步骤' }, { value: 'parallel', label: '并行分支' }, { value: 'platform_notify', label: '发送通知' }, ...(variables.length ? [{ value: 'condition', label: '条件分支' }] : []), ...Object.values(draft.publishedDefinition.nodes).filter(node => ['approval', 'handle', 'cc', 'action'].includes(node.kind)).map(node => ({ value: node.id, label: `复制已有配置 · ${node.title}` }))] })] }), _jsxs("label", { children: ["\u8282\u70B9\u540D\u79F0", _jsx(Input, { value: nodeTitle, onChange: event => setNodeTitle(event.target.value) })] })] }), _jsx(Drawer, { open: versionsOpen, title: "\u6D41\u7A0B\u7248\u672C\u8BB0\u5F55", width: 620, onClose: () => setVersionsOpen(false), children: _jsx(Table, { loading: busy, rowKey: "publicationId", dataSource: versions, pagination: { pageSize: 10 }, columns: [{ title: '版本', render: (_, item) => `v${item.definitionVersion}` }, { title: '说明', dataIndex: 'reason' }, { title: '发布时间', dataIndex: 'createdAt', render: value => new Date(value).toLocaleString() }, { title: '操作', render: (_, item) => _jsx(Popconfirm, { title: "\u5C06\u8BE5\u7248\u672C\u6062\u590D\u5230\u5171\u4EAB\u8349\u7A3F\uFF1F", description: "\u5F53\u524D\u8349\u7A3F\u5C06\u88AB\u66FF\u6362\uFF1B\u53D1\u5E03\u540E\u624D\u4F1A\u751F\u6548\u3002", onConfirm: () => void restore(item.definitionVersion), children: _jsx(Button, { disabled: busy || dirty || liveState.dirty || liveState.busy || liveState.unknown || !!frozenSave.current || !!frozenPublish.current || !!frozenAux.current, children: "\u6062\u590D\u5230\u8349\u7A3F" }) }) }] }) }), _jsxs(Modal, { open: publication, title: "\u53D1\u5E03\u5E76\u542F\u7528", width: 648, className: "oxa-designer-publish-modal", cancelText: "\u7EE7\u7EED\u7F16\u8F91", onCancel: () => { if (!frozenPublish.current)
584
+ setPublication(false); }, onOk: () => void publish(), confirmLoading: busy, okText: frozenPublish.current ? '重试原发布请求' : '发布并启用', okButtonProps: { disabled: !reason.trim() || scope === 'running_and_new' && (holdIds.length > 0 || holdNodeIds.length > 0) && !holdReason.trim() || !preview || preview.truncated || scope === 'running_and_new' && !!preview.counts.excepted && !acknowledge }, children: [_jsxs("p", { children: ["\u5C06\u5F53\u524D\u8349\u7A3F\u53D1\u5E03\u5230", draft.environmentKey === 'production' ? '正式环境' : '测试环境', "\u3002\u68C0\u67E5\u901A\u8FC7\u540E\u7ACB\u5373\u751F\u6548\u3002"] }), _jsxs(Spin, { spinning: busy, children: [_jsxs("div", { className: "oxa-designer-publish-checks", children: [_jsx(CheckCircleOutlined, {}), _jsx("span", { children: preview ? '流程与应用能力检查已完成' : '正在检查流程与应用能力' })] }), _jsxs("fieldset", { disabled: busy || !!frozenPublish.current, children: [_jsx("h3", { children: "\u751F\u6548\u8303\u56F4" }), _jsxs(Radio.Group, { value: scope, disabled: busy || !!frozenPublish.current, onChange: event => setScope(event.target.value), className: "oxa-designer-publish-scope", children: [_jsxs(Radio, { value: "running_and_new", children: [_jsxs("strong", { children: ["\u8FDB\u884C\u4E2D\u7684\u7533\u8BF7\u548C\u65B0\u53D1\u8D77\u7684\u7533\u8BF7\u90FD\u4F7F\u7528\u65B0\u7248\u672C", _jsx(Tag, { color: "blue", children: "\u9ED8\u8BA4" })] }), _jsx("small", { children: "\u5DF2\u8FDB\u5165\u7684\u4EFB\u52A1\u4FDD\u7559\u539F\u6709\u4EBA\u9009\u3001\u6309\u94AE\u548C\u9875\u9762\uFF0C\u540E\u7EED\u6D41\u8F6C\u4F7F\u7528\u65B0\u7248\u672C\u3002" })] }), _jsxs(Radio, { value: "new_only", children: [_jsx("strong", { children: "\u4EC5\u65B0\u53D1\u8D77\u7684\u7533\u8BF7\u4F7F\u7528\u65B0\u7248\u672C" }), _jsx("small", { children: "\u8FDB\u884C\u4E2D\u7684\u7533\u8BF7\u7EE7\u7EED\u6309\u539F\u7248\u672C\u529E\u7406\u3002" })] })] }), scope === 'running_and_new' && _jsxs("details", { className: "oxa-designer-publish-holds", children: [_jsxs("summary", { children: ["\u6307\u5B9A\u4FDD\u7559\u5728\u539F\u7248\u672C\u7684\u7533\u8BF7", (holdIds.length > 0 || holdNodeIds.length > 0) && _jsx(Tag, { children: "\u5DF2\u6307\u5B9A" })] }), _jsxs("label", { children: ["\u4FDD\u7559\u539F\u7248\u672C\u7684\u7533\u8BF7", _jsx(Select, { mode: "multiple", showSearch: true, filterOption: false, onSearch: keyword => void searchHolds(keyword), disabled: busy || !!frozenPublish.current, value: holdIds, onChange: value => { setHoldIds(value); setPreview(undefined); }, options: holdCandidates.map(item => ({ value: item.instanceId, label: `${item.businessKey} · ${item.nodeTitle}` })) })] }), _jsxs("label", { children: ["\u4FDD\u7559\u5F53\u524D\u505C\u5728\u8FD9\u4E9B\u8282\u70B9\u7684\u7533\u8BF7", _jsx(Select, { mode: "multiple", disabled: busy || !!frozenPublish.current, value: holdNodeIds, options: Object.values(definition.nodes).filter(node => ['approval', 'handle', 'correction', 'action'].includes(node.kind)).map(node => ({ value: node.id, label: node.title || '流程节点' })), onChange: value => { setHoldNodeIds(value); setPreview(undefined); } })] }), (holdIds.length > 0 || holdNodeIds.length > 0) && _jsxs("label", { children: ["\u4FDD\u7559\u539F\u56E0", _jsx(Input, { disabled: busy || !!frozenPublish.current, value: holdReason, maxLength: 1000, onChange: event => setHoldReason(event.target.value) })] }), _jsx(Button, { disabled: busy || !!frozenPublish.current, onClick: () => void check(), children: "\u91CD\u65B0\u68C0\u67E5\u5F71\u54CD" })] }), preview && scope === 'running_and_new' && _jsxs(_Fragment, { children: [_jsx("h3", { children: "\u8FDB\u884C\u4E2D\u7684\u7533\u8BF7" }), _jsx("dl", { className: "oxa-designer-publish-counts", children: Object.entries(preview.counts).map(([key, count]) => _jsxs("div", { className: `outcome-${key}`, children: [_jsx("dt", { children: outcomeLabels[key] || key }), _jsx("dd", { children: count })] }, key)) }), preview.items.some(item => item.outcome !== 'eligible') && _jsxs("details", { className: "oxa-designer-publish-exceptions", children: [_jsx("summary", { children: "\u67E5\u770B\u9700\u5355\u72EC\u5904\u7406\u7684\u7533\u8BF7" }), _jsx(Table, { size: "small", rowKey: "instanceId", dataSource: preview.items.filter(item => item.outcome !== 'eligible'), pagination: { pageSize: 5 }, columns: [{ title: '申请', dataIndex: 'businessKey' }, { title: '处理', render: (_, item) => outcomeLabels[item.outcome] }, { title: '原因', dataIndex: 'reason' }] })] }), !!preview.counts.excepted && _jsx(Checkbox, { disabled: !!frozenPublish.current || busy, checked: acknowledge, onChange: event => setAcknowledge(event.target.checked), children: "\u6211\u5DF2\u4E86\u89E3\u4E0D\u80FD\u66F4\u65B0\u7684\u7533\u8BF7\u5C06\u4FDD\u7559\u539F\u7248\u672C\uFF0C\u5E76\u5728\u66F4\u65B0\u8BB0\u5F55\u4E2D\u5355\u72EC\u5217\u51FA\u3002" })] }), scope === 'new_only' && _jsx("p", { children: "\u65B0\u53D1\u8D77\u7684\u7533\u8BF7\u4F7F\u7528\u6B64\u7248\u672C\uFF0C\u8FDB\u884C\u4E2D\u7684\u7533\u8BF7\u4FDD\u6301\u5F53\u524D\u7248\u672C\u3002" }), _jsxs("label", { className: "oxa-designer-publish-reason", children: ["\u7248\u672C\u8BF4\u660E", _jsx(Input, { "aria-label": "\u6D41\u7A0B\u7248\u672C\u8BF4\u660E", disabled: busy || !!frozenPublish.current, value: reason, maxLength: 1000, onChange: event => setReason(event.target.value), placeholder: "\u8BF4\u660E\u672C\u6B21\u6D41\u7A0B\u7684\u8C03\u6574" })] })] })] })] })] });
585
+ }
586
+ //# sourceMappingURL=WorkflowDesigner.js.map