From cb64e5d24c3fcae36773b7517cb965ebf0cd241e Mon Sep 17 00:00:00 2001 From: zhangshujun <34877569+makeitease@users.noreply.github.com> Date: Mon, 17 Jul 2023 16:52:21 +0800 Subject: [PATCH] From default value (#2913) --- src/components/Form/src/BasicForm.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Form/src/BasicForm.vue b/src/components/Form/src/BasicForm.vue index f561a9a..a9ee8b7 100644 --- a/src/components/Form/src/BasicForm.vue +++ b/src/components/Form/src/BasicForm.vue @@ -117,15 +117,18 @@ const getSchema = computed((): FormSchema[] => { const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any); for (const schema of schemas) { - const { defaultValue, component, isHandleDateDefaultValue = true } = schema; + const { defaultValue, component, componentProps,isHandleDateDefaultValue = true } = schema; // handle date type if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) { + const valueFormat =componentProps ? componentProps['valueFormat'] : null; if (!Array.isArray(defaultValue)) { - schema.defaultValue = dateUtil(defaultValue); + schema.defaultValue = valueFormat + ? dateUtil(defaultValue).format(valueFormat) + : dateUtil(defaultValue); } else { const def: any[] = []; defaultValue.forEach((item) => { - def.push(dateUtil(item)); + def.push(valueFormat ? dateUtil(item).format(valueFormat) : dateUtil(item)); }); schema.defaultValue = def; } -- libgit2 0.23.3