1
This commit is contained in:
parent
fa506b4d96
commit
79c9804dbd
@ -21,7 +21,7 @@ interface NodeConfigModalProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface FormData {
|
interface FormData {
|
||||||
config?: Record<string, any>;
|
configs?: Record<string, any>;
|
||||||
inputMapping?: Record<string, any>;
|
inputMapping?: Record<string, any>;
|
||||||
outputMapping?: Record<string, any>;
|
outputMapping?: Record<string, any>;
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ const NodeConfigModal: React.FC<NodeConfigModalProps> = ({
|
|||||||
|
|
||||||
// 合并默认值和已保存的配置
|
// 合并默认值和已保存的配置
|
||||||
setFormData({
|
setFormData({
|
||||||
config: { ...defaultConfig, ...(nodeData.config || {}) },
|
configs: { ...defaultConfig, ...(nodeData.configs || {}) },
|
||||||
inputMapping: nodeData.inputMapping || {},
|
inputMapping: nodeData.inputMapping || {},
|
||||||
outputMapping: nodeData.outputMapping || {},
|
outputMapping: nodeData.outputMapping || {},
|
||||||
});
|
});
|
||||||
@ -71,7 +71,7 @@ const NodeConfigModal: React.FC<NodeConfigModalProps> = ({
|
|||||||
const handleConfigChange = (values: Record<string, any>) => {
|
const handleConfigChange = (values: Record<string, any>) => {
|
||||||
setFormData(prev => ({
|
setFormData(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
config: values
|
configs: values
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,10 +101,10 @@ const NodeConfigModal: React.FC<NodeConfigModalProps> = ({
|
|||||||
children: (
|
children: (
|
||||||
<div style={{ padding: '16px 0' }}>
|
<div style={{ padding: '16px 0' }}>
|
||||||
<BetaSchemaForm
|
<BetaSchemaForm
|
||||||
key={`config-${node?.id}-${JSON.stringify(formData.config)}`}
|
key={`configs-${node?.id}-${JSON.stringify(formData.configs)}`}
|
||||||
layoutType="Form"
|
layoutType="Form"
|
||||||
columns={convertJsonSchemaToColumns(nodeDefinition.configSchema as any)}
|
columns={convertJsonSchemaToColumns(nodeDefinition.configSchema as any)}
|
||||||
initialValues={formData.config}
|
initialValues={formData.configs}
|
||||||
onValuesChange={(_, allValues) => handleConfigChange(allValues)}
|
onValuesChange={(_, allValues) => handleConfigChange(allValues)}
|
||||||
submitter={false}
|
submitter={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -178,7 +178,7 @@ export const useWorkflowData = () => {
|
|||||||
nodeType: nodeData.nodeType,
|
nodeType: nodeData.nodeType,
|
||||||
nodeName: nodeData.nodeName,
|
nodeName: nodeData.nodeName,
|
||||||
position, // 只保存位置信息
|
position, // 只保存位置信息
|
||||||
config: nodeData.config || {}, // 节点配置数据
|
configs: nodeData.configs || {}, // 节点配置数据
|
||||||
inputMapping: nodeData.inputMapping || {}, // 输入映射数据
|
inputMapping: nodeData.inputMapping || {}, // 输入映射数据
|
||||||
outputMapping: nodeData.outputMapping || {} // 输出映射数据
|
outputMapping: nodeData.outputMapping || {} // 输出映射数据
|
||||||
};
|
};
|
||||||
|
|||||||
@ -40,8 +40,8 @@ export const useWorkflowModals = () => {
|
|||||||
selectedNode.setData(updatedData);
|
selectedNode.setData(updatedData);
|
||||||
|
|
||||||
// 更新节点显示名称(如果配置中有nodeName)
|
// 更新节点显示名称(如果配置中有nodeName)
|
||||||
if (formData.config?.nodeName) {
|
if (formData.configs?.nodeName) {
|
||||||
selectedNode.attr('label/text', formData.config.nodeName);
|
selectedNode.attr('label/text', formData.configs.nodeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfigModalVisible(false);
|
setConfigModalVisible(false);
|
||||||
|
|||||||
@ -133,7 +133,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.x6-node-selected {
|
.x6-node-selected {
|
||||||
rect {
|
rect, ellipse {
|
||||||
stroke: #1890ff;
|
stroke: #1890ff;
|
||||||
stroke-width: 2px;
|
stroke-width: 2px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,10 @@ export const EndEventNode: BaseNodeDefinition = {
|
|||||||
|
|
||||||
// UI 配置 - 节点在画布上的显示样式(现代化设计)
|
// UI 配置 - 节点在画布上的显示样式(现代化设计)
|
||||||
uiConfig: {
|
uiConfig: {
|
||||||
shape: 'circle',
|
shape: 'ellipse',
|
||||||
size: {
|
size: {
|
||||||
width: 60,
|
width: 80,
|
||||||
height: 60
|
height: 50
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
fill: '#f5222d',
|
fill: '#f5222d',
|
||||||
|
|||||||
@ -13,10 +13,10 @@ export const StartEventNode: BaseNodeDefinition = {
|
|||||||
|
|
||||||
// UI 配置 - 节点在画布上的显示样式(现代化设计)
|
// UI 配置 - 节点在画布上的显示样式(现代化设计)
|
||||||
uiConfig: {
|
uiConfig: {
|
||||||
shape: 'circle',
|
shape: 'ellipse',
|
||||||
size: {
|
size: {
|
||||||
width: 60,
|
width: 80,
|
||||||
height: 60
|
height: 50
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
fill: '#52c41a',
|
fill: '#52c41a',
|
||||||
|
|||||||
@ -62,7 +62,7 @@ export interface PortGroups {
|
|||||||
out?: PortConfig;
|
out?: PortConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NodeShape = 'rect' | 'circle' | 'diamond';
|
export type NodeShape = 'rect' | 'circle' | 'ellipse' | 'polygon';
|
||||||
|
|
||||||
export interface NodeStyle {
|
export interface NodeStyle {
|
||||||
fill: string;
|
fill: string;
|
||||||
|
|||||||
@ -11,17 +11,9 @@ export const createNodeFromDefinition = (
|
|||||||
) => {
|
) => {
|
||||||
const {uiConfig} = nodeDefinition;
|
const {uiConfig} = nodeDefinition;
|
||||||
|
|
||||||
// 根据形状类型设置正确的 shape
|
// 创建节点配置 - 直接使用X6原生形状名称
|
||||||
let shape = 'rect';
|
|
||||||
if (uiConfig.shape === 'circle') {
|
|
||||||
shape = 'circle';
|
|
||||||
} else if (uiConfig.shape === 'diamond') {
|
|
||||||
shape = 'polygon';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建节点配置
|
|
||||||
const nodeConfig = {
|
const nodeConfig = {
|
||||||
shape,
|
shape: uiConfig.shape,
|
||||||
x: position.x,
|
x: position.x,
|
||||||
y: position.y,
|
y: position.y,
|
||||||
width: uiConfig.size.width,
|
width: uiConfig.size.width,
|
||||||
@ -29,7 +21,7 @@ export const createNodeFromDefinition = (
|
|||||||
attrs: {
|
attrs: {
|
||||||
body: {
|
body: {
|
||||||
...uiConfig.style,
|
...uiConfig.style,
|
||||||
...(uiConfig.shape === 'diamond' ? {
|
...(uiConfig.shape === 'polygon' ? {
|
||||||
refPoints: '0,10 10,0 20,10 10,20',
|
refPoints: '0,10 10,0 20,10 10,20',
|
||||||
} : {})
|
} : {})
|
||||||
},
|
},
|
||||||
@ -46,7 +38,11 @@ export const createNodeFromDefinition = (
|
|||||||
data: {
|
data: {
|
||||||
nodeType: nodeDefinition.nodeType,
|
nodeType: nodeDefinition.nodeType,
|
||||||
nodeCode: nodeDefinition.nodeCode,
|
nodeCode: nodeDefinition.nodeCode,
|
||||||
nodeName: nodeDefinition.nodeName
|
nodeName: nodeDefinition.nodeName,
|
||||||
|
// 新创建的节点,configs等数据为空
|
||||||
|
configs: {},
|
||||||
|
inputMapping: {},
|
||||||
|
outputMapping: {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,18 +60,10 @@ export const restoreNodeFromData = (
|
|||||||
// 从节点定义中获取UI配置,兼容旧数据中的uiConfig
|
// 从节点定义中获取UI配置,兼容旧数据中的uiConfig
|
||||||
const uiConfig = nodeData.uiConfig || nodeDefinition.uiConfig;
|
const uiConfig = nodeData.uiConfig || nodeDefinition.uiConfig;
|
||||||
|
|
||||||
// 根据形状类型设置正确的 shape
|
// 创建节点配置 - 直接使用X6原生形状名称
|
||||||
let shape = 'rect';
|
|
||||||
if (uiConfig.shape === 'circle') {
|
|
||||||
shape = 'circle';
|
|
||||||
} else if (uiConfig.shape === 'diamond') {
|
|
||||||
shape = 'polygon';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建节点配置
|
|
||||||
const nodeConfig = {
|
const nodeConfig = {
|
||||||
id: nodeData.nodeCode, // 使用保存的ID
|
id: nodeData.nodeCode, // 使用保存的ID
|
||||||
shape,
|
shape: uiConfig.shape,
|
||||||
x: nodeData.position.x,
|
x: nodeData.position.x,
|
||||||
y: nodeData.position.y,
|
y: nodeData.position.y,
|
||||||
width: uiConfig.size.width,
|
width: uiConfig.size.width,
|
||||||
@ -83,7 +71,7 @@ export const restoreNodeFromData = (
|
|||||||
attrs: {
|
attrs: {
|
||||||
body: {
|
body: {
|
||||||
...uiConfig.style,
|
...uiConfig.style,
|
||||||
...(uiConfig.shape === 'diamond' ? {
|
...(uiConfig.shape === 'polygon' ? {
|
||||||
refPoints: '0,10 10,0 20,10 10,20',
|
refPoints: '0,10 10,0 20,10 10,20',
|
||||||
} : {})
|
} : {})
|
||||||
},
|
},
|
||||||
@ -101,9 +89,10 @@ export const restoreNodeFromData = (
|
|||||||
nodeType: nodeData.nodeType,
|
nodeType: nodeData.nodeType,
|
||||||
nodeCode: nodeData.nodeCode,
|
nodeCode: nodeData.nodeCode,
|
||||||
nodeName: nodeData.nodeName,
|
nodeName: nodeData.nodeName,
|
||||||
configs: nodeData.configs,
|
// 统一使用configs字段名
|
||||||
inputMapping: nodeData.inputMapping,
|
configs: nodeData.configs || {},
|
||||||
outputMapping: nodeData.outputMapping
|
inputMapping: nodeData.inputMapping || {},
|
||||||
|
outputMapping: nodeData.outputMapping || {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user