fix: snapshot display fix (#1328)

This commit is contained in:
anuoua 2023-01-05 12:45:06 +08:00 committed by GitHub
parent c851e65459
commit 72e9533b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View File

@ -47,18 +47,21 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
return ( return (
<Fragment key={`${record.id}_${index}`}> <Fragment key={`${record.id}_${index}`}>
<span> <span>
<a {snapshot ? (
onClick={(e) => { getLabelFormatValue(labelUiSchema, val)
if (snapshot) return; ) : (
e.stopPropagation(); <a
e.preventDefault(); onClick={(e) => {
setVisible(true); e.stopPropagation();
setRecord(record); e.preventDefault();
ellipsisWithTooltipRef?.current?.setPopoverVisible(false); setVisible(true);
}} setRecord(record);
> ellipsisWithTooltipRef?.current?.setPopoverVisible(false);
{getLabelFormatValue(labelUiSchema, val)} }}
</a> >
{getLabelFormatValue(labelUiSchema, val)}
</a>
)}
</span> </span>
{index < arr.length - 1 ? <span style={{ marginRight: 4, color: '#aaa' }}>,</span> : null} {index < arr.length - 1 ? <span style={{ marginRight: 4, color: '#aaa' }}>,</span> : null}
</Fragment> </Fragment>

View File

@ -3,6 +3,7 @@ import { observer, useField } from '@formily/react';
import { isValid } from '@formily/shared'; import { isValid } from '@formily/shared';
import { Tag } from 'antd'; import { Tag } from 'antd';
import React from 'react'; import React from 'react';
import { useCompile } from '../../hooks';
import { defaultFieldNames, getCurrentOptions } from './shared'; import { defaultFieldNames, getCurrentOptions } from './shared';
type Composed = { type Composed = {
@ -13,6 +14,8 @@ type Composed = {
export const ReadPretty = observer((props: any) => { export const ReadPretty = observer((props: any) => {
const fieldNames = { ...defaultFieldNames, ...props.fieldNames }; const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
const field = useField<any>(); const field = useField<any>();
const compile = useCompile();
if (!isValid(props.value)) { if (!isValid(props.value)) {
return <div />; return <div />;
} }
@ -25,7 +28,7 @@ export const ReadPretty = observer((props: any) => {
<div> <div>
{options.map((option, key) => ( {options.map((option, key) => (
<Tag key={key} color={option[fieldNames.color]} icon={option.icon}> <Tag key={key} color={option[fieldNames.color]} icon={option.icon}>
{option[fieldNames.label]} {compile(option[fieldNames.label])}
</Tag> </Tag>
))} ))}
</div> </div>