update src/hooks/web/useCrudSchemas.ts.
解决了当使用默认的dict选项时,form中事件不能触发的问题 Signed-off-by: AKING <2734339436@qq.com>
This commit is contained in:
parent
e6a9dd0e4c
commit
3e67f3bc4c
@ -9,7 +9,7 @@ import { TableColumn } from '@/types/table'
|
|||||||
import { DescriptionsSchema } from '@/types/descriptions'
|
import { DescriptionsSchema } from '@/types/descriptions'
|
||||||
import { ComponentOptions, ComponentProps } from '@/types/components'
|
import { ComponentOptions, ComponentProps } from '@/types/components'
|
||||||
import { DictTag } from '@/components/DictTag'
|
import { DictTag } from '@/components/DictTag'
|
||||||
import { cloneDeep } from 'lodash-es'
|
import { cloneDeep, merge } from 'lodash-es'
|
||||||
|
|
||||||
export type CrudSchema = Omit<TableColumn, 'children'> & {
|
export type CrudSchema = Omit<TableColumn, 'children'> & {
|
||||||
isSearch?: boolean // 是否在查询显示
|
isSearch?: boolean // 是否在查询显示
|
||||||
@ -117,14 +117,18 @@ const filterSearchSchema = (crudSchema: CrudSchema[], allSchemas: AllSchemas): F
|
|||||||
}
|
}
|
||||||
if (!schemaItem.search?.component) component = 'Select'
|
if (!schemaItem.search?.component) component = 'Select'
|
||||||
}
|
}
|
||||||
const searchSchemaItem = {
|
|
||||||
// 默认为 input
|
// updated by AKing: 解决了当使用默认的dict选项时,form中事件不能触发的问题
|
||||||
component: component,
|
const searchSchemaItem = merge(
|
||||||
componentProps: comonentProps,
|
{
|
||||||
...schemaItem.search,
|
// 默认为 input
|
||||||
field: schemaItem.field,
|
component,
|
||||||
label: schemaItem.search?.label || schemaItem.label
|
...schemaItem.search,
|
||||||
}
|
field: schemaItem.field,
|
||||||
|
label: schemaItem.search?.label || schemaItem.label
|
||||||
|
},
|
||||||
|
{ componentProps: comonentProps }
|
||||||
|
)
|
||||||
if (searchSchemaItem.api) {
|
if (searchSchemaItem.api) {
|
||||||
searchRequestTask.push(async () => {
|
searchRequestTask.push(async () => {
|
||||||
const res = await (searchSchemaItem.api as () => AxiosPromise)()
|
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'
|
if (!(schemaItem.form && schemaItem.form.component)) component = 'Select'
|
||||||
}
|
}
|
||||||
const formSchemaItem = {
|
|
||||||
// 默认为 input
|
// updated by AKing: 解决了当使用默认的dict选项时,form中事件不能触发的问题
|
||||||
component: component,
|
const formSchemaItem = merge(
|
||||||
componentProps: comonentProps,
|
{
|
||||||
value: defaultValue,
|
// 默认为 input
|
||||||
...schemaItem.form,
|
component,
|
||||||
field: schemaItem.field,
|
value: defaultValue,
|
||||||
label: schemaItem.form?.label || schemaItem.label
|
...schemaItem.form,
|
||||||
}
|
field: schemaItem.field,
|
||||||
|
label: schemaItem.form?.label || schemaItem.label
|
||||||
|
},
|
||||||
|
{ componentProps: comonentProps }
|
||||||
|
)
|
||||||
|
|
||||||
if (formSchemaItem.api) {
|
if (formSchemaItem.api) {
|
||||||
formRequestTask.push(async () => {
|
formRequestTask.push(async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user