From 3e67f3bc4c15d56399bd6162399acfd770eed6d5 Mon Sep 17 00:00:00 2001 From: AKING <2734339436@qq.com> Date: Thu, 31 Aug 2023 03:50:51 +0000 Subject: [PATCH] =?UTF-8?q?update=20src/hooks/web/useCrudSchemas.ts.=20=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=E5=BD=93=E4=BD=BF=E7=94=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84dict=E9=80=89=E9=A1=B9=E6=97=B6=EF=BC=8Cform?= =?UTF-8?q?=E4=B8=AD=E4=BA=8B=E4=BB=B6=E4=B8=8D=E8=83=BD=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: AKING <2734339436@qq.com> --- src/hooks/web/useCrudSchemas.ts | 44 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/hooks/web/useCrudSchemas.ts b/src/hooks/web/useCrudSchemas.ts index 4cfe1eaf..458b57ec 100644 --- a/src/hooks/web/useCrudSchemas.ts +++ b/src/hooks/web/useCrudSchemas.ts @@ -9,7 +9,7 @@ import { TableColumn } from '@/types/table' import { DescriptionsSchema } from '@/types/descriptions' import { ComponentOptions, ComponentProps } from '@/types/components' import { DictTag } from '@/components/DictTag' -import { cloneDeep } from 'lodash-es' +import { cloneDeep, merge } from 'lodash-es' export type CrudSchema = Omit & { isSearch?: boolean // 是否在查询显示 @@ -117,14 +117,18 @@ const filterSearchSchema = (crudSchema: CrudSchema[], allSchemas: AllSchemas): F } if (!schemaItem.search?.component) component = 'Select' } - const searchSchemaItem = { - // 默认为 input - component: component, - componentProps: comonentProps, - ...schemaItem.search, - field: schemaItem.field, - label: schemaItem.search?.label || schemaItem.label - } + + // updated by AKing: 解决了当使用默认的dict选项时,form中事件不能触发的问题 + const searchSchemaItem = merge( + { + // 默认为 input + component, + ...schemaItem.search, + field: schemaItem.field, + label: schemaItem.search?.label || schemaItem.label + }, + { componentProps: comonentProps } + ) if (searchSchemaItem.api) { searchRequestTask.push(async () => { const res = await (searchSchemaItem.api as () => AxiosPromise)() @@ -224,15 +228,19 @@ const filterFormSchema = (crudSchema: CrudSchema[], allSchemas: AllSchemas): For } if (!(schemaItem.form && schemaItem.form.component)) component = 'Select' } - const formSchemaItem = { - // 默认为 input - component: component, - componentProps: comonentProps, - value: defaultValue, - ...schemaItem.form, - field: schemaItem.field, - label: schemaItem.form?.label || schemaItem.label - } + + // updated by AKing: 解决了当使用默认的dict选项时,form中事件不能触发的问题 + const formSchemaItem = merge( + { + // 默认为 input + component, + value: defaultValue, + ...schemaItem.form, + field: schemaItem.field, + label: schemaItem.form?.label || schemaItem.label + }, + { componentProps: comonentProps } + ) if (formSchemaItem.api) { formRequestTask.push(async () => {