diff --git a/packages/table/src/ActionsColumn.vue b/packages/table/src/ActionsColumn.vue index 07883edf..06fb960e 100644 --- a/packages/table/src/ActionsColumn.vue +++ b/packages/table/src/ActionsColumn.vue @@ -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) => { diff --git a/packages/table/src/schema.ts b/packages/table/src/schema.ts index 1399ecfc..40f31568 100644 --- a/packages/table/src/schema.ts +++ b/packages/table/src/schema.ts @@ -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; - before?: (row: any) => void; - after?: (row: any) => void; + handler?: (row: any, index: number) => Promise | any; + before?: (row: any, index: number) => void; + after?: (row: any, index: number) => void; action?: (data: { data: any }) => void; }