diff --git a/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx b/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx index ccf8faaeed..cfc8c17b4e 100644 --- a/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx +++ b/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx @@ -642,6 +642,7 @@ export const ConfigNetworkPage: React.FC = (props) => { (e) => i.Type !== e.Type ) }) + setTimeout(() => submit(), 100) }} > {i.Type} diff --git a/app/renderer/src/main/src/components/configNetwork/NewThirdPartyApplicationConfig.tsx b/app/renderer/src/main/src/components/configNetwork/NewThirdPartyApplicationConfig.tsx index 294ff35e97..5311da7362 100644 --- a/app/renderer/src/main/src/components/configNetwork/NewThirdPartyApplicationConfig.tsx +++ b/app/renderer/src/main/src/components/configNetwork/NewThirdPartyApplicationConfig.tsx @@ -102,7 +102,7 @@ export const NewThirdPartyApplicationConfig: React.FC { @@ -145,15 +145,36 @@ export const NewThirdPartyApplicationConfig: React.FC item.value === typeVal) !== -1 }, [options, typeVal]) + const initialValues = useMemo(() => { + const copyFormValues = {...formValues} + Object.keys(copyFormValues).forEach((key) => { + if (copyFormValues[key] === "true") { + copyFormValues[key] = true + } else if (copyFormValues[key] === "false") { + copyFormValues[key] = false + } + }) + return copyFormValues + }, [formValues]) + return (
{ - console.log("表单值改变", allFields) + initialValues={initialValues} + onValuesChange={(changedValues, allValues) => { + // 当类型改变时,表单项的值采用默认值 + if (changedValues.Type !== undefined) { + const templatesobj = templates.find((item) => item.Name === changedValues.Type) + const formItems = templatesobj?.Items || [] + formItems.forEach((item) => { + form.setFieldsValue({ + [item.Name]: item.Type === "string" ? item.DefaultValue : item.DefaultValue === "true" + }) + }) + } }} onSubmitCapture={(e) => { e.preventDefault() @@ -187,7 +208,6 @@ export const NewThirdPartyApplicationConfig: React.FC { form.validateFields().then((res) => { - console.log("提交参数", res) const ExtraParams = Object.keys(res) .filter((key) => key !== "Type") .map((key) => ({Key: key, Value: res[key]}))