web-admin 列表页操作列按钮过多(3-6 个),导致操作列宽度达 320-480px,挤压数据列空间。部分页面(如耗材管理)工具栏和操作列的按钮存在功能重复。
取消操作列,所有操作按钮移到表格上方工具栏。用户通过勾选行来激活操作按钮,实现「选择 → 操作」的交互模式。
| 选中状态 | 批量按钮(mode: batch) | 单行按钮(mode: single) |
|---|---|---|
| 0 行 | 禁用 | 禁用 |
| 1 行 | 可操作 | 可操作 |
| 多行 | 可操作 | 禁用 + tooltip「请选择单条记录」 |
@row-dblclick 模式)src/components/common/toolbar-action/
index.vue
types.ts
import type { Component } from 'vue'
export interface ToolbarActionItem {
label: string
icon?: Component
handler: (rows: any[]) => void
mode: 'batch' | 'single'
danger?: boolean
disabled?: boolean
visible?: boolean
}
interface Props {
selected: any[]
actions: ToolbarActionItem[]
}
visible !== false 的 actionsselected.length 和 action.mode 自动控制按钮 disabled 状态danger=true 的按钮使用 btn-ghost + type="danger" 样式disabled=true 的按钮始终禁用(调用方控制)btn-ghost 样式.btn-ghost 按钮样式(已在 el-ui.scss 中定义)visible 控制)使用 ToolbarAction 组件的页面将移除操作列(fixed="right"),el-ui.scss 中现有 min-width: 260px 规则不再对这些页面生效(因为不再有 .btn-op-item)。无需修改全局样式。
仅新建组件。不改造现有页面(后续按需逐步替换)。