增加节点验证。
This commit is contained in:
parent
19ee89418a
commit
17acef1529
@ -20,6 +20,7 @@ import NodeConfig from './components/NodeConfig';
|
||||
import Toolbar from './components/Toolbar';
|
||||
import {NodeType, getNodeTypes} from './service';
|
||||
import {DeleteOutlined, CopyOutlined, SettingOutlined, ClearOutlined, FullscreenOutlined} from '@ant-design/icons';
|
||||
import { validateFlow, hasCycle } from './validate';
|
||||
|
||||
const {Sider, Content} = Layout;
|
||||
|
||||
@ -99,7 +100,7 @@ const FlowDesigner: React.FC = () => {
|
||||
},
|
||||
{
|
||||
key: 'config',
|
||||
label: '配置节点',
|
||||
label: '<EFBFBD><EFBFBD><EFBFBD>置节点',
|
||||
icon: <SettingOutlined />,
|
||||
onClick: () => {
|
||||
if (contextMenu.cell && contextMenu.cell.isNode()) {
|
||||
@ -247,9 +248,7 @@ const FlowDesigner: React.FC = () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
keyboard: {
|
||||
enabled: true,
|
||||
},
|
||||
keyboard: true,
|
||||
clipboard: {
|
||||
enabled: true,
|
||||
},
|
||||
@ -310,7 +309,7 @@ const FlowDesigner: React.FC = () => {
|
||||
minWidth: 1,
|
||||
minHeight: 1,
|
||||
orthogonal: true,
|
||||
restricted: true,
|
||||
restrict: true,
|
||||
},
|
||||
rotating: {
|
||||
enabled: true,
|
||||
@ -597,7 +596,7 @@ const FlowDesigner: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取详情
|
||||
// 获取<EFBFBD><EFBFBD>情
|
||||
const fetchDetail = async () => {
|
||||
if (!id) return;
|
||||
setLoading(true);
|
||||
@ -615,11 +614,34 @@ const FlowDesigner: React.FC = () => {
|
||||
const handleSave = async () => {
|
||||
if (!id || !detail || !graphRef.current || detail.status !== WorkflowStatus.DRAFT) return;
|
||||
|
||||
// 先进行流程验证
|
||||
const result = validateFlow(graphRef.current);
|
||||
const hasCycleResult = hasCycle(graphRef.current);
|
||||
|
||||
if (hasCycleResult) {
|
||||
result.errors.push('流程图中存在循环依赖');
|
||||
result.valid = false;
|
||||
}
|
||||
|
||||
if (!result.valid) {
|
||||
message.error(
|
||||
<div>
|
||||
<div>流程验证失败,无法保存:</div>
|
||||
<ul style={{ marginBottom: 0 }}>
|
||||
{result.errors.map((error, index) => (
|
||||
<li key={index}>{error}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取图形数据
|
||||
const graphData = graphRef.current.toJSON();
|
||||
|
||||
// 收集节点配置数据
|
||||
// 收<EFBFBD><EFBFBD><EFBFBD>节点配置数据
|
||||
const nodes = graphRef.current.getNodes().map(node => {
|
||||
const data = node.getData() as NodeData;
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user