From 478802b42625f74e8e8f817dea343b0692e3d024 Mon Sep 17 00:00:00 2001 From: zzy-jonay <59468578+zzy-jonay@users.noreply.github.com> Date: Fri, 10 May 2024 17:51:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(BasicForm):=20=E4=BF=AE=E5=A4=8DFormSchema?= =?UTF-8?q?=E4=B8=AD=E4=BD=BF=E7=94=A8ifShow=E9=9A=90=E8=97=8F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=97=B6=EF=BC=8C=E9=BB=98=E8=AE=A4=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=87=8D=E7=BD=AE=E6=8C=89=E9=92=AE=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=81=8F=E7=A7=BB=E9=87=8F=E8=AE=A1=E7=AE=97=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#3830)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/hooks/useAdvanced.ts | 28 ++++++++------------ 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/components/Form/src/hooks/useAdvanced.ts b/src/components/Form/src/hooks/useAdvanced.ts index fb9edcf3..342b10dd 100644 --- a/src/components/Form/src/hooks/useAdvanced.ts +++ b/src/components/Form/src/hooks/useAdvanced.ts @@ -120,24 +120,18 @@ export default function ({ const { baseColProps = {} } = unref(getProps); for (const schema of unref(getSchema)) { - const { show, colProps } = schema; + const { show, ifShow, colProps } = schema; + const renderCallbackParams = { + schema: schema, + model: formModel, + field: schema.field, + values: { ...unref(defaultValueRef), ...formModel }, + }; let isShow = true; - - if (isBoolean(show)) { - isShow = show; - } - - if (isFunction(show)) { - isShow = show({ - schema: schema, - model: formModel, - field: schema.field, - values: { - ...unref(defaultValueRef), - ...formModel, - }, - }); - } + isShow && isBoolean(ifShow) && (isShow = ifShow); + isShow && isFunction(ifShow) && (isShow = ifShow(renderCallbackParams)); + isShow && isBoolean(show) && (isShow = show); + isShow && isFunction(show) && (isShow = show(renderCallbackParams)); if (isShow && (colProps || baseColProps)) { const { itemColSum: sum, isAdvanced } = getAdvanced(