1
This commit is contained in:
parent
f79e0db965
commit
c46fe9e420
@ -9,6 +9,8 @@ import {BetaSchemaForm} from '@ant-design/pro-form';
|
||||
import {convertJsonSchemaToColumns} from '@/utils/jsonSchemaUtils';
|
||||
import {Editor} from '@/components/Editor';
|
||||
import type {JsonNode} from '@/types/common';
|
||||
import {getPublishedDefinitions} from '@/pages/Workflow/Definition/service';
|
||||
import type {WorkflowDefinition} from '@/pages/Workflow/Definition/types';
|
||||
import './styles.less';
|
||||
|
||||
const {Option} = Select;
|
||||
@ -34,6 +36,7 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
const [selectedTemplate, setSelectedTemplate] = useState<DeployConfigTemplate>();
|
||||
const [buildVariables, setBuildVariables] = useState<JsonNode>({});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [workflowDefinitions, setWorkflowDefinitions] = useState<WorkflowDefinition[]>([]);
|
||||
const [fullscreenEditor, setFullscreenEditor] = useState<{
|
||||
key: string;
|
||||
title: string;
|
||||
@ -60,13 +63,26 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 获取已发布的工作流列表
|
||||
const fetchWorkflowDefinitions = useCallback(async () => {
|
||||
try {
|
||||
const data = await getPublishedDefinitions(0);
|
||||
setWorkflowDefinitions(data);
|
||||
} catch (error) {
|
||||
message.error('获取工作流列表失败');
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 在模态框显示时获取数据
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
fetchApplications();
|
||||
fetchTemplates();
|
||||
if (!isEdit) {
|
||||
fetchWorkflowDefinitions();
|
||||
}
|
||||
}
|
||||
}, [open, fetchApplications, fetchTemplates]);
|
||||
}, [open, fetchApplications, fetchTemplates, fetchWorkflowDefinitions, isEdit]);
|
||||
|
||||
// 初始化表单数据
|
||||
useEffect(() => {
|
||||
@ -140,8 +156,8 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
throw new Error('未找到匹配配置模板');
|
||||
}
|
||||
|
||||
// 从 formValues 中提取构建变量(排除 applicationId 和 enabled)
|
||||
const { applicationId, enabled, ...formBuildVariables } = formValues;
|
||||
// 从 formValues 中提取构建变量(排除 applicationId、enabled 和 workflowDefinitionId)
|
||||
const { applicationId, enabled, workflowDefinitionId, ...formBuildVariables } = formValues;
|
||||
|
||||
// 构建提交数据
|
||||
const submitData: CreateDeploymentConfigRequest = {
|
||||
@ -153,7 +169,8 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
...formBuildVariables, // 表单中的值
|
||||
...buildVariables // 编辑器中的值
|
||||
} as Record<string, any>, // 使用类型断言确保类型兼容
|
||||
enabled
|
||||
enabled,
|
||||
workflowDefinitionId: isEdit ? initialValues.workflowDefinitionId : workflowDefinitionId
|
||||
};
|
||||
|
||||
if (isEdit) {
|
||||
@ -239,6 +256,28 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
{/* 工作流选择 */}
|
||||
{!isEdit && (
|
||||
<Form.Item
|
||||
name="workflowDefinitionId"
|
||||
label="工作流"
|
||||
required
|
||||
tooltip="选择要使用的工作流"
|
||||
>
|
||||
<Select
|
||||
placeholder="请选择工作流"
|
||||
showSearch
|
||||
optionFilterProp="children"
|
||||
>
|
||||
{workflowDefinitions.map((workflow) => (
|
||||
<Option key={workflow.id} value={workflow.id}>
|
||||
{workflow.name}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
)}
|
||||
|
||||
{/* 动态构建配置 */}
|
||||
{selectedTemplate?.buildVariablesSchema?.properties && (
|
||||
<>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user