Skip to content

Commit 70e4ceb

Browse files
committedFeb 17, 2025
🚧 Fix create datasource submit failed
1 parent e2abf06 commit 70e4ceb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
 

‎src/pages/datasources/DatasourceCreateModal.jsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const CreateDatasourceModal = ({ visible, onClose, selectedRow, type, han
2727
const [enabled, setEnabled] = useState(true) // 设置初始状态为 true
2828
const [selectedType, setSelectedType] = useState(null) // 数据源类型
2929
const [submitLoading,setSubmitLoading] = useState(false)
30+
const [testLoading,setTestLoading] = useState(false)
3031

3132
// 禁止输入空格
3233
const [spaceValue, setSpaceValue] = useState('')
@@ -132,9 +133,14 @@ export const CreateDatasourceModal = ({ visible, onClose, selectedRow, type, han
132133

133134
const handleSubmit = async () => {
134135
setSubmitLoading(true)
136+
const values = form.getFieldsValue();
137+
await form.validateFields()
138+
await handleFormSubmit(values)
139+
setSubmitLoading(false)
135140
}
136141

137142
const handleTestConnection = async () => {
143+
setTestLoading(true)
138144
// 获取表单数据
139145
const values = await form.validateFields().catch((err) => null);
140146
const formattedLabels = values.labels?.reduce((acc, { key, value }) => {
@@ -161,6 +167,7 @@ export const CreateDatasourceModal = ({ visible, onClose, selectedRow, type, han
161167
} catch (error) {
162168
console.error('连接测试失败:', error);
163169
}
170+
setTestLoading(false)
164171
};
165172

166173
return (
@@ -171,7 +178,11 @@ export const CreateDatasourceModal = ({ visible, onClose, selectedRow, type, han
171178
size='large'
172179
footer={
173180
<div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
174-
<Button type="default" onClick={handleTestConnection}>
181+
<Button
182+
type="default"
183+
onClick={handleTestConnection}
184+
loading={testLoading}
185+
>
175186
连接测试
176187
</Button>
177188
<Button
@@ -188,7 +199,7 @@ export const CreateDatasourceModal = ({ visible, onClose, selectedRow, type, han
188199
</div>
189200
}
190201
>
191-
<Form form={form} name="form_item_path" layout="vertical" onFinish={handleFormSubmit}>
202+
<Form form={form} name="form_item_path" layout="vertical">
192203
<MyFormItem
193204
name="name"
194205
label="数据源名称"

0 commit comments

Comments
 (0)