diff --git a/packages/table/src/ActionsColumn.vue b/packages/table/src/ActionsColumn.vue index c7497011..421fd1d8 100644 --- a/packages/table/src/ActionsColumn.vue +++ b/packages/table/src/ActionsColumn.vue @@ -15,6 +15,7 @@ size="small" :type="action.buttonType || 'primary'" :icon="action.icon" + :disabled="disabled(action.disabled, scope.row)" @click="actionHandler(action, scope.row, scope.$index)" > @@ -71,9 +72,22 @@ const display = (fuc: boolean | Function | undefined, row: any) => { if (typeof fuc === 'function') { return fuc(row); } + if (typeof fuc === 'boolean') { + return fuc; + } return true; }; +const disabled = (fuc: boolean | Function | undefined, row: any) => { + if (typeof fuc === 'function') { + return fuc(row); + } + if (typeof fuc === 'boolean') { + return fuc; + } + return false; +}; + const formatter = (fuc: string | Function | undefined, row: any) => { if (typeof fuc === 'function') { return fuc(row); diff --git a/packages/table/src/schema.ts b/packages/table/src/schema.ts index ff010342..a3f5f3fc 100644 --- a/packages/table/src/schema.ts +++ b/packages/table/src/schema.ts @@ -21,7 +21,8 @@ import { FormConfig, FormValue } from '@tmagic/form'; export interface ColumnActionConfig { type?: 'delete' | 'copy' | 'edit' | string; buttonType?: string; - display?: (row: any) => boolean; + display?: boolean | ((row: any) => boolean); + disabled?: boolean | ((row: any) => boolean); text?: string | ((row: any) => string); name?: string; tooltip?: string; diff --git a/playground/src/pages/Table.vue b/playground/src/pages/Table.vue index f2c0f226..6b553480 100644 --- a/playground/src/pages/Table.vue +++ b/playground/src/pages/Table.vue @@ -2,7 +2,7 @@