feat(form): table操作列支持配置固定在左边还是右边

This commit is contained in:
roymondchen 2025-11-20 15:44:14 +08:00
parent bf6598c871
commit fa0e10f687
2 changed files with 18 additions and 4 deletions

View File

@ -722,7 +722,7 @@ export interface TableConfig extends FormItem {
dropSort?: boolean; dropSort?: boolean;
/** 是否显示全屏按钮 */ /** 是否显示全屏按钮 */
enableFullscreen?: boolean; enableFullscreen?: boolean;
fixed?: boolean; fixed?: boolean | 'left' | 'right';
itemExtra?: string | FilterFunction<string>; itemExtra?: string | FilterFunction<string>;
titleTip?: FilterFunction<string>; titleTip?: FilterFunction<string>;
rowKey?: string; rowKey?: string;

View File

@ -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: { props: {
label: '操作', label: '操作',
fixed: props.config.fixed === false ? undefined : 'left', fixed: actionFixed,
width: props.config.operateColWidth || 112, width: props.config.operateColWidth || 112,
align: 'center', align: 'center',
}, },
@ -124,7 +130,11 @@ export const useTableColumns = (
emit('change', v); emit('change', v);
}, },
}), }),
}); };
if (actionFixed !== 'right') {
columns.push(actionClumn);
}
if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) { if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) {
columns.push({ columns.push({
@ -226,6 +236,10 @@ export const useTableColumns = (
} }
} }
if (actionFixed === 'right') {
columns.push(actionClumn);
}
return columns; return columns;
}); });