vxe-table 3.12.10-beta.2 → 3.12.10-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/locale/lang/ar-EG.js +2 -1
- package/es/locale/lang/de-DE.js +2 -1
- package/es/locale/lang/en-US.js +2 -1
- package/es/locale/lang/es-ES.js +2 -1
- package/es/locale/lang/fr-FR.js +2 -1
- package/es/locale/lang/hu-HU.js +2 -1
- package/es/locale/lang/hy-AM.js +2 -1
- package/es/locale/lang/it-IT.js +2 -1
- package/es/locale/lang/ja-JP.js +2 -1
- package/es/locale/lang/ko-KR.js +2 -1
- package/es/locale/lang/nb-NO.js +2 -1
- package/es/locale/lang/pt-BR.js +2 -1
- package/es/locale/lang/ru-RU.js +4 -3
- package/es/locale/lang/th-TH.js +2 -1
- package/es/locale/lang/ug-CN.js +2 -1
- package/es/locale/lang/uk-UA.js +518 -517
- package/es/locale/lang/vi-VN.js +2 -1
- package/es/locale/lang/zh-CHT.js +2 -1
- package/es/locale/lang/zh-CN.js +2 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/edit/mixin.js +7 -7
- package/es/table/module/export/mixin.js +55 -32
- package/es/table/module/keyboard/mixin.js +68 -25
- package/es/table/module/menu/mixin.js +3 -1
- package/es/table/src/body.js +96 -64
- package/es/table/src/cell.js +3 -7
- package/es/table/src/column.js +2 -0
- package/es/table/src/columnInfo.js +1 -0
- package/es/table/src/footer.js +31 -6
- package/es/table/src/header.js +45 -141
- package/es/table/src/methods.js +918 -456
- package/es/table/src/props.js +6 -2
- package/es/table/src/table.js +299 -149
- package/es/table/src/util.js +67 -57
- package/es/table/style.css +299 -191
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +20 -10
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +299 -191
- package/es/vxe-table/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +1735 -1025
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ar-EG.js +2 -1
- package/lib/locale/lang/ar-EG.min.js +1 -1
- package/lib/locale/lang/de-DE.js +2 -1
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/en-US.js +2 -1
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +2 -1
- package/lib/locale/lang/es-ES.js +2 -1
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +2 -1
- package/lib/locale/lang/fr-FR.js +2 -1
- package/lib/locale/lang/fr-FR.min.js +1 -1
- package/lib/locale/lang/hu-HU.js +2 -1
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +2 -1
- package/lib/locale/lang/hy-AM.js +2 -1
- package/lib/locale/lang/hy-AM.min.js +1 -1
- package/lib/locale/lang/it-IT.js +2 -1
- package/lib/locale/lang/it-IT.min.js +1 -1
- package/lib/locale/lang/ja-JP.js +2 -1
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +2 -1
- package/lib/locale/lang/ko-KR.js +2 -1
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +2 -1
- package/lib/locale/lang/nb-NO.js +2 -1
- package/lib/locale/lang/nb-NO.min.js +1 -1
- package/lib/locale/lang/pt-BR.js +2 -1
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +2 -1
- package/lib/locale/lang/ru-RU.js +4 -3
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +4 -3
- package/lib/locale/lang/th-TH.js +2 -1
- package/lib/locale/lang/th-TH.min.js +1 -1
- package/lib/locale/lang/ug-CN.js +2 -1
- package/lib/locale/lang/ug-CN.min.js +1 -1
- package/lib/locale/lang/uk-UA.js +518 -517
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +518 -517
- package/lib/locale/lang/vi-VN.js +2 -1
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +2 -1
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +2 -1
- package/lib/locale/lang/zh-CN.js +2 -1
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +2 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/edit/mixin.js +12 -2
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/mixin.js +52 -27
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +73 -27
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +3 -1
- package/lib/table/src/body.js +89 -60
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +3 -5
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +2 -0
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +1 -0
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +26 -6
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +38 -153
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +1076 -551
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +6 -2
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +269 -129
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +80 -70
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +299 -191
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +20 -10
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +299 -191
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/locale/lang/ar-EG.ts +2 -1
- package/packages/locale/lang/de-DE.ts +2 -1
- package/packages/locale/lang/en-US.ts +2 -1
- package/packages/locale/lang/es-ES.ts +2 -1
- package/packages/locale/lang/fr-FR.ts +2 -1
- package/packages/locale/lang/hu-HU.ts +2 -1
- package/packages/locale/lang/hy-AM.ts +2 -1
- package/packages/locale/lang/it-IT.ts +2 -1
- package/packages/locale/lang/ja-JP.ts +2 -1
- package/packages/locale/lang/ko-KR.ts +2 -1
- package/packages/locale/lang/nb-NO.ts +2 -1
- package/packages/locale/lang/pt-BR.ts +2 -1
- package/packages/locale/lang/ru-RU.ts +4 -3
- package/packages/locale/lang/th-TH.ts +2 -1
- package/packages/locale/lang/ug-CN.ts +2 -1
- package/packages/locale/lang/uk-UA.ts +518 -517
- package/packages/locale/lang/vi-VN.ts +2 -1
- package/packages/locale/lang/zh-CHT.ts +2 -1
- package/packages/locale/lang/zh-CN.ts +2 -1
- package/packages/table/module/edit/mixin.ts +7 -7
- package/packages/table/module/export/mixin.ts +50 -27
- package/packages/table/module/keyboard/mixin.ts +65 -24
- package/packages/table/module/menu/mixin.ts +4 -1
- package/packages/table/src/body.ts +102 -61
- package/packages/table/src/cell.ts +3 -7
- package/packages/table/src/column.ts +7 -2
- package/packages/table/src/columnInfo.ts +1 -0
- package/packages/table/src/footer.ts +31 -6
- package/packages/table/src/header.ts +45 -141
- package/packages/table/src/methods.ts +957 -461
- package/packages/table/src/props.ts +6 -2
- package/packages/table/src/table.ts +325 -149
- package/packages/table/src/util.ts +75 -62
- package/packages/ui/index.ts +21 -9
- package/styles/components/table.scss +352 -260
- package/styles/theme/base.scss +4 -6
- package/styles/theme/dark.scss +1 -0
- package/styles/theme/light.scss +1 -0
- package/styles/variable.scss +1 -0
- /package/es/{iconfont.1736736807414.ttf → iconfont.1737182271148.ttf} +0 -0
- /package/es/{iconfont.1736736807414.woff → iconfont.1737182271148.woff} +0 -0
- /package/es/{iconfont.1736736807414.woff2 → iconfont.1737182271148.woff2} +0 -0
- /package/lib/{iconfont.1736736807414.ttf → iconfont.1737182271148.ttf} +0 -0
- /package/lib/{iconfont.1736736807414.woff → iconfont.1737182271148.woff} +0 -0
- /package/lib/{iconfont.1736736807414.woff2 → iconfont.1737182271148.woff2} +0 -0
|
@@ -2,12 +2,11 @@ import { PropType, CreateElement } from 'vue'
|
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
3
|
import { VxeUI } from '../../ui'
|
|
4
4
|
import { getClass } from '../../ui/src/utils'
|
|
5
|
-
import {
|
|
6
|
-
import { convertHeaderColumnToRows, getColReMinWidth } from './util'
|
|
5
|
+
import { convertHeaderColumnToRows } from './util'
|
|
7
6
|
|
|
8
7
|
import type { VxeTableDefines, VxeTableConstructor, VxeTablePrivateMethods, VxeColumnPropTypes, TableReactData, TableInternalData, VxeComponentStyleType } from '../../../types'
|
|
9
8
|
|
|
10
|
-
const {
|
|
9
|
+
const { renderer, renderEmptyElement } = VxeUI
|
|
11
10
|
|
|
12
11
|
const cellType = 'header'
|
|
13
12
|
|
|
@@ -25,6 +24,10 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
|
|
|
25
24
|
const { scrollXStore } = tableInternalData
|
|
26
25
|
const columnOpts = $xeTable.computeColumnOpts
|
|
27
26
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
27
|
+
const cellOpts = $xeTable.computeCellOpts
|
|
28
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
29
|
+
const headerCellOpts = $xeTable.computeHeaderCellOpts
|
|
30
|
+
const currCellHeight = headerCellOpts.height || cellOpts.height || defaultRowHeight
|
|
28
31
|
const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = columnDragOpts
|
|
29
32
|
return cols.map((column: any, $columnIndex: any) => {
|
|
30
33
|
const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column
|
|
@@ -34,6 +37,7 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
|
|
|
34
37
|
const compConf = renderOpts ? renderer.get(renderOpts.name) : null
|
|
35
38
|
const isColGroup = column.children && column.children.length
|
|
36
39
|
const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX
|
|
40
|
+
const isPadding = XEUtils.isBoolean(headerCellOpts.padding) ? headerCellOpts.padding : cellOpts.padding
|
|
37
41
|
const headOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
|
|
38
42
|
const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
|
|
39
43
|
let showEllipsis = headOverflow === 'ellipsis'
|
|
@@ -48,15 +52,15 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
|
|
|
48
52
|
}
|
|
49
53
|
const columnIndex = $xeTable.getColumnIndex(column)
|
|
50
54
|
const _columnIndex = $xeTable.getVTColumnIndex(column)
|
|
51
|
-
const
|
|
55
|
+
const cellParams = { $table: $xeTable, $grid: $xeGrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, firstFilterOption, fixed: fixedType, type: cellType, isHidden: fixedHiddenColumn, hasFilter }
|
|
52
56
|
const thAttrs: Record<string, string | number | null> = {
|
|
53
57
|
colid,
|
|
54
58
|
colspan: column.colSpan > 1 ? column.colSpan : null,
|
|
55
59
|
rowspan: column.rowSpan > 1 ? column.rowSpan : null
|
|
56
60
|
}
|
|
57
61
|
const thOns: any = {
|
|
58
|
-
click: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt,
|
|
59
|
-
dblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt,
|
|
62
|
+
click: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, cellParams),
|
|
63
|
+
dblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt, cellParams)
|
|
60
64
|
}
|
|
61
65
|
// 虚拟滚动不支持动态高度
|
|
62
66
|
if (scrollXLoad && !hasEllipsis) {
|
|
@@ -65,11 +69,11 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
|
|
|
65
69
|
const isColDragCell = columnOpts.drag && columnDragOpts.trigger === 'cell'
|
|
66
70
|
let isDisabledDrag = false
|
|
67
71
|
if (isColDragCell) {
|
|
68
|
-
isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(
|
|
72
|
+
isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(cellParams))
|
|
69
73
|
}
|
|
70
74
|
// 按下事件处理
|
|
71
75
|
if (mouseConfig || isColDragCell) {
|
|
72
|
-
thOns.mousedown = (evnt: any) => $xeTable.triggerHeaderCellMousedownEvent(evnt,
|
|
76
|
+
thOns.mousedown = (evnt: any) => $xeTable.triggerHeaderCellMousedownEvent(evnt, cellParams)
|
|
73
77
|
}
|
|
74
78
|
// 拖拽列事件
|
|
75
79
|
if (columnOpts.drag) {
|
|
@@ -80,32 +84,42 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
|
|
|
80
84
|
thOns.mouseup = $xeTable.handleHeaderCellDragMouseupEvent
|
|
81
85
|
}
|
|
82
86
|
}
|
|
87
|
+
const isLastColumn = $columnIndex === cols.length - 1
|
|
88
|
+
const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
|
|
83
89
|
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
|
|
84
90
|
|
|
85
|
-
let
|
|
86
|
-
if (scrollXLoad && !
|
|
87
|
-
|
|
91
|
+
let isVNPreEmptyStatus = false
|
|
92
|
+
if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
|
|
93
|
+
isVNPreEmptyStatus = true
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const tcStyle: Record<string, string> = {}
|
|
97
|
+
if (hasEllipsis) {
|
|
98
|
+
tcStyle.height = `${currCellHeight}px`
|
|
99
|
+
} else {
|
|
100
|
+
tcStyle.minHeight = `${currCellHeight}px`
|
|
88
101
|
}
|
|
89
102
|
|
|
90
103
|
return h('th', {
|
|
91
104
|
class: ['vxe-header--column', colid, {
|
|
92
105
|
[`col--${headAlign}`]: headAlign,
|
|
93
106
|
[`col--${type}`]: type,
|
|
94
|
-
'col--last':
|
|
107
|
+
'col--last': isLastColumn,
|
|
95
108
|
'col--fixed': column.fixed,
|
|
96
109
|
'col--group': isColGroup,
|
|
97
110
|
'col--ellipsis': hasEllipsis,
|
|
98
111
|
'fixed--width': !isAutoCellWidth,
|
|
99
112
|
'fixed--hidden': fixedHiddenColumn,
|
|
113
|
+
'is--padding': isPadding,
|
|
100
114
|
'is--sortable': column.sortable,
|
|
101
115
|
'col--filter': !!filters,
|
|
102
116
|
'is--filter-active': hasFilter,
|
|
103
117
|
'is--drag-active': !column.fixed && !isDisabledDrag && (isCrossDrag || isPeerDrag || !column.parentId),
|
|
104
118
|
'is--drag-disabled': isDisabledDrag,
|
|
105
119
|
'col--current': currentColumn === column
|
|
106
|
-
}, getClass(headerClassName,
|
|
120
|
+
}, getClass(headerClassName, cellParams), getClass(headerCellClassName, cellParams)],
|
|
107
121
|
attrs: thAttrs,
|
|
108
|
-
style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(
|
|
122
|
+
style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) as VxeComponentStyleType : undefined,
|
|
109
123
|
on: thOns,
|
|
110
124
|
key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex
|
|
111
125
|
}, [
|
|
@@ -114,22 +128,32 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
|
|
|
114
128
|
'c--title': showTitle,
|
|
115
129
|
'c--tooltip': showTooltip,
|
|
116
130
|
'c--ellipsis': showEllipsis
|
|
117
|
-
}]
|
|
118
|
-
|
|
131
|
+
}],
|
|
132
|
+
style: tcStyle
|
|
133
|
+
}, isVNPreEmptyStatus || (isOptimizeMode && fixedHiddenColumn)
|
|
134
|
+
? []
|
|
135
|
+
: [
|
|
136
|
+
h('div', {
|
|
137
|
+
attrs: {
|
|
138
|
+
colid
|
|
139
|
+
},
|
|
140
|
+
class: 'vxe-cell--wrapper'
|
|
141
|
+
}, column.renderHeader(h, cellParams))
|
|
142
|
+
]),
|
|
119
143
|
/**
|
|
120
144
|
* 列宽拖动
|
|
121
145
|
*/
|
|
122
|
-
!fixedHiddenColumn &&
|
|
146
|
+
!fixedHiddenColumn && showResizable
|
|
123
147
|
? h('div', {
|
|
124
|
-
class: ['vxe-resizable', {
|
|
148
|
+
class: ['vxe-cell--col-resizable', {
|
|
125
149
|
'is--line': !border || border === 'none'
|
|
126
150
|
}],
|
|
127
151
|
on: {
|
|
128
|
-
mousedown: (evnt: MouseEvent) =>
|
|
129
|
-
dblclick: (evnt: MouseEvent) => $xeTable.
|
|
152
|
+
mousedown: (evnt: MouseEvent) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
|
|
153
|
+
dblclick: (evnt: MouseEvent) => $xeTable.handleColResizeDblclickEvent(evnt, cellParams)
|
|
130
154
|
}
|
|
131
155
|
})
|
|
132
|
-
:
|
|
156
|
+
: renderEmptyElement($xeTable)
|
|
133
157
|
])
|
|
134
158
|
})
|
|
135
159
|
}
|
|
@@ -368,126 +392,6 @@ export default {
|
|
|
368
392
|
uploadColumn () {
|
|
369
393
|
const { $parent: $xetable } = this
|
|
370
394
|
this.headerColumn = $xetable.isGroup ? convertHeaderColumnToRows(this.tableGroupColumn) : []
|
|
371
|
-
},
|
|
372
|
-
resizeMousedownEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
|
|
373
|
-
const $xeTable = this.$parent
|
|
374
|
-
const tableInternalData = $xeTable
|
|
375
|
-
|
|
376
|
-
const { column } = params
|
|
377
|
-
const { $parent: $xetable, fixedType } = this
|
|
378
|
-
const { visibleColumn } = tableInternalData
|
|
379
|
-
const { refTableBody, refLeftContainer, refRightContainer } = $xetable.$refs
|
|
380
|
-
const tableEl = $xeTable.$el as HTMLDivElement
|
|
381
|
-
const resizeBarElem = $xetable.$refs.refCellResizeBar as HTMLDivElement
|
|
382
|
-
const resizeTipElem = $xetable.$refs.refCellResizeTip as HTMLDivElement
|
|
383
|
-
const wrapperElem = this.$el as HTMLDivElement
|
|
384
|
-
const { clientX: dragClientX } = evnt
|
|
385
|
-
const dragBtnElem = evnt.target as HTMLDivElement
|
|
386
|
-
const cell = dragBtnElem.parentNode as HTMLTableCellElement
|
|
387
|
-
const cellParams = Object.assign(params, { cell })
|
|
388
|
-
const resizableOpts = $xeTable.computeResizableOpts
|
|
389
|
-
let dragLeft = 0
|
|
390
|
-
const tableBodyElem = refTableBody.$el
|
|
391
|
-
const pos = getOffsetPos(dragBtnElem, tableEl)
|
|
392
|
-
const dragBtnWidth = dragBtnElem.clientWidth
|
|
393
|
-
const dragBtnOffsetWidth = Math.floor(dragBtnWidth / 2)
|
|
394
|
-
const minInterval = getColReMinWidth(cellParams) - dragBtnOffsetWidth // 列之间的最小间距
|
|
395
|
-
let dragMinLeft = pos.left - cell.clientWidth + dragBtnWidth + minInterval
|
|
396
|
-
let dragPosLeft = pos.left + dragBtnOffsetWidth
|
|
397
|
-
const domMousemove = document.onmousemove
|
|
398
|
-
const domMouseup = document.onmouseup
|
|
399
|
-
const isLeftFixed = fixedType === 'left'
|
|
400
|
-
const isRightFixed = fixedType === 'right'
|
|
401
|
-
|
|
402
|
-
// 计算左右侧固定列偏移量
|
|
403
|
-
let fixedOffsetWidth = 0
|
|
404
|
-
if (isLeftFixed || isRightFixed) {
|
|
405
|
-
const siblingProp = isLeftFixed ? 'nextElementSibling' : 'previousElementSibling'
|
|
406
|
-
let tempCellElem = cell[siblingProp] as HTMLTableCellElement
|
|
407
|
-
while (tempCellElem) {
|
|
408
|
-
if (hasClass(tempCellElem, 'fixed--hidden')) {
|
|
409
|
-
break
|
|
410
|
-
} else if (!hasClass(tempCellElem, 'col--group')) {
|
|
411
|
-
fixedOffsetWidth += tempCellElem.offsetWidth
|
|
412
|
-
}
|
|
413
|
-
tempCellElem = tempCellElem[siblingProp] as HTMLTableCellElement
|
|
414
|
-
}
|
|
415
|
-
if (isRightFixed && refRightContainer) {
|
|
416
|
-
dragPosLeft = refRightContainer.offsetLeft + fixedOffsetWidth
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// 处理拖动事件
|
|
421
|
-
const updateEvent = function (evnt: any) {
|
|
422
|
-
evnt.stopPropagation()
|
|
423
|
-
evnt.preventDefault()
|
|
424
|
-
const offsetX = evnt.clientX - dragClientX
|
|
425
|
-
let left = dragPosLeft + offsetX
|
|
426
|
-
const scrollLeft = fixedType ? 0 : tableBodyElem.scrollLeft
|
|
427
|
-
if (isLeftFixed) {
|
|
428
|
-
// 左固定列(不允许超过右侧固定列、不允许超过右边距)
|
|
429
|
-
left = Math.min(left, (refRightContainer ? refRightContainer.offsetLeft : tableBodyElem.clientWidth) - fixedOffsetWidth - minInterval)
|
|
430
|
-
} else if (isRightFixed) {
|
|
431
|
-
// 右侧固定列(不允许超过左侧固定列、不允许超过左边距)
|
|
432
|
-
dragMinLeft = (refLeftContainer ? refLeftContainer.clientWidth : 0) + fixedOffsetWidth + minInterval
|
|
433
|
-
left = Math.min(left, dragPosLeft + cell.clientWidth - minInterval)
|
|
434
|
-
} else {
|
|
435
|
-
dragMinLeft = Math.max(tableBodyElem.scrollLeft, dragMinLeft)
|
|
436
|
-
// left = Math.min(left, tableBodyElem.clientWidth + tableBodyElem.scrollLeft - 40)
|
|
437
|
-
}
|
|
438
|
-
dragLeft = Math.max(left, dragMinLeft)
|
|
439
|
-
const resizeBarLeft = dragLeft - scrollLeft
|
|
440
|
-
resizeBarElem.style.left = `${resizeBarLeft}px`
|
|
441
|
-
if (resizableOpts.showDragTip && resizeTipElem) {
|
|
442
|
-
const tableWidth = tableEl.clientWidth
|
|
443
|
-
const wrapperRect = wrapperElem.getBoundingClientRect()
|
|
444
|
-
const resizeBarWidth = resizeBarElem.clientWidth
|
|
445
|
-
const resizeTipWidth = resizeTipElem.clientWidth
|
|
446
|
-
const resizeTipHeight = resizeTipElem.clientHeight
|
|
447
|
-
let resizeTipLeft = -resizeTipWidth
|
|
448
|
-
if (resizeBarLeft < resizeTipWidth + resizeBarWidth) {
|
|
449
|
-
resizeTipLeft = resizeTipWidth + resizeBarWidth - resizeBarLeft
|
|
450
|
-
} else if (resizeBarLeft > tableWidth) {
|
|
451
|
-
resizeTipLeft += tableWidth - resizeBarLeft
|
|
452
|
-
}
|
|
453
|
-
resizeTipElem.style.left = `${resizeTipLeft}px`
|
|
454
|
-
resizeTipElem.style.top = `${Math.min(tableEl.clientHeight - resizeTipHeight, Math.max(0, evnt.clientY - wrapperRect.y - resizeTipHeight / 2))}px`
|
|
455
|
-
resizeTipElem.textContent = getI18n('vxe.table.resizeColTip', [column.renderWidth + (isRightFixed ? dragPosLeft - dragLeft : dragLeft - dragPosLeft)])
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
$xetable._isResize = true
|
|
460
|
-
addClass($xetable.$el, 'drag--resize')
|
|
461
|
-
resizeBarElem.style.display = 'block'
|
|
462
|
-
document.onmousemove = updateEvent
|
|
463
|
-
document.onmouseup = function (evnt) {
|
|
464
|
-
document.onmousemove = domMousemove
|
|
465
|
-
document.onmouseup = domMouseup
|
|
466
|
-
const resizeWidth = column.renderWidth + (isRightFixed ? dragPosLeft - dragLeft : dragLeft - dragPosLeft)
|
|
467
|
-
column.resizeWidth = resizeWidth
|
|
468
|
-
if (resizableOpts.dragMode === 'fixed') {
|
|
469
|
-
visibleColumn.forEach((item: any) => {
|
|
470
|
-
if (item.id !== column.id) {
|
|
471
|
-
if (!item.resizeWidth) {
|
|
472
|
-
item.resizeWidth = item.renderWidth
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
})
|
|
476
|
-
}
|
|
477
|
-
resizeBarElem.style.display = 'none'
|
|
478
|
-
$xetable._isResize = false
|
|
479
|
-
$xetable._lastResizeTime = Date.now()
|
|
480
|
-
$xetable.analyColumnWidth()
|
|
481
|
-
$xetable.recalculate(true).then(() => {
|
|
482
|
-
$xetable.saveCustomStore('update:visible')
|
|
483
|
-
$xetable.updateCellAreas()
|
|
484
|
-
$xetable.emitEvent('resizable-change', { ...params, resizeWidth }, evnt)
|
|
485
|
-
setTimeout(() => $xetable.recalculate(true), 300)
|
|
486
|
-
})
|
|
487
|
-
removeClass($xetable.$el, 'drag--resize')
|
|
488
|
-
}
|
|
489
|
-
updateEvent(evnt)
|
|
490
|
-
$xetable.closeMenu()
|
|
491
395
|
}
|
|
492
396
|
} as any
|
|
493
397
|
} as any
|