diff --git a/packages/form-schema/src/base.ts b/packages/form-schema/src/base.ts index 27e5ac3c..cc75bf33 100644 --- a/packages/form-schema/src/base.ts +++ b/packages/form-schema/src/base.ts @@ -722,7 +722,7 @@ export interface TableConfig extends FormItem { dropSort?: boolean; /** 是否显示全屏按钮 */ enableFullscreen?: boolean; - fixed?: boolean; + fixed?: boolean | 'left' | 'right'; itemExtra?: string | FilterFunction; titleTip?: FilterFunction; rowKey?: string; diff --git a/packages/form/src/table/useTableColumns.ts b/packages/form/src/table/useTableColumns.ts index 69db09d2..e8378a8b 100644 --- a/packages/form/src/table/useTableColumns.ts +++ b/packages/form/src/table/useTableColumns.ts @@ -101,10 +101,16 @@ export const useTableColumns = ( }); } - columns.push({ + let actionFixed: 'left' | 'right' | undefined = props.config.fixed === false ? undefined : 'left'; + + if (typeof props.config.fixed === 'string' && ['left', 'right'].includes(props.config.fixed)) { + actionFixed = props.config.fixed; + } + + const actionClumn = { props: { label: '操作', - fixed: props.config.fixed === false ? undefined : 'left', + fixed: actionFixed, width: props.config.operateColWidth || 112, align: 'center', }, @@ -124,7 +130,11 @@ export const useTableColumns = ( emit('change', v); }, }), - }); + }; + + if (actionFixed !== 'right') { + columns.push(actionClumn); + } if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) { columns.push({ @@ -226,6 +236,10 @@ export const useTableColumns = ( } } + if (actionFixed === 'right') { + columns.push(actionClumn); + } + return columns; });