openxiangda 2.62.0 → 2.63.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/AuthoritativeSelector.d.ts +4 -3
- package/dist/browser/AuthoritativeSelector.d.ts.map +1 -1
- package/dist/browser/AuthoritativeSelector.js +25 -16
- package/dist/browser/AuthoritativeSelector.js.map +1 -1
- package/dist/browser/admin-contributions.d.ts +26 -0
- package/dist/browser/admin-contributions.d.ts.map +1 -1
- package/dist/browser/admin-contributions.js +30 -0
- package/dist/browser/admin-contributions.js.map +1 -1
- package/dist/browser/components/administration/membership-batch-model.d.ts.map +1 -1
- package/dist/browser/components/administration/membership-batch-model.js +2 -1
- package/dist/browser/components/administration/membership-batch-model.js.map +1 -1
- package/dist/browser/components/platform-fields/AttachmentFileList.d.ts +2 -1
- package/dist/browser/components/platform-fields/AttachmentFileList.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/AttachmentFileList.js +3 -3
- package/dist/browser/components/platform-fields/AttachmentFileList.js.map +1 -1
- package/dist/browser/components/platform-fields/MobileManagedFileField.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/MobileManagedFileField.js +2 -1
- package/dist/browser/components/platform-fields/MobileManagedFileField.js.map +1 -1
- package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts +4 -2
- package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/ResourceReferenceField.js +4 -4
- package/dist/browser/components/platform-fields/ResourceReferenceField.js.map +1 -1
- package/dist/browser/components/platform-fields/SubtableField.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/SubtableField.js +3 -2
- package/dist/browser/components/platform-fields/SubtableField.js.map +1 -1
- package/dist/browser/components/platform-fields/address-value.d.ts +2 -12
- package/dist/browser/components/platform-fields/address-value.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/address-value.js +1 -69
- package/dist/browser/components/platform-fields/address-value.js.map +1 -1
- package/dist/browser/components/platform-fields/cascade-value.d.ts +2 -5
- package/dist/browser/components/platform-fields/cascade-value.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/cascade-value.js +1 -46
- package/dist/browser/components/platform-fields/cascade-value.js.map +1 -1
- package/dist/browser/components/platform-fields/resource-query.d.ts +3 -19
- package/dist/browser/components/platform-fields/resource-query.d.ts.map +1 -1
- package/dist/browser/components/platform-fields/resource-query.js +2 -153
- package/dist/browser/components/platform-fields/resource-query.js.map +1 -1
- package/dist/browser/components/resource/GeneratedResourceCrud.d.ts +393 -2
- package/dist/browser/components/resource/GeneratedResourceCrud.d.ts.map +1 -1
- package/dist/browser/components/resource/GeneratedResourceCrud.js +148 -71
- package/dist/browser/components/resource/GeneratedResourceCrud.js.map +1 -1
- package/dist/browser/components/resource/GeneratedResourceForm.d.ts.map +1 -1
- package/dist/browser/components/resource/GeneratedResourceForm.js +7 -1
- package/dist/browser/components/resource/GeneratedResourceForm.js.map +1 -1
- package/dist/browser/components/resource/RecordDetailFrame.d.ts +4 -1
- package/dist/browser/components/resource/RecordDetailFrame.d.ts.map +1 -1
- package/dist/browser/components/resource/RecordDetailFrame.js +4 -2
- package/dist/browser/components/resource/RecordDetailFrame.js.map +1 -1
- package/dist/browser/components/resource/ResourceBatchActions.d.ts.map +1 -1
- package/dist/browser/components/resource/ResourceBatchActions.js +7 -6
- package/dist/browser/components/resource/ResourceBatchActions.js.map +1 -1
- package/dist/browser/components/resource/SurfaceFields.d.ts +4 -1
- package/dist/browser/components/resource/SurfaceFields.d.ts.map +1 -1
- package/dist/browser/components/resource/SurfaceFields.js +8 -8
- package/dist/browser/components/resource/SurfaceFields.js.map +1 -1
- package/dist/browser/components/resource/record-comment-session.d.ts.map +1 -1
- package/dist/browser/components/resource/record-comment-session.js +2 -1
- package/dist/browser/components/resource/record-comment-session.js.map +1 -1
- package/dist/browser/components/resource/record-deletion-session.d.ts.map +1 -1
- package/dist/browser/components/resource/record-deletion-session.js +2 -1
- package/dist/browser/components/resource/record-deletion-session.js.map +1 -1
- package/dist/browser/components/resource/useResourceFormDrafts.d.ts.map +1 -1
- package/dist/browser/components/resource/useResourceFormDrafts.js +2 -9
- package/dist/browser/components/resource/useResourceFormDrafts.js.map +1 -1
- package/dist/browser/components/workflow/StandardWorkflowPages.d.ts +5 -2
- package/dist/browser/components/workflow/StandardWorkflowPages.d.ts.map +1 -1
- package/dist/browser/components/workflow/StandardWorkflowPages.js +107 -64
- package/dist/browser/components/workflow/StandardWorkflowPages.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowAssignmentRoutingEditor.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowAssignmentRoutingEditor.js +2 -1
- package/dist/browser/components/workflow/WorkflowAssignmentRoutingEditor.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowBusinessStepRecoveryPanel.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowBusinessStepRecoveryPanel.js +15 -9
- package/dist/browser/components/workflow/WorkflowBusinessStepRecoveryPanel.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.d.ts +18 -0
- package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.js +29 -0
- package/dist/browser/components/workflow/WorkflowConditionConfigurationEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowConditionEditor.d.ts +9 -0
- package/dist/browser/components/workflow/WorkflowConditionEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowConditionEditor.js +33 -0
- package/dist/browser/components/workflow/WorkflowConditionEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowDelegationManager.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowDelegationManager.js +2 -1
- package/dist/browser/components/workflow/WorkflowDelegationManager.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowDesigner.d.ts +14 -0
- package/dist/browser/components/workflow/WorkflowDesigner.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowDesigner.js +510 -0
- package/dist/browser/components/workflow/WorkflowDesigner.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowDesignerAssistant.d.ts +15 -0
- package/dist/browser/components/workflow/WorkflowDesignerAssistant.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowDesignerAssistant.js +75 -0
- package/dist/browser/components/workflow/WorkflowDesignerAssistant.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowDiagram.d.ts +8 -2
- package/dist/browser/components/workflow/WorkflowDiagram.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowDiagram.js +6 -6
- package/dist/browser/components/workflow/WorkflowDiagram.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.d.ts +13 -0
- package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.js +20 -0
- package/dist/browser/components/workflow/WorkflowDraftHandlingEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowFlowCanvas.d.ts +7 -0
- package/dist/browser/components/workflow/WorkflowFlowCanvas.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowFlowCanvas.js +84 -23
- package/dist/browser/components/workflow/WorkflowFlowCanvas.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowNodeCard.d.ts +2 -1
- package/dist/browser/components/workflow/WorkflowNodeCard.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowNodeCard.js +12 -10
- package/dist/browser/components/workflow/WorkflowNodeCard.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.d.ts +13 -2
- package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.js +72 -24
- package/dist/browser/components/workflow/WorkflowNodeConfigurationEditor.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowNotificationEditor.d.ts +20 -0
- package/dist/browser/components/workflow/WorkflowNotificationEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowNotificationEditor.js +18 -0
- package/dist/browser/components/workflow/WorkflowNotificationEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.d.ts +10 -0
- package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.js +24 -0
- package/dist/browser/components/workflow/WorkflowParallelConfigurationEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowRecordEditor.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowRecordEditor.js +2 -1
- package/dist/browser/components/workflow/WorkflowRecordEditor.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowReminderEditor.d.ts +7 -0
- package/dist/browser/components/workflow/WorkflowReminderEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowReminderEditor.js +7 -0
- package/dist/browser/components/workflow/WorkflowReminderEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.d.ts +8 -0
- package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.d.ts.map +1 -0
- package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.js +33 -0
- package/dist/browser/components/workflow/WorkflowReturnPolicyEditor.js.map +1 -0
- package/dist/browser/components/workflow/WorkflowTaskDraftPanel.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowTaskDraftPanel.js +2 -1
- package/dist/browser/components/workflow/WorkflowTaskDraftPanel.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowTaskFiles.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowTaskFiles.js +2 -1
- package/dist/browser/components/workflow/WorkflowTaskFiles.js.map +1 -1
- package/dist/browser/components/workflow/WorkflowTaskForm.d.ts +1 -4
- package/dist/browser/components/workflow/WorkflowTaskForm.d.ts.map +1 -1
- package/dist/browser/components/workflow/WorkflowTaskForm.js +5 -6
- package/dist/browser/components/workflow/WorkflowTaskForm.js.map +1 -1
- package/dist/browser/components/workflow/workflow-approval-presentation.d.ts +13 -0
- package/dist/browser/components/workflow/workflow-approval-presentation.d.ts.map +1 -0
- package/dist/browser/components/workflow/workflow-approval-presentation.js +21 -0
- package/dist/browser/components/workflow/workflow-approval-presentation.js.map +1 -0
- package/dist/browser/components/workflow/workflow-designer-presentation.d.ts +13 -0
- package/dist/browser/components/workflow/workflow-designer-presentation.d.ts.map +1 -0
- package/dist/browser/components/workflow/workflow-designer-presentation.js +69 -0
- package/dist/browser/components/workflow/workflow-designer-presentation.js.map +1 -0
- package/dist/browser/components/workflow/workflow-flow-layout.d.ts +11 -2
- package/dist/browser/components/workflow/workflow-flow-layout.d.ts.map +1 -1
- package/dist/browser/components/workflow/workflow-flow-layout.js +44 -9
- package/dist/browser/components/workflow/workflow-flow-layout.js.map +1 -1
- package/dist/browser/components/workflow/workflow-operation-layout.d.ts +6 -0
- package/dist/browser/components/workflow/workflow-operation-layout.d.ts.map +1 -0
- package/dist/browser/components/workflow/workflow-operation-layout.js +17 -0
- package/dist/browser/components/workflow/workflow-operation-layout.js.map +1 -0
- package/dist/browser/durable-command.d.ts.map +1 -1
- package/dist/browser/durable-command.js +2 -1
- package/dist/browser/durable-command.js.map +1 -1
- package/dist/browser/managed-command.d.ts.map +1 -1
- package/dist/browser/managed-command.js +2 -1
- package/dist/browser/managed-command.js.map +1 -1
- package/dist/browser/platform-client.d.ts +71 -3
- package/dist/browser/platform-client.d.ts.map +1 -1
- package/dist/browser/platform-client.js +58 -9
- package/dist/browser/platform-client.js.map +1 -1
- package/dist/browser/record-detail.css +4 -3
- package/dist/browser/styles.css +355 -1
- package/dist/browser/uuid.d.ts +7 -0
- package/dist/browser/uuid.d.ts.map +1 -0
- package/dist/browser/uuid.js +19 -0
- package/dist/browser/uuid.js.map +1 -0
- package/dist/browser/workflow-approval.css +205 -0
- package/dist/browser/workflow-operation-input.d.ts.map +1 -1
- package/dist/browser/workflow-operation-input.js +1 -0
- package/dist/browser/workflow-operation-input.js.map +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1 -0
- package/dist/core.js.map +1 -1
- package/dist/react.d.ts +1 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -0
- package/dist/react.js.map +1 -1
- package/dist/resource.d.ts +22 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +18 -0
- package/dist/resource.js.map +1 -0
- package/documentation/AGENTS.md +1 -1
- package/documentation/application-templates.md +37 -0
- package/documentation/field-components.md +10 -1
- package/documentation/frontend.md +14 -4
- package/documentation/getting-started.md +9 -7
- package/documentation/manifest.json +13 -7
- package/documentation/reference/cli.md +2 -0
- package/documentation/reference/mcp.md +238 -0
- package/documentation/workflow-events.md +33 -0
- package/package.json +39 -29
- package/releases/2.63.0.json +45 -0
- package/releases/2.63.1.json +46 -0
- package/skills/manifest.json +1 -1
- package/skills/openxiangda-v2/SKILL.md +7 -7
- package/skills/openxiangda-v2/references/application-templates.md +37 -0
- package/skills/openxiangda-v2/references/cli.md +2 -0
- package/skills/openxiangda-v2/references/field-components.md +10 -1
- package/skills/openxiangda-v2/references/frontend.md +14 -4
- package/skills/openxiangda-v2/references/getting-started.md +9 -7
- package/skills/openxiangda-v2/references/mcp.md +238 -0
- package/skills/openxiangda-v2/references/workflow-events.md +33 -0
- package/releases/2.20.1.json +0 -30
- package/releases/2.20.2.json +0 -30
- package/releases/2.20.3.json +0 -29
- package/releases/2.20.4.json +0 -30
- package/releases/2.31.5.json +0 -33
- package/releases/2.59.3.json +0 -36
- package/releases/2.60.0.json +0 -38
- package/releases/2.61.0.json +0 -39
- package/releases/2.61.1.json +0 -37
- package/releases/2.61.2.json +0 -32
- package/releases/2.61.3.json +0 -33
- package/releases/2.62.0.json +0 -40
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { WorkflowParallelConfigurationEditor } from './WorkflowParallelConfigurationEditor.js';
|
|
3
|
+
import { WorkflowReminderEditor } from './WorkflowReminderEditor.js';
|
|
4
|
+
import { WorkflowNotificationEditor } from './WorkflowNotificationEditor.js';
|
|
5
|
+
import { WorkflowReturnPolicyEditor } from './WorkflowReturnPolicyEditor.js';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { Alert, App, Button, Checkbox, Collapse, Drawer, Input, Modal, Popconfirm, Radio, Segmented, Select, Skeleton, Space, Spin, Table, Tag, Tooltip } from 'antd';
|
|
8
|
+
import { ArrowLeftOutlined, CheckCircleOutlined, CloseOutlined, HistoryOutlined, MenuFoldOutlined, MenuUnfoldOutlined, RedoOutlined, RobotOutlined, SafetyOutlined, UndoOutlined, UserOutlined, FormOutlined, CodeOutlined, CopyOutlined, BranchesOutlined, BellOutlined, PlayCircleOutlined } from '@ant-design/icons';
|
|
9
|
+
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';
|
|
10
|
+
import { OpenXiangdaPlatformRequestError, loadWorkflowDesignerDraft, loadWorkflowNodeConfigurations, loadApplicationAdministrationContext, saveWorkflowDesignerDraft, previewWorkflowDesignerPublication, publishWorkflowDesigner, loadWorkflowDesignerPublication, listWorkflowDesignerPublications, restoreWorkflowDesignerVersion, controlWorkflowDesignerPublication, searchWorkflowDesignerHoldCandidates } from '../../platform-client';
|
|
11
|
+
import { createBrowserUuid } from '../../uuid';
|
|
12
|
+
import { WorkflowDiagram } from './WorkflowDiagram';
|
|
13
|
+
import { workflowDesignerDisplayGraph, workflowDesignerOutlineRows, workflowDesignerStartId } from './workflow-designer-presentation';
|
|
14
|
+
import { WorkflowDraftHandlingEditor } from './WorkflowDraftHandlingEditor';
|
|
15
|
+
import { WorkflowNodeConfigurationEditor } from './WorkflowNodeConfigurationEditor';
|
|
16
|
+
import { WorkflowDesignerAssistant } from './WorkflowDesignerAssistant';
|
|
17
|
+
import { defaultWorkflowCondition } from './WorkflowConditionEditor';
|
|
18
|
+
import { WorkflowConditionConfigurationEditor } from './WorkflowConditionConfigurationEditor';
|
|
19
|
+
const kinds = { handle: '办理节点', approval: '审批节点', condition: '条件分支', parallel: '并行分支', join: '汇合', cc: '抄送', action: '已发布业务步骤', correction: '补正', end: '结束' };
|
|
20
|
+
const id = () => `node_${createBrowserUuid().replaceAll('-', '').slice(0, 12)}`;
|
|
21
|
+
const outcomeLabels = { eligible: '可更新', migrated: '已更新', deferred: '等待步骤完成', excepted: '需单独处理', held: '保留原版本', failed: '更新失败', completed: '已结束', superseded: '已替代' };
|
|
22
|
+
const refused = (error) => error instanceof OpenXiangdaPlatformRequestError && error.status >= 400 && error.status < 500;
|
|
23
|
+
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;
|
|
24
|
+
const same = (left, right) => JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
|
|
25
|
+
/** Canonical authoring. The graph is a projection; coordinates never become executable state. */
|
|
26
|
+
export function WorkflowDesigner({ workflowCode, onPublished, onDirtyChange, onStateChange, onBack }) {
|
|
27
|
+
const { message } = App.useApp();
|
|
28
|
+
const [draft, setDraft] = useState();
|
|
29
|
+
const [definition, setDefinition] = useState();
|
|
30
|
+
const [nativeHeadRevision, setNativeHeadRevision] = useState();
|
|
31
|
+
const [configurations, setConfigurations] = useState();
|
|
32
|
+
const [selected, setSelected] = useState('');
|
|
33
|
+
const [selectedEdge, setSelectedEdge] = useState();
|
|
34
|
+
const [publishedView, setPublishedView] = useState(false);
|
|
35
|
+
const [outline, setOutline] = useState(true);
|
|
36
|
+
const [detailInspector, setDetailInspector] = useState(false);
|
|
37
|
+
const [inspector, setInspector] = useState(true);
|
|
38
|
+
const [narrow, setNarrow] = useState(() => typeof matchMedia !== 'undefined' && matchMedia('(max-width: 899px)').matches);
|
|
39
|
+
const inspectorElement = useRef(null);
|
|
40
|
+
useEffect(() => { const media = matchMedia('(max-width: 899px)'); const update = () => setNarrow(media.matches); media.addEventListener('change', update); return () => media.removeEventListener('change', update); }, []);
|
|
41
|
+
const [liveState, setLiveState] = useState({ dirty: false, busy: false, unknown: false });
|
|
42
|
+
const leaveHandling = useRef(undefined);
|
|
43
|
+
const handlingGuardChanged = useCallback((guard) => { leaveHandling.current = guard; }, []);
|
|
44
|
+
const handlingStateChanged = useCallback((state) => setLiveState(state), []);
|
|
45
|
+
const [outlineKeyword, setOutlineKeyword] = useState('');
|
|
46
|
+
const [checksOpen, setChecksOpen] = useState(false);
|
|
47
|
+
const [structureKeys, setStructureKeys] = useState([]);
|
|
48
|
+
const attemptedAutosave = useRef(undefined);
|
|
49
|
+
const [error, setError] = useState();
|
|
50
|
+
const [busy, setBusy] = useState(false);
|
|
51
|
+
const [history, setHistory] = useState([]);
|
|
52
|
+
const [future, setFuture] = useState([]);
|
|
53
|
+
const [insert, setInsert] = useState();
|
|
54
|
+
const [template, setTemplate] = useState('condition');
|
|
55
|
+
const [nodeTitle, setNodeTitle] = useState('');
|
|
56
|
+
const [assistantOpen, setAssistantOpen] = useState(false);
|
|
57
|
+
const [assistantState, setAssistantState] = useState({ busy: false, unknown: false });
|
|
58
|
+
const [versionsOpen, setVersionsOpen] = useState(false);
|
|
59
|
+
const [versions, setVersions] = useState([]);
|
|
60
|
+
const [publication, setPublication] = useState(false);
|
|
61
|
+
const [holdCandidates, setHoldCandidates] = useState([]);
|
|
62
|
+
const [preview, setPreview] = useState();
|
|
63
|
+
const [scope, setScope] = useState('running_and_new');
|
|
64
|
+
const [releaseIds, setReleaseIds] = useState([]);
|
|
65
|
+
const [releaseReason, setReleaseReason] = useState('');
|
|
66
|
+
const [reason, setReason] = useState('');
|
|
67
|
+
const [holdNodeIds, setHoldNodeIds] = useState([]);
|
|
68
|
+
const [holdIds, setHoldIds] = useState([]);
|
|
69
|
+
const [holdReason, setHoldReason] = useState('');
|
|
70
|
+
const [acknowledge, setAcknowledge] = useState(false);
|
|
71
|
+
const [receipt, setReceipt] = useState();
|
|
72
|
+
const frozenSave = useRef(undefined);
|
|
73
|
+
const frozenPublish = useRef(undefined);
|
|
74
|
+
const frozenAux = useRef(undefined);
|
|
75
|
+
const alive = useRef(true);
|
|
76
|
+
const load = useCallback(async () => {
|
|
77
|
+
const [value, configuration, context] = await Promise.all([loadWorkflowDesignerDraft(workflowCode), loadWorkflowNodeConfigurations(workflowCode), loadApplicationAdministrationContext()]);
|
|
78
|
+
if (context.headRevision == null)
|
|
79
|
+
throw new Error('当前应用没有可用的办理配置版本');
|
|
80
|
+
if (!alive.current)
|
|
81
|
+
return;
|
|
82
|
+
setDraft(value);
|
|
83
|
+
setDefinition(value.definition);
|
|
84
|
+
setConfigurations(configuration);
|
|
85
|
+
setNativeHeadRevision(context.headRevision);
|
|
86
|
+
setSelected(value.definition.startAt);
|
|
87
|
+
setHistory([]);
|
|
88
|
+
setFuture([]);
|
|
89
|
+
setError(undefined);
|
|
90
|
+
}, [workflowCode]);
|
|
91
|
+
useEffect(() => { alive.current = true; void load().catch(error => setError(String(error.message))); return () => { alive.current = false; }; }, [load]);
|
|
92
|
+
const refreshHandling = async () => {
|
|
93
|
+
const [configuration, context] = await Promise.all([loadWorkflowNodeConfigurations(workflowCode), loadApplicationAdministrationContext()]);
|
|
94
|
+
if (context.headRevision == null)
|
|
95
|
+
throw new Error('当前应用没有可用的办理配置版本');
|
|
96
|
+
setConfigurations(configuration);
|
|
97
|
+
setNativeHeadRevision(context.headRevision);
|
|
98
|
+
};
|
|
99
|
+
const dirty = !!draft && !!definition && !same(draft.definition, definition);
|
|
100
|
+
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]);
|
|
101
|
+
useEffect(() => { const guard = (event) => { if (dirty || frozenSave.current || frozenPublish.current || frozenAux.current || assistantState.unknown) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
event.returnValue = '';
|
|
104
|
+
} }; addEventListener('beforeunload', guard); return () => removeEventListener('beforeunload', guard); }, [dirty, assistantState.unknown]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!receipt || receipt.status !== 'running' || publication)
|
|
107
|
+
return;
|
|
108
|
+
let active = true;
|
|
109
|
+
const poll = setInterval(() => { void loadWorkflowDesignerPublication(workflowCode, receipt.publicationId).then(value => { if (active)
|
|
110
|
+
setReceipt(value); }, () => { }); }, 3000);
|
|
111
|
+
return () => { active = false; clearInterval(poll); };
|
|
112
|
+
}, [workflowCode, receipt?.publicationId, receipt?.status, publication]);
|
|
113
|
+
const shown = publishedView ? draft?.publishedDefinition : definition;
|
|
114
|
+
const graph = useMemo(() => shown ? projectWorkflowGraph(shown, 'draft') : undefined, [shown]);
|
|
115
|
+
const displayGraph = useMemo(() => {
|
|
116
|
+
const activeReturn = structureKeys.includes('return') ? shown?.nodes[selected] : undefined;
|
|
117
|
+
return graph ? workflowDesignerDisplayGraph(graph, activeReturn?.id, activeReturn && ['approval', 'handle'].includes(activeReturn.kind) ? workflowReturnTargets(activeReturn) : []) : undefined;
|
|
118
|
+
}, [graph, structureKeys, selected, shown]);
|
|
119
|
+
const outlineNodes = useMemo(() => displayGraph ? workflowDesignerOutlineRows(displayGraph) : [], [displayGraph]);
|
|
120
|
+
useEffect(() => { if (shown && selected !== workflowDesignerStartId && !shown.nodes[selected])
|
|
121
|
+
setSelected(shown.startAt); }, [shown, selected]);
|
|
122
|
+
const variables = useMemo(() => definition ? workflowDesignerVariables(definition) : [], [definition]);
|
|
123
|
+
const errors = useMemo(() => definition ? validateWorkflowDesignerDocument(definition) : [], [definition]);
|
|
124
|
+
const node = shown?.nodes[selected];
|
|
125
|
+
const liveNode = configurations?.nodes.find(item => item.nodeId === selected);
|
|
126
|
+
const disabled = busy || assistantState.busy || assistantState.unknown || publishedView || !!frozenSave.current || !!frozenPublish.current || !!frozenAux.current;
|
|
127
|
+
const mutate = (next) => {
|
|
128
|
+
if (!definition || disabled)
|
|
129
|
+
return;
|
|
130
|
+
setHistory(current => {
|
|
131
|
+
const bounded = [...current, definition].slice(-25);
|
|
132
|
+
while (bounded.length > 1 && bounded.reduce((bytes, item) => bytes + JSON.stringify(item).length, 0) > 4 * 1024 * 1024)
|
|
133
|
+
bounded.shift();
|
|
134
|
+
return bounded;
|
|
135
|
+
});
|
|
136
|
+
setFuture([]);
|
|
137
|
+
setDefinition(next);
|
|
138
|
+
setError(undefined);
|
|
139
|
+
};
|
|
140
|
+
const patch = (patch) => { if (definition && node)
|
|
141
|
+
mutate(editWorkflowDesignerDefinition(definition, { type: 'node', nodeId: node.id, patch })); };
|
|
142
|
+
const save = async (quiet = false) => {
|
|
143
|
+
if (!draft || !definition)
|
|
144
|
+
return undefined;
|
|
145
|
+
setBusy(true);
|
|
146
|
+
try {
|
|
147
|
+
frozenSave.current ||= { expectedRevision: draft.revision, expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), definition, binding: draft.binding };
|
|
148
|
+
const saved = await saveWorkflowDesignerDraft(workflowCode, frozenSave.current);
|
|
149
|
+
frozenSave.current = undefined;
|
|
150
|
+
setDraft(saved);
|
|
151
|
+
setDefinition(saved.definition);
|
|
152
|
+
setError(undefined);
|
|
153
|
+
if (!quiet)
|
|
154
|
+
message.success('流程草稿已保存');
|
|
155
|
+
return saved;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (refused(error))
|
|
159
|
+
frozenSave.current = undefined;
|
|
160
|
+
setError(`${String(error.message)}${refused(error) ? '。修改已保留,可修正后再次保存。' : '。结果待确认,请重试原保存请求。'}`);
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
setBusy(false);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const autosave = useRef(save);
|
|
168
|
+
autosave.current = save;
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!dirty || !definition || busy || publishedView || errors.length || frozenSave.current || frozenPublish.current || frozenAux.current || attemptedAutosave.current === definition)
|
|
171
|
+
return;
|
|
172
|
+
const timer = setTimeout(() => { attemptedAutosave.current = definition; void autosave.current(true); }, 900);
|
|
173
|
+
return () => clearTimeout(timer);
|
|
174
|
+
}, [dirty, definition, busy, publishedView, errors.length]);
|
|
175
|
+
const selectNode = (value, edgeId) => {
|
|
176
|
+
const next = () => { setSelected(value); setSelectedEdge(edgeId); if (value !== selected)
|
|
177
|
+
setStructureKeys([]); setInspector(value !== workflowDesignerStartId); };
|
|
178
|
+
if (value !== selected && leaveHandling.current)
|
|
179
|
+
leaveHandling.current(next);
|
|
180
|
+
else
|
|
181
|
+
next();
|
|
182
|
+
};
|
|
183
|
+
const selectEdge = (value) => {
|
|
184
|
+
const edge = displayGraph?.edges.find(edge => edge.id === value);
|
|
185
|
+
if (edge && ['branch', 'default'].includes(edge.kind))
|
|
186
|
+
selectNode(edge.from, value);
|
|
187
|
+
else
|
|
188
|
+
setSelectedEdge(value);
|
|
189
|
+
};
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (!narrow || !inspector)
|
|
192
|
+
return;
|
|
193
|
+
const previous = document.activeElement;
|
|
194
|
+
const element = inspectorElement.current;
|
|
195
|
+
const keydown = (event) => {
|
|
196
|
+
if (!element || !element.contains(event.target) || event.defaultPrevented)
|
|
197
|
+
return;
|
|
198
|
+
if (event.key === 'Escape' && ![...element.querySelectorAll('[aria-expanded="true"]')].some(item => item.getClientRects().length)) {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
const close = () => setInspector(false);
|
|
201
|
+
if (leaveHandling.current)
|
|
202
|
+
leaveHandling.current(close);
|
|
203
|
+
else
|
|
204
|
+
close();
|
|
205
|
+
}
|
|
206
|
+
if (event.key === 'Tab') {
|
|
207
|
+
const focusable = [...element.querySelectorAll('button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex="0"]')].filter(item => item.getClientRects().length);
|
|
208
|
+
const target = event.shiftKey && document.activeElement === focusable[0] ? focusable.at(-1) : !event.shiftKey && document.activeElement === focusable.at(-1) ? focusable[0] : undefined;
|
|
209
|
+
if (target) {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
target.focus();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
element?.querySelector('button')?.focus();
|
|
216
|
+
document.addEventListener('keydown', keydown);
|
|
217
|
+
return () => { document.removeEventListener('keydown', keydown); previous?.focus({ preventScroll: true }); };
|
|
218
|
+
}, [narrow, inspector]);
|
|
219
|
+
const switchVersion = (value) => {
|
|
220
|
+
const next = () => { setPublishedView(value === 'published'); };
|
|
221
|
+
if (leaveHandling.current)
|
|
222
|
+
leaveHandling.current(next);
|
|
223
|
+
else
|
|
224
|
+
next();
|
|
225
|
+
};
|
|
226
|
+
const goBack = () => {
|
|
227
|
+
const next = () => { if (dirty) {
|
|
228
|
+
void save(true).then(saved => { if (saved) {
|
|
229
|
+
if (onBack)
|
|
230
|
+
onBack();
|
|
231
|
+
else {
|
|
232
|
+
const url = new URL(location.href);
|
|
233
|
+
url.searchParams.delete('design');
|
|
234
|
+
location.assign(url.href);
|
|
235
|
+
}
|
|
236
|
+
} });
|
|
237
|
+
return;
|
|
238
|
+
} if (onBack)
|
|
239
|
+
onBack();
|
|
240
|
+
else {
|
|
241
|
+
const url = new URL(location.href);
|
|
242
|
+
url.searchParams.delete('design');
|
|
243
|
+
location.assign(url.href);
|
|
244
|
+
} };
|
|
245
|
+
if (leaveHandling.current)
|
|
246
|
+
leaveHandling.current(next);
|
|
247
|
+
else
|
|
248
|
+
next();
|
|
249
|
+
};
|
|
250
|
+
const holds = () => holdIds.length || holdNodeIds.length ? [{ instanceIds: holdIds, nodeIds: holdNodeIds, reason: holdReason.trim() }] : [];
|
|
251
|
+
const check = async (value = draft, selectedHolds = holds()) => {
|
|
252
|
+
if (!value)
|
|
253
|
+
return;
|
|
254
|
+
setBusy(true);
|
|
255
|
+
setPreview(undefined);
|
|
256
|
+
try {
|
|
257
|
+
const result = await previewWorkflowDesignerPublication(workflowCode, { expectedRevision: value.revision, holds: selectedHolds });
|
|
258
|
+
setPreview(result);
|
|
259
|
+
setHoldCandidates(result.items);
|
|
260
|
+
setError(undefined);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
setError(String(error.message));
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
setBusy(false);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const openPublication = async () => {
|
|
270
|
+
const saved = dirty || frozenSave.current ? await save() : draft;
|
|
271
|
+
if (!saved)
|
|
272
|
+
return;
|
|
273
|
+
setScope('running_and_new');
|
|
274
|
+
setHoldIds([]);
|
|
275
|
+
setHoldNodeIds([]);
|
|
276
|
+
setHoldReason('');
|
|
277
|
+
setReason('');
|
|
278
|
+
setAcknowledge(false);
|
|
279
|
+
setPublication(true);
|
|
280
|
+
setPreview(undefined);
|
|
281
|
+
await check(saved, []);
|
|
282
|
+
};
|
|
283
|
+
const publish = async () => {
|
|
284
|
+
if (!draft || !reason.trim() || scope === 'running_and_new' && (holdIds.length || holdNodeIds.length) && !holdReason.trim())
|
|
285
|
+
return;
|
|
286
|
+
setBusy(true);
|
|
287
|
+
try {
|
|
288
|
+
frozenPublish.current ||= { expectedRevision: draft.revision, expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), reason: reason.trim(), scope, holds: scope === 'running_and_new' ? holds() : [], acknowledgeExceptions: acknowledge };
|
|
289
|
+
const result = await publishWorkflowDesigner(workflowCode, frozenPublish.current);
|
|
290
|
+
frozenPublish.current = undefined;
|
|
291
|
+
setReceipt(result);
|
|
292
|
+
setPublication(false);
|
|
293
|
+
await load();
|
|
294
|
+
onPublished?.(result);
|
|
295
|
+
message.success('流程版本已发布并启用');
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
if (refused(error))
|
|
299
|
+
frozenPublish.current = undefined;
|
|
300
|
+
setError(`${String(error.message)}${refused(error) ? '。草稿已保留。' : '。结果待确认,重试将使用原发布请求。'}`);
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
setBusy(false);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const openAssistant = async () => {
|
|
307
|
+
if (disabled)
|
|
308
|
+
return;
|
|
309
|
+
if (dirty || frozenSave.current) {
|
|
310
|
+
const saved = await save();
|
|
311
|
+
if (!saved)
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
setInspector(true);
|
|
315
|
+
setAssistantOpen(true);
|
|
316
|
+
};
|
|
317
|
+
const showVersions = async () => {
|
|
318
|
+
setVersionsOpen(true);
|
|
319
|
+
setBusy(true);
|
|
320
|
+
try {
|
|
321
|
+
setVersions(await listWorkflowDesignerPublications(workflowCode));
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
setError(String(error.message));
|
|
325
|
+
}
|
|
326
|
+
finally {
|
|
327
|
+
setBusy(false);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const retryAux = async () => {
|
|
331
|
+
if (!frozenAux.current)
|
|
332
|
+
return;
|
|
333
|
+
setBusy(true);
|
|
334
|
+
try {
|
|
335
|
+
await frozenAux.current();
|
|
336
|
+
frozenAux.current = undefined;
|
|
337
|
+
setError(undefined);
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
if (refused(error))
|
|
341
|
+
frozenAux.current = undefined;
|
|
342
|
+
setError(`${String(error.message)}${refused(error) ? '。输入已保留。' : '。结果待确认,请重试原操作。'}`);
|
|
343
|
+
}
|
|
344
|
+
finally {
|
|
345
|
+
setBusy(false);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
const restore = async (version) => {
|
|
349
|
+
if (!draft || frozenAux.current)
|
|
350
|
+
return;
|
|
351
|
+
const input = { version, expectedRevision: draft.revision, expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid() };
|
|
352
|
+
frozenAux.current = async () => {
|
|
353
|
+
const restored = await restoreWorkflowDesignerVersion(workflowCode, input);
|
|
354
|
+
setDraft(restored);
|
|
355
|
+
setDefinition(restored.definition);
|
|
356
|
+
setHistory([]);
|
|
357
|
+
setFuture([]);
|
|
358
|
+
setVersionsOpen(false);
|
|
359
|
+
message.success('历史版本已恢复到草稿,检查后可发布');
|
|
360
|
+
};
|
|
361
|
+
await retryAux();
|
|
362
|
+
};
|
|
363
|
+
const control = async (action) => {
|
|
364
|
+
if (!receipt || !draft || frozenAux.current)
|
|
365
|
+
return;
|
|
366
|
+
const publicationId = receipt.publicationId;
|
|
367
|
+
const input = { expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), action, reason: action === 'pause' ? '管理员暂停更新' : action === 'retry_failed' ? '管理员重试更新失败的申请' : '管理员继续更新' };
|
|
368
|
+
frozenAux.current = async () => { setReceipt(await controlWorkflowDesignerPublication(workflowCode, publicationId, input)); };
|
|
369
|
+
await retryAux();
|
|
370
|
+
};
|
|
371
|
+
const searchHolds = async (keyword) => {
|
|
372
|
+
try {
|
|
373
|
+
setHoldCandidates(await searchWorkflowDesignerHoldCandidates(workflowCode, keyword));
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
setError(String(error.message));
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
const releaseHolds = async () => {
|
|
380
|
+
if (!receipt || !draft || !releaseIds.length || !releaseReason.trim() || frozenAux.current)
|
|
381
|
+
return;
|
|
382
|
+
const publicationId = receipt.publicationId;
|
|
383
|
+
const input = { expectedHeadRevision: draft.baseHeadRevision, operationId: createBrowserUuid(), action: 'release_holds', instanceIds: releaseIds, reason: releaseReason.trim() };
|
|
384
|
+
frozenAux.current = async () => { setReceipt(await controlWorkflowDesignerPublication(workflowCode, publicationId, input)); setReleaseIds([]); setReleaseReason(''); };
|
|
385
|
+
await retryAux();
|
|
386
|
+
};
|
|
387
|
+
const insertNode = (chosenTemplate = template, chosenTitle = nodeTitle, edgeId = insert) => {
|
|
388
|
+
const edge = displayGraph?.edges.find(item => item.id === edgeId);
|
|
389
|
+
if (!edge || !definition || !chosenTitle.trim())
|
|
390
|
+
return;
|
|
391
|
+
const nodeId = id();
|
|
392
|
+
if (chosenTemplate === 'parallel') {
|
|
393
|
+
const joinId = id(), branches = [{ id: 'branch_1', title: '分支 1' }, { id: 'branch_2', title: '分支 2' }];
|
|
394
|
+
try {
|
|
395
|
+
const next = edge.from === workflowDesignerStartId ? { ...definition, startAt: nodeId, nodes: { ...definition.nodes,
|
|
396
|
+
[nodeId]: { id: nodeId, kind: 'parallel', title: chosenTitle.trim(), join: joinId, branches: branches.map(branch => ({ ...branch, target: joinId })) },
|
|
397
|
+
[joinId]: { id: joinId, kind: 'join', title: '全部完成后继续', parallel: nodeId, next: edge.to } } } :
|
|
398
|
+
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 });
|
|
399
|
+
mutate(next);
|
|
400
|
+
setSelected(nodeId);
|
|
401
|
+
setInspector(true);
|
|
402
|
+
setStructureKeys([]);
|
|
403
|
+
setInsert(undefined);
|
|
404
|
+
}
|
|
405
|
+
catch (failure) {
|
|
406
|
+
message.error(failure instanceof Error ? failure.message : '并行分支添加失败');
|
|
407
|
+
}
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
let next;
|
|
411
|
+
if (chosenTemplate === 'condition')
|
|
412
|
+
next = { id: nodeId, kind: 'condition', title: chosenTitle.trim(), branches: [{ label: '条件 1', when: defaultWorkflowCondition(variables), target: edge.to }], otherwise: edge.to };
|
|
413
|
+
else if (chosenTemplate === 'platform_notify')
|
|
414
|
+
next = { id: nodeId, kind: 'action', title: chosenTitle.trim(), next: edge.to,
|
|
415
|
+
handler: { code: WORKFLOW_PLATFORM_NOTIFY_HANDLER, version: 1, mode: 'reconciled-effect' },
|
|
416
|
+
inputSchema: structuredClone(WORKFLOW_PLATFORM_NOTIFY_INPUT_SCHEMA), outputSchema: structuredClone(WORKFLOW_PLATFORM_NOTIFY_OUTPUT_SCHEMA),
|
|
417
|
+
inputs: { text: { source: 'literal', value: '请关注此申请的最新进展。' } }, notification: { template: 'workflow_message', recipients: { provider: 'initiator' } } };
|
|
418
|
+
else {
|
|
419
|
+
const source = draft?.publishedDefinition.nodes[chosenTemplate];
|
|
420
|
+
if (!source || !['approval', 'handle', 'cc', 'action'].includes(source.kind))
|
|
421
|
+
return;
|
|
422
|
+
next = { ...structuredClone(source), id: nodeId, title: chosenTitle.trim() };
|
|
423
|
+
if (next.kind === 'approval')
|
|
424
|
+
next.onApprove = edge.to;
|
|
425
|
+
else if ('next' in next)
|
|
426
|
+
next.next = edge.to;
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
mutate(edge.from === workflowDesignerStartId ? { ...definition, startAt: next.id, nodes: { ...definition.nodes, [next.id]: next } } : editWorkflowDesignerDefinition(definition, { type: 'insert', from: edge.from, target: edge.to, node: next, edge: edge.kind === 'branch' ? (edge.priority || 1) - 1 : edge.kind === 'default' ? 'default' : edge.kind }));
|
|
430
|
+
setSelected(nodeId);
|
|
431
|
+
setInspector(true);
|
|
432
|
+
setStructureKeys(next.kind === 'condition' ? [] : ['advanced']);
|
|
433
|
+
setInsert(undefined);
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
setError(String(error.message));
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
if (!draft || !definition || !graph || nativeHeadRevision == null)
|
|
440
|
+
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 });
|
|
441
|
+
const targets = Object.values(definition.nodes).filter(item => item.id !== selected).map(item => ({ value: item.id, label: item.title || item.id }));
|
|
442
|
+
const typeIcons = { approval: UserOutlined, handle: FormOutlined, condition: BranchesOutlined, parallel: BranchesOutlined, join: CheckCircleOutlined, action: CodeOutlined, cc: CopyOutlined, correction: FormOutlined, end: CheckCircleOutlined, start: PlayCircleOutlined };
|
|
443
|
+
const NodeIcon = isWorkflowPlatformNotify(node) ? BellOutlined : typeIcons[node?.kind] || CodeOutlined;
|
|
444
|
+
const summaries = Object.fromEntries((configurations?.nodes || []).map(item => {
|
|
445
|
+
const binding = item.effective.binding;
|
|
446
|
+
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) : '按已配置的人员规则';
|
|
447
|
+
const mode = { single: '单人', any: '或签', all: '会签', sequence: '依次审批' }[item.effective.mode || ''] || '';
|
|
448
|
+
return [item.nodeId, `${mode}${mode ? ' · ' : ''}${source}`];
|
|
449
|
+
}));
|
|
450
|
+
const human = node?.kind === 'approval' || node?.kind === 'handle';
|
|
451
|
+
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: () => { const close = () => setInspector(false); if (leaveHandling.current)
|
|
452
|
+
leaveHandling.current(close);
|
|
453
|
+
else
|
|
454
|
+
close(); } })] }), 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: () => setInspector(false), 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}`) : human && _jsx(WorkflowDraftHandlingEditor, { node: node, baseline: Object.values(draft.publishedDefinition.nodes).find(source => source.kind === node.kind && 'taskPageCode' in source && source.taskPageCode === node.taskPageCode && 'binding' in source && source.binding === node.binding) || node, bindingOptions: Object.keys(draft.publishedBinding.bindings).map(value => ({ value, label: `${Object.values(draft.publishedDefinition.nodes).find(source => 'binding' in source && source.binding === value)?.title || '已发布节点'}的人员规则` })), disabled: disabled, onChange: value => patch({ ...value, ...(typeof value.binding === 'string' && draft.publishedBinding.bindings[value.binding]?.provider === 'supervisor_chain' && draft.publishedBinding.bindings[value.binding]?.continuous !== false ? { mode: 'sequence' } : {}) }) }) }), 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: [
|
|
455
|
+
{ 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 }) })] }) },
|
|
456
|
+
...(human ? [{ key: 'return', label: '退回设置', extra: _jsx("span", { children: (node.returnPolicy?.targets || node.returnTargets || []).length ? `可退回 ${(node.returnPolicy?.targets || node.returnTargets || []).length} 个节点` : '未配置退回目标' }), children: null }] : []),
|
|
457
|
+
...(['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, onChange: reminders => patch({ reminders }) }) }) }] : []),
|
|
458
|
+
...('taskPageCode' in node ? [{ key: 'page', label: '本节点表单', extra: _jsx("span", { children: definition.taskPages?.[node.taskPageCode || '']?.title || '应用自定义页面' }), children: _jsx("p", { children: "\u9875\u9762\u5185\u5BB9\u548C\u5B57\u6BB5\u89C4\u5219\u7531\u5E94\u7528\u7EF4\u62A4\u3002\u529E\u7406\u4EBA\u5458\u53EA\u80FD\u6309\u672C\u8282\u70B9\u5DF2\u5F00\u653E\u7684\u5B57\u6BB5\u586B\u5199\u3002" }) }] : []),
|
|
459
|
+
{ 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: ["\u4EBA\u5458\u89C4\u5219", _jsx(Select, { disabled: disabled, value: node.binding, options: Object.keys(draft.publishedBinding.bindings).map(value => ({ value, label: draft.publishedBinding.bindings[value]?.provider === 'supervisor_chain' ? formatWorkflowSupervisorChain(draft.publishedBinding.bindings[value]) : `${Object.values(draft.publishedDefinition.nodes).find(node => 'binding' in node && node.binding === value)?.title || '已发布节点'}的人员规则` })), onChange: binding => patch({ binding, ...(draft.publishedBinding.bindings[binding]?.provider === 'supervisor_chain' && draft.publishedBinding.bindings[binding]?.continuous !== false ? { mode: 'sequence' } : {}) }) })] }), _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: () => { try {
|
|
460
|
+
const next = editWorkflowDesignerDefinition(definition, { type: 'remove', nodeId: node.id, ...(node.kind === 'condition' ? { reconnectTo: node.otherwise } : {}) });
|
|
461
|
+
mutate(next);
|
|
462
|
+
setSelected(next.startAt);
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
message.error('此节点有多个出口,请先选择明确的后续节点。');
|
|
466
|
+
} }, children: _jsx(Button, { danger: true, disabled: disabled, children: "\u5220\u9664\u8282\u70B9" }) })] }) },
|
|
467
|
+
] })] })] }) : _jsx("p", { children: "\u53D1\u8D77\u540E\u6309\u6D41\u7A0B\u7ED3\u6784\u8FDB\u5165\u7B2C\u4E00\u4E2A\u8282\u70B9\u3002" })] });
|
|
468
|
+
const diagnostic = (error) => {
|
|
469
|
+
const [code, nodeId] = error.split(':');
|
|
470
|
+
const title = nodeId ? definition.nodes[nodeId]?.title || '节点' : '流程';
|
|
471
|
+
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: '条件分支数量超出限制' };
|
|
472
|
+
return `${title}:${messages[code || ''] || '配置需要调整'}`;
|
|
473
|
+
};
|
|
474
|
+
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 || !history.length, onClick: () => { const previous = history.at(-1); if (previous) {
|
|
475
|
+
setFuture(current => [...current, definition]);
|
|
476
|
+
setHistory(current => current.slice(0, -1));
|
|
477
|
+
setDefinition(previous);
|
|
478
|
+
} }, children: "\u64A4\u9500" }) }), _jsx(Tooltip, { title: "\u91CD\u505A", children: _jsx(Button, { icon: _jsx(RedoOutlined, {}), "aria-label": "\u91CD\u505A", disabled: disabled || !future.length, onClick: () => { const next = future.at(-1); if (next) {
|
|
479
|
+
setHistory(current => [...current, definition]);
|
|
480
|
+
setFuture(current => current.slice(0, -1));
|
|
481
|
+
setDefinition(next);
|
|
482
|
+
} }, 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)
|
|
483
|
+
leaveHandling.current(open);
|
|
484
|
+
else
|
|
485
|
+
open(); }, children: "AI \u52A9\u624B" }), _jsx(Button, { type: "primary", disabled: disabled || 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)
|
|
486
|
+
setDetailInspector(false); setOutline(value => !value); }; if (!outline && leaveHandling.current)
|
|
487
|
+
leaveHandling.current(toggle);
|
|
488
|
+
else
|
|
489
|
+
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 => {
|
|
490
|
+
const Icon = item.presentation === 'notification' ? BellOutlined : typeIcons[item.kind] || CodeOutlined;
|
|
491
|
+
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);
|
|
492
|
+
}) }), 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: [...Object.values(draft.publishedDefinition.nodes).filter(source => ['approval', 'handle', 'cc', 'action'].includes(source.kind) && !isWorkflowPlatformNotify(source)).map(source => ({ value: source.id, label: source.title || kinds[source.kind] || '已发布节点', kind: source.kind })), ...(variables.length ? [{ value: 'condition', label: '条件分支', kind: 'condition' }] : []), { value: 'parallel', label: '并行分支', kind: 'parallel' }, { value: 'platform_notify', label: '发送通知', kind: 'notification' }], onInsertEdge: disabled ? undefined : (value, chosenTemplate) => { const open = () => { if (chosenTemplate) {
|
|
493
|
+
const title = chosenTemplate === 'parallel' ? '并行分支' : chosenTemplate === 'condition' ? '条件分支' : chosenTemplate === 'platform_notify' ? '发送通知' : draft.publishedDefinition.nodes[chosenTemplate]?.title || '新增节点';
|
|
494
|
+
insertNode(chosenTemplate, title, value);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
setInsert(value);
|
|
498
|
+
setNodeTitle('');
|
|
499
|
+
setTemplate(variables.length ? 'condition' : Object.values(draft.publishedDefinition.nodes).find(node => node.kind === 'approval' || node.kind === 'handle')?.id || '');
|
|
500
|
+
} }; if (leaveHandling.current)
|
|
501
|
+
leaveHandling.current(open);
|
|
502
|
+
else
|
|
503
|
+
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: () => { const close = () => setInspector(false); if (leaveHandling.current)
|
|
504
|
+
leaveHandling.current(close);
|
|
505
|
+
else
|
|
506
|
+
close(); } }), _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, 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); setHistory(current => { const snapshots = [...current, definition].slice(-25); while (snapshots.length > 1 && snapshots.reduce((bytes, item) => bytes + JSON.stringify(item).length, 0) > 4 * 1024 * 1024)
|
|
507
|
+
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: "\u5728\u9009\u4E2D\u8DEF\u5F84\u4E2D\u63D2\u5165\u8282\u70B9\uFF0C\u6CBF\u7528\u5DF2\u53D1\u5E03\u7684\u4EBA\u5458\u89C4\u5219\u3001\u4E1A\u52A1\u6B65\u9AA4\u548C\u9875\u9762\u3002" }), _jsxs("label", { children: ["\u8282\u70B9\u7C7B\u578B", _jsx(Select, { style: { width: '100%' }, value: template, onChange: setTemplate, options: [{ 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: `${kinds[node.kind]} · ${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)
|
|
508
|
+
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" })] })] })] })] })] });
|
|
509
|
+
}
|
|
510
|
+
//# sourceMappingURL=WorkflowDesigner.js.map
|