vxe-table 3.12.8 → 3.12.10-beta.0
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/grid/src/grid.js +6 -1
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/export/mixin.js +3 -3
- package/es/table/module/filter/mixin.js +3 -3
- package/es/table/module/keyboard/mixin.js +4 -4
- package/es/table/module/menu/mixin.js +2 -2
- package/es/table/module/validator/mixin.js +2 -2
- package/es/table/src/body.js +262 -363
- package/es/table/src/footer.js +135 -154
- package/es/table/src/header.js +120 -100
- package/es/table/src/methods.js +1175 -816
- package/es/table/src/props.js +9 -3
- package/es/table/src/table.js +187 -103
- package/es/table/src/util.js +35 -21
- package/es/table/style.css +146 -63
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +14 -4
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +146 -63
- package/es/vxe-table/style.min.css +1 -1
- package/lib/grid/src/grid.js +4 -1
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +1920 -1599
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/export/mixin.js +3 -3
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/filter/mixin.js +4 -4
- package/lib/table/module/filter/mixin.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +5 -5
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +2 -2
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +2 -2
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/body.js +205 -381
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/footer.js +124 -151
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +97 -74
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +1261 -875
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +9 -3
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +171 -90
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +38 -22
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +146 -63
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +14 -4
- 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 +146 -63
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/grid/src/grid.ts +6 -1
- package/packages/table/module/export/mixin.ts +3 -3
- package/packages/table/module/filter/mixin.ts +3 -3
- package/packages/table/module/keyboard/mixin.ts +4 -4
- package/packages/table/module/menu/mixin.ts +2 -2
- package/packages/table/module/validator/mixin.ts +2 -2
- package/packages/table/src/body.ts +296 -436
- package/packages/table/src/footer.ts +148 -164
- package/packages/table/src/header.ts +135 -111
- package/packages/table/src/methods.ts +1249 -873
- package/packages/table/src/props.ts +9 -3
- package/packages/table/src/table.ts +195 -146
- package/packages/table/src/util.ts +40 -23
- package/packages/ui/index.ts +13 -3
- package/styles/components/table.scss +164 -74
- /package/es/{iconfont.1736406699090.ttf → iconfont.1736688976404.ttf} +0 -0
- /package/es/{iconfont.1736406699090.woff → iconfont.1736688976404.woff} +0 -0
- /package/es/{iconfont.1736406699090.woff2 → iconfont.1736688976404.woff2} +0 -0
- /package/lib/{iconfont.1736406699090.ttf → iconfont.1736688976404.ttf} +0 -0
- /package/lib/{iconfont.1736406699090.woff → iconfont.1736688976404.woff} +0 -0
- /package/lib/{iconfont.1736406699090.woff2 → iconfont.1736688976404.woff2} +0 -0
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils'
|
|
2
|
-
import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft
|
|
2
|
+
import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft } from '../../ui/src/dom'
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
5
|
import Cell from './cell'
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth } from './util'
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getRefElem } from './util'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
9
9
|
|
|
10
|
-
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, TableInternalData, VxeTablePrivateMethods } from '../../../types'
|
|
10
|
+
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeTablePrivateMethods, VxeTooltipInstance } from '../../../types'
|
|
11
11
|
|
|
12
12
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
|
|
13
13
|
|
|
14
14
|
const customStorageKey = 'VXE_CUSTOM_STORE'
|
|
15
15
|
|
|
16
|
-
// 获取所有的列,排除分组
|
|
17
|
-
const getColumnList = (columns: any[]) => {
|
|
18
|
-
const result: any[] = []
|
|
19
|
-
columns.forEach((column) => {
|
|
20
|
-
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
|
|
21
|
-
})
|
|
22
|
-
return result
|
|
23
|
-
}
|
|
24
|
-
|
|
25
16
|
function eqCellValue (row1: any, row2: any, field: any) {
|
|
26
17
|
const val1 = XEUtils.get(row1, field)
|
|
27
18
|
const val2 = XEUtils.get(row2, field)
|
|
@@ -78,21 +69,23 @@ function handleReserveRow (_vm: any, reserveRowMap: any) {
|
|
|
78
69
|
return reserveList
|
|
79
70
|
}
|
|
80
71
|
|
|
81
|
-
function handleVirtualXVisible ($xeTable:
|
|
82
|
-
const internalData = $xeTable
|
|
72
|
+
function handleVirtualXVisible ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
73
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
83
74
|
|
|
84
|
-
const { visibleColumn } = internalData
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
75
|
+
const { elemStore, visibleColumn } = internalData
|
|
76
|
+
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
77
|
+
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
78
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
79
|
+
if (bodyScrollElem) {
|
|
80
|
+
const { scrollLeft, clientWidth } = bodyScrollElem
|
|
81
|
+
const startWidth = scrollLeft + leftFixedWidth
|
|
82
|
+
const endWidth = scrollLeft + clientWidth - rightFixedWidth
|
|
90
83
|
let toVisibleIndex = -1
|
|
91
84
|
let cWidth = 0
|
|
92
85
|
let visibleSize = 0
|
|
93
86
|
for (let colIndex = 0, colLen = visibleColumn.length; colIndex < colLen; colIndex++) {
|
|
94
87
|
cWidth += visibleColumn[colIndex].renderWidth
|
|
95
|
-
if (toVisibleIndex === -1 &&
|
|
88
|
+
if (toVisibleIndex === -1 && startWidth < cWidth) {
|
|
96
89
|
toVisibleIndex = colIndex
|
|
97
90
|
}
|
|
98
91
|
if (toVisibleIndex >= 0) {
|
|
@@ -102,15 +95,92 @@ function handleVirtualXVisible ($xeTable: any) {
|
|
|
102
95
|
}
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
|
-
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(
|
|
98
|
+
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(1, visibleSize) }
|
|
106
99
|
}
|
|
107
100
|
return { toVisibleIndex: 0, visibleSize: 6 }
|
|
108
101
|
}
|
|
109
102
|
|
|
103
|
+
function handleCustomRestore ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, storeData: VxeTableDefines.CustomStoreData) {
|
|
104
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
105
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
106
|
+
|
|
107
|
+
let { collectColumn } = internalData
|
|
108
|
+
const { resizableData, sortData, visibleData, fixedData } = storeData
|
|
109
|
+
let hasCustomSort = false
|
|
110
|
+
// 处理还原
|
|
111
|
+
if (resizableData || sortData || visibleData || fixedData) {
|
|
112
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
113
|
+
const colKey = column.getKey()
|
|
114
|
+
// 支持一级
|
|
115
|
+
if (!parentColumn) {
|
|
116
|
+
if (fixedData && fixedData[colKey] !== undefined) {
|
|
117
|
+
column.fixed = fixedData[colKey]
|
|
118
|
+
}
|
|
119
|
+
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
120
|
+
hasCustomSort = true
|
|
121
|
+
column.renderSortNumber = sortData[colKey]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
125
|
+
column.resizeWidth = resizableData[colKey]
|
|
126
|
+
}
|
|
127
|
+
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
128
|
+
column.visible = visibleData[colKey]
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
// 如果自定义了顺序
|
|
132
|
+
if (hasCustomSort) {
|
|
133
|
+
collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
|
|
134
|
+
internalData.collectColumn = collectColumn
|
|
135
|
+
internalData.tableFullColumn = getColumnList(collectColumn)
|
|
136
|
+
}
|
|
137
|
+
reactData.isCustomStatus = true
|
|
138
|
+
} else {
|
|
139
|
+
reactData.isCustomStatus = false
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
110
143
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
144
|
+
* 还原自定义列操作状态
|
|
145
|
+
*/
|
|
146
|
+
function restoreCustomStorage ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
147
|
+
const props = $xeTable
|
|
148
|
+
|
|
149
|
+
const { customConfig } = props
|
|
150
|
+
const tableId = $xeTable.computeTableId
|
|
151
|
+
const customOpts = $xeTable.computeCustomOpts
|
|
152
|
+
const { storage, restoreStore } = customOpts
|
|
153
|
+
const isAllCustom = storage === true
|
|
154
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
155
|
+
const isCustomResizable = isAllCustom || storageOpts.resizable
|
|
156
|
+
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
157
|
+
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
158
|
+
const isCustomSort = isAllCustom || storageOpts.sort
|
|
159
|
+
if ((customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
|
|
160
|
+
if (!tableId) {
|
|
161
|
+
errLog('vxe.error.reqProp', ['id'])
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
const storeData: VxeTableDefines.CustomStoreData = getCustomStorageMap(tableId)
|
|
165
|
+
if (restoreStore) {
|
|
166
|
+
return Promise.resolve(
|
|
167
|
+
restoreStore({ id: tableId, type: 'restore', storeData })
|
|
168
|
+
).then(storeData => {
|
|
169
|
+
if (!storeData) {
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
return handleCustomRestore($xeTable, storeData)
|
|
173
|
+
}).catch(e => e)
|
|
174
|
+
} else {
|
|
175
|
+
return handleCustomRestore($xeTable, storeData)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 更新数据列的 Map
|
|
182
|
+
* 牺牲数据组装的耗时,用来换取使用过程中的流畅
|
|
183
|
+
*/
|
|
114
184
|
function cacheColumnMap ($xeTable: VxeTableConstructor) {
|
|
115
185
|
const props = $xeTable
|
|
116
186
|
const reactData = $xeTable as unknown as TableReactData
|
|
@@ -143,7 +213,7 @@ function cacheColumnMap ($xeTable: VxeTableConstructor) {
|
|
|
143
213
|
}
|
|
144
214
|
fullColumnFieldData[field] = rest
|
|
145
215
|
} else {
|
|
146
|
-
if (storage || isCrossDrag || isSelfToChildDrag) {
|
|
216
|
+
if (storage || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
|
|
147
217
|
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field`])
|
|
148
218
|
}
|
|
149
219
|
}
|
|
@@ -284,15 +354,345 @@ function handleVirtualTreeToList ($xeTable: VxeTableConstructor) {
|
|
|
284
354
|
return internalData.afterFullData
|
|
285
355
|
}
|
|
286
356
|
|
|
287
|
-
function
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const
|
|
357
|
+
function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
358
|
+
const props = $xeTable
|
|
359
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
360
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
361
|
+
|
|
362
|
+
const { border, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
|
|
363
|
+
const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, scrollbarWidth, scrollbarHeight, columnStore, editStore, isAllOverflow, expandColumn } = reactData
|
|
364
|
+
const { visibleColumn, fullColumnIdData, tableHeight, tableWidth, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData
|
|
365
|
+
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
366
|
+
if (!el) {
|
|
367
|
+
return
|
|
368
|
+
}
|
|
369
|
+
const containerList = ['main', 'left', 'right']
|
|
370
|
+
const emptyPlaceholderElem = $xeTable.$refs.refEmptyPlaceholder as HTMLDivElement
|
|
371
|
+
const cellOffsetWidth = $xeTable.computeCellOffsetWidth
|
|
372
|
+
const mouseOpts = $xeTable.computeMouseOpts
|
|
373
|
+
const bodyWrapperElem = getRefElem(elemStore['main-body-wrapper'])
|
|
374
|
+
const bodyTableElem = getRefElem(elemStore['main-body-table'])
|
|
375
|
+
if (emptyPlaceholderElem) {
|
|
376
|
+
emptyPlaceholderElem.style.top = `${headerHeight}px`
|
|
377
|
+
emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : ''
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
let bodyHeight = 0
|
|
381
|
+
let bodyMaxHeight = 0
|
|
382
|
+
const bodyMinHeight = customMinHeight - headerHeight - footerHeight - scrollbarHeight
|
|
383
|
+
if (customMaxHeight) {
|
|
384
|
+
bodyMaxHeight = Math.max(bodyMinHeight, customMaxHeight - headerHeight - footerHeight - scrollbarHeight)
|
|
385
|
+
}
|
|
386
|
+
if (customHeight) {
|
|
387
|
+
bodyHeight = customHeight - headerHeight - footerHeight - scrollbarHeight
|
|
388
|
+
}
|
|
389
|
+
if (!bodyHeight) {
|
|
390
|
+
if (bodyTableElem) {
|
|
391
|
+
bodyHeight = bodyTableElem.clientHeight
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (bodyHeight) {
|
|
395
|
+
if (bodyMaxHeight) {
|
|
396
|
+
bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
|
|
397
|
+
}
|
|
398
|
+
bodyHeight = Math.max(bodyMinHeight, bodyHeight)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem as HTMLDivElement
|
|
402
|
+
if (scrollXVirtualEl) {
|
|
403
|
+
scrollXVirtualEl.style.height = `${scrollbarHeight}px`
|
|
404
|
+
scrollXVirtualEl.style.visibility = scrollbarHeight ? 'visible' : 'hidden'
|
|
405
|
+
}
|
|
406
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
407
|
+
if (xHandleEl) {
|
|
408
|
+
xHandleEl.style.width = `${el.clientWidth - scrollbarWidth}px`
|
|
409
|
+
}
|
|
410
|
+
const xRightCornerEl = $xeTable.$refs.refScrollXRightCornerElem as HTMLDivElement
|
|
411
|
+
if (xRightCornerEl) {
|
|
412
|
+
xRightCornerEl.style.width = `${scrollbarWidth}px`
|
|
413
|
+
xRightCornerEl.style.display = scrollbarWidth && scrollbarHeight ? 'block' : ''
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem as HTMLDivElement
|
|
417
|
+
if (scrollYVirtualEl) {
|
|
418
|
+
scrollYVirtualEl.style.width = `${scrollbarWidth}px`
|
|
419
|
+
scrollYVirtualEl.style.height = `${bodyHeight + headerHeight + footerHeight}px`
|
|
420
|
+
scrollYVirtualEl.style.visibility = scrollbarWidth ? 'visible' : 'hidden'
|
|
421
|
+
}
|
|
422
|
+
const yTopCornerEl = $xeTable.$refs.refScrollYTopCornerElem as HTMLDivElement
|
|
423
|
+
if (yTopCornerEl) {
|
|
424
|
+
yTopCornerEl.style.height = `${headerHeight}px`
|
|
425
|
+
yTopCornerEl.style.display = headerHeight ? 'block' : ''
|
|
426
|
+
}
|
|
427
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
428
|
+
if (yHandleEl) {
|
|
429
|
+
yHandleEl.style.height = `${bodyHeight}px`
|
|
430
|
+
yHandleEl.style.top = `${headerHeight}px`
|
|
431
|
+
}
|
|
432
|
+
const yBottomCornerEl = $xeTable.$refs.refScrollYBottomCornerElem as HTMLDivElement
|
|
433
|
+
if (yBottomCornerEl) {
|
|
434
|
+
yBottomCornerEl.style.height = `${footerHeight}px`
|
|
435
|
+
yBottomCornerEl.style.top = `${headerHeight + bodyHeight}px`
|
|
436
|
+
yBottomCornerEl.style.display = footerHeight ? 'block' : ''
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
containerList.forEach((name, index) => {
|
|
440
|
+
const fixedType = index > 0 ? name : ''
|
|
441
|
+
const layoutList = ['header', 'body', 'footer']
|
|
442
|
+
const isFixedLeft = fixedType === 'left'
|
|
443
|
+
let fixedColumn: VxeTableDefines.ColumnInfo[] = []
|
|
444
|
+
let fixedWrapperElem: HTMLDivElement
|
|
445
|
+
if (fixedType) {
|
|
446
|
+
fixedColumn = isFixedLeft ? columnStore.leftList : columnStore.rightList
|
|
447
|
+
fixedWrapperElem = (isFixedLeft ? $xeTable.$refs.refLeftContainer : $xeTable.$refs.refRightContainer) as HTMLDivElement
|
|
448
|
+
}
|
|
449
|
+
layoutList.forEach(layout => {
|
|
450
|
+
const wrapperElem = getRefElem(elemStore[`${name}-${layout}-wrapper`])
|
|
451
|
+
const currScrollElem = getRefElem(elemStore[`${name}-${layout}-scroll`])
|
|
452
|
+
const tableElem = getRefElem(elemStore[`${name}-${layout}-table`])
|
|
453
|
+
if (layout === 'header') {
|
|
454
|
+
// 表头体样式处理
|
|
455
|
+
// 横向滚动渲染
|
|
456
|
+
let tWidth = tableWidth
|
|
457
|
+
let renderColumnList = tableColumn
|
|
458
|
+
let isOptimizeMode = false
|
|
459
|
+
|
|
460
|
+
if (isGroup) {
|
|
461
|
+
renderColumnList = visibleColumn
|
|
462
|
+
|
|
463
|
+
if (fixedType) {
|
|
464
|
+
if (wrapperElem) {
|
|
465
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
} else {
|
|
469
|
+
// 如果是使用优化模式
|
|
470
|
+
if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
|
|
471
|
+
if (spanMethod || footerSpanMethod) {
|
|
472
|
+
// 如果不支持优化模式
|
|
473
|
+
} else {
|
|
474
|
+
isOptimizeMode = true
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (fixedType) {
|
|
479
|
+
renderColumnList = visibleColumn
|
|
480
|
+
// 如果是使用优化模式
|
|
481
|
+
if (isOptimizeMode) {
|
|
482
|
+
renderColumnList = fixedColumn || []
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (!isOptimizeMode) {
|
|
486
|
+
if (wrapperElem) {
|
|
487
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0)
|
|
494
|
+
|
|
495
|
+
if (currScrollElem) {
|
|
496
|
+
currScrollElem.style.height = `${headerHeight}px`
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (tableElem) {
|
|
500
|
+
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const repairElem = getRefElem(elemStore[`${name}-${layout}-repair`])
|
|
504
|
+
if (repairElem) {
|
|
505
|
+
repairElem.style.width = `${tableWidth}px`
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const listElem = getRefElem(elemStore[`${name}-${layout}-list`])
|
|
509
|
+
if (isGroup && listElem) {
|
|
510
|
+
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem: any) => {
|
|
511
|
+
const colNode = $xeTable.getColumnNode(thElem)
|
|
512
|
+
if (colNode) {
|
|
513
|
+
const column = colNode.item
|
|
514
|
+
const { showHeaderOverflow } = column
|
|
515
|
+
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow
|
|
516
|
+
const showEllipsis = cellOverflow === 'ellipsis'
|
|
517
|
+
const showTitle = cellOverflow === 'title'
|
|
518
|
+
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
519
|
+
const hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
520
|
+
let childWidth = 0
|
|
521
|
+
let countChild = 0
|
|
522
|
+
if (hasEllipsis) {
|
|
523
|
+
XEUtils.eachTree(column.children, (item) => {
|
|
524
|
+
if (!item.children || !column.children.length) {
|
|
525
|
+
countChild++
|
|
526
|
+
}
|
|
527
|
+
childWidth += item.renderWidth
|
|
528
|
+
}, { children: 'children' })
|
|
529
|
+
}
|
|
530
|
+
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : ''
|
|
531
|
+
}
|
|
532
|
+
})
|
|
533
|
+
}
|
|
534
|
+
} else if (layout === 'body') {
|
|
535
|
+
if (currScrollElem) {
|
|
536
|
+
currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : ''
|
|
537
|
+
currScrollElem.style.height = customHeight ? `${bodyHeight}px` : ''
|
|
538
|
+
currScrollElem.style.minHeight = `${bodyMinHeight}px`
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// 如果是固定列
|
|
542
|
+
if (fixedWrapperElem) {
|
|
543
|
+
if (wrapperElem) {
|
|
544
|
+
wrapperElem.style.top = `${headerHeight}px`
|
|
545
|
+
}
|
|
546
|
+
fixedWrapperElem.style.height = `${customHeight > 0 ? customHeight : (tableHeight + headerHeight + footerHeight + scrollbarHeight)}px`
|
|
547
|
+
fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, 0)}px`
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
let tWidth = tableWidth
|
|
551
|
+
let renderColumnList = tableColumn
|
|
552
|
+
|
|
553
|
+
let isOptimizeMode = false
|
|
554
|
+
// 如果是使用优化模式
|
|
555
|
+
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
556
|
+
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
557
|
+
// 如果不支持优化模式
|
|
558
|
+
} else {
|
|
559
|
+
isOptimizeMode = true
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (fixedType) {
|
|
564
|
+
renderColumnList = visibleColumn
|
|
565
|
+
if (isOptimizeMode) {
|
|
566
|
+
renderColumnList = fixedColumn || []
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (!isOptimizeMode) {
|
|
570
|
+
if (wrapperElem) {
|
|
571
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0)
|
|
577
|
+
|
|
578
|
+
if (tableElem) {
|
|
579
|
+
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
580
|
+
// 兼容性处理
|
|
581
|
+
tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : ''
|
|
582
|
+
}
|
|
583
|
+
const emptyBlockElem = getRefElem(elemStore[`${name}-${layout}-emptyBlock`])
|
|
584
|
+
if (emptyBlockElem) {
|
|
585
|
+
emptyBlockElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
586
|
+
}
|
|
587
|
+
} else if (layout === 'footer') {
|
|
588
|
+
let tWidth = tableWidth
|
|
589
|
+
|
|
590
|
+
let renderColumnList = tableColumn
|
|
591
|
+
let isOptimizeMode = false
|
|
592
|
+
// 如果是使用优化模式
|
|
593
|
+
if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
|
|
594
|
+
if (spanMethod || footerSpanMethod) {
|
|
595
|
+
// 如果不支持优化模式
|
|
596
|
+
} else {
|
|
597
|
+
isOptimizeMode = true
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (fixedType) {
|
|
602
|
+
renderColumnList = visibleColumn
|
|
603
|
+
if (isOptimizeMode) {
|
|
604
|
+
renderColumnList = fixedColumn || []
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if (!isOptimizeMode) {
|
|
608
|
+
if (wrapperElem) {
|
|
609
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0)
|
|
615
|
+
|
|
616
|
+
if (currScrollElem) {
|
|
617
|
+
currScrollElem.style.height = `${footerHeight}px`
|
|
618
|
+
// 如果是固定列
|
|
619
|
+
if (fixedWrapperElem) {
|
|
620
|
+
if (wrapperElem) {
|
|
621
|
+
wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight - scrollbarHeight : tableHeight + headerHeight}px`
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (tableElem) {
|
|
626
|
+
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const colgroupElem = getRefElem(elemStore[`${name}-${layout}-colgroup`])
|
|
630
|
+
if (colgroupElem) {
|
|
631
|
+
XEUtils.arrayEach(colgroupElem.children, (colElem: any) => {
|
|
632
|
+
const colid = colElem.getAttribute('name')
|
|
633
|
+
if (fullColumnIdData[colid]) {
|
|
634
|
+
const colRest = fullColumnIdData[colid]
|
|
635
|
+
const column = colRest.column
|
|
636
|
+
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column
|
|
637
|
+
let cellOverflow
|
|
638
|
+
colElem.style.width = `${column.renderWidth}px`
|
|
639
|
+
if (layout === 'header') {
|
|
640
|
+
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
|
|
641
|
+
} else if (layout === 'footer') {
|
|
642
|
+
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
|
|
643
|
+
} else {
|
|
644
|
+
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow
|
|
645
|
+
}
|
|
646
|
+
const showEllipsis = cellOverflow === 'ellipsis'
|
|
647
|
+
const showTitle = cellOverflow === 'title'
|
|
648
|
+
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
649
|
+
let hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
650
|
+
const listElem = getRefElem(elemStore[`${name}-${layout}-list`])
|
|
651
|
+
// 纵向虚拟滚动不支持动态行高
|
|
652
|
+
if (scrollYLoad && !hasEllipsis) {
|
|
653
|
+
hasEllipsis = true
|
|
654
|
+
}
|
|
655
|
+
if (listElem) {
|
|
656
|
+
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem: any) => {
|
|
657
|
+
const colspan = parseInt(elem.getAttribute('colspan') || 1)
|
|
658
|
+
const cellElem = elem.querySelector('.vxe-cell')
|
|
659
|
+
let colWidth = column.renderWidth
|
|
660
|
+
if (cellElem) {
|
|
661
|
+
if (colspan > 1) {
|
|
662
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
663
|
+
for (let index = 1; index < colspan; index++) {
|
|
664
|
+
const nextColumn = $xeTable.getColumns(columnIndex + index)
|
|
665
|
+
if (nextColumn) {
|
|
666
|
+
colWidth += nextColumn.renderWidth
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : ''
|
|
671
|
+
}
|
|
672
|
+
})
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
})
|
|
676
|
+
}
|
|
677
|
+
})
|
|
678
|
+
})
|
|
679
|
+
if (currentRow) {
|
|
680
|
+
$xeTable.setCurrentRow(currentRow)
|
|
681
|
+
}
|
|
682
|
+
if (mouseConfig && mouseOpts.selected && editStore.selected.row && editStore.selected.column) {
|
|
683
|
+
$xeTable.addCellSelectedClass()
|
|
684
|
+
}
|
|
685
|
+
return $xeTable.$nextTick()
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function computeRowHeight ($xeTable: VxeTableConstructor) {
|
|
689
|
+
const tableHeader = $xeTable.$refs.refTableHeader
|
|
690
|
+
const tableBody = $xeTable.$refs.refTableBody
|
|
691
|
+
const tableBodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
|
|
692
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
293
693
|
let rowHeight = 0
|
|
294
694
|
if (tableBodyElem) {
|
|
295
|
-
const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
|
|
695
|
+
const tableHeaderElem = tableHeader ? (tableHeader as any).$el as HTMLDivElement : null
|
|
296
696
|
let firstTrElem
|
|
297
697
|
firstTrElem = tableBodyElem.querySelector('tr')
|
|
298
698
|
if (!firstTrElem && tableHeaderElem) {
|
|
@@ -303,7 +703,7 @@ function computeRowHeight ($xeTable: any) {
|
|
|
303
703
|
}
|
|
304
704
|
}
|
|
305
705
|
if (!rowHeight) {
|
|
306
|
-
rowHeight =
|
|
706
|
+
rowHeight = defaultRowHeight
|
|
307
707
|
}
|
|
308
708
|
// 最低支持 18px 行高
|
|
309
709
|
return Math.max(18, rowHeight)
|
|
@@ -311,15 +711,15 @@ function computeRowHeight ($xeTable: any) {
|
|
|
311
711
|
|
|
312
712
|
function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
313
713
|
const props = $xeTable
|
|
714
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
314
715
|
const internalData = $xeTable as unknown as TableInternalData
|
|
315
716
|
|
|
316
717
|
const { showOverflow } = props
|
|
317
|
-
const {
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const { scrollTop, clientHeight } = tableBodyElem
|
|
718
|
+
const { rowHeight } = reactData
|
|
719
|
+
const { elemStore, afterFullData, fullAllDataRowIdData } = internalData
|
|
720
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
721
|
+
if (bodyScrollElem) {
|
|
722
|
+
const { scrollTop, clientHeight } = bodyScrollElem
|
|
323
723
|
const endHeight = scrollTop + clientHeight
|
|
324
724
|
let toVisibleIndex = -1
|
|
325
725
|
let offsetTop = 0
|
|
@@ -344,9 +744,9 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
344
744
|
}
|
|
345
745
|
}
|
|
346
746
|
}
|
|
347
|
-
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(
|
|
747
|
+
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(6, visibleSize) }
|
|
348
748
|
}
|
|
349
|
-
return { toVisibleIndex: 0, visibleSize:
|
|
749
|
+
return { toVisibleIndex: 0, visibleSize: 6 }
|
|
350
750
|
}
|
|
351
751
|
|
|
352
752
|
function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
@@ -485,18 +885,24 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
485
885
|
const reactData = $xeTable as unknown as TableReactData
|
|
486
886
|
const internalData = $xeTable as unknown as TableInternalData
|
|
487
887
|
|
|
488
|
-
const
|
|
489
|
-
const
|
|
490
|
-
const
|
|
888
|
+
const { elemStore } = internalData
|
|
889
|
+
const scrollbarOpts = $xeTable.computeScrollbarOpts
|
|
890
|
+
const tableBody = $xeTable.$refs.refTableBody
|
|
491
891
|
const bodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
|
|
492
|
-
const headerElem = tableHeader ? (tableHeader as any).$el as HTMLDivElement : null
|
|
493
|
-
const footerElem = tableFooter ? (tableFooter as any).$el as HTMLDivElement : null
|
|
494
892
|
if (!bodyElem) {
|
|
495
893
|
return
|
|
496
894
|
}
|
|
895
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
896
|
+
if (!yHandleEl) {
|
|
897
|
+
return
|
|
898
|
+
}
|
|
899
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
900
|
+
if (!xHandleEl) {
|
|
901
|
+
return
|
|
902
|
+
}
|
|
497
903
|
let tableWidth = 0
|
|
498
904
|
const minCellWidth = 40 // 列宽最少限制 40px
|
|
499
|
-
const bodyWidth = bodyElem.clientWidth
|
|
905
|
+
const bodyWidth = bodyElem.clientWidth
|
|
500
906
|
let remainWidth = bodyWidth
|
|
501
907
|
let meanWidth = remainWidth / 100
|
|
502
908
|
const { fit } = props
|
|
@@ -564,16 +970,16 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
564
970
|
})
|
|
565
971
|
if (fit) {
|
|
566
972
|
/**
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
973
|
+
* 偏移量算法
|
|
974
|
+
* 如果所有列足够放的情况下,从最后动态列开始分配
|
|
975
|
+
*/
|
|
570
976
|
const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList)
|
|
571
977
|
let dynamicSize = dynamicList.length - 1
|
|
572
978
|
if (dynamicSize > 0) {
|
|
573
|
-
let
|
|
574
|
-
if (
|
|
575
|
-
while (
|
|
576
|
-
|
|
979
|
+
let i = bodyWidth - tableWidth
|
|
980
|
+
if (i > 0) {
|
|
981
|
+
while (i > 0 && dynamicSize >= 0) {
|
|
982
|
+
i--
|
|
577
983
|
dynamicList[dynamicSize--].renderWidth++
|
|
578
984
|
}
|
|
579
985
|
tableWidth = bodyWidth
|
|
@@ -581,40 +987,21 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
581
987
|
}
|
|
582
988
|
}
|
|
583
989
|
const tableHeight = bodyElem.offsetHeight
|
|
584
|
-
const overflowY =
|
|
585
|
-
|
|
586
|
-
if (overflowY) {
|
|
587
|
-
scrollbarWidth = Math.max(bodyElem.offsetWidth - bodyElem.clientWidth, 0)
|
|
588
|
-
}
|
|
589
|
-
reactData.scrollbarWidth = scrollbarWidth
|
|
990
|
+
const overflowY = yHandleEl.scrollHeight > yHandleEl.clientHeight
|
|
991
|
+
reactData.scrollbarWidth = overflowY ? Math.max(scrollbarOpts.width || 0, yHandleEl.offsetWidth - yHandleEl.clientWidth) : 0
|
|
590
992
|
reactData.overflowY = overflowY
|
|
591
993
|
internalData.tableWidth = tableWidth
|
|
592
994
|
internalData.tableHeight = tableHeight
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
})
|
|
602
|
-
}
|
|
995
|
+
|
|
996
|
+
const headerTableElem = getRefElem(elemStore['main-header-table'])
|
|
997
|
+
const footerTableElem = getRefElem(elemStore['main-footer-table'])
|
|
998
|
+
const headerHeight = headerTableElem ? headerTableElem.clientHeight : 0
|
|
999
|
+
const overflowX = tableWidth > bodyWidth
|
|
1000
|
+
const footerHeight = footerTableElem ? footerTableElem.clientHeight : 0
|
|
1001
|
+
reactData.scrollbarHeight = overflowX ? Math.max(scrollbarOpts.height || 0, xHandleEl.offsetHeight - xHandleEl.clientHeight) : 0
|
|
603
1002
|
internalData.headerHeight = headerHeight
|
|
604
|
-
let overflowX = false
|
|
605
|
-
let footerHeight = 0
|
|
606
|
-
let scrollbarHeight = 0
|
|
607
|
-
if (footerElem) {
|
|
608
|
-
footerHeight = footerElem.offsetHeight
|
|
609
|
-
overflowX = tableWidth > footerElem.clientWidth
|
|
610
|
-
scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0)
|
|
611
|
-
} else {
|
|
612
|
-
overflowX = tableWidth > bodyWidth
|
|
613
|
-
scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0)
|
|
614
|
-
}
|
|
615
1003
|
internalData.footerHeight = footerHeight
|
|
616
1004
|
reactData.overflowX = overflowX
|
|
617
|
-
reactData.scrollbarHeight = scrollbarHeight
|
|
618
1005
|
updateHeight($xeTable)
|
|
619
1006
|
reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight())
|
|
620
1007
|
if (overflowX) {
|
|
@@ -838,9 +1225,9 @@ function showDropTip ($xeTable: any, evnt: DragEvent | MouseEvent, trEl: HTMLEle
|
|
|
838
1225
|
const cdLineEl = $xeTable.$refs.refDragColLineElem as HTMLElement
|
|
839
1226
|
if (cdLineEl) {
|
|
840
1227
|
if (showLine) {
|
|
841
|
-
const leftContainerElem = $xeTable.$refs.
|
|
1228
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
|
|
842
1229
|
const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
|
|
843
|
-
const rightContainerElem = $xeTable.$refs.
|
|
1230
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
|
|
844
1231
|
const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0
|
|
845
1232
|
const thRect = thEl.getBoundingClientRect()
|
|
846
1233
|
let thWidth = thEl.clientWidth
|
|
@@ -918,11 +1305,14 @@ function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMetho
|
|
|
918
1305
|
const sXOpts = $xeTable.computeSXOpts
|
|
919
1306
|
// 计算 X 逻辑
|
|
920
1307
|
if (scrollXLoad) {
|
|
921
|
-
const { visibleSize: visibleXSize } = handleVirtualXVisible($xeTable)
|
|
922
|
-
const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) :
|
|
1308
|
+
const { toVisibleIndex: toXVisibleIndex, visibleSize: visibleXSize } = handleVirtualXVisible($xeTable)
|
|
1309
|
+
const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : 0)
|
|
1310
|
+
scrollXStore.preloadSize = 4
|
|
923
1311
|
scrollXStore.offsetSize = offsetXSize
|
|
924
1312
|
scrollXStore.visibleSize = visibleXSize
|
|
925
1313
|
scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex)
|
|
1314
|
+
scrollXStore.visibleStartIndex = Math.max(scrollXStore.startIndex, toXVisibleIndex)
|
|
1315
|
+
scrollXStore.visibleEndIndex = Math.min(scrollXStore.endIndex, toXVisibleIndex + visibleXSize)
|
|
926
1316
|
$xeTable.updateScrollXData().then(() => {
|
|
927
1317
|
loadScrollXData($xeTable)
|
|
928
1318
|
})
|
|
@@ -932,14 +1322,17 @@ function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMetho
|
|
|
932
1322
|
calcCellHeight($xeTable)
|
|
933
1323
|
// 计算 Y 逻辑
|
|
934
1324
|
const rowHeight = computeRowHeight($xeTable)
|
|
935
|
-
scrollYStore.rowHeight = rowHeight
|
|
1325
|
+
;(scrollYStore as any).rowHeight = rowHeight
|
|
936
1326
|
reactData.rowHeight = rowHeight
|
|
937
|
-
const { visibleSize: visibleYSize } = handleVirtualYVisible($xeTable)
|
|
1327
|
+
const { toVisibleIndex: toYVisibleIndex, visibleSize: visibleYSize } = handleVirtualYVisible($xeTable)
|
|
938
1328
|
if (scrollYLoad) {
|
|
939
|
-
const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) :
|
|
1329
|
+
const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : 0)
|
|
1330
|
+
scrollYStore.preloadSize = 2
|
|
940
1331
|
scrollYStore.offsetSize = offsetYSize
|
|
941
1332
|
scrollYStore.visibleSize = visibleYSize
|
|
942
1333
|
scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex)
|
|
1334
|
+
scrollYStore.visibleStartIndex = Math.max(scrollYStore.startIndex, toYVisibleIndex)
|
|
1335
|
+
scrollYStore.visibleEndIndex = Math.min(scrollYStore.endIndex, toYVisibleIndex + visibleYSize)
|
|
943
1336
|
$xeTable.updateScrollYData().then(() => {
|
|
944
1337
|
loadScrollYData($xeTable)
|
|
945
1338
|
})
|
|
@@ -947,7 +1340,7 @@ function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMetho
|
|
|
947
1340
|
$xeTable.updateScrollYSpace()
|
|
948
1341
|
}
|
|
949
1342
|
$xeTable.$nextTick(() => {
|
|
950
|
-
($xeTable
|
|
1343
|
+
updateStyle($xeTable)
|
|
951
1344
|
})
|
|
952
1345
|
})
|
|
953
1346
|
}
|
|
@@ -973,18 +1366,47 @@ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivat
|
|
|
973
1366
|
})
|
|
974
1367
|
}
|
|
975
1368
|
|
|
1369
|
+
function handleTableColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1370
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1371
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1372
|
+
|
|
1373
|
+
const { scrollXLoad } = reactData
|
|
1374
|
+
const { visibleColumn, scrollXStore, fullColumnIdData } = internalData
|
|
1375
|
+
const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0)
|
|
1376
|
+
tableColumn.forEach((column, $index) => {
|
|
1377
|
+
const colid = column.id
|
|
1378
|
+
const colRest = fullColumnIdData[colid]
|
|
1379
|
+
if (colRest) {
|
|
1380
|
+
colRest.$index = $index
|
|
1381
|
+
}
|
|
1382
|
+
})
|
|
1383
|
+
reactData.tableColumn = tableColumn
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
function handleUpdateColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1387
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1388
|
+
|
|
1389
|
+
const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber')
|
|
1390
|
+
internalData.collectColumn = columnList
|
|
1391
|
+
const tableFullColumn = getColumnList(columnList)
|
|
1392
|
+
internalData.tableFullColumn = tableFullColumn
|
|
1393
|
+
cacheColumnMap($xeTable)
|
|
1394
|
+
}
|
|
1395
|
+
|
|
976
1396
|
function loadScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
977
1397
|
const reactData = $xeTable as unknown as TableReactData
|
|
978
1398
|
const internalData = $xeTable as unknown as TableInternalData
|
|
979
1399
|
|
|
980
1400
|
const { mergeList, mergeFooterList } = reactData
|
|
981
1401
|
const { scrollXStore } = internalData
|
|
982
|
-
const { startIndex, endIndex, offsetSize } = scrollXStore
|
|
1402
|
+
const { preloadSize, startIndex, endIndex, offsetSize } = scrollXStore
|
|
983
1403
|
const { toVisibleIndex, visibleSize } = handleVirtualXVisible($xeTable)
|
|
984
1404
|
const offsetItem = {
|
|
985
|
-
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
|
|
986
|
-
endIndex: toVisibleIndex + visibleSize + offsetSize
|
|
1405
|
+
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
|
|
1406
|
+
endIndex: toVisibleIndex + visibleSize + offsetSize + preloadSize
|
|
987
1407
|
}
|
|
1408
|
+
scrollXStore.visibleStartIndex = toVisibleIndex
|
|
1409
|
+
scrollXStore.visibleEndIndex = toVisibleIndex + visibleSize
|
|
988
1410
|
calculateMergerOffsetIndex(mergeList.concat(mergeFooterList), offsetItem, 'col')
|
|
989
1411
|
const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem
|
|
990
1412
|
if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
|
|
@@ -993,8 +1415,201 @@ function loadScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
993
1415
|
scrollXStore.endIndex = offsetEndIndex
|
|
994
1416
|
$xeTable.updateScrollXData()
|
|
995
1417
|
}
|
|
996
|
-
}
|
|
997
|
-
$xeTable.closeTooltip()
|
|
1418
|
+
}
|
|
1419
|
+
$xeTable.closeTooltip()
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// 获取所有的列,排除分组
|
|
1423
|
+
function getColumnList (columns: any[]) {
|
|
1424
|
+
const result: any[] = []
|
|
1425
|
+
columns.forEach((column) => {
|
|
1426
|
+
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
|
|
1427
|
+
})
|
|
1428
|
+
return result
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, isReset: boolean) {
|
|
1432
|
+
const props = $xeTable
|
|
1433
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1434
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1435
|
+
|
|
1436
|
+
const { showOverflow } = props
|
|
1437
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
1438
|
+
const leftList: VxeTableDefines.ColumnInfo[] = []
|
|
1439
|
+
const centerList: VxeTableDefines.ColumnInfo[] = []
|
|
1440
|
+
const rightList: VxeTableDefines.ColumnInfo[] = []
|
|
1441
|
+
const { isGroup, columnStore } = reactData
|
|
1442
|
+
const sXOpts = $xeTable.computeSXOpts
|
|
1443
|
+
const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData
|
|
1444
|
+
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
1445
|
+
if (isGroup) {
|
|
1446
|
+
const leftGroupList: VxeTableDefines.ColumnInfo[] = []
|
|
1447
|
+
const centerGroupList: VxeTableDefines.ColumnInfo[] = []
|
|
1448
|
+
const rightGroupList: VxeTableDefines.ColumnInfo[] = []
|
|
1449
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
1450
|
+
const isColGroup = hasChildrenList(column)
|
|
1451
|
+
// 如果是分组,必须按组设置固定列,不允许给子列设置固定
|
|
1452
|
+
if (parentColumn && parentColumn.fixed) {
|
|
1453
|
+
column.fixed = parentColumn.fixed
|
|
1454
|
+
}
|
|
1455
|
+
if (parentColumn && column.fixed !== parentColumn.fixed) {
|
|
1456
|
+
errLog('vxe.error.groupFixed')
|
|
1457
|
+
}
|
|
1458
|
+
if (isColGroup) {
|
|
1459
|
+
column.visible = !!XEUtils.findTree(column.children, (subColumn) => hasChildrenList(subColumn) ? false : subColumn.visible)
|
|
1460
|
+
} else if (column.visible) {
|
|
1461
|
+
if (column.fixed === 'left') {
|
|
1462
|
+
leftList.push(column)
|
|
1463
|
+
} else if (column.fixed === 'right') {
|
|
1464
|
+
rightList.push(column)
|
|
1465
|
+
} else {
|
|
1466
|
+
centerList.push(column)
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
})
|
|
1470
|
+
collectColumn.forEach((column) => {
|
|
1471
|
+
if (column.visible) {
|
|
1472
|
+
if (column.fixed === 'left') {
|
|
1473
|
+
leftGroupList.push(column)
|
|
1474
|
+
} else if (column.fixed === 'right') {
|
|
1475
|
+
rightGroupList.push(column)
|
|
1476
|
+
} else {
|
|
1477
|
+
centerGroupList.push(column)
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
})
|
|
1481
|
+
reactData.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList)
|
|
1482
|
+
} else {
|
|
1483
|
+
// 重新分配列
|
|
1484
|
+
tableFullColumn.forEach((column) => {
|
|
1485
|
+
if (column.visible) {
|
|
1486
|
+
if (column.fixed === 'left') {
|
|
1487
|
+
leftList.push(column)
|
|
1488
|
+
} else if (column.fixed === 'right') {
|
|
1489
|
+
rightList.push(column)
|
|
1490
|
+
} else {
|
|
1491
|
+
centerList.push(column)
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
})
|
|
1495
|
+
}
|
|
1496
|
+
const visibleColumn = leftList.concat(centerList).concat(rightList)
|
|
1497
|
+
// 如果gt为0,则总是启用
|
|
1498
|
+
const scrollXLoad = !!sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt < tableFullColumn.length)
|
|
1499
|
+
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
|
|
1500
|
+
Object.assign(columnStore, { leftList, centerList, rightList })
|
|
1501
|
+
if (scrollXLoad) {
|
|
1502
|
+
if (showOverflow) {
|
|
1503
|
+
if (!rowOpts.height) {
|
|
1504
|
+
const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
|
|
1505
|
+
if (errColumn) {
|
|
1506
|
+
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1511
|
+
// if (props.showHeader && !props.showHeaderOverflow) {
|
|
1512
|
+
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
1513
|
+
// }
|
|
1514
|
+
// if (props.showFooter && !props.showFooterOverflow) {
|
|
1515
|
+
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
1516
|
+
// }
|
|
1517
|
+
if (props.spanMethod) {
|
|
1518
|
+
warnLog('vxe.error.scrollErrProp', ['span-method'])
|
|
1519
|
+
}
|
|
1520
|
+
if (props.footerSpanMethod) {
|
|
1521
|
+
warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
if (isReset) {
|
|
1525
|
+
const { visibleSize } = handleVirtualXVisible($xeTable)
|
|
1526
|
+
scrollXStore.startIndex = 0
|
|
1527
|
+
scrollXStore.endIndex = visibleSize
|
|
1528
|
+
scrollXStore.visibleSize = visibleSize
|
|
1529
|
+
scrollXStore.visibleStartIndex = 0
|
|
1530
|
+
scrollXStore.visibleEndIndex = visibleSize
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
// 如果列被显示/隐藏,则清除合并状态
|
|
1534
|
+
// 如果列被设置为固定,则清除合并状态
|
|
1535
|
+
if (visibleColumn.length !== internalData.visibleColumn.length || !internalData.visibleColumn.every((column, index) => column === visibleColumn[index])) {
|
|
1536
|
+
$xeTable.clearMergeCells()
|
|
1537
|
+
$xeTable.clearMergeFooterItems()
|
|
1538
|
+
}
|
|
1539
|
+
reactData.scrollXLoad = scrollXLoad
|
|
1540
|
+
visibleColumn.forEach((column, index) => {
|
|
1541
|
+
const colid = column.id
|
|
1542
|
+
const colRest = fullColumnIdData[colid]
|
|
1543
|
+
if (colRest) {
|
|
1544
|
+
colRest._index = index
|
|
1545
|
+
}
|
|
1546
|
+
})
|
|
1547
|
+
internalData.visibleColumn = visibleColumn
|
|
1548
|
+
handleTableColumn($xeTable)
|
|
1549
|
+
if (isReset) {
|
|
1550
|
+
return $xeTable.updateFooter().then(() => {
|
|
1551
|
+
return $xeTable.recalculate()
|
|
1552
|
+
}).then(() => {
|
|
1553
|
+
$xeTable.updateCellAreas()
|
|
1554
|
+
return $xeTable.recalculate()
|
|
1555
|
+
})
|
|
1556
|
+
}
|
|
1557
|
+
return $xeTable.updateFooter()
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
function initColumnSort ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1561
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1562
|
+
|
|
1563
|
+
const { collectColumn } = internalData
|
|
1564
|
+
collectColumn.forEach((column, index) => {
|
|
1565
|
+
const sortIndex = index + 1
|
|
1566
|
+
column.sortNumber = sortIndex
|
|
1567
|
+
column.renderSortNumber = sortIndex
|
|
1568
|
+
})
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, collectColumn: VxeTableDefines.ColumnInfo[]) {
|
|
1572
|
+
const $xeToolbar = $xeTable.$refs.$xeToolbar as VxeToolbarConstructor
|
|
1573
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1574
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1575
|
+
|
|
1576
|
+
internalData.collectColumn = collectColumn
|
|
1577
|
+
const tableFullColumn = getColumnList(collectColumn)
|
|
1578
|
+
internalData.tableFullColumn = tableFullColumn
|
|
1579
|
+
reactData.isLoading = true
|
|
1580
|
+
reactData.isDragColMove = false
|
|
1581
|
+
initColumnSort($xeTable)
|
|
1582
|
+
return Promise.resolve(
|
|
1583
|
+
restoreCustomStorage($xeTable)
|
|
1584
|
+
).then(() => {
|
|
1585
|
+
reactData.isLoading = false
|
|
1586
|
+
cacheColumnMap($xeTable)
|
|
1587
|
+
parseColumns($xeTable, true).then(() => {
|
|
1588
|
+
if (reactData.scrollXLoad) {
|
|
1589
|
+
loadScrollXData($xeTable)
|
|
1590
|
+
}
|
|
1591
|
+
})
|
|
1592
|
+
$xeTable.clearMergeCells()
|
|
1593
|
+
$xeTable.clearMergeFooterItems()
|
|
1594
|
+
$xeTable.handleTableData(true)
|
|
1595
|
+
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1596
|
+
if ((reactData.scrollXLoad || reactData.scrollYLoad) && reactData.expandColumn) {
|
|
1597
|
+
warnLog('vxe.error.scrollErrProp', ['column.type=expand'])
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
return $xeTable.$nextTick().then(() => {
|
|
1601
|
+
if ($xeToolbar) {
|
|
1602
|
+
$xeToolbar.syncUpdate({
|
|
1603
|
+
collectColumn: internalData.collectColumn,
|
|
1604
|
+
$table: $xeTable
|
|
1605
|
+
})
|
|
1606
|
+
}
|
|
1607
|
+
if ($xeTable.handleUpdateCustomColumn) {
|
|
1608
|
+
$xeTable.handleUpdateCustomColumn()
|
|
1609
|
+
}
|
|
1610
|
+
return $xeTable.recalculate()
|
|
1611
|
+
})
|
|
1612
|
+
})
|
|
998
1613
|
}
|
|
999
1614
|
|
|
1000
1615
|
/**
|
|
@@ -1007,14 +1622,16 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
1007
1622
|
|
|
1008
1623
|
const { showOverflow } = props
|
|
1009
1624
|
const { mergeList } = reactData
|
|
1010
|
-
const {
|
|
1011
|
-
const { startIndex, endIndex, offsetSize } = scrollYStore
|
|
1012
|
-
const autoOffsetYSize = showOverflow ? offsetSize : offsetSize +
|
|
1625
|
+
const { scrollYStore } = internalData
|
|
1626
|
+
const { preloadSize, startIndex, endIndex, offsetSize } = scrollYStore
|
|
1627
|
+
const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + 1
|
|
1013
1628
|
const { toVisibleIndex, visibleSize } = handleVirtualYVisible($xeTable)
|
|
1014
1629
|
const offsetItem = {
|
|
1015
|
-
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
|
|
1016
|
-
endIndex: toVisibleIndex + visibleSize + autoOffsetYSize
|
|
1630
|
+
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
|
|
1631
|
+
endIndex: toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize
|
|
1017
1632
|
}
|
|
1633
|
+
scrollYStore.visibleStartIndex = toVisibleIndex
|
|
1634
|
+
scrollYStore.visibleEndIndex = toVisibleIndex + visibleSize
|
|
1018
1635
|
calculateMergerOffsetIndex(mergeList, offsetItem, 'row')
|
|
1019
1636
|
const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem
|
|
1020
1637
|
if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
|
|
@@ -1039,16 +1656,20 @@ function checkLastSyncScroll ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
1039
1656
|
internalData.lcsRunTime = Date.now()
|
|
1040
1657
|
internalData.lcsTimeout = undefined
|
|
1041
1658
|
internalData.inVirtualScroll = false
|
|
1659
|
+
internalData.inWheelScroll = false
|
|
1660
|
+
internalData.inHeaderScroll = false
|
|
1042
1661
|
internalData.inBodyScroll = false
|
|
1043
1662
|
internalData.inFooterScroll = false
|
|
1044
|
-
internalData.
|
|
1663
|
+
internalData.scrollRenderType = ''
|
|
1045
1664
|
if (isRollX && scrollXLoad) {
|
|
1046
1665
|
$xeTable.updateScrollXData().then(() => {
|
|
1666
|
+
calcCellHeight($xeTable)
|
|
1047
1667
|
loadScrollXData($xeTable)
|
|
1048
1668
|
})
|
|
1049
1669
|
}
|
|
1050
1670
|
if (isRollY && scrollYLoad) {
|
|
1051
1671
|
$xeTable.updateScrollYData().then(() => {
|
|
1672
|
+
calcCellHeight($xeTable)
|
|
1052
1673
|
loadScrollYData($xeTable)
|
|
1053
1674
|
})
|
|
1054
1675
|
}
|
|
@@ -1323,7 +1944,7 @@ const Methods = {
|
|
|
1323
1944
|
this.updateFooter()
|
|
1324
1945
|
return this.$nextTick().then(() => {
|
|
1325
1946
|
updateHeight($xeTable)
|
|
1326
|
-
|
|
1947
|
+
updateStyle($xeTable)
|
|
1327
1948
|
}).then(() => {
|
|
1328
1949
|
computeScrollLoad($xeTable)
|
|
1329
1950
|
}).then(() => {
|
|
@@ -1333,7 +1954,7 @@ const Methods = {
|
|
|
1333
1954
|
}
|
|
1334
1955
|
this.handleReserveStatus()
|
|
1335
1956
|
this.checkSelectionStatus()
|
|
1336
|
-
return new Promise(resolve => {
|
|
1957
|
+
return new Promise<void>(resolve => {
|
|
1337
1958
|
this.$nextTick()
|
|
1338
1959
|
.then(() => this.recalculate())
|
|
1339
1960
|
.then(() => {
|
|
@@ -1348,9 +1969,17 @@ const Methods = {
|
|
|
1348
1969
|
}
|
|
1349
1970
|
// 是否变更虚拟滚动
|
|
1350
1971
|
if (oldScrollYLoad === sYLoad) {
|
|
1351
|
-
restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
|
|
1972
|
+
restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
|
|
1973
|
+
.then(() => {
|
|
1974
|
+
resolve()
|
|
1975
|
+
})
|
|
1352
1976
|
} else {
|
|
1353
|
-
setTimeout(() =>
|
|
1977
|
+
setTimeout(() => {
|
|
1978
|
+
restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
|
|
1979
|
+
.then(() => {
|
|
1980
|
+
resolve()
|
|
1981
|
+
})
|
|
1982
|
+
})
|
|
1354
1983
|
}
|
|
1355
1984
|
})
|
|
1356
1985
|
})
|
|
@@ -1436,8 +2065,10 @@ const Methods = {
|
|
|
1436
2065
|
* @param {ColumnInfo} columns 列配置
|
|
1437
2066
|
*/
|
|
1438
2067
|
loadColumn (columns: any) {
|
|
2068
|
+
const $xeTable = this
|
|
2069
|
+
|
|
1439
2070
|
const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn(this, column), { children: 'children' })
|
|
1440
|
-
return
|
|
2071
|
+
return handleColumn($xeTable, collectColumn)
|
|
1441
2072
|
},
|
|
1442
2073
|
/**
|
|
1443
2074
|
* 加载列配置并恢复到初始状态
|
|
@@ -1449,54 +2080,10 @@ const Methods = {
|
|
|
1449
2080
|
return this.loadColumn(columns)
|
|
1450
2081
|
})
|
|
1451
2082
|
},
|
|
1452
|
-
|
|
1453
|
-
const { collectColumn } = this
|
|
1454
|
-
collectColumn.forEach((column: any, index: any) => {
|
|
1455
|
-
const sortIndex = index + 1
|
|
1456
|
-
column.sortNumber = sortIndex
|
|
1457
|
-
column.renderSortNumber = sortIndex
|
|
1458
|
-
})
|
|
1459
|
-
},
|
|
1460
|
-
handleColumn (collectColumn: any) {
|
|
2083
|
+
handleColumn (collectColumn: any[]) {
|
|
1461
2084
|
const $xeTable = this
|
|
1462
2085
|
|
|
1463
|
-
|
|
1464
|
-
const tableFullColumn = getColumnList(collectColumn)
|
|
1465
|
-
this.tableFullColumn = tableFullColumn
|
|
1466
|
-
this._isLoading = true
|
|
1467
|
-
this.isDragColMove = false
|
|
1468
|
-
this.initColumnSort()
|
|
1469
|
-
return Promise.resolve(
|
|
1470
|
-
this.restoreCustomStorage()
|
|
1471
|
-
).then(() => {
|
|
1472
|
-
this._isLoading = false
|
|
1473
|
-
cacheColumnMap($xeTable)
|
|
1474
|
-
this.parseColumns(true).then(() => {
|
|
1475
|
-
if (this.scrollXLoad) {
|
|
1476
|
-
loadScrollXData($xeTable)
|
|
1477
|
-
}
|
|
1478
|
-
})
|
|
1479
|
-
this.clearMergeCells()
|
|
1480
|
-
this.clearMergeFooterItems()
|
|
1481
|
-
this.handleTableData(true)
|
|
1482
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1483
|
-
if ((this.scrollXLoad || this.scrollYLoad) && this.expandColumn) {
|
|
1484
|
-
warnLog('vxe.error.scrollErrProp', ['column.type=expand'])
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
return this.$nextTick().then(() => {
|
|
1488
|
-
if (this.$toolbar) {
|
|
1489
|
-
this.$toolbar.syncUpdate({
|
|
1490
|
-
collectColumn: this.collectColumn,
|
|
1491
|
-
$table: this
|
|
1492
|
-
})
|
|
1493
|
-
}
|
|
1494
|
-
if ($xeTable.handleUpdateCustomColumn) {
|
|
1495
|
-
$xeTable.handleUpdateCustomColumn()
|
|
1496
|
-
}
|
|
1497
|
-
return this.recalculate()
|
|
1498
|
-
})
|
|
1499
|
-
})
|
|
2086
|
+
return handleColumn($xeTable, collectColumn)
|
|
1500
2087
|
},
|
|
1501
2088
|
/**
|
|
1502
2089
|
* 更新数据行的 Map
|
|
@@ -1955,7 +2542,7 @@ const Methods = {
|
|
|
1955
2542
|
const rowid = getRowid(this, row)
|
|
1956
2543
|
let bodyElem = null
|
|
1957
2544
|
if (column) {
|
|
1958
|
-
bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.
|
|
2545
|
+
bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.refTableBody
|
|
1959
2546
|
}
|
|
1960
2547
|
if (bodyElem && bodyElem.$el) {
|
|
1961
2548
|
return bodyElem.$el.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`)
|
|
@@ -2276,30 +2863,6 @@ const Methods = {
|
|
|
2276
2863
|
this.afterTreeFullData = tableTree
|
|
2277
2864
|
this.updateAfterDataIndex()
|
|
2278
2865
|
},
|
|
2279
|
-
updateTreeDataIndex () {
|
|
2280
|
-
const $xeTable = this
|
|
2281
|
-
const props = $xeTable
|
|
2282
|
-
const internalData = $xeTable
|
|
2283
|
-
|
|
2284
|
-
const { treeConfig } = props
|
|
2285
|
-
const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
2286
|
-
const treeOpts = $xeTable.computeTreeOpts
|
|
2287
|
-
if (treeConfig) {
|
|
2288
|
-
if (treeOpts.transform) {
|
|
2289
|
-
afterFullData.forEach((row: any, index: number) => {
|
|
2290
|
-
const rowid = getRowid($xeTable, row)
|
|
2291
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
2292
|
-
if (rowRest) {
|
|
2293
|
-
rowRest._index = index
|
|
2294
|
-
} else {
|
|
2295
|
-
const rest = { row, rowid, seq: '-1', index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0, oTop: 0 }
|
|
2296
|
-
fullAllDataRowIdData[rowid] = rest
|
|
2297
|
-
fullDataRowIdData[rowid] = rest
|
|
2298
|
-
}
|
|
2299
|
-
})
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
},
|
|
2303
2866
|
/**
|
|
2304
2867
|
* 预编译
|
|
2305
2868
|
* 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
|
|
@@ -2329,7 +2892,6 @@ const Methods = {
|
|
|
2329
2892
|
}
|
|
2330
2893
|
fullMaps[rowid] = row
|
|
2331
2894
|
}, { children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField })
|
|
2332
|
-
$xeTable.updateTreeDataIndex()
|
|
2333
2895
|
} else {
|
|
2334
2896
|
afterFullData.forEach((row: any, index: number) => {
|
|
2335
2897
|
const rowid = getRowid($xeTable, row)
|
|
@@ -2617,8 +3179,8 @@ const Methods = {
|
|
|
2617
3179
|
const colWidth = XEUtils.toInteger(width)
|
|
2618
3180
|
let rdWidth = colWidth
|
|
2619
3181
|
if (isScale(width)) {
|
|
2620
|
-
const
|
|
2621
|
-
const bodyElem =
|
|
3182
|
+
const refTableBody = $xeTable.$refs.refTableBody
|
|
3183
|
+
const bodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
|
|
2622
3184
|
const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0
|
|
2623
3185
|
rdWidth = Math.floor(colWidth * bodyWidth)
|
|
2624
3186
|
}
|
|
@@ -2864,143 +3426,17 @@ const Methods = {
|
|
|
2864
3426
|
* 刷新列配置
|
|
2865
3427
|
*/
|
|
2866
3428
|
refreshColumn (initSort?: boolean) {
|
|
3429
|
+
const $xeTable = this
|
|
3430
|
+
|
|
2867
3431
|
if (initSort) {
|
|
2868
|
-
|
|
3432
|
+
handleUpdateColumn($xeTable)
|
|
2869
3433
|
}
|
|
2870
|
-
return
|
|
3434
|
+
return parseColumns($xeTable, true).then(() => {
|
|
2871
3435
|
return this.refreshScroll()
|
|
2872
3436
|
}).then(() => {
|
|
2873
3437
|
return this.recalculate()
|
|
2874
3438
|
})
|
|
2875
3439
|
},
|
|
2876
|
-
/**
|
|
2877
|
-
* 刷新列信息
|
|
2878
|
-
* 将固定的列左边、右边分别靠边
|
|
2879
|
-
*/
|
|
2880
|
-
parseColumns (isReset: boolean) {
|
|
2881
|
-
const $xeTable = this
|
|
2882
|
-
const props = $xeTable
|
|
2883
|
-
const internalData = $xeTable
|
|
2884
|
-
|
|
2885
|
-
const { showOverflow } = props
|
|
2886
|
-
const rowOpts = $xeTable.computeRowOpts
|
|
2887
|
-
const leftList: any[] = []
|
|
2888
|
-
const centerList: any[] = []
|
|
2889
|
-
const rightList: any[] = []
|
|
2890
|
-
const { collectColumn, tableFullColumn, isGroup, columnStore, sXOpts, scrollXStore, fullColumnIdData } = this
|
|
2891
|
-
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
2892
|
-
if (isGroup) {
|
|
2893
|
-
const leftGroupList: any[] = []
|
|
2894
|
-
const centerGroupList: any[] = []
|
|
2895
|
-
const rightGroupList: any[] = []
|
|
2896
|
-
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
2897
|
-
const isColGroup = hasChildrenList(column)
|
|
2898
|
-
// 如果是分组,必须按组设置固定列,不允许给子列设置固定
|
|
2899
|
-
if (parentColumn && parentColumn.fixed) {
|
|
2900
|
-
column.fixed = parentColumn.fixed
|
|
2901
|
-
}
|
|
2902
|
-
if (parentColumn && column.fixed !== parentColumn.fixed) {
|
|
2903
|
-
errLog('vxe.error.groupFixed')
|
|
2904
|
-
}
|
|
2905
|
-
if (isColGroup) {
|
|
2906
|
-
column.visible = !!XEUtils.findTree(column.children, (subColumn: any) => hasChildrenList(subColumn) ? null : subColumn.visible)
|
|
2907
|
-
} else if (column.visible) {
|
|
2908
|
-
if (column.fixed === 'left') {
|
|
2909
|
-
leftList.push(column)
|
|
2910
|
-
} else if (column.fixed === 'right') {
|
|
2911
|
-
rightList.push(column)
|
|
2912
|
-
} else {
|
|
2913
|
-
centerList.push(column)
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
})
|
|
2917
|
-
collectColumn.forEach((column: any) => {
|
|
2918
|
-
if (column.visible) {
|
|
2919
|
-
if (column.fixed === 'left') {
|
|
2920
|
-
leftGroupList.push(column)
|
|
2921
|
-
} else if (column.fixed === 'right') {
|
|
2922
|
-
rightGroupList.push(column)
|
|
2923
|
-
} else {
|
|
2924
|
-
centerGroupList.push(column)
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
})
|
|
2928
|
-
this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList)
|
|
2929
|
-
} else {
|
|
2930
|
-
// 重新分配列
|
|
2931
|
-
tableFullColumn.forEach((column: any) => {
|
|
2932
|
-
if (column.visible) {
|
|
2933
|
-
if (column.fixed === 'left') {
|
|
2934
|
-
leftList.push(column)
|
|
2935
|
-
} else if (column.fixed === 'right') {
|
|
2936
|
-
rightList.push(column)
|
|
2937
|
-
} else {
|
|
2938
|
-
centerList.push(column)
|
|
2939
|
-
}
|
|
2940
|
-
}
|
|
2941
|
-
})
|
|
2942
|
-
}
|
|
2943
|
-
const visibleColumn = leftList.concat(centerList).concat(rightList)
|
|
2944
|
-
// 如果gt为0,则总是启用
|
|
2945
|
-
const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length)
|
|
2946
|
-
this.hasFixedColumn = leftList.length > 0 || rightList.length > 0
|
|
2947
|
-
Object.assign(columnStore, { leftList, centerList, rightList })
|
|
2948
|
-
if (scrollXLoad) {
|
|
2949
|
-
if (showOverflow) {
|
|
2950
|
-
if (!rowOpts.height) {
|
|
2951
|
-
const errColumn = internalData.tableFullColumn.find((column: any) => column.showOverflow === false)
|
|
2952
|
-
if (errColumn) {
|
|
2953
|
-
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
}
|
|
2957
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
2958
|
-
// if (this.showHeader && !this.showHeaderOverflow) {
|
|
2959
|
-
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
2960
|
-
// }
|
|
2961
|
-
// if (this.showFooter && !this.showFooterOverflow) {
|
|
2962
|
-
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
2963
|
-
// }
|
|
2964
|
-
if (this.spanMethod) {
|
|
2965
|
-
warnLog('vxe.error.scrollErrProp', ['span-method'])
|
|
2966
|
-
}
|
|
2967
|
-
if (this.footerSpanMethod) {
|
|
2968
|
-
warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
|
|
2969
|
-
}
|
|
2970
|
-
}
|
|
2971
|
-
if (isReset) {
|
|
2972
|
-
const { visibleSize } = handleVirtualXVisible(this)
|
|
2973
|
-
scrollXStore.startIndex = 0
|
|
2974
|
-
scrollXStore.endIndex = visibleSize
|
|
2975
|
-
scrollXStore.visibleSize = visibleSize
|
|
2976
|
-
}
|
|
2977
|
-
}
|
|
2978
|
-
// 如果列被显示/隐藏,则清除合并状态
|
|
2979
|
-
// 如果列被设置为固定,则清除合并状态
|
|
2980
|
-
if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column: any, index: any) => column === visibleColumn[index])) {
|
|
2981
|
-
this.clearMergeCells()
|
|
2982
|
-
this.clearMergeFooterItems()
|
|
2983
|
-
}
|
|
2984
|
-
this.scrollXLoad = scrollXLoad
|
|
2985
|
-
visibleColumn.forEach((column, index) => {
|
|
2986
|
-
const colid = column.id
|
|
2987
|
-
const colRest = fullColumnIdData[colid]
|
|
2988
|
-
if (colRest) {
|
|
2989
|
-
colRest._index = index
|
|
2990
|
-
}
|
|
2991
|
-
})
|
|
2992
|
-
this.visibleColumn = visibleColumn
|
|
2993
|
-
this.handleTableColumn()
|
|
2994
|
-
if (isReset) {
|
|
2995
|
-
return this.updateFooter().then(() => {
|
|
2996
|
-
return this.recalculate()
|
|
2997
|
-
}).then(() => {
|
|
2998
|
-
this.updateCellAreas()
|
|
2999
|
-
return this.recalculate()
|
|
3000
|
-
})
|
|
3001
|
-
}
|
|
3002
|
-
return this.updateFooter()
|
|
3003
|
-
},
|
|
3004
3440
|
/**
|
|
3005
3441
|
* 指定列宽的列进行拆分
|
|
3006
3442
|
*/
|
|
@@ -3081,408 +3517,112 @@ const Methods = {
|
|
|
3081
3517
|
* 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
|
|
3082
3518
|
*/
|
|
3083
3519
|
refreshScroll () {
|
|
3084
|
-
const
|
|
3085
|
-
const
|
|
3086
|
-
|
|
3087
|
-
const
|
|
3088
|
-
const
|
|
3089
|
-
const
|
|
3090
|
-
const
|
|
3091
|
-
|
|
3520
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3521
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3522
|
+
|
|
3523
|
+
const { elemStore, lastScrollLeft, lastScrollTop } = internalData
|
|
3524
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
|
|
3525
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
3526
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
|
|
3527
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
|
|
3528
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
|
|
3529
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
3530
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
3531
|
+
return new Promise<void>(resolve => {
|
|
3092
3532
|
// 还原滚动条位置
|
|
3093
3533
|
if (lastScrollLeft || lastScrollTop) {
|
|
3094
|
-
return restoreScrollLocation(
|
|
3534
|
+
return restoreScrollLocation($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
|
|
3095
3535
|
// 存在滚动行为未结束情况
|
|
3096
|
-
setTimeout(resolve,
|
|
3097
|
-
})
|
|
3098
|
-
}
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
setScrollTop(
|
|
3102
|
-
setScrollTop(
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
handleRecalculateLayout($xeTable, !!reFull)
|
|
3143
|
-
}, refreshDelay)
|
|
3144
|
-
})
|
|
3145
|
-
},
|
|
3146
|
-
updateStyle () {
|
|
3147
|
-
const $xeTable = this
|
|
3148
|
-
|
|
3149
|
-
let {
|
|
3150
|
-
$refs,
|
|
3151
|
-
isGroup,
|
|
3152
|
-
fullColumnIdData,
|
|
3153
|
-
tableColumn,
|
|
3154
|
-
customHeight,
|
|
3155
|
-
customMinHeight,
|
|
3156
|
-
customMaxHeight,
|
|
3157
|
-
border,
|
|
3158
|
-
headerHeight,
|
|
3159
|
-
showFooter,
|
|
3160
|
-
showOverflow: allColumnOverflow,
|
|
3161
|
-
showHeaderOverflow: allColumnHeaderOverflow,
|
|
3162
|
-
showFooterOverflow: allColumnFooterOverflow,
|
|
3163
|
-
footerHeight,
|
|
3164
|
-
tableHeight,
|
|
3165
|
-
tableWidth,
|
|
3166
|
-
scrollbarHeight,
|
|
3167
|
-
scrollbarWidth,
|
|
3168
|
-
scrollXLoad,
|
|
3169
|
-
scrollYLoad,
|
|
3170
|
-
overflowX,
|
|
3171
|
-
cellOffsetWidth,
|
|
3172
|
-
columnStore,
|
|
3173
|
-
elemStore,
|
|
3174
|
-
editStore,
|
|
3175
|
-
currentRow,
|
|
3176
|
-
mouseConfig,
|
|
3177
|
-
spanMethod,
|
|
3178
|
-
expandColumn,
|
|
3179
|
-
footerSpanMethod,
|
|
3180
|
-
isAllOverflow,
|
|
3181
|
-
visibleColumn
|
|
3182
|
-
} = $xeTable
|
|
3183
|
-
const containerList = ['main', 'left', 'right']
|
|
3184
|
-
const emptyPlaceholderElem = $refs.emptyPlaceholder
|
|
3185
|
-
const bodyWrapperElem = elemStore['main-body-wrapper']
|
|
3186
|
-
if (emptyPlaceholderElem) {
|
|
3187
|
-
emptyPlaceholderElem.style.top = `${headerHeight}px`
|
|
3188
|
-
emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : ''
|
|
3189
|
-
}
|
|
3190
|
-
if (customHeight > 0) {
|
|
3191
|
-
if (showFooter) {
|
|
3192
|
-
customHeight += scrollbarHeight
|
|
3193
|
-
}
|
|
3194
|
-
}
|
|
3195
|
-
|
|
3196
|
-
const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem
|
|
3197
|
-
if (scrollXVirtualEl) {
|
|
3198
|
-
scrollXVirtualEl.style.height = `${scrollbarHeight}px`
|
|
3199
|
-
}
|
|
3200
|
-
|
|
3201
|
-
const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem
|
|
3202
|
-
if (scrollYVirtualEl) {
|
|
3203
|
-
let bodyHeight = 0
|
|
3204
|
-
let bodyMaxHeight = 0
|
|
3205
|
-
const bodyMinHeight = customMinHeight - headerHeight - footerHeight
|
|
3206
|
-
if (customMaxHeight) {
|
|
3207
|
-
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight
|
|
3208
|
-
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight)
|
|
3209
|
-
}
|
|
3210
|
-
if (customHeight) {
|
|
3211
|
-
bodyHeight = customHeight - headerHeight - footerHeight
|
|
3212
|
-
if (bodyMaxHeight) {
|
|
3213
|
-
bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
|
|
3214
|
-
}
|
|
3215
|
-
bodyHeight = Math.max(bodyMinHeight, bodyHeight)
|
|
3216
|
-
}
|
|
3217
|
-
scrollYVirtualEl.style.top = `${headerHeight}px`
|
|
3218
|
-
scrollYVirtualEl.style.width = `${scrollbarWidth}px`
|
|
3219
|
-
scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`
|
|
3220
|
-
}
|
|
3221
|
-
|
|
3222
|
-
containerList.forEach((name, index) => {
|
|
3223
|
-
const fixedType = index > 0 ? name : ''
|
|
3224
|
-
const layoutList = ['header', 'body', 'footer']
|
|
3225
|
-
const fixedColumn = columnStore[`${fixedType}List`]
|
|
3226
|
-
const fixedWrapperElem = $refs[`${fixedType}Container`]
|
|
3227
|
-
layoutList.forEach(layout => {
|
|
3228
|
-
const wrapperElem = elemStore[`${name}-${layout}-wrapper`]
|
|
3229
|
-
const tableElem = elemStore[`${name}-${layout}-table`]
|
|
3230
|
-
if (layout === 'header') {
|
|
3231
|
-
// 表头体样式处理
|
|
3232
|
-
// 横向滚动渲染
|
|
3233
|
-
let tWidth = tableWidth
|
|
3234
|
-
let renderColumnList = tableColumn
|
|
3235
|
-
|
|
3236
|
-
if (isGroup) {
|
|
3237
|
-
renderColumnList = visibleColumn
|
|
3238
|
-
} else {
|
|
3239
|
-
if (fixedType) {
|
|
3240
|
-
// 如果是使用优化模式
|
|
3241
|
-
if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
|
|
3242
|
-
// 如果不支持优化模式
|
|
3243
|
-
if (spanMethod || footerSpanMethod) {
|
|
3244
|
-
renderColumnList = visibleColumn
|
|
3245
|
-
} else {
|
|
3246
|
-
renderColumnList = fixedColumn || []
|
|
3247
|
-
}
|
|
3248
|
-
} else {
|
|
3249
|
-
renderColumnList = visibleColumn
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
|
|
3254
|
-
tWidth = renderColumnList.reduce((previous: any, column: any) => previous + column.renderWidth, 0)
|
|
3255
|
-
|
|
3256
|
-
if (tableElem) {
|
|
3257
|
-
tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : ''
|
|
3258
|
-
// 修复 IE 中高度无法自适应问题
|
|
3259
|
-
if (browse.msie) {
|
|
3260
|
-
XEUtils.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), (resizeElem: any) => {
|
|
3261
|
-
resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`
|
|
3262
|
-
})
|
|
3263
|
-
}
|
|
3264
|
-
}
|
|
3265
|
-
|
|
3266
|
-
const repairElem = elemStore[`${name}-${layout}-repair`]
|
|
3267
|
-
if (repairElem) {
|
|
3268
|
-
repairElem.style.width = `${tableWidth}px`
|
|
3269
|
-
}
|
|
3270
|
-
|
|
3271
|
-
const listElem = elemStore[`${name}-${layout}-list`]
|
|
3272
|
-
if (isGroup && listElem) {
|
|
3273
|
-
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem: HTMLTableRowElement) => {
|
|
3274
|
-
const colNode = this.getColumnNode(thElem)
|
|
3275
|
-
if (colNode) {
|
|
3276
|
-
const column = colNode.item
|
|
3277
|
-
const { showHeaderOverflow } = column
|
|
3278
|
-
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow
|
|
3279
|
-
const showEllipsis = cellOverflow === 'ellipsis'
|
|
3280
|
-
const showTitle = cellOverflow === 'title'
|
|
3281
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
3282
|
-
const hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
3283
|
-
let childWidth = 0
|
|
3284
|
-
let countChild = 0
|
|
3285
|
-
if (hasEllipsis) {
|
|
3286
|
-
XEUtils.eachTree(column.children, item => {
|
|
3287
|
-
if (!item.children || !column.children.length) {
|
|
3288
|
-
countChild++
|
|
3289
|
-
}
|
|
3290
|
-
childWidth += item.renderWidth
|
|
3291
|
-
})
|
|
3292
|
-
}
|
|
3293
|
-
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : ''
|
|
3294
|
-
}
|
|
3295
|
-
})
|
|
3296
|
-
}
|
|
3297
|
-
} else if (layout === 'body') {
|
|
3298
|
-
const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`]
|
|
3299
|
-
if (isNodeElement(wrapperElem)) {
|
|
3300
|
-
let bodyMaxHeight = 0
|
|
3301
|
-
const bodyMinHeight = customMinHeight - headerHeight - footerHeight
|
|
3302
|
-
if (customMaxHeight) {
|
|
3303
|
-
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight
|
|
3304
|
-
// 如果是固定列
|
|
3305
|
-
if (fixedType) {
|
|
3306
|
-
bodyMaxHeight -= (showFooter ? 0 : scrollbarHeight)
|
|
3307
|
-
}
|
|
3308
|
-
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight)
|
|
3309
|
-
wrapperElem.style.maxHeight = `${bodyMaxHeight}px`
|
|
3310
|
-
}
|
|
3311
|
-
if (customHeight) {
|
|
3312
|
-
let bodyHeight = customHeight - headerHeight - footerHeight
|
|
3313
|
-
// 如果是固定列
|
|
3314
|
-
if (fixedType) {
|
|
3315
|
-
bodyHeight -= (showFooter ? 0 : scrollbarHeight)
|
|
3316
|
-
}
|
|
3317
|
-
if (bodyMaxHeight) {
|
|
3318
|
-
bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
|
|
3319
|
-
}
|
|
3320
|
-
wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`
|
|
3321
|
-
} else {
|
|
3322
|
-
wrapperElem.style.height = ''
|
|
3323
|
-
}
|
|
3324
|
-
wrapperElem.style.minHeight = `${bodyMinHeight}px`
|
|
3325
|
-
}
|
|
3326
|
-
|
|
3327
|
-
// 如果是固定列
|
|
3328
|
-
if (fixedWrapperElem) {
|
|
3329
|
-
const isRightFixed = fixedType === 'right'
|
|
3330
|
-
const fixedColumn = columnStore[`${fixedType}List`]
|
|
3331
|
-
if (isNodeElement(wrapperElem)) {
|
|
3332
|
-
wrapperElem.style.top = `${headerHeight}px`
|
|
3333
|
-
}
|
|
3334
|
-
fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`
|
|
3335
|
-
fixedWrapperElem.style.width = `${fixedColumn.reduce((previous: any, column: any) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`
|
|
3336
|
-
}
|
|
3337
|
-
|
|
3338
|
-
let tWidth = tableWidth
|
|
3339
|
-
let renderColumnList = tableColumn
|
|
3340
|
-
|
|
3341
|
-
if (fixedType) {
|
|
3342
|
-
// 如果是使用优化模式
|
|
3343
|
-
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
3344
|
-
// 如果不支持优化模式
|
|
3345
|
-
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
3346
|
-
renderColumnList = visibleColumn
|
|
3347
|
-
} else {
|
|
3348
|
-
renderColumnList = fixedColumn || []
|
|
3349
|
-
}
|
|
3350
|
-
} else {
|
|
3351
|
-
renderColumnList = visibleColumn
|
|
3352
|
-
}
|
|
3353
|
-
}
|
|
3354
|
-
|
|
3355
|
-
tWidth = renderColumnList.reduce((previous: any, column: any) => previous + column.renderWidth, 0)
|
|
3356
|
-
|
|
3357
|
-
if (tableElem) {
|
|
3358
|
-
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
3359
|
-
// 兼容性处理
|
|
3360
|
-
tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : ''
|
|
3361
|
-
}
|
|
3362
|
-
if (emptyBlockElem) {
|
|
3363
|
-
emptyBlockElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
3364
|
-
}
|
|
3365
|
-
} else if (layout === 'footer') {
|
|
3366
|
-
let tWidth = tableWidth
|
|
3367
|
-
let renderColumnList = tableColumn
|
|
3368
|
-
|
|
3369
|
-
if (fixedType) {
|
|
3370
|
-
// 如果是使用优化模式
|
|
3371
|
-
if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
|
|
3372
|
-
// 如果不支持优化模式
|
|
3373
|
-
if (spanMethod || footerSpanMethod) {
|
|
3374
|
-
renderColumnList = visibleColumn
|
|
3375
|
-
} else {
|
|
3376
|
-
renderColumnList = fixedColumn || []
|
|
3377
|
-
}
|
|
3378
|
-
} else {
|
|
3379
|
-
renderColumnList = visibleColumn
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
-
tWidth = renderColumnList.reduce((previous: any, column: any) => previous + column.renderWidth, 0)
|
|
3384
|
-
|
|
3385
|
-
if (isNodeElement(wrapperElem)) {
|
|
3386
|
-
// 如果是固定列
|
|
3387
|
-
if (fixedWrapperElem) {
|
|
3388
|
-
wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`
|
|
3389
|
-
}
|
|
3390
|
-
wrapperElem.style.marginTop = `${-scrollbarHeight}px`
|
|
3391
|
-
}
|
|
3392
|
-
if (tableElem) {
|
|
3393
|
-
tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : ''
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
const colgroupElem = elemStore[`${name}-${layout}-colgroup`]
|
|
3397
|
-
if (colgroupElem) {
|
|
3398
|
-
XEUtils.arrayEach(colgroupElem.children, (colElem: any) => {
|
|
3399
|
-
const colid = colElem.getAttribute('name')
|
|
3400
|
-
if (colid === 'col_gutter') {
|
|
3401
|
-
colElem.style.width = `${scrollbarWidth}px`
|
|
3402
|
-
}
|
|
3403
|
-
if (fullColumnIdData[colid]) {
|
|
3404
|
-
const colRest = fullColumnIdData[colid]
|
|
3405
|
-
const column = colRest.column
|
|
3406
|
-
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column
|
|
3407
|
-
let cellOverflow
|
|
3408
|
-
colElem.style.width = `${column.renderWidth}px`
|
|
3409
|
-
if (layout === 'header') {
|
|
3410
|
-
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
|
|
3411
|
-
} else if (layout === 'footer') {
|
|
3412
|
-
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
|
|
3413
|
-
} else {
|
|
3414
|
-
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow
|
|
3415
|
-
}
|
|
3416
|
-
const showEllipsis = cellOverflow === 'ellipsis'
|
|
3417
|
-
const showTitle = cellOverflow === 'title'
|
|
3418
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
3419
|
-
let hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
3420
|
-
const listElem = elemStore[`${name}-${layout}-list`]
|
|
3421
|
-
// 滚动的渲染不支持动态行高
|
|
3422
|
-
if (layout === 'header' || layout === 'footer') {
|
|
3423
|
-
if (scrollXLoad && !hasEllipsis) {
|
|
3424
|
-
hasEllipsis = true
|
|
3425
|
-
}
|
|
3426
|
-
} else {
|
|
3427
|
-
if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
|
|
3428
|
-
hasEllipsis = true
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
if (listElem) {
|
|
3432
|
-
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem: any) => {
|
|
3433
|
-
const colspan = parseInt(elem.getAttribute('colspan') || 1)
|
|
3434
|
-
const cellElem = elem.querySelector('.vxe-cell')
|
|
3435
|
-
let colWidth = column.renderWidth
|
|
3436
|
-
if (cellElem) {
|
|
3437
|
-
if (colspan > 1) {
|
|
3438
|
-
const columnIndex = this.getColumnIndex(column)
|
|
3439
|
-
for (let index = 1; index < colspan; index++) {
|
|
3440
|
-
const nextColumn = this.getColumns(columnIndex + index)
|
|
3441
|
-
if (nextColumn) {
|
|
3442
|
-
colWidth += nextColumn.renderWidth
|
|
3443
|
-
}
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : ''
|
|
3447
|
-
}
|
|
3448
|
-
})
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3536
|
+
setTimeout(resolve, 10)
|
|
3537
|
+
})
|
|
3538
|
+
}
|
|
3539
|
+
internalData.intoRunScroll = true
|
|
3540
|
+
// 重置
|
|
3541
|
+
setScrollTop(yHandleEl, lastScrollTop)
|
|
3542
|
+
setScrollTop(bodyScrollElem, lastScrollTop)
|
|
3543
|
+
setScrollTop(leftScrollElem, lastScrollTop)
|
|
3544
|
+
setScrollTop(rightScrollElem, lastScrollTop)
|
|
3545
|
+
|
|
3546
|
+
setScrollLeft(xHandleEl, lastScrollLeft)
|
|
3547
|
+
setScrollLeft(bodyScrollElem, lastScrollLeft)
|
|
3548
|
+
setScrollLeft(headerScrollElem, lastScrollLeft)
|
|
3549
|
+
setScrollLeft(footerScrollElem, lastScrollLeft)
|
|
3550
|
+
// 存在滚动行为未结束情况
|
|
3551
|
+
setTimeout(() => {
|
|
3552
|
+
internalData.intoRunScroll = false
|
|
3553
|
+
resolve()
|
|
3554
|
+
}, 10)
|
|
3555
|
+
})
|
|
3556
|
+
},
|
|
3557
|
+
/**
|
|
3558
|
+
* 重新渲染布局
|
|
3559
|
+
* 刷新布局
|
|
3560
|
+
*/
|
|
3561
|
+
recalculate (reFull?: boolean) {
|
|
3562
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3563
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3564
|
+
|
|
3565
|
+
return new Promise<void>(resolve => {
|
|
3566
|
+
const { rceTimeout, rceRunTime } = internalData
|
|
3567
|
+
const resizeOpts = $xeTable.computeResizeOpts
|
|
3568
|
+
const refreshDelay = resizeOpts.refreshDelay || 20
|
|
3569
|
+
const el = $xeTable.$refs.refElem as HTMLElement
|
|
3570
|
+
if (el && el.clientWidth) {
|
|
3571
|
+
autoCellWidth($xeTable)
|
|
3572
|
+
}
|
|
3573
|
+
if (rceTimeout) {
|
|
3574
|
+
clearTimeout(rceTimeout)
|
|
3575
|
+
if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
|
|
3576
|
+
resolve(
|
|
3577
|
+
handleRecalculateLayout($xeTable, !!reFull)
|
|
3578
|
+
)
|
|
3579
|
+
} else {
|
|
3580
|
+
$xeTable.$nextTick(() => {
|
|
3581
|
+
resolve()
|
|
3451
3582
|
})
|
|
3452
3583
|
}
|
|
3453
|
-
}
|
|
3584
|
+
} else {
|
|
3585
|
+
resolve(
|
|
3586
|
+
handleRecalculateLayout($xeTable, !!reFull)
|
|
3587
|
+
)
|
|
3588
|
+
}
|
|
3589
|
+
internalData.rceTimeout = setTimeout(() => {
|
|
3590
|
+
internalData.rceTimeout = undefined
|
|
3591
|
+
handleRecalculateLayout($xeTable, !!reFull)
|
|
3592
|
+
}, refreshDelay)
|
|
3454
3593
|
})
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
}
|
|
3461
|
-
return this.$nextTick()
|
|
3594
|
+
},
|
|
3595
|
+
updateStyle () {
|
|
3596
|
+
const $xeTable = this
|
|
3597
|
+
|
|
3598
|
+
return updateStyle($xeTable)
|
|
3462
3599
|
},
|
|
3463
3600
|
/**
|
|
3464
3601
|
* 处理固定列的显示状态
|
|
3465
3602
|
*/
|
|
3466
3603
|
checkScrolling () {
|
|
3467
|
-
const $xeTable = this
|
|
3604
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3605
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3468
3606
|
|
|
3469
|
-
const {
|
|
3470
|
-
const
|
|
3607
|
+
const { elemStore } = internalData
|
|
3608
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
3609
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
|
|
3610
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
|
|
3471
3611
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
3472
|
-
const bodtTargetEl = xHandleEl ||
|
|
3612
|
+
const bodtTargetEl = xHandleEl || bodyScrollElem
|
|
3473
3613
|
if (bodtTargetEl) {
|
|
3474
|
-
if (
|
|
3614
|
+
if (leftContainerElem) {
|
|
3475
3615
|
if (bodtTargetEl.scrollLeft > 0) {
|
|
3476
|
-
addClass(
|
|
3616
|
+
addClass(leftContainerElem, 'scrolling--middle')
|
|
3477
3617
|
} else {
|
|
3478
|
-
removeClass(
|
|
3618
|
+
removeClass(leftContainerElem, 'scrolling--middle')
|
|
3479
3619
|
}
|
|
3480
3620
|
}
|
|
3481
|
-
if (
|
|
3621
|
+
if (rightContainerElem) {
|
|
3482
3622
|
if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
|
|
3483
|
-
addClass(
|
|
3623
|
+
addClass(rightContainerElem, 'scrolling--middle')
|
|
3484
3624
|
} else {
|
|
3485
|
-
removeClass(
|
|
3625
|
+
removeClass(rightContainerElem, 'scrolling--middle')
|
|
3486
3626
|
}
|
|
3487
3627
|
}
|
|
3488
3628
|
}
|
|
@@ -3518,7 +3658,7 @@ const Methods = {
|
|
|
3518
3658
|
handleGlobalMousedownEvent (evnt: any) {
|
|
3519
3659
|
const { $el, $refs, $xegrid, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this
|
|
3520
3660
|
const { actived } = editStore
|
|
3521
|
-
const {
|
|
3661
|
+
const { refTableMenu, filterWrapper, customWrapper, refValidTooltip } = $refs
|
|
3522
3662
|
// 筛选
|
|
3523
3663
|
if (filterWrapper) {
|
|
3524
3664
|
if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {
|
|
@@ -3550,7 +3690,7 @@ const Methods = {
|
|
|
3550
3690
|
// 如果是激活状态,点击了单元格之外
|
|
3551
3691
|
const cell = actived.args.cell
|
|
3552
3692
|
if ((!cell || !getEventTargetNode(evnt, cell).flag)) {
|
|
3553
|
-
if (
|
|
3693
|
+
if (refValidTooltip && getEventTargetNode(evnt, refValidTooltip.$el).flag) {
|
|
3554
3694
|
// 如果是激活状态,且点击了校验提示框
|
|
3555
3695
|
} else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
|
|
3556
3696
|
if (!getEventTargetNode(evnt, document.body, 'vxe-table--ignore-clear').flag) {
|
|
@@ -3600,7 +3740,7 @@ const Methods = {
|
|
|
3600
3740
|
}
|
|
3601
3741
|
}
|
|
3602
3742
|
} else if (mouseConfig) {
|
|
3603
|
-
if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(
|
|
3743
|
+
if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(refTableMenu && getEventTargetNode(evnt, refTableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
|
|
3604
3744
|
if (this.clearSelected) {
|
|
3605
3745
|
this.clearSelected()
|
|
3606
3746
|
}
|
|
@@ -3619,7 +3759,7 @@ const Methods = {
|
|
|
3619
3759
|
}
|
|
3620
3760
|
}
|
|
3621
3761
|
// 如果配置了快捷菜单且,点击了其他地方则关闭
|
|
3622
|
-
if (ctxMenuStore.visible &&
|
|
3762
|
+
if (ctxMenuStore.visible && refTableMenu && !getEventTargetNode(evnt, refTableMenu.$el).flag) {
|
|
3623
3763
|
this.closeMenu()
|
|
3624
3764
|
}
|
|
3625
3765
|
const isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag
|
|
@@ -3750,8 +3890,8 @@ const Methods = {
|
|
|
3750
3890
|
} else if (isContextMenu) {
|
|
3751
3891
|
// 如果按下上下文键
|
|
3752
3892
|
this._keyCtx = selected.row && selected.column && bodyCtxMenu.length
|
|
3753
|
-
clearTimeout(
|
|
3754
|
-
|
|
3893
|
+
clearTimeout(internalData.keyCtxTimeout)
|
|
3894
|
+
internalData.keyCtxTimeout = setTimeout(() => {
|
|
3755
3895
|
this._keyCtx = false
|
|
3756
3896
|
}, 1000)
|
|
3757
3897
|
} else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
|
|
@@ -4096,6 +4236,11 @@ const Methods = {
|
|
|
4096
4236
|
* @param {Row} row 行对象
|
|
4097
4237
|
*/
|
|
4098
4238
|
handleTooltip (evnt: any, cell: any, overflowElem: any, tipElem: any, params: any) {
|
|
4239
|
+
const $xeTable = this
|
|
4240
|
+
|
|
4241
|
+
if (!overflowElem) {
|
|
4242
|
+
return $xeTable.$nextTick()
|
|
4243
|
+
}
|
|
4099
4244
|
params.cell = cell
|
|
4100
4245
|
const { $refs, tooltipOpts, tooltipStore } = this
|
|
4101
4246
|
const { column, row } = params
|
|
@@ -4122,7 +4267,7 @@ const Methods = {
|
|
|
4122
4267
|
},
|
|
4123
4268
|
openTooltip (target: any, content: any) {
|
|
4124
4269
|
const { $refs } = this
|
|
4125
|
-
const commTip = $refs.
|
|
4270
|
+
const commTip = $refs.refCommTooltip
|
|
4126
4271
|
if (commTip) {
|
|
4127
4272
|
return commTip.open(target, content)
|
|
4128
4273
|
}
|
|
@@ -4134,7 +4279,7 @@ const Methods = {
|
|
|
4134
4279
|
closeTooltip () {
|
|
4135
4280
|
const { $refs, tooltipStore } = this
|
|
4136
4281
|
const tooltip = $refs.tooltip
|
|
4137
|
-
const commTip = $refs.
|
|
4282
|
+
const commTip = $refs.refCommTooltip
|
|
4138
4283
|
if (tooltipStore.visible) {
|
|
4139
4284
|
Object.assign(tooltipStore, {
|
|
4140
4285
|
row: null,
|
|
@@ -5316,6 +5461,8 @@ const Methods = {
|
|
|
5316
5461
|
this.emitEvent('cell-dblclick', params, evnt)
|
|
5317
5462
|
},
|
|
5318
5463
|
handleDefaultSort () {
|
|
5464
|
+
const $xeTable = this
|
|
5465
|
+
|
|
5319
5466
|
const { sortConfig, sortOpts } = this
|
|
5320
5467
|
let { defaultSort } = sortOpts
|
|
5321
5468
|
if (defaultSort) {
|
|
@@ -5334,7 +5481,7 @@ const Methods = {
|
|
|
5334
5481
|
}
|
|
5335
5482
|
})
|
|
5336
5483
|
if (!sortOpts.remote) {
|
|
5337
|
-
this.handleTableData(true).then(
|
|
5484
|
+
this.handleTableData(true).then(() => updateStyle($xeTable))
|
|
5338
5485
|
}
|
|
5339
5486
|
}
|
|
5340
5487
|
}
|
|
@@ -5776,8 +5923,8 @@ const Methods = {
|
|
|
5776
5923
|
handleColDragSwapColumn () {
|
|
5777
5924
|
const $xeTable = this
|
|
5778
5925
|
|
|
5779
|
-
$xeTable
|
|
5780
|
-
$xeTable
|
|
5926
|
+
handleUpdateColumn($xeTable)
|
|
5927
|
+
parseColumns($xeTable, false).then(() => {
|
|
5781
5928
|
$xeTable.updateCellAreas()
|
|
5782
5929
|
$xeTable.saveCustomStore('update:sort')
|
|
5783
5930
|
})
|
|
@@ -6019,15 +6166,15 @@ const Methods = {
|
|
|
6019
6166
|
return
|
|
6020
6167
|
}
|
|
6021
6168
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
6022
|
-
const
|
|
6023
|
-
const tableBodyElem =
|
|
6169
|
+
const refTableBody = $xeTable.$refs.refTableBody
|
|
6170
|
+
const tableBodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
|
|
6024
6171
|
const scrollTargetEl = xHandleEl || tableBodyElem
|
|
6025
6172
|
if (scrollTargetEl) {
|
|
6026
6173
|
const wrapperRect = el.getBoundingClientRect()
|
|
6027
6174
|
const tableWidth = el.clientWidth
|
|
6028
|
-
const leftContainerElem = $xeTable.$refs.
|
|
6175
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
|
|
6029
6176
|
const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
|
|
6030
|
-
const rightContainerElem = $xeTable.$refs.
|
|
6177
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
|
|
6031
6178
|
const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0
|
|
6032
6179
|
const srartX = wrapperRect.x + leftContainerWidth
|
|
6033
6180
|
const endX = wrapperRect.x + tableWidth - rightContainerWidth
|
|
@@ -6152,6 +6299,8 @@ const Methods = {
|
|
|
6152
6299
|
return this.$nextTick()
|
|
6153
6300
|
},
|
|
6154
6301
|
sort (sortConfs: any, sortOrder: any) {
|
|
6302
|
+
const $xeTable = this
|
|
6303
|
+
|
|
6155
6304
|
const { sortOpts } = this
|
|
6156
6305
|
const { multiple, remote, orders } = sortOpts
|
|
6157
6306
|
if (sortConfs) {
|
|
@@ -6194,7 +6343,7 @@ const Methods = {
|
|
|
6194
6343
|
}
|
|
6195
6344
|
return this.$nextTick().then(() => {
|
|
6196
6345
|
this.updateCellAreas()
|
|
6197
|
-
return
|
|
6346
|
+
return updateStyle($xeTable)
|
|
6198
6347
|
})
|
|
6199
6348
|
}
|
|
6200
6349
|
return this.$nextTick()
|
|
@@ -6240,7 +6389,7 @@ const Methods = {
|
|
|
6240
6389
|
}
|
|
6241
6390
|
return $xeTable.$nextTick().then(() => {
|
|
6242
6391
|
$xeTable.updateCellAreas()
|
|
6243
|
-
return $xeTable
|
|
6392
|
+
return updateStyle($xeTable)
|
|
6244
6393
|
})
|
|
6245
6394
|
}
|
|
6246
6395
|
return $xeTable.$nextTick()
|
|
@@ -6251,6 +6400,8 @@ const Methods = {
|
|
|
6251
6400
|
* @param {String} column 列或字段名
|
|
6252
6401
|
*/
|
|
6253
6402
|
clearSort (fieldOrColumn: any) {
|
|
6403
|
+
const $xeTable = this
|
|
6404
|
+
|
|
6254
6405
|
const { sortOpts } = this
|
|
6255
6406
|
if (fieldOrColumn) {
|
|
6256
6407
|
const column = handleFieldOrColumn(this, fieldOrColumn)
|
|
@@ -6263,7 +6414,7 @@ const Methods = {
|
|
|
6263
6414
|
if (!sortOpts.remote) {
|
|
6264
6415
|
this.handleTableData(true)
|
|
6265
6416
|
}
|
|
6266
|
-
return this.$nextTick().then(
|
|
6417
|
+
return this.$nextTick().then(() => updateStyle($xeTable))
|
|
6267
6418
|
},
|
|
6268
6419
|
// 在 v3 中废弃
|
|
6269
6420
|
getSortColumn () {
|
|
@@ -6766,7 +6917,7 @@ const Methods = {
|
|
|
6766
6917
|
return this.$nextTick().then(() => {
|
|
6767
6918
|
if (transform) {
|
|
6768
6919
|
this.handleTableData()
|
|
6769
|
-
this.
|
|
6920
|
+
this.updateAfterDataIndex()
|
|
6770
6921
|
return this.$nextTick()
|
|
6771
6922
|
}
|
|
6772
6923
|
})
|
|
@@ -6880,7 +7031,7 @@ const Methods = {
|
|
|
6880
7031
|
return this.handleBaseTreeExpand(rows, expanded).then(() => {
|
|
6881
7032
|
handleVirtualTreeToList($xeTable)
|
|
6882
7033
|
this.handleTableData()
|
|
6883
|
-
this.
|
|
7034
|
+
this.updateAfterDataIndex()
|
|
6884
7035
|
}).then(() => {
|
|
6885
7036
|
return this.recalculate()
|
|
6886
7037
|
}).then(() => {
|
|
@@ -6967,7 +7118,7 @@ const Methods = {
|
|
|
6967
7118
|
*/
|
|
6968
7119
|
getScroll () {
|
|
6969
7120
|
const { $refs, scrollXLoad, scrollYLoad } = this
|
|
6970
|
-
const bodyElem = $refs.
|
|
7121
|
+
const bodyElem = $refs.refTableBody.$el
|
|
6971
7122
|
return {
|
|
6972
7123
|
virtualX: scrollXLoad,
|
|
6973
7124
|
virtualY: scrollYLoad,
|
|
@@ -6976,22 +7127,25 @@ const Methods = {
|
|
|
6976
7127
|
}
|
|
6977
7128
|
},
|
|
6978
7129
|
handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number, params: any) {
|
|
6979
|
-
const $xeTable = this
|
|
7130
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6980
7131
|
const props = $xeTable
|
|
6981
|
-
const reactData = $xeTable
|
|
6982
|
-
const internalData = $xeTable
|
|
7132
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7133
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6983
7134
|
|
|
6984
7135
|
const { highlightHoverRow } = props
|
|
6985
7136
|
const { lastScrollLeft, lastScrollTop } = internalData
|
|
6986
|
-
const
|
|
6987
|
-
const
|
|
7137
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7138
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7139
|
+
if (!xHandleEl || !yHandleEl) {
|
|
7140
|
+
return
|
|
7141
|
+
}
|
|
6988
7142
|
const rowOpts = $xeTable.computeRowOpts
|
|
6989
|
-
const validTip = $xeTable.$refs.
|
|
6990
|
-
const tooltip = $xeTable.$refs.
|
|
6991
|
-
const bodyHeight =
|
|
6992
|
-
const bodyWidth =
|
|
6993
|
-
const scrollHeight =
|
|
6994
|
-
const scrollWidth =
|
|
7143
|
+
const validTip = $xeTable.$refs.refValidTooltip as VxeTooltipInstance
|
|
7144
|
+
const tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
|
|
7145
|
+
const bodyHeight = yHandleEl.clientHeight
|
|
7146
|
+
const bodyWidth = xHandleEl.clientWidth
|
|
7147
|
+
const scrollHeight = yHandleEl.scrollHeight
|
|
7148
|
+
const scrollWidth = xHandleEl.scrollWidth
|
|
6995
7149
|
let isTop = false
|
|
6996
7150
|
let isBottom = false
|
|
6997
7151
|
let isLeft = false
|
|
@@ -7063,13 +7217,12 @@ const Methods = {
|
|
|
7063
7217
|
if (rowOpts.isHover || highlightHoverRow) {
|
|
7064
7218
|
$xeTable.clearHoverRow()
|
|
7065
7219
|
}
|
|
7066
|
-
if (validTip && validTip.visible) {
|
|
7220
|
+
if (validTip && validTip.reactData.visible) {
|
|
7067
7221
|
validTip.close()
|
|
7068
7222
|
}
|
|
7069
|
-
if (tooltip && tooltip.visible) {
|
|
7223
|
+
if (tooltip && tooltip.reactData.visible) {
|
|
7070
7224
|
tooltip.close()
|
|
7071
7225
|
}
|
|
7072
|
-
|
|
7073
7226
|
if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
|
|
7074
7227
|
$xeTable.dispatchEvent('scroll-boundary', evntParams, evnt)
|
|
7075
7228
|
}
|
|
@@ -7081,7 +7234,7 @@ const Methods = {
|
|
|
7081
7234
|
|
|
7082
7235
|
const { lxTimeout, lxRunTime, scrollXStore } = internalData
|
|
7083
7236
|
const { visibleSize } = scrollXStore
|
|
7084
|
-
const fpsTime = Math.min(80, Math.floor(visibleSize * 3))
|
|
7237
|
+
const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)))
|
|
7085
7238
|
if (lxTimeout) {
|
|
7086
7239
|
clearTimeout(lxTimeout)
|
|
7087
7240
|
}
|
|
@@ -7097,11 +7250,13 @@ const Methods = {
|
|
|
7097
7250
|
},
|
|
7098
7251
|
lazyScrollYData () {
|
|
7099
7252
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7253
|
+
const props = $xeTable
|
|
7100
7254
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7101
7255
|
|
|
7256
|
+
const { showOverflow } = props
|
|
7102
7257
|
const { lyTimeout, lyRunTime, scrollYStore } = internalData
|
|
7103
7258
|
const { visibleSize } = scrollYStore
|
|
7104
|
-
const fpsTime = Math.min(80, Math.floor(visibleSize))
|
|
7259
|
+
const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)))
|
|
7105
7260
|
if (lyTimeout) {
|
|
7106
7261
|
clearTimeout(lyTimeout)
|
|
7107
7262
|
}
|
|
@@ -7141,29 +7296,258 @@ const Methods = {
|
|
|
7141
7296
|
$xeTable.lazyScrollYData()
|
|
7142
7297
|
}
|
|
7143
7298
|
},
|
|
7144
|
-
|
|
7145
|
-
const $xeTable = this
|
|
7146
|
-
const internalData = $xeTable
|
|
7299
|
+
triggerBodyScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
|
|
7300
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7301
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7147
7302
|
|
|
7148
|
-
const {
|
|
7149
|
-
|
|
7150
|
-
|
|
7303
|
+
const { elemStore, lastScrollTop, lastScrollLeft, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll, scrollRenderType, inFooterScroll } = internalData
|
|
7304
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7305
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7306
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
|
|
7307
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7308
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
|
|
7309
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
|
|
7310
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
|
|
7311
|
+
if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
|
|
7312
|
+
return
|
|
7313
|
+
}
|
|
7314
|
+
if (!bodyScrollElem) {
|
|
7315
|
+
return
|
|
7316
|
+
}
|
|
7317
|
+
if (!xHandleEl) {
|
|
7318
|
+
return
|
|
7319
|
+
}
|
|
7320
|
+
if (!yHandleEl) {
|
|
7321
|
+
return
|
|
7322
|
+
}
|
|
7323
|
+
if (inBodyScroll) {
|
|
7324
|
+
if (scrollRenderType !== fixedType) {
|
|
7151
7325
|
return
|
|
7152
7326
|
}
|
|
7153
|
-
|
|
7154
|
-
|
|
7327
|
+
}
|
|
7328
|
+
let scrollTop = yHandleEl.scrollTop
|
|
7329
|
+
let scrollLeft = xHandleEl.scrollLeft
|
|
7330
|
+
if (leftScrollElem && fixedType === 'left') {
|
|
7331
|
+
scrollTop = leftScrollElem.scrollTop
|
|
7332
|
+
} else if (rightScrollElem && fixedType === 'right') {
|
|
7333
|
+
scrollTop = rightScrollElem.scrollTop
|
|
7334
|
+
} else {
|
|
7335
|
+
scrollTop = bodyScrollElem.scrollTop
|
|
7336
|
+
scrollLeft = bodyScrollElem.scrollLeft
|
|
7337
|
+
}
|
|
7338
|
+
const isRollX = scrollLeft !== lastScrollLeft
|
|
7339
|
+
const isRollY = scrollTop !== lastScrollTop
|
|
7340
|
+
internalData.inBodyScroll = true
|
|
7341
|
+
internalData.scrollRenderType = fixedType
|
|
7342
|
+
if (isRollY) {
|
|
7343
|
+
if (fixedType === 'left') {
|
|
7344
|
+
setScrollTop(bodyScrollElem, scrollTop)
|
|
7345
|
+
setScrollTop(rightScrollElem, scrollTop)
|
|
7346
|
+
} else if (fixedType === 'right') {
|
|
7347
|
+
setScrollTop(bodyScrollElem, scrollTop)
|
|
7348
|
+
setScrollTop(leftScrollElem, scrollTop)
|
|
7349
|
+
} else {
|
|
7350
|
+
setScrollTop(leftScrollElem, scrollTop)
|
|
7351
|
+
setScrollTop(rightScrollElem, scrollTop)
|
|
7155
7352
|
}
|
|
7353
|
+
setScrollTop(yHandleEl, scrollTop)
|
|
7354
|
+
$xeTable.triggerScrollYEvent(evnt)
|
|
7355
|
+
}
|
|
7356
|
+
if (isRollX) {
|
|
7357
|
+
setScrollLeft(xHandleEl, scrollLeft)
|
|
7358
|
+
setScrollLeft(headerScrollElem, scrollLeft)
|
|
7359
|
+
setScrollLeft(footerScrollElem, scrollLeft)
|
|
7360
|
+
$xeTable.triggerScrollXEvent(evnt)
|
|
7361
|
+
}
|
|
7362
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7363
|
+
type: 'body',
|
|
7364
|
+
fixed: fixedType
|
|
7365
|
+
})
|
|
7366
|
+
},
|
|
7367
|
+
triggerHeaderScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
|
|
7368
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7369
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7370
|
+
|
|
7371
|
+
const { elemStore, inWheelScroll, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData
|
|
7372
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7373
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7374
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7375
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
|
|
7376
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
|
|
7377
|
+
if (inWheelScroll) {
|
|
7378
|
+
return
|
|
7379
|
+
}
|
|
7380
|
+
if (inVirtualScroll) {
|
|
7381
|
+
return
|
|
7382
|
+
}
|
|
7383
|
+
if (inBodyScroll) {
|
|
7384
|
+
return
|
|
7385
|
+
}
|
|
7386
|
+
if (inFooterScroll) {
|
|
7387
|
+
return
|
|
7388
|
+
}
|
|
7389
|
+
if (!headerScrollElem) {
|
|
7390
|
+
return
|
|
7391
|
+
}
|
|
7392
|
+
if (!xHandleEl) {
|
|
7393
|
+
return
|
|
7394
|
+
}
|
|
7395
|
+
if (!yHandleEl) {
|
|
7396
|
+
return
|
|
7397
|
+
}
|
|
7398
|
+
const scrollTop = yHandleEl.scrollTop
|
|
7399
|
+
const scrollLeft = headerScrollElem.scrollLeft
|
|
7400
|
+
const isRollX = true
|
|
7401
|
+
const isRollY = false
|
|
7402
|
+
internalData.inHeaderScroll = true
|
|
7403
|
+
setScrollLeft(xHandleEl, scrollLeft)
|
|
7404
|
+
setScrollLeft(footerScrollElem, scrollLeft)
|
|
7405
|
+
setScrollLeft(bodyScrollElem, scrollLeft)
|
|
7406
|
+
$xeTable.triggerScrollXEvent(evnt)
|
|
7407
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7408
|
+
type: 'header',
|
|
7409
|
+
fixed: fixedType
|
|
7410
|
+
})
|
|
7411
|
+
},
|
|
7412
|
+
triggerFooterScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
|
|
7413
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7414
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7415
|
+
|
|
7416
|
+
const { elemStore, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData
|
|
7417
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7418
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7419
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7420
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
|
|
7421
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
|
|
7422
|
+
if (inWheelScroll) {
|
|
7423
|
+
return
|
|
7424
|
+
}
|
|
7425
|
+
if (inVirtualScroll) {
|
|
7426
|
+
return
|
|
7427
|
+
}
|
|
7428
|
+
if (inHeaderScroll) {
|
|
7429
|
+
return
|
|
7430
|
+
}
|
|
7431
|
+
if (inBodyScroll) {
|
|
7432
|
+
return
|
|
7433
|
+
}
|
|
7434
|
+
if (!footerScrollElem) {
|
|
7435
|
+
return
|
|
7436
|
+
}
|
|
7437
|
+
if (!xHandleEl) {
|
|
7438
|
+
return
|
|
7439
|
+
}
|
|
7440
|
+
if (!yHandleEl) {
|
|
7441
|
+
return
|
|
7442
|
+
}
|
|
7443
|
+
const scrollTop = yHandleEl.scrollTop
|
|
7444
|
+
const scrollLeft = footerScrollElem.scrollLeft
|
|
7445
|
+
const isRollX = true
|
|
7446
|
+
const isRollY = false
|
|
7447
|
+
internalData.inFooterScroll = true
|
|
7448
|
+
setScrollLeft(xHandleEl, scrollLeft)
|
|
7449
|
+
setScrollLeft(headerScrollElem, scrollLeft)
|
|
7450
|
+
setScrollLeft(bodyScrollElem, scrollLeft)
|
|
7451
|
+
$xeTable.triggerScrollXEvent(evnt)
|
|
7452
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7453
|
+
type: 'footer',
|
|
7454
|
+
fixed: fixedType
|
|
7455
|
+
})
|
|
7456
|
+
},
|
|
7457
|
+
triggerBodyWheelEvent (evnt: WheelEvent) {
|
|
7458
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7459
|
+
const tableProps = $xeTable
|
|
7460
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7461
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7462
|
+
|
|
7463
|
+
const { deltaY, deltaX } = evnt
|
|
7464
|
+
const { highlightHoverRow } = tableProps
|
|
7465
|
+
const { elemStore, lastScrollTop, lastScrollLeft } = internalData
|
|
7466
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
7467
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7468
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7469
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
|
|
7470
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7471
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
|
|
7472
|
+
|
|
7473
|
+
if (!xHandleEl) {
|
|
7474
|
+
return
|
|
7475
|
+
}
|
|
7476
|
+
if (!yHandleEl) {
|
|
7477
|
+
return
|
|
7478
|
+
}
|
|
7479
|
+
if (!bodyScrollElem) {
|
|
7480
|
+
return
|
|
7481
|
+
}
|
|
7482
|
+
|
|
7483
|
+
let multiple = 1
|
|
7484
|
+
|
|
7485
|
+
if (reactData.lastScrollTime + 25 > Date.now()) {
|
|
7486
|
+
multiple = 1.18
|
|
7487
|
+
} else if (reactData.lastScrollTime + 30 > Date.now()) {
|
|
7488
|
+
multiple = 1.15
|
|
7489
|
+
} else if (reactData.lastScrollTime + 40 > Date.now()) {
|
|
7490
|
+
multiple = 1.12
|
|
7491
|
+
} else if (reactData.lastScrollTime + 55 > Date.now()) {
|
|
7492
|
+
multiple = 1.09
|
|
7493
|
+
} else if (reactData.lastScrollTime + 75 > Date.now()) {
|
|
7494
|
+
multiple = 1.06
|
|
7495
|
+
} else if (reactData.lastScrollTime + 100 > Date.now()) {
|
|
7496
|
+
multiple = 1.03
|
|
7497
|
+
}
|
|
7498
|
+
|
|
7499
|
+
const deltaTop = deltaY * multiple
|
|
7500
|
+
const deltaLeft = deltaX * multiple
|
|
7501
|
+
|
|
7502
|
+
const isTopWheel = deltaTop < 0
|
|
7503
|
+
const currScrollTop = yHandleEl.scrollTop
|
|
7504
|
+
// 如果滚动位置已经是顶部或底部,则不需要触发
|
|
7505
|
+
if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
|
|
7506
|
+
return
|
|
7507
|
+
}
|
|
7508
|
+
|
|
7509
|
+
const scrollTop = bodyScrollElem.scrollTop + deltaTop
|
|
7510
|
+
const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft
|
|
7511
|
+
const isRollX = scrollLeft !== lastScrollLeft
|
|
7512
|
+
const isRollY = scrollTop !== lastScrollTop
|
|
7513
|
+
|
|
7514
|
+
// 用于鼠标纵向滚轮处理
|
|
7515
|
+
if (isRollY) {
|
|
7516
|
+
evnt.preventDefault()
|
|
7517
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
7518
|
+
$xeTable.clearHoverRow()
|
|
7519
|
+
}
|
|
7520
|
+
|
|
7521
|
+
internalData.inWheelScroll = true
|
|
7522
|
+
setScrollTop(yHandleEl, scrollTop)
|
|
7523
|
+
setScrollTop(bodyScrollElem, scrollTop)
|
|
7524
|
+
setScrollTop(leftScrollElem, scrollTop)
|
|
7525
|
+
setScrollTop(rightScrollElem, scrollTop)
|
|
7526
|
+
$xeTable.triggerScrollYEvent(evnt)
|
|
7527
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7528
|
+
type: 'footer',
|
|
7529
|
+
fixed: ''
|
|
7530
|
+
})
|
|
7531
|
+
}
|
|
7532
|
+
},
|
|
7533
|
+
scrollXEvent (evnt: Event) {
|
|
7534
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7535
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7536
|
+
|
|
7537
|
+
const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
|
|
7538
|
+
if (inHeaderScroll || inBodyScroll || inFooterScroll) {
|
|
7539
|
+
return
|
|
7156
7540
|
}
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
const
|
|
7161
|
-
const
|
|
7162
|
-
const
|
|
7541
|
+
if (inWheelScroll) {
|
|
7542
|
+
return
|
|
7543
|
+
}
|
|
7544
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
|
|
7545
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7546
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
|
|
7163
7547
|
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7164
7548
|
const wrapperEl = evnt.currentTarget as HTMLDivElement
|
|
7165
7549
|
const { scrollLeft } = wrapperEl
|
|
7166
|
-
const yBodyEl = yHandleEl ||
|
|
7550
|
+
const yBodyEl = yHandleEl || bodyScrollElem
|
|
7167
7551
|
let scrollTop = 0
|
|
7168
7552
|
if (yBodyEl) {
|
|
7169
7553
|
scrollTop = yBodyEl.scrollTop
|
|
@@ -7172,9 +7556,9 @@ const Methods = {
|
|
|
7172
7556
|
const isRollY = scrollTop !== lastScrollTop
|
|
7173
7557
|
|
|
7174
7558
|
internalData.inVirtualScroll = true
|
|
7175
|
-
setScrollLeft(
|
|
7176
|
-
setScrollLeft(
|
|
7177
|
-
setScrollLeft(
|
|
7559
|
+
setScrollLeft(bodyScrollElem, scrollLeft)
|
|
7560
|
+
setScrollLeft(headerScrollElem, scrollLeft)
|
|
7561
|
+
setScrollLeft(footerScrollElem, scrollLeft)
|
|
7178
7562
|
$xeTable.triggerScrollXEvent(evnt)
|
|
7179
7563
|
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7180
7564
|
type: 'table',
|
|
@@ -7182,28 +7566,23 @@ const Methods = {
|
|
|
7182
7566
|
})
|
|
7183
7567
|
},
|
|
7184
7568
|
scrollYEvent (evnt: Event) {
|
|
7185
|
-
const $xeTable = this
|
|
7186
|
-
const internalData = $xeTable
|
|
7569
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7570
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7187
7571
|
|
|
7188
|
-
const {
|
|
7189
|
-
if (
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
return
|
|
7195
|
-
}
|
|
7572
|
+
const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
|
|
7573
|
+
if (inHeaderScroll || inBodyScroll || inFooterScroll) {
|
|
7574
|
+
return
|
|
7575
|
+
}
|
|
7576
|
+
if (inWheelScroll) {
|
|
7577
|
+
return
|
|
7196
7578
|
}
|
|
7197
|
-
const
|
|
7198
|
-
const
|
|
7199
|
-
const
|
|
7200
|
-
const bodyElem = tableBody.$el as HTMLDivElement
|
|
7201
|
-
const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
|
|
7202
|
-
const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
|
|
7579
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
|
|
7580
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7581
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
|
|
7203
7582
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7204
7583
|
const wrapperEl = evnt.currentTarget as HTMLDivElement
|
|
7205
7584
|
const { scrollTop } = wrapperEl
|
|
7206
|
-
const xBodyEl = xHandleEl ||
|
|
7585
|
+
const xBodyEl = xHandleEl || bodyScrollElem
|
|
7207
7586
|
let scrollLeft = 0
|
|
7208
7587
|
if (xBodyEl) {
|
|
7209
7588
|
scrollLeft = xBodyEl.scrollLeft
|
|
@@ -7212,47 +7591,25 @@ const Methods = {
|
|
|
7212
7591
|
const isRollY = true
|
|
7213
7592
|
|
|
7214
7593
|
internalData.inVirtualScroll = true
|
|
7215
|
-
setScrollTop(
|
|
7216
|
-
setScrollTop(
|
|
7217
|
-
setScrollTop(
|
|
7594
|
+
setScrollTop(bodyScrollElem, scrollTop)
|
|
7595
|
+
setScrollTop(leftScrollElem, scrollTop)
|
|
7596
|
+
setScrollTop(rightScrollElem, scrollTop)
|
|
7218
7597
|
$xeTable.triggerScrollYEvent(evnt)
|
|
7219
7598
|
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7220
7599
|
type: 'table',
|
|
7221
7600
|
fixed: ''
|
|
7222
7601
|
})
|
|
7223
7602
|
},
|
|
7224
|
-
handleTableColumn () {
|
|
7225
|
-
const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this
|
|
7226
|
-
const tableColumn: any[] = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0)
|
|
7227
|
-
tableColumn.forEach((column, $index) => {
|
|
7228
|
-
const colid = column.id
|
|
7229
|
-
const colRest = fullColumnIdData[colid]
|
|
7230
|
-
if (colRest) {
|
|
7231
|
-
colRest.$index = $index
|
|
7232
|
-
}
|
|
7233
|
-
})
|
|
7234
|
-
this.tableColumn = tableColumn
|
|
7235
|
-
},
|
|
7236
|
-
handleUpdateColumn () {
|
|
7237
|
-
const $xeTable = this as VxeTableConstructor
|
|
7238
|
-
const internalData = $xeTable as unknown as TableInternalData
|
|
7239
|
-
|
|
7240
|
-
const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber')
|
|
7241
|
-
internalData.collectColumn = columnList
|
|
7242
|
-
const tableFullColumn = getColumnList(columnList)
|
|
7243
|
-
internalData.tableFullColumn = tableFullColumn
|
|
7244
|
-
cacheColumnMap($xeTable)
|
|
7245
|
-
},
|
|
7246
7603
|
updateScrollXData () {
|
|
7247
7604
|
const $xeTable = this
|
|
7248
7605
|
const props = $xeTable
|
|
7249
7606
|
|
|
7250
7607
|
const { showOverflow } = props
|
|
7251
|
-
$xeTable
|
|
7252
|
-
calcCellHeight(
|
|
7608
|
+
handleTableColumn($xeTable)
|
|
7609
|
+
// calcCellHeight()
|
|
7253
7610
|
return $xeTable.$nextTick().then(() => {
|
|
7254
|
-
calcCellHeight(
|
|
7255
|
-
$xeTable
|
|
7611
|
+
// calcCellHeight()
|
|
7612
|
+
handleTableColumn($xeTable)
|
|
7256
7613
|
$xeTable.updateScrollXSpace()
|
|
7257
7614
|
if (!showOverflow) {
|
|
7258
7615
|
$xeTable.updateScrollYSpace()
|
|
@@ -7261,18 +7618,23 @@ const Methods = {
|
|
|
7261
7618
|
},
|
|
7262
7619
|
// 更新横向 X 可视渲染上下剩余空间大小
|
|
7263
7620
|
updateScrollXSpace () {
|
|
7264
|
-
const $xeTable = this
|
|
7621
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7622
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7623
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7265
7624
|
|
|
7266
|
-
const {
|
|
7267
|
-
const {
|
|
7268
|
-
const
|
|
7625
|
+
const { isGroup, scrollXLoad } = reactData
|
|
7626
|
+
const { visibleColumn, scrollXStore, elemStore, tableWidth } = internalData
|
|
7627
|
+
const tableHeader = $xeTable.$refs.refTableHeader
|
|
7628
|
+
const tableBody = $xeTable.$refs.refTableBody
|
|
7629
|
+
const tableFooter = $xeTable.$refs.refTableFooter
|
|
7630
|
+
const tableBodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
|
|
7269
7631
|
if (tableBodyElem) {
|
|
7270
|
-
const tableHeaderElem = tableHeader ? tableHeader.$el : null
|
|
7271
|
-
const tableFooterElem = tableFooter ? tableFooter.$el : null
|
|
7272
|
-
const headerElem = tableHeaderElem ? tableHeaderElem.querySelector('.vxe-table--header') : null
|
|
7273
|
-
const bodyElem = tableBodyElem.querySelector('.vxe-table--body')
|
|
7274
|
-
const footerElem = tableFooterElem ? tableFooterElem.querySelector('.vxe-table--footer') : null
|
|
7275
|
-
const leftSpaceWidth = visibleColumn.slice(0, scrollXStore.startIndex).reduce((previous
|
|
7632
|
+
const tableHeaderElem = tableHeader ? (tableHeader as any).$el as HTMLDivElement : null
|
|
7633
|
+
const tableFooterElem = tableFooter ? (tableFooter as any).$el as HTMLDivElement : null
|
|
7634
|
+
const headerElem = tableHeaderElem ? tableHeaderElem.querySelector('.vxe-table--header') as HTMLTableElement : null
|
|
7635
|
+
const bodyElem = tableBodyElem.querySelector('.vxe-table--body') as HTMLTableElement
|
|
7636
|
+
const footerElem = tableFooterElem ? tableFooterElem.querySelector('.vxe-table--footer') as HTMLTableElement : null
|
|
7637
|
+
const leftSpaceWidth = visibleColumn.slice(0, scrollXStore.startIndex).reduce((previous, column) => previous + column.renderWidth, 0)
|
|
7276
7638
|
let marginLeft = ''
|
|
7277
7639
|
if (scrollXLoad) {
|
|
7278
7640
|
marginLeft = `${leftSpaceWidth}px`
|
|
@@ -7288,44 +7650,50 @@ const Methods = {
|
|
|
7288
7650
|
containerList.forEach(name => {
|
|
7289
7651
|
const layoutList = ['header', 'body', 'footer']
|
|
7290
7652
|
layoutList.forEach(layout => {
|
|
7291
|
-
const xSpaceElem = elemStore[`${name}-${layout}-xSpace`]
|
|
7653
|
+
const xSpaceElem = getRefElem(elemStore[`${name}-${layout}-xSpace`])
|
|
7292
7654
|
if (xSpaceElem) {
|
|
7293
|
-
xSpaceElem.style.width = scrollXLoad ? `${tableWidth
|
|
7655
|
+
xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : ''
|
|
7294
7656
|
}
|
|
7295
7657
|
})
|
|
7296
7658
|
})
|
|
7297
|
-
const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem
|
|
7659
|
+
const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem as HTMLDivElement
|
|
7298
7660
|
if (scrollXSpaceEl) {
|
|
7299
|
-
scrollXSpaceEl.style.width = `${tableWidth
|
|
7661
|
+
scrollXSpaceEl.style.width = `${tableWidth}px`
|
|
7300
7662
|
}
|
|
7301
|
-
|
|
7663
|
+
$xeTable.$nextTick(() => {
|
|
7664
|
+
updateStyle($xeTable)
|
|
7665
|
+
})
|
|
7302
7666
|
}
|
|
7303
7667
|
},
|
|
7304
7668
|
updateScrollYData () {
|
|
7305
7669
|
const $xeTable = this
|
|
7306
7670
|
|
|
7307
7671
|
$xeTable.handleTableData()
|
|
7308
|
-
calcCellHeight(
|
|
7672
|
+
// calcCellHeight()
|
|
7309
7673
|
return $xeTable.$nextTick().then(() => {
|
|
7310
|
-
calcCellHeight(
|
|
7674
|
+
// calcCellHeight()
|
|
7311
7675
|
$xeTable.handleTableData()
|
|
7312
7676
|
$xeTable.updateScrollYSpace()
|
|
7313
7677
|
})
|
|
7314
7678
|
},
|
|
7315
7679
|
// 更新纵向 Y 可视渲染上下剩余空间大小
|
|
7316
7680
|
updateScrollYSpace () {
|
|
7317
|
-
const $xeTable = this
|
|
7681
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7682
|
+
const props = $xeTable
|
|
7683
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7684
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7318
7685
|
|
|
7319
|
-
const { showOverflow
|
|
7320
|
-
const {
|
|
7321
|
-
|
|
7322
|
-
|
|
7686
|
+
const { showOverflow } = props
|
|
7687
|
+
const { scrollYLoad, rowHeight } = reactData
|
|
7688
|
+
const { scrollYStore, elemStore, afterFullData, fullAllDataRowIdData } = internalData
|
|
7689
|
+
const { startIndex } = scrollYStore
|
|
7690
|
+
const bodyTableElem = getRefElem(elemStore['main-body-table'])
|
|
7323
7691
|
const containerList = ['main', 'left', 'right']
|
|
7324
|
-
let
|
|
7325
|
-
let ySpaceHeight =
|
|
7692
|
+
let topSpaceHeight = 0
|
|
7693
|
+
let ySpaceHeight = 0
|
|
7326
7694
|
if (scrollYLoad) {
|
|
7327
7695
|
if (showOverflow) {
|
|
7328
|
-
|
|
7696
|
+
ySpaceHeight = afterFullData.length * rowHeight
|
|
7329
7697
|
topSpaceHeight = Math.max(0, startIndex * rowHeight)
|
|
7330
7698
|
} else {
|
|
7331
7699
|
for (let i = 0; i < afterFullData.length; i++) {
|
|
@@ -7333,7 +7701,7 @@ const Methods = {
|
|
|
7333
7701
|
const rowid = getRowid($xeTable, row)
|
|
7334
7702
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7335
7703
|
if (rowRest) {
|
|
7336
|
-
|
|
7704
|
+
ySpaceHeight += rowRest.height || rowHeight
|
|
7337
7705
|
}
|
|
7338
7706
|
}
|
|
7339
7707
|
for (let i = 0; i < startIndex; i++) {
|
|
@@ -7345,27 +7713,31 @@ const Methods = {
|
|
|
7345
7713
|
}
|
|
7346
7714
|
}
|
|
7347
7715
|
}
|
|
7348
|
-
|
|
7349
|
-
|
|
7716
|
+
} else {
|
|
7717
|
+
if (bodyTableElem) {
|
|
7718
|
+
ySpaceHeight = bodyTableElem.clientHeight
|
|
7719
|
+
}
|
|
7350
7720
|
}
|
|
7351
7721
|
containerList.forEach(name => {
|
|
7352
7722
|
const layoutList = ['header', 'body', 'footer']
|
|
7353
|
-
const tableElem = elemStore[`${name}-body-table`]
|
|
7723
|
+
const tableElem = getRefElem(elemStore[`${name}-body-table`])
|
|
7354
7724
|
if (tableElem) {
|
|
7355
|
-
tableElem.style.marginTop =
|
|
7725
|
+
tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : ''
|
|
7356
7726
|
}
|
|
7357
7727
|
layoutList.forEach(layout => {
|
|
7358
|
-
const ySpaceElem = elemStore[`${name}-${layout}-ySpace`]
|
|
7728
|
+
const ySpaceElem = getRefElem(elemStore[`${name}-${layout}-ySpace`])
|
|
7359
7729
|
if (ySpaceElem) {
|
|
7360
|
-
ySpaceElem.style.height = ySpaceHeight
|
|
7730
|
+
ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
|
|
7361
7731
|
}
|
|
7362
7732
|
})
|
|
7363
7733
|
})
|
|
7364
|
-
const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem
|
|
7734
|
+
const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem as HTMLDivElement
|
|
7365
7735
|
if (scrollYSpaceEl) {
|
|
7366
|
-
scrollYSpaceEl.style.height = ySpaceHeight
|
|
7736
|
+
scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
|
|
7367
7737
|
}
|
|
7368
|
-
|
|
7738
|
+
$xeTable.$nextTick(() => {
|
|
7739
|
+
updateStyle($xeTable)
|
|
7740
|
+
})
|
|
7369
7741
|
},
|
|
7370
7742
|
updateScrollYStatus () {
|
|
7371
7743
|
const $xeTable = this
|
|
@@ -7382,12 +7754,12 @@ const Methods = {
|
|
|
7382
7754
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7383
7755
|
|
|
7384
7756
|
const { $refs } = this
|
|
7385
|
-
const {
|
|
7386
|
-
const tableBodyElem =
|
|
7757
|
+
const { refTableBody, refTableHeader, leftBody, rightBody, refTableFooter } = $refs
|
|
7758
|
+
const tableBodyElem = refTableBody ? refTableBody.$el : null
|
|
7387
7759
|
const leftBodyElem = leftBody ? leftBody.$el : null
|
|
7388
7760
|
const rightBodyElem = rightBody ? rightBody.$el : null
|
|
7389
|
-
const tableHeaderElem =
|
|
7390
|
-
const tableFooterElem =
|
|
7761
|
+
const tableHeaderElem = refTableHeader ? refTableHeader.$el : null
|
|
7762
|
+
const tableFooterElem = refTableFooter ? refTableFooter.$el : null
|
|
7391
7763
|
internalData.intoRunScroll = true
|
|
7392
7764
|
if (XEUtils.isNumber(scrollLeft)) {
|
|
7393
7765
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
@@ -7492,45 +7864,37 @@ const Methods = {
|
|
|
7492
7864
|
const $xeTable = this
|
|
7493
7865
|
const internalData = $xeTable
|
|
7494
7866
|
|
|
7495
|
-
const { scrollXStore, scrollYStore } = internalData
|
|
7496
|
-
const
|
|
7497
|
-
const
|
|
7498
|
-
const
|
|
7499
|
-
const
|
|
7500
|
-
const
|
|
7501
|
-
const leftBodyElem = leftBody ? leftBody.$el as HTMLDivElement : null
|
|
7502
|
-
const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
|
|
7503
|
-
const rightBodyElem = rightBody ? rightBody.$el as HTMLDivElement : null
|
|
7504
|
-
const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
|
|
7505
|
-
const tableFooterElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
|
|
7867
|
+
const { elemStore, scrollXStore, scrollYStore } = internalData
|
|
7868
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
|
|
7869
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
7870
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
|
|
7871
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
|
|
7872
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
|
|
7506
7873
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
7507
|
-
if (xHandleEl) {
|
|
7508
|
-
setScrollLeft(xHandleEl, 0)
|
|
7509
|
-
} else {
|
|
7510
|
-
setScrollLeft(tableBodyElem, 0)
|
|
7511
|
-
setScrollLeft(tableHeaderElem, 0)
|
|
7512
|
-
setScrollLeft(tableFooterElem, 0)
|
|
7513
|
-
}
|
|
7514
7874
|
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7875
|
+
|
|
7876
|
+
internalData.intoRunScroll = true
|
|
7877
|
+
|
|
7878
|
+
setScrollLeft(xHandleEl, 0)
|
|
7879
|
+
setScrollLeft(bodyScrollElem, 0)
|
|
7880
|
+
setScrollLeft(headerScrollElem, 0)
|
|
7881
|
+
setScrollLeft(footerScrollElem, 0)
|
|
7882
|
+
|
|
7883
|
+
setScrollTop(yHandleEl, 0)
|
|
7884
|
+
setScrollTop(bodyScrollElem, 0)
|
|
7885
|
+
setScrollTop(leftScrollElem, 0)
|
|
7886
|
+
setScrollTop(rightScrollElem, 0)
|
|
7887
|
+
|
|
7522
7888
|
scrollXStore.startIndex = 0
|
|
7889
|
+
scrollXStore.visibleStartIndex = 0
|
|
7523
7890
|
scrollXStore.endIndex = scrollXStore.visibleSize
|
|
7891
|
+
scrollXStore.visibleEndIndex = scrollXStore.visibleSize
|
|
7524
7892
|
scrollYStore.startIndex = 0
|
|
7893
|
+
scrollYStore.visibleStartIndex = 0
|
|
7525
7894
|
scrollYStore.endIndex = scrollYStore.visibleSize
|
|
7895
|
+
scrollYStore.visibleEndIndex = scrollYStore.visibleSize
|
|
7526
7896
|
return $xeTable.$nextTick().then(() => {
|
|
7527
|
-
|
|
7528
|
-
setScrollLeft(tableHeaderElem, 0)
|
|
7529
|
-
setScrollLeft(tableFooterElem, 0)
|
|
7530
|
-
|
|
7531
|
-
setScrollTop(tableBodyElem, 0)
|
|
7532
|
-
setScrollTop(leftBodyElem, 0)
|
|
7533
|
-
setScrollTop(rightBodyElem, 0)
|
|
7897
|
+
internalData.intoRunScroll = false
|
|
7534
7898
|
})
|
|
7535
7899
|
},
|
|
7536
7900
|
/**
|
|
@@ -7556,8 +7920,8 @@ const Methods = {
|
|
|
7556
7920
|
const customVal = !XEUtils.isUndefined(cellValue)
|
|
7557
7921
|
return this.$nextTick().then(() => {
|
|
7558
7922
|
const { $refs, editRules, validStore } = this
|
|
7559
|
-
const
|
|
7560
|
-
if (slotParams &&
|
|
7923
|
+
const refTableBody = $refs.refTableBody
|
|
7924
|
+
if (slotParams && refTableBody && editRules) {
|
|
7561
7925
|
const { row, column } = slotParams
|
|
7562
7926
|
const type = 'change'
|
|
7563
7927
|
if (this.hasCellRules) {
|
|
@@ -7591,13 +7955,15 @@ const Methods = {
|
|
|
7591
7955
|
* @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
|
|
7592
7956
|
*/
|
|
7593
7957
|
setMergeCells (merges: any) {
|
|
7958
|
+
const $xeTable = this
|
|
7959
|
+
|
|
7594
7960
|
if (this.spanMethod) {
|
|
7595
7961
|
errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
|
|
7596
7962
|
}
|
|
7597
7963
|
setMerges(this, merges, this.mergeList, this.afterFullData)
|
|
7598
7964
|
return this.$nextTick().then(() => {
|
|
7599
7965
|
this.updateCellAreas()
|
|
7600
|
-
return
|
|
7966
|
+
return updateStyle($xeTable)
|
|
7601
7967
|
})
|
|
7602
7968
|
},
|
|
7603
7969
|
/**
|
|
@@ -7605,13 +7971,15 @@ const Methods = {
|
|
|
7605
7971
|
* @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
|
|
7606
7972
|
*/
|
|
7607
7973
|
removeMergeCells (merges: any) {
|
|
7974
|
+
const $xeTable = this
|
|
7975
|
+
|
|
7608
7976
|
if (this.spanMethod) {
|
|
7609
7977
|
errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
|
|
7610
7978
|
}
|
|
7611
7979
|
const rest = removeMerges(this, merges, this.mergeList, this.afterFullData)
|
|
7612
7980
|
return this.$nextTick().then(() => {
|
|
7613
7981
|
this.updateCellAreas()
|
|
7614
|
-
|
|
7982
|
+
updateStyle($xeTable)
|
|
7615
7983
|
return rest
|
|
7616
7984
|
})
|
|
7617
7985
|
},
|
|
@@ -7625,32 +7993,38 @@ const Methods = {
|
|
|
7625
7993
|
* 清除所有单元格合并
|
|
7626
7994
|
*/
|
|
7627
7995
|
clearMergeCells () {
|
|
7996
|
+
const $xeTable = this
|
|
7997
|
+
|
|
7628
7998
|
this.mergeList = []
|
|
7629
7999
|
return this.$nextTick().then(() => {
|
|
7630
|
-
return
|
|
8000
|
+
return updateStyle($xeTable)
|
|
7631
8001
|
})
|
|
7632
8002
|
},
|
|
7633
8003
|
handleDefaultMergeFooterItems () {
|
|
7634
8004
|
this.setMergeFooterItems(this.mergeFooterItems)
|
|
7635
8005
|
},
|
|
7636
8006
|
setMergeFooterItems (merges: any) {
|
|
8007
|
+
const $xeTable = this
|
|
8008
|
+
|
|
7637
8009
|
if (this.footerSpanMethod) {
|
|
7638
8010
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
7639
8011
|
}
|
|
7640
8012
|
setMerges(this, merges, this.mergeFooterList, null)
|
|
7641
8013
|
return this.$nextTick().then(() => {
|
|
7642
8014
|
this.updateCellAreas()
|
|
7643
|
-
return
|
|
8015
|
+
return updateStyle($xeTable)
|
|
7644
8016
|
})
|
|
7645
8017
|
},
|
|
7646
8018
|
removeMergeFooterItems (merges: any) {
|
|
8019
|
+
const $xeTable = this
|
|
8020
|
+
|
|
7647
8021
|
if (this.footerSpanMethod) {
|
|
7648
8022
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
7649
8023
|
}
|
|
7650
8024
|
const rest = removeMerges(this, merges, this.mergeFooterList, null)
|
|
7651
8025
|
return this.$nextTick().then(() => {
|
|
7652
8026
|
this.updateCellAreas()
|
|
7653
|
-
|
|
8027
|
+
updateStyle($xeTable)
|
|
7654
8028
|
return rest
|
|
7655
8029
|
})
|
|
7656
8030
|
},
|
|
@@ -7664,9 +8038,11 @@ const Methods = {
|
|
|
7664
8038
|
* 清除所有表尾合并
|
|
7665
8039
|
*/
|
|
7666
8040
|
clearMergeFooterItems () {
|
|
8041
|
+
const $xeTable = this
|
|
8042
|
+
|
|
7667
8043
|
this.mergeFooterList = []
|
|
7668
8044
|
return this.$nextTick().then(() => {
|
|
7669
|
-
return
|
|
8045
|
+
return updateStyle($xeTable)
|
|
7670
8046
|
})
|
|
7671
8047
|
},
|
|
7672
8048
|
updateZindex () {
|