fix: connected view does not apply field displayName settings

This commit is contained in:
aaaaaajie 2025-06-29 14:44:40 +08:00
parent 6afcbffdec
commit f9d69e347f

View File

@ -9,7 +9,7 @@
import { useField, useForm } from '@formily/react'; import { useField, useForm } from '@formily/react';
import { Cascader, Input, Select, Spin, Table, Tag } from 'antd'; import { Cascader, Input, Select, Spin, Table, Tag } from 'antd';
import { last, omit } from 'lodash'; import _, { last, omit } from 'lodash';
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { ResourceActionContext, useCompile } from '../../../'; import { ResourceActionContext, useCompile } from '../../../';
@ -120,9 +120,10 @@ const PreviewCom = (props) => {
}, [databaseView]); }, [databaseView]);
const handleFieldChange = (record, index) => { const handleFieldChange = (record, index) => {
dataSource.splice(index, 1, record); const newDataSource = _.cloneDeep(dataSource);
setDataSource(dataSource); newDataSource[index] = record;
field.value = dataSource.map((v) => { setDataSource(newDataSource);
field.value = newDataSource.map((v) => {
const source = typeof v.source === 'string' ? v.source : v.source?.filter?.(Boolean)?.join('.'); const source = typeof v.source === 'string' ? v.source : v.source?.filter?.(Boolean)?.join('.');
return { return {
...v, ...v,
@ -198,8 +199,7 @@ const PreviewCom = (props) => {
style={{ width: '100%' }} style={{ width: '100%' }}
popupMatchSelectWidth={false} popupMatchSelectWidth={false}
onChange={(value) => { onChange={(value) => {
const interfaceConfig = getInterface(value); handleFieldChange({ ...item, interface: value }, index);
handleFieldChange({ ...item, interface: value, uiSchema: interfaceConfig?.default?.uiSchema }, index);
}} }}
> >
{data.map((group) => ( {data.map((group) => (
@ -227,7 +227,7 @@ const PreviewCom = (props) => {
defaultValue={item?.uiSchema?.title || text} defaultValue={item?.uiSchema?.title || text}
onChange={(e) => onChange={(e) =>
handleFieldChange( handleFieldChange(
{ ...item, uiSchema: { ...omit(item?.uiSchema, 'rawTitle'), title: e.target.value } }, { ...item, title1: e.target.value, uiSchema: { ...omit(item?.uiSchema, 'rawTitle'), title: e.target.value } },
index, index,
) )
} }