yyd-flow-designer 0.1.5 → 0.1.6
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/package.json
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import { Position } from '@xyflow/react';
|
|
2
2
|
import BpmnNodeWrapper from '../components/BpmnNodeWrapper';
|
|
3
|
+
import {
|
|
4
|
+
FLOW_ACTION_APPROVE,
|
|
5
|
+
FLOW_ACTION_KEY,
|
|
6
|
+
FLOW_ACTION_REJECT,
|
|
7
|
+
} from '../config';
|
|
3
8
|
import { IconExclusiveGateway } from '../icons';
|
|
4
9
|
import { CustomNodeProps } from '../types';
|
|
5
10
|
|
|
11
|
+
const DEFAULT_BRANCHES = [
|
|
12
|
+
{
|
|
13
|
+
id: 'no',
|
|
14
|
+
label: '驳回',
|
|
15
|
+
andor: 'and' as const,
|
|
16
|
+
conditions: [{ key: FLOW_ACTION_KEY, mode: 'equal', value: FLOW_ACTION_REJECT }],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'yes',
|
|
20
|
+
label: '通过',
|
|
21
|
+
andor: 'and' as const,
|
|
22
|
+
conditions: [{ key: FLOW_ACTION_KEY, mode: 'equal', value: FLOW_ACTION_APPROVE }],
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
6
26
|
const ExclusiveGateway = (props: CustomNodeProps) => {
|
|
7
27
|
const { id } = props;
|
|
8
|
-
const branches = props.data?.nodeConfig?.content?.branches ??
|
|
9
|
-
{ id: 'no', label: '驳回', condition: '' },
|
|
10
|
-
{ id: 'yes', label: '通过', condition: '' },
|
|
11
|
-
];
|
|
28
|
+
const branches = props.data?.nodeConfig?.content?.branches ?? DEFAULT_BRANCHES;
|
|
12
29
|
|
|
13
30
|
return (
|
|
14
31
|
<BpmnNodeWrapper
|
|
@@ -42,21 +59,9 @@ ExclusiveGateway.nodeSchema = {
|
|
|
42
59
|
code: '',
|
|
43
60
|
name: '判断',
|
|
44
61
|
description: '',
|
|
45
|
-
inputs
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
id: 'no',
|
|
49
|
-
label: '驳回',
|
|
50
|
-
andor: 'and',
|
|
51
|
-
conditions: [{ key: '', mode: 'equal', value: '' }],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: 'yes',
|
|
55
|
-
label: '通过',
|
|
56
|
-
andor: 'and',
|
|
57
|
-
conditions: [{ key: '', mode: 'equal', value: '' }],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
62
|
+
// 约定:续跑 UserTask 时 command.inputs.action = approve | reject
|
|
63
|
+
inputs: [{ key: FLOW_ACTION_KEY, mode: 'value', value: '' }],
|
|
64
|
+
branches: DEFAULT_BRANCHES,
|
|
60
65
|
},
|
|
61
66
|
},
|
|
62
67
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Position } from '@xyflow/react';
|
|
2
2
|
import BpmnNodeWrapper from '../components/BpmnNodeWrapper';
|
|
3
|
+
import { FLOW_ACTION_KEY } from '../config';
|
|
3
4
|
import { IconUserTask } from '../icons';
|
|
4
5
|
import { CustomNodeProps } from '../types';
|
|
5
6
|
|
|
@@ -31,7 +32,8 @@ UserTask.nodeSchema = {
|
|
|
31
32
|
},
|
|
32
33
|
timeoutSetting: [],
|
|
33
34
|
inputs: [],
|
|
34
|
-
|
|
35
|
+
// 提交时写入 command.inputs.action(approve | reject),供后续判断节点使用
|
|
36
|
+
outputs: [{ key: FLOW_ACTION_KEY, mode: 'value', value: '' }],
|
|
35
37
|
outputNotifyWebhook: { enabled: false, url: '', body: [] },
|
|
36
38
|
},
|
|
37
39
|
},
|
|
@@ -57,6 +57,11 @@ export const SERVICE_TYPE_OPTIONS = [
|
|
|
57
57
|
{ label: 'HTTP 调用', value: 'http' },
|
|
58
58
|
];
|
|
59
59
|
|
|
60
|
+
/** 审批结果约定:UserTask 提交 / ExclusiveGateway 默认分支共用 */
|
|
61
|
+
export const FLOW_ACTION_KEY = 'action';
|
|
62
|
+
export const FLOW_ACTION_APPROVE = 'approve';
|
|
63
|
+
export const FLOW_ACTION_REJECT = 'reject';
|
|
64
|
+
|
|
60
65
|
/** 条件分支运算符(与 API 条件节点语义对齐) */
|
|
61
66
|
export const BPMN_CONDITION_MODE_OPTIONS = [
|
|
62
67
|
{ label: '等于', value: 'equal' },
|
|
@@ -103,6 +103,18 @@ export const validateFlowGraph = (nodes: Node[] = [], edges: Edge[] = []): FlowI
|
|
|
103
103
|
if (!(outgoingByHandle.get(`${node.id}::${handle}`) ?? 0)) {
|
|
104
104
|
issues.push({ level: 'error', message: `${label}:分支「${branchLabel}」未连出` });
|
|
105
105
|
}
|
|
106
|
+
// 非末条分支若条件 key 全空,引擎会跳过;末条作兜底。空 equal 曾会恒真导致回环死循环。
|
|
107
|
+
const isLast = idx === branches.length - 1;
|
|
108
|
+
if (!isLast) {
|
|
109
|
+
const conditions = Array.isArray(branch?.conditions) ? branch.conditions : [];
|
|
110
|
+
const hasKeyed = conditions.some((c: any) => String(c?.key ?? '').trim());
|
|
111
|
+
if (!hasKeyed) {
|
|
112
|
+
issues.push({
|
|
113
|
+
level: 'warning',
|
|
114
|
+
message: `${label}:分支「${branchLabel}」未配置条件字段,执行时不会命中(仅末条可作兜底)`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
106
118
|
});
|
|
107
119
|
}
|
|
108
120
|
}
|