diff --git a/packages/core/client/src/flow/models/blocks/table/TableColumnModel.tsx b/packages/core/client/src/flow/models/blocks/table/TableColumnModel.tsx index 7d896346acb..80cf1d7b33b 100644 --- a/packages/core/client/src/flow/models/blocks/table/TableColumnModel.tsx +++ b/packages/core/client/src/flow/models/blocks/table/TableColumnModel.tsx @@ -116,6 +116,14 @@ export const CustomWidth = ({ setOpen, t, handleChange, defaultValue }) => { ); }; + +function getSavedAssociationTitleField(model: { + props?: { titleField?: string }; + getStepParams?: (flowKey: string, stepKey: string) => { label?: string } | undefined; +}) { + return model.getStepParams?.('tableColumnSettings', 'fieldNames')?.label || model.props?.titleField; +} + export class TableColumnModel extends DisplayItemModel { // 标记:该类的 render 返回函数, 避免错误的reactive封装 static renderMode: ModelRenderMode = ModelRenderMode.RenderFunction; @@ -336,12 +344,20 @@ TableColumnModel.registerFlow({ if (!collectionField) { return; } + const titleField = getSavedAssociationTitleField(ctx.model); + const componentProps = + collectionField.isAssociationField() && titleField + ? { + ...collectionField.getComponentProps(), + ...collectionField.targetCollection?.getField?.(titleField)?.getComponentProps?.(), + } + : collectionField.getComponentProps(); ctx.model.setProps('title', collectionField.title); ctx.model.setProps('dataIndex', collectionField.name); // for quick edit await ctx.model.applySubModelsBeforeRenderFlows('field'); ctx.model.setProps({ - ...collectionField.getComponentProps(), + ...componentProps, }); }, }, @@ -523,7 +539,7 @@ TableColumnModel.registerFlow({ defaultParams: (ctx: any) => { const titleField = ctx.model.context.collectionField.targetCollectionTitleFieldName; return { - label: ctx.model.props.titleField || titleField, + label: getSavedAssociationTitleField(ctx.model) || titleField, }; }, handler(ctx, params) {