1
This commit is contained in:
parent
5e80f9de10
commit
cd650f56f5
@ -1,5 +1,5 @@
|
||||
import React, {useEffect, useState, useCallback} from 'react';
|
||||
import {Modal, Form, Select, message, Switch, InputNumber, Input, Space, Button} from 'antd';
|
||||
import {Modal, Form, Select, message, Switch, Space, Button} from 'antd';
|
||||
import {FullscreenOutlined} from '@ant-design/icons';
|
||||
import type {DeploymentConfig, DeployConfigTemplate, CreateDeploymentConfigRequest} from '../types';
|
||||
import {createDeploymentConfig, updateDeploymentConfig, getDeployConfigTemplates} from '../service';
|
||||
@ -68,12 +68,11 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
}
|
||||
}, [open, fetchApplications, fetchTemplates]);
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>始化表单数据
|
||||
// 初始化表单数据
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
||||
if (initialValues) {
|
||||
// 设置基础字段
|
||||
form.setFieldsValue({
|
||||
applicationId: initialValues.applicationId,
|
||||
enabled: initialValues.enabled
|
||||
@ -162,14 +161,6 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
}));
|
||||
};
|
||||
|
||||
// 处理普通输入框的值变化
|
||||
const handleInputChange = (key: string, value: string) => {
|
||||
setBuildVariables(prev => ({
|
||||
...prev,
|
||||
[key]: value
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
@ -199,7 +190,6 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
layout="vertical"
|
||||
initialValues={{
|
||||
enabled: true,
|
||||
sort: 0,
|
||||
}}
|
||||
>
|
||||
{/* 应用选择 */}
|
||||
@ -271,46 +261,54 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
suggestOnTriggerCharacters: property.editorConfig.autoComplete ?? true,
|
||||
renderWhitespace: 'boundary',
|
||||
}}
|
||||
loading={
|
||||
<div style={{
|
||||
padding: '8px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
height: '300px',
|
||||
background: '#1e1e1e',
|
||||
color: '#fff'
|
||||
}}>
|
||||
编辑器加载中...
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
))
|
||||
}
|
||||
|
||||
{/* 普通字段 */}
|
||||
{Object.entries(selectedTemplate.buildVariablesSchema.properties)
|
||||
.filter(([_, property]) => !property.editorConfig)
|
||||
.map(([key, property]) => (
|
||||
<Form.Item
|
||||
key={key}
|
||||
label={property.title || key}
|
||||
required={selectedTemplate.buildVariablesSchema.required?.includes(key)}
|
||||
tooltip={property.description}
|
||||
>
|
||||
<Input
|
||||
value={buildVariables[key] || property.default || ''}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange(key, e.target.value)}
|
||||
placeholder={`请输入${property.title || key}`}
|
||||
/>
|
||||
</Form.Item>
|
||||
))
|
||||
}
|
||||
<BetaSchemaForm
|
||||
layoutType="Embed"
|
||||
columns={convertJsonSchemaToColumns({
|
||||
type: 'object',
|
||||
properties: Object.fromEntries(
|
||||
Object.entries(selectedTemplate.buildVariablesSchema.properties)
|
||||
.filter(([_, prop]) => !prop.editorConfig)
|
||||
.map(([key, prop]) => [
|
||||
key,
|
||||
{
|
||||
type: prop.type || 'string',
|
||||
title: prop.title,
|
||||
description: prop.description,
|
||||
default: prop.default,
|
||||
enum: prop.enum,
|
||||
enumNames: prop.enumNames,
|
||||
format: prop.format,
|
||||
minimum: prop.minimum,
|
||||
maximum: prop.maximum,
|
||||
minLength: prop.minLength,
|
||||
maxLength: prop.maxLength,
|
||||
pattern: prop.pattern,
|
||||
items: prop.items && {
|
||||
type: prop.items.type || 'string',
|
||||
enum: prop.items.enum,
|
||||
enumNames: prop.items.enumNames
|
||||
}
|
||||
}
|
||||
])
|
||||
),
|
||||
required: selectedTemplate.buildVariablesSchema.required || []
|
||||
})}
|
||||
initialValues={buildVariables}
|
||||
onValuesChange={(_, values) => setBuildVariables(prev => ({
|
||||
...prev,
|
||||
...values
|
||||
}))}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 状态和排序 */}
|
||||
{/* 状态 */}
|
||||
<Form.Item
|
||||
name="enabled"
|
||||
label="状态"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user