Table cell 直接支持 input-xxx

This commit is contained in:
2betop 2021-06-01 16:43:34 +08:00
parent e005d64745
commit f158aaac62
3 changed files with 30 additions and 3 deletions

View File

@ -874,7 +874,7 @@ export class FormItemWrap extends React.Component<FormItemProps> {
return (
<div
data-role="form-item"
className={cx(`Form-item Form-item--${formMode}`, className, {
className={cx(`Form-item Form-item--normal`, className, {
'is-error': model && !model.valid,
[`is-required`]: required
})}

View File

@ -54,11 +54,13 @@ export class TableCell extends React.Component<RendererProps> {
className: innerClassName,
type: (column && column.type) || 'plain'
};
delete schema.label;
let body = children
? children
: render('field', schema, {
...rest,
inputOnly: true,
value,
data
});

View File

@ -31,6 +31,7 @@ export class TableRow extends React.Component<TableRowProps> {
super(props);
this.handleAction = this.handleAction.bind(this);
this.handleQuickChange = this.handleQuickChange.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleClick = this.handleClick.bind(this);
const item = props.item;
@ -100,6 +101,28 @@ export class TableRow extends React.Component<TableRowProps> {
onQuickChange(item, values, saveImmediately, savePristine, resetOnFailed);
}
handleChange(
value: any,
name: string,
submit?: boolean,
changePristine?: boolean
) {
if (!name) {
return;
}
const {item, onQuickChange} = this.props;
onQuickChange?.(
item,
{
[name]: value
},
submit,
changePristine
);
}
render() {
const {
itemClassName,
@ -173,7 +196,8 @@ export class TableRow extends React.Component<TableRowProps> {
colIndex: column.index,
key: column.index,
onAction: this.handleAction,
onQuickChange: this.handleQuickChange
onQuickChange: this.handleQuickChange,
onChange: this.handleChange
}
)}
</tr>
@ -216,7 +240,8 @@ export class TableRow extends React.Component<TableRowProps> {
colIndex: column.index,
key: column.index,
onAction: this.handleAction,
onQuickChange: this.handleQuickChange
onQuickChange: this.handleQuickChange,
onChange: this.handleChange
})
)}
</tr>