@@ -18,8 +18,7 @@ const props = withDefaults(
1818 data? : unknown []
1919 maxTableHeight? : number
2020 paginationConfig? : PaginationConfig
21- resizable? : boolean
22- isSearching? : boolean
21+ resizable? : boolean // 非指定表格禁止开启
2322 }>(),
2423 {
2524 data : () => [],
@@ -68,51 +67,6 @@ function clearSelection() {
6867 selectedRows .value = []
6968}
7069
71- /**
72- * 列宽拖拽
73- * resizable 借用 Element Plus border 开启拖拽交互,并补充固定在列边界的 Hover 提示线。
74- */
75- const tableRootRef = ref <HTMLElement >()
76- const resizeHoverStyle = ref <{ height: string ; left: string ; top: string }>()
77-
78- function clearResizeHover() {
79- resizeHoverStyle .value = undefined
80- }
81-
82- function handleTableMouseMove(event : MouseEvent ) {
83- if (! props .resizable ) {
84- clearResizeHover ()
85- return
86- }
87-
88- const resizeProxy = tableRootRef .value ?.querySelector (' .el-table__column-resize-proxy' )
89-
90- if (resizeProxy instanceof HTMLElement && resizeProxy .style .display !== ' none' ) {
91- clearResizeHover ()
92- return
93- }
94-
95- const target = event .target instanceof Element ? event .target .closest (' th.el-table__cell' ) : null
96-
97- if (document .body .style .cursor !== ' col-resize' || ! (target instanceof HTMLElement )) {
98- clearResizeHover ()
99- return
100- }
101-
102- const rootRect = tableRootRef .value ?.getBoundingClientRect ()
103- const targetRect = target .getBoundingClientRect ()
104-
105- if (! rootRect ) {
106- return
107- }
108-
109- resizeHoverStyle .value = {
110- height: ` ${targetRect .height }px ` ,
111- left: ` ${targetRect .right - rootRect .left }px ` ,
112- top: ` ${targetRect .top - rootRect .top }px ` ,
113- }
114- }
115-
11670/** 分页 */
11771function handleCurrentPageChange(currentPage : number ) {
11872 if (! props .paginationConfig ) {
@@ -152,12 +106,7 @@ defineExpose({ clearSelection, tableRef })
152106 </script >
153107
154108<template >
155- <div
156- ref =" tableRootRef"
157- class =" mk-table relative flex w-full min-h-0 flex-1 flex-col"
158- @mouseleave =" clearResizeHover"
159- @mousemove =" handleTableMouseMove"
160- >
109+ <div class =" mk-table relative flex w-full min-h-0 flex-1 flex-col" >
161110 <el-table
162111 ref =" tableRef"
163112 :class =" { 'mk-table__resizable--borderless': props.resizable }"
@@ -171,12 +120,6 @@ defineExpose({ clearSelection, tableRef })
171120 <slot />
172121 </el-table >
173122
174- <div
175- v-if =" props.resizable && resizeHoverStyle"
176- class =" mk-table__resize-hover-indicator"
177- :style =" resizeHoverStyle"
178- />
179-
180123 <div class =" mt-4 flex justify-end" v-if =" props.paginationConfig" >
181124 <el-pagination
182125 background
@@ -212,6 +155,8 @@ defineExpose({ clearSelection, tableRef })
212155
213156<style scoped lang="scss">
214157:deep(.mk-table__resizable--borderless ) {
158+ border : none !important ;
159+
215160 & ,
216161 & ::after ,
217162 & ::before ,
@@ -223,14 +168,21 @@ defineExpose({ clearSelection, tableRef })
223168 .el-table__border-left-patch {
224169 display : none ;
225170 }
226- }
227171
228- .mk-table__resize-hover-indicator {
229- background-color : color-mix (in srgb , var (--mk-primary ) 20% , transparent );
230- pointer-events : none ;
231- position : absolute ;
232- transform : translateX (-50% );
233- width : 6px ;
234- z-index : 10 ;
172+ .el-table__header-wrapper :hover th .el-table__cell :not (:last-child )::after {
173+ background-color : var (--mk-N300 );
174+ content : ' ' ;
175+ height : 22px ;
176+ pointer-events : none ;
177+ position : absolute ;
178+ right : 0 ;
179+ top : 50% ;
180+ transform : translateY (-50% );
181+ width : 2px ;
182+ z-index : 1 ;
183+ }
184+ .el-table__column-resize-proxy {
185+ border-left : 2px solid var (--el-color-primary );
186+ }
235187}
236188 </style >
0 commit comments