From 44b3aed5950512fa152282682b8962a33604ca38 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Wed, 30 Oct 2024 21:11:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9=E5=90=8E,=E6=9C=AA?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=97=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/dynamics-form/index.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/src/components/dynamics-form/index.vue b/ui/src/components/dynamics-form/index.vue index ad3c8877e..e19998040 100644 --- a/ui/src/components/dynamics-form/index.vue +++ b/ui/src/components/dynamics-form/index.vue @@ -172,8 +172,17 @@ const render = ( formFieldList.value = ok.data }) } - if (data) { - formValue.value = _.cloneDeep(data) + const form_data = data ? data : {} + if (form_data) { + const value = formFieldList.value + .map((item) => { + if (form_data[item.field] !== undefined) { + return { [item.field]: form_data[item.field] } + } + return { [item.field]: item.default_value } + }) + .reduce((x, y) => ({ ...x, ...y }), {}) + formValue.value = _.cloneDeep(value) } } /**