feat(table): action增加before配置

This commit is contained in:
roymondchen 2022-04-28 20:51:40 +08:00 committed by jia000
parent 15b202a9be
commit 912639999d
2 changed files with 4 additions and 2 deletions

View File

@ -116,6 +116,7 @@ const copyHandler = async (action: ColumnActionConfig, row: any) => {
};
const actionHandler = async (action: ColumnActionConfig, row: any, index: number) => {
await action.before?.(row);
if (action.type === 'delete') {
await deleteAction(action, row);
} else if (action.type === 'copy') {
@ -124,8 +125,8 @@ const actionHandler = async (action: ColumnActionConfig, row: any, index: number
props.editState[index] = row;
} else {
await action.handler?.(row);
action.after?.();
}
action.after?.(row);
};
const save = async (index: number, config: ColumnConfig) => {

View File

@ -24,7 +24,8 @@ export interface ColumnActionConfig {
text: string;
name: string;
handler?: (row: any) => Promise<any> | any;
after?: () => void;
before?: (row: any) => void;
after?: (row: any) => void;
action?: (data: { data: any }) => void;
}