This commit is contained in:
38
src/components/core/others/TableContextMenuHint.vue
Normal file
38
src/components/core/others/TableContextMenuHint.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<!-- 表格右键菜单悬浮提示组件 -->
|
||||
<template>
|
||||
<div
|
||||
v-show="visible"
|
||||
class="table-context-menu-hint"
|
||||
:style="{ left: position.x + 'px', top: position.y + 'px' }"
|
||||
>
|
||||
{{ text }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
visible: boolean
|
||||
position: { x: number; y: number }
|
||||
text?: string
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
text: '右键查看更多操作'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table-context-menu-hint {
|
||||
position: fixed;
|
||||
padding: 4px 10px;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
pointer-events: none;
|
||||
white-space: nowrap;
|
||||
z-index: 9999;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
</style>
|
||||
@@ -14,6 +14,7 @@
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
:height="height"
|
||||
:max-height="maxHeight"
|
||||
:show-header="showHeader"
|
||||
@@ -30,6 +31,8 @@
|
||||
@row-click="handleRowClick"
|
||||
@row-contextmenu="handleRowContextmenu"
|
||||
@selection-change="handleSelectionChange"
|
||||
@cell-mouse-enter="handleCellMouseEnter"
|
||||
@cell-mouse-leave="handleCellMouseLeave"
|
||||
>
|
||||
<!-- 序号列 -->
|
||||
<el-table-column
|
||||
@@ -86,6 +89,8 @@
|
||||
loading?: boolean
|
||||
/** 行数据的 Key,用于标识每一行数据 */
|
||||
rowKey?: string
|
||||
/** 行的 className 的回调方法 */
|
||||
rowClassName?: ((data: { row: any; rowIndex: number }) => string) | string
|
||||
/** 是否显示边框 */
|
||||
border?: boolean | null
|
||||
/** 是否使用斑马纹样式 */
|
||||
@@ -136,6 +141,7 @@
|
||||
data: () => [],
|
||||
loading: false,
|
||||
rowKey: 'id',
|
||||
rowClassName: undefined,
|
||||
border: null,
|
||||
stripe: null,
|
||||
index: false,
|
||||
@@ -178,7 +184,9 @@
|
||||
'row-contextmenu',
|
||||
'size-change',
|
||||
'current-change',
|
||||
'selection-change'
|
||||
'selection-change',
|
||||
'cell-mouse-enter',
|
||||
'cell-mouse-leave'
|
||||
])
|
||||
|
||||
const tableStore = useTableStore()
|
||||
@@ -281,6 +289,16 @@
|
||||
emit('row-contextmenu', row, column, event)
|
||||
}
|
||||
|
||||
// 单元格鼠标进入事件
|
||||
const handleCellMouseEnter = (row: any, column: any, cell: any, event: any) => {
|
||||
emit('cell-mouse-enter', row, column, cell, event)
|
||||
}
|
||||
|
||||
// 单元格鼠标离开事件
|
||||
const handleCellMouseLeave = (row: any, column: any, cell: any, event: any) => {
|
||||
emit('cell-mouse-leave', row, column, cell, event)
|
||||
}
|
||||
|
||||
// 选择变化事件
|
||||
const handleSelectionChange = (selection: any) => {
|
||||
emit('selection-change', selection)
|
||||
|
||||
Reference in New Issue
Block a user