vxe-table 3.12.9 → 3.12.10-beta.1

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.
Files changed (90) hide show
  1. package/es/grid/src/grid.js +6 -1
  2. package/es/index.css +1 -1
  3. package/es/index.min.css +1 -1
  4. package/es/locale/lang/ko-KR.js +515 -515
  5. package/es/style.css +1 -1
  6. package/es/style.min.css +1 -1
  7. package/es/table/module/export/mixin.js +3 -3
  8. package/es/table/module/filter/mixin.js +3 -3
  9. package/es/table/module/keyboard/mixin.js +4 -4
  10. package/es/table/module/menu/mixin.js +2 -2
  11. package/es/table/module/validator/mixin.js +2 -2
  12. package/es/table/src/body.js +247 -351
  13. package/es/table/src/footer.js +135 -154
  14. package/es/table/src/header.js +120 -100
  15. package/es/table/src/methods.js +1192 -797
  16. package/es/table/src/props.js +9 -3
  17. package/es/table/src/table.js +187 -103
  18. package/es/table/src/util.js +16 -7
  19. package/es/table/style.css +146 -63
  20. package/es/table/style.min.css +1 -1
  21. package/es/ui/index.js +14 -4
  22. package/es/ui/src/log.js +1 -1
  23. package/es/vxe-table/style.css +146 -63
  24. package/es/vxe-table/style.min.css +1 -1
  25. package/lib/grid/src/grid.js +4 -1
  26. package/lib/grid/src/grid.min.js +1 -1
  27. package/lib/index.css +1 -1
  28. package/lib/index.min.css +1 -1
  29. package/lib/index.umd.js +1917 -1550
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/locale/lang/ko-KR.js +515 -515
  32. package/lib/locale/lang/ko-KR.min.js +1 -1
  33. package/lib/locale/lang/ko-KR.umd.js +515 -515
  34. package/lib/style.css +1 -1
  35. package/lib/style.min.css +1 -1
  36. package/lib/table/module/export/mixin.js +3 -3
  37. package/lib/table/module/export/mixin.min.js +1 -1
  38. package/lib/table/module/filter/mixin.js +4 -4
  39. package/lib/table/module/filter/mixin.min.js +1 -1
  40. package/lib/table/module/keyboard/mixin.js +5 -5
  41. package/lib/table/module/keyboard/mixin.min.js +1 -1
  42. package/lib/table/module/menu/mixin.js +2 -2
  43. package/lib/table/module/menu/mixin.min.js +1 -1
  44. package/lib/table/module/validator/mixin.js +2 -2
  45. package/lib/table/module/validator/mixin.min.js +1 -1
  46. package/lib/table/src/body.js +185 -365
  47. package/lib/table/src/body.min.js +1 -1
  48. package/lib/table/src/footer.js +124 -151
  49. package/lib/table/src/footer.min.js +1 -1
  50. package/lib/table/src/header.js +97 -74
  51. package/lib/table/src/header.min.js +1 -1
  52. package/lib/table/src/methods.js +1282 -840
  53. package/lib/table/src/methods.min.js +1 -1
  54. package/lib/table/src/props.js +9 -3
  55. package/lib/table/src/props.min.js +1 -1
  56. package/lib/table/src/table.js +171 -90
  57. package/lib/table/src/table.min.js +1 -1
  58. package/lib/table/src/util.js +17 -7
  59. package/lib/table/src/util.min.js +1 -1
  60. package/lib/table/style/style.css +146 -63
  61. package/lib/table/style/style.min.css +1 -1
  62. package/lib/ui/index.js +14 -4
  63. package/lib/ui/index.min.js +1 -1
  64. package/lib/ui/src/log.js +1 -1
  65. package/lib/ui/src/log.min.js +1 -1
  66. package/lib/vxe-table/style/style.css +146 -63
  67. package/lib/vxe-table/style/style.min.css +1 -1
  68. package/package.json +2 -2
  69. package/packages/grid/src/grid.ts +6 -1
  70. package/packages/locale/lang/ko-KR.ts +515 -515
  71. package/packages/table/module/export/mixin.ts +3 -3
  72. package/packages/table/module/filter/mixin.ts +3 -3
  73. package/packages/table/module/keyboard/mixin.ts +4 -4
  74. package/packages/table/module/menu/mixin.ts +2 -2
  75. package/packages/table/module/validator/mixin.ts +2 -2
  76. package/packages/table/src/body.ts +281 -427
  77. package/packages/table/src/footer.ts +148 -164
  78. package/packages/table/src/header.ts +135 -111
  79. package/packages/table/src/methods.ts +1271 -858
  80. package/packages/table/src/props.ts +9 -3
  81. package/packages/table/src/table.ts +195 -146
  82. package/packages/table/src/util.ts +17 -7
  83. package/packages/ui/index.ts +13 -3
  84. package/styles/components/table.scss +164 -74
  85. /package/es/{iconfont.1736414871619.ttf → iconfont.1736690657500.ttf} +0 -0
  86. /package/es/{iconfont.1736414871619.woff → iconfont.1736690657500.woff} +0 -0
  87. /package/es/{iconfont.1736414871619.woff2 → iconfont.1736690657500.woff2} +0 -0
  88. /package/lib/{iconfont.1736414871619.ttf → iconfont.1736690657500.ttf} +0 -0
  89. /package/lib/{iconfont.1736414871619.woff → iconfont.1736690657500.woff} +0 -0
  90. /package/lib/{iconfont.1736414871619.woff2 → iconfont.1736690657500.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, isNodeElement } from '../../ui/src/dom'
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: any) {
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 tableBody = $xeTable.$refs.tableBody
86
- const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
87
- if (tableBodyElem) {
88
- const { scrollLeft, clientWidth } = tableBodyElem
89
- const endWidth = scrollLeft + clientWidth
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 && scrollLeft < cWidth) {
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(6, visibleSize) }
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
- * 更新数据列的 Map
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 computeRowHeight ($xeTable: any) {
288
- const tableHeader = $xeTable.$refs.tableHeader
289
- const tableBody = $xeTable.$refs.tableBody
290
- const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
291
- const vSize = $xeTable.computeSize
292
- const rowHeightMaps = $xeTable.computeRowHeightMaps
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 = rowHeightMaps[vSize || 'default']
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 { scrollYStore, afterFullData, fullAllDataRowIdData } = internalData
318
- const tableBody = $xeTable.$refs.tableBody
319
- const tableBodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
320
- const { rowHeight } = scrollYStore
321
- if (tableBodyElem) {
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(8, visibleSize) }
747
+ return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(6, visibleSize) }
348
748
  }
349
- return { toVisibleIndex: 0, visibleSize: 8 }
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 tableHeader = $xeTable.$refs.tableHeader
489
- const tableBody = $xeTable.$refs.tableBody
490
- const tableFooter = $xeTable.$refs.tableFooter
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 - 1
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 odiffer = bodyWidth - tableWidth
574
- if (odiffer > 0) {
575
- while (odiffer > 0 && dynamicSize >= 0) {
576
- odiffer--
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 = bodyElem.scrollHeight > bodyElem.clientHeight
585
- let scrollbarWidth = 0
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
- let headerHeight = 0
594
- if (headerElem) {
595
- headerHeight = headerElem.clientHeight
596
- $xeTable.$nextTick(() => {
597
- // 检测是否同步滚动
598
- if (headerElem && bodyElem && headerElem.scrollLeft !== bodyElem.scrollLeft) {
599
- headerElem.scrollLeft = bodyElem.scrollLeft
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.leftContainer as HTMLDivElement
1228
+ const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
842
1229
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
843
- const rightContainerElem = $xeTable.$refs.rightContainer as HTMLDivElement
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) : (browse.edge ? 5 : 0))
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) : (browse.edge ? 10 : 0))
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 as any).updateStyle()
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 { tableHeight, scrollYStore } = internalData
1011
- const { startIndex, endIndex, offsetSize } = scrollYStore
1012
- const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + Math.min(8, Math.ceil(tableHeight / 200))
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.bodyScrollType = ''
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
- this.updateStyle()
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).then(resolve)
1972
+ restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
1973
+ .then(() => {
1974
+ resolve()
1975
+ })
1352
1976
  } else {
1353
- setTimeout(() => restoreScrollLocation(this, targetScrollLeft, targetScrollTop).then(resolve))
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 this.handleColumn(collectColumn)
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
- initColumnSort () {
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
- this.collectColumn = collectColumn
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.tableBody
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}`)
@@ -2357,13 +2944,18 @@ const Methods = {
2357
2944
  * 只对 tree-config 有效,获取行的父级
2358
2945
  */
2359
2946
  getTreeParentRow (rowOrRowid: any) {
2360
- const { treeConfig, fullDataRowIdData } = this
2947
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2948
+ const props = $xeTable
2949
+ const internalData = $xeTable as unknown as TableInternalData
2950
+
2951
+ const { treeConfig } = props
2952
+ const { fullDataRowIdData } = internalData
2361
2953
  if (rowOrRowid && treeConfig) {
2362
2954
  let rowid
2363
2955
  if (XEUtils.isString(rowOrRowid)) {
2364
2956
  rowid = rowOrRowid
2365
2957
  } else {
2366
- rowid = getRowid(this, rowOrRowid)
2958
+ rowid = getRowid($xeTable, rowOrRowid)
2367
2959
  }
2368
2960
  if (rowid) {
2369
2961
  const rest = fullDataRowIdData[rowid]
@@ -2373,7 +2965,7 @@ const Methods = {
2373
2965
  return null
2374
2966
  },
2375
2967
  getParentRow (rowOrRowid: any) {
2376
- const $xeTable = this
2968
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2377
2969
 
2378
2970
  warnLog('vxe.error.delFunc', ['getParentRow', 'getTreeParentRow'])
2379
2971
  return $xeTable.getTreeParentRow(rowOrRowid)
@@ -2391,11 +2983,13 @@ const Methods = {
2391
2983
  * 根据行获取行的唯一主键
2392
2984
  * @param {Row} row 行对象
2393
2985
  */
2394
- getRowid (row: any) {
2395
- const $xeTable = this
2986
+ getRowid (cellValue: any) {
2987
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2988
+ const internalData = $xeTable as unknown as TableInternalData
2396
2989
 
2397
- const rowid = XEUtils.get(row, getRowkey($xeTable))
2398
- return XEUtils.eqNull(rowid) ? '' : encodeURIComponent(rowid)
2990
+ const { fullDataRowIdData } = internalData
2991
+ const rowid = XEUtils.eqNull(cellValue) ? '' : encodeURIComponent(cellValue || '')
2992
+ return fullDataRowIdData[rowid] ? fullDataRowIdData[rowid].row : null
2399
2993
  },
2400
2994
  /**
2401
2995
  * 获取处理后的表格数据
@@ -2415,22 +3009,27 @@ const Methods = {
2415
3009
  * 获取表格的全量数据,如果是 tree-config 则返回带层级的树结构
2416
3010
  */
2417
3011
  getFullData () {
2418
- const $xeTable = this
3012
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2419
3013
  const props = $xeTable
2420
- const internalData = $xeTable
3014
+ const internalData = $xeTable as unknown as TableInternalData
2421
3015
 
2422
3016
  const { treeConfig } = props
2423
3017
  const { tableFullData, tableFullTreeData } = internalData
2424
3018
  if (treeConfig) {
2425
3019
  const treeOpts = $xeTable.computeTreeOpts
2426
- const { transform, mapChildrenField } = treeOpts
3020
+ const { transform, mapChildrenField, rowField, parentField } = treeOpts
2427
3021
  const childrenField = treeOpts.children || treeOpts.childrenField
2428
3022
  if (transform) {
2429
3023
  return XEUtils.toArrayTree(
2430
3024
  XEUtils.toTreeArray(tableFullTreeData, {
2431
3025
  children: mapChildrenField
2432
3026
  }),
2433
- { children: childrenField }
3027
+ {
3028
+ key: rowField,
3029
+ parentKey: parentField,
3030
+ children: childrenField,
3031
+ mapChildren: mapChildrenField
3032
+ }
2434
3033
  )
2435
3034
  }
2436
3035
  return tableFullTreeData.slice(0)
@@ -2592,8 +3191,8 @@ const Methods = {
2592
3191
  const colWidth = XEUtils.toInteger(width)
2593
3192
  let rdWidth = colWidth
2594
3193
  if (isScale(width)) {
2595
- const tableBody = $xeTable.$refs.tableBody
2596
- const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
3194
+ const refTableBody = $xeTable.$refs.refTableBody
3195
+ const bodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
2597
3196
  const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0
2598
3197
  rdWidth = Math.floor(colWidth * bodyWidth)
2599
3198
  }
@@ -2839,143 +3438,17 @@ const Methods = {
2839
3438
  * 刷新列配置
2840
3439
  */
2841
3440
  refreshColumn (initSort?: boolean) {
3441
+ const $xeTable = this
3442
+
2842
3443
  if (initSort) {
2843
- this.handleUpdateColumn()
3444
+ handleUpdateColumn($xeTable)
2844
3445
  }
2845
- return this.parseColumns(true).then(() => {
3446
+ return parseColumns($xeTable, true).then(() => {
2846
3447
  return this.refreshScroll()
2847
3448
  }).then(() => {
2848
3449
  return this.recalculate()
2849
3450
  })
2850
3451
  },
2851
- /**
2852
- * 刷新列信息
2853
- * 将固定的列左边、右边分别靠边
2854
- */
2855
- parseColumns (isReset: boolean) {
2856
- const $xeTable = this
2857
- const props = $xeTable
2858
- const internalData = $xeTable
2859
-
2860
- const { showOverflow } = props
2861
- const rowOpts = $xeTable.computeRowOpts
2862
- const leftList: any[] = []
2863
- const centerList: any[] = []
2864
- const rightList: any[] = []
2865
- const { collectColumn, tableFullColumn, isGroup, columnStore, sXOpts, scrollXStore, fullColumnIdData } = this
2866
- // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
2867
- if (isGroup) {
2868
- const leftGroupList: any[] = []
2869
- const centerGroupList: any[] = []
2870
- const rightGroupList: any[] = []
2871
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
2872
- const isColGroup = hasChildrenList(column)
2873
- // 如果是分组,必须按组设置固定列,不允许给子列设置固定
2874
- if (parentColumn && parentColumn.fixed) {
2875
- column.fixed = parentColumn.fixed
2876
- }
2877
- if (parentColumn && column.fixed !== parentColumn.fixed) {
2878
- errLog('vxe.error.groupFixed')
2879
- }
2880
- if (isColGroup) {
2881
- column.visible = !!XEUtils.findTree(column.children, (subColumn: any) => hasChildrenList(subColumn) ? null : subColumn.visible)
2882
- } else if (column.visible) {
2883
- if (column.fixed === 'left') {
2884
- leftList.push(column)
2885
- } else if (column.fixed === 'right') {
2886
- rightList.push(column)
2887
- } else {
2888
- centerList.push(column)
2889
- }
2890
- }
2891
- })
2892
- collectColumn.forEach((column: any) => {
2893
- if (column.visible) {
2894
- if (column.fixed === 'left') {
2895
- leftGroupList.push(column)
2896
- } else if (column.fixed === 'right') {
2897
- rightGroupList.push(column)
2898
- } else {
2899
- centerGroupList.push(column)
2900
- }
2901
- }
2902
- })
2903
- this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList)
2904
- } else {
2905
- // 重新分配列
2906
- tableFullColumn.forEach((column: any) => {
2907
- 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
- }
2918
- const visibleColumn = leftList.concat(centerList).concat(rightList)
2919
- // 如果gt为0,则总是启用
2920
- const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length)
2921
- this.hasFixedColumn = leftList.length > 0 || rightList.length > 0
2922
- Object.assign(columnStore, { leftList, centerList, rightList })
2923
- if (scrollXLoad) {
2924
- if (showOverflow) {
2925
- if (!rowOpts.height) {
2926
- const errColumn = internalData.tableFullColumn.find((column: any) => column.showOverflow === false)
2927
- if (errColumn) {
2928
- errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
2929
- }
2930
- }
2931
- }
2932
- if (process.env.VUE_APP_VXE_ENV === 'development') {
2933
- // if (this.showHeader && !this.showHeaderOverflow) {
2934
- // warnLog('vxe.error.reqProp', ['show-header-overflow'])
2935
- // }
2936
- // if (this.showFooter && !this.showFooterOverflow) {
2937
- // warnLog('vxe.error.reqProp', ['show-footer-overflow'])
2938
- // }
2939
- if (this.spanMethod) {
2940
- warnLog('vxe.error.scrollErrProp', ['span-method'])
2941
- }
2942
- if (this.footerSpanMethod) {
2943
- warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
2944
- }
2945
- }
2946
- if (isReset) {
2947
- const { visibleSize } = handleVirtualXVisible(this)
2948
- scrollXStore.startIndex = 0
2949
- scrollXStore.endIndex = visibleSize
2950
- scrollXStore.visibleSize = visibleSize
2951
- }
2952
- }
2953
- // 如果列被显示/隐藏,则清除合并状态
2954
- // 如果列被设置为固定,则清除合并状态
2955
- if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column: any, index: any) => column === visibleColumn[index])) {
2956
- this.clearMergeCells()
2957
- this.clearMergeFooterItems()
2958
- }
2959
- this.scrollXLoad = scrollXLoad
2960
- visibleColumn.forEach((column, index) => {
2961
- const colid = column.id
2962
- const colRest = fullColumnIdData[colid]
2963
- if (colRest) {
2964
- colRest._index = index
2965
- }
2966
- })
2967
- this.visibleColumn = visibleColumn
2968
- this.handleTableColumn()
2969
- if (isReset) {
2970
- return this.updateFooter().then(() => {
2971
- return this.recalculate()
2972
- }).then(() => {
2973
- this.updateCellAreas()
2974
- return this.recalculate()
2975
- })
2976
- }
2977
- return this.updateFooter()
2978
- },
2979
3452
  /**
2980
3453
  * 指定列宽的列进行拆分
2981
3454
  */
@@ -3056,408 +3529,112 @@ const Methods = {
3056
3529
  * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
3057
3530
  */
3058
3531
  refreshScroll () {
3059
- const { lastScrollLeft, lastScrollTop } = this
3060
- const { $refs } = this
3061
- const { tableBody, leftBody, rightBody, tableFooter } = $refs
3062
- const tableBodyElem = tableBody ? tableBody.$el : null
3063
- const leftBodyElem = leftBody ? leftBody.$el : null
3064
- const rightBodyElem = rightBody ? rightBody.$el : null
3065
- const tableFooterElem = tableFooter ? tableFooter.$el : null
3066
- return new Promise(resolve => {
3067
- // 还原滚动条位置
3068
- if (lastScrollLeft || lastScrollTop) {
3069
- return restoreScrollLocation(this, lastScrollLeft, lastScrollTop).then(() => {
3070
- // 存在滚动行为未结束情况
3071
- setTimeout(resolve, 30)
3072
- })
3073
- }
3074
- // 重置
3075
- setScrollTop(tableBodyElem, lastScrollTop)
3076
- setScrollTop(leftBodyElem, lastScrollTop)
3077
- setScrollTop(rightBodyElem, lastScrollTop)
3078
- setScrollLeft(tableFooterElem, lastScrollLeft)
3079
- // 存在滚动行为未结束情况
3080
- setTimeout(resolve, 30)
3081
- })
3082
- },
3083
- /**
3084
- * 重新渲染布局
3085
- * 刷新布局
3086
- */
3087
- recalculate (reFull?: boolean) {
3088
- const $xeTable = this
3089
- const internalData = $xeTable
3532
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3533
+ const internalData = $xeTable as unknown as TableInternalData
3090
3534
 
3535
+ const { elemStore, lastScrollLeft, lastScrollTop } = internalData
3536
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
3537
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
3538
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
3539
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
3540
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
3541
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
3542
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
3091
3543
  return new Promise<void>(resolve => {
3092
- const { rceTimeout, rceRunTime } = internalData
3093
- const resizeOpts = $xeTable.computeResizeOpts
3094
- const refreshDelay = resizeOpts.refreshDelay || 20
3095
- const el = $xeTable.$refs.refElem as HTMLElement
3096
- if (el && el.clientWidth) {
3097
- autoCellWidth($xeTable)
3098
- }
3099
- if (rceTimeout) {
3100
- clearTimeout(rceTimeout)
3101
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3102
- resolve(
3103
- handleRecalculateLayout($xeTable, !!reFull)
3104
- )
3105
- } else {
3106
- $xeTable.$nextTick(() => {
3107
- resolve()
3108
- })
3109
- }
3110
- } else {
3111
- resolve(
3112
- handleRecalculateLayout($xeTable, !!reFull)
3113
- )
3114
- }
3115
- internalData.rceTimeout = setTimeout(() => {
3116
- internalData.rceTimeout = undefined
3117
- handleRecalculateLayout($xeTable, !!reFull)
3118
- }, refreshDelay)
3119
- })
3120
- },
3121
- updateStyle () {
3122
- const $xeTable = this
3123
-
3124
- let {
3125
- $refs,
3126
- isGroup,
3127
- fullColumnIdData,
3128
- tableColumn,
3129
- customHeight,
3130
- customMinHeight,
3131
- customMaxHeight,
3132
- border,
3133
- headerHeight,
3134
- showFooter,
3135
- showOverflow: allColumnOverflow,
3136
- showHeaderOverflow: allColumnHeaderOverflow,
3137
- showFooterOverflow: allColumnFooterOverflow,
3138
- footerHeight,
3139
- tableHeight,
3140
- tableWidth,
3141
- scrollbarHeight,
3142
- scrollbarWidth,
3143
- scrollXLoad,
3144
- scrollYLoad,
3145
- overflowX,
3146
- cellOffsetWidth,
3147
- columnStore,
3148
- elemStore,
3149
- editStore,
3150
- currentRow,
3151
- mouseConfig,
3152
- spanMethod,
3153
- expandColumn,
3154
- footerSpanMethod,
3155
- isAllOverflow,
3156
- visibleColumn
3157
- } = $xeTable
3158
- const containerList = ['main', 'left', 'right']
3159
- const emptyPlaceholderElem = $refs.emptyPlaceholder
3160
- const bodyWrapperElem = elemStore['main-body-wrapper']
3161
- if (emptyPlaceholderElem) {
3162
- emptyPlaceholderElem.style.top = `${headerHeight}px`
3163
- emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : ''
3164
- }
3165
- if (customHeight > 0) {
3166
- if (showFooter) {
3167
- customHeight += scrollbarHeight
3168
- }
3169
- }
3170
-
3171
- const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem
3172
- if (scrollXVirtualEl) {
3173
- scrollXVirtualEl.style.height = `${scrollbarHeight}px`
3174
- }
3175
-
3176
- const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem
3177
- if (scrollYVirtualEl) {
3178
- let bodyHeight = 0
3179
- let bodyMaxHeight = 0
3180
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight
3181
- if (customMaxHeight) {
3182
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight
3183
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight)
3184
- }
3185
- if (customHeight) {
3186
- bodyHeight = customHeight - headerHeight - footerHeight
3187
- if (bodyMaxHeight) {
3188
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
3189
- }
3190
- bodyHeight = Math.max(bodyMinHeight, bodyHeight)
3191
- }
3192
- scrollYVirtualEl.style.top = `${headerHeight}px`
3193
- scrollYVirtualEl.style.width = `${scrollbarWidth}px`
3194
- scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`
3195
- }
3196
-
3197
- containerList.forEach((name, index) => {
3198
- const fixedType = index > 0 ? name : ''
3199
- const layoutList = ['header', 'body', 'footer']
3200
- const fixedColumn = columnStore[`${fixedType}List`]
3201
- const fixedWrapperElem = $refs[`${fixedType}Container`]
3202
- layoutList.forEach(layout => {
3203
- const wrapperElem = elemStore[`${name}-${layout}-wrapper`]
3204
- const tableElem = elemStore[`${name}-${layout}-table`]
3205
- if (layout === 'header') {
3206
- // 表头体样式处理
3207
- // 横向滚动渲染
3208
- let tWidth = tableWidth
3209
- let renderColumnList = tableColumn
3210
-
3211
- if (isGroup) {
3212
- renderColumnList = visibleColumn
3213
- } else {
3214
- if (fixedType) {
3215
- // 如果是使用优化模式
3216
- if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
3217
- // 如果不支持优化模式
3218
- if (spanMethod || footerSpanMethod) {
3219
- renderColumnList = visibleColumn
3220
- } else {
3221
- renderColumnList = fixedColumn || []
3222
- }
3223
- } else {
3224
- renderColumnList = visibleColumn
3225
- }
3226
- }
3227
- }
3228
-
3229
- tWidth = renderColumnList.reduce((previous: any, column: any) => previous + column.renderWidth, 0)
3230
-
3231
- if (tableElem) {
3232
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : ''
3233
- // 修复 IE 中高度无法自适应问题
3234
- if (browse.msie) {
3235
- XEUtils.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), (resizeElem: any) => {
3236
- resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`
3237
- })
3238
- }
3239
- }
3240
-
3241
- const repairElem = elemStore[`${name}-${layout}-repair`]
3242
- if (repairElem) {
3243
- repairElem.style.width = `${tableWidth}px`
3244
- }
3245
-
3246
- const listElem = elemStore[`${name}-${layout}-list`]
3247
- if (isGroup && listElem) {
3248
- XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem: HTMLTableRowElement) => {
3249
- const colNode = this.getColumnNode(thElem)
3250
- if (colNode) {
3251
- const column = colNode.item
3252
- const { showHeaderOverflow } = column
3253
- const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow
3254
- const showEllipsis = cellOverflow === 'ellipsis'
3255
- const showTitle = cellOverflow === 'title'
3256
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
3257
- const hasEllipsis = showTitle || showTooltip || showEllipsis
3258
- let childWidth = 0
3259
- let countChild = 0
3260
- if (hasEllipsis) {
3261
- XEUtils.eachTree(column.children, item => {
3262
- if (!item.children || !column.children.length) {
3263
- countChild++
3264
- }
3265
- childWidth += item.renderWidth
3266
- })
3267
- }
3268
- thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : ''
3269
- }
3270
- })
3271
- }
3272
- } else if (layout === 'body') {
3273
- const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`]
3274
- if (isNodeElement(wrapperElem)) {
3275
- let bodyMaxHeight = 0
3276
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight
3277
- if (customMaxHeight) {
3278
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight
3279
- // 如果是固定列
3280
- if (fixedType) {
3281
- bodyMaxHeight -= (showFooter ? 0 : scrollbarHeight)
3282
- }
3283
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight)
3284
- wrapperElem.style.maxHeight = `${bodyMaxHeight}px`
3285
- }
3286
- if (customHeight) {
3287
- let bodyHeight = customHeight - headerHeight - footerHeight
3288
- // 如果是固定列
3289
- if (fixedType) {
3290
- bodyHeight -= (showFooter ? 0 : scrollbarHeight)
3291
- }
3292
- if (bodyMaxHeight) {
3293
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
3294
- }
3295
- wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`
3296
- } else {
3297
- wrapperElem.style.height = ''
3298
- }
3299
- wrapperElem.style.minHeight = `${bodyMinHeight}px`
3300
- }
3301
-
3302
- // 如果是固定列
3303
- if (fixedWrapperElem) {
3304
- const isRightFixed = fixedType === 'right'
3305
- const fixedColumn = columnStore[`${fixedType}List`]
3306
- if (isNodeElement(wrapperElem)) {
3307
- wrapperElem.style.top = `${headerHeight}px`
3308
- }
3309
- fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`
3310
- fixedWrapperElem.style.width = `${fixedColumn.reduce((previous: any, column: any) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`
3311
- }
3312
-
3313
- let tWidth = tableWidth
3314
- let renderColumnList = tableColumn
3315
-
3316
- if (fixedType) {
3317
- // 如果是使用优化模式
3318
- if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
3319
- // 如果不支持优化模式
3320
- if (expandColumn || spanMethod || footerSpanMethod) {
3321
- renderColumnList = visibleColumn
3322
- } else {
3323
- renderColumnList = fixedColumn || []
3324
- }
3325
- } else {
3326
- renderColumnList = visibleColumn
3327
- }
3328
- }
3329
-
3330
- tWidth = renderColumnList.reduce((previous: any, column: any) => previous + column.renderWidth, 0)
3331
-
3332
- if (tableElem) {
3333
- tableElem.style.width = tWidth ? `${tWidth}px` : ''
3334
- // 兼容性处理
3335
- tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : ''
3336
- }
3337
- if (emptyBlockElem) {
3338
- emptyBlockElem.style.width = tWidth ? `${tWidth}px` : ''
3339
- }
3340
- } else if (layout === 'footer') {
3341
- let tWidth = tableWidth
3342
- let renderColumnList = tableColumn
3343
-
3344
- if (fixedType) {
3345
- // 如果是使用优化模式
3346
- if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
3347
- // 如果不支持优化模式
3348
- if (spanMethod || footerSpanMethod) {
3349
- renderColumnList = visibleColumn
3350
- } else {
3351
- renderColumnList = fixedColumn || []
3352
- }
3353
- } else {
3354
- renderColumnList = visibleColumn
3355
- }
3356
- }
3357
-
3358
- tWidth = renderColumnList.reduce((previous: any, column: any) => previous + column.renderWidth, 0)
3359
-
3360
- if (isNodeElement(wrapperElem)) {
3361
- // 如果是固定列
3362
- if (fixedWrapperElem) {
3363
- wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`
3364
- }
3365
- wrapperElem.style.marginTop = `${-scrollbarHeight}px`
3366
- }
3367
- if (tableElem) {
3368
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : ''
3369
- }
3370
- }
3371
- const colgroupElem = elemStore[`${name}-${layout}-colgroup`]
3372
- if (colgroupElem) {
3373
- XEUtils.arrayEach(colgroupElem.children, (colElem: any) => {
3374
- const colid = colElem.getAttribute('name')
3375
- if (colid === 'col_gutter') {
3376
- colElem.style.width = `${scrollbarWidth}px`
3377
- }
3378
- if (fullColumnIdData[colid]) {
3379
- const colRest = fullColumnIdData[colid]
3380
- const column = colRest.column
3381
- const { showHeaderOverflow, showFooterOverflow, showOverflow } = column
3382
- let cellOverflow
3383
- colElem.style.width = `${column.renderWidth}px`
3384
- if (layout === 'header') {
3385
- cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
3386
- } else if (layout === 'footer') {
3387
- cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
3388
- } else {
3389
- cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow
3390
- }
3391
- const showEllipsis = cellOverflow === 'ellipsis'
3392
- const showTitle = cellOverflow === 'title'
3393
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
3394
- let hasEllipsis = showTitle || showTooltip || showEllipsis
3395
- const listElem = elemStore[`${name}-${layout}-list`]
3396
- // 滚动的渲染不支持动态行高
3397
- if (layout === 'header' || layout === 'footer') {
3398
- if (scrollXLoad && !hasEllipsis) {
3399
- hasEllipsis = true
3400
- }
3401
- } else {
3402
- if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
3403
- hasEllipsis = true
3404
- }
3405
- }
3406
- if (listElem) {
3407
- XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem: any) => {
3408
- const colspan = parseInt(elem.getAttribute('colspan') || 1)
3409
- const cellElem = elem.querySelector('.vxe-cell')
3410
- let colWidth = column.renderWidth
3411
- if (cellElem) {
3412
- if (colspan > 1) {
3413
- const columnIndex = this.getColumnIndex(column)
3414
- for (let index = 1; index < colspan; index++) {
3415
- const nextColumn = this.getColumns(columnIndex + index)
3416
- if (nextColumn) {
3417
- colWidth += nextColumn.renderWidth
3418
- }
3419
- }
3420
- }
3421
- cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : ''
3422
- }
3423
- })
3424
- }
3425
- }
3544
+ // 还原滚动条位置
3545
+ if (lastScrollLeft || lastScrollTop) {
3546
+ return restoreScrollLocation($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
3547
+ // 存在滚动行为未结束情况
3548
+ setTimeout(resolve, 10)
3549
+ })
3550
+ }
3551
+ internalData.intoRunScroll = true
3552
+ // 重置
3553
+ setScrollTop(yHandleEl, lastScrollTop)
3554
+ setScrollTop(bodyScrollElem, lastScrollTop)
3555
+ setScrollTop(leftScrollElem, lastScrollTop)
3556
+ setScrollTop(rightScrollElem, lastScrollTop)
3557
+
3558
+ setScrollLeft(xHandleEl, lastScrollLeft)
3559
+ setScrollLeft(bodyScrollElem, lastScrollLeft)
3560
+ setScrollLeft(headerScrollElem, lastScrollLeft)
3561
+ setScrollLeft(footerScrollElem, lastScrollLeft)
3562
+ // 存在滚动行为未结束情况
3563
+ setTimeout(() => {
3564
+ internalData.intoRunScroll = false
3565
+ resolve()
3566
+ }, 10)
3567
+ })
3568
+ },
3569
+ /**
3570
+ * 重新渲染布局
3571
+ * 刷新布局
3572
+ */
3573
+ recalculate (reFull?: boolean) {
3574
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3575
+ const internalData = $xeTable as unknown as TableInternalData
3576
+
3577
+ return new Promise<void>(resolve => {
3578
+ const { rceTimeout, rceRunTime } = internalData
3579
+ const resizeOpts = $xeTable.computeResizeOpts
3580
+ const refreshDelay = resizeOpts.refreshDelay || 20
3581
+ const el = $xeTable.$refs.refElem as HTMLElement
3582
+ if (el && el.clientWidth) {
3583
+ autoCellWidth($xeTable)
3584
+ }
3585
+ if (rceTimeout) {
3586
+ clearTimeout(rceTimeout)
3587
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3588
+ resolve(
3589
+ handleRecalculateLayout($xeTable, !!reFull)
3590
+ )
3591
+ } else {
3592
+ $xeTable.$nextTick(() => {
3593
+ resolve()
3426
3594
  })
3427
3595
  }
3428
- })
3596
+ } else {
3597
+ resolve(
3598
+ handleRecalculateLayout($xeTable, !!reFull)
3599
+ )
3600
+ }
3601
+ internalData.rceTimeout = setTimeout(() => {
3602
+ internalData.rceTimeout = undefined
3603
+ handleRecalculateLayout($xeTable, !!reFull)
3604
+ }, refreshDelay)
3429
3605
  })
3430
- if (currentRow) {
3431
- this.setCurrentRow(currentRow)
3432
- }
3433
- if (mouseConfig && mouseConfig.selected && editStore.selected.row && editStore.selected.column) {
3434
- this.addColSdCls()
3435
- }
3436
- return this.$nextTick()
3606
+ },
3607
+ updateStyle () {
3608
+ const $xeTable = this
3609
+
3610
+ return updateStyle($xeTable)
3437
3611
  },
3438
3612
  /**
3439
3613
  * 处理固定列的显示状态
3440
3614
  */
3441
3615
  checkScrolling () {
3442
- const $xeTable = this
3616
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3617
+ const internalData = $xeTable as unknown as TableInternalData
3443
3618
 
3444
- const { tableBody, leftContainer, rightContainer } = $xeTable.$refs
3445
- const bodyElem = tableBody ? tableBody.$el : null
3619
+ const { elemStore } = internalData
3620
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
3621
+ const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
3622
+ const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
3446
3623
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
3447
- const bodtTargetEl = xHandleEl || bodyElem
3624
+ const bodtTargetEl = xHandleEl || bodyScrollElem
3448
3625
  if (bodtTargetEl) {
3449
- if (leftContainer) {
3626
+ if (leftContainerElem) {
3450
3627
  if (bodtTargetEl.scrollLeft > 0) {
3451
- addClass(leftContainer, 'scrolling--middle')
3628
+ addClass(leftContainerElem, 'scrolling--middle')
3452
3629
  } else {
3453
- removeClass(leftContainer, 'scrolling--middle')
3630
+ removeClass(leftContainerElem, 'scrolling--middle')
3454
3631
  }
3455
3632
  }
3456
- if (rightContainer) {
3633
+ if (rightContainerElem) {
3457
3634
  if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
3458
- addClass(rightContainer, 'scrolling--middle')
3635
+ addClass(rightContainerElem, 'scrolling--middle')
3459
3636
  } else {
3460
- removeClass(rightContainer, 'scrolling--middle')
3637
+ removeClass(rightContainerElem, 'scrolling--middle')
3461
3638
  }
3462
3639
  }
3463
3640
  }
@@ -3493,7 +3670,7 @@ const Methods = {
3493
3670
  handleGlobalMousedownEvent (evnt: any) {
3494
3671
  const { $el, $refs, $xegrid, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this
3495
3672
  const { actived } = editStore
3496
- const { ctxWrapper, filterWrapper, customWrapper, validTip } = $refs
3673
+ const { refTableMenu, filterWrapper, customWrapper, refValidTooltip } = $refs
3497
3674
  // 筛选
3498
3675
  if (filterWrapper) {
3499
3676
  if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {
@@ -3525,7 +3702,7 @@ const Methods = {
3525
3702
  // 如果是激活状态,点击了单元格之外
3526
3703
  const cell = actived.args.cell
3527
3704
  if ((!cell || !getEventTargetNode(evnt, cell).flag)) {
3528
- if (validTip && getEventTargetNode(evnt, validTip.$el).flag) {
3705
+ if (refValidTooltip && getEventTargetNode(evnt, refValidTooltip.$el).flag) {
3529
3706
  // 如果是激活状态,且点击了校验提示框
3530
3707
  } else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
3531
3708
  if (!getEventTargetNode(evnt, document.body, 'vxe-table--ignore-clear').flag) {
@@ -3575,7 +3752,7 @@ const Methods = {
3575
3752
  }
3576
3753
  }
3577
3754
  } else if (mouseConfig) {
3578
- if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(ctxWrapper && getEventTargetNode(evnt, ctxWrapper.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
3755
+ if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(refTableMenu && getEventTargetNode(evnt, refTableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
3579
3756
  if (this.clearSelected) {
3580
3757
  this.clearSelected()
3581
3758
  }
@@ -3594,7 +3771,7 @@ const Methods = {
3594
3771
  }
3595
3772
  }
3596
3773
  // 如果配置了快捷菜单且,点击了其他地方则关闭
3597
- if (ctxMenuStore.visible && ctxWrapper && !getEventTargetNode(evnt, ctxWrapper.$el).flag) {
3774
+ if (ctxMenuStore.visible && refTableMenu && !getEventTargetNode(evnt, refTableMenu.$el).flag) {
3598
3775
  this.closeMenu()
3599
3776
  }
3600
3777
  const isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag
@@ -3725,8 +3902,8 @@ const Methods = {
3725
3902
  } else if (isContextMenu) {
3726
3903
  // 如果按下上下文键
3727
3904
  this._keyCtx = selected.row && selected.column && bodyCtxMenu.length
3728
- clearTimeout(this.keyCtxTimeout)
3729
- this.keyCtxTimeout = setTimeout(() => {
3905
+ clearTimeout(internalData.keyCtxTimeout)
3906
+ internalData.keyCtxTimeout = setTimeout(() => {
3730
3907
  this._keyCtx = false
3731
3908
  }, 1000)
3732
3909
  } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
@@ -4071,6 +4248,11 @@ const Methods = {
4071
4248
  * @param {Row} row 行对象
4072
4249
  */
4073
4250
  handleTooltip (evnt: any, cell: any, overflowElem: any, tipElem: any, params: any) {
4251
+ const $xeTable = this
4252
+
4253
+ if (!overflowElem) {
4254
+ return $xeTable.$nextTick()
4255
+ }
4074
4256
  params.cell = cell
4075
4257
  const { $refs, tooltipOpts, tooltipStore } = this
4076
4258
  const { column, row } = params
@@ -4097,7 +4279,7 @@ const Methods = {
4097
4279
  },
4098
4280
  openTooltip (target: any, content: any) {
4099
4281
  const { $refs } = this
4100
- const commTip = $refs.commTip
4282
+ const commTip = $refs.refCommTooltip
4101
4283
  if (commTip) {
4102
4284
  return commTip.open(target, content)
4103
4285
  }
@@ -4109,7 +4291,7 @@ const Methods = {
4109
4291
  closeTooltip () {
4110
4292
  const { $refs, tooltipStore } = this
4111
4293
  const tooltip = $refs.tooltip
4112
- const commTip = $refs.commTip
4294
+ const commTip = $refs.refCommTooltip
4113
4295
  if (tooltipStore.visible) {
4114
4296
  Object.assign(tooltipStore, {
4115
4297
  row: null,
@@ -5291,6 +5473,8 @@ const Methods = {
5291
5473
  this.emitEvent('cell-dblclick', params, evnt)
5292
5474
  },
5293
5475
  handleDefaultSort () {
5476
+ const $xeTable = this
5477
+
5294
5478
  const { sortConfig, sortOpts } = this
5295
5479
  let { defaultSort } = sortOpts
5296
5480
  if (defaultSort) {
@@ -5309,7 +5493,7 @@ const Methods = {
5309
5493
  }
5310
5494
  })
5311
5495
  if (!sortOpts.remote) {
5312
- this.handleTableData(true).then(this.updateStyle)
5496
+ this.handleTableData(true).then(() => updateStyle($xeTable))
5313
5497
  }
5314
5498
  }
5315
5499
  }
@@ -5751,8 +5935,8 @@ const Methods = {
5751
5935
  handleColDragSwapColumn () {
5752
5936
  const $xeTable = this
5753
5937
 
5754
- $xeTable.handleUpdateColumn()
5755
- $xeTable.parseColumns(false).then(() => {
5938
+ handleUpdateColumn($xeTable)
5939
+ parseColumns($xeTable, false).then(() => {
5756
5940
  $xeTable.updateCellAreas()
5757
5941
  $xeTable.saveCustomStore('update:sort')
5758
5942
  })
@@ -5994,15 +6178,15 @@ const Methods = {
5994
6178
  return
5995
6179
  }
5996
6180
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
5997
- const tableBody = $xeTable.$refs.tableBody
5998
- const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
6181
+ const refTableBody = $xeTable.$refs.refTableBody
6182
+ const tableBodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
5999
6183
  const scrollTargetEl = xHandleEl || tableBodyElem
6000
6184
  if (scrollTargetEl) {
6001
6185
  const wrapperRect = el.getBoundingClientRect()
6002
6186
  const tableWidth = el.clientWidth
6003
- const leftContainerElem = $xeTable.$refs.leftContainer as HTMLDivElement
6187
+ const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
6004
6188
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
6005
- const rightContainerElem = $xeTable.$refs.rightContainer as HTMLDivElement
6189
+ const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
6006
6190
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0
6007
6191
  const srartX = wrapperRect.x + leftContainerWidth
6008
6192
  const endX = wrapperRect.x + tableWidth - rightContainerWidth
@@ -6127,6 +6311,8 @@ const Methods = {
6127
6311
  return this.$nextTick()
6128
6312
  },
6129
6313
  sort (sortConfs: any, sortOrder: any) {
6314
+ const $xeTable = this
6315
+
6130
6316
  const { sortOpts } = this
6131
6317
  const { multiple, remote, orders } = sortOpts
6132
6318
  if (sortConfs) {
@@ -6169,7 +6355,7 @@ const Methods = {
6169
6355
  }
6170
6356
  return this.$nextTick().then(() => {
6171
6357
  this.updateCellAreas()
6172
- return this.updateStyle()
6358
+ return updateStyle($xeTable)
6173
6359
  })
6174
6360
  }
6175
6361
  return this.$nextTick()
@@ -6215,7 +6401,7 @@ const Methods = {
6215
6401
  }
6216
6402
  return $xeTable.$nextTick().then(() => {
6217
6403
  $xeTable.updateCellAreas()
6218
- return $xeTable.updateStyle()
6404
+ return updateStyle($xeTable)
6219
6405
  })
6220
6406
  }
6221
6407
  return $xeTable.$nextTick()
@@ -6226,6 +6412,8 @@ const Methods = {
6226
6412
  * @param {String} column 列或字段名
6227
6413
  */
6228
6414
  clearSort (fieldOrColumn: any) {
6415
+ const $xeTable = this
6416
+
6229
6417
  const { sortOpts } = this
6230
6418
  if (fieldOrColumn) {
6231
6419
  const column = handleFieldOrColumn(this, fieldOrColumn)
@@ -6238,7 +6426,7 @@ const Methods = {
6238
6426
  if (!sortOpts.remote) {
6239
6427
  this.handleTableData(true)
6240
6428
  }
6241
- return this.$nextTick().then(this.updateStyle)
6429
+ return this.$nextTick().then(() => updateStyle($xeTable))
6242
6430
  },
6243
6431
  // 在 v3 中废弃
6244
6432
  getSortColumn () {
@@ -6942,7 +7130,7 @@ const Methods = {
6942
7130
  */
6943
7131
  getScroll () {
6944
7132
  const { $refs, scrollXLoad, scrollYLoad } = this
6945
- const bodyElem = $refs.tableBody.$el
7133
+ const bodyElem = $refs.refTableBody.$el
6946
7134
  return {
6947
7135
  virtualX: scrollXLoad,
6948
7136
  virtualY: scrollYLoad,
@@ -6951,22 +7139,25 @@ const Methods = {
6951
7139
  }
6952
7140
  },
6953
7141
  handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number, params: any) {
6954
- const $xeTable = this
7142
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6955
7143
  const props = $xeTable
6956
- const reactData = $xeTable
6957
- const internalData = $xeTable
7144
+ const reactData = $xeTable as unknown as TableReactData
7145
+ const internalData = $xeTable as unknown as TableInternalData
6958
7146
 
6959
7147
  const { highlightHoverRow } = props
6960
7148
  const { lastScrollLeft, lastScrollTop } = internalData
6961
- const tableBody = $xeTable.$refs.tableBody
6962
- const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
7149
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7150
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7151
+ if (!xHandleEl || !yHandleEl) {
7152
+ return
7153
+ }
6963
7154
  const rowOpts = $xeTable.computeRowOpts
6964
- const validTip = $xeTable.$refs.validTip
6965
- const tooltip = $xeTable.$refs.tooltip
6966
- const bodyHeight = bodyElem ? bodyElem.clientHeight : 0
6967
- const bodyWidth = bodyElem ? bodyElem.clientWidth : 0
6968
- const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0
6969
- const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0
7155
+ const validTip = $xeTable.$refs.refValidTooltip as VxeTooltipInstance
7156
+ const tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
7157
+ const bodyHeight = yHandleEl.clientHeight
7158
+ const bodyWidth = xHandleEl.clientWidth
7159
+ const scrollHeight = yHandleEl.scrollHeight
7160
+ const scrollWidth = xHandleEl.scrollWidth
6970
7161
  let isTop = false
6971
7162
  let isBottom = false
6972
7163
  let isLeft = false
@@ -7038,13 +7229,12 @@ const Methods = {
7038
7229
  if (rowOpts.isHover || highlightHoverRow) {
7039
7230
  $xeTable.clearHoverRow()
7040
7231
  }
7041
- if (validTip && validTip.visible) {
7232
+ if (validTip && validTip.reactData.visible) {
7042
7233
  validTip.close()
7043
7234
  }
7044
- if (tooltip && tooltip.visible) {
7235
+ if (tooltip && tooltip.reactData.visible) {
7045
7236
  tooltip.close()
7046
7237
  }
7047
-
7048
7238
  if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
7049
7239
  $xeTable.dispatchEvent('scroll-boundary', evntParams, evnt)
7050
7240
  }
@@ -7056,7 +7246,7 @@ const Methods = {
7056
7246
 
7057
7247
  const { lxTimeout, lxRunTime, scrollXStore } = internalData
7058
7248
  const { visibleSize } = scrollXStore
7059
- const fpsTime = Math.min(80, Math.floor(visibleSize * 3))
7249
+ const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)))
7060
7250
  if (lxTimeout) {
7061
7251
  clearTimeout(lxTimeout)
7062
7252
  }
@@ -7072,11 +7262,13 @@ const Methods = {
7072
7262
  },
7073
7263
  lazyScrollYData () {
7074
7264
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7265
+ const props = $xeTable
7075
7266
  const internalData = $xeTable as unknown as TableInternalData
7076
7267
 
7268
+ const { showOverflow } = props
7077
7269
  const { lyTimeout, lyRunTime, scrollYStore } = internalData
7078
7270
  const { visibleSize } = scrollYStore
7079
- const fpsTime = Math.min(80, Math.floor(visibleSize))
7271
+ const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)))
7080
7272
  if (lyTimeout) {
7081
7273
  clearTimeout(lyTimeout)
7082
7274
  }
@@ -7116,29 +7308,258 @@ const Methods = {
7116
7308
  $xeTable.lazyScrollYData()
7117
7309
  }
7118
7310
  },
7119
- scrollXEvent (evnt: Event) {
7120
- const $xeTable = this
7121
- const internalData = $xeTable
7311
+ triggerBodyScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
7312
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7313
+ const internalData = $xeTable as unknown as TableInternalData
7122
7314
 
7123
- const { intoRunScroll, inFooterScroll, inBodyScroll, lastScrollTop } = internalData
7124
- if (!intoRunScroll) {
7125
- if (inFooterScroll) {
7315
+ const { elemStore, lastScrollTop, lastScrollLeft, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll, scrollRenderType, inFooterScroll } = internalData
7316
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7317
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7318
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7319
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7320
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7321
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7322
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7323
+ if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
7324
+ return
7325
+ }
7326
+ if (!bodyScrollElem) {
7327
+ return
7328
+ }
7329
+ if (!xHandleEl) {
7330
+ return
7331
+ }
7332
+ if (!yHandleEl) {
7333
+ return
7334
+ }
7335
+ if (inBodyScroll) {
7336
+ if (scrollRenderType !== fixedType) {
7126
7337
  return
7127
7338
  }
7128
- if (inBodyScroll) {
7129
- return
7339
+ }
7340
+ let scrollTop = yHandleEl.scrollTop
7341
+ let scrollLeft = xHandleEl.scrollLeft
7342
+ if (leftScrollElem && fixedType === 'left') {
7343
+ scrollTop = leftScrollElem.scrollTop
7344
+ } else if (rightScrollElem && fixedType === 'right') {
7345
+ scrollTop = rightScrollElem.scrollTop
7346
+ } else {
7347
+ scrollTop = bodyScrollElem.scrollTop
7348
+ scrollLeft = bodyScrollElem.scrollLeft
7349
+ }
7350
+ const isRollX = scrollLeft !== lastScrollLeft
7351
+ const isRollY = scrollTop !== lastScrollTop
7352
+ internalData.inBodyScroll = true
7353
+ internalData.scrollRenderType = fixedType
7354
+ if (isRollY) {
7355
+ if (fixedType === 'left') {
7356
+ setScrollTop(bodyScrollElem, scrollTop)
7357
+ setScrollTop(rightScrollElem, scrollTop)
7358
+ } else if (fixedType === 'right') {
7359
+ setScrollTop(bodyScrollElem, scrollTop)
7360
+ setScrollTop(leftScrollElem, scrollTop)
7361
+ } else {
7362
+ setScrollTop(leftScrollElem, scrollTop)
7363
+ setScrollTop(rightScrollElem, scrollTop)
7130
7364
  }
7365
+ setScrollTop(yHandleEl, scrollTop)
7366
+ $xeTable.triggerScrollYEvent(evnt)
7367
+ }
7368
+ if (isRollX) {
7369
+ setScrollLeft(xHandleEl, scrollLeft)
7370
+ setScrollLeft(headerScrollElem, scrollLeft)
7371
+ setScrollLeft(footerScrollElem, scrollLeft)
7372
+ $xeTable.triggerScrollXEvent(evnt)
7373
+ }
7374
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7375
+ type: 'body',
7376
+ fixed: fixedType
7377
+ })
7378
+ },
7379
+ triggerHeaderScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
7380
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7381
+ const internalData = $xeTable as unknown as TableInternalData
7382
+
7383
+ const { elemStore, inWheelScroll, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData
7384
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7385
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7386
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7387
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7388
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7389
+ if (inWheelScroll) {
7390
+ return
7391
+ }
7392
+ if (inVirtualScroll) {
7393
+ return
7394
+ }
7395
+ if (inBodyScroll) {
7396
+ return
7397
+ }
7398
+ if (inFooterScroll) {
7399
+ return
7400
+ }
7401
+ if (!headerScrollElem) {
7402
+ return
7403
+ }
7404
+ if (!xHandleEl) {
7405
+ return
7406
+ }
7407
+ if (!yHandleEl) {
7408
+ return
7409
+ }
7410
+ const scrollTop = yHandleEl.scrollTop
7411
+ const scrollLeft = headerScrollElem.scrollLeft
7412
+ const isRollX = true
7413
+ const isRollY = false
7414
+ internalData.inHeaderScroll = true
7415
+ setScrollLeft(xHandleEl, scrollLeft)
7416
+ setScrollLeft(footerScrollElem, scrollLeft)
7417
+ setScrollLeft(bodyScrollElem, scrollLeft)
7418
+ $xeTable.triggerScrollXEvent(evnt)
7419
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7420
+ type: 'header',
7421
+ fixed: fixedType
7422
+ })
7423
+ },
7424
+ triggerFooterScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
7425
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7426
+ const internalData = $xeTable as unknown as TableInternalData
7427
+
7428
+ const { elemStore, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData
7429
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7430
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7431
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7432
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7433
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7434
+ if (inWheelScroll) {
7435
+ return
7436
+ }
7437
+ if (inVirtualScroll) {
7438
+ return
7439
+ }
7440
+ if (inHeaderScroll) {
7441
+ return
7442
+ }
7443
+ if (inBodyScroll) {
7444
+ return
7445
+ }
7446
+ if (!footerScrollElem) {
7447
+ return
7448
+ }
7449
+ if (!xHandleEl) {
7450
+ return
7451
+ }
7452
+ if (!yHandleEl) {
7453
+ return
7454
+ }
7455
+ const scrollTop = yHandleEl.scrollTop
7456
+ const scrollLeft = footerScrollElem.scrollLeft
7457
+ const isRollX = true
7458
+ const isRollY = false
7459
+ internalData.inFooterScroll = true
7460
+ setScrollLeft(xHandleEl, scrollLeft)
7461
+ setScrollLeft(headerScrollElem, scrollLeft)
7462
+ setScrollLeft(bodyScrollElem, scrollLeft)
7463
+ $xeTable.triggerScrollXEvent(evnt)
7464
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7465
+ type: 'footer',
7466
+ fixed: fixedType
7467
+ })
7468
+ },
7469
+ triggerBodyWheelEvent (evnt: WheelEvent) {
7470
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7471
+ const tableProps = $xeTable
7472
+ const reactData = $xeTable as unknown as TableReactData
7473
+ const internalData = $xeTable as unknown as TableInternalData
7474
+
7475
+ const { deltaY, deltaX } = evnt
7476
+ const { highlightHoverRow } = tableProps
7477
+ const { elemStore, lastScrollTop, lastScrollLeft } = internalData
7478
+ const rowOpts = $xeTable.computeRowOpts
7479
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7480
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7481
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7482
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7483
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7484
+
7485
+ if (!xHandleEl) {
7486
+ return
7487
+ }
7488
+ if (!yHandleEl) {
7489
+ return
7490
+ }
7491
+ if (!bodyScrollElem) {
7492
+ return
7493
+ }
7494
+
7495
+ let multiple = 1
7496
+
7497
+ if (reactData.lastScrollTime + 25 > Date.now()) {
7498
+ multiple = 1.18
7499
+ } else if (reactData.lastScrollTime + 30 > Date.now()) {
7500
+ multiple = 1.15
7501
+ } else if (reactData.lastScrollTime + 40 > Date.now()) {
7502
+ multiple = 1.12
7503
+ } else if (reactData.lastScrollTime + 55 > Date.now()) {
7504
+ multiple = 1.09
7505
+ } else if (reactData.lastScrollTime + 75 > Date.now()) {
7506
+ multiple = 1.06
7507
+ } else if (reactData.lastScrollTime + 100 > Date.now()) {
7508
+ multiple = 1.03
7509
+ }
7510
+
7511
+ const deltaTop = deltaY * multiple
7512
+ const deltaLeft = deltaX * multiple
7513
+
7514
+ const isTopWheel = deltaTop < 0
7515
+ const currScrollTop = yHandleEl.scrollTop
7516
+ // 如果滚动位置已经是顶部或底部,则不需要触发
7517
+ if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
7518
+ return
7519
+ }
7520
+
7521
+ const scrollTop = bodyScrollElem.scrollTop + deltaTop
7522
+ const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft
7523
+ const isRollX = scrollLeft !== lastScrollLeft
7524
+ const isRollY = scrollTop !== lastScrollTop
7525
+
7526
+ // 用于鼠标纵向滚轮处理
7527
+ if (isRollY) {
7528
+ evnt.preventDefault()
7529
+ if (rowOpts.isHover || highlightHoverRow) {
7530
+ $xeTable.clearHoverRow()
7531
+ }
7532
+
7533
+ internalData.inWheelScroll = true
7534
+ setScrollTop(yHandleEl, scrollTop)
7535
+ setScrollTop(bodyScrollElem, scrollTop)
7536
+ setScrollTop(leftScrollElem, scrollTop)
7537
+ setScrollTop(rightScrollElem, scrollTop)
7538
+ $xeTable.triggerScrollYEvent(evnt)
7539
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7540
+ type: 'footer',
7541
+ fixed: ''
7542
+ })
7543
+ }
7544
+ },
7545
+ scrollXEvent (evnt: Event) {
7546
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7547
+ const internalData = $xeTable as unknown as TableInternalData
7548
+
7549
+ const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
7550
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
7551
+ return
7131
7552
  }
7132
- const tableHeader = $xeTable.$refs.tableHeader
7133
- const tableBody = $xeTable.$refs.tableBody
7134
- const tableFooter = $xeTable.$refs.tableFooter
7135
- const bodyElem = tableBody.$el as HTMLDivElement
7136
- const headerElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
7137
- const footerElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
7553
+ if (inWheelScroll) {
7554
+ return
7555
+ }
7556
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7557
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7558
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7138
7559
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7139
7560
  const wrapperEl = evnt.currentTarget as HTMLDivElement
7140
7561
  const { scrollLeft } = wrapperEl
7141
- const yBodyEl = yHandleEl || bodyElem
7562
+ const yBodyEl = yHandleEl || bodyScrollElem
7142
7563
  let scrollTop = 0
7143
7564
  if (yBodyEl) {
7144
7565
  scrollTop = yBodyEl.scrollTop
@@ -7147,9 +7568,9 @@ const Methods = {
7147
7568
  const isRollY = scrollTop !== lastScrollTop
7148
7569
 
7149
7570
  internalData.inVirtualScroll = true
7150
- setScrollLeft(bodyElem, scrollLeft)
7151
- setScrollLeft(headerElem, scrollLeft)
7152
- setScrollLeft(footerElem, scrollLeft)
7571
+ setScrollLeft(bodyScrollElem, scrollLeft)
7572
+ setScrollLeft(headerScrollElem, scrollLeft)
7573
+ setScrollLeft(footerScrollElem, scrollLeft)
7153
7574
  $xeTable.triggerScrollXEvent(evnt)
7154
7575
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7155
7576
  type: 'table',
@@ -7157,28 +7578,23 @@ const Methods = {
7157
7578
  })
7158
7579
  },
7159
7580
  scrollYEvent (evnt: Event) {
7160
- const $xeTable = this
7161
- const internalData = $xeTable
7581
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7582
+ const internalData = $xeTable as unknown as TableInternalData
7162
7583
 
7163
- const { intoRunScroll, inFooterScroll, inBodyScroll, lastScrollLeft } = internalData
7164
- if (!intoRunScroll) {
7165
- if (inFooterScroll) {
7166
- return
7167
- }
7168
- if (inBodyScroll) {
7169
- return
7170
- }
7584
+ const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
7585
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
7586
+ return
7587
+ }
7588
+ if (inWheelScroll) {
7589
+ return
7171
7590
  }
7172
- const tableBody = $xeTable.$refs.tableBody
7173
- const leftBody = $xeTable.$refs.leftBody
7174
- const rightBody = $xeTable.$refs.rightBody
7175
- const bodyElem = tableBody.$el as HTMLDivElement
7176
- const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
7177
- const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
7591
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7592
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7593
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7178
7594
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7179
7595
  const wrapperEl = evnt.currentTarget as HTMLDivElement
7180
7596
  const { scrollTop } = wrapperEl
7181
- const xBodyEl = xHandleEl || bodyElem
7597
+ const xBodyEl = xHandleEl || bodyScrollElem
7182
7598
  let scrollLeft = 0
7183
7599
  if (xBodyEl) {
7184
7600
  scrollLeft = xBodyEl.scrollLeft
@@ -7187,47 +7603,25 @@ const Methods = {
7187
7603
  const isRollY = true
7188
7604
 
7189
7605
  internalData.inVirtualScroll = true
7190
- setScrollTop(bodyElem, scrollTop)
7191
- setScrollTop(leftElem, scrollTop)
7192
- setScrollTop(rightElem, scrollTop)
7606
+ setScrollTop(bodyScrollElem, scrollTop)
7607
+ setScrollTop(leftScrollElem, scrollTop)
7608
+ setScrollTop(rightScrollElem, scrollTop)
7193
7609
  $xeTable.triggerScrollYEvent(evnt)
7194
7610
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7195
7611
  type: 'table',
7196
7612
  fixed: ''
7197
7613
  })
7198
7614
  },
7199
- handleTableColumn () {
7200
- const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this
7201
- const tableColumn: any[] = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0)
7202
- tableColumn.forEach((column, $index) => {
7203
- const colid = column.id
7204
- const colRest = fullColumnIdData[colid]
7205
- if (colRest) {
7206
- colRest.$index = $index
7207
- }
7208
- })
7209
- this.tableColumn = tableColumn
7210
- },
7211
- handleUpdateColumn () {
7212
- const $xeTable = this as VxeTableConstructor
7213
- const internalData = $xeTable as unknown as TableInternalData
7214
-
7215
- const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber')
7216
- internalData.collectColumn = columnList
7217
- const tableFullColumn = getColumnList(columnList)
7218
- internalData.tableFullColumn = tableFullColumn
7219
- cacheColumnMap($xeTable)
7220
- },
7221
7615
  updateScrollXData () {
7222
7616
  const $xeTable = this
7223
7617
  const props = $xeTable
7224
7618
 
7225
7619
  const { showOverflow } = props
7226
- $xeTable.handleTableColumn()
7227
- calcCellHeight($xeTable)
7620
+ handleTableColumn($xeTable)
7621
+ // calcCellHeight()
7228
7622
  return $xeTable.$nextTick().then(() => {
7229
- calcCellHeight($xeTable)
7230
- $xeTable.handleTableColumn()
7623
+ // calcCellHeight()
7624
+ handleTableColumn($xeTable)
7231
7625
  $xeTable.updateScrollXSpace()
7232
7626
  if (!showOverflow) {
7233
7627
  $xeTable.updateScrollYSpace()
@@ -7236,18 +7630,23 @@ const Methods = {
7236
7630
  },
7237
7631
  // 更新横向 X 可视渲染上下剩余空间大小
7238
7632
  updateScrollXSpace () {
7239
- const $xeTable = this
7633
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7634
+ const reactData = $xeTable as unknown as TableReactData
7635
+ const internalData = $xeTable as unknown as TableInternalData
7240
7636
 
7241
- const { $refs, isGroup, elemStore, visibleColumn, scrollXStore, scrollXLoad, tableWidth, scrollbarWidth } = $xeTable
7242
- const { tableHeader, tableBody, tableFooter } = $refs
7243
- const tableBodyElem = tableBody ? tableBody.$el : null
7637
+ const { isGroup, scrollXLoad } = reactData
7638
+ const { visibleColumn, scrollXStore, elemStore, tableWidth } = internalData
7639
+ const tableHeader = $xeTable.$refs.refTableHeader
7640
+ const tableBody = $xeTable.$refs.refTableBody
7641
+ const tableFooter = $xeTable.$refs.refTableFooter
7642
+ const tableBodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
7244
7643
  if (tableBodyElem) {
7245
- const tableHeaderElem = tableHeader ? tableHeader.$el : null
7246
- const tableFooterElem = tableFooter ? tableFooter.$el : null
7247
- const headerElem = tableHeaderElem ? tableHeaderElem.querySelector('.vxe-table--header') : null
7248
- const bodyElem = tableBodyElem.querySelector('.vxe-table--body')
7249
- const footerElem = tableFooterElem ? tableFooterElem.querySelector('.vxe-table--footer') : null
7250
- const leftSpaceWidth = visibleColumn.slice(0, scrollXStore.startIndex).reduce((previous: any, column: any) => previous + column.renderWidth, 0)
7644
+ const tableHeaderElem = tableHeader ? (tableHeader as any).$el as HTMLDivElement : null
7645
+ const tableFooterElem = tableFooter ? (tableFooter as any).$el as HTMLDivElement : null
7646
+ const headerElem = tableHeaderElem ? tableHeaderElem.querySelector('.vxe-table--header') as HTMLTableElement : null
7647
+ const bodyElem = tableBodyElem.querySelector('.vxe-table--body') as HTMLTableElement
7648
+ const footerElem = tableFooterElem ? tableFooterElem.querySelector('.vxe-table--footer') as HTMLTableElement : null
7649
+ const leftSpaceWidth = visibleColumn.slice(0, scrollXStore.startIndex).reduce((previous, column) => previous + column.renderWidth, 0)
7251
7650
  let marginLeft = ''
7252
7651
  if (scrollXLoad) {
7253
7652
  marginLeft = `${leftSpaceWidth}px`
@@ -7263,44 +7662,50 @@ const Methods = {
7263
7662
  containerList.forEach(name => {
7264
7663
  const layoutList = ['header', 'body', 'footer']
7265
7664
  layoutList.forEach(layout => {
7266
- const xSpaceElem = elemStore[`${name}-${layout}-xSpace`]
7665
+ const xSpaceElem = getRefElem(elemStore[`${name}-${layout}-xSpace`])
7267
7666
  if (xSpaceElem) {
7268
- xSpaceElem.style.width = scrollXLoad ? `${tableWidth + (layout === 'header' ? scrollbarWidth : 0)}px` : ''
7667
+ xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : ''
7269
7668
  }
7270
7669
  })
7271
7670
  })
7272
- const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem
7671
+ const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem as HTMLDivElement
7273
7672
  if (scrollXSpaceEl) {
7274
- scrollXSpaceEl.style.width = `${tableWidth + scrollbarWidth}px`
7673
+ scrollXSpaceEl.style.width = `${tableWidth}px`
7275
7674
  }
7276
- this.$nextTick(this.updateStyle)
7675
+ $xeTable.$nextTick(() => {
7676
+ updateStyle($xeTable)
7677
+ })
7277
7678
  }
7278
7679
  },
7279
7680
  updateScrollYData () {
7280
7681
  const $xeTable = this
7281
7682
 
7282
7683
  $xeTable.handleTableData()
7283
- calcCellHeight($xeTable)
7684
+ // calcCellHeight()
7284
7685
  return $xeTable.$nextTick().then(() => {
7285
- calcCellHeight($xeTable)
7686
+ // calcCellHeight()
7286
7687
  $xeTable.handleTableData()
7287
7688
  $xeTable.updateScrollYSpace()
7288
7689
  })
7289
7690
  },
7290
7691
  // 更新纵向 Y 可视渲染上下剩余空间大小
7291
7692
  updateScrollYSpace () {
7292
- const $xeTable = this
7693
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7694
+ const props = $xeTable
7695
+ const reactData = $xeTable as unknown as TableReactData
7696
+ const internalData = $xeTable as unknown as TableInternalData
7293
7697
 
7294
- const { showOverflow, elemStore, scrollYStore, scrollYLoad, afterFullData, fullAllDataRowIdData } = this
7295
- const { startIndex, rowHeight } = scrollYStore
7296
- let bodyHeight = 0
7297
- let topSpaceHeight = 0
7698
+ const { showOverflow } = props
7699
+ const { scrollYLoad, rowHeight } = reactData
7700
+ const { scrollYStore, elemStore, afterFullData, fullAllDataRowIdData } = internalData
7701
+ const { startIndex } = scrollYStore
7702
+ const bodyTableElem = getRefElem(elemStore['main-body-table'])
7298
7703
  const containerList = ['main', 'left', 'right']
7299
- let marginTop = ''
7300
- let ySpaceHeight = ''
7704
+ let topSpaceHeight = 0
7705
+ let ySpaceHeight = 0
7301
7706
  if (scrollYLoad) {
7302
7707
  if (showOverflow) {
7303
- bodyHeight = afterFullData.length * rowHeight
7708
+ ySpaceHeight = afterFullData.length * rowHeight
7304
7709
  topSpaceHeight = Math.max(0, startIndex * rowHeight)
7305
7710
  } else {
7306
7711
  for (let i = 0; i < afterFullData.length; i++) {
@@ -7308,7 +7713,7 @@ const Methods = {
7308
7713
  const rowid = getRowid($xeTable, row)
7309
7714
  const rowRest = fullAllDataRowIdData[rowid]
7310
7715
  if (rowRest) {
7311
- bodyHeight += rowRest.height || rowHeight
7716
+ ySpaceHeight += rowRest.height || rowHeight
7312
7717
  }
7313
7718
  }
7314
7719
  for (let i = 0; i < startIndex; i++) {
@@ -7320,27 +7725,31 @@ const Methods = {
7320
7725
  }
7321
7726
  }
7322
7727
  }
7323
- marginTop = `${topSpaceHeight}px`
7324
- ySpaceHeight = `${bodyHeight}px`
7728
+ } else {
7729
+ if (bodyTableElem) {
7730
+ ySpaceHeight = bodyTableElem.clientHeight
7731
+ }
7325
7732
  }
7326
7733
  containerList.forEach(name => {
7327
7734
  const layoutList = ['header', 'body', 'footer']
7328
- const tableElem = elemStore[`${name}-body-table`]
7735
+ const tableElem = getRefElem(elemStore[`${name}-body-table`])
7329
7736
  if (tableElem) {
7330
- tableElem.style.marginTop = marginTop
7737
+ tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : ''
7331
7738
  }
7332
7739
  layoutList.forEach(layout => {
7333
- const ySpaceElem = elemStore[`${name}-${layout}-ySpace`]
7740
+ const ySpaceElem = getRefElem(elemStore[`${name}-${layout}-ySpace`])
7334
7741
  if (ySpaceElem) {
7335
- ySpaceElem.style.height = ySpaceHeight
7742
+ ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
7336
7743
  }
7337
7744
  })
7338
7745
  })
7339
- const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem
7746
+ const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem as HTMLDivElement
7340
7747
  if (scrollYSpaceEl) {
7341
- scrollYSpaceEl.style.height = ySpaceHeight
7748
+ scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
7342
7749
  }
7343
- this.$nextTick(this.updateStyle)
7750
+ $xeTable.$nextTick(() => {
7751
+ updateStyle($xeTable)
7752
+ })
7344
7753
  },
7345
7754
  updateScrollYStatus () {
7346
7755
  const $xeTable = this
@@ -7357,12 +7766,12 @@ const Methods = {
7357
7766
  const internalData = $xeTable as unknown as TableInternalData
7358
7767
 
7359
7768
  const { $refs } = this
7360
- const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs
7361
- const tableBodyElem = tableBody ? tableBody.$el : null
7769
+ const { refTableBody, refTableHeader, leftBody, rightBody, refTableFooter } = $refs
7770
+ const tableBodyElem = refTableBody ? refTableBody.$el : null
7362
7771
  const leftBodyElem = leftBody ? leftBody.$el : null
7363
7772
  const rightBodyElem = rightBody ? rightBody.$el : null
7364
- const tableHeaderElem = tableHeader ? tableHeader.$el : null
7365
- const tableFooterElem = tableFooter ? tableFooter.$el : null
7773
+ const tableHeaderElem = refTableHeader ? refTableHeader.$el : null
7774
+ const tableFooterElem = refTableFooter ? refTableFooter.$el : null
7366
7775
  internalData.intoRunScroll = true
7367
7776
  if (XEUtils.isNumber(scrollLeft)) {
7368
7777
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
@@ -7467,45 +7876,37 @@ const Methods = {
7467
7876
  const $xeTable = this
7468
7877
  const internalData = $xeTable
7469
7878
 
7470
- const { scrollXStore, scrollYStore } = internalData
7471
- const tableBody = $xeTable.$refs.tableBody
7472
- const tableHeader = $xeTable.$refs.tableHeader
7473
- const tableFooter = $xeTable.$refs.tableFooter
7474
- const leftBody = $xeTable.$refs.leftBody
7475
- const rightBody = $xeTable.$refs.rightBody
7476
- const leftBodyElem = leftBody ? leftBody.$el as HTMLDivElement : null
7477
- const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
7478
- const rightBodyElem = rightBody ? rightBody.$el as HTMLDivElement : null
7479
- const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
7480
- const tableFooterElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
7879
+ const { elemStore, scrollXStore, scrollYStore } = internalData
7880
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7881
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7882
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7883
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7884
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7481
7885
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7482
- if (xHandleEl) {
7483
- setScrollLeft(xHandleEl, 0)
7484
- } else {
7485
- setScrollLeft(tableBodyElem, 0)
7486
- setScrollLeft(tableHeaderElem, 0)
7487
- setScrollLeft(tableFooterElem, 0)
7488
- }
7489
7886
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7490
- if (yHandleEl) {
7491
- setScrollTop(yHandleEl, 0)
7492
- } else {
7493
- setScrollTop(tableBodyElem, 0)
7494
- setScrollTop(leftBodyElem, 0)
7495
- setScrollTop(rightBodyElem, 0)
7496
- }
7887
+
7888
+ internalData.intoRunScroll = true
7889
+
7890
+ setScrollLeft(xHandleEl, 0)
7891
+ setScrollLeft(bodyScrollElem, 0)
7892
+ setScrollLeft(headerScrollElem, 0)
7893
+ setScrollLeft(footerScrollElem, 0)
7894
+
7895
+ setScrollTop(yHandleEl, 0)
7896
+ setScrollTop(bodyScrollElem, 0)
7897
+ setScrollTop(leftScrollElem, 0)
7898
+ setScrollTop(rightScrollElem, 0)
7899
+
7497
7900
  scrollXStore.startIndex = 0
7901
+ scrollXStore.visibleStartIndex = 0
7498
7902
  scrollXStore.endIndex = scrollXStore.visibleSize
7903
+ scrollXStore.visibleEndIndex = scrollXStore.visibleSize
7499
7904
  scrollYStore.startIndex = 0
7905
+ scrollYStore.visibleStartIndex = 0
7500
7906
  scrollYStore.endIndex = scrollYStore.visibleSize
7907
+ scrollYStore.visibleEndIndex = scrollYStore.visibleSize
7501
7908
  return $xeTable.$nextTick().then(() => {
7502
- setScrollLeft(tableBodyElem, 0)
7503
- setScrollLeft(tableHeaderElem, 0)
7504
- setScrollLeft(tableFooterElem, 0)
7505
-
7506
- setScrollTop(tableBodyElem, 0)
7507
- setScrollTop(leftBodyElem, 0)
7508
- setScrollTop(rightBodyElem, 0)
7909
+ internalData.intoRunScroll = false
7509
7910
  })
7510
7911
  },
7511
7912
  /**
@@ -7531,8 +7932,8 @@ const Methods = {
7531
7932
  const customVal = !XEUtils.isUndefined(cellValue)
7532
7933
  return this.$nextTick().then(() => {
7533
7934
  const { $refs, editRules, validStore } = this
7534
- const tableBody = $refs.tableBody
7535
- if (slotParams && tableBody && editRules) {
7935
+ const refTableBody = $refs.refTableBody
7936
+ if (slotParams && refTableBody && editRules) {
7536
7937
  const { row, column } = slotParams
7537
7938
  const type = 'change'
7538
7939
  if (this.hasCellRules) {
@@ -7566,13 +7967,15 @@ const Methods = {
7566
7967
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
7567
7968
  */
7568
7969
  setMergeCells (merges: any) {
7970
+ const $xeTable = this
7971
+
7569
7972
  if (this.spanMethod) {
7570
7973
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
7571
7974
  }
7572
7975
  setMerges(this, merges, this.mergeList, this.afterFullData)
7573
7976
  return this.$nextTick().then(() => {
7574
7977
  this.updateCellAreas()
7575
- return this.updateStyle()
7978
+ return updateStyle($xeTable)
7576
7979
  })
7577
7980
  },
7578
7981
  /**
@@ -7580,13 +7983,15 @@ const Methods = {
7580
7983
  * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
7581
7984
  */
7582
7985
  removeMergeCells (merges: any) {
7986
+ const $xeTable = this
7987
+
7583
7988
  if (this.spanMethod) {
7584
7989
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
7585
7990
  }
7586
7991
  const rest = removeMerges(this, merges, this.mergeList, this.afterFullData)
7587
7992
  return this.$nextTick().then(() => {
7588
7993
  this.updateCellAreas()
7589
- this.updateStyle()
7994
+ updateStyle($xeTable)
7590
7995
  return rest
7591
7996
  })
7592
7997
  },
@@ -7600,32 +8005,38 @@ const Methods = {
7600
8005
  * 清除所有单元格合并
7601
8006
  */
7602
8007
  clearMergeCells () {
8008
+ const $xeTable = this
8009
+
7603
8010
  this.mergeList = []
7604
8011
  return this.$nextTick().then(() => {
7605
- return this.updateStyle()
8012
+ return updateStyle($xeTable)
7606
8013
  })
7607
8014
  },
7608
8015
  handleDefaultMergeFooterItems () {
7609
8016
  this.setMergeFooterItems(this.mergeFooterItems)
7610
8017
  },
7611
8018
  setMergeFooterItems (merges: any) {
8019
+ const $xeTable = this
8020
+
7612
8021
  if (this.footerSpanMethod) {
7613
8022
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
7614
8023
  }
7615
8024
  setMerges(this, merges, this.mergeFooterList, null)
7616
8025
  return this.$nextTick().then(() => {
7617
8026
  this.updateCellAreas()
7618
- return this.updateStyle()
8027
+ return updateStyle($xeTable)
7619
8028
  })
7620
8029
  },
7621
8030
  removeMergeFooterItems (merges: any) {
8031
+ const $xeTable = this
8032
+
7622
8033
  if (this.footerSpanMethod) {
7623
8034
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
7624
8035
  }
7625
8036
  const rest = removeMerges(this, merges, this.mergeFooterList, null)
7626
8037
  return this.$nextTick().then(() => {
7627
8038
  this.updateCellAreas()
7628
- this.updateStyle()
8039
+ updateStyle($xeTable)
7629
8040
  return rest
7630
8041
  })
7631
8042
  },
@@ -7639,9 +8050,11 @@ const Methods = {
7639
8050
  * 清除所有表尾合并
7640
8051
  */
7641
8052
  clearMergeFooterItems () {
8053
+ const $xeTable = this
8054
+
7642
8055
  this.mergeFooterList = []
7643
8056
  return this.$nextTick().then(() => {
7644
- return this.updateStyle()
8057
+ return updateStyle($xeTable)
7645
8058
  })
7646
8059
  },
7647
8060
  updateZindex () {