This is an automated email from the ASF dual-hosted git repository.
songjian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new fa56751 fix Alert instance form not init bug (#9258)
fa56751 is described below
commit fa56751a56742d372b9e1d0f55213c10c20d0c78
Author: Devosend <[email protected]>
AuthorDate: Tue Mar 29 17:39:04 2022 +0800
fix Alert instance form not init bug (#9258)
---
dolphinscheduler-ui-next/src/components/form/use-form.ts | 12 ++++++++++++
.../src/views/security/alarm-instance-manage/use-form.ts | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dolphinscheduler-ui-next/src/components/form/use-form.ts
b/dolphinscheduler-ui-next/src/components/form/use-form.ts
index b474d52..2f76a11 100644
--- a/dolphinscheduler-ui-next/src/components/form/use-form.ts
+++ b/dolphinscheduler-ui-next/src/components/form/use-form.ts
@@ -26,6 +26,17 @@ export function useForm() {
await state.formRef.validate(...args)
}
+ const resetValues = (initialValues: { [field: string]: any }) => {
+ const modelKeys = Object.keys(state.formRef.model)
+ for (const key of modelKeys) {
+ if (!Object.keys(initialValues).includes(key)) {
+ delete state.formRef.model[key]
+ }
+ }
+
+ setValues(initialValues)
+ }
+
const setValues = (initialValues: { [field: string]: any }) => {
for (const [key, value] of Object.entries(initialValues)) {
state.formRef.model[key] = value
@@ -45,6 +56,7 @@ export function useForm() {
validate,
setValues,
getValues,
+ resetValues,
restoreValidation
}
}
diff --git
a/dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-form.ts
b/dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-form.ts
index e8a75bf..1e5fc3d 100644
---
a/dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-form.ts
+++
b/dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-form.ts
@@ -96,7 +96,7 @@ export function useForm() {
}
const resetForm = () => {
- state.detailFormRef.setValues({ ...initialValues })
+ state.detailFormRef.resetValues({ ...initialValues })
state.json = []
}