vxe-table 3.16.0-beta.0 → 3.16.0-beta.10

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 (202) hide show
  1. package/README.md +3 -1
  2. package/es/grid/src/grid.js +866 -692
  3. package/es/index.css +1 -1
  4. package/es/index.min.css +1 -1
  5. package/es/locale/lang/ar-EG.js +4 -1
  6. package/es/locale/lang/de-DE.js +4 -1
  7. package/es/locale/lang/en-US.js +4 -1
  8. package/es/locale/lang/es-ES.js +4 -1
  9. package/es/locale/lang/fr-FR.js +4 -1
  10. package/es/locale/lang/hu-HU.js +4 -1
  11. package/es/locale/lang/hy-AM.js +4 -1
  12. package/es/locale/lang/id-ID.js +4 -1
  13. package/es/locale/lang/it-IT.js +4 -1
  14. package/es/locale/lang/ja-JP.js +4 -1
  15. package/es/locale/lang/ko-KR.js +4 -1
  16. package/es/locale/lang/ms-MY.js +4 -1
  17. package/es/locale/lang/nb-NO.js +4 -1
  18. package/es/locale/lang/pt-BR.js +4 -1
  19. package/es/locale/lang/ru-RU.js +4 -1
  20. package/es/locale/lang/th-TH.js +4 -1
  21. package/es/locale/lang/ug-CN.js +4 -1
  22. package/es/locale/lang/uk-UA.js +4 -1
  23. package/es/locale/lang/uz-UZ.js +4 -1
  24. package/es/locale/lang/vi-VN.js +4 -1
  25. package/es/locale/lang/zh-CHT.js +4 -1
  26. package/es/locale/lang/zh-CN.js +4 -1
  27. package/es/style.css +1 -1
  28. package/es/style.min.css +1 -1
  29. package/es/table/module/custom/mixin.js +0 -4
  30. package/es/table/module/custom/panel.js +0 -1
  31. package/es/table/module/edit/mixin.js +31 -1
  32. package/es/table/module/keyboard/mixin.js +2 -2
  33. package/es/table/src/anime.js +46 -0
  34. package/es/table/src/body.js +18 -43
  35. package/es/table/src/cell.js +6 -3
  36. package/es/table/src/columnInfo.js +6 -1
  37. package/es/table/src/footer.js +4 -22
  38. package/es/table/src/header.js +2 -20
  39. package/es/table/src/methods.js +569 -362
  40. package/es/table/src/table.js +49 -18
  41. package/es/table/src/util.js +5 -1
  42. package/es/table/style.css +8 -8
  43. package/es/table/style.min.css +1 -1
  44. package/es/ui/index.js +3 -2
  45. package/es/ui/src/log.js +1 -1
  46. package/es/vxe-table/style.css +8 -8
  47. package/es/vxe-table/style.min.css +1 -1
  48. package/lib/grid/src/grid.js +971 -810
  49. package/lib/grid/src/grid.min.js +1 -1
  50. package/lib/index.css +1 -1
  51. package/lib/index.min.css +1 -1
  52. package/lib/index.umd.js +1725 -1292
  53. package/lib/index.umd.min.js +1 -1
  54. package/lib/locale/lang/ar-EG.js +4 -1
  55. package/lib/locale/lang/ar-EG.min.js +1 -1
  56. package/lib/locale/lang/ar-EG.umd.js +4 -1
  57. package/lib/locale/lang/de-DE.js +4 -1
  58. package/lib/locale/lang/de-DE.min.js +1 -1
  59. package/lib/locale/lang/de-DE.umd.js +4 -1
  60. package/lib/locale/lang/en-US.js +4 -1
  61. package/lib/locale/lang/en-US.min.js +1 -1
  62. package/lib/locale/lang/en-US.umd.js +4 -1
  63. package/lib/locale/lang/es-ES.js +4 -1
  64. package/lib/locale/lang/es-ES.min.js +1 -1
  65. package/lib/locale/lang/es-ES.umd.js +4 -1
  66. package/lib/locale/lang/fr-FR.js +4 -1
  67. package/lib/locale/lang/fr-FR.min.js +1 -1
  68. package/lib/locale/lang/fr-FR.umd.js +4 -1
  69. package/lib/locale/lang/hu-HU.js +4 -1
  70. package/lib/locale/lang/hu-HU.min.js +1 -1
  71. package/lib/locale/lang/hu-HU.umd.js +4 -1
  72. package/lib/locale/lang/hy-AM.js +4 -1
  73. package/lib/locale/lang/hy-AM.min.js +1 -1
  74. package/lib/locale/lang/hy-AM.umd.js +4 -1
  75. package/lib/locale/lang/id-ID.js +4 -1
  76. package/lib/locale/lang/id-ID.min.js +1 -1
  77. package/lib/locale/lang/id-ID.umd.js +4 -1
  78. package/lib/locale/lang/it-IT.js +4 -1
  79. package/lib/locale/lang/it-IT.min.js +1 -1
  80. package/lib/locale/lang/it-IT.umd.js +4 -1
  81. package/lib/locale/lang/ja-JP.js +4 -1
  82. package/lib/locale/lang/ja-JP.min.js +1 -1
  83. package/lib/locale/lang/ja-JP.umd.js +4 -1
  84. package/lib/locale/lang/ko-KR.js +4 -1
  85. package/lib/locale/lang/ko-KR.min.js +1 -1
  86. package/lib/locale/lang/ko-KR.umd.js +4 -1
  87. package/lib/locale/lang/ms-MY.js +4 -1
  88. package/lib/locale/lang/ms-MY.min.js +1 -1
  89. package/lib/locale/lang/ms-MY.umd.js +4 -1
  90. package/lib/locale/lang/nb-NO.js +4 -1
  91. package/lib/locale/lang/nb-NO.min.js +1 -1
  92. package/lib/locale/lang/nb-NO.umd.js +4 -1
  93. package/lib/locale/lang/pt-BR.js +4 -1
  94. package/lib/locale/lang/pt-BR.min.js +1 -1
  95. package/lib/locale/lang/pt-BR.umd.js +4 -1
  96. package/lib/locale/lang/ru-RU.js +4 -1
  97. package/lib/locale/lang/ru-RU.min.js +1 -1
  98. package/lib/locale/lang/ru-RU.umd.js +4 -1
  99. package/lib/locale/lang/th-TH.js +4 -1
  100. package/lib/locale/lang/th-TH.min.js +1 -1
  101. package/lib/locale/lang/th-TH.umd.js +4 -1
  102. package/lib/locale/lang/ug-CN.js +4 -1
  103. package/lib/locale/lang/ug-CN.min.js +1 -1
  104. package/lib/locale/lang/ug-CN.umd.js +4 -1
  105. package/lib/locale/lang/uk-UA.js +4 -1
  106. package/lib/locale/lang/uk-UA.min.js +1 -1
  107. package/lib/locale/lang/uk-UA.umd.js +4 -1
  108. package/lib/locale/lang/uz-UZ.js +4 -1
  109. package/lib/locale/lang/uz-UZ.min.js +1 -1
  110. package/lib/locale/lang/uz-UZ.umd.js +4 -1
  111. package/lib/locale/lang/vi-VN.js +4 -1
  112. package/lib/locale/lang/vi-VN.min.js +1 -1
  113. package/lib/locale/lang/vi-VN.umd.js +4 -1
  114. package/lib/locale/lang/zh-CHT.js +4 -1
  115. package/lib/locale/lang/zh-CHT.min.js +1 -1
  116. package/lib/locale/lang/zh-CHT.umd.js +4 -1
  117. package/lib/locale/lang/zh-CN.js +4 -1
  118. package/lib/locale/lang/zh-CN.min.js +1 -1
  119. package/lib/locale/lang/zh-CN.umd.js +4 -1
  120. package/lib/style.css +1 -1
  121. package/lib/style.min.css +1 -1
  122. package/lib/table/module/custom/mixin.js +0 -4
  123. package/lib/table/module/custom/mixin.min.js +1 -1
  124. package/lib/table/module/custom/panel.js +0 -1
  125. package/lib/table/module/custom/panel.min.js +1 -1
  126. package/lib/table/module/edit/mixin.js +30 -1
  127. package/lib/table/module/edit/mixin.min.js +1 -1
  128. package/lib/table/module/keyboard/mixin.js +2 -2
  129. package/lib/table/module/keyboard/mixin.min.js +1 -1
  130. package/lib/table/src/anime.js +56 -0
  131. package/lib/table/src/anime.min.js +1 -0
  132. package/lib/table/src/body.js +5 -31
  133. package/lib/table/src/body.min.js +1 -1
  134. package/lib/table/src/cell.js +8 -7
  135. package/lib/table/src/cell.min.js +1 -1
  136. package/lib/table/src/columnInfo.js +6 -1
  137. package/lib/table/src/columnInfo.min.js +1 -1
  138. package/lib/table/src/footer.js +5 -22
  139. package/lib/table/src/footer.min.js +1 -1
  140. package/lib/table/src/header.js +2 -20
  141. package/lib/table/src/header.min.js +1 -1
  142. package/lib/table/src/methods.js +586 -371
  143. package/lib/table/src/methods.min.js +1 -1
  144. package/lib/table/src/table.js +49 -17
  145. package/lib/table/src/table.min.js +1 -1
  146. package/lib/table/src/util.js +9 -1
  147. package/lib/table/src/util.min.js +1 -1
  148. package/lib/table/style/style.css +8 -8
  149. package/lib/table/style/style.min.css +1 -1
  150. package/lib/ui/index.js +3 -2
  151. package/lib/ui/index.min.js +1 -1
  152. package/lib/ui/src/log.js +1 -1
  153. package/lib/ui/src/log.min.js +1 -1
  154. package/lib/vxe-table/style/style.css +8 -8
  155. package/lib/vxe-table/style/style.min.css +1 -1
  156. package/package.json +2 -2
  157. package/packages/grid/src/grid.ts +1007 -779
  158. package/packages/locale/lang/ar-EG.ts +4 -1
  159. package/packages/locale/lang/de-DE.ts +4 -1
  160. package/packages/locale/lang/en-US.ts +4 -1
  161. package/packages/locale/lang/es-ES.ts +4 -1
  162. package/packages/locale/lang/fr-FR.ts +4 -1
  163. package/packages/locale/lang/hu-HU.ts +4 -1
  164. package/packages/locale/lang/hy-AM.ts +4 -1
  165. package/packages/locale/lang/id-ID.ts +4 -1
  166. package/packages/locale/lang/it-IT.ts +4 -1
  167. package/packages/locale/lang/ja-JP.ts +4 -1
  168. package/packages/locale/lang/ko-KR.ts +4 -1
  169. package/packages/locale/lang/ms-MY.ts +4 -1
  170. package/packages/locale/lang/nb-NO.ts +4 -1
  171. package/packages/locale/lang/pt-BR.ts +4 -1
  172. package/packages/locale/lang/ru-RU.ts +4 -1
  173. package/packages/locale/lang/th-TH.ts +4 -1
  174. package/packages/locale/lang/ug-CN.ts +4 -1
  175. package/packages/locale/lang/uk-UA.ts +4 -1
  176. package/packages/locale/lang/uz-UZ.ts +4 -1
  177. package/packages/locale/lang/vi-VN.ts +4 -1
  178. package/packages/locale/lang/zh-CHT.ts +4 -1
  179. package/packages/locale/lang/zh-CN.ts +4 -1
  180. package/packages/table/module/custom/mixin.ts +0 -4
  181. package/packages/table/module/custom/panel.ts +0 -1
  182. package/packages/table/module/edit/mixin.ts +30 -2
  183. package/packages/table/module/keyboard/mixin.ts +2 -2
  184. package/packages/table/src/anime.ts +52 -0
  185. package/packages/table/src/body.ts +18 -43
  186. package/packages/table/src/cell.ts +3 -3
  187. package/packages/table/src/columnInfo.ts +6 -1
  188. package/packages/table/src/footer.ts +4 -22
  189. package/packages/table/src/header.ts +2 -21
  190. package/packages/table/src/methods.ts +589 -374
  191. package/packages/table/src/props.ts +4 -4
  192. package/packages/table/src/table.ts +55 -18
  193. package/packages/table/src/util.ts +5 -1
  194. package/packages/ui/index.ts +2 -1
  195. package/styles/components/table.scss +9 -9
  196. package/types/all.d.ts +3 -2
  197. /package/es/{iconfont.1750770351840.ttf → iconfont.1751970594233.ttf} +0 -0
  198. /package/es/{iconfont.1750770351840.woff → iconfont.1751970594233.woff} +0 -0
  199. /package/es/{iconfont.1750770351840.woff2 → iconfont.1751970594233.woff2} +0 -0
  200. /package/lib/{iconfont.1750770351840.ttf → iconfont.1751970594233.ttf} +0 -0
  201. /package/lib/{iconfont.1750770351840.woff → iconfont.1751970594233.woff} +0 -0
  202. /package/lib/{iconfont.1750770351840.woff2 → iconfont.1751970594233.woff2} +0 -0
@@ -3,8 +3,9 @@ import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTarge
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, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem } from './util'
6
+ import { getRowUniqueId, clearTableAllStatus, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight } from './util'
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
+ import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime'
8
9
  import { warnLog, errLog } from '../../ui/src/log'
9
10
 
10
11
  import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeGridConstructor, GridPrivateMethods, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
@@ -445,7 +446,7 @@ function handleVirtualTreeExpand ($xeTable: VxeTableConstructor & VxeTablePrivat
445
446
  updateAfterDataIndex($xeTable)
446
447
  return $xeTable.$nextTick()
447
448
  }).then(() => {
448
- return $xeTable.recalculate(true)
449
+ return handleLazyRecalculate($xeTable, true, true, true)
449
450
  }).then(() => {
450
451
  setTimeout(() => {
451
452
  $xeTable.updateCellAreas()
@@ -523,7 +524,7 @@ function handleRowGroupVirtualExpand ($xeTable: VxeTableConstructor & VxeTablePr
523
524
  updateAfterDataIndex($xeTable)
524
525
  return $xeTable.$nextTick()
525
526
  }).then(() => {
526
- return $xeTable.recalculate(true)
527
+ return handleLazyRecalculate($xeTable, true, true, true)
527
528
  }).then(() => {
528
529
  setTimeout(() => {
529
530
  $xeTable.updateCellAreas()
@@ -1832,7 +1833,7 @@ function buildMergeData (mergeConfigs: VxeTableDefines.MergeItem[]) {
1832
1833
  return mergeMaps
1833
1834
  }
1834
1835
 
1835
- const handleBodyMerge = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) => {
1836
+ function handleBodyMerge ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
1836
1837
  const internalData = $xeTable as unknown as TableInternalData
1837
1838
 
1838
1839
  const { fullAllDataRowIdData, fullColumnIdData, visibleColumn, afterFullData, mergeBodyList, mergeBodyMaps } = internalData
@@ -1895,7 +1896,7 @@ const handleBodyMerge = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
1895
1896
  }
1896
1897
  }
1897
1898
 
1898
- const handleFooterMerge = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) => {
1899
+ function handleFooterMerge ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
1899
1900
  const reactData = $xeTable as unknown as TableReactData
1900
1901
  const internalData = $xeTable as unknown as TableInternalData
1901
1902
 
@@ -2313,8 +2314,6 @@ function clearDragStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
2313
2314
  hideDropTip($xeTable)
2314
2315
  reactData.dragRow = null
2315
2316
  reactData.dragCol = null
2316
- reactData.isDragColMove = false
2317
- reactData.isDragRowMove = false
2318
2317
  }
2319
2318
  }
2320
2319
 
@@ -2677,7 +2676,7 @@ function calcScrollbar ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
2677
2676
  }
2678
2677
  }
2679
2678
 
2680
- function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, reFull: boolean) {
2679
+ function handleRecalculateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, reFull: boolean, reWidth: boolean, reHeight: boolean) {
2681
2680
  const internalData = $xeTable as unknown as TableInternalData
2682
2681
 
2683
2682
  const el = $xeTable.$refs.refElem as HTMLDivElement
@@ -2693,19 +2692,28 @@ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivat
2693
2692
  calcVarRowHeightConfig($xeTable, 'small', smallEl)
2694
2693
  calcVarRowHeightConfig($xeTable, 'mini', miniEl)
2695
2694
  }
2696
- calcCellWidth($xeTable)
2697
- autoCellWidth($xeTable)
2695
+ if (reWidth) {
2696
+ calcCellWidth($xeTable)
2697
+ }
2698
+ if (reFull) {
2699
+ autoCellWidth($xeTable)
2700
+ }
2698
2701
  calcScrollbar($xeTable)
2699
2702
  updateStyle($xeTable)
2700
2703
  updateRowExpandStyle($xeTable)
2701
2704
  return computeScrollLoad($xeTable).then(() => {
2702
2705
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
2703
- calcCellWidth($xeTable)
2706
+ if (reWidth) {
2707
+ calcCellWidth($xeTable)
2708
+ }
2704
2709
  if (reFull) {
2705
2710
  autoCellWidth($xeTable)
2706
2711
  }
2707
- calcScrollbar($xeTable)
2712
+ if (reHeight) {
2713
+ calcCellHeight($xeTable)
2714
+ }
2708
2715
  updateStyle($xeTable)
2716
+ calcScrollbar($xeTable)
2709
2717
  if (reFull) {
2710
2718
  updateRowOffsetTop($xeTable)
2711
2719
  }
@@ -2716,6 +2724,41 @@ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivat
2716
2724
  })
2717
2725
  }
2718
2726
 
2727
+ function handleLazyRecalculate ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, reFull: boolean, reWidth: boolean, reHeight: boolean) {
2728
+ const internalData = $xeTable as unknown as TableInternalData
2729
+
2730
+ return new Promise<void>(resolve => {
2731
+ const { rceTimeout, rceRunTime } = internalData
2732
+ const resizeOpts = $xeTable.computeResizeOpts
2733
+ const refreshDelay = resizeOpts.refreshDelay || 20
2734
+ const el = $xeTable.$refs.refElem as HTMLElement
2735
+ if (el && el.clientWidth) {
2736
+ autoCellWidth($xeTable)
2737
+ updateRowExpandStyle($xeTable)
2738
+ }
2739
+ if (rceTimeout) {
2740
+ clearTimeout(rceTimeout)
2741
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
2742
+ resolve(
2743
+ handleRecalculateStyle($xeTable, reFull, reWidth, reHeight)
2744
+ )
2745
+ } else {
2746
+ $xeTable.$nextTick(() => {
2747
+ resolve()
2748
+ })
2749
+ }
2750
+ } else {
2751
+ resolve(
2752
+ handleRecalculateStyle($xeTable, reFull, reWidth, reHeight)
2753
+ )
2754
+ }
2755
+ internalData.rceTimeout = setTimeout(() => {
2756
+ internalData.rceTimeout = undefined
2757
+ handleRecalculateStyle($xeTable, reFull, reWidth, reHeight)
2758
+ }, refreshDelay)
2759
+ })
2760
+ }
2761
+
2719
2762
  function handleUpdateAggValues ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2720
2763
  const reactData = $xeTable as unknown as TableReactData
2721
2764
  const internalData = $xeTable as unknown as TableInternalData
@@ -2944,8 +2987,6 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
2944
2987
  internalData.removeRowMaps = {}
2945
2988
  reactData.removeRowFlag++
2946
2989
  const sYLoad = updateScrollYStatus($xeTable, fullData)
2947
- reactData.isDragColMove = false
2948
- reactData.isDragRowMove = false
2949
2990
  // 全量数据
2950
2991
  internalData.tableFullData = fullData
2951
2992
  internalData.tableFullTreeData = isRGroup ? [] : treeData
@@ -3009,11 +3050,10 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
3009
3050
  $xeTable.checkSelectionStatus()
3010
3051
  return new Promise<void>(resolve => {
3011
3052
  $xeTable.$nextTick()
3012
- .then(() => handleRecalculateLayout($xeTable, false))
3053
+ .then(() => handleRecalculateStyle($xeTable, false, false, false))
3013
3054
  .then(() => {
3014
- calcCellHeight($xeTable)
3055
+ handleRecalculateStyle($xeTable, false, true, true)
3015
3056
  updateRowOffsetTop($xeTable)
3016
- return handleRecalculateLayout($xeTable, false)
3017
3057
  })
3018
3058
  .then(() => {
3019
3059
  let targetScrollLeft = lastScrollLeft
@@ -3028,12 +3068,12 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
3028
3068
  targetScrollTop = 0
3029
3069
  }
3030
3070
  reactData.isRowLoading = false
3031
- handleRecalculateLayout($xeTable, false)
3071
+ handleRecalculateStyle($xeTable, false, false, false)
3032
3072
  // 是否变更虚拟滚动
3033
3073
  if (oldScrollYLoad === sYLoad) {
3034
3074
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
3035
3075
  .then(() => {
3036
- calcCellHeight($xeTable)
3076
+ handleRecalculateStyle($xeTable, false, true, true)
3037
3077
  updateRowOffsetTop($xeTable)
3038
3078
  resolve()
3039
3079
  })
@@ -3041,7 +3081,7 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
3041
3081
  setTimeout(() => {
3042
3082
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
3043
3083
  .then(() => {
3044
- calcCellHeight($xeTable)
3084
+ handleRecalculateStyle($xeTable, false, true, true)
3045
3085
  updateRowOffsetTop($xeTable)
3046
3086
  resolve()
3047
3087
  })
@@ -3283,7 +3323,6 @@ function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, c
3283
3323
  const tableFullColumn = getColumnList(collectColumn)
3284
3324
  internalData.tableFullColumn = tableFullColumn
3285
3325
  reactData.isColLoading = true
3286
- reactData.isDragColMove = false
3287
3326
  initColumnSort($xeTable)
3288
3327
  return Promise.resolve(
3289
3328
  restoreCustomStorage($xeTable)
@@ -3315,7 +3354,7 @@ function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, c
3315
3354
  $xeTable.handleUpdateCustomColumn()
3316
3355
  }
3317
3356
  reactData.isColLoading = false
3318
- return $xeTable.recalculate()
3357
+ return handleLazyRecalculate($xeTable, false, true, true)
3319
3358
  })
3320
3359
  })
3321
3360
  }
@@ -3520,8 +3559,21 @@ function updateHeight ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
3520
3559
  }
3521
3560
  }
3522
3561
 
3523
- function calcColumnAutoWidth (column: VxeTableDefines.ColumnInfo, wrapperEl: HTMLDivElement) {
3524
- const cellElemList = wrapperEl.querySelectorAll(`.vxe-cell--wrapper[colid="${column.id}"]`)
3562
+ function calcColumnAutoWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, column: VxeTableDefines.ColumnInfo, wrapperEl: HTMLDivElement) {
3563
+ const columnOpts = $xeTable.computeColumnOpts
3564
+ const { autoOptions } = columnOpts
3565
+ const { isCalcHeader, isCalcBody, isCalcFooter } = autoOptions || {}
3566
+ const querySelections: string[] = []
3567
+ if (isCalcHeader) {
3568
+ querySelections.push(`.vxe-header-cell--wrapper[colid="${column.id}"]`)
3569
+ }
3570
+ if (isCalcBody) {
3571
+ querySelections.push(`.vxe-body-cell--wrapper[colid="${column.id}"]`)
3572
+ }
3573
+ if (isCalcFooter) {
3574
+ querySelections.push(`.vxe-footer-cell--wrapper[colid="${column.id}"]`)
3575
+ }
3576
+ const cellElemList = querySelections.length ? wrapperEl.querySelectorAll(querySelections.join(',')) : []
3525
3577
  let leftRightPadding = 0
3526
3578
  const firstCellEl = cellElemList[0]
3527
3579
  if (firstCellEl && firstCellEl.parentElement) {
@@ -3547,7 +3599,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
3547
3599
  autoWidthColumnList.forEach(column => {
3548
3600
  const colid = column.id
3549
3601
  const colRest = fullColumnIdData[colid]
3550
- const colWidth = calcColumnAutoWidth(column, el)
3602
+ const colWidth = calcColumnAutoWidth($xeTable, column, el)
3551
3603
  if (colRest) {
3552
3604
  colRest.width = Math.max(colWidth, colRest.width)
3553
3605
  }
@@ -3810,10 +3862,10 @@ const Methods = {
3810
3862
  }
3811
3863
  }).then(() => {
3812
3864
  $xeTable.updateCellAreas()
3813
- return $xeTable.recalculate(true)
3865
+ return handleLazyRecalculate($xeTable, true, true, true)
3814
3866
  }).then(() => {
3815
3867
  // 存在滚动行为未结束情况
3816
- setTimeout(() => $xeTable.recalculate(), 50)
3868
+ setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 50)
3817
3869
  })
3818
3870
  },
3819
3871
  handleTableData (force: any) {
@@ -3868,7 +3920,7 @@ const Methods = {
3868
3920
  if (!initStatus) {
3869
3921
  handleLoadDefaults($xeTable)
3870
3922
  }
3871
- return this.recalculate()
3923
+ return handleLazyRecalculate($xeTable, false, true, true)
3872
3924
  })
3873
3925
  },
3874
3926
  /**
@@ -3886,7 +3938,7 @@ const Methods = {
3886
3938
  })
3887
3939
  .then(() => {
3888
3940
  handleLoadDefaults($xeTable)
3889
- return this.recalculate()
3941
+ return handleLazyRecalculate($xeTable, false, true, true)
3890
3942
  })
3891
3943
  },
3892
3944
  /**
@@ -4388,7 +4440,7 @@ const Methods = {
4388
4440
  }
4389
4441
  return $xeTable.$nextTick().then(() => {
4390
4442
  $xeTable.updateCellAreas()
4391
- return $xeTable.recalculate()
4443
+ return handleLazyRecalculate($xeTable, false, true, true)
4392
4444
  })
4393
4445
  }
4394
4446
  return $xeTable.reloadData(tableSourceData)
@@ -5319,7 +5371,7 @@ const Methods = {
5319
5371
  return parseColumns($xeTable, true).then(() => {
5320
5372
  return this.refreshScroll()
5321
5373
  }).then(() => {
5322
- return this.recalculate()
5374
+ return handleLazyRecalculate($xeTable, false, true, true)
5323
5375
  })
5324
5376
  },
5325
5377
  /**
@@ -5544,7 +5596,7 @@ const Methods = {
5544
5596
  const colMinWidth = getColReMinWidth(cellParams)
5545
5597
 
5546
5598
  el.setAttribute('data-calc-col', 'Y')
5547
- let resizeWidth = calcColumnAutoWidth(resizeColumn, el)
5599
+ let resizeWidth = calcColumnAutoWidth($xeTable, resizeColumn, el)
5548
5600
  el.removeAttribute('data-calc-col')
5549
5601
  if (colRest) {
5550
5602
  resizeWidth = Math.max(resizeWidth, colRest.width)
@@ -5860,38 +5912,9 @@ const Methods = {
5860
5912
  */
5861
5913
  recalculate (reFull?: boolean) {
5862
5914
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5863
- const internalData = $xeTable as unknown as TableInternalData
5864
5915
 
5865
- return new Promise<void>(resolve => {
5866
- const { rceTimeout, rceRunTime } = internalData
5867
- const resizeOpts = $xeTable.computeResizeOpts
5868
- const refreshDelay = resizeOpts.refreshDelay || 20
5869
- const el = $xeTable.$refs.refElem as HTMLElement
5870
- if (el && el.clientWidth) {
5871
- autoCellWidth($xeTable)
5872
- updateRowExpandStyle($xeTable)
5873
- }
5874
- if (rceTimeout) {
5875
- clearTimeout(rceTimeout)
5876
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
5877
- resolve(
5878
- handleRecalculateLayout($xeTable, !!reFull)
5879
- )
5880
- } else {
5881
- $xeTable.$nextTick(() => {
5882
- resolve()
5883
- })
5884
- }
5885
- } else {
5886
- resolve(
5887
- handleRecalculateLayout($xeTable, !!reFull)
5888
- )
5889
- }
5890
- internalData.rceTimeout = setTimeout(() => {
5891
- internalData.rceTimeout = undefined
5892
- handleRecalculateLayout($xeTable, !!reFull)
5893
- }, refreshDelay)
5894
- })
5916
+ const isForce = !!reFull
5917
+ return handleLazyRecalculate($xeTable, isForce, isForce, isForce)
5895
5918
  },
5896
5919
  updateStyle () {
5897
5920
  const $xeTable = this
@@ -6475,9 +6498,12 @@ const Methods = {
6475
6498
  }
6476
6499
  },
6477
6500
  handleGlobalResizeEvent () {
6478
- this.closeMenu()
6479
- this.updateCellAreas()
6480
- this.recalculate(true)
6501
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6502
+
6503
+ $xeTable.closeMenu()
6504
+ $xeTable.updateCellAreas()
6505
+ handleLazyRecalculate($xeTable, true, true, true)
6506
+ $xeTable.updateCellAreas()
6481
6507
  },
6482
6508
  /**
6483
6509
  * 处理合并
@@ -7063,7 +7089,8 @@ const Methods = {
7063
7089
  const childList: any[] = vals[2]
7064
7090
  let sLen = 0 // 已选
7065
7091
  let hLen = 0 // 半选
7066
- let vLen = 0 // 有效行
7092
+ let vLen = 0 // 有效子行
7093
+ const cLen = childList.length // 有效子行
7067
7094
  childList.forEach(
7068
7095
  checkMethod
7069
7096
  ? (item) => {
@@ -7096,15 +7123,25 @@ const Methods = {
7096
7123
  }
7097
7124
  )
7098
7125
 
7099
- let isSelected = (sLen >= vLen && (vLen >= 1 || hLen >= 1))
7100
- if (checkMethod) {
7101
- if (checkMethod({ $table: $xeTable, row })) {
7102
- isSelected = sLen >= vLen
7126
+ let isSelected = false
7127
+ if (cLen > 0) {
7128
+ if (vLen > 0) {
7129
+ isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen
7103
7130
  } else {
7104
- isSelected = selectCheckboxMaps[rowid]
7131
+ // 如果存在子项禁用
7132
+ if ((sLen > 0 && sLen >= vLen)) {
7133
+ isSelected = true
7134
+ } else if (selectCheckboxMaps[rowid]) {
7135
+ isSelected = true
7136
+ } else {
7137
+ isSelected = false
7138
+ }
7105
7139
  }
7140
+ } else {
7141
+ // 如果无子项
7142
+ isSelected = selectCheckboxMaps[rowid]
7106
7143
  }
7107
- const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
7144
+ const halfSelect = !isSelected && (sLen > 0 || hLen > 0)
7108
7145
 
7109
7146
  if (checkField) {
7110
7147
  XEUtils.set(row, checkField, isSelected)
@@ -7148,7 +7185,9 @@ const Methods = {
7148
7185
  const { handleGetRowId } = createHandleGetRowId($xeTable)
7149
7186
 
7150
7187
  let sLen = 0 // 已选
7188
+ let dsLen = 0 // 禁用的已选
7151
7189
  let hLen = 0 // 半选
7190
+ let dhLen = 0 // 禁用的半选
7152
7191
  let vLen = 0 // 有效行
7153
7192
 
7154
7193
  const rootList = (treeConfig ? afterTreeFullData : (isRowGroupStatus ? afterGroupFullData : afterFullData))
@@ -7165,9 +7204,9 @@ const Methods = {
7165
7204
  vLen++
7166
7205
  } else {
7167
7206
  if (selected) {
7168
- sLen++
7207
+ dsLen++
7169
7208
  } else if (treeIndeterminateRowMaps[childRowid]) {
7170
- hLen++
7209
+ dhLen++
7171
7210
  }
7172
7211
  }
7173
7212
  }
@@ -7183,7 +7222,7 @@ const Methods = {
7183
7222
  })
7184
7223
 
7185
7224
  const isSelected = rootList.length > 0 ? (vLen > 0 ? (sLen >= vLen) : (sLen >= rootList.length)) : false
7186
- let halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
7225
+ let halfSelect = !isSelected && (sLen > 0 || hLen > 0 || dsLen > 0 || dhLen > 0)
7187
7226
 
7188
7227
  // 如果复选框启用保留记录,当保留数据存在时显示半选
7189
7228
  if (!isSelected && !halfSelect && showReserveStatus) {
@@ -7953,88 +7992,81 @@ const Methods = {
7953
7992
  const { treeConfig, dragConfig } = props
7954
7993
  const rowDragOpts = $xeTable.computeRowDragOpts
7955
7994
  const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
7956
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
7995
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
7957
7996
  const treeOpts = $xeTable.computeTreeOpts
7997
+ const cellOpts = $xeTable.computeCellOpts
7998
+ const rowOpts = $xeTable.computeRowOpts
7999
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight
7958
8000
  const { transform, rowField, mapChildrenField, parentField } = treeOpts
7959
8001
  const childrenField = treeOpts.children || treeOpts.childrenField
7960
8002
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
7961
8003
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
8004
+ const el = $xeTable.$refs.refElem as HTMLDivElement
7962
8005
  const errRest = {
7963
8006
  status: false
7964
8007
  }
7965
- if (prevDragRow && dragRow) {
7966
- // 判断是否有拖动
7967
- if (prevDragRow !== dragRow) {
7968
- const dragParams = {
7969
- oldRow: dragRow,
7970
- newRow: prevDragRow,
7971
- dragRow,
7972
- dragPos: prevDragPos as 'top' | 'bottom',
7973
- dragToChild: !!prevDragToChild,
7974
- offsetIndex: dragOffsetIndex as 0 | 1
7975
- }
7976
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
7977
- return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
7978
- if (!status) {
7979
- return errRest
8008
+ if (!(el && prevDragRow && dragRow)) {
8009
+ return Promise.resolve(errRest)
8010
+ }
8011
+ // 判断是否有拖动
8012
+ if (prevDragRow !== dragRow) {
8013
+ const dragParams = {
8014
+ oldRow: dragRow,
8015
+ newRow: prevDragRow,
8016
+ dragRow,
8017
+ dragPos: prevDragPos as 'top' | 'bottom',
8018
+ dragToChild: !!prevDragToChild,
8019
+ offsetIndex: dragOffsetIndex as 0 | 1
8020
+ }
8021
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
8022
+ return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
8023
+ if (!status) {
8024
+ return errRest
8025
+ }
8026
+
8027
+ const dragRowid = getRowid($xeTable, dragRow)
8028
+ const dragRowRest = fullAllDataRowIdData[dragRowid] || {}
8029
+ const _dragRowIndex = dragRowRest._index
8030
+ let dragRowHeight = 0
8031
+ let dragOffsetTop = -1
8032
+ if (animation) {
8033
+ dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight)
8034
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-body--row[rowid="${dragRowid}"]`)
8035
+ if (oldTrEl) {
8036
+ dragOffsetTop = oldTrEl.offsetTop
7980
8037
  }
8038
+ }
7981
8039
 
7982
- let oafIndex = -1
7983
- let nafIndex = -1
7984
- // 如果为树结构
7985
- if (treeConfig) {
7986
- if (transform) {
7987
- // 移出源位置
7988
- const oldRowid = getRowid($xeTable, dragRow)
7989
- const oldRest = fullAllDataRowIdData[oldRowid]
7990
- const newRowid = getRowid($xeTable, prevDragRow)
7991
- const newRest = fullAllDataRowIdData[newRowid]
7992
-
7993
- if (oldRest && newRest) {
7994
- const { level: oldLevel } = oldRest
7995
- const { level: newLevel } = newRest
7996
-
7997
- const oldAllMaps: Record<string, any> = {}
7998
- XEUtils.eachTree([dragRow], item => {
7999
- oldAllMaps[getRowid($xeTable, item)] = item
8000
- }, { children: mapChildrenField })
8001
-
8002
- let isSelfToChildStatus = false
8003
-
8004
- if (oldLevel && newLevel) {
8005
- // 子到子
8006
-
8007
- if (isPeerDrag && !isCrossDrag) {
8008
- if (oldRest.row[parentField] !== newRest.row[parentField]) {
8009
- // 非同级
8010
- return errRest
8011
- }
8012
- } else {
8013
- if (!isCrossDrag) {
8014
- return errRest
8015
- }
8016
- if (oldAllMaps[newRowid]) {
8017
- isSelfToChildStatus = true
8018
- if (!(isCrossDrag && isSelfToChildDrag)) {
8019
- if (VxeUI.modal) {
8020
- VxeUI.modal.message({
8021
- status: 'error',
8022
- content: getI18n('vxe.error.treeDragChild')
8023
- })
8024
- }
8025
- return errRest
8026
- }
8027
- }
8028
- }
8029
- } else if (oldLevel) {
8030
- // 子到根
8040
+ let oafIndex = -1
8041
+ let nafIndex = -1
8042
+ // 如果为树结构
8043
+ if (treeConfig) {
8044
+ if (transform) {
8045
+ // 移出源位置
8046
+ const oldRest = dragRowRest
8047
+ const newRowid = getRowid($xeTable, prevDragRow)
8048
+ const newRest = fullAllDataRowIdData[newRowid]
8031
8049
 
8032
- if (!isCrossDrag) {
8050
+ if (oldRest && newRest) {
8051
+ const { level: oldLevel } = oldRest
8052
+ const { level: newLevel } = newRest
8053
+
8054
+ const oldAllMaps: Record<string, any> = {}
8055
+ XEUtils.eachTree([dragRow], item => {
8056
+ oldAllMaps[getRowid($xeTable, item)] = item
8057
+ }, { children: mapChildrenField })
8058
+
8059
+ let isSelfToChildStatus = false
8060
+
8061
+ if (oldLevel && newLevel) {
8062
+ // 子到子
8063
+
8064
+ if (isPeerDrag && !isCrossDrag) {
8065
+ if (oldRest.row[parentField] !== newRest.row[parentField]) {
8066
+ // 非同级
8033
8067
  return errRest
8034
8068
  }
8035
- } else if (newLevel) {
8036
- // 根到子
8037
-
8069
+ } else {
8038
8070
  if (!isCrossDrag) {
8039
8071
  return errRest
8040
8072
  }
@@ -8050,95 +8082,171 @@ const Methods = {
8050
8082
  return errRest
8051
8083
  }
8052
8084
  }
8053
- } else {
8054
- // 根到根
8055
8085
  }
8086
+ } else if (oldLevel) {
8087
+ // 子到根
8056
8088
 
8057
- const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
8058
- key: rowField,
8059
- parentKey: parentField,
8060
- children: mapChildrenField
8061
- })
8089
+ if (!isCrossDrag) {
8090
+ return errRest
8091
+ }
8092
+ } else if (newLevel) {
8093
+ // 根到子
8062
8094
 
8063
- // 移出
8064
- const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
8065
- fullList.splice(otfIndex, 1)
8095
+ if (!isCrossDrag) {
8096
+ return errRest
8097
+ }
8098
+ if (oldAllMaps[newRowid]) {
8099
+ isSelfToChildStatus = true
8100
+ if (!(isCrossDrag && isSelfToChildDrag)) {
8101
+ if (VxeUI.modal) {
8102
+ VxeUI.modal.message({
8103
+ status: 'error',
8104
+ content: getI18n('vxe.error.treeDragChild')
8105
+ })
8106
+ }
8107
+ return errRest
8108
+ }
8109
+ }
8110
+ } else {
8111
+ // 根到根
8112
+ }
8066
8113
 
8067
- // 插入
8068
- const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
8069
- const ntfIndex = ptfIndex + dragOffsetIndex
8070
- fullList.splice(ntfIndex, 0, dragRow)
8114
+ const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
8115
+ key: rowField,
8116
+ parentKey: parentField,
8117
+ children: mapChildrenField
8118
+ })
8071
8119
 
8072
- // 改变层级
8073
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
8074
- XEUtils.each(dragRow[childrenField], childRow => {
8075
- childRow[parentField] = dragRow[parentField]
8076
- })
8077
- }
8078
- dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField]
8120
+ // 移出
8121
+ const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
8122
+ fullList.splice(otfIndex, 1)
8079
8123
 
8080
- internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
8081
- key: rowField,
8082
- parentKey: parentField,
8083
- children: childrenField,
8084
- mapChildren: mapChildrenField
8124
+ // 插入
8125
+ const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
8126
+ const ntfIndex = ptfIndex + dragOffsetIndex
8127
+ fullList.splice(ntfIndex, 0, dragRow)
8128
+
8129
+ // 改变层级
8130
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
8131
+ XEUtils.each(dragRow[childrenField], childRow => {
8132
+ childRow[parentField] = dragRow[parentField]
8085
8133
  })
8086
8134
  }
8135
+ dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField]
8136
+
8137
+ internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
8138
+ key: rowField,
8139
+ parentKey: parentField,
8140
+ children: childrenField,
8141
+ mapChildren: mapChildrenField
8142
+ })
8087
8143
  }
8088
- } else {
8089
- // 移出
8090
- oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
8091
- const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
8092
- afterFullData.splice(oafIndex, 1)
8093
- tableFullData.splice(otfIndex, 1)
8094
- // 插入
8095
- const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
8096
- const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
8097
- nafIndex = pafIndex + dragOffsetIndex
8098
- const ntfIndex = ptfIndex + dragOffsetIndex
8099
- afterFullData.splice(nafIndex, 0, dragRow)
8100
- tableFullData.splice(ntfIndex, 0, dragRow)
8101
8144
  }
8145
+ } else {
8146
+ // 移出
8147
+ oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
8148
+ const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
8149
+ afterFullData.splice(oafIndex, 1)
8150
+ tableFullData.splice(otfIndex, 1)
8151
+ // 插入
8152
+ const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
8153
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
8154
+ nafIndex = pafIndex + dragOffsetIndex
8155
+ const ntfIndex = ptfIndex + dragOffsetIndex
8156
+ afterFullData.splice(nafIndex, 0, dragRow)
8157
+ tableFullData.splice(ntfIndex, 0, dragRow)
8158
+ }
8102
8159
 
8103
- reactData.isDragRowMove = true
8104
- $xeTable.handleTableData(treeConfig && transform)
8105
- $xeTable.cacheRowMap(false)
8106
- updateScrollYStatus($xeTable)
8107
- if (!(treeConfig && transform)) {
8108
- updateAfterDataIndex($xeTable)
8109
- }
8110
- $xeTable.checkSelectionStatus()
8111
- if (reactData.scrollYLoad) {
8112
- $xeTable.updateScrollYSpace()
8113
- }
8160
+ $xeTable.handleTableData(treeConfig && transform)
8161
+ $xeTable.cacheRowMap(false)
8162
+ updateScrollYStatus($xeTable)
8163
+ if (!(treeConfig && transform)) {
8164
+ updateAfterDataIndex($xeTable)
8165
+ }
8166
+ $xeTable.checkSelectionStatus()
8167
+ if (reactData.scrollYLoad) {
8168
+ $xeTable.updateScrollYSpace()
8169
+ }
8170
+
8171
+ if (evnt) {
8172
+ $xeTable.dispatchEvent('row-dragend', {
8173
+ oldRow: dragRow,
8174
+ newRow: prevDragRow,
8175
+ dragRow,
8176
+ dragPos: prevDragPos as any,
8177
+ dragToChild: isDragToChildFlag,
8178
+ offsetIndex: dragOffsetIndex,
8179
+ _index: {
8180
+ newIndex: nafIndex,
8181
+ oldIndex: oafIndex
8182
+ }
8183
+ }, evnt)
8184
+ }
8185
+
8186
+ return $xeTable.$nextTick().then(() => {
8187
+ if (animation) {
8188
+ const { tableData } = reactData
8189
+ const dragRowRest = fullAllDataRowIdData[dragRowid]
8190
+ const _newRowIndex = dragRowRest._index
8191
+ const firstRow = tableData[0]
8192
+ const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)]
8193
+
8194
+ if (firstRowRest) {
8195
+ const _firstRowIndex = firstRowRest._index
8196
+ const _lastRowIndex = _firstRowIndex + tableData.length
8197
+
8198
+ let rsIndex = -1
8199
+ let reIndex = -1
8200
+ let offsetRate = 1
8201
+ if (_dragRowIndex < _firstRowIndex) {
8202
+ // 从上往下虚拟拖拽
8203
+ rsIndex = 0
8204
+ reIndex = _newRowIndex - _firstRowIndex
8205
+ } else if (_dragRowIndex > _lastRowIndex) {
8206
+ // 从下往上虚拟拖拽
8207
+ const $newRowIndex = dragRowRest.$index
8208
+ rsIndex = $newRowIndex + 1
8209
+ reIndex = tableData.length
8210
+ offsetRate = -1
8211
+ } else {
8212
+ if (_newRowIndex > _dragRowIndex) {
8213
+ // 从上往下拖拽
8214
+ rsIndex = _dragRowIndex - _firstRowIndex
8215
+ reIndex = rsIndex + _newRowIndex - _dragRowIndex
8216
+ } else {
8217
+ // 从下往上拖拽
8218
+ rsIndex = _newRowIndex - _firstRowIndex
8219
+ reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1
8220
+ offsetRate = -1
8221
+ }
8222
+ }
8114
8223
 
8115
- if (evnt) {
8116
- $xeTable.dispatchEvent('row-dragend', {
8117
- oldRow: dragRow,
8118
- newRow: prevDragRow,
8119
- dragRow,
8120
- dragPos: prevDragPos as any,
8121
- dragToChild: isDragToChildFlag,
8122
- offsetIndex: dragOffsetIndex,
8123
- _index: {
8124
- newIndex: nafIndex,
8125
- oldIndex: oafIndex
8224
+ const dragRangeList = tableData.slice(rsIndex, reIndex)
8225
+ if (dragRangeList.length) {
8226
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(row => `.vxe-body--row[rowid="${getRowid($xeTable, row)}"]`).join(','))
8227
+ moveRowAnimateToTb(dtTrList, offsetRate * dragRowHeight)
8126
8228
  }
8127
- }, evnt)
8128
- }
8229
+ }
8129
8230
 
8130
- return $xeTable.$nextTick().then(() => {
8131
- $xeTable.updateCellAreas()
8132
- $xeTable.recalculate()
8133
- }).then(() => {
8134
- return {
8135
- status: true
8231
+ const newTrList = el.querySelectorAll<HTMLElement>(`.vxe-body--row[rowid="${dragRowid}"]`)
8232
+ const newTrEl = newTrList[0]
8233
+ if (dragOffsetTop > -1 && newTrEl) {
8234
+ moveRowAnimateToTb(newTrList, dragOffsetTop - newTrEl.offsetTop)
8136
8235
  }
8137
- })
8138
- }).catch(() => {
8139
- return errRest
8236
+ }
8237
+
8238
+ updateRowOffsetTop($xeTable)
8239
+ updateRowExpandStyle($xeTable)
8240
+ $xeTable.updateCellAreas()
8241
+ $xeTable.recalculate()
8242
+ }).then(() => {
8243
+ return {
8244
+ status: true
8245
+ }
8140
8246
  })
8141
- }
8247
+ }).catch(() => {
8248
+ return errRest
8249
+ })
8142
8250
  }
8143
8251
  return Promise.resolve(errRest)
8144
8252
  },
@@ -8155,6 +8263,7 @@ const Methods = {
8155
8263
  const { lazy } = treeOpts
8156
8264
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
8157
8265
  const { prevDragRow, prevDragPos } = internalData
8266
+ const el = $xeTable.$refs.refElem as HTMLDivElement
8158
8267
 
8159
8268
  if (treeConfig && lazy && prevDragToChild) {
8160
8269
  // 懒加载
@@ -8172,18 +8281,16 @@ const Methods = {
8172
8281
  }
8173
8282
  hideDropTip($xeTable)
8174
8283
  clearRowDropOrigin($xeTable)
8284
+ clearRowAnimate(el)
8175
8285
  internalData.prevDragToChild = false
8176
8286
  reactData.dragRow = null
8177
8287
  reactData.dragCol = null
8178
- setTimeout(() => {
8179
- reactData.isDragRowMove = false
8180
- }, 500)
8181
8288
  },
8182
8289
  handleRowDragDragoverEvent (evnt: DragEvent) {
8183
- const $xeTable = this
8290
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8184
8291
  const props = $xeTable
8185
- const internalData = $xeTable
8186
- const reactData = $xeTable
8292
+ const reactData = $xeTable as unknown as TableReactData
8293
+ const internalData = $xeTable as unknown as TableInternalData
8187
8294
 
8188
8295
  const { treeConfig } = props
8189
8296
  const { fullAllDataRowIdData } = internalData
@@ -8228,9 +8335,9 @@ const Methods = {
8228
8335
  }
8229
8336
  },
8230
8337
  handleCellDragMousedownEvent (evnt: MouseEvent, params: any) {
8231
- const $xeTable = this
8338
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8232
8339
  const props = $xeTable
8233
- const reactData = $xeTable
8340
+ const reactData = $xeTable as unknown as TableReactData
8234
8341
 
8235
8342
  evnt.stopPropagation()
8236
8343
  const { dragConfig } = props
@@ -8241,7 +8348,6 @@ const Methods = {
8241
8348
  const tdEl = trigger === 'cell' || trigger === 'row' ? dragEl : dragEl.parentElement?.parentElement as HTMLElement
8242
8349
  const trEl = tdEl.parentElement as HTMLElement
8243
8350
  const dStartMethod = dragStartMethod || (dragConfig ? dragConfig.dragStartMethod : null)
8244
- reactData.isDragRowMove = false
8245
8351
  clearRowDropOrigin($xeTable)
8246
8352
  if (dStartMethod && !dStartMethod(params)) {
8247
8353
  trEl.draggable = false
@@ -8258,7 +8364,7 @@ const Methods = {
8258
8364
  $xeTable.dispatchEvent('row-dragstart', params, evnt)
8259
8365
  },
8260
8366
  handleCellDragMouseupEvent () {
8261
- const $xeTable = this
8367
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8262
8368
 
8263
8369
  clearDragStatus($xeTable)
8264
8370
  },
@@ -8274,7 +8380,7 @@ const Methods = {
8274
8380
  const $xeTable = this
8275
8381
 
8276
8382
  handleUpdateColumn($xeTable)
8277
- parseColumns($xeTable, false).then(() => {
8383
+ return parseColumns($xeTable, false).then(() => {
8278
8384
  $xeTable.updateCellAreas()
8279
8385
  $xeTable.saveCustomStore('update:sort')
8280
8386
  })
@@ -8287,79 +8393,84 @@ const Methods = {
8287
8393
 
8288
8394
  const { mouseConfig } = props
8289
8395
  const columnDragOpts = $xeTable.computeColumnDragOpts
8290
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
8291
- const { collectColumn } = internalData
8396
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
8397
+ const { collectColumn, fullColumnIdData } = internalData
8398
+ const el = $xeTable.$refs.refElem as HTMLDivElement
8292
8399
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
8293
8400
  const errRest = {
8294
8401
  status: false
8295
8402
  }
8296
- if (prevDragCol && dragCol) {
8297
- // 判断是否有拖动
8298
- if (prevDragCol !== dragCol) {
8299
- const dragColumn = dragCol
8300
- const newColumn = prevDragCol
8301
- const dragParams = {
8302
- oldColumn: dragColumn,
8303
- newColumn,
8304
- dragColumn,
8305
- dragPos: prevDragPos as 'left' | 'right',
8306
- dragToChild: !!prevDragToChild,
8307
- offsetIndex: dragOffsetIndex as 0 | 1
8308
- }
8309
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
8310
- return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
8311
- if (!status) {
8312
- return errRest
8313
- }
8314
8403
 
8315
- let oafIndex = -1
8316
- let nafIndex = -1
8404
+ if (!(el && prevDragCol && dragCol)) {
8405
+ return Promise.resolve(errRest)
8406
+ }
8407
+ // 判断是否有拖动
8408
+ if (prevDragCol !== dragCol) {
8409
+ const dragColumn = dragCol
8410
+ const newColumn = prevDragCol
8411
+ const dragParams = {
8412
+ oldColumn: dragColumn,
8413
+ newColumn,
8414
+ dragColumn,
8415
+ dragPos: prevDragPos as 'left' | 'right',
8416
+ dragToChild: !!prevDragToChild,
8417
+ offsetIndex: dragOffsetIndex as 0 | 1
8418
+ }
8419
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
8420
+ return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
8421
+ if (!status) {
8422
+ return errRest
8423
+ }
8317
8424
 
8318
- const oldAllMaps: Record<string, any> = {}
8425
+ let dragTargetColumn: VxeTableDefines.ColumnInfo | null = null
8426
+ const dragAllTargetCols: VxeTableDefines.ColumnInfo[] = []
8427
+ let dragColWidth = 0
8428
+ if (animation) {
8319
8429
  XEUtils.eachTree([dragColumn], column => {
8320
- oldAllMaps[column.id] = column
8430
+ if (!dragTargetColumn && (!column.children || !column.children.length)) {
8431
+ dragTargetColumn = column
8432
+ dragColWidth += column.renderWidth
8433
+ }
8434
+ dragAllTargetCols.push(column)
8321
8435
  })
8436
+ }
8437
+ if (!dragTargetColumn) {
8438
+ dragTargetColumn = dragColumn
8439
+ }
8440
+ const dragColRest = fullColumnIdData[dragTargetColumn.id] || {}
8441
+ const _dragColIndex = dragColRest._index
8322
8442
 
8323
- let isSelfToChildStatus = false
8443
+ let dragOffsetLeft = -1
8444
+ if (animation) {
8445
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-table--column[colid="${dragTargetColumn.id}"]`)
8446
+ if (oldTrEl) {
8447
+ dragOffsetLeft = oldTrEl.offsetLeft
8448
+ }
8449
+ }
8324
8450
 
8325
- if (dragColumn.parentId && newColumn.parentId) {
8326
- // 子到子
8451
+ let oafIndex = -1
8452
+ let nafIndex = -1
8327
8453
 
8328
- if (isPeerDrag && !isCrossDrag) {
8329
- if (dragColumn.parentId !== newColumn.parentId) {
8330
- // 非同级
8331
- return errRest
8332
- }
8333
- } else {
8334
- if (!isCrossDrag) {
8335
- return errRest
8336
- }
8454
+ const oldAllMaps: Record<string, any> = {}
8455
+ XEUtils.eachTree([dragColumn], column => {
8456
+ oldAllMaps[column.id] = column
8457
+ })
8337
8458
 
8338
- if (oldAllMaps[newColumn.id]) {
8339
- isSelfToChildStatus = true
8340
- if (!(isCrossDrag && isSelfToChildDrag)) {
8341
- if (VxeUI.modal) {
8342
- VxeUI.modal.message({
8343
- status: 'error',
8344
- content: getI18n('vxe.error.treeDragChild')
8345
- })
8346
- }
8347
- return errRest
8348
- }
8349
- }
8350
- }
8351
- } else if (dragColumn.parentId) {
8352
- // 子到根
8459
+ let isSelfToChildStatus = false
8353
8460
 
8354
- if (!isCrossDrag) {
8461
+ if (dragColumn.parentId && newColumn.parentId) {
8462
+ // 子到子
8463
+
8464
+ if (isPeerDrag && !isCrossDrag) {
8465
+ if (dragColumn.parentId !== newColumn.parentId) {
8466
+ // 非同级
8355
8467
  return errRest
8356
8468
  }
8357
- } else if (newColumn.parentId) {
8358
- // 根到子
8359
-
8469
+ } else {
8360
8470
  if (!isCrossDrag) {
8361
8471
  return errRest
8362
8472
  }
8473
+
8363
8474
  if (oldAllMaps[newColumn.id]) {
8364
8475
  isSelfToChildStatus = true
8365
8476
  if (!(isCrossDrag && isSelfToChildDrag)) {
@@ -8372,120 +8483,223 @@ const Methods = {
8372
8483
  return errRest
8373
8484
  }
8374
8485
  }
8375
- } else {
8376
- // 根到根
8377
8486
  }
8487
+ } else if (dragColumn.parentId) {
8488
+ // 子到根
8378
8489
 
8379
- const oldewMatchRest = XEUtils.findTree(collectColumn as VxeTableDefines.ColumnInfo[], item => item.id === dragColumn.id)
8490
+ if (!isCrossDrag) {
8491
+ return errRest
8492
+ }
8493
+ } else if (newColumn.parentId) {
8494
+ // 根到子
8380
8495
 
8381
- // 改变层级
8382
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
8383
- if (oldewMatchRest) {
8384
- const { items: oCols, index: oIndex } = oldewMatchRest
8385
- const childList = dragColumn.children || []
8386
- childList.forEach(column => {
8387
- column.parentId = dragColumn.parentId
8388
- })
8389
- oCols.splice(oIndex, 1, ...childList)
8390
- dragColumn.children = []
8391
- }
8392
- } else {
8393
- if (oldewMatchRest) {
8394
- const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
8395
- oCols.splice(oIndex, 1)
8396
- if (!oParent) {
8397
- oafIndex = oIndex
8496
+ if (!isCrossDrag) {
8497
+ return errRest
8498
+ }
8499
+ if (oldAllMaps[newColumn.id]) {
8500
+ isSelfToChildStatus = true
8501
+ if (!(isCrossDrag && isSelfToChildDrag)) {
8502
+ if (VxeUI.modal) {
8503
+ VxeUI.modal.message({
8504
+ status: 'error',
8505
+ content: getI18n('vxe.error.treeDragChild')
8506
+ })
8398
8507
  }
8508
+ return errRest
8399
8509
  }
8400
8510
  }
8511
+ } else {
8512
+ // 根到根
8513
+ }
8401
8514
 
8402
- const newMatchRest = XEUtils.findTree(collectColumn as VxeTableDefines.ColumnInfo[], item => item.id === newColumn.id)
8403
- if (newMatchRest) {
8404
- const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
8405
- // 转子级
8406
- if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
8407
- dragColumn.parentId = newColumn.id
8408
- newColumn.children = (newColumn.children || []).concat([dragColumn])
8409
- } else {
8410
- dragColumn.parentId = newColumn.parentId
8411
- nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
8412
- }
8413
- if (!nParent) {
8414
- nafIndex = nIndex
8515
+ const oldewMatchRest = XEUtils.findTree(collectColumn as VxeTableDefines.ColumnInfo[], item => item.id === dragColumn.id)
8516
+
8517
+ // 改变层级
8518
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
8519
+ if (oldewMatchRest) {
8520
+ const { items: oCols, index: oIndex } = oldewMatchRest
8521
+ const childList = dragColumn.children || []
8522
+ childList.forEach(column => {
8523
+ column.parentId = dragColumn.parentId
8524
+ })
8525
+ oCols.splice(oIndex, 1, ...childList)
8526
+ dragColumn.children = []
8527
+ }
8528
+ } else {
8529
+ if (oldewMatchRest) {
8530
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
8531
+ oCols.splice(oIndex, 1)
8532
+ if (!oParent) {
8533
+ oafIndex = oIndex
8415
8534
  }
8416
8535
  }
8536
+ }
8417
8537
 
8418
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
8419
- if (!parentColumn) {
8420
- const sortIndex = index + 1
8421
- column.renderSortNumber = sortIndex
8422
- }
8423
- })
8538
+ const newMatchRest = XEUtils.findTree(collectColumn as VxeTableDefines.ColumnInfo[], item => item.id === newColumn.id)
8539
+ if (newMatchRest) {
8540
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
8541
+ // 转子级
8542
+ if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
8543
+ dragColumn.parentId = newColumn.id
8544
+ newColumn.children = (newColumn.children || []).concat([dragColumn])
8545
+ } else {
8546
+ dragColumn.parentId = newColumn.parentId
8547
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
8548
+ }
8549
+ if (!nParent) {
8550
+ nafIndex = nIndex
8551
+ }
8552
+ }
8424
8553
 
8425
- reactData.isDragColMove = true
8426
- if (mouseConfig) {
8427
- if ($xeTable.clearSelected) {
8428
- $xeTable.clearSelected()
8429
- }
8430
- if ($xeTable.clearCellAreas) {
8431
- $xeTable.clearCellAreas()
8432
- $xeTable.clearCopyCellArea()
8433
- }
8554
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
8555
+ if (!parentColumn) {
8556
+ const sortIndex = index + 1
8557
+ column.renderSortNumber = sortIndex
8434
8558
  }
8559
+ })
8435
8560
 
8436
- if (evnt) {
8437
- $xeTable.dispatchEvent('column-dragend', {
8438
- oldColumn: dragColumn,
8439
- newColumn,
8440
- dragColumn,
8441
- dragPos: prevDragPos,
8442
- dragToChild: isDragToChildFlag,
8443
- offsetIndex: dragOffsetIndex,
8444
- _index: {
8445
- newIndex: nafIndex,
8446
- oldIndex: oafIndex
8447
- }
8448
- }, evnt)
8561
+ if (mouseConfig) {
8562
+ if ($xeTable.clearSelected) {
8563
+ $xeTable.clearSelected()
8449
8564
  }
8565
+ if ($xeTable.clearCellAreas) {
8566
+ $xeTable.clearCellAreas()
8567
+ $xeTable.clearCopyCellArea()
8568
+ }
8569
+ }
8570
+
8571
+ if (evnt) {
8572
+ $xeTable.dispatchEvent('column-dragend', {
8573
+ oldColumn: dragColumn,
8574
+ newColumn,
8575
+ dragColumn,
8576
+ dragPos: prevDragPos,
8577
+ dragToChild: isDragToChildFlag,
8578
+ offsetIndex: dragOffsetIndex,
8579
+ _index: {
8580
+ newIndex: nafIndex,
8581
+ oldIndex: oafIndex
8582
+ }
8583
+ }, evnt)
8584
+ }
8450
8585
 
8586
+ return $xeTable.$nextTick().then(() => {
8451
8587
  if (isSyncColumn) {
8452
- $xeTable.handleColDragSwapColumn()
8588
+ return $xeTable.handleColDragSwapColumn()
8453
8589
  }
8590
+ }).then(() => {
8591
+ if (animation) {
8592
+ const { tableColumn } = reactData
8593
+ const { visibleColumn, fullColumnIdData } = internalData
8594
+ let dragNewColumn: VxeTableDefines.ColumnInfo | null = null
8595
+ const dragNewColMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
8596
+ XEUtils.eachTree([dragColumn], column => {
8597
+ if (!dragNewColumn && (!column.children || !column.children.length)) {
8598
+ dragNewColumn = column
8599
+ }
8600
+ dragNewColMaps[column.id] = column
8601
+ })
8602
+ if (!dragNewColumn) {
8603
+ dragNewColumn = dragColumn
8604
+ }
8605
+
8606
+ if (dragColWidth && dragAllTargetCols.length) {
8607
+ const _newColIndex = XEUtils.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id)
8608
+ const firstCol = tableColumn[0]
8609
+ const firstColRest = fullColumnIdData[firstCol.id]
8610
+
8611
+ if (firstColRest) {
8612
+ const _firstColIndex = firstColRest._index
8613
+ const _lastColIndex = _firstColIndex + tableColumn.length
8614
+ let csIndex = -1
8615
+ let ceIndex = -1
8616
+ let offsetRate = 1
8617
+ if (_dragColIndex < _firstColIndex) {
8618
+ // 从左往右虚拟拖拽
8619
+ csIndex = 0
8620
+ ceIndex = _newColIndex - _firstColIndex
8621
+ } else if (_dragColIndex > _lastColIndex) {
8622
+ // 从右往左虚拟拖拽
8623
+ const $newRowIndex = dragColRest.$index
8624
+ csIndex = $newRowIndex + 1
8625
+ ceIndex = tableColumn.length
8626
+ offsetRate = -1
8627
+ } else {
8628
+ if (_newColIndex > _dragColIndex) {
8629
+ // 从左往右拖拽
8630
+ csIndex = _dragColIndex - _firstColIndex
8631
+ ceIndex = csIndex + _newColIndex - _dragColIndex
8632
+ } else {
8633
+ // 从右往左拖拽
8634
+ csIndex = _newColIndex - _firstColIndex + 1
8635
+ ceIndex = csIndex + _dragColIndex - _newColIndex
8636
+ offsetRate = -1
8637
+ }
8638
+ }
8639
+
8640
+ const dragRangeList: VxeTableDefines.ColumnInfo[] = []
8641
+ const dragRangeMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
8642
+ for (let i = csIndex; i < ceIndex; i++) {
8643
+ const column = tableColumn[i]
8644
+ if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
8645
+ dragRangeMaps[column.id] = column
8646
+ dragRangeList.push(column)
8647
+ }
8648
+ }
8649
+ XEUtils.eachTree([newColumn], column => {
8650
+ if (!dragRangeMaps[column.id]) {
8651
+ dragRangeMaps[column.id] = column
8652
+ dragRangeList.push(column)
8653
+ }
8654
+ })
8655
+ if (dragRangeList.length) {
8656
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
8657
+ moveColAnimateToLr(dtTrList, offsetRate * dragColWidth)
8658
+ }
8659
+ }
8660
+
8661
+ const newTrList = el.querySelectorAll<HTMLElement>(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
8662
+ const newTdEl = newTrList[0]
8663
+ if (dragOffsetLeft > -1 && newTdEl) {
8664
+ moveColAnimateToLr(newTrList, dragOffsetLeft - newTdEl.offsetLeft)
8665
+ }
8666
+ }
8667
+ }
8668
+
8669
+ updateColumnOffsetLeft($xeTable)
8670
+ loadScrollXData($xeTable)
8671
+ $xeTable.updateCellAreas()
8454
8672
 
8455
8673
  return {
8456
8674
  status: true
8457
8675
  }
8458
- }).catch(() => {
8459
- return errRest
8460
8676
  })
8461
- }
8677
+ }).catch(() => {
8678
+ return errRest
8679
+ })
8462
8680
  }
8463
8681
  return Promise.resolve(errRest)
8464
8682
  },
8465
8683
  handleHeaderCellDragDragendEvent (evnt: DragEvent) {
8466
- const $xeTable = this
8467
- const reactData = $xeTable
8468
- const internalData = $xeTable
8684
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8685
+ const reactData = $xeTable as unknown as TableReactData
8686
+ const internalData = $xeTable as unknown as TableInternalData
8469
8687
 
8470
8688
  const { dragCol } = reactData
8471
8689
  const { prevDragCol, prevDragPos, prevDragToChild } = internalData
8690
+ const el = $xeTable.$refs.refElem as HTMLDivElement
8472
8691
  $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild)
8473
8692
  hideDropTip($xeTable)
8474
8693
  clearColDropOrigin($xeTable)
8694
+ clearColAnimate(el)
8475
8695
  internalData.prevDragToChild = false
8476
8696
  reactData.dragRow = null
8477
8697
  reactData.dragCol = null
8478
- setTimeout(() => {
8479
- reactData.isDragColMove = false
8480
- $xeTable.recalculate().then(() => {
8481
- loadScrollXData($xeTable)
8482
- })
8483
- }, 500)
8484
8698
  },
8485
8699
  handleHeaderCellDragDragoverEvent (evnt: DragEvent) {
8486
- const $xeTable = this
8487
- const reactData = $xeTable
8488
- const internalData = $xeTable
8700
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8701
+ const reactData = $xeTable as unknown as TableReactData
8702
+ const internalData = $xeTable as unknown as TableInternalData
8489
8703
 
8490
8704
  const { dragCol } = reactData
8491
8705
  const columnDragOpts = $xeTable.computeColumnDragOpts
@@ -8527,7 +8741,7 @@ const Methods = {
8527
8741
  }
8528
8742
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
8529
8743
  const refTableBody = $xeTable.$refs.refTableBody
8530
- const tableBodyElem = refTableBody ? refTableBody.$el as HTMLDivElement : null
8744
+ const tableBodyElem = refTableBody ? (refTableBody as any).$el as HTMLDivElement : null
8531
8745
  const scrollTargetEl = xHandleEl || tableBodyElem
8532
8746
  if (scrollTargetEl) {
8533
8747
  const wrapperRect = el.getBoundingClientRect()
@@ -8561,7 +8775,6 @@ const Methods = {
8561
8775
  const { column } = params
8562
8776
  const dragEl = evnt.currentTarget as HTMLElement
8563
8777
  const thEl = trigger === 'cell' ? dragEl : dragEl.parentElement?.parentElement as HTMLElement
8564
- reactData.isDragColMove = false
8565
8778
  clearColDropOrigin($xeTable)
8566
8779
  if (dragStartMethod && !dragStartMethod(params)) {
8567
8780
  thEl.draggable = false
@@ -8585,7 +8798,6 @@ const Methods = {
8585
8798
  hideDropTip($xeTable)
8586
8799
  reactData.dragRow = null
8587
8800
  reactData.dragCol = null
8588
- reactData.isDragColMove = false
8589
8801
  },
8590
8802
  setPendingRow (rows: any, status: any) {
8591
8803
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -9087,7 +9299,7 @@ const Methods = {
9087
9299
  reactData.rowExpandedFlag++
9088
9300
  return Promise.all(lazyRests)
9089
9301
  .then(() => $xeTable.$nextTick())
9090
- .then(() => $xeTable.recalculate(true))
9302
+ .then(() => handleLazyRecalculate($xeTable, true, true, true))
9091
9303
  .then(() => {
9092
9304
  updateRowOffsetTop($xeTable)
9093
9305
  updateRowExpandStyle($xeTable)
@@ -9133,7 +9345,7 @@ const Methods = {
9133
9345
  }
9134
9346
  return $xeTable.$nextTick().then(() => {
9135
9347
  if (expList.length) {
9136
- return $xeTable.recalculate(true)
9348
+ return handleLazyRecalculate($xeTable, true, true, true)
9137
9349
  }
9138
9350
  }).then(() => {
9139
9351
  updateRowOffsetTop($xeTable)
@@ -9278,7 +9490,7 @@ const Methods = {
9278
9490
  $xeTable.handleTableData()
9279
9491
  updateAfterDataIndex($xeTable)
9280
9492
  reactData.rowGroupExpandedFlag++
9281
- return $xeTable.recalculate(true)
9493
+ return handleLazyRecalculate($xeTable, true, true, true)
9282
9494
  },
9283
9495
  clearRowGroupExpand () {
9284
9496
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -9290,7 +9502,7 @@ const Methods = {
9290
9502
  $xeTable.handleTableData()
9291
9503
  updateAfterDataIndex($xeTable)
9292
9504
  reactData.rowGroupExpandedFlag++
9293
- return $xeTable.recalculate(true)
9505
+ return handleLazyRecalculate($xeTable, true, true, true)
9294
9506
  },
9295
9507
  getTreeExpandRecords () {
9296
9508
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -9649,8 +9861,6 @@ const Methods = {
9649
9861
  }
9650
9862
  internalData.lastScrollTop = scrollTop
9651
9863
  }
9652
- reactData.isDragColMove = false
9653
- reactData.isDragRowMove = false
9654
9864
  reactData.lastScrollTime = Date.now()
9655
9865
  const evntParams = {
9656
9866
  scrollTop,
@@ -10510,12 +10720,13 @@ const Methods = {
10510
10720
  })
10511
10721
  },
10512
10722
  /**
10513
- * 设置合并单元格
10514
- * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
10723
+ * 设置合并单元格 [{ row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }]
10515
10724
  */
10516
10725
  setMergeCells (merges: any) {
10517
10726
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
10518
10727
  const props = $xeTable
10728
+ const reactData = $xeTable as unknown as TableReactData
10729
+ const internalData = $xeTable as unknown as TableInternalData
10519
10730
 
10520
10731
  if (props.spanMethod) {
10521
10732
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method'])
@@ -10523,13 +10734,17 @@ const Methods = {
10523
10734
  handleBodyMerge($xeTable, merges)
10524
10735
  $xeTable.handleUpdateBodyMerge()
10525
10736
  return $xeTable.$nextTick().then(() => {
10737
+ const { expandColumn } = reactData
10738
+ const { mergeBodyList } = internalData
10739
+ if (expandColumn && mergeBodyList.length) {
10740
+ warnLog('vxe.error.errConflicts', ['type=expand', 'merge-cells | span-method'])
10741
+ }
10526
10742
  $xeTable.updateCellAreas()
10527
10743
  return updateStyle($xeTable)
10528
10744
  })
10529
10745
  },
10530
10746
  /**
10531
- * 移除单元格合并
10532
- * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
10747
+ * 移除单元格合并 [{row:Row|number, col:ColumnInfo|number}]
10533
10748
  */
10534
10749
  removeMergeCells (merges: any) {
10535
10750
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods