list 组件extraActions支持取到每行数据
This commit is contained in:
parent
f70b40baed
commit
6bdc401df8
|
|
@ -3,7 +3,7 @@ import { TableProps } from 'antd';
|
|||
import { RowWithActions, ReactComponentProps } from '../../types/Page';
|
||||
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
|
||||
entity: T2;
|
||||
extraActions: OakExtraActionProps[];
|
||||
extraActions: OakExtraActionProps[] | ((row: ED2[T2]["Schema"]) => OakExtraActionProps[]);
|
||||
onAction: onActionFnDef;
|
||||
disabledOp: boolean;
|
||||
attributes: OakAbsAttrDef[];
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { OakAbsAttrDef, onActionFnDef, OakExtraActionProps, OakAbsAttrJudgeDef }
|
|||
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
|
||||
width: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
||||
loading: boolean;
|
||||
extraActions: OakExtraActionProps[];
|
||||
extraActions: OakExtraActionProps[] | ((row: any) => OakExtraActionProps[]);
|
||||
entity: string;
|
||||
schema: StorageSchema<EntityDict & BaseEntityDict>;
|
||||
attributes: OakAbsAttrDef[];
|
||||
|
|
|
|||
|
|
@ -78,7 +78,14 @@ export default function Render(props) {
|
|||
render: (value, row) => {
|
||||
const oakActions = row?.['#oakLegalActions'];
|
||||
// assert(!!oakActions, '行数据中不存在#oakLegalActions, 请禁用(disableOp:true)或添加actions')
|
||||
return (<ActionBtn entity={entity} extraActions={extraActions} actions={oakActions || []} cascadeActions={row?.['#oakLegalCascadeActions']} onAction={(action, cascadeAction) => onAction && onAction(row, action, cascadeAction)}/>);
|
||||
let extraActions2;
|
||||
if (typeof extraActions === 'function') {
|
||||
extraActions2 = extraActions(row);
|
||||
}
|
||||
else {
|
||||
extraActions2 = extraActions;
|
||||
}
|
||||
return (<ActionBtn entity={entity} extraActions={extraActions2} actions={oakActions || []} cascadeActions={row?.['#oakLegalCascadeActions']} onAction={(action, cascadeAction) => onAction && onAction(row, action, cascadeAction)}/>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export default OakComponent({
|
|||
isList: false,
|
||||
properties: {
|
||||
entity: '' as keyof ED,
|
||||
extraActions: [] as OakExtraActionProps[],
|
||||
extraActions: [] as OakExtraActionProps[] | ((row: any) => OakExtraActionProps[]),
|
||||
onAction: (() => undefined) as Function,
|
||||
disabledOp: false,
|
||||
attributes: [] as OakAbsAttrDef[],
|
||||
|
|
@ -92,7 +92,7 @@ export default OakComponent({
|
|||
false,
|
||||
{
|
||||
entity: T2;
|
||||
extraActions: OakExtraActionProps[];
|
||||
extraActions: OakExtraActionProps[] | ((row: ED2[T2]['Schema']) => OakExtraActionProps[]);
|
||||
onAction: onActionFnDef;
|
||||
disabledOp: boolean;
|
||||
attributes: OakAbsAttrDef[];
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default function Render(
|
|||
{
|
||||
width: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
||||
loading: boolean;
|
||||
extraActions: OakExtraActionProps[];
|
||||
extraActions: OakExtraActionProps[] | ((row: any) => OakExtraActionProps[]);
|
||||
entity: string;
|
||||
schema: StorageSchema<EntityDict & BaseEntityDict>;
|
||||
attributes: OakAbsAttrDef[],
|
||||
|
|
@ -132,10 +132,17 @@ export default function Render(
|
|||
render: (value: any, row: any) => {
|
||||
const oakActions = row?.['#oakLegalActions'] as string[];
|
||||
// assert(!!oakActions, '行数据中不存在#oakLegalActions, 请禁用(disableOp:true)或添加actions')
|
||||
let extraActions2: OakExtraActionProps[];
|
||||
if (typeof extraActions === 'function') {
|
||||
extraActions2 = extraActions(row);
|
||||
}
|
||||
else {
|
||||
extraActions2 = extraActions;
|
||||
}
|
||||
return (
|
||||
<ActionBtn
|
||||
entity={entity}
|
||||
extraActions={extraActions}
|
||||
extraActions={extraActions2}
|
||||
actions={oakActions || []}
|
||||
cascadeActions={row?.['#oakLegalCascadeActions']}
|
||||
onAction={(action: string, cascadeAction: CascadeActionProps) => onAction && onAction(row, action, cascadeAction)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue