From 8cc86369a23cd01cb6266f72325875e0b747138f Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Thu, 23 Apr 2026 16:03:54 +0800 Subject: [PATCH] fix: bug --- src/components/core/tables/ArtTable.vue | 33 ++++++++++++++----------- src/views/finance/refund/index.vue | 3 ++- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/components/core/tables/ArtTable.vue b/src/components/core/tables/ArtTable.vue index 7fcd6c7..bebbb01 100644 --- a/src/components/core/tables/ArtTable.vue +++ b/src/components/core/tables/ArtTable.vue @@ -164,6 +164,8 @@ actions?: ((row: any) => TableAction[]) | null /** 操作列宽度 */ actionsWidth?: number + /** 直接显示的操作按钮数量,默认2个 */ + inlineActionsCount?: number } const props = withDefaults(defineProps(), { @@ -192,7 +194,8 @@ treeProps: undefined, defaultExpandAll: false, actions: null, - actionsWidth: 140 + actionsWidth: 140, + inlineActionsCount: 2 }) /* @@ -371,8 +374,8 @@ ) } - // 如果操作数量 <= 3,直接显示所有按钮 - if (actionList.length <= 3) { + // 如果操作数量 <= inlineActionsCount,直接显示所有按钮 + if (actionList.length <= props.inlineActionsCount) { return h( 'div', { style: 'display: flex; gap: 8px;' }, @@ -390,19 +393,21 @@ ) } - // 如果操作数量 > 3,显示第一个 + 更多下拉菜单 - const firstAction = actionList[0] - const moreActions = actionList.slice(1) + // 如果操作数量 > inlineActionsCount,显示前 inlineActionsCount 个 + 更多下拉菜单 + const inlineActions = actionList.slice(0, props.inlineActionsCount) + const moreActions = actionList.slice(props.inlineActionsCount) return h('div', { style: 'display: flex; gap: 12px; align-items: center;' }, [ - h( - ElButton, - { - type: firstAction.type === 'danger' ? 'danger' : 'primary', - link: true, - onClick: () => firstAction.handler(row) - }, - () => firstAction.label + ...inlineActions.map((action) => + h( + ElButton, + { + type: action.type === 'danger' ? 'danger' : 'primary', + link: true, + onClick: () => action.handler(row) + }, + () => action.label + ) ), h( ElDropdown, diff --git a/src/views/finance/refund/index.vue b/src/views/finance/refund/index.vue index 4dc0ec0..c5dbc66 100644 --- a/src/views/finance/refund/index.vue +++ b/src/views/finance/refund/index.vue @@ -35,7 +35,8 @@ :total="pagination.total" :marginTop="10" :actions="getActions" - :actionsWidth="250" + :actionsWidth="230" + :inlineActionsCount="2" @size-change="handleSizeChange" @current-change="handleCurrentChange" >