feat: demo

This commit is contained in:
chenos 2025-06-20 15:41:08 +08:00
parent 5b70b68383
commit d709d41d00
2 changed files with 52 additions and 15 deletions

View File

@ -75,12 +75,19 @@ export class TableColumnModel extends FieldModel {
};
}
componentProps = observable.deep({
prefix: '',
suffix: '',
});
setComponentProps(props) {
this.setProps('componentProps', { ...(this.props.componentProps || {}), ...props });
Object.assign(this.componentProps, props);
}
getComponentProps() {
return this.props.componentProps;
return this.componentProps;
}
setDataSource(dataSource) {
this.setProps('componentProps', { ...(this.props.componentProps || {}), dataSource });
}
@ -110,13 +117,21 @@ export class TableColumnModel extends FieldModel {
render() {
return (value, record, index) => (
<>
<TableField record={record} model={this} value={value} index={index} />
<Demo value={value} model={this} />
{this.renderQuickEditButton(record)}
</>
);
}
}
const Demo = observer<any>(({ model, value }) => {
return (
<div>
{model.componentProps.prefix} | {value} | {model.componentProps.suffix}
</div>
);
});
TableColumnModel.define({
title: 'Table Column',
icon: 'TableColumn',
@ -145,5 +160,27 @@ TableColumnModel.registerFlow({
ctx.model.setProps('dataIndex', field.name);
},
},
step2: {
title: 'Edit Title',
uiSchema: {
prefix: {
'x-component': 'Input',
'x-decorator': 'FormItem',
'x-component-props': {
placeholder: 'Prefix',
},
},
suffix: {
'x-component': 'Input',
'x-decorator': 'FormItem',
'x-component-props': {
placeholder: 'Suffix',
},
},
},
handler(ctx, params) {
ctx.model.setComponentProps(params);
},
},
},
});

View File

@ -53,18 +53,18 @@ export class TableModel extends DataBlockModel<S> {
},
},
},
subModels: {
field: {
use: 'TableFieldModel',
stepParams: {
default: {
step1: {
fieldPath: field.fullpath,
},
},
},
},
},
// subModels: {
// field: {
// use: 'TableFieldModel',
// stepParams: {
// default: {
// step1: {
// fieldPath: field.fullpath,
// },
// },
// },
// },
// },
})}
appendItems={[
{