mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-05 05:38:23 +08:00
fix(AssociationSelect): fix x-read-pretty not working (#1766)
* fix: the default value input should not be disabled * fix(AssociationSelect): fix x-read-pretty not working
This commit is contained in:
parent
de5260bc2c
commit
07d1c7ccc0
@ -4,7 +4,7 @@ import { Field } from '@formily/core';
|
||||
import { ISchema, connect, mapProps, mapReadPretty, useField, useFieldSchema } from '@formily/react';
|
||||
import { uid } from '@formily/shared';
|
||||
import _ from 'lodash';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useFilterByTk, useFormBlockContext } from '../../../block-provider';
|
||||
import {
|
||||
@ -118,6 +118,14 @@ AssociationSelect.Designer = function Designer() {
|
||||
const defaultFilter = field.componentProps?.service?.params?.filter || {};
|
||||
const dataSource = useCollectionFilterOptions(collectionField?.target);
|
||||
|
||||
// TODO: 这里 fieldSchema['x-read-pretty'] 的值为 true,但是 field.readPretty 的值却为 false,不知道什么原因
|
||||
useEffect(() => {
|
||||
// 没有这一步判断会出现禁用状态失效的情况
|
||||
if (field.readPretty !== fieldSchema['x-read-pretty']) {
|
||||
field.readPretty = !!fieldSchema['x-read-pretty'];
|
||||
}
|
||||
}, [fieldSchema['x-read-pretty']]);
|
||||
|
||||
const sort = defaultSort?.map((item: string) => {
|
||||
return item.startsWith('-')
|
||||
? {
|
||||
@ -416,6 +424,8 @@ AssociationSelect.Designer = function Designer() {
|
||||
name: 'default',
|
||||
title: t('Default value'),
|
||||
default: fieldSchema.default || collectionField.defaultValue,
|
||||
'x-read-pretty': false,
|
||||
'x-disabled': false,
|
||||
},
|
||||
},
|
||||
} as ISchema
|
||||
|
@ -450,6 +450,8 @@ FormItem.Designer = function Designer() {
|
||||
name: 'default',
|
||||
title: t('Default value'),
|
||||
default: getFieldDefaultValue(fieldSchema, collectionField),
|
||||
'x-read-pretty': false,
|
||||
'x-disabled': false,
|
||||
}
|
||||
: {
|
||||
...(fieldSchema || {}),
|
||||
|
Loading…
Reference in New Issue
Block a user