vxe-table 3.12.9 → 3.12.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) 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/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/export/mixin.js +3 -3
  7. package/es/table/module/filter/mixin.js +3 -3
  8. package/es/table/module/keyboard/mixin.js +4 -4
  9. package/es/table/module/menu/mixin.js +2 -2
  10. package/es/table/module/validator/mixin.js +2 -2
  11. package/es/table/src/body.js +247 -351
  12. package/es/table/src/footer.js +135 -154
  13. package/es/table/src/header.js +120 -100
  14. package/es/table/src/methods.js +1174 -790
  15. package/es/table/src/props.js +9 -3
  16. package/es/table/src/table.js +187 -103
  17. package/es/table/src/util.js +16 -7
  18. package/es/table/style.css +146 -63
  19. package/es/table/style.min.css +1 -1
  20. package/es/ui/index.js +14 -4
  21. package/es/ui/src/log.js +1 -1
  22. package/es/vxe-table/style.css +146 -63
  23. package/es/vxe-table/style.min.css +1 -1
  24. package/lib/grid/src/grid.js +4 -1
  25. package/lib/grid/src/grid.min.js +1 -1
  26. package/lib/index.css +1 -1
  27. package/lib/index.min.css +1 -1
  28. package/lib/index.umd.js +1896 -1543
  29. package/lib/index.umd.min.js +1 -1
  30. package/lib/style.css +1 -1
  31. package/lib/style.min.css +1 -1
  32. package/lib/table/module/export/mixin.js +3 -3
  33. package/lib/table/module/export/mixin.min.js +1 -1
  34. package/lib/table/module/filter/mixin.js +4 -4
  35. package/lib/table/module/filter/mixin.min.js +1 -1
  36. package/lib/table/module/keyboard/mixin.js +5 -5
  37. package/lib/table/module/keyboard/mixin.min.js +1 -1
  38. package/lib/table/module/menu/mixin.js +2 -2
  39. package/lib/table/module/menu/mixin.min.js +1 -1
  40. package/lib/table/module/validator/mixin.js +2 -2
  41. package/lib/table/module/validator/mixin.min.js +1 -1
  42. package/lib/table/src/body.js +185 -365
  43. package/lib/table/src/body.min.js +1 -1
  44. package/lib/table/src/footer.js +124 -151
  45. package/lib/table/src/footer.min.js +1 -1
  46. package/lib/table/src/header.js +97 -74
  47. package/lib/table/src/header.min.js +1 -1
  48. package/lib/table/src/methods.js +1258 -830
  49. package/lib/table/src/methods.min.js +1 -1
  50. package/lib/table/src/props.js +9 -3
  51. package/lib/table/src/props.min.js +1 -1
  52. package/lib/table/src/table.js +171 -90
  53. package/lib/table/src/table.min.js +1 -1
  54. package/lib/table/src/util.js +17 -7
  55. package/lib/table/src/util.min.js +1 -1
  56. package/lib/table/style/style.css +146 -63
  57. package/lib/table/style/style.min.css +1 -1
  58. package/lib/ui/index.js +14 -4
  59. package/lib/ui/index.min.js +1 -1
  60. package/lib/ui/src/log.js +1 -1
  61. package/lib/ui/src/log.min.js +1 -1
  62. package/lib/vxe-table/style/style.css +146 -63
  63. package/lib/vxe-table/style/style.min.css +1 -1
  64. package/package.json +2 -2
  65. package/packages/grid/src/grid.ts +6 -1
  66. package/packages/table/module/export/mixin.ts +3 -3
  67. package/packages/table/module/filter/mixin.ts +3 -3
  68. package/packages/table/module/keyboard/mixin.ts +4 -4
  69. package/packages/table/module/menu/mixin.ts +2 -2
  70. package/packages/table/module/validator/mixin.ts +2 -2
  71. package/packages/table/src/body.ts +281 -427
  72. package/packages/table/src/footer.ts +148 -164
  73. package/packages/table/src/header.ts +135 -111
  74. package/packages/table/src/methods.ts +1246 -845
  75. package/packages/table/src/props.ts +9 -3
  76. package/packages/table/src/table.ts +195 -146
  77. package/packages/table/src/util.ts +17 -7
  78. package/packages/ui/index.ts +13 -3
  79. package/styles/components/table.scss +164 -74
  80. /package/es/{iconfont.1736414871619.ttf → iconfont.1736688976404.ttf} +0 -0
  81. /package/es/{iconfont.1736414871619.woff → iconfont.1736688976404.woff} +0 -0
  82. /package/es/{iconfont.1736414871619.woff2 → iconfont.1736688976404.woff2} +0 -0
  83. /package/lib/{iconfont.1736414871619.ttf → iconfont.1736688976404.ttf} +0 -0
  84. /package/lib/{iconfont.1736414871619.woff → iconfont.1736688976404.woff} +0 -0
  85. /package/lib/{iconfont.1736414871619.woff2 → iconfont.1736688976404.woff2} +0 -0
@@ -1,27 +1,18 @@
1
1
  import XEUtils from 'xe-utils'
2
- import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, 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) {
@@ -997,6 +1419,199 @@ function loadScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
997
1419
  $xeTable.closeTooltip()
998
1420
  }
999
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
+ })
1613
+ }
1614
+
1000
1615
  /**
1001
1616
  * 纵向 Y 可视渲染处理
1002
1617
  */
@@ -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}`)
@@ -2592,8 +3179,8 @@ const Methods = {
2592
3179
  const colWidth = XEUtils.toInteger(width)
2593
3180
  let rdWidth = colWidth
2594
3181
  if (isScale(width)) {
2595
- const tableBody = $xeTable.$refs.tableBody
2596
- const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
3182
+ const refTableBody = $xeTable.$refs.refTableBody
3183
+ const bodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
2597
3184
  const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0
2598
3185
  rdWidth = Math.floor(colWidth * bodyWidth)
2599
3186
  }
@@ -2839,143 +3426,17 @@ const Methods = {
2839
3426
  * 刷新列配置
2840
3427
  */
2841
3428
  refreshColumn (initSort?: boolean) {
3429
+ const $xeTable = this
3430
+
2842
3431
  if (initSort) {
2843
- this.handleUpdateColumn()
3432
+ handleUpdateColumn($xeTable)
2844
3433
  }
2845
- return this.parseColumns(true).then(() => {
3434
+ return parseColumns($xeTable, true).then(() => {
2846
3435
  return this.refreshScroll()
2847
3436
  }).then(() => {
2848
3437
  return this.recalculate()
2849
3438
  })
2850
3439
  },
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
3440
  /**
2980
3441
  * 指定列宽的列进行拆分
2981
3442
  */
@@ -3056,408 +3517,112 @@ const Methods = {
3056
3517
  * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
3057
3518
  */
3058
3519
  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
3520
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3521
+ const internalData = $xeTable as unknown as TableInternalData
3090
3522
 
3523
+ const { elemStore, lastScrollLeft, lastScrollTop } = internalData
3524
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
3525
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
3526
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
3527
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
3528
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
3529
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
3530
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
3091
3531
  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
- }
3532
+ // 还原滚动条位置
3533
+ if (lastScrollLeft || lastScrollTop) {
3534
+ return restoreScrollLocation($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
3535
+ // 存在滚动行为未结束情况
3536
+ setTimeout(resolve, 10)
3537
+ })
3538
+ }
3539
+ internalData.intoRunScroll = true
3540
+ // 重置
3541
+ setScrollTop(yHandleEl, lastScrollTop)
3542
+ setScrollTop(bodyScrollElem, lastScrollTop)
3543
+ setScrollTop(leftScrollElem, lastScrollTop)
3544
+ setScrollTop(rightScrollElem, lastScrollTop)
3545
+
3546
+ setScrollLeft(xHandleEl, lastScrollLeft)
3547
+ setScrollLeft(bodyScrollElem, lastScrollLeft)
3548
+ setScrollLeft(headerScrollElem, lastScrollLeft)
3549
+ setScrollLeft(footerScrollElem, lastScrollLeft)
3550
+ // 存在滚动行为未结束情况
3551
+ setTimeout(() => {
3552
+ internalData.intoRunScroll = false
3553
+ resolve()
3554
+ }, 10)
3555
+ })
3556
+ },
3557
+ /**
3558
+ * 重新渲染布局
3559
+ * 刷新布局
3560
+ */
3561
+ recalculate (reFull?: boolean) {
3562
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3563
+ const internalData = $xeTable as unknown as TableInternalData
3564
+
3565
+ return new Promise<void>(resolve => {
3566
+ const { rceTimeout, rceRunTime } = internalData
3567
+ const resizeOpts = $xeTable.computeResizeOpts
3568
+ const refreshDelay = resizeOpts.refreshDelay || 20
3569
+ const el = $xeTable.$refs.refElem as HTMLElement
3570
+ if (el && el.clientWidth) {
3571
+ autoCellWidth($xeTable)
3572
+ }
3573
+ if (rceTimeout) {
3574
+ clearTimeout(rceTimeout)
3575
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3576
+ resolve(
3577
+ handleRecalculateLayout($xeTable, !!reFull)
3578
+ )
3579
+ } else {
3580
+ $xeTable.$nextTick(() => {
3581
+ resolve()
3426
3582
  })
3427
3583
  }
3428
- })
3584
+ } else {
3585
+ resolve(
3586
+ handleRecalculateLayout($xeTable, !!reFull)
3587
+ )
3588
+ }
3589
+ internalData.rceTimeout = setTimeout(() => {
3590
+ internalData.rceTimeout = undefined
3591
+ handleRecalculateLayout($xeTable, !!reFull)
3592
+ }, refreshDelay)
3429
3593
  })
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()
3594
+ },
3595
+ updateStyle () {
3596
+ const $xeTable = this
3597
+
3598
+ return updateStyle($xeTable)
3437
3599
  },
3438
3600
  /**
3439
3601
  * 处理固定列的显示状态
3440
3602
  */
3441
3603
  checkScrolling () {
3442
- const $xeTable = this
3604
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3605
+ const internalData = $xeTable as unknown as TableInternalData
3443
3606
 
3444
- const { tableBody, leftContainer, rightContainer } = $xeTable.$refs
3445
- const bodyElem = tableBody ? tableBody.$el : null
3607
+ const { elemStore } = internalData
3608
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
3609
+ const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
3610
+ const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
3446
3611
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
3447
- const bodtTargetEl = xHandleEl || bodyElem
3612
+ const bodtTargetEl = xHandleEl || bodyScrollElem
3448
3613
  if (bodtTargetEl) {
3449
- if (leftContainer) {
3614
+ if (leftContainerElem) {
3450
3615
  if (bodtTargetEl.scrollLeft > 0) {
3451
- addClass(leftContainer, 'scrolling--middle')
3616
+ addClass(leftContainerElem, 'scrolling--middle')
3452
3617
  } else {
3453
- removeClass(leftContainer, 'scrolling--middle')
3618
+ removeClass(leftContainerElem, 'scrolling--middle')
3454
3619
  }
3455
3620
  }
3456
- if (rightContainer) {
3621
+ if (rightContainerElem) {
3457
3622
  if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
3458
- addClass(rightContainer, 'scrolling--middle')
3623
+ addClass(rightContainerElem, 'scrolling--middle')
3459
3624
  } else {
3460
- removeClass(rightContainer, 'scrolling--middle')
3625
+ removeClass(rightContainerElem, 'scrolling--middle')
3461
3626
  }
3462
3627
  }
3463
3628
  }
@@ -3493,7 +3658,7 @@ const Methods = {
3493
3658
  handleGlobalMousedownEvent (evnt: any) {
3494
3659
  const { $el, $refs, $xegrid, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this
3495
3660
  const { actived } = editStore
3496
- const { ctxWrapper, filterWrapper, customWrapper, validTip } = $refs
3661
+ const { refTableMenu, filterWrapper, customWrapper, refValidTooltip } = $refs
3497
3662
  // 筛选
3498
3663
  if (filterWrapper) {
3499
3664
  if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {
@@ -3525,7 +3690,7 @@ const Methods = {
3525
3690
  // 如果是激活状态,点击了单元格之外
3526
3691
  const cell = actived.args.cell
3527
3692
  if ((!cell || !getEventTargetNode(evnt, cell).flag)) {
3528
- if (validTip && getEventTargetNode(evnt, validTip.$el).flag) {
3693
+ if (refValidTooltip && getEventTargetNode(evnt, refValidTooltip.$el).flag) {
3529
3694
  // 如果是激活状态,且点击了校验提示框
3530
3695
  } else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
3531
3696
  if (!getEventTargetNode(evnt, document.body, 'vxe-table--ignore-clear').flag) {
@@ -3575,7 +3740,7 @@ const Methods = {
3575
3740
  }
3576
3741
  }
3577
3742
  } 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)) {
3743
+ if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(refTableMenu && getEventTargetNode(evnt, refTableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
3579
3744
  if (this.clearSelected) {
3580
3745
  this.clearSelected()
3581
3746
  }
@@ -3594,7 +3759,7 @@ const Methods = {
3594
3759
  }
3595
3760
  }
3596
3761
  // 如果配置了快捷菜单且,点击了其他地方则关闭
3597
- if (ctxMenuStore.visible && ctxWrapper && !getEventTargetNode(evnt, ctxWrapper.$el).flag) {
3762
+ if (ctxMenuStore.visible && refTableMenu && !getEventTargetNode(evnt, refTableMenu.$el).flag) {
3598
3763
  this.closeMenu()
3599
3764
  }
3600
3765
  const isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag
@@ -3725,8 +3890,8 @@ const Methods = {
3725
3890
  } else if (isContextMenu) {
3726
3891
  // 如果按下上下文键
3727
3892
  this._keyCtx = selected.row && selected.column && bodyCtxMenu.length
3728
- clearTimeout(this.keyCtxTimeout)
3729
- this.keyCtxTimeout = setTimeout(() => {
3893
+ clearTimeout(internalData.keyCtxTimeout)
3894
+ internalData.keyCtxTimeout = setTimeout(() => {
3730
3895
  this._keyCtx = false
3731
3896
  }, 1000)
3732
3897
  } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
@@ -4071,6 +4236,11 @@ const Methods = {
4071
4236
  * @param {Row} row 行对象
4072
4237
  */
4073
4238
  handleTooltip (evnt: any, cell: any, overflowElem: any, tipElem: any, params: any) {
4239
+ const $xeTable = this
4240
+
4241
+ if (!overflowElem) {
4242
+ return $xeTable.$nextTick()
4243
+ }
4074
4244
  params.cell = cell
4075
4245
  const { $refs, tooltipOpts, tooltipStore } = this
4076
4246
  const { column, row } = params
@@ -4097,7 +4267,7 @@ const Methods = {
4097
4267
  },
4098
4268
  openTooltip (target: any, content: any) {
4099
4269
  const { $refs } = this
4100
- const commTip = $refs.commTip
4270
+ const commTip = $refs.refCommTooltip
4101
4271
  if (commTip) {
4102
4272
  return commTip.open(target, content)
4103
4273
  }
@@ -4109,7 +4279,7 @@ const Methods = {
4109
4279
  closeTooltip () {
4110
4280
  const { $refs, tooltipStore } = this
4111
4281
  const tooltip = $refs.tooltip
4112
- const commTip = $refs.commTip
4282
+ const commTip = $refs.refCommTooltip
4113
4283
  if (tooltipStore.visible) {
4114
4284
  Object.assign(tooltipStore, {
4115
4285
  row: null,
@@ -5291,6 +5461,8 @@ const Methods = {
5291
5461
  this.emitEvent('cell-dblclick', params, evnt)
5292
5462
  },
5293
5463
  handleDefaultSort () {
5464
+ const $xeTable = this
5465
+
5294
5466
  const { sortConfig, sortOpts } = this
5295
5467
  let { defaultSort } = sortOpts
5296
5468
  if (defaultSort) {
@@ -5309,7 +5481,7 @@ const Methods = {
5309
5481
  }
5310
5482
  })
5311
5483
  if (!sortOpts.remote) {
5312
- this.handleTableData(true).then(this.updateStyle)
5484
+ this.handleTableData(true).then(() => updateStyle($xeTable))
5313
5485
  }
5314
5486
  }
5315
5487
  }
@@ -5751,8 +5923,8 @@ const Methods = {
5751
5923
  handleColDragSwapColumn () {
5752
5924
  const $xeTable = this
5753
5925
 
5754
- $xeTable.handleUpdateColumn()
5755
- $xeTable.parseColumns(false).then(() => {
5926
+ handleUpdateColumn($xeTable)
5927
+ parseColumns($xeTable, false).then(() => {
5756
5928
  $xeTable.updateCellAreas()
5757
5929
  $xeTable.saveCustomStore('update:sort')
5758
5930
  })
@@ -5994,15 +6166,15 @@ const Methods = {
5994
6166
  return
5995
6167
  }
5996
6168
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
5997
- const tableBody = $xeTable.$refs.tableBody
5998
- const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
6169
+ const refTableBody = $xeTable.$refs.refTableBody
6170
+ const tableBodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
5999
6171
  const scrollTargetEl = xHandleEl || tableBodyElem
6000
6172
  if (scrollTargetEl) {
6001
6173
  const wrapperRect = el.getBoundingClientRect()
6002
6174
  const tableWidth = el.clientWidth
6003
- const leftContainerElem = $xeTable.$refs.leftContainer as HTMLDivElement
6175
+ const leftContainerElem = $xeTable.$refs.refLeftContainer as HTMLDivElement
6004
6176
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
6005
- const rightContainerElem = $xeTable.$refs.rightContainer as HTMLDivElement
6177
+ const rightContainerElem = $xeTable.$refs.refRightContainer as HTMLDivElement
6006
6178
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0
6007
6179
  const srartX = wrapperRect.x + leftContainerWidth
6008
6180
  const endX = wrapperRect.x + tableWidth - rightContainerWidth
@@ -6127,6 +6299,8 @@ const Methods = {
6127
6299
  return this.$nextTick()
6128
6300
  },
6129
6301
  sort (sortConfs: any, sortOrder: any) {
6302
+ const $xeTable = this
6303
+
6130
6304
  const { sortOpts } = this
6131
6305
  const { multiple, remote, orders } = sortOpts
6132
6306
  if (sortConfs) {
@@ -6169,7 +6343,7 @@ const Methods = {
6169
6343
  }
6170
6344
  return this.$nextTick().then(() => {
6171
6345
  this.updateCellAreas()
6172
- return this.updateStyle()
6346
+ return updateStyle($xeTable)
6173
6347
  })
6174
6348
  }
6175
6349
  return this.$nextTick()
@@ -6215,7 +6389,7 @@ const Methods = {
6215
6389
  }
6216
6390
  return $xeTable.$nextTick().then(() => {
6217
6391
  $xeTable.updateCellAreas()
6218
- return $xeTable.updateStyle()
6392
+ return updateStyle($xeTable)
6219
6393
  })
6220
6394
  }
6221
6395
  return $xeTable.$nextTick()
@@ -6226,6 +6400,8 @@ const Methods = {
6226
6400
  * @param {String} column 列或字段名
6227
6401
  */
6228
6402
  clearSort (fieldOrColumn: any) {
6403
+ const $xeTable = this
6404
+
6229
6405
  const { sortOpts } = this
6230
6406
  if (fieldOrColumn) {
6231
6407
  const column = handleFieldOrColumn(this, fieldOrColumn)
@@ -6238,7 +6414,7 @@ const Methods = {
6238
6414
  if (!sortOpts.remote) {
6239
6415
  this.handleTableData(true)
6240
6416
  }
6241
- return this.$nextTick().then(this.updateStyle)
6417
+ return this.$nextTick().then(() => updateStyle($xeTable))
6242
6418
  },
6243
6419
  // 在 v3 中废弃
6244
6420
  getSortColumn () {
@@ -6942,7 +7118,7 @@ const Methods = {
6942
7118
  */
6943
7119
  getScroll () {
6944
7120
  const { $refs, scrollXLoad, scrollYLoad } = this
6945
- const bodyElem = $refs.tableBody.$el
7121
+ const bodyElem = $refs.refTableBody.$el
6946
7122
  return {
6947
7123
  virtualX: scrollXLoad,
6948
7124
  virtualY: scrollYLoad,
@@ -6951,22 +7127,25 @@ const Methods = {
6951
7127
  }
6952
7128
  },
6953
7129
  handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number, params: any) {
6954
- const $xeTable = this
7130
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6955
7131
  const props = $xeTable
6956
- const reactData = $xeTable
6957
- const internalData = $xeTable
7132
+ const reactData = $xeTable as unknown as TableReactData
7133
+ const internalData = $xeTable as unknown as TableInternalData
6958
7134
 
6959
7135
  const { highlightHoverRow } = props
6960
7136
  const { lastScrollLeft, lastScrollTop } = internalData
6961
- const tableBody = $xeTable.$refs.tableBody
6962
- const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
7137
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7138
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7139
+ if (!xHandleEl || !yHandleEl) {
7140
+ return
7141
+ }
6963
7142
  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
7143
+ const validTip = $xeTable.$refs.refValidTooltip as VxeTooltipInstance
7144
+ const tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
7145
+ const bodyHeight = yHandleEl.clientHeight
7146
+ const bodyWidth = xHandleEl.clientWidth
7147
+ const scrollHeight = yHandleEl.scrollHeight
7148
+ const scrollWidth = xHandleEl.scrollWidth
6970
7149
  let isTop = false
6971
7150
  let isBottom = false
6972
7151
  let isLeft = false
@@ -7038,13 +7217,12 @@ const Methods = {
7038
7217
  if (rowOpts.isHover || highlightHoverRow) {
7039
7218
  $xeTable.clearHoverRow()
7040
7219
  }
7041
- if (validTip && validTip.visible) {
7220
+ if (validTip && validTip.reactData.visible) {
7042
7221
  validTip.close()
7043
7222
  }
7044
- if (tooltip && tooltip.visible) {
7223
+ if (tooltip && tooltip.reactData.visible) {
7045
7224
  tooltip.close()
7046
7225
  }
7047
-
7048
7226
  if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
7049
7227
  $xeTable.dispatchEvent('scroll-boundary', evntParams, evnt)
7050
7228
  }
@@ -7056,7 +7234,7 @@ const Methods = {
7056
7234
 
7057
7235
  const { lxTimeout, lxRunTime, scrollXStore } = internalData
7058
7236
  const { visibleSize } = scrollXStore
7059
- const fpsTime = Math.min(80, Math.floor(visibleSize * 3))
7237
+ const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)))
7060
7238
  if (lxTimeout) {
7061
7239
  clearTimeout(lxTimeout)
7062
7240
  }
@@ -7072,11 +7250,13 @@ const Methods = {
7072
7250
  },
7073
7251
  lazyScrollYData () {
7074
7252
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7253
+ const props = $xeTable
7075
7254
  const internalData = $xeTable as unknown as TableInternalData
7076
7255
 
7256
+ const { showOverflow } = props
7077
7257
  const { lyTimeout, lyRunTime, scrollYStore } = internalData
7078
7258
  const { visibleSize } = scrollYStore
7079
- const fpsTime = Math.min(80, Math.floor(visibleSize))
7259
+ const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)))
7080
7260
  if (lyTimeout) {
7081
7261
  clearTimeout(lyTimeout)
7082
7262
  }
@@ -7116,29 +7296,258 @@ const Methods = {
7116
7296
  $xeTable.lazyScrollYData()
7117
7297
  }
7118
7298
  },
7119
- scrollXEvent (evnt: Event) {
7120
- const $xeTable = this
7121
- const internalData = $xeTable
7299
+ triggerBodyScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
7300
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7301
+ const internalData = $xeTable as unknown as TableInternalData
7122
7302
 
7123
- const { intoRunScroll, inFooterScroll, inBodyScroll, lastScrollTop } = internalData
7124
- if (!intoRunScroll) {
7125
- if (inFooterScroll) {
7303
+ const { elemStore, lastScrollTop, lastScrollLeft, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll, scrollRenderType, inFooterScroll } = internalData
7304
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7305
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7306
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7307
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7308
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7309
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7310
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7311
+ if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
7312
+ return
7313
+ }
7314
+ if (!bodyScrollElem) {
7315
+ return
7316
+ }
7317
+ if (!xHandleEl) {
7318
+ return
7319
+ }
7320
+ if (!yHandleEl) {
7321
+ return
7322
+ }
7323
+ if (inBodyScroll) {
7324
+ if (scrollRenderType !== fixedType) {
7126
7325
  return
7127
7326
  }
7128
- if (inBodyScroll) {
7129
- return
7327
+ }
7328
+ let scrollTop = yHandleEl.scrollTop
7329
+ let scrollLeft = xHandleEl.scrollLeft
7330
+ if (leftScrollElem && fixedType === 'left') {
7331
+ scrollTop = leftScrollElem.scrollTop
7332
+ } else if (rightScrollElem && fixedType === 'right') {
7333
+ scrollTop = rightScrollElem.scrollTop
7334
+ } else {
7335
+ scrollTop = bodyScrollElem.scrollTop
7336
+ scrollLeft = bodyScrollElem.scrollLeft
7337
+ }
7338
+ const isRollX = scrollLeft !== lastScrollLeft
7339
+ const isRollY = scrollTop !== lastScrollTop
7340
+ internalData.inBodyScroll = true
7341
+ internalData.scrollRenderType = fixedType
7342
+ if (isRollY) {
7343
+ if (fixedType === 'left') {
7344
+ setScrollTop(bodyScrollElem, scrollTop)
7345
+ setScrollTop(rightScrollElem, scrollTop)
7346
+ } else if (fixedType === 'right') {
7347
+ setScrollTop(bodyScrollElem, scrollTop)
7348
+ setScrollTop(leftScrollElem, scrollTop)
7349
+ } else {
7350
+ setScrollTop(leftScrollElem, scrollTop)
7351
+ setScrollTop(rightScrollElem, scrollTop)
7130
7352
  }
7353
+ setScrollTop(yHandleEl, scrollTop)
7354
+ $xeTable.triggerScrollYEvent(evnt)
7355
+ }
7356
+ if (isRollX) {
7357
+ setScrollLeft(xHandleEl, scrollLeft)
7358
+ setScrollLeft(headerScrollElem, scrollLeft)
7359
+ setScrollLeft(footerScrollElem, scrollLeft)
7360
+ $xeTable.triggerScrollXEvent(evnt)
7361
+ }
7362
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7363
+ type: 'body',
7364
+ fixed: fixedType
7365
+ })
7366
+ },
7367
+ triggerHeaderScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
7368
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7369
+ const internalData = $xeTable as unknown as TableInternalData
7370
+
7371
+ const { elemStore, inWheelScroll, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData
7372
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7373
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7374
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7375
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7376
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7377
+ if (inWheelScroll) {
7378
+ return
7379
+ }
7380
+ if (inVirtualScroll) {
7381
+ return
7382
+ }
7383
+ if (inBodyScroll) {
7384
+ return
7385
+ }
7386
+ if (inFooterScroll) {
7387
+ return
7388
+ }
7389
+ if (!headerScrollElem) {
7390
+ return
7391
+ }
7392
+ if (!xHandleEl) {
7393
+ return
7394
+ }
7395
+ if (!yHandleEl) {
7396
+ return
7397
+ }
7398
+ const scrollTop = yHandleEl.scrollTop
7399
+ const scrollLeft = headerScrollElem.scrollLeft
7400
+ const isRollX = true
7401
+ const isRollY = false
7402
+ internalData.inHeaderScroll = true
7403
+ setScrollLeft(xHandleEl, scrollLeft)
7404
+ setScrollLeft(footerScrollElem, scrollLeft)
7405
+ setScrollLeft(bodyScrollElem, scrollLeft)
7406
+ $xeTable.triggerScrollXEvent(evnt)
7407
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7408
+ type: 'header',
7409
+ fixed: fixedType
7410
+ })
7411
+ },
7412
+ triggerFooterScrollEvent (evnt: Event, fixedType: '' | 'left' | 'right') {
7413
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7414
+ const internalData = $xeTable as unknown as TableInternalData
7415
+
7416
+ const { elemStore, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData
7417
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7418
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7419
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7420
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7421
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7422
+ if (inWheelScroll) {
7423
+ return
7424
+ }
7425
+ if (inVirtualScroll) {
7426
+ return
7427
+ }
7428
+ if (inHeaderScroll) {
7429
+ return
7430
+ }
7431
+ if (inBodyScroll) {
7432
+ return
7433
+ }
7434
+ if (!footerScrollElem) {
7435
+ return
7436
+ }
7437
+ if (!xHandleEl) {
7438
+ return
7439
+ }
7440
+ if (!yHandleEl) {
7441
+ return
7442
+ }
7443
+ const scrollTop = yHandleEl.scrollTop
7444
+ const scrollLeft = footerScrollElem.scrollLeft
7445
+ const isRollX = true
7446
+ const isRollY = false
7447
+ internalData.inFooterScroll = true
7448
+ setScrollLeft(xHandleEl, scrollLeft)
7449
+ setScrollLeft(headerScrollElem, scrollLeft)
7450
+ setScrollLeft(bodyScrollElem, scrollLeft)
7451
+ $xeTable.triggerScrollXEvent(evnt)
7452
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7453
+ type: 'footer',
7454
+ fixed: fixedType
7455
+ })
7456
+ },
7457
+ triggerBodyWheelEvent (evnt: WheelEvent) {
7458
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7459
+ const tableProps = $xeTable
7460
+ const reactData = $xeTable as unknown as TableReactData
7461
+ const internalData = $xeTable as unknown as TableInternalData
7462
+
7463
+ const { deltaY, deltaX } = evnt
7464
+ const { highlightHoverRow } = tableProps
7465
+ const { elemStore, lastScrollTop, lastScrollLeft } = internalData
7466
+ const rowOpts = $xeTable.computeRowOpts
7467
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7468
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7469
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7470
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7471
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7472
+
7473
+ if (!xHandleEl) {
7474
+ return
7475
+ }
7476
+ if (!yHandleEl) {
7477
+ return
7478
+ }
7479
+ if (!bodyScrollElem) {
7480
+ return
7481
+ }
7482
+
7483
+ let multiple = 1
7484
+
7485
+ if (reactData.lastScrollTime + 25 > Date.now()) {
7486
+ multiple = 1.18
7487
+ } else if (reactData.lastScrollTime + 30 > Date.now()) {
7488
+ multiple = 1.15
7489
+ } else if (reactData.lastScrollTime + 40 > Date.now()) {
7490
+ multiple = 1.12
7491
+ } else if (reactData.lastScrollTime + 55 > Date.now()) {
7492
+ multiple = 1.09
7493
+ } else if (reactData.lastScrollTime + 75 > Date.now()) {
7494
+ multiple = 1.06
7495
+ } else if (reactData.lastScrollTime + 100 > Date.now()) {
7496
+ multiple = 1.03
7497
+ }
7498
+
7499
+ const deltaTop = deltaY * multiple
7500
+ const deltaLeft = deltaX * multiple
7501
+
7502
+ const isTopWheel = deltaTop < 0
7503
+ const currScrollTop = yHandleEl.scrollTop
7504
+ // 如果滚动位置已经是顶部或底部,则不需要触发
7505
+ if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
7506
+ return
7507
+ }
7508
+
7509
+ const scrollTop = bodyScrollElem.scrollTop + deltaTop
7510
+ const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft
7511
+ const isRollX = scrollLeft !== lastScrollLeft
7512
+ const isRollY = scrollTop !== lastScrollTop
7513
+
7514
+ // 用于鼠标纵向滚轮处理
7515
+ if (isRollY) {
7516
+ evnt.preventDefault()
7517
+ if (rowOpts.isHover || highlightHoverRow) {
7518
+ $xeTable.clearHoverRow()
7519
+ }
7520
+
7521
+ internalData.inWheelScroll = true
7522
+ setScrollTop(yHandleEl, scrollTop)
7523
+ setScrollTop(bodyScrollElem, scrollTop)
7524
+ setScrollTop(leftScrollElem, scrollTop)
7525
+ setScrollTop(rightScrollElem, scrollTop)
7526
+ $xeTable.triggerScrollYEvent(evnt)
7527
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7528
+ type: 'footer',
7529
+ fixed: ''
7530
+ })
7531
+ }
7532
+ },
7533
+ scrollXEvent (evnt: Event) {
7534
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7535
+ const internalData = $xeTable as unknown as TableInternalData
7536
+
7537
+ const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
7538
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
7539
+ return
7131
7540
  }
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
7541
+ if (inWheelScroll) {
7542
+ return
7543
+ }
7544
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7545
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7546
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7138
7547
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
7139
7548
  const wrapperEl = evnt.currentTarget as HTMLDivElement
7140
7549
  const { scrollLeft } = wrapperEl
7141
- const yBodyEl = yHandleEl || bodyElem
7550
+ const yBodyEl = yHandleEl || bodyScrollElem
7142
7551
  let scrollTop = 0
7143
7552
  if (yBodyEl) {
7144
7553
  scrollTop = yBodyEl.scrollTop
@@ -7147,9 +7556,9 @@ const Methods = {
7147
7556
  const isRollY = scrollTop !== lastScrollTop
7148
7557
 
7149
7558
  internalData.inVirtualScroll = true
7150
- setScrollLeft(bodyElem, scrollLeft)
7151
- setScrollLeft(headerElem, scrollLeft)
7152
- setScrollLeft(footerElem, scrollLeft)
7559
+ setScrollLeft(bodyScrollElem, scrollLeft)
7560
+ setScrollLeft(headerScrollElem, scrollLeft)
7561
+ setScrollLeft(footerScrollElem, scrollLeft)
7153
7562
  $xeTable.triggerScrollXEvent(evnt)
7154
7563
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7155
7564
  type: 'table',
@@ -7157,28 +7566,23 @@ const Methods = {
7157
7566
  })
7158
7567
  },
7159
7568
  scrollYEvent (evnt: Event) {
7160
- const $xeTable = this
7161
- const internalData = $xeTable
7569
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7570
+ const internalData = $xeTable as unknown as TableInternalData
7162
7571
 
7163
- const { intoRunScroll, inFooterScroll, inBodyScroll, lastScrollLeft } = internalData
7164
- if (!intoRunScroll) {
7165
- if (inFooterScroll) {
7166
- return
7167
- }
7168
- if (inBodyScroll) {
7169
- return
7170
- }
7572
+ const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
7573
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
7574
+ return
7575
+ }
7576
+ if (inWheelScroll) {
7577
+ return
7171
7578
  }
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
7579
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7580
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7581
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7178
7582
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
7179
7583
  const wrapperEl = evnt.currentTarget as HTMLDivElement
7180
7584
  const { scrollTop } = wrapperEl
7181
- const xBodyEl = xHandleEl || bodyElem
7585
+ const xBodyEl = xHandleEl || bodyScrollElem
7182
7586
  let scrollLeft = 0
7183
7587
  if (xBodyEl) {
7184
7588
  scrollLeft = xBodyEl.scrollLeft
@@ -7187,47 +7591,25 @@ const Methods = {
7187
7591
  const isRollY = true
7188
7592
 
7189
7593
  internalData.inVirtualScroll = true
7190
- setScrollTop(bodyElem, scrollTop)
7191
- setScrollTop(leftElem, scrollTop)
7192
- setScrollTop(rightElem, scrollTop)
7594
+ setScrollTop(bodyScrollElem, scrollTop)
7595
+ setScrollTop(leftScrollElem, scrollTop)
7596
+ setScrollTop(rightScrollElem, scrollTop)
7193
7597
  $xeTable.triggerScrollYEvent(evnt)
7194
7598
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7195
7599
  type: 'table',
7196
7600
  fixed: ''
7197
7601
  })
7198
7602
  },
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
7603
  updateScrollXData () {
7222
7604
  const $xeTable = this
7223
7605
  const props = $xeTable
7224
7606
 
7225
7607
  const { showOverflow } = props
7226
- $xeTable.handleTableColumn()
7227
- calcCellHeight($xeTable)
7608
+ handleTableColumn($xeTable)
7609
+ // calcCellHeight()
7228
7610
  return $xeTable.$nextTick().then(() => {
7229
- calcCellHeight($xeTable)
7230
- $xeTable.handleTableColumn()
7611
+ // calcCellHeight()
7612
+ handleTableColumn($xeTable)
7231
7613
  $xeTable.updateScrollXSpace()
7232
7614
  if (!showOverflow) {
7233
7615
  $xeTable.updateScrollYSpace()
@@ -7236,18 +7618,23 @@ const Methods = {
7236
7618
  },
7237
7619
  // 更新横向 X 可视渲染上下剩余空间大小
7238
7620
  updateScrollXSpace () {
7239
- const $xeTable = this
7621
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7622
+ const reactData = $xeTable as unknown as TableReactData
7623
+ const internalData = $xeTable as unknown as TableInternalData
7240
7624
 
7241
- const { $refs, isGroup, elemStore, visibleColumn, scrollXStore, scrollXLoad, tableWidth, scrollbarWidth } = $xeTable
7242
- const { tableHeader, tableBody, tableFooter } = $refs
7243
- const tableBodyElem = tableBody ? tableBody.$el : null
7625
+ const { isGroup, scrollXLoad } = reactData
7626
+ const { visibleColumn, scrollXStore, elemStore, tableWidth } = internalData
7627
+ const tableHeader = $xeTable.$refs.refTableHeader
7628
+ const tableBody = $xeTable.$refs.refTableBody
7629
+ const tableFooter = $xeTable.$refs.refTableFooter
7630
+ const tableBodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
7244
7631
  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)
7632
+ const tableHeaderElem = tableHeader ? (tableHeader as any).$el as HTMLDivElement : null
7633
+ const tableFooterElem = tableFooter ? (tableFooter as any).$el as HTMLDivElement : null
7634
+ const headerElem = tableHeaderElem ? tableHeaderElem.querySelector('.vxe-table--header') as HTMLTableElement : null
7635
+ const bodyElem = tableBodyElem.querySelector('.vxe-table--body') as HTMLTableElement
7636
+ const footerElem = tableFooterElem ? tableFooterElem.querySelector('.vxe-table--footer') as HTMLTableElement : null
7637
+ const leftSpaceWidth = visibleColumn.slice(0, scrollXStore.startIndex).reduce((previous, column) => previous + column.renderWidth, 0)
7251
7638
  let marginLeft = ''
7252
7639
  if (scrollXLoad) {
7253
7640
  marginLeft = `${leftSpaceWidth}px`
@@ -7263,44 +7650,50 @@ const Methods = {
7263
7650
  containerList.forEach(name => {
7264
7651
  const layoutList = ['header', 'body', 'footer']
7265
7652
  layoutList.forEach(layout => {
7266
- const xSpaceElem = elemStore[`${name}-${layout}-xSpace`]
7653
+ const xSpaceElem = getRefElem(elemStore[`${name}-${layout}-xSpace`])
7267
7654
  if (xSpaceElem) {
7268
- xSpaceElem.style.width = scrollXLoad ? `${tableWidth + (layout === 'header' ? scrollbarWidth : 0)}px` : ''
7655
+ xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : ''
7269
7656
  }
7270
7657
  })
7271
7658
  })
7272
- const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem
7659
+ const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem as HTMLDivElement
7273
7660
  if (scrollXSpaceEl) {
7274
- scrollXSpaceEl.style.width = `${tableWidth + scrollbarWidth}px`
7661
+ scrollXSpaceEl.style.width = `${tableWidth}px`
7275
7662
  }
7276
- this.$nextTick(this.updateStyle)
7663
+ $xeTable.$nextTick(() => {
7664
+ updateStyle($xeTable)
7665
+ })
7277
7666
  }
7278
7667
  },
7279
7668
  updateScrollYData () {
7280
7669
  const $xeTable = this
7281
7670
 
7282
7671
  $xeTable.handleTableData()
7283
- calcCellHeight($xeTable)
7672
+ // calcCellHeight()
7284
7673
  return $xeTable.$nextTick().then(() => {
7285
- calcCellHeight($xeTable)
7674
+ // calcCellHeight()
7286
7675
  $xeTable.handleTableData()
7287
7676
  $xeTable.updateScrollYSpace()
7288
7677
  })
7289
7678
  },
7290
7679
  // 更新纵向 Y 可视渲染上下剩余空间大小
7291
7680
  updateScrollYSpace () {
7292
- const $xeTable = this
7681
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7682
+ const props = $xeTable
7683
+ const reactData = $xeTable as unknown as TableReactData
7684
+ const internalData = $xeTable as unknown as TableInternalData
7293
7685
 
7294
- const { showOverflow, elemStore, scrollYStore, scrollYLoad, afterFullData, fullAllDataRowIdData } = this
7295
- const { startIndex, rowHeight } = scrollYStore
7296
- let bodyHeight = 0
7297
- let topSpaceHeight = 0
7686
+ const { showOverflow } = props
7687
+ const { scrollYLoad, rowHeight } = reactData
7688
+ const { scrollYStore, elemStore, afterFullData, fullAllDataRowIdData } = internalData
7689
+ const { startIndex } = scrollYStore
7690
+ const bodyTableElem = getRefElem(elemStore['main-body-table'])
7298
7691
  const containerList = ['main', 'left', 'right']
7299
- let marginTop = ''
7300
- let ySpaceHeight = ''
7692
+ let topSpaceHeight = 0
7693
+ let ySpaceHeight = 0
7301
7694
  if (scrollYLoad) {
7302
7695
  if (showOverflow) {
7303
- bodyHeight = afterFullData.length * rowHeight
7696
+ ySpaceHeight = afterFullData.length * rowHeight
7304
7697
  topSpaceHeight = Math.max(0, startIndex * rowHeight)
7305
7698
  } else {
7306
7699
  for (let i = 0; i < afterFullData.length; i++) {
@@ -7308,7 +7701,7 @@ const Methods = {
7308
7701
  const rowid = getRowid($xeTable, row)
7309
7702
  const rowRest = fullAllDataRowIdData[rowid]
7310
7703
  if (rowRest) {
7311
- bodyHeight += rowRest.height || rowHeight
7704
+ ySpaceHeight += rowRest.height || rowHeight
7312
7705
  }
7313
7706
  }
7314
7707
  for (let i = 0; i < startIndex; i++) {
@@ -7320,27 +7713,31 @@ const Methods = {
7320
7713
  }
7321
7714
  }
7322
7715
  }
7323
- marginTop = `${topSpaceHeight}px`
7324
- ySpaceHeight = `${bodyHeight}px`
7716
+ } else {
7717
+ if (bodyTableElem) {
7718
+ ySpaceHeight = bodyTableElem.clientHeight
7719
+ }
7325
7720
  }
7326
7721
  containerList.forEach(name => {
7327
7722
  const layoutList = ['header', 'body', 'footer']
7328
- const tableElem = elemStore[`${name}-body-table`]
7723
+ const tableElem = getRefElem(elemStore[`${name}-body-table`])
7329
7724
  if (tableElem) {
7330
- tableElem.style.marginTop = marginTop
7725
+ tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : ''
7331
7726
  }
7332
7727
  layoutList.forEach(layout => {
7333
- const ySpaceElem = elemStore[`${name}-${layout}-ySpace`]
7728
+ const ySpaceElem = getRefElem(elemStore[`${name}-${layout}-ySpace`])
7334
7729
  if (ySpaceElem) {
7335
- ySpaceElem.style.height = ySpaceHeight
7730
+ ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
7336
7731
  }
7337
7732
  })
7338
7733
  })
7339
- const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem
7734
+ const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem as HTMLDivElement
7340
7735
  if (scrollYSpaceEl) {
7341
- scrollYSpaceEl.style.height = ySpaceHeight
7736
+ scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : ''
7342
7737
  }
7343
- this.$nextTick(this.updateStyle)
7738
+ $xeTable.$nextTick(() => {
7739
+ updateStyle($xeTable)
7740
+ })
7344
7741
  },
7345
7742
  updateScrollYStatus () {
7346
7743
  const $xeTable = this
@@ -7357,12 +7754,12 @@ const Methods = {
7357
7754
  const internalData = $xeTable as unknown as TableInternalData
7358
7755
 
7359
7756
  const { $refs } = this
7360
- const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs
7361
- const tableBodyElem = tableBody ? tableBody.$el : null
7757
+ const { refTableBody, refTableHeader, leftBody, rightBody, refTableFooter } = $refs
7758
+ const tableBodyElem = refTableBody ? refTableBody.$el : null
7362
7759
  const leftBodyElem = leftBody ? leftBody.$el : null
7363
7760
  const rightBodyElem = rightBody ? rightBody.$el : null
7364
- const tableHeaderElem = tableHeader ? tableHeader.$el : null
7365
- const tableFooterElem = tableFooter ? tableFooter.$el : null
7761
+ const tableHeaderElem = refTableHeader ? refTableHeader.$el : null
7762
+ const tableFooterElem = refTableFooter ? refTableFooter.$el : null
7366
7763
  internalData.intoRunScroll = true
7367
7764
  if (XEUtils.isNumber(scrollLeft)) {
7368
7765
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
@@ -7467,45 +7864,37 @@ const Methods = {
7467
7864
  const $xeTable = this
7468
7865
  const internalData = $xeTable
7469
7866
 
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
7867
+ const { elemStore, scrollXStore, scrollYStore } = internalData
7868
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
7869
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
7870
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
7871
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
7872
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
7481
7873
  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
7874
  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
- }
7875
+
7876
+ internalData.intoRunScroll = true
7877
+
7878
+ setScrollLeft(xHandleEl, 0)
7879
+ setScrollLeft(bodyScrollElem, 0)
7880
+ setScrollLeft(headerScrollElem, 0)
7881
+ setScrollLeft(footerScrollElem, 0)
7882
+
7883
+ setScrollTop(yHandleEl, 0)
7884
+ setScrollTop(bodyScrollElem, 0)
7885
+ setScrollTop(leftScrollElem, 0)
7886
+ setScrollTop(rightScrollElem, 0)
7887
+
7497
7888
  scrollXStore.startIndex = 0
7889
+ scrollXStore.visibleStartIndex = 0
7498
7890
  scrollXStore.endIndex = scrollXStore.visibleSize
7891
+ scrollXStore.visibleEndIndex = scrollXStore.visibleSize
7499
7892
  scrollYStore.startIndex = 0
7893
+ scrollYStore.visibleStartIndex = 0
7500
7894
  scrollYStore.endIndex = scrollYStore.visibleSize
7895
+ scrollYStore.visibleEndIndex = scrollYStore.visibleSize
7501
7896
  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)
7897
+ internalData.intoRunScroll = false
7509
7898
  })
7510
7899
  },
7511
7900
  /**
@@ -7531,8 +7920,8 @@ const Methods = {
7531
7920
  const customVal = !XEUtils.isUndefined(cellValue)
7532
7921
  return this.$nextTick().then(() => {
7533
7922
  const { $refs, editRules, validStore } = this
7534
- const tableBody = $refs.tableBody
7535
- if (slotParams && tableBody && editRules) {
7923
+ const refTableBody = $refs.refTableBody
7924
+ if (slotParams && refTableBody && editRules) {
7536
7925
  const { row, column } = slotParams
7537
7926
  const type = 'change'
7538
7927
  if (this.hasCellRules) {
@@ -7566,13 +7955,15 @@ const Methods = {
7566
7955
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
7567
7956
  */
7568
7957
  setMergeCells (merges: any) {
7958
+ const $xeTable = this
7959
+
7569
7960
  if (this.spanMethod) {
7570
7961
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
7571
7962
  }
7572
7963
  setMerges(this, merges, this.mergeList, this.afterFullData)
7573
7964
  return this.$nextTick().then(() => {
7574
7965
  this.updateCellAreas()
7575
- return this.updateStyle()
7966
+ return updateStyle($xeTable)
7576
7967
  })
7577
7968
  },
7578
7969
  /**
@@ -7580,13 +7971,15 @@ const Methods = {
7580
7971
  * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
7581
7972
  */
7582
7973
  removeMergeCells (merges: any) {
7974
+ const $xeTable = this
7975
+
7583
7976
  if (this.spanMethod) {
7584
7977
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
7585
7978
  }
7586
7979
  const rest = removeMerges(this, merges, this.mergeList, this.afterFullData)
7587
7980
  return this.$nextTick().then(() => {
7588
7981
  this.updateCellAreas()
7589
- this.updateStyle()
7982
+ updateStyle($xeTable)
7590
7983
  return rest
7591
7984
  })
7592
7985
  },
@@ -7600,32 +7993,38 @@ const Methods = {
7600
7993
  * 清除所有单元格合并
7601
7994
  */
7602
7995
  clearMergeCells () {
7996
+ const $xeTable = this
7997
+
7603
7998
  this.mergeList = []
7604
7999
  return this.$nextTick().then(() => {
7605
- return this.updateStyle()
8000
+ return updateStyle($xeTable)
7606
8001
  })
7607
8002
  },
7608
8003
  handleDefaultMergeFooterItems () {
7609
8004
  this.setMergeFooterItems(this.mergeFooterItems)
7610
8005
  },
7611
8006
  setMergeFooterItems (merges: any) {
8007
+ const $xeTable = this
8008
+
7612
8009
  if (this.footerSpanMethod) {
7613
8010
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
7614
8011
  }
7615
8012
  setMerges(this, merges, this.mergeFooterList, null)
7616
8013
  return this.$nextTick().then(() => {
7617
8014
  this.updateCellAreas()
7618
- return this.updateStyle()
8015
+ return updateStyle($xeTable)
7619
8016
  })
7620
8017
  },
7621
8018
  removeMergeFooterItems (merges: any) {
8019
+ const $xeTable = this
8020
+
7622
8021
  if (this.footerSpanMethod) {
7623
8022
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
7624
8023
  }
7625
8024
  const rest = removeMerges(this, merges, this.mergeFooterList, null)
7626
8025
  return this.$nextTick().then(() => {
7627
8026
  this.updateCellAreas()
7628
- this.updateStyle()
8027
+ updateStyle($xeTable)
7629
8028
  return rest
7630
8029
  })
7631
8030
  },
@@ -7639,9 +8038,11 @@ const Methods = {
7639
8038
  * 清除所有表尾合并
7640
8039
  */
7641
8040
  clearMergeFooterItems () {
8041
+ const $xeTable = this
8042
+
7642
8043
  this.mergeFooterList = []
7643
8044
  return this.$nextTick().then(() => {
7644
- return this.updateStyle()
8045
+ return updateStyle($xeTable)
7645
8046
  })
7646
8047
  },
7647
8048
  updateZindex () {