From fa0e10f6872ade5599957051e2e6923fa2d4ca66 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Thu, 20 Nov 2025 15:44:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(form):=20table=E6=93=8D=E4=BD=9C=E5=88=97?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE=E5=9B=BA=E5=AE=9A=E5=9C=A8?= =?UTF-8?q?=E5=B7=A6=E8=BE=B9=E8=BF=98=E6=98=AF=E5=8F=B3=E8=BE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/form-schema/src/base.ts | 2 +- packages/form/src/table/useTableColumns.ts | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) 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; });