mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(table): action hook配置加入index参数
This commit is contained in:
parent
af393e34fb
commit
26835f6a29
@ -6,7 +6,7 @@
|
||||
v-show="display(action.display, scope.row) && !editState[scope.$index]"
|
||||
class="action-btn"
|
||||
text
|
||||
type="primary"
|
||||
:type="action.buttonType || 'primary'"
|
||||
size="small"
|
||||
:icon="action.icon"
|
||||
:key="actionIndex"
|
||||
@ -72,13 +72,13 @@ const formatter = (fuc: string | Function | undefined, row: any) => {
|
||||
};
|
||||
|
||||
const actionHandler = async (action: ColumnActionConfig, row: any, index: number) => {
|
||||
await action.before?.(row);
|
||||
await action.before?.(row, index);
|
||||
if (action.type === 'edit') {
|
||||
props.editState[index] = row;
|
||||
} else {
|
||||
await action.handler?.(row);
|
||||
await action.handler?.(row, index);
|
||||
}
|
||||
action.after?.(row);
|
||||
action.after?.(row, index);
|
||||
};
|
||||
|
||||
const save = async (index: number, config: ColumnConfig) => {
|
||||
|
@ -20,13 +20,14 @@ import { FormConfig, FormValue } from '@tmagic/form';
|
||||
|
||||
export interface ColumnActionConfig {
|
||||
type?: 'delete' | 'copy' | 'edit';
|
||||
buttonType: string;
|
||||
display?: (row: any) => boolean;
|
||||
text: string | ((row: any) => string);
|
||||
name: string;
|
||||
icon?: any;
|
||||
handler?: (row: any) => Promise<any> | any;
|
||||
before?: (row: any) => void;
|
||||
after?: (row: any) => void;
|
||||
handler?: (row: any, index: number) => Promise<any> | any;
|
||||
before?: (row: any, index: number) => void;
|
||||
after?: (row: any, index: number) => void;
|
||||
action?: (data: { data: any }) => void;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user