From 3b0b8d0baa9b03a82fb88fbdb4bb21214793dfe6 Mon Sep 17 00:00:00 2001 From: zhangshujun <34877569+makeitease@users.noreply.github.com> Date: Fri, 21 Jul 2023 20:23:04 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=B8=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=8F=AF=E9=87=8D=E5=A4=8D=E6=B7=BB=E5=8A=A0=E5=90=8C=E4=B8=80?= =?UTF-8?q?field=E7=9A=84=E8=A1=A8=E5=8D=95=E9=A1=B9=20(#2923)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/hooks/useFormEvents.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Form/src/hooks/useFormEvents.ts b/src/components/Form/src/hooks/useFormEvents.ts index 028c314e..18fbfa8b 100644 --- a/src/components/Form/src/hooks/useFormEvents.ts +++ b/src/components/Form/src/hooks/useFormEvents.ts @@ -210,7 +210,13 @@ export function useFormEvents({ first = false, ) { const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); - + const addSchemaIds: string[] = Array.isArray(schema) + ? schema.map((item) => item.field) + : [schema.field]; + if (schemaList.find((item) => addSchemaIds.includes(item.field))) { + error('There are schemas that have already been added'); + return; + } const index = schemaList.findIndex((schema) => schema.field === prefixField); const _schemaList = isObject(schema) ? [schema as FormSchema] : (schema as FormSchema[]); if (!prefixField || index === -1 || first) {