vxe-table 3.12.1-beta.2 → 3.12.1-beta.4

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 (127) hide show
  1. package/es/locale/lang/ar-EG.js +2 -1
  2. package/es/locale/lang/de-DE.js +2 -1
  3. package/es/locale/lang/en-US.js +2 -1
  4. package/es/locale/lang/es-ES.js +2 -1
  5. package/es/locale/lang/fr-FR.js +2 -1
  6. package/es/locale/lang/hu-HU.js +2 -1
  7. package/es/locale/lang/hy-AM.js +2 -1
  8. package/es/locale/lang/it-IT.js +2 -1
  9. package/es/locale/lang/ja-JP.js +2 -1
  10. package/es/locale/lang/ko-KR.js +2 -1
  11. package/es/locale/lang/nb-NO.js +2 -1
  12. package/es/locale/lang/pt-BR.js +2 -1
  13. package/es/locale/lang/ru-RU.js +2 -1
  14. package/es/locale/lang/th-TH.js +2 -1
  15. package/es/locale/lang/ug-CN.js +2 -1
  16. package/es/locale/lang/uk-UA.js +2 -1
  17. package/es/locale/lang/vi-VN.js +2 -1
  18. package/es/locale/lang/zh-CHT.js +2 -1
  19. package/es/locale/lang/zh-CN.js +2 -1
  20. package/es/style.css +1 -1
  21. package/es/table/module/edit/mixin.js +5 -5
  22. package/es/table/src/body.js +4 -3
  23. package/es/table/src/cell.js +73 -50
  24. package/es/table/src/header.js +10 -7
  25. package/es/table/src/methods.js +503 -450
  26. package/es/table/src/table.js +2 -1
  27. package/es/ui/index.js +1 -1
  28. package/es/ui/src/log.js +1 -1
  29. package/lib/index.umd.js +704 -597
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/locale/lang/ar-EG.js +2 -1
  32. package/lib/locale/lang/ar-EG.min.js +1 -1
  33. package/lib/locale/lang/de-DE.js +2 -1
  34. package/lib/locale/lang/de-DE.min.js +1 -1
  35. package/lib/locale/lang/en-US.js +2 -1
  36. package/lib/locale/lang/en-US.min.js +1 -1
  37. package/lib/locale/lang/en-US.umd.js +2 -1
  38. package/lib/locale/lang/es-ES.js +2 -1
  39. package/lib/locale/lang/es-ES.min.js +1 -1
  40. package/lib/locale/lang/es-ES.umd.js +2 -1
  41. package/lib/locale/lang/fr-FR.js +2 -1
  42. package/lib/locale/lang/fr-FR.min.js +1 -1
  43. package/lib/locale/lang/hu-HU.js +2 -1
  44. package/lib/locale/lang/hu-HU.min.js +1 -1
  45. package/lib/locale/lang/hu-HU.umd.js +2 -1
  46. package/lib/locale/lang/hy-AM.js +2 -1
  47. package/lib/locale/lang/hy-AM.min.js +1 -1
  48. package/lib/locale/lang/it-IT.js +2 -1
  49. package/lib/locale/lang/it-IT.min.js +1 -1
  50. package/lib/locale/lang/ja-JP.js +2 -1
  51. package/lib/locale/lang/ja-JP.min.js +1 -1
  52. package/lib/locale/lang/ja-JP.umd.js +2 -1
  53. package/lib/locale/lang/ko-KR.js +2 -1
  54. package/lib/locale/lang/ko-KR.min.js +1 -1
  55. package/lib/locale/lang/ko-KR.umd.js +2 -1
  56. package/lib/locale/lang/nb-NO.js +2 -1
  57. package/lib/locale/lang/nb-NO.min.js +1 -1
  58. package/lib/locale/lang/pt-BR.js +2 -1
  59. package/lib/locale/lang/pt-BR.min.js +1 -1
  60. package/lib/locale/lang/pt-BR.umd.js +2 -1
  61. package/lib/locale/lang/ru-RU.js +2 -1
  62. package/lib/locale/lang/ru-RU.min.js +1 -1
  63. package/lib/locale/lang/ru-RU.umd.js +2 -1
  64. package/lib/locale/lang/th-TH.js +2 -1
  65. package/lib/locale/lang/th-TH.min.js +1 -1
  66. package/lib/locale/lang/ug-CN.js +2 -1
  67. package/lib/locale/lang/ug-CN.min.js +1 -1
  68. package/lib/locale/lang/uk-UA.js +2 -1
  69. package/lib/locale/lang/uk-UA.min.js +1 -1
  70. package/lib/locale/lang/uk-UA.umd.js +2 -1
  71. package/lib/locale/lang/vi-VN.js +2 -1
  72. package/lib/locale/lang/vi-VN.min.js +1 -1
  73. package/lib/locale/lang/zh-CHT.js +2 -1
  74. package/lib/locale/lang/zh-CHT.min.js +1 -1
  75. package/lib/locale/lang/zh-CHT.umd.js +2 -1
  76. package/lib/locale/lang/zh-CN.js +2 -1
  77. package/lib/locale/lang/zh-CN.min.js +1 -1
  78. package/lib/locale/lang/zh-CN.umd.js +2 -1
  79. package/lib/style.css +1 -1
  80. package/lib/table/module/edit/mixin.js +10 -5
  81. package/lib/table/module/edit/mixin.min.js +1 -1
  82. package/lib/table/src/body.js +4 -2
  83. package/lib/table/src/body.min.js +1 -1
  84. package/lib/table/src/cell.js +87 -54
  85. package/lib/table/src/cell.min.js +1 -1
  86. package/lib/table/src/header.js +11 -6
  87. package/lib/table/src/header.min.js +1 -1
  88. package/lib/table/src/methods.js +585 -526
  89. package/lib/table/src/methods.min.js +1 -1
  90. package/lib/table/src/table.js +2 -1
  91. package/lib/table/src/table.min.js +1 -1
  92. package/lib/ui/index.js +1 -1
  93. package/lib/ui/index.min.js +1 -1
  94. package/lib/ui/src/log.js +1 -1
  95. package/lib/ui/src/log.min.js +1 -1
  96. package/package.json +2 -2
  97. package/packages/locale/lang/ar-EG.ts +2 -1
  98. package/packages/locale/lang/de-DE.ts +2 -1
  99. package/packages/locale/lang/en-US.ts +2 -1
  100. package/packages/locale/lang/es-ES.ts +2 -1
  101. package/packages/locale/lang/fr-FR.ts +2 -1
  102. package/packages/locale/lang/hu-HU.ts +2 -1
  103. package/packages/locale/lang/hy-AM.ts +2 -1
  104. package/packages/locale/lang/it-IT.ts +2 -1
  105. package/packages/locale/lang/ja-JP.ts +2 -1
  106. package/packages/locale/lang/ko-KR.ts +2 -1
  107. package/packages/locale/lang/nb-NO.ts +2 -1
  108. package/packages/locale/lang/pt-BR.ts +2 -1
  109. package/packages/locale/lang/ru-RU.ts +2 -1
  110. package/packages/locale/lang/th-TH.ts +2 -1
  111. package/packages/locale/lang/ug-CN.ts +2 -1
  112. package/packages/locale/lang/uk-UA.ts +2 -1
  113. package/packages/locale/lang/vi-VN.ts +2 -1
  114. package/packages/locale/lang/zh-CHT.ts +2 -1
  115. package/packages/locale/lang/zh-CN.ts +2 -1
  116. package/packages/table/module/edit/mixin.ts +5 -5
  117. package/packages/table/src/body.ts +4 -2
  118. package/packages/table/src/cell.ts +78 -46
  119. package/packages/table/src/header.ts +13 -10
  120. package/packages/table/src/methods.ts +523 -459
  121. package/packages/table/src/table.ts +3 -1
  122. /package/es/{iconfont.1735881990049.ttf → iconfont.1735908447074.ttf} +0 -0
  123. /package/es/{iconfont.1735881990049.woff → iconfont.1735908447074.woff} +0 -0
  124. /package/es/{iconfont.1735881990049.woff2 → iconfont.1735908447074.woff2} +0 -0
  125. /package/lib/{iconfont.1735881990049.ttf → iconfont.1735908447074.ttf} +0 -0
  126. /package/lib/{iconfont.1735881990049.woff → iconfont.1735908447074.woff} +0 -0
  127. /package/lib/{iconfont.1735881990049.woff2 → iconfont.1735908447074.woff2} +0 -0
@@ -7,7 +7,7 @@ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible,
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 } from '../../../types'
10
+ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, TableInternalData, VxeTablePrivateMethods } from '../../../types'
11
11
 
12
12
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
13
13
 
@@ -107,7 +107,128 @@ function handleVirtualXVisible ($xeTable: any) {
107
107
  return { toVisibleIndex: 0, visibleSize: 6 }
108
108
  }
109
109
 
110
- const computeRowHeight = ($xeTable: any) => {
110
+ /**
111
+ * 更新数据列的 Map
112
+ * 牺牲数据组装的耗时,用来换取使用过程中的流畅
113
+ */
114
+ function cacheColumnMap ($xeTable: VxeTableConstructor) {
115
+ const props = $xeTable
116
+ const reactData = $xeTable as unknown as TableReactData
117
+ const internalData = $xeTable as unknown as TableInternalData
118
+
119
+ const { tableFullColumn, collectColumn } = internalData
120
+ const fullColumnIdData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnIdData = {}
121
+ const fullColumnFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnFieldData = {}
122
+ const mouseOpts = $xeTable.computeMouseOpts
123
+ const columnOpts = $xeTable.computeColumnOpts
124
+ const columnDragOpts = $xeTable.computeColumnDragOpts
125
+ const { isCrossDrag, isSelfToChildDrag } = columnDragOpts
126
+ const rowOpts = $xeTable.computeRowOpts
127
+ const isGroup = collectColumn.some(hasChildrenList)
128
+ let isAllOverflow = !!props.showOverflow
129
+ let expandColumn: VxeTableDefines.ColumnInfo | undefined
130
+ let treeNodeColumn: VxeTableDefines.ColumnInfo | undefined
131
+ let checkboxColumn: VxeTableDefines.ColumnInfo | undefined
132
+ let radioColumn: VxeTableDefines.ColumnInfo | undefined
133
+ let htmlColumn: VxeTableDefines.ColumnInfo | undefined
134
+ let hasFixed: VxeColumnPropTypes.Fixed | undefined
135
+ const handleFunc = (column: VxeTableDefines.ColumnInfo, index: number, items: VxeTableDefines.ColumnInfo[], path?: string[], parentColumn?: VxeTableDefines.ColumnInfo) => {
136
+ const { id: colid, field, fixed, type, treeNode } = column
137
+ const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0 }
138
+ if (field) {
139
+ if (fullColumnFieldData[field]) {
140
+ errLog('vxe.error.colRepet', ['field', field])
141
+ }
142
+ fullColumnFieldData[field] = rest
143
+ } else {
144
+ if (isCrossDrag || isSelfToChildDrag) {
145
+ errLog('vxe.error.emptyProp', ['column.field'])
146
+ }
147
+ }
148
+ if (!hasFixed && fixed) {
149
+ hasFixed = fixed
150
+ }
151
+ if (!htmlColumn && type === 'html') {
152
+ htmlColumn = column
153
+ }
154
+ if (treeNode) {
155
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
156
+ if (treeNodeColumn) {
157
+ warnLog('vxe.error.colRepet', ['tree-node', treeNode])
158
+ }
159
+ }
160
+ if (!treeNodeColumn) {
161
+ treeNodeColumn = column
162
+ }
163
+ } else if (type === 'expand') {
164
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
165
+ if (expandColumn) {
166
+ warnLog('vxe.error.colRepet', ['type', type])
167
+ }
168
+ }
169
+ if (!expandColumn) {
170
+ expandColumn = column
171
+ }
172
+ }
173
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
174
+ if (type === 'checkbox') {
175
+ if (checkboxColumn) {
176
+ warnLog('vxe.error.colRepet', ['type', type])
177
+ }
178
+ if (!checkboxColumn) {
179
+ checkboxColumn = column
180
+ }
181
+ } else if (type === 'radio') {
182
+ if (radioColumn) {
183
+ warnLog('vxe.error.colRepet', ['type', type])
184
+ }
185
+ if (!radioColumn) {
186
+ radioColumn = column
187
+ }
188
+ }
189
+ }
190
+ if (isAllOverflow && column.showOverflow === false) {
191
+ isAllOverflow = false
192
+ }
193
+ if (fullColumnIdData[colid]) {
194
+ errLog('vxe.error.colRepet', ['colId', colid])
195
+ }
196
+ fullColumnIdData[colid] = rest
197
+ }
198
+
199
+ if (isGroup) {
200
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn, nodes) => {
201
+ column.level = nodes.length
202
+ handleFunc(column, index, items, path, parentColumn)
203
+ })
204
+ } else {
205
+ tableFullColumn.forEach(handleFunc)
206
+ }
207
+
208
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
209
+ if (expandColumn && mouseOpts.area) {
210
+ errLog('vxe.error.errConflicts', ['mouse-config.area', 'column.type=expand'])
211
+ }
212
+ }
213
+
214
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
215
+ if (htmlColumn) {
216
+ if (!columnOpts.useKey) {
217
+ errLog('vxe.error.reqProp', ['column-config.useKey & column.type=html'])
218
+ }
219
+ if (!rowOpts.useKey) {
220
+ errLog('vxe.error.reqProp', ['row-config.useKey & column.type=html'])
221
+ }
222
+ }
223
+ }
224
+
225
+ reactData.isGroup = isGroup
226
+ reactData.treeNodeColumn = treeNodeColumn
227
+ reactData.expandColumn = expandColumn
228
+ reactData.isAllOverflow = isAllOverflow
229
+ }
230
+
231
+ function computeRowHeight ($xeTable: any) {
111
232
  const tableHeader = $xeTable.$refs.tableHeader
112
233
  const tableBody = $xeTable.$refs.tableBody
113
234
  const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
@@ -269,15 +390,18 @@ function clearAllSort (_vm: any) {
269
390
  })
270
391
  }
271
392
 
272
- function calcTableHeight (_vm: any, key: 'height' | 'minHeight' | 'maxHeight') {
273
- const { parentHeight } = _vm
274
- const val = _vm[key]
393
+ function calcTableHeight ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, key: 'height' | 'minHeight' | 'maxHeight') {
394
+ const props = $xeTable
395
+ const reactData = $xeTable as unknown as TableReactData
396
+
397
+ const { parentHeight } = reactData
398
+ const val = props[key]
275
399
  let num = 0
276
400
  if (val) {
277
401
  if (val === '100%' || val === 'auto') {
278
402
  num = parentHeight
279
403
  } else {
280
- const excludeHeight = _vm.getExcludeHeight()
404
+ const excludeHeight = $xeTable.getExcludeHeight()
281
405
  if (isScale(val)) {
282
406
  num = Math.floor((XEUtils.toInteger(val) || 1) / 100 * parentHeight)
283
407
  } else {
@@ -289,6 +413,155 @@ function calcTableHeight (_vm: any, key: 'height' | 'minHeight' | 'maxHeight') {
289
413
  return num
290
414
  }
291
415
 
416
+ /**
417
+ * 列宽算法,计算单元格列宽,动态分配可用剩余空间
418
+ * 支持 px、%、固定 混合分配
419
+ * 支持动态列表调整分配
420
+ * 支持自动分配偏移量
421
+ * 支持 width=60 width=60px width=10% min-width=60 min-width=60px min-width=10%
422
+ */
423
+ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
424
+ const props = $xeTable
425
+ const reactData = $xeTable as unknown as TableReactData
426
+ const internalData = $xeTable as unknown as TableInternalData
427
+
428
+ const tableHeader = $xeTable.$refs.tableHeader
429
+ const tableBody = $xeTable.$refs.tableBody
430
+ const tableFooter = $xeTable.$refs.tableFooter
431
+ const bodyElem = tableBody ? (tableBody as any).$el as HTMLDivElement : null
432
+ const headerElem = tableHeader ? (tableHeader as any).$el as HTMLDivElement : null
433
+ const footerElem = tableFooter ? (tableFooter as any).$el as HTMLDivElement : null
434
+ if (!bodyElem) {
435
+ return
436
+ }
437
+ let tableWidth = 0
438
+ const minCellWidth = 40 // 列宽最少限制 40px
439
+ const bodyWidth = bodyElem.clientWidth - 1
440
+ let remainWidth = bodyWidth
441
+ let meanWidth = remainWidth / 100
442
+ const { fit } = props
443
+ const { columnStore } = reactData
444
+ const { resizeList, pxMinList, autoMinList, pxList, scaleList, scaleMinList, autoList, remainList } = columnStore
445
+ // 最小宽
446
+ pxMinList.forEach((column) => {
447
+ const minWidth = XEUtils.toInteger(column.minWidth)
448
+ tableWidth += minWidth
449
+ column.renderWidth = minWidth
450
+ })
451
+ // 最小自适应
452
+ autoMinList.forEach((column) => {
453
+ const scaleWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth))
454
+ tableWidth += scaleWidth
455
+ column.renderWidth = scaleWidth
456
+ })
457
+ // 最小百分比
458
+ scaleMinList.forEach((column) => {
459
+ const scaleWidth = Math.floor(XEUtils.toInteger(column.minWidth) * meanWidth)
460
+ tableWidth += scaleWidth
461
+ column.renderWidth = scaleWidth
462
+ })
463
+ // 固定百分比
464
+ scaleList.forEach((column) => {
465
+ const scaleWidth = Math.floor(XEUtils.toInteger(column.width) * meanWidth)
466
+ tableWidth += scaleWidth
467
+ column.renderWidth = scaleWidth
468
+ })
469
+ // 固定宽
470
+ pxList.forEach((column) => {
471
+ const width = XEUtils.toInteger(column.width)
472
+ tableWidth += width
473
+ column.renderWidth = width
474
+ })
475
+ // 自适应宽
476
+ autoList.forEach((column) => {
477
+ const width = Math.max(60, XEUtils.toInteger(column.renderAutoWidth))
478
+ tableWidth += width
479
+ column.renderWidth = width
480
+ })
481
+ // 调整了列宽
482
+ resizeList.forEach((column) => {
483
+ const width = XEUtils.toInteger(column.resizeWidth)
484
+ tableWidth += width
485
+ column.renderWidth = width
486
+ })
487
+ remainWidth -= tableWidth
488
+ meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoMinList.length + remainList.length)) : 0
489
+ if (fit) {
490
+ if (remainWidth > 0) {
491
+ scaleMinList.concat(pxMinList).concat(autoMinList).forEach((column) => {
492
+ tableWidth += meanWidth
493
+ column.renderWidth += meanWidth
494
+ })
495
+ }
496
+ } else {
497
+ meanWidth = minCellWidth
498
+ }
499
+ // 剩余均分
500
+ remainList.forEach((column) => {
501
+ const width = Math.max(meanWidth, minCellWidth)
502
+ column.renderWidth = width
503
+ tableWidth += width
504
+ })
505
+ if (fit) {
506
+ /**
507
+ * 偏移量算法
508
+ * 如果所有列足够放的情况下,从最后动态列开始分配
509
+ */
510
+ const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList)
511
+ let dynamicSize = dynamicList.length - 1
512
+ if (dynamicSize > 0) {
513
+ let odiffer = bodyWidth - tableWidth
514
+ if (odiffer > 0) {
515
+ while (odiffer > 0 && dynamicSize >= 0) {
516
+ odiffer--
517
+ dynamicList[dynamicSize--].renderWidth++
518
+ }
519
+ tableWidth = bodyWidth
520
+ }
521
+ }
522
+ }
523
+ const tableHeight = bodyElem.offsetHeight
524
+ const overflowY = bodyElem.scrollHeight > bodyElem.clientHeight
525
+ let scrollbarWidth = 0
526
+ if (overflowY) {
527
+ scrollbarWidth = Math.max(bodyElem.offsetWidth - bodyElem.clientWidth, 0)
528
+ }
529
+ reactData.scrollbarWidth = scrollbarWidth
530
+ reactData.overflowY = overflowY
531
+ internalData.tableWidth = tableWidth
532
+ internalData.tableHeight = tableHeight
533
+ let headerHeight = 0
534
+ if (headerElem) {
535
+ headerHeight = headerElem.clientHeight
536
+ $xeTable.$nextTick(() => {
537
+ // 检测是否同步滚动
538
+ if (headerElem && bodyElem && headerElem.scrollLeft !== bodyElem.scrollLeft) {
539
+ headerElem.scrollLeft = bodyElem.scrollLeft
540
+ }
541
+ })
542
+ }
543
+ internalData.headerHeight = headerHeight
544
+ let overflowX = false
545
+ let footerHeight = 0
546
+ let scrollbarHeight = 0
547
+ if (footerElem) {
548
+ footerHeight = footerElem.offsetHeight
549
+ overflowX = tableWidth > footerElem.clientWidth
550
+ scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0)
551
+ } else {
552
+ overflowX = tableWidth > bodyWidth
553
+ scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0)
554
+ }
555
+ internalData.footerHeight = footerHeight
556
+ reactData.overflowX = overflowX
557
+ reactData.scrollbarHeight = scrollbarHeight
558
+ updateHeight($xeTable)
559
+ reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight())
560
+ if (overflowX) {
561
+ $xeTable.checkScrolling()
562
+ }
563
+ }
564
+
292
565
  // const updateCellOffset = ($xeTable: VxeTableConstructor) => {
293
566
  // const internalData = $xeTable as unknown as TableInternalData
294
567
 
@@ -405,7 +678,7 @@ function updateRowDropOrigin ($xeTable: any, row: any) {
405
678
  }
406
679
  }
407
680
 
408
- const updateRowDropTipContent = ($xeTable: any, tdEl: HTMLElement) => {
681
+ function updateRowDropTipContent ($xeTable: any, tdEl: HTMLElement) {
409
682
  const reactData = $xeTable
410
683
  const props = $xeTable
411
684
 
@@ -425,7 +698,7 @@ const updateRowDropTipContent = ($xeTable: any, tdEl: HTMLElement) => {
425
698
  reactData.dragTipText = tipContent
426
699
  }
427
700
 
428
- const updateColDropOrigin = ($xeTable: any, column: VxeTableDefines.ColumnInfo) => {
701
+ function updateColDropOrigin ($xeTable: any, column: VxeTableDefines.ColumnInfo) {
429
702
  const el = $xeTable.$el as HTMLElement
430
703
  if (el) {
431
704
  const colQuerys: string[] = []
@@ -439,7 +712,7 @@ const updateColDropOrigin = ($xeTable: any, column: VxeTableDefines.ColumnInfo)
439
712
  }
440
713
  }
441
714
 
442
- const clearColDropOrigin = ($xeTable: any) => {
715
+ function clearColDropOrigin ($xeTable: any) {
443
716
  const el = $xeTable.$el as HTMLElement
444
717
  if (el) {
445
718
  const clss = 'col--drag-origin'
@@ -450,7 +723,7 @@ const clearColDropOrigin = ($xeTable: any) => {
450
723
  }
451
724
  }
452
725
 
453
- const updateColDropTipContent = ($xeTable: any, tdEl: HTMLElement) => {
726
+ function updateColDropTipContent ($xeTable: any, tdEl: HTMLElement) {
454
727
  const reactData = $xeTable
455
728
 
456
729
  const { dragCol } = reactData
@@ -546,7 +819,7 @@ function showDropTip ($xeTable: any, evnt: DragEvent | MouseEvent, trEl: HTMLEle
546
819
  }
547
820
  }
548
821
 
549
- const hideDropTip = ($xeTable: any) => {
822
+ function hideDropTip ($xeTable: any) {
550
823
  const rdTipEl = $xeTable.$refs.refDragTipElem as HTMLDivElement
551
824
  const rdLineEl = $xeTable.$refs.refDragRowLineElem as HTMLDivElement
552
825
  const cdLineEl = $xeTable.$refs.refDragColLineElem as HTMLDivElement
@@ -561,8 +834,8 @@ const hideDropTip = ($xeTable: any) => {
561
834
  }
562
835
  }
563
836
 
564
- const handleScrollToRowColumn = ($xeTable: any, fieldOrColumn: string | VxeTableDefines.ColumnInfo | null, row?: any) => {
565
- const internalData = $xeTable
837
+ function handleScrollToRowColumn ($xeTable: VxeTableConstructor, fieldOrColumn: string | VxeTableDefines.ColumnInfo | null, row?: any) {
838
+ const internalData = $xeTable as unknown as TableInternalData
566
839
 
567
840
  const { fullColumnIdData } = internalData
568
841
  const column = handleFieldOrColumn($xeTable, fieldOrColumn)
@@ -572,30 +845,129 @@ const handleScrollToRowColumn = ($xeTable: any, fieldOrColumn: string | VxeTable
572
845
  return $xeTable.$nextTick()
573
846
  }
574
847
 
575
- function handleRecalculateLayout ($xeTable: any, reFull: boolean) {
576
- const internalData = $xeTable
848
+ // 计算可视渲染相关数据
849
+ function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
850
+ const reactData = $xeTable as unknown as TableReactData
851
+ const internalData = $xeTable as unknown as TableInternalData
852
+
853
+ return $xeTable.$nextTick().then(() => {
854
+ const { scrollXLoad, scrollYLoad } = reactData
855
+ const { scrollXStore, scrollYStore } = internalData
856
+ const sYOpts = $xeTable.computeSYOpts
857
+ const sXOpts = $xeTable.computeSXOpts
858
+ // 计算 X 逻辑
859
+ if (scrollXLoad) {
860
+ const { visibleSize: visibleXSize } = handleVirtualXVisible($xeTable)
861
+ const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : (browse.edge ? 5 : 0))
862
+ scrollXStore.offsetSize = offsetXSize
863
+ scrollXStore.visibleSize = visibleXSize
864
+ scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex)
865
+ $xeTable.updateScrollXData().then(() => {
866
+ loadScrollXData($xeTable)
867
+ })
868
+ } else {
869
+ $xeTable.updateScrollXSpace()
870
+ }
871
+ calcCellHeight($xeTable)
872
+ // 计算 Y 逻辑
873
+ const rowHeight = computeRowHeight($xeTable)
874
+ scrollYStore.rowHeight = rowHeight
875
+ reactData.rowHeight = rowHeight
876
+ const { visibleSize: visibleYSize } = handleVirtualYVisible($xeTable)
877
+ if (scrollYLoad) {
878
+ const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : (browse.edge ? 10 : 0))
879
+ scrollYStore.offsetSize = offsetYSize
880
+ scrollYStore.visibleSize = visibleYSize
881
+ scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex)
882
+ $xeTable.updateScrollYData().then(() => {
883
+ loadScrollYData($xeTable)
884
+ })
885
+ } else {
886
+ $xeTable.updateScrollYSpace()
887
+ }
888
+ $xeTable.$nextTick(() => {
889
+ ($xeTable as any).updateStyle()
890
+ })
891
+ })
892
+ }
577
893
 
578
- const el = $xeTable.$refs.refElem
894
+ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, reFull: boolean) {
895
+ const internalData = $xeTable as unknown as TableInternalData
896
+
897
+ const el = $xeTable.$refs.refElem as HTMLDivElement
579
898
  internalData.rceRunTime = Date.now()
580
899
  if (!el || !el.clientWidth) {
581
900
  return $xeTable.$nextTick()
582
901
  }
583
- $xeTable.calcCellWidth()
584
- $xeTable.autoCellWidth()
585
- return $xeTable.computeScrollLoad().then(() => {
902
+ calcCellWidth($xeTable)
903
+ autoCellWidth($xeTable)
904
+ return computeScrollLoad($xeTable).then(() => {
586
905
  if (reFull === true) {
587
906
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
588
907
  calcCellHeight($xeTable)
589
- $xeTable.calcCellWidth()
590
- $xeTable.autoCellWidth()
591
- return $xeTable.computeScrollLoad()
908
+ calcCellWidth($xeTable)
909
+ autoCellWidth($xeTable)
910
+ return computeScrollLoad($xeTable)
592
911
  }
593
912
  })
594
913
  }
595
914
 
596
- function checkLastSyncScroll ($xeTable: any, isRollX: boolean, isRollY: boolean) {
597
- const reactData = $xeTable
598
- const internalData = $xeTable
915
+ function loadScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
916
+ const reactData = $xeTable as unknown as TableReactData
917
+ const internalData = $xeTable as unknown as TableInternalData
918
+
919
+ const { mergeList, mergeFooterList } = reactData
920
+ const { scrollXStore } = internalData
921
+ const { startIndex, endIndex, offsetSize } = scrollXStore
922
+ const { toVisibleIndex, visibleSize } = handleVirtualXVisible($xeTable)
923
+ const offsetItem = {
924
+ startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
925
+ endIndex: toVisibleIndex + visibleSize + offsetSize
926
+ }
927
+ calculateMergerOffsetIndex(mergeList.concat(mergeFooterList), offsetItem, 'col')
928
+ const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem
929
+ if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
930
+ if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
931
+ scrollXStore.startIndex = offsetStartIndex
932
+ scrollXStore.endIndex = offsetEndIndex
933
+ $xeTable.updateScrollXData()
934
+ }
935
+ }
936
+ $xeTable.closeTooltip()
937
+ }
938
+
939
+ /**
940
+ * 纵向 Y 可视渲染处理
941
+ */
942
+ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
943
+ const props = $xeTable
944
+ const reactData = $xeTable as unknown as TableReactData
945
+ const internalData = $xeTable as unknown as TableInternalData
946
+
947
+ const { showOverflow } = props
948
+ const { mergeList } = reactData
949
+ const { tableHeight, scrollYStore } = internalData
950
+ const { startIndex, endIndex, offsetSize } = scrollYStore
951
+ const offsetYSize = showOverflow ? offsetSize : offsetSize + Math.min(8, Math.ceil(tableHeight / 200))
952
+ const { toVisibleIndex, visibleSize } = handleVirtualYVisible($xeTable)
953
+ const offsetItem = {
954
+ startIndex: Math.max(0, toVisibleIndex - 1 - offsetYSize),
955
+ endIndex: toVisibleIndex + visibleSize + offsetYSize
956
+ }
957
+ calculateMergerOffsetIndex(mergeList, offsetItem, 'row')
958
+ const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem
959
+ if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
960
+ if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
961
+ scrollYStore.startIndex = offsetStartIndex
962
+ scrollYStore.endIndex = offsetEndIndex
963
+ $xeTable.updateScrollYData()
964
+ }
965
+ }
966
+ }
967
+
968
+ function checkLastSyncScroll ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, isRollX: boolean, isRollY: boolean) {
969
+ const reactData = $xeTable as unknown as TableReactData
970
+ const internalData = $xeTable as unknown as TableInternalData
599
971
 
600
972
  const { scrollXLoad, scrollYLoad } = reactData
601
973
  const { lcsTimeout } = internalData
@@ -610,18 +982,81 @@ function checkLastSyncScroll ($xeTable: any, isRollX: boolean, isRollY: boolean)
610
982
  internalData.inFooterScroll = false
611
983
  if (isRollX && scrollXLoad) {
612
984
  $xeTable.updateScrollXData().then(() => {
613
- $xeTable.loadScrollXData()
985
+ loadScrollXData($xeTable)
614
986
  })
615
987
  }
616
988
  if (isRollY && scrollYLoad) {
617
989
  $xeTable.updateScrollYData().then(() => {
618
- $xeTable.loadScrollYData()
990
+ loadScrollYData($xeTable)
619
991
  })
620
992
  }
621
993
  $xeTable.updateCellAreas()
622
994
  }, 200)
623
995
  }
624
996
 
997
+ function updateHeight ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
998
+ const internalData = $xeTable as unknown as TableInternalData
999
+
1000
+ internalData.customHeight = calcTableHeight($xeTable, 'height')
1001
+ internalData.customMinHeight = calcTableHeight($xeTable, 'minHeight')
1002
+ internalData.customMaxHeight = calcTableHeight($xeTable, 'maxHeight')
1003
+ }
1004
+
1005
+ function calcColumnAutoWidth (column: VxeTableDefines.ColumnInfo, wrapperEl: HTMLDivElement) {
1006
+ const cellElList = wrapperEl.querySelectorAll(`.vxe-header--column.${column.id}>.vxe-cell,.vxe-body--column.${column.id}>.vxe-cell,.vxe-footer--column.${column.id}>.vxe-cell`)
1007
+ const firstCellEl = cellElList[0]
1008
+ let paddingSize = 0
1009
+ if (firstCellEl) {
1010
+ const cellStyle = getComputedStyle(firstCellEl)
1011
+ paddingSize = Math.floor(XEUtils.toNumber(cellStyle.paddingLeft) + XEUtils.toNumber(cellStyle.paddingRight)) + 2
1012
+ }
1013
+ let colWidth = column.renderAutoWidth - paddingSize
1014
+ XEUtils.arrayEach(cellElList, (itemEl) => {
1015
+ const cellEl = itemEl as HTMLElement
1016
+ const thElem = cellEl.parentElement as HTMLElement
1017
+ let titleWidth = 0
1018
+ if (`${thElem.tagName}`.toLowerCase() === 'th') {
1019
+ XEUtils.arrayEach(cellEl.children, (btnEl) => {
1020
+ titleWidth += (btnEl as HTMLElement).offsetWidth + 1
1021
+ })
1022
+ } else {
1023
+ const labelEl = cellEl.firstElementChild as HTMLElement
1024
+ if (labelEl) {
1025
+ titleWidth = labelEl.offsetWidth
1026
+ }
1027
+ }
1028
+ if (titleWidth) {
1029
+ colWidth = Math.max(colWidth, Math.ceil(titleWidth) + 4)
1030
+ }
1031
+ })
1032
+ return colWidth + paddingSize
1033
+ }
1034
+
1035
+ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1036
+ const reactData = $xeTable as unknown as TableReactData
1037
+ const internalData = $xeTable as unknown as TableInternalData
1038
+
1039
+ const autoWidthColumnList = $xeTable.computeAutoWidthColumnList
1040
+ reactData.isCalcColumn = true
1041
+ return $xeTable.$nextTick().then(() => {
1042
+ const { fullColumnIdData } = internalData
1043
+ const el = $xeTable.$refs.refElem as HTMLDivElement
1044
+ if (el) {
1045
+ autoWidthColumnList.forEach(column => {
1046
+ const colid = column.id
1047
+ const colRest = fullColumnIdData[colid]
1048
+ const colWidth = calcColumnAutoWidth(column, el)
1049
+ if (colRest) {
1050
+ colRest.width = Math.max(colWidth, colRest.width)
1051
+ }
1052
+ column.renderAutoWidth = colWidth
1053
+ })
1054
+ $xeTable.analyColumnWidth()
1055
+ }
1056
+ reactData.isCalcColumn = false
1057
+ })
1058
+ }
1059
+
625
1060
  const Methods = {
626
1061
  callSlot (slotFunc: any, params: any, h: any, vNodes: any) {
627
1062
  if (slotFunc) {
@@ -832,10 +1267,10 @@ const Methods = {
832
1267
  this.handleTableData(true)
833
1268
  this.updateFooter()
834
1269
  return this.$nextTick().then(() => {
835
- this.updateHeight()
1270
+ updateHeight($xeTable)
836
1271
  this.updateStyle()
837
1272
  }).then(() => {
838
- this.computeScrollLoad()
1273
+ computeScrollLoad($xeTable)
839
1274
  }).then(() => {
840
1275
  // 是否启用了虚拟滚动
841
1276
  if (sYLoad) {
@@ -980,10 +1415,10 @@ const Methods = {
980
1415
  this.restoreCustomStorage()
981
1416
  ).then(() => {
982
1417
  this._isLoading = false
983
- this.cacheColumnMap()
1418
+ cacheColumnMap($xeTable)
984
1419
  this.parseColumns(true).then(() => {
985
1420
  if (this.scrollXLoad) {
986
- this.loadScrollXData(true)
1421
+ loadScrollXData($xeTable)
987
1422
  }
988
1423
  })
989
1424
  this.clearMergeCells()
@@ -1033,7 +1468,7 @@ const Methods = {
1033
1468
  }
1034
1469
  let cacheItem = fullAllDataRowIdData[rowid]
1035
1470
  if (!cacheItem) {
1036
- cacheItem = { row, rowid, seq, index: -1, _index: -1, $index: -1, items, parent: parentRow, level, height: 0 }
1471
+ cacheItem = { row, rowid, seq, index: -1, _index: -1, $index: -1, items, parent: parentRow, level, height: 0, oTop: 0 }
1037
1472
  }
1038
1473
  cacheItem.row = row
1039
1474
  cacheItem.items = items
@@ -1106,7 +1541,7 @@ const Methods = {
1106
1541
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
1107
1542
  const rowid = getRowid($xeTable, childRow)
1108
1543
  const parentRow = parentItem || parentRest.row
1109
- const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0 }
1544
+ const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0, oTop: 0 }
1110
1545
  fullDataRowIdData[rowid] = rest
1111
1546
  fullAllDataRowIdData[rowid] = rest
1112
1547
  }, { children: childrenField })
@@ -1118,127 +1553,6 @@ const Methods = {
1118
1553
  return rows
1119
1554
  })
1120
1555
  },
1121
- /**
1122
- * 更新数据列的 Map
1123
- * 牺牲数据组装的耗时,用来换取使用过程中的流畅
1124
- */
1125
- cacheColumnMap () {
1126
- const $xeTable = this
1127
- const props = $xeTable
1128
- const reactData = $xeTable
1129
- const internalData = $xeTable
1130
-
1131
- const { tableFullColumn, collectColumn } = internalData
1132
- const fullColumnIdData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnIdData = {}
1133
- const fullColumnFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnFieldData = {}
1134
- const mouseOpts = $xeTable.computeMouseOpts
1135
- const columnOpts = $xeTable.computeColumnOpts
1136
- const columnDragOpts = $xeTable.computeColumnDragOpts
1137
- const { isCrossDrag, isSelfToChildDrag } = columnDragOpts
1138
- const rowOpts = $xeTable.computeRowOpts
1139
- const isGroup = collectColumn.some(hasChildrenList)
1140
- let isAllOverflow = !!props.showOverflow
1141
- let expandColumn: VxeTableDefines.ColumnInfo | undefined
1142
- let treeNodeColumn: VxeTableDefines.ColumnInfo | undefined
1143
- let checkboxColumn: VxeTableDefines.ColumnInfo | undefined
1144
- let radioColumn: VxeTableDefines.ColumnInfo | undefined
1145
- let htmlColumn: VxeTableDefines.ColumnInfo | undefined
1146
- let hasFixed: VxeColumnPropTypes.Fixed | undefined
1147
- const handleFunc = (column: VxeTableDefines.ColumnInfo, index: number, items: VxeTableDefines.ColumnInfo[], path?: string[], parentColumn?: VxeTableDefines.ColumnInfo) => {
1148
- const { id: colid, field, fixed, type, treeNode } = column
1149
- const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0 }
1150
- if (field) {
1151
- if (fullColumnFieldData[field]) {
1152
- errLog('vxe.error.colRepet', ['field', field])
1153
- }
1154
- fullColumnFieldData[field] = rest
1155
- } else {
1156
- if (isCrossDrag || isSelfToChildDrag) {
1157
- errLog('vxe.error.emptyProp', ['column.field'])
1158
- }
1159
- }
1160
- if (!hasFixed && fixed) {
1161
- hasFixed = fixed
1162
- }
1163
- if (!htmlColumn && type === 'html') {
1164
- htmlColumn = column
1165
- }
1166
- if (treeNode) {
1167
- if (process.env.VUE_APP_VXE_ENV === 'development') {
1168
- if (treeNodeColumn) {
1169
- warnLog('vxe.error.colRepet', ['tree-node', treeNode])
1170
- }
1171
- }
1172
- if (!treeNodeColumn) {
1173
- treeNodeColumn = column
1174
- }
1175
- } else if (type === 'expand') {
1176
- if (process.env.VUE_APP_VXE_ENV === 'development') {
1177
- if (expandColumn) {
1178
- warnLog('vxe.error.colRepet', ['type', type])
1179
- }
1180
- }
1181
- if (!expandColumn) {
1182
- expandColumn = column
1183
- }
1184
- }
1185
- if (process.env.VUE_APP_VXE_ENV === 'development') {
1186
- if (type === 'checkbox') {
1187
- if (checkboxColumn) {
1188
- warnLog('vxe.error.colRepet', ['type', type])
1189
- }
1190
- if (!checkboxColumn) {
1191
- checkboxColumn = column
1192
- }
1193
- } else if (type === 'radio') {
1194
- if (radioColumn) {
1195
- warnLog('vxe.error.colRepet', ['type', type])
1196
- }
1197
- if (!radioColumn) {
1198
- radioColumn = column
1199
- }
1200
- }
1201
- }
1202
- if (isAllOverflow && column.showOverflow === false) {
1203
- isAllOverflow = false
1204
- }
1205
- if (fullColumnIdData[colid]) {
1206
- errLog('vxe.error.colRepet', ['colId', colid])
1207
- }
1208
- fullColumnIdData[colid] = rest
1209
- }
1210
-
1211
- if (isGroup) {
1212
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn, nodes) => {
1213
- column.level = nodes.length
1214
- handleFunc(column, index, items, path, parentColumn)
1215
- })
1216
- } else {
1217
- tableFullColumn.forEach(handleFunc)
1218
- }
1219
-
1220
- if (process.env.VUE_APP_VXE_ENV === 'development') {
1221
- if (expandColumn && mouseOpts.area) {
1222
- errLog('vxe.error.errConflicts', ['mouse-config.area', 'column.type=expand'])
1223
- }
1224
- }
1225
-
1226
- if (process.env.VUE_APP_VXE_ENV === 'development') {
1227
- if (htmlColumn) {
1228
- if (!columnOpts.useKey) {
1229
- errLog('vxe.error.reqProp', ['column-config.useKey & column.type=html'])
1230
- }
1231
- if (!rowOpts.useKey) {
1232
- errLog('vxe.error.reqProp', ['row-config.useKey & column.type=html'])
1233
- }
1234
- }
1235
- }
1236
-
1237
- reactData.isGroup = isGroup
1238
- reactData.treeNodeColumn = treeNodeColumn
1239
- reactData.expandColumn = expandColumn
1240
- reactData.isAllOverflow = isAllOverflow
1241
- },
1242
1556
  /**
1243
1557
  * 根据 tr 元素获取对应的 row 信息
1244
1558
  * @param {Element} tr 元素
@@ -1955,7 +2269,7 @@ const Methods = {
1955
2269
  if (rowRest) {
1956
2270
  rowRest._index = index
1957
2271
  } else {
1958
- const rest = { row, rowid, seq: '-1', index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0 }
2272
+ const rest = { row, rowid, seq: '-1', index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0, oTop: 0 }
1959
2273
  fullAllDataRowIdData[rowid] = rest
1960
2274
  fullDataRowIdData[rowid] = rest
1961
2275
  }
@@ -1986,7 +2300,7 @@ const Methods = {
1986
2300
  rowRest.seq = seq
1987
2301
  rowRest._index = index
1988
2302
  } else {
1989
- const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0 }
2303
+ const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0, oTop: 0 }
1990
2304
  fullAllDataRowIdData[rowid] = rest
1991
2305
  fullDataRowIdData[rowid] = rest
1992
2306
  }
@@ -2002,7 +2316,7 @@ const Methods = {
2002
2316
  rowRest.seq = seq
2003
2317
  rowRest._index = index
2004
2318
  } else {
2005
- const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0 }
2319
+ const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0, oTop: 0 }
2006
2320
  fullAllDataRowIdData[rowid] = rest
2007
2321
  fullDataRowIdData[rowid] = rest
2008
2322
  }
@@ -2707,6 +3021,35 @@ const Methods = {
2707
3021
  })
2708
3022
  Object.assign(this.columnStore, { resizeList, pxList, pxMinList, autoMinList, scaleList, scaleMinList, autoList, remainList })
2709
3023
  },
3024
+ handleResizeDblclickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams) {
3025
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3026
+ const reactData = $xeTable as unknown as TableReactData
3027
+ const internalData = $xeTable as unknown as TableInternalData
3028
+
3029
+ const resizableOpts = $xeTable.computeResizableOpts
3030
+ const { isDblclickAutoWidth } = resizableOpts
3031
+ const el = $xeTable.$refs.refElem as HTMLDivElement
3032
+ if (isDblclickAutoWidth && el) {
3033
+ const { fullColumnIdData } = internalData
3034
+ const { column } = params
3035
+ const colid = column.id
3036
+ const colRest = fullColumnIdData[colid]
3037
+ let resizeWidth = calcColumnAutoWidth(column, el)
3038
+ if (colRest) {
3039
+ resizeWidth = Math.max(resizeWidth, colRest.width)
3040
+ }
3041
+ column.resizeWidth = resizeWidth
3042
+ reactData._isResize = false
3043
+ internalData._lastResizeTime = Date.now()
3044
+ $xeTable.analyColumnWidth()
3045
+ $xeTable.recalculate(true).then(() => {
3046
+ $xeTable.saveCustomStore('update:visible')
3047
+ $xeTable.updateCellAreas()
3048
+ $xeTable.dispatchEvent('resizable-change', { ...params, resizeWidth }, evnt)
3049
+ setTimeout(() => $xeTable.recalculate(true), 300)
3050
+ })
3051
+ }
3052
+ },
2710
3053
  /**
2711
3054
  * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
2712
3055
  */
@@ -2749,7 +3092,7 @@ const Methods = {
2749
3092
  const refreshDelay = resizeOpts.refreshDelay || 20
2750
3093
  const el = $xeTable.$refs.refElem as HTMLElement
2751
3094
  if (el && el.clientWidth) {
2752
- $xeTable.autoCellWidth()
3095
+ autoCellWidth($xeTable)
2753
3096
  }
2754
3097
  if (rceTimeout) {
2755
3098
  clearTimeout(rceTimeout)
@@ -2773,197 +3116,6 @@ const Methods = {
2773
3116
  }, refreshDelay)
2774
3117
  })
2775
3118
  },
2776
- calcCellWidth () {
2777
- const $xeTable = this
2778
-
2779
- const { autoWidthColumnList } = this
2780
- this.isCalcColumn = true
2781
- return this.$nextTick().then(() => {
2782
- const internalData = $xeTable
2783
-
2784
- const { fullColumnIdData } = internalData
2785
- const el = this.$el
2786
- if (el) {
2787
- autoWidthColumnList.forEach((column: any) => {
2788
- const colid = column.id
2789
- const colRest = fullColumnIdData[colid]
2790
- const cellElList = el.querySelectorAll(`.vxe-header--column.${column.id}>.vxe-cell,.vxe-body--column.${column.id}>.vxe-cell,.vxe-footer--column.${column.id}>.vxe-cell`)
2791
- const firstCellEl = cellElList[0]
2792
- let paddingSize = 0
2793
- if (firstCellEl) {
2794
- const cellStyle = getComputedStyle(firstCellEl)
2795
- paddingSize = Math.floor(XEUtils.toNumber(cellStyle.paddingLeft) + XEUtils.toNumber(cellStyle.paddingRight)) + 2
2796
- }
2797
- let colWidth = column.renderAutoWidth - paddingSize
2798
- XEUtils.arrayEach(cellElList, (itemEl) => {
2799
- const cellEl = itemEl as HTMLElement
2800
- const thElem = cellEl.parentElement as HTMLElement
2801
- let titleWidth = 0
2802
- if (`${thElem.tagName}`.toLowerCase() === 'th') {
2803
- XEUtils.arrayEach(cellEl.children, (btnEl) => {
2804
- titleWidth += (btnEl as HTMLElement).offsetWidth + 1
2805
- })
2806
- } else {
2807
- const labelEl = cellEl.firstElementChild as HTMLElement
2808
- if (labelEl) {
2809
- titleWidth = labelEl.offsetWidth
2810
- }
2811
- }
2812
- if (titleWidth) {
2813
- colWidth = Math.max(colWidth, Math.ceil(titleWidth) + 4)
2814
- }
2815
- })
2816
- if (colRest) {
2817
- colRest.width = Math.max(colWidth, colRest.width)
2818
- }
2819
- column.renderAutoWidth = colWidth + paddingSize
2820
- })
2821
- this.analyColumnWidth()
2822
- }
2823
- this.isCalcColumn = false
2824
- })
2825
- },
2826
- /**
2827
- * 列宽算法,计算单元格列宽,动态分配可用剩余空间
2828
- * 支持 px、%、固定 混合分配
2829
- * 支持动态列表调整分配
2830
- * 支持自动分配偏移量
2831
- * 支持 width=60 width=60px width=10% min-width=60 min-width=60px min-width=10%
2832
- */
2833
- autoCellWidth () {
2834
- const { $refs } = this
2835
- const { tableBody, tableHeader, tableFooter } = $refs
2836
- const bodyElem = tableBody ? tableBody.$el : null
2837
- const headerElem = tableHeader ? tableHeader.$el : null
2838
- const footerElem = tableFooter ? tableFooter.$el : null
2839
-
2840
- let tableWidth = 0
2841
- const minCellWidth = 40 // 列宽最少限制 40px
2842
- const bodyWidth = bodyElem.clientWidth - 1
2843
- let remainWidth = bodyWidth
2844
- let meanWidth = remainWidth / 100
2845
- const { fit, columnStore } = this
2846
- const { resizeList, pxMinList, pxList, autoMinList, scaleList, scaleMinList, autoList, remainList } = columnStore
2847
- // 最小宽
2848
- pxMinList.forEach((column: any) => {
2849
- const minWidth = parseInt(column.minWidth)
2850
- tableWidth += minWidth
2851
- column.renderWidth = minWidth
2852
- })
2853
- // 最小自适应
2854
- autoMinList.forEach((column: any) => {
2855
- const scaleWidth = Math.max(60, XEUtils.toInteger(column.renderAutoWidth))
2856
- tableWidth += scaleWidth
2857
- column.renderWidth = scaleWidth
2858
- })
2859
- // 最小百分比
2860
- scaleMinList.forEach((column: any) => {
2861
- const scaleWidth = Math.floor(parseInt(column.minWidth) * meanWidth)
2862
- tableWidth += scaleWidth
2863
- column.renderWidth = scaleWidth
2864
- })
2865
- // 固定百分比
2866
- scaleList.forEach((column: any) => {
2867
- const scaleWidth = Math.floor(parseInt(column.width) * meanWidth)
2868
- tableWidth += scaleWidth
2869
- column.renderWidth = scaleWidth
2870
- })
2871
- // 固定宽
2872
- pxList.forEach((column: any) => {
2873
- const width = parseInt(column.width)
2874
- tableWidth += width
2875
- column.renderWidth = width
2876
- })
2877
- // 自适应宽
2878
- autoList.forEach((column: any) => {
2879
- const width = Math.max(60, XEUtils.toInteger(column.renderAutoWidth))
2880
- tableWidth += width
2881
- column.renderWidth = width
2882
- })
2883
- // 调整了列宽
2884
- resizeList.forEach((column: any) => {
2885
- const width = parseInt(column.resizeWidth)
2886
- tableWidth += width
2887
- column.renderWidth = width
2888
- })
2889
- remainWidth -= tableWidth
2890
- meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoMinList.length + remainList.length)) : 0
2891
- if (fit) {
2892
- if (remainWidth > 0) {
2893
- scaleMinList.concat(pxMinList).concat(autoMinList).forEach((column: any) => {
2894
- tableWidth += meanWidth
2895
- column.renderWidth += meanWidth
2896
- })
2897
- }
2898
- } else {
2899
- meanWidth = minCellWidth
2900
- }
2901
- // 剩余均分
2902
- remainList.forEach((column: any) => {
2903
- const width = Math.max(meanWidth, minCellWidth)
2904
- column.renderWidth = width
2905
- tableWidth += width
2906
- })
2907
- if (fit) {
2908
- /**
2909
- * 偏移量算法
2910
- * 如果所有列足够放的情况下,从最后动态列开始分配
2911
- */
2912
- const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList)
2913
- let dynamicSize = dynamicList.length - 1
2914
- if (dynamicSize > 0) {
2915
- let odiffer = bodyWidth - tableWidth
2916
- if (odiffer > 0) {
2917
- while (odiffer > 0 && dynamicSize >= 0) {
2918
- odiffer--
2919
- dynamicList[dynamicSize--].renderWidth++
2920
- }
2921
- tableWidth = bodyWidth
2922
- }
2923
- }
2924
- }
2925
- const tableHeight = bodyElem.offsetHeight
2926
- const overflowY = bodyElem.scrollHeight > bodyElem.clientHeight
2927
- this.scrollbarWidth = overflowY ? bodyElem.offsetWidth - bodyElem.clientWidth : 0
2928
- this.overflowY = overflowY
2929
- this.tableWidth = tableWidth
2930
- this.tableHeight = tableHeight
2931
- if (headerElem) {
2932
- this.headerHeight = headerElem.clientHeight
2933
- this.$nextTick(() => {
2934
- // 检测是否同步滚动
2935
- if (headerElem && bodyElem && headerElem.scrollLeft !== bodyElem.scrollLeft) {
2936
- headerElem.scrollLeft = bodyElem.scrollLeft
2937
- }
2938
- })
2939
- } else {
2940
- this.headerHeight = 0
2941
- }
2942
- let overflowX = false
2943
- let footerHeight = 0
2944
- let scrollbarHeight = 0
2945
- if (footerElem) {
2946
- footerHeight = footerElem.offsetHeight
2947
- overflowX = tableWidth > footerElem.clientWidth
2948
- scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0)
2949
- } else {
2950
- overflowX = tableWidth > bodyWidth
2951
- scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0)
2952
- }
2953
- this.footerHeight = footerHeight
2954
- this.overflowX = tableWidth > bodyWidth
2955
- this.scrollbarHeight = scrollbarHeight
2956
- this.updateHeight()
2957
- this.parentHeight = Math.max(this.headerHeight + this.footerHeight + 20, this.getParentHeight())
2958
- if (overflowX) {
2959
- this.checkScrolling()
2960
- }
2961
- },
2962
- updateHeight () {
2963
- this.customHeight = calcTableHeight(this, 'height')
2964
- this.customMinHeight = calcTableHeight(this, 'minHeight')
2965
- this.customMaxHeight = calcTableHeight(this, 'maxHeight')
2966
- },
2967
3119
  updateStyle () {
2968
3120
  const $xeTable = this
2969
3121
 
@@ -5448,7 +5600,8 @@ const Methods = {
5448
5600
  $xeTable.dispatchEvent('row-dragend', {
5449
5601
  oldRow: dragRow,
5450
5602
  newRow: prevDragRow,
5451
- dragPos: prevDragPos as any,
5603
+ dragPos: prevDragPos,
5604
+ dragToChild: isSelfToChildDrag,
5452
5605
  offsetIndex: dragOffsetIndex,
5453
5606
  _index: {
5454
5607
  newIndex: nafIndex,
@@ -5719,6 +5872,7 @@ const Methods = {
5719
5872
  oldColumn,
5720
5873
  newColumn,
5721
5874
  dragPos: prevDragPos,
5875
+ dragToChild: isSelfToChildDrag,
5722
5876
  offsetIndex: dragOffsetIndex,
5723
5877
  _index: {
5724
5878
  newIndex: nafIndex,
@@ -5751,7 +5905,7 @@ const Methods = {
5751
5905
  setTimeout(() => {
5752
5906
  reactData.isDragColMove = false
5753
5907
  $xeTable.recalculate().then(() => {
5754
- $xeTable.loadScrollXData()
5908
+ loadScrollXData($xeTable)
5755
5909
  })
5756
5910
  }, 500)
5757
5911
  },
@@ -6737,30 +6891,6 @@ const Methods = {
6737
6891
  scrollLeft: bodyElem.scrollLeft
6738
6892
  }
6739
6893
  },
6740
- loadScrollXData () {
6741
- const $xeTable = this
6742
- const reactData = $xeTable
6743
- const internalData = $xeTable
6744
-
6745
- const { mergeList, mergeFooterList } = reactData
6746
- const { scrollXStore } = internalData
6747
- const { startIndex, endIndex, offsetSize } = scrollXStore
6748
- const { toVisibleIndex, visibleSize } = handleVirtualXVisible($xeTable)
6749
- const offsetItem = {
6750
- startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
6751
- endIndex: toVisibleIndex + visibleSize + offsetSize
6752
- }
6753
- calculateMergerOffsetIndex(mergeList.concat(mergeFooterList), offsetItem, 'col')
6754
- const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem
6755
- if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
6756
- if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
6757
- scrollXStore.startIndex = offsetStartIndex
6758
- scrollXStore.endIndex = offsetEndIndex
6759
- $xeTable.updateScrollXData()
6760
- }
6761
- }
6762
- $xeTable.closeTooltip()
6763
- },
6764
6894
  handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number, params: any) {
6765
6895
  const $xeTable = this
6766
6896
  const props = $xeTable
@@ -6862,8 +6992,8 @@ const Methods = {
6862
6992
  $xeTable.dispatchEvent('scroll', evntParams, evnt)
6863
6993
  },
6864
6994
  lazyScrollXData () {
6865
- const $xeTable = this
6866
- const internalData = $xeTable
6995
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6996
+ const internalData = $xeTable as unknown as TableInternalData
6867
6997
 
6868
6998
  const { lxTimeout, lxRunTime, scrollXStore } = internalData
6869
6999
  const { visibleSize } = scrollXStore
@@ -6873,17 +7003,17 @@ const Methods = {
6873
7003
  }
6874
7004
  if (!lxRunTime || lxRunTime + fpsTime < Date.now()) {
6875
7005
  internalData.lxRunTime = Date.now()
6876
- $xeTable.loadScrollXData()
7006
+ loadScrollXData($xeTable)
6877
7007
  }
6878
7008
  internalData.lxTimeout = setTimeout(() => {
7009
+ internalData.lxTimeout = undefined
6879
7010
  internalData.lxRunTime = undefined
6880
- internalData.lxRunTime = undefined
6881
- $xeTable.loadScrollXData()
7011
+ loadScrollXData($xeTable)
6882
7012
  }, fpsTime)
6883
7013
  },
6884
7014
  lazyScrollYData () {
6885
- const $xeTable = this
6886
- const internalData = $xeTable
7015
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7016
+ const internalData = $xeTable as unknown as TableInternalData
6887
7017
 
6888
7018
  const { lyTimeout, lyRunTime, scrollYStore } = internalData
6889
7019
  const { visibleSize } = scrollYStore
@@ -6893,12 +7023,12 @@ const Methods = {
6893
7023
  }
6894
7024
  if (!lyRunTime || lyRunTime + fpsTime < Date.now()) {
6895
7025
  internalData.lyRunTime = Date.now()
6896
- $xeTable.loadScrollYData()
7026
+ loadScrollYData($xeTable)
6897
7027
  }
6898
7028
  internalData.lyTimeout = setTimeout(() => {
6899
7029
  internalData.lyTimeout = undefined
6900
7030
  internalData.lyRunTime = undefined
6901
- $xeTable.loadScrollYData()
7031
+ loadScrollYData($xeTable)
6902
7032
  }, fpsTime)
6903
7033
  },
6904
7034
  /**
@@ -6909,7 +7039,7 @@ const Methods = {
6909
7039
 
6910
7040
  const sXOpts = $xeTable.computeSXOpts
6911
7041
  if (sXOpts.immediate) {
6912
- $xeTable.loadScrollXData()
7042
+ loadScrollXData($xeTable)
6913
7043
  } else {
6914
7044
  $xeTable.lazyScrollXData()
6915
7045
  }
@@ -6922,7 +7052,7 @@ const Methods = {
6922
7052
 
6923
7053
  const sYOpts = $xeTable.computeSYOpts
6924
7054
  if (sYOpts.immediate) {
6925
- $xeTable.loadScrollYData()
7055
+ loadScrollYData($xeTable)
6926
7056
  } else {
6927
7057
  $xeTable.lazyScrollYData()
6928
7058
  }
@@ -7007,74 +7137,6 @@ const Methods = {
7007
7137
  fixed: ''
7008
7138
  })
7009
7139
  },
7010
- /**
7011
- * 纵向 Y 可视渲染处理
7012
- */
7013
- loadScrollYData () {
7014
- const $xeTable = this
7015
- const props = $xeTable
7016
- const reactData = $xeTable
7017
- const internalData = $xeTable
7018
-
7019
- const { showOverflow } = props
7020
- const { mergeList } = reactData
7021
- const { tableHeight, scrollYStore } = internalData
7022
- const { startIndex, endIndex, offsetSize } = scrollYStore
7023
- const offsetYSize = showOverflow ? offsetSize : offsetSize + Math.min(8, Math.ceil(tableHeight / 200))
7024
- const { toVisibleIndex, visibleSize } = handleVirtualYVisible($xeTable)
7025
- const offsetItem = {
7026
- startIndex: Math.max(0, toVisibleIndex - 1 - offsetYSize),
7027
- endIndex: toVisibleIndex + visibleSize + offsetYSize
7028
- }
7029
- calculateMergerOffsetIndex(mergeList, offsetItem, 'row')
7030
- const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem
7031
- if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
7032
- if (startIndex !== offsetStartIndex || endIndex !== offsetEndIndex) {
7033
- scrollYStore.startIndex = offsetStartIndex
7034
- scrollYStore.endIndex = offsetEndIndex
7035
- $xeTable.updateScrollYData()
7036
- }
7037
- }
7038
- },
7039
- // 计算可视渲染相关数据
7040
- computeScrollLoad () {
7041
- const $xeTable = this
7042
-
7043
- return this.$nextTick().then(() => {
7044
- const { sYOpts, sXOpts, scrollXLoad, scrollYLoad, scrollXStore, scrollYStore } = this
7045
- // 计算 X 逻辑
7046
- if (scrollXLoad) {
7047
- const { visibleSize: visibleXSize } = handleVirtualXVisible($xeTable)
7048
- const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : (browse.edge ? 5 : 0))
7049
- scrollXStore.offsetSize = offsetXSize
7050
- scrollXStore.visibleSize = visibleXSize
7051
- scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex)
7052
- $xeTable.updateScrollXData().then(() => {
7053
- $xeTable.loadScrollXData()
7054
- })
7055
- } else {
7056
- $xeTable.updateScrollXSpace()
7057
- }
7058
- calcCellHeight(this)
7059
- // 计算 Y 逻辑
7060
- const rowHeight = computeRowHeight(this)
7061
- scrollYStore.rowHeight = rowHeight
7062
- this.rowHeight = rowHeight
7063
- const { visibleSize: visibleYSize } = handleVirtualYVisible($xeTable)
7064
- if (scrollYLoad) {
7065
- const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : (browse.edge ? 10 : 0))
7066
- scrollYStore.offsetSize = offsetYSize
7067
- scrollYStore.visibleSize = visibleYSize
7068
- scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex)
7069
- $xeTable.updateScrollYData().then(() => {
7070
- $xeTable.loadScrollYData()
7071
- })
7072
- } else {
7073
- $xeTable.updateScrollYSpace()
7074
- }
7075
- $xeTable.$nextTick(this.updateStyle)
7076
- })
7077
- },
7078
7140
  handleTableColumn () {
7079
7141
  const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this
7080
7142
  const tableColumn: any[] = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0)
@@ -7088,22 +7150,23 @@ const Methods = {
7088
7150
  this.tableColumn = tableColumn
7089
7151
  },
7090
7152
  handleUpdateColumn () {
7091
- const $xeTable = this
7092
- const internalData = $xeTable
7153
+ const $xeTable = this as VxeTableConstructor
7154
+ const internalData = $xeTable as unknown as TableInternalData
7093
7155
 
7094
7156
  const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber')
7095
7157
  internalData.collectColumn = columnList
7096
7158
  const tableFullColumn = getColumnList(columnList)
7097
7159
  internalData.tableFullColumn = tableFullColumn
7098
- $xeTable.cacheColumnMap()
7160
+ cacheColumnMap($xeTable)
7099
7161
  },
7100
7162
  updateScrollXData () {
7101
7163
  const $xeTable = this
7102
7164
  const props = $xeTable
7103
7165
 
7104
7166
  const { showOverflow } = props
7167
+ $xeTable.handleTableColumn()
7168
+ calcCellHeight($xeTable)
7105
7169
  return $xeTable.$nextTick().then(() => {
7106
- $xeTable.handleTableColumn()
7107
7170
  calcCellHeight($xeTable)
7108
7171
  $xeTable.updateScrollXSpace()
7109
7172
  if (!showOverflow) {
@@ -7156,8 +7219,9 @@ const Methods = {
7156
7219
  updateScrollYData () {
7157
7220
  const $xeTable = this
7158
7221
 
7222
+ $xeTable.handleTableData()
7223
+ calcCellHeight($xeTable)
7159
7224
  return $xeTable.$nextTick().then(() => {
7160
- $xeTable.handleTableData()
7161
7225
  calcCellHeight($xeTable)
7162
7226
  $xeTable.updateScrollYSpace()
7163
7227
  })