1
This commit is contained in:
parent
603cd19420
commit
e6bd17d9d0
@ -55,6 +55,20 @@ const NodeDesignForm: React.FC = () => {
|
||||
// 获取当前节点可用的 Tab 列表
|
||||
const getAvailableTabs = (node: NodeDesignData | null) => {
|
||||
if (!node) return [];
|
||||
|
||||
// 如果是修改模式,从nodeDefinitions中找到对应的节点定义
|
||||
if (nodeData) {
|
||||
const nodeDefinition = nodeDefinitions.find(def => def.nodeCode === nodeData.nodeType);
|
||||
if (nodeDefinition) {
|
||||
return TAB_CONFIG.filter(tab => {
|
||||
// 使用节点定义中的schema
|
||||
const value = nodeDefinition[tab.schemaKey as keyof NodeDesignData];
|
||||
return value !== null && value !== undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 新建模式
|
||||
return TAB_CONFIG.filter(tab => {
|
||||
const value = node[tab.schemaKey as keyof NodeDesignData];
|
||||
return value !== null && value !== undefined;
|
||||
@ -212,15 +226,48 @@ const NodeDesignForm: React.FC = () => {
|
||||
// 渲染 Tab 内容
|
||||
const renderTabContent = (schemaKey: string) => {
|
||||
if (!selectedNode) return null;
|
||||
const schema = selectedNode[schemaKey as keyof NodeDesignData];
|
||||
|
||||
// 获取schema和初始值
|
||||
let schema;
|
||||
let initialValues = {};
|
||||
|
||||
if (nodeData) {
|
||||
// 编辑模式
|
||||
const nodeDefinition = nodeDefinitions.find(def => def.nodeCode === nodeData.nodeType);
|
||||
if (!nodeDefinition) return null;
|
||||
|
||||
if (schemaKey === 'uiVariables') {
|
||||
// UI配置:使用nodeDefinitions中的schema定义,使用nodeData中的实际数据作为初始值
|
||||
schema = nodeDefinition.uiVariables;
|
||||
initialValues = nodeData.uiVariables || {};
|
||||
} else {
|
||||
// 其他配置:使用schema中的定义
|
||||
schema = nodeDefinition[schemaKey as keyof NodeDesignData];
|
||||
// 只在非UI配置时使用默认值
|
||||
initialValues = getDefaultValues(schema);
|
||||
}
|
||||
} else {
|
||||
// 新建模式
|
||||
schema = selectedNode[schemaKey as keyof NodeDesignData];
|
||||
initialValues = getDefaultValues(schema);
|
||||
}
|
||||
|
||||
if (!schema) return null;
|
||||
|
||||
console.log(`Rendering ${schemaKey}:`, {
|
||||
schema,
|
||||
initialValues
|
||||
});
|
||||
|
||||
const formColumns = convertToProFormSchema(schema);
|
||||
|
||||
return (
|
||||
<BetaSchemaForm
|
||||
key={`${selectedNode.nodeCode}-${schemaKey}`}
|
||||
formRef={schemaKey === 'uiVariables' ? uiFormRef : undefined}
|
||||
layoutType="Form"
|
||||
initialValues={getDefaultValues(schema)}
|
||||
columns={convertToProFormSchema(schema)}
|
||||
initialValues={initialValues}
|
||||
columns={formColumns}
|
||||
submitter={false}
|
||||
/>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user