vxe-table 4.14.0-beta.1 → 4.14.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 (203) hide show
  1. package/README.en.md +1 -70
  2. package/README.ja-JP.md +1 -70
  3. package/README.md +9 -18
  4. package/README.zh-TW.md +1 -69
  5. package/es/grid/src/grid.js +30 -21
  6. package/es/index.css +1 -1
  7. package/es/index.esm.js +2 -2
  8. package/es/index.min.css +1 -1
  9. package/es/locale/lang/ar-EG.js +4 -1
  10. package/es/locale/lang/de-DE.js +4 -1
  11. package/es/locale/lang/en-US.js +4 -1
  12. package/es/locale/lang/es-ES.js +4 -1
  13. package/es/locale/lang/fr-FR.js +4 -1
  14. package/es/locale/lang/hu-HU.js +4 -1
  15. package/es/locale/lang/hy-AM.js +4 -1
  16. package/es/locale/lang/id-ID.js +4 -1
  17. package/es/locale/lang/it-IT.js +4 -1
  18. package/es/locale/lang/ja-JP.js +4 -1
  19. package/es/locale/lang/ko-KR.js +4 -1
  20. package/es/locale/lang/ms-MY.js +4 -1
  21. package/es/locale/lang/nb-NO.js +4 -1
  22. package/es/locale/lang/pt-BR.js +4 -1
  23. package/es/locale/lang/ru-RU.js +4 -1
  24. package/es/locale/lang/th-TH.js +4 -1
  25. package/es/locale/lang/ug-CN.js +4 -1
  26. package/es/locale/lang/uk-UA.js +4 -1
  27. package/es/locale/lang/uz-UZ.js +4 -1
  28. package/es/locale/lang/vi-VN.js +4 -1
  29. package/es/locale/lang/zh-CHT.js +4 -1
  30. package/es/locale/lang/zh-CN.js +4 -1
  31. package/es/style.css +1 -1
  32. package/es/style.min.css +1 -1
  33. package/es/table/module/custom/hook.js +0 -4
  34. package/es/table/module/custom/panel.js +0 -1
  35. package/es/table/module/edit/hook.js +31 -1
  36. package/es/table/module/filter/hook.js +1 -1
  37. package/es/table/src/anime.js +46 -0
  38. package/es/table/src/body.js +13 -27
  39. package/es/table/src/cell.js +1 -1
  40. package/es/table/src/columnInfo.js +5 -0
  41. package/es/table/src/footer.js +8 -25
  42. package/es/table/src/header.js +5 -22
  43. package/es/table/src/table.js +609 -381
  44. package/es/table/src/util.js +6 -2
  45. package/es/table/style.css +8 -8
  46. package/es/table/style.min.css +1 -1
  47. package/es/ui/index.js +7 -1
  48. package/es/ui/src/log.js +1 -1
  49. package/es/vxe-table/style.css +8 -8
  50. package/es/vxe-table/style.min.css +1 -1
  51. package/lib/grid/src/grid.js +35 -23
  52. package/lib/grid/src/grid.min.js +1 -1
  53. package/lib/index.common.js +5 -5
  54. package/lib/index.css +1 -1
  55. package/lib/index.min.css +1 -1
  56. package/lib/index.umd.js +211 -153
  57. package/lib/index.umd.min.js +1 -1
  58. package/lib/locale/lang/ar-EG.js +4 -1
  59. package/lib/locale/lang/ar-EG.min.js +1 -1
  60. package/lib/locale/lang/ar-EG.umd.js +4 -1
  61. package/lib/locale/lang/de-DE.js +4 -1
  62. package/lib/locale/lang/de-DE.min.js +1 -1
  63. package/lib/locale/lang/de-DE.umd.js +4 -1
  64. package/lib/locale/lang/en-US.js +4 -1
  65. package/lib/locale/lang/en-US.min.js +1 -1
  66. package/lib/locale/lang/en-US.umd.js +4 -1
  67. package/lib/locale/lang/es-ES.js +4 -1
  68. package/lib/locale/lang/es-ES.min.js +1 -1
  69. package/lib/locale/lang/es-ES.umd.js +4 -1
  70. package/lib/locale/lang/fr-FR.js +4 -1
  71. package/lib/locale/lang/fr-FR.min.js +1 -1
  72. package/lib/locale/lang/fr-FR.umd.js +4 -1
  73. package/lib/locale/lang/hu-HU.js +4 -1
  74. package/lib/locale/lang/hu-HU.min.js +1 -1
  75. package/lib/locale/lang/hu-HU.umd.js +4 -1
  76. package/lib/locale/lang/hy-AM.js +4 -1
  77. package/lib/locale/lang/hy-AM.min.js +1 -1
  78. package/lib/locale/lang/hy-AM.umd.js +4 -1
  79. package/lib/locale/lang/id-ID.js +4 -1
  80. package/lib/locale/lang/id-ID.min.js +1 -1
  81. package/lib/locale/lang/id-ID.umd.js +4 -1
  82. package/lib/locale/lang/it-IT.js +4 -1
  83. package/lib/locale/lang/it-IT.min.js +1 -1
  84. package/lib/locale/lang/it-IT.umd.js +4 -1
  85. package/lib/locale/lang/ja-JP.js +4 -1
  86. package/lib/locale/lang/ja-JP.min.js +1 -1
  87. package/lib/locale/lang/ja-JP.umd.js +4 -1
  88. package/lib/locale/lang/ko-KR.js +4 -1
  89. package/lib/locale/lang/ko-KR.min.js +1 -1
  90. package/lib/locale/lang/ko-KR.umd.js +4 -1
  91. package/lib/locale/lang/ms-MY.js +4 -1
  92. package/lib/locale/lang/ms-MY.min.js +1 -1
  93. package/lib/locale/lang/ms-MY.umd.js +4 -1
  94. package/lib/locale/lang/nb-NO.js +4 -1
  95. package/lib/locale/lang/nb-NO.min.js +1 -1
  96. package/lib/locale/lang/nb-NO.umd.js +4 -1
  97. package/lib/locale/lang/pt-BR.js +4 -1
  98. package/lib/locale/lang/pt-BR.min.js +1 -1
  99. package/lib/locale/lang/pt-BR.umd.js +4 -1
  100. package/lib/locale/lang/ru-RU.js +4 -1
  101. package/lib/locale/lang/ru-RU.min.js +1 -1
  102. package/lib/locale/lang/ru-RU.umd.js +4 -1
  103. package/lib/locale/lang/th-TH.js +4 -1
  104. package/lib/locale/lang/th-TH.min.js +1 -1
  105. package/lib/locale/lang/th-TH.umd.js +4 -1
  106. package/lib/locale/lang/ug-CN.js +4 -1
  107. package/lib/locale/lang/ug-CN.min.js +1 -1
  108. package/lib/locale/lang/ug-CN.umd.js +4 -1
  109. package/lib/locale/lang/uk-UA.js +4 -1
  110. package/lib/locale/lang/uk-UA.min.js +1 -1
  111. package/lib/locale/lang/uk-UA.umd.js +4 -1
  112. package/lib/locale/lang/uz-UZ.js +4 -1
  113. package/lib/locale/lang/uz-UZ.min.js +1 -1
  114. package/lib/locale/lang/uz-UZ.umd.js +4 -1
  115. package/lib/locale/lang/vi-VN.js +4 -1
  116. package/lib/locale/lang/vi-VN.min.js +1 -1
  117. package/lib/locale/lang/vi-VN.umd.js +4 -1
  118. package/lib/locale/lang/zh-CHT.js +4 -1
  119. package/lib/locale/lang/zh-CHT.min.js +1 -1
  120. package/lib/locale/lang/zh-CHT.umd.js +4 -1
  121. package/lib/locale/lang/zh-CN.js +4 -1
  122. package/lib/locale/lang/zh-CN.min.js +1 -1
  123. package/lib/locale/lang/zh-CN.umd.js +4 -1
  124. package/lib/style.css +1 -1
  125. package/lib/style.min.css +1 -1
  126. package/lib/table/module/custom/hook.js +0 -4
  127. package/lib/table/module/custom/hook.min.js +1 -1
  128. package/lib/table/module/custom/panel.js +0 -1
  129. package/lib/table/module/custom/panel.min.js +1 -1
  130. package/lib/table/module/edit/hook.js +30 -1
  131. package/lib/table/module/edit/hook.min.js +1 -1
  132. package/lib/table/module/filter/hook.js +1 -1
  133. package/lib/table/module/filter/hook.min.js +1 -1
  134. package/lib/table/src/anime.js +56 -0
  135. package/lib/table/src/anime.min.js +1 -0
  136. package/lib/table/src/body.js +6 -29
  137. package/lib/table/src/body.min.js +1 -1
  138. package/lib/table/src/cell.js +1 -1
  139. package/lib/table/src/cell.min.js +1 -1
  140. package/lib/table/src/columnInfo.js +5 -0
  141. package/lib/table/src/columnInfo.min.js +1 -1
  142. package/lib/table/src/footer.js +6 -23
  143. package/lib/table/src/footer.min.js +1 -1
  144. package/lib/table/src/header.js +3 -20
  145. package/lib/table/src/header.min.js +1 -1
  146. package/lib/table/src/table.js +56 -45
  147. package/lib/table/src/table.min.js +1 -1
  148. package/lib/table/src/util.js +11 -3
  149. package/lib/table/src/util.min.js +1 -1
  150. package/lib/table/style/style.css +8 -8
  151. package/lib/table/style/style.min.css +1 -1
  152. package/lib/ui/index.js +7 -1
  153. package/lib/ui/index.min.js +1 -1
  154. package/lib/ui/src/log.js +1 -1
  155. package/lib/ui/src/log.min.js +1 -1
  156. package/lib/vxe-table/style/style.css +8 -8
  157. package/lib/vxe-table/style/style.min.css +1 -1
  158. package/package.json +2 -2
  159. package/packages/grid/src/grid.ts +32 -22
  160. package/packages/index.ts +2 -2
  161. package/packages/locale/lang/ar-EG.ts +4 -1
  162. package/packages/locale/lang/de-DE.ts +4 -1
  163. package/packages/locale/lang/en-US.ts +4 -1
  164. package/packages/locale/lang/es-ES.ts +4 -1
  165. package/packages/locale/lang/fr-FR.ts +4 -1
  166. package/packages/locale/lang/hu-HU.ts +4 -1
  167. package/packages/locale/lang/hy-AM.ts +4 -1
  168. package/packages/locale/lang/id-ID.ts +4 -1
  169. package/packages/locale/lang/it-IT.ts +4 -1
  170. package/packages/locale/lang/ja-JP.ts +4 -1
  171. package/packages/locale/lang/ko-KR.ts +4 -1
  172. package/packages/locale/lang/ms-MY.ts +4 -1
  173. package/packages/locale/lang/nb-NO.ts +4 -1
  174. package/packages/locale/lang/pt-BR.ts +4 -1
  175. package/packages/locale/lang/ru-RU.ts +4 -1
  176. package/packages/locale/lang/th-TH.ts +4 -1
  177. package/packages/locale/lang/ug-CN.ts +4 -1
  178. package/packages/locale/lang/uk-UA.ts +4 -1
  179. package/packages/locale/lang/uz-UZ.ts +4 -1
  180. package/packages/locale/lang/vi-VN.ts +4 -1
  181. package/packages/locale/lang/zh-CHT.ts +4 -1
  182. package/packages/locale/lang/zh-CN.ts +4 -1
  183. package/packages/table/module/custom/hook.ts +0 -4
  184. package/packages/table/module/custom/panel.ts +0 -1
  185. package/packages/table/module/edit/hook.ts +29 -1
  186. package/packages/table/module/filter/hook.ts +1 -1
  187. package/packages/table/src/anime.ts +52 -0
  188. package/packages/table/src/body.ts +20 -41
  189. package/packages/table/src/cell.ts +1 -1
  190. package/packages/table/src/columnInfo.ts +5 -0
  191. package/packages/table/src/footer.ts +8 -25
  192. package/packages/table/src/header.ts +5 -22
  193. package/packages/table/src/table.ts +620 -384
  194. package/packages/table/src/util.ts +6 -2
  195. package/packages/ui/index.ts +6 -0
  196. package/styles/components/table.scss +9 -9
  197. package/types/all.d.ts +3 -18
  198. /package/es/{iconfont.1750910518778.ttf → iconfont.1751970630744.ttf} +0 -0
  199. /package/es/{iconfont.1750910518778.woff → iconfont.1751970630744.woff} +0 -0
  200. /package/es/{iconfont.1750910518778.woff2 → iconfont.1751970630744.woff2} +0 -0
  201. /package/lib/{iconfont.1750910518778.ttf → iconfont.1751970630744.ttf} +0 -0
  202. /package/lib/{iconfont.1750910518778.woff → iconfont.1751970630744.woff} +0 -0
  203. /package/lib/{iconfont.1750910518778.woff2 → iconfont.1751970630744.woff2} +0 -0
@@ -4,15 +4,16 @@ import XEUtils from 'xe-utils'
4
4
  import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey } from '../../ui/src/dom'
5
5
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
6
6
  import { VxeUI } from '../../ui'
7
+ import { getRowUniqueId, clearTableAllStatus, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight } from './util'
8
+ import { getSlotVNs } from '../../ui/src/vn'
9
+ import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime'
10
+ import { warnLog, errLog } from '../../ui/src/log'
7
11
  import Cell from './cell'
8
12
  import TableBodyComponent from './body'
9
13
  import TableHeaderComponent from './header'
10
14
  import TableFooterComponent from './footer'
11
15
  import tableProps from './props'
12
16
  import tableEmits from './emits'
13
- import { getRowUniqueId, clearTableAllStatus, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCellHeight } from './util'
14
- import { getSlotVNs } from '../../ui/src/vn'
15
- import { warnLog, errLog } from '../../ui/src/log'
16
17
  import TableCustomPanelComponent from '../module/custom/panel'
17
18
  import TableFilterPanelComponent from '../module/filter/panel'
18
19
  import TableImportPanelComponent from '../module/export/import-panel'
@@ -277,6 +278,8 @@ export default defineVxeComponent({
277
278
  scrollXWidth: 0,
278
279
  isScrollXBig: false,
279
280
 
281
+ lazScrollLoading: false,
282
+
280
283
  rowExpandHeightFlag: 1,
281
284
  calcCellHeightFlag: 1,
282
285
  resizeHeightFlag: 1,
@@ -570,14 +573,14 @@ export default defineVxeComponent({
570
573
  const computeHeaderCellOpts = computed(() => {
571
574
  const headerCellOpts = Object.assign({}, getConfig().table.headerCellConfig, props.headerCellConfig)
572
575
  const cellOpts = computeCellOpts.value
573
- headerCellOpts.height = XEUtils.toNumber(getCellHeight(headerCellOpts.height || cellOpts.height))
576
+ headerCellOpts.height = XEUtils.toNumber(getCalcHeight(headerCellOpts.height || cellOpts.height))
574
577
  return headerCellOpts
575
578
  })
576
579
 
577
580
  const computeFooterCellOpts = computed(() => {
578
581
  const footerCellOpts = Object.assign({}, getConfig().table.footerCellConfig, props.footerCellConfig)
579
582
  const cellOpts = computeCellOpts.value
580
- footerCellOpts.height = XEUtils.toNumber(getCellHeight(footerCellOpts.height || cellOpts.height))
583
+ footerCellOpts.height = XEUtils.toNumber(getCalcHeight(footerCellOpts.height || cellOpts.height))
581
584
  return footerCellOpts
582
585
  })
583
586
 
@@ -772,10 +775,10 @@ export default defineVxeComponent({
772
775
  })
773
776
 
774
777
  const computeTableRowExpandedList = computed(() => {
775
- const { rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData
778
+ const { tableData, rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData
776
779
  const { visibleDataRowIdData, rowExpandedMaps } = internalData
777
780
  const expandList: any[] = []
778
- if (expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
781
+ if (tableData.length && expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
779
782
  XEUtils.each(rowExpandedMaps, (row, rowid) => {
780
783
  if (visibleDataRowIdData[rowid]) {
781
784
  expandList.push(row)
@@ -1223,6 +1226,13 @@ export default defineVxeComponent({
1223
1226
  return mergeMaps
1224
1227
  }
1225
1228
 
1229
+ const handleUpdateMergeBodyCells = (merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) => {
1230
+ internalData.mergeBodyList = []
1231
+ internalData.mergeBodyMaps = {}
1232
+ internalData.mergeBodyCellMaps = {}
1233
+ $xeTable.setMergeCells(merges)
1234
+ }
1235
+
1226
1236
  const handleBodyMerge = (merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) => {
1227
1237
  const { fullAllDataRowIdData, fullColumnIdData, visibleColumn, afterFullData, mergeBodyList, mergeBodyMaps } = internalData
1228
1238
  if (merges) {
@@ -1284,6 +1294,13 @@ export default defineVxeComponent({
1284
1294
  }
1285
1295
  }
1286
1296
 
1297
+ const handleUpdateMergeFooterCells = (merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) => {
1298
+ internalData.mergeFooterList = []
1299
+ internalData.mergeFooterMaps = {}
1300
+ internalData.mergeFooterCellMaps = {}
1301
+ $xeTable.setMergeFooterItems(merges)
1302
+ }
1303
+
1287
1304
  const handleFooterMerge = (merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) => {
1288
1305
  const { footerTableData } = reactData
1289
1306
  const { mergeFooterList, mergeFooterMaps, fullColumnIdData } = internalData
@@ -1703,7 +1720,20 @@ export default defineVxeComponent({
1703
1720
  }
1704
1721
 
1705
1722
  const calcColumnAutoWidth = (column: VxeTableDefines.ColumnInfo, wrapperEl: HTMLDivElement) => {
1706
- const cellElemList = wrapperEl.querySelectorAll(`.vxe-cell--wrapper[colid="${column.id}"]`)
1723
+ const columnOpts = computeColumnOpts.value
1724
+ const { autoOptions } = columnOpts
1725
+ const { isCalcHeader, isCalcBody, isCalcFooter } = autoOptions || {}
1726
+ const querySelections: string[] = []
1727
+ if (isCalcHeader) {
1728
+ querySelections.push(`.vxe-header-cell--wrapper[colid="${column.id}"]`)
1729
+ }
1730
+ if (isCalcBody) {
1731
+ querySelections.push(`.vxe-body-cell--wrapper[colid="${column.id}"]`)
1732
+ }
1733
+ if (isCalcFooter) {
1734
+ querySelections.push(`.vxe-footer-cell--wrapper[colid="${column.id}"]`)
1735
+ }
1736
+ const cellElemList = querySelections.length ? wrapperEl.querySelectorAll(querySelections.join(',')) : []
1707
1737
  let leftRightPadding = 0
1708
1738
  const firstCellEl = cellElemList[0]
1709
1739
  if (firstCellEl && firstCellEl.parentElement) {
@@ -3113,7 +3143,7 @@ export default defineVxeComponent({
3113
3143
  }
3114
3144
  }
3115
3145
 
3116
- const handleRecalculateLayout = (reFull: boolean) => {
3146
+ const handleRecalculateStyle = (reFull: boolean, reWidth: boolean, reHeight: boolean) => {
3117
3147
  const el = refElem.value
3118
3148
  internalData.rceRunTime = Date.now()
3119
3149
  if (!el || !el.clientWidth) {
@@ -3127,19 +3157,28 @@ export default defineVxeComponent({
3127
3157
  calcVarRowHeightConfig('small', smallEl)
3128
3158
  calcVarRowHeightConfig('mini', miniEl)
3129
3159
  }
3130
- calcCellWidth()
3131
- autoCellWidth()
3160
+ if (reWidth) {
3161
+ calcCellWidth()
3162
+ }
3163
+ if (reFull) {
3164
+ autoCellWidth()
3165
+ }
3132
3166
  calcScrollbar()
3133
3167
  updateStyle()
3134
3168
  updateRowExpandStyle()
3135
3169
  return computeScrollLoad().then(() => {
3136
3170
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
3137
- calcCellWidth()
3171
+ if (reWidth) {
3172
+ calcCellWidth()
3173
+ }
3138
3174
  if (reFull) {
3139
3175
  autoCellWidth()
3140
3176
  }
3141
- calcScrollbar()
3177
+ if (reHeight) {
3178
+ calcCellHeight()
3179
+ }
3142
3180
  updateStyle()
3181
+ calcScrollbar()
3143
3182
  if (reFull) {
3144
3183
  updateRowOffsetTop()
3145
3184
  }
@@ -3150,6 +3189,39 @@ export default defineVxeComponent({
3150
3189
  })
3151
3190
  }
3152
3191
 
3192
+ const handleLazyRecalculate = (reFull: boolean, reWidth: boolean, reHeight: boolean) => {
3193
+ return new Promise<void>(resolve => {
3194
+ const { rceTimeout, rceRunTime } = internalData
3195
+ const resizeOpts = computeResizeOpts.value
3196
+ const refreshDelay = resizeOpts.refreshDelay || 20
3197
+ const el = refElem.value
3198
+ if (el && el.clientWidth) {
3199
+ autoCellWidth()
3200
+ updateRowExpandStyle()
3201
+ }
3202
+ if (rceTimeout) {
3203
+ clearTimeout(rceTimeout)
3204
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3205
+ resolve(
3206
+ handleRecalculateStyle(reFull, reWidth, reHeight)
3207
+ )
3208
+ } else {
3209
+ nextTick(() => {
3210
+ resolve()
3211
+ })
3212
+ }
3213
+ } else {
3214
+ resolve(
3215
+ handleRecalculateStyle(reFull, reWidth, reHeight)
3216
+ )
3217
+ }
3218
+ internalData.rceTimeout = setTimeout(() => {
3219
+ internalData.rceTimeout = undefined
3220
+ handleRecalculateStyle(reFull, reWidth, reHeight)
3221
+ }, refreshDelay)
3222
+ })
3223
+ }
3224
+
3153
3225
  const handleUpdateAggValues = () => {
3154
3226
  const { visibleColumn } = internalData
3155
3227
  const aggCols: VxeTableDefines.ColumnInfo[] = []
@@ -3365,8 +3437,6 @@ export default defineVxeComponent({
3365
3437
  internalData.removeRowMaps = {}
3366
3438
  reactData.removeRowFlag++
3367
3439
  const sYLoad = updateScrollYStatus(fullData)
3368
- reactData.isDragColMove = false
3369
- reactData.isDragRowMove = false
3370
3440
  // 全量数据
3371
3441
  internalData.tableFullData = fullData
3372
3442
  internalData.tableFullTreeData = isRGroup ? [] : treeData
@@ -3430,11 +3500,10 @@ export default defineVxeComponent({
3430
3500
  $xeTable.checkSelectionStatus()
3431
3501
  return new Promise<void>(resolve => {
3432
3502
  nextTick()
3433
- .then(() => handleRecalculateLayout(false))
3503
+ .then(() => handleRecalculateStyle(false, false, false))
3434
3504
  .then(() => {
3435
- calcCellHeight()
3505
+ handleRecalculateStyle(false, true, true)
3436
3506
  updateRowOffsetTop()
3437
- return handleRecalculateLayout(false)
3438
3507
  })
3439
3508
  .then(() => {
3440
3509
  let targetScrollLeft = lastScrollLeft
@@ -3449,12 +3518,12 @@ export default defineVxeComponent({
3449
3518
  targetScrollTop = 0
3450
3519
  }
3451
3520
  reactData.isRowLoading = false
3452
- handleRecalculateLayout(false)
3521
+ handleRecalculateStyle(false, false, false)
3453
3522
  // 是否变更虚拟滚动
3454
3523
  if (oldScrollYLoad === sYLoad) {
3455
3524
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
3456
3525
  .then(() => {
3457
- calcCellHeight()
3526
+ handleRecalculateStyle(false, true, true)
3458
3527
  updateRowOffsetTop()
3459
3528
  resolve()
3460
3529
  })
@@ -3462,7 +3531,7 @@ export default defineVxeComponent({
3462
3531
  setTimeout(() => {
3463
3532
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
3464
3533
  .then(() => {
3465
- calcCellHeight()
3534
+ handleRecalculateStyle(false, true, true)
3466
3535
  updateRowOffsetTop()
3467
3536
  resolve()
3468
3537
  })
@@ -3687,7 +3756,6 @@ export default defineVxeComponent({
3687
3756
  const tableFullColumn = getColumnList(collectColumn)
3688
3757
  internalData.tableFullColumn = tableFullColumn
3689
3758
  reactData.isColLoading = true
3690
- reactData.isDragColMove = false
3691
3759
  initColumnSort()
3692
3760
  return Promise.resolve(
3693
3761
  restoreCustomStorage()
@@ -3719,7 +3787,7 @@ export default defineVxeComponent({
3719
3787
  $xeTable.handleUpdateCustomColumn()
3720
3788
  }
3721
3789
  reactData.isColLoading = false
3722
- return $xeTable.recalculate()
3790
+ return handleLazyRecalculate(false, true, true)
3723
3791
  })
3724
3792
  })
3725
3793
  }
@@ -3825,7 +3893,7 @@ export default defineVxeComponent({
3825
3893
  updateAfterDataIndex()
3826
3894
  return nextTick()
3827
3895
  }).then(() => {
3828
- return $xeTable.recalculate(true)
3896
+ return handleLazyRecalculate(true, true, true)
3829
3897
  }).then(() => {
3830
3898
  setTimeout(() => {
3831
3899
  $xeTable.updateCellAreas()
@@ -3898,7 +3966,7 @@ export default defineVxeComponent({
3898
3966
  updateAfterDataIndex()
3899
3967
  return nextTick()
3900
3968
  }).then(() => {
3901
- return $xeTable.recalculate(true)
3969
+ return handleLazyRecalculate(true, true, true)
3902
3970
  }).then(() => {
3903
3971
  setTimeout(() => {
3904
3972
  $xeTable.updateCellAreas()
@@ -4010,6 +4078,7 @@ export default defineVxeComponent({
4010
4078
  const checkLastSyncScroll = (isRollX: boolean, isRollY: boolean) => {
4011
4079
  const { scrollXLoad, scrollYLoad, isAllOverflow } = reactData
4012
4080
  const { lcsTimeout } = internalData
4081
+ reactData.lazScrollLoading = true
4013
4082
  if (lcsTimeout) {
4014
4083
  clearTimeout(lcsTimeout)
4015
4084
  }
@@ -4022,6 +4091,7 @@ export default defineVxeComponent({
4022
4091
  internalData.inHeaderScroll = false
4023
4092
  internalData.inBodyScroll = false
4024
4093
  internalData.inFooterScroll = false
4094
+ reactData.lazScrollLoading = false
4025
4095
  internalData.scrollRenderType = ''
4026
4096
 
4027
4097
  if (!isAllOverflow) {
@@ -4261,23 +4331,23 @@ export default defineVxeComponent({
4261
4331
  */
4262
4332
  updateData () {
4263
4333
  const { scrollXLoad, scrollYLoad } = reactData
4264
- return tablePrivateMethods.handleTableData(true).then(() => {
4265
- tableMethods.updateFooter()
4334
+ return $xeTable.handleTableData(true).then(() => {
4335
+ $xeTable.updateFooter()
4266
4336
  if (scrollXLoad || scrollYLoad) {
4267
4337
  if (scrollXLoad) {
4268
- tablePrivateMethods.updateScrollXSpace()
4338
+ $xeTable.updateScrollXSpace()
4269
4339
  }
4270
4340
  if (scrollYLoad) {
4271
- tablePrivateMethods.updateScrollYSpace()
4341
+ $xeTable.updateScrollYSpace()
4272
4342
  }
4273
- return tableMethods.refreshScroll()
4343
+ return $xeTable.refreshScroll()
4274
4344
  }
4275
4345
  }).then(() => {
4276
- tableMethods.updateCellAreas()
4277
- return tableMethods.recalculate(true)
4346
+ $xeTable.updateCellAreas()
4347
+ return handleLazyRecalculate(true, true, true)
4278
4348
  }).then(() => {
4279
4349
  // 存在滚动行为未结束情况
4280
- setTimeout(() => $xeTable.recalculate(), 50)
4350
+ setTimeout(() => handleLazyRecalculate(false, true, true), 50)
4281
4351
  })
4282
4352
  },
4283
4353
  /**
@@ -4292,7 +4362,7 @@ export default defineVxeComponent({
4292
4362
  if (!initStatus) {
4293
4363
  handleLoadDefaults()
4294
4364
  }
4295
- return tableMethods.recalculate()
4365
+ return handleLazyRecalculate(false, true, true)
4296
4366
  })
4297
4367
  },
4298
4368
  /**
@@ -4300,14 +4370,14 @@ export default defineVxeComponent({
4300
4370
  * @param {Array} datas 数据
4301
4371
  */
4302
4372
  reloadData (datas) {
4303
- return tableMethods.clearAll()
4373
+ return $xeTable.clearAll()
4304
4374
  .then(() => {
4305
4375
  internalData.inited = true
4306
4376
  internalData.initStatus = true
4307
4377
  return loadTableData(datas, true)
4308
4378
  }).then(() => {
4309
4379
  handleLoadDefaults()
4310
- return tableMethods.recalculate()
4380
+ return handleLazyRecalculate(false, true, true)
4311
4381
  })
4312
4382
  },
4313
4383
  /**
@@ -4610,7 +4680,7 @@ export default defineVxeComponent({
4610
4680
  }
4611
4681
  return nextTick().then(() => {
4612
4682
  $xeTable.updateCellAreas()
4613
- return $xeTable.recalculate()
4683
+ return handleLazyRecalculate(false, true, true)
4614
4684
  })
4615
4685
  }
4616
4686
  return $xeTable.reloadData(tableSourceData)
@@ -5215,9 +5285,9 @@ export default defineVxeComponent({
5215
5285
  handleUpdateColumn()
5216
5286
  }
5217
5287
  return parseColumns(true).then(() => {
5218
- return tableMethods.refreshScroll()
5288
+ return $xeTable.refreshScroll()
5219
5289
  }).then(() => {
5220
- return tableMethods.recalculate()
5290
+ return handleLazyRecalculate(false, true, true)
5221
5291
  })
5222
5292
  },
5223
5293
  setRowHeightConf (heightConf) {
@@ -5353,36 +5423,8 @@ export default defineVxeComponent({
5353
5423
  * 刷新布局
5354
5424
  */
5355
5425
  recalculate (reFull?: boolean) {
5356
- return new Promise<void>(resolve => {
5357
- const { rceTimeout, rceRunTime } = internalData
5358
- const resizeOpts = computeResizeOpts.value
5359
- const refreshDelay = resizeOpts.refreshDelay || 20
5360
- const el = refElem.value
5361
- if (el && el.clientWidth) {
5362
- autoCellWidth()
5363
- updateRowExpandStyle()
5364
- }
5365
- if (rceTimeout) {
5366
- clearTimeout(rceTimeout)
5367
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
5368
- resolve(
5369
- handleRecalculateLayout(!!reFull)
5370
- )
5371
- } else {
5372
- nextTick(() => {
5373
- resolve()
5374
- })
5375
- }
5376
- } else {
5377
- resolve(
5378
- handleRecalculateLayout(!!reFull)
5379
- )
5380
- }
5381
- internalData.rceTimeout = setTimeout(() => {
5382
- internalData.rceTimeout = undefined
5383
- handleRecalculateLayout(!!reFull)
5384
- }, refreshDelay)
5385
- })
5426
+ const isForce = !!reFull
5427
+ return handleLazyRecalculate(isForce, isForce, isForce)
5386
5428
  },
5387
5429
  openTooltip (target, content) {
5388
5430
  const $commTip = refCommTooltip.value
@@ -6179,7 +6221,7 @@ export default defineVxeComponent({
6179
6221
  reactData.rowExpandedFlag++
6180
6222
  return Promise.all(lazyRests)
6181
6223
  .then(() => nextTick())
6182
- .then(() => $xeTable.recalculate(true))
6224
+ .then(() => handleLazyRecalculate(true, true, true))
6183
6225
  .then(() => {
6184
6226
  updateRowOffsetTop()
6185
6227
  updateRowExpandStyle()
@@ -6217,7 +6259,7 @@ export default defineVxeComponent({
6217
6259
  }
6218
6260
  return nextTick().then(() => {
6219
6261
  if (expList.length) {
6220
- return $xeTable.recalculate(true)
6262
+ return handleLazyRecalculate(true, true, true)
6221
6263
  }
6222
6264
  }).then(() => {
6223
6265
  updateRowOffsetTop()
@@ -6328,7 +6370,7 @@ export default defineVxeComponent({
6328
6370
  $xeTable.handleTableData()
6329
6371
  updateAfterDataIndex()
6330
6372
  reactData.rowGroupExpandedFlag++
6331
- return $xeTable.recalculate(true)
6373
+ return handleLazyRecalculate(true, true, true)
6332
6374
  },
6333
6375
  clearRowGroupExpand () {
6334
6376
  internalData.rowGroupExpandedMaps = {}
@@ -6336,7 +6378,7 @@ export default defineVxeComponent({
6336
6378
  $xeTable.handleTableData()
6337
6379
  updateAfterDataIndex()
6338
6380
  reactData.rowGroupExpandedFlag++
6339
- return $xeTable.recalculate(true)
6381
+ return handleLazyRecalculate(true, true, true)
6340
6382
  },
6341
6383
  getTreeExpandRecords () {
6342
6384
  const rest: any[] = []
@@ -6675,8 +6717,7 @@ export default defineVxeComponent({
6675
6717
  })
6676
6718
  },
6677
6719
  /**
6678
- * 设置合并单元格
6679
- * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
6720
+ * 设置合并单元格 [{ row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }]
6680
6721
  */
6681
6722
  setMergeCells (merges) {
6682
6723
  if (props.spanMethod) {
@@ -6685,13 +6726,17 @@ export default defineVxeComponent({
6685
6726
  handleBodyMerge(merges)
6686
6727
  $xeTable.handleUpdateBodyMerge()
6687
6728
  return nextTick().then(() => {
6729
+ const { expandColumn } = reactData
6730
+ const { mergeBodyList } = internalData
6731
+ if (expandColumn && mergeBodyList.length) {
6732
+ warnLog('vxe.error.errConflicts', ['type=expand', 'merge-cells | span-method'])
6733
+ }
6688
6734
  $xeTable.updateCellAreas()
6689
6735
  return updateStyle()
6690
6736
  })
6691
6737
  },
6692
6738
  /**
6693
- * 移除单元格合并
6694
- * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
6739
+ * 移除单元格合并 [{row:Row|number, col:ColumnInfo|number}]
6695
6740
  */
6696
6741
  removeMergeCells (merges) {
6697
6742
  if (props.spanMethod) {
@@ -6730,7 +6775,7 @@ export default defineVxeComponent({
6730
6775
  handleFooterMerge(merges)
6731
6776
  $xeTable.handleUpdateFooterMerge()
6732
6777
  return nextTick().then(() => {
6733
- tableMethods.updateCellAreas()
6778
+ $xeTable.updateCellAreas()
6734
6779
  return updateStyle()
6735
6780
  })
6736
6781
  },
@@ -6741,7 +6786,7 @@ export default defineVxeComponent({
6741
6786
  const rest = removeFooterMerges(merges)
6742
6787
  $xeTable.handleUpdateFooterMerge()
6743
6788
  return nextTick().then(() => {
6744
- tableMethods.updateCellAreas()
6789
+ $xeTable.updateCellAreas()
6745
6790
  updateStyle()
6746
6791
  return rest
6747
6792
  })
@@ -7428,10 +7473,10 @@ export default defineVxeComponent({
7428
7473
  }
7429
7474
  const el = refElem.value
7430
7475
  if (!el || !el.clientWidth) {
7431
- return nextTick()
7476
+ return
7432
7477
  }
7433
- tableMethods.recalculate(true)
7434
- tableMethods.updateCellAreas()
7478
+ handleLazyRecalculate(true, true, true)
7479
+ $xeTable.updateCellAreas()
7435
7480
  }
7436
7481
 
7437
7482
  const handleTargetEnterEvent = (isClear: boolean) => {
@@ -7454,8 +7499,6 @@ export default defineVxeComponent({
7454
7499
  hideDropTip()
7455
7500
  reactData.dragRow = null
7456
7501
  reactData.dragCol = null
7457
- reactData.isDragColMove = false
7458
- reactData.isDragRowMove = false
7459
7502
  }
7460
7503
  }
7461
7504
 
@@ -8421,7 +8464,8 @@ export default defineVxeComponent({
8421
8464
  const childList: any[] = vals[2]
8422
8465
  let sLen = 0 // 已选
8423
8466
  let hLen = 0 // 半选
8424
- let vLen = 0 // 有效行
8467
+ let vLen = 0 // 有效子行
8468
+ const cLen = childList.length // 有效子行
8425
8469
  childList.forEach(
8426
8470
  checkMethod
8427
8471
  ? (item) => {
@@ -8454,15 +8498,25 @@ export default defineVxeComponent({
8454
8498
  }
8455
8499
  )
8456
8500
 
8457
- let isSelected = (sLen >= vLen && (vLen >= 1 || hLen >= 1))
8458
- if (checkMethod) {
8459
- if (checkMethod({ $table: $xeTable, row })) {
8460
- isSelected = sLen >= vLen
8501
+ let isSelected = false
8502
+ if (cLen > 0) {
8503
+ if (vLen > 0) {
8504
+ isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen
8461
8505
  } else {
8462
- isSelected = selectCheckboxMaps[rowid]
8506
+ // 如果存在子项禁用
8507
+ if ((sLen > 0 && sLen >= vLen)) {
8508
+ isSelected = true
8509
+ } else if (selectCheckboxMaps[rowid]) {
8510
+ isSelected = true
8511
+ } else {
8512
+ isSelected = false
8513
+ }
8463
8514
  }
8515
+ } else {
8516
+ // 如果无子项
8517
+ isSelected = selectCheckboxMaps[rowid]
8464
8518
  }
8465
- const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
8519
+ const halfSelect = !isSelected && (sLen > 0 || hLen > 0)
8466
8520
 
8467
8521
  if (checkField) {
8468
8522
  XEUtils.set(row, checkField, isSelected)
@@ -8501,7 +8555,9 @@ export default defineVxeComponent({
8501
8555
  const { handleGetRowId } = createHandleGetRowId($xeTable)
8502
8556
 
8503
8557
  let sLen = 0 // 已选
8558
+ let dsLen = 0 // 禁用的已选
8504
8559
  let hLen = 0 // 半选
8560
+ let dhLen = 0 // 禁用的半选
8505
8561
  let vLen = 0 // 有效行
8506
8562
 
8507
8563
  const rootList = (treeConfig ? afterTreeFullData : (isRowGroupStatus ? afterGroupFullData : afterFullData))
@@ -8518,9 +8574,9 @@ export default defineVxeComponent({
8518
8574
  vLen++
8519
8575
  } else {
8520
8576
  if (selected) {
8521
- sLen++
8577
+ dsLen++
8522
8578
  } else if (treeIndeterminateRowMaps[childRowid]) {
8523
- hLen++
8579
+ dhLen++
8524
8580
  }
8525
8581
  }
8526
8582
  }
@@ -8536,7 +8592,7 @@ export default defineVxeComponent({
8536
8592
  })
8537
8593
 
8538
8594
  const isSelected = rootList.length > 0 ? (vLen > 0 ? (sLen >= vLen) : (sLen >= rootList.length)) : false
8539
- let halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
8595
+ let halfSelect = !isSelected && (sLen > 0 || hLen > 0 || dsLen > 0 || dhLen > 0)
8540
8596
 
8541
8597
  // 如果复选框启用保留记录,当保留数据存在时显示半选
8542
8598
  if (!isSelected && !halfSelect && showReserveStatus) {
@@ -9328,88 +9384,81 @@ export default defineVxeComponent({
9328
9384
  const { treeConfig, dragConfig } = props
9329
9385
  const rowDragOpts = computeRowDragOpts.value
9330
9386
  const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
9331
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
9387
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
9332
9388
  const treeOpts = computeTreeOpts.value
9389
+ const cellOpts = computeCellOpts.value
9390
+ const rowOpts = computeRowOpts.value
9391
+ const defaultRowHeight = computeDefaultRowHeight.value
9333
9392
  const { transform, rowField, mapChildrenField, parentField } = treeOpts
9334
9393
  const childrenField = treeOpts.children || treeOpts.childrenField
9335
9394
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
9336
9395
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
9396
+ const el = refElem.value
9337
9397
  const errRest = {
9338
9398
  status: false
9339
9399
  }
9340
- if (prevDragRow && dragRow) {
9341
- // 判断是否有拖动
9342
- if (prevDragRow !== dragRow) {
9343
- const dragParams = {
9344
- oldRow: dragRow,
9345
- newRow: prevDragRow,
9346
- dragRow,
9347
- dragPos: prevDragPos as 'top' | 'bottom',
9348
- dragToChild: !!prevDragToChild,
9349
- offsetIndex: dragOffsetIndex as 0 | 1
9350
- }
9351
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9352
- return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
9353
- if (!status) {
9354
- return errRest
9400
+ if (!(el && prevDragRow && dragRow)) {
9401
+ return Promise.resolve(errRest)
9402
+ }
9403
+ // 判断是否有拖动
9404
+ if (prevDragRow !== dragRow) {
9405
+ const dragParams = {
9406
+ oldRow: dragRow,
9407
+ newRow: prevDragRow,
9408
+ dragRow,
9409
+ dragPos: prevDragPos as 'top' | 'bottom',
9410
+ dragToChild: !!prevDragToChild,
9411
+ offsetIndex: dragOffsetIndex as 0 | 1
9412
+ }
9413
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9414
+ return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
9415
+ if (!status) {
9416
+ return errRest
9417
+ }
9418
+
9419
+ const dragRowid = getRowid($xeTable, dragRow)
9420
+ const dragRowRest = fullAllDataRowIdData[dragRowid] || {}
9421
+ const _dragRowIndex = dragRowRest._index
9422
+ let dragRowHeight = 0
9423
+ let dragOffsetTop = -1
9424
+ if (animation) {
9425
+ dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight)
9426
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-body--row[rowid="${dragRowid}"]`)
9427
+ if (oldTrEl) {
9428
+ dragOffsetTop = oldTrEl.offsetTop
9355
9429
  }
9430
+ }
9356
9431
 
9357
- let oafIndex = -1
9358
- let nafIndex = -1
9359
- // 如果为树结构
9360
- if (treeConfig) {
9361
- if (transform) {
9362
- // 移出源位置
9363
- const oldRowid = getRowid($xeTable, dragRow)
9364
- const oldRest = fullAllDataRowIdData[oldRowid]
9365
- const newRowid = getRowid($xeTable, prevDragRow)
9366
- const newRest = fullAllDataRowIdData[newRowid]
9367
-
9368
- if (oldRest && newRest) {
9369
- const { level: oldLevel } = oldRest
9370
- const { level: newLevel } = newRest
9371
-
9372
- const oldAllMaps: Record<string, any> = {}
9373
- XEUtils.eachTree([dragRow], item => {
9374
- oldAllMaps[getRowid($xeTable, item)] = item
9375
- }, { children: mapChildrenField })
9376
-
9377
- let isSelfToChildStatus = false
9378
-
9379
- if (oldLevel && newLevel) {
9380
- // 子到子
9381
-
9382
- if (isPeerDrag && !isCrossDrag) {
9383
- if (oldRest.row[parentField] !== newRest.row[parentField]) {
9384
- // 非同级
9385
- return errRest
9386
- }
9387
- } else {
9388
- if (!isCrossDrag) {
9389
- return errRest
9390
- }
9391
- if (oldAllMaps[newRowid]) {
9392
- isSelfToChildStatus = true
9393
- if (!(isCrossDrag && isSelfToChildDrag)) {
9394
- if (VxeUI.modal) {
9395
- VxeUI.modal.message({
9396
- status: 'error',
9397
- content: getI18n('vxe.error.treeDragChild')
9398
- })
9399
- }
9400
- return errRest
9401
- }
9402
- }
9403
- }
9404
- } else if (oldLevel) {
9405
- // 子到根
9432
+ let oafIndex = -1
9433
+ let nafIndex = -1
9434
+ // 如果为树结构
9435
+ if (treeConfig) {
9436
+ if (transform) {
9437
+ // 移出源位置
9438
+ const oldRest = dragRowRest
9439
+ const newRowid = getRowid($xeTable, prevDragRow)
9440
+ const newRest = fullAllDataRowIdData[newRowid]
9406
9441
 
9407
- if (!isCrossDrag) {
9442
+ if (oldRest && newRest) {
9443
+ const { level: oldLevel } = oldRest
9444
+ const { level: newLevel } = newRest
9445
+
9446
+ const oldAllMaps: Record<string, any> = {}
9447
+ XEUtils.eachTree([dragRow], item => {
9448
+ oldAllMaps[getRowid($xeTable, item)] = item
9449
+ }, { children: mapChildrenField })
9450
+
9451
+ let isSelfToChildStatus = false
9452
+
9453
+ if (oldLevel && newLevel) {
9454
+ // 子到子
9455
+
9456
+ if (isPeerDrag && !isCrossDrag) {
9457
+ if (oldRest.row[parentField] !== newRest.row[parentField]) {
9458
+ // 非同级
9408
9459
  return errRest
9409
9460
  }
9410
- } else if (newLevel) {
9411
- // 根到子
9412
-
9461
+ } else {
9413
9462
  if (!isCrossDrag) {
9414
9463
  return errRest
9415
9464
  }
@@ -9425,95 +9474,171 @@ export default defineVxeComponent({
9425
9474
  return errRest
9426
9475
  }
9427
9476
  }
9428
- } else {
9429
- // 根到根
9430
9477
  }
9478
+ } else if (oldLevel) {
9479
+ // 子到根
9431
9480
 
9432
- const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9433
- key: rowField,
9434
- parentKey: parentField,
9435
- children: mapChildrenField
9436
- })
9481
+ if (!isCrossDrag) {
9482
+ return errRest
9483
+ }
9484
+ } else if (newLevel) {
9485
+ // 根到子
9437
9486
 
9438
- // 移出
9439
- const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
9440
- fullList.splice(otfIndex, 1)
9487
+ if (!isCrossDrag) {
9488
+ return errRest
9489
+ }
9490
+ if (oldAllMaps[newRowid]) {
9491
+ isSelfToChildStatus = true
9492
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9493
+ if (VxeUI.modal) {
9494
+ VxeUI.modal.message({
9495
+ status: 'error',
9496
+ content: getI18n('vxe.error.treeDragChild')
9497
+ })
9498
+ }
9499
+ return errRest
9500
+ }
9501
+ }
9502
+ } else {
9503
+ // 根到根
9504
+ }
9441
9505
 
9442
- // 插入
9443
- const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
9444
- const ntfIndex = ptfIndex + dragOffsetIndex
9445
- fullList.splice(ntfIndex, 0, dragRow)
9506
+ const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9507
+ key: rowField,
9508
+ parentKey: parentField,
9509
+ children: mapChildrenField
9510
+ })
9446
9511
 
9447
- // 改变层级
9448
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9449
- XEUtils.each(dragRow[childrenField], childRow => {
9450
- childRow[parentField] = dragRow[parentField]
9451
- })
9452
- }
9453
- dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField]
9512
+ // 移出
9513
+ const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
9514
+ fullList.splice(otfIndex, 1)
9515
+
9516
+ // 插入
9517
+ const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
9518
+ const ntfIndex = ptfIndex + dragOffsetIndex
9519
+ fullList.splice(ntfIndex, 0, dragRow)
9454
9520
 
9455
- internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
9456
- key: rowField,
9457
- parentKey: parentField,
9458
- children: childrenField,
9459
- mapChildren: mapChildrenField
9521
+ // 改变层级
9522
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9523
+ XEUtils.each(dragRow[childrenField], childRow => {
9524
+ childRow[parentField] = dragRow[parentField]
9460
9525
  })
9461
9526
  }
9527
+ dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField]
9528
+
9529
+ internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
9530
+ key: rowField,
9531
+ parentKey: parentField,
9532
+ children: childrenField,
9533
+ mapChildren: mapChildrenField
9534
+ })
9462
9535
  }
9463
- } else {
9464
- // 移出
9465
- oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
9466
- const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
9467
- afterFullData.splice(oafIndex, 1)
9468
- tableFullData.splice(otfIndex, 1)
9469
- // 插入
9470
- const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
9471
- const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
9472
- nafIndex = pafIndex + dragOffsetIndex
9473
- const ntfIndex = ptfIndex + dragOffsetIndex
9474
- afterFullData.splice(nafIndex, 0, dragRow)
9475
- tableFullData.splice(ntfIndex, 0, dragRow)
9476
9536
  }
9537
+ } else {
9538
+ // 移出
9539
+ oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
9540
+ const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
9541
+ afterFullData.splice(oafIndex, 1)
9542
+ tableFullData.splice(otfIndex, 1)
9543
+ // 插入
9544
+ const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
9545
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
9546
+ nafIndex = pafIndex + dragOffsetIndex
9547
+ const ntfIndex = ptfIndex + dragOffsetIndex
9548
+ afterFullData.splice(nafIndex, 0, dragRow)
9549
+ tableFullData.splice(ntfIndex, 0, dragRow)
9550
+ }
9477
9551
 
9478
- reactData.isDragRowMove = true
9479
- $xeTable.handleTableData(treeConfig && transform)
9480
- $xeTable.cacheRowMap(false)
9481
- updateScrollYStatus()
9482
- if (!(treeConfig && transform)) {
9483
- $xeTable.updateAfterDataIndex()
9484
- }
9485
- $xeTable.checkSelectionStatus()
9486
- if (reactData.scrollYLoad) {
9487
- $xeTable.updateScrollYSpace()
9488
- }
9552
+ $xeTable.handleTableData(treeConfig && transform)
9553
+ $xeTable.cacheRowMap(false)
9554
+ updateScrollYStatus()
9555
+ if (!(treeConfig && transform)) {
9556
+ $xeTable.updateAfterDataIndex()
9557
+ }
9558
+ $xeTable.checkSelectionStatus()
9559
+ if (reactData.scrollYLoad) {
9560
+ $xeTable.updateScrollYSpace()
9561
+ }
9489
9562
 
9490
- if (evnt) {
9491
- dispatchEvent('row-dragend', {
9492
- oldRow: dragRow,
9493
- newRow: prevDragRow,
9494
- dragRow,
9495
- dragPos: prevDragPos as any,
9496
- dragToChild: isDragToChildFlag,
9497
- offsetIndex: dragOffsetIndex,
9498
- _index: {
9499
- newIndex: nafIndex,
9500
- oldIndex: oafIndex
9563
+ if (evnt) {
9564
+ dispatchEvent('row-dragend', {
9565
+ oldRow: dragRow,
9566
+ newRow: prevDragRow,
9567
+ dragRow,
9568
+ dragPos: prevDragPos as any,
9569
+ dragToChild: isDragToChildFlag,
9570
+ offsetIndex: dragOffsetIndex,
9571
+ _index: {
9572
+ newIndex: nafIndex,
9573
+ oldIndex: oafIndex
9574
+ }
9575
+ }, evnt)
9576
+ }
9577
+
9578
+ return nextTick().then(() => {
9579
+ if (animation) {
9580
+ const { tableData } = reactData
9581
+ const dragRowRest = fullAllDataRowIdData[dragRowid]
9582
+ const _newRowIndex = dragRowRest._index
9583
+ const firstRow = tableData[0]
9584
+ const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)]
9585
+
9586
+ if (firstRowRest) {
9587
+ const _firstRowIndex = firstRowRest._index
9588
+ const _lastRowIndex = _firstRowIndex + tableData.length
9589
+
9590
+ let rsIndex = -1
9591
+ let reIndex = -1
9592
+ let offsetRate = 1
9593
+ if (_dragRowIndex < _firstRowIndex) {
9594
+ // 从上往下虚拟拖拽
9595
+ rsIndex = 0
9596
+ reIndex = _newRowIndex - _firstRowIndex
9597
+ } else if (_dragRowIndex > _lastRowIndex) {
9598
+ // 从下往上虚拟拖拽
9599
+ const $newRowIndex = dragRowRest.$index
9600
+ rsIndex = $newRowIndex + 1
9601
+ reIndex = tableData.length
9602
+ offsetRate = -1
9603
+ } else {
9604
+ if (_newRowIndex > _dragRowIndex) {
9605
+ // 从上往下拖拽
9606
+ rsIndex = _dragRowIndex - _firstRowIndex
9607
+ reIndex = rsIndex + _newRowIndex - _dragRowIndex
9608
+ } else {
9609
+ // 从下往上拖拽
9610
+ rsIndex = _newRowIndex - _firstRowIndex
9611
+ reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1
9612
+ offsetRate = -1
9613
+ }
9501
9614
  }
9502
- }, evnt)
9503
- }
9504
9615
 
9505
- return nextTick().then(() => {
9506
- $xeTable.updateCellAreas()
9507
- $xeTable.recalculate()
9508
- }).then(() => {
9509
- return {
9510
- status: true
9616
+ const dragRangeList = tableData.slice(rsIndex, reIndex)
9617
+ if (dragRangeList.length) {
9618
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(row => `.vxe-body--row[rowid="${getRowid($xeTable, row)}"]`).join(','))
9619
+ moveRowAnimateToTb(dtTrList, offsetRate * dragRowHeight)
9620
+ }
9511
9621
  }
9512
- })
9513
- }).catch(() => {
9514
- return errRest
9622
+
9623
+ const newTrList = el.querySelectorAll<HTMLElement>(`.vxe-body--row[rowid="${dragRowid}"]`)
9624
+ const newTrEl = newTrList[0]
9625
+ if (dragOffsetTop > -1 && newTrEl) {
9626
+ moveRowAnimateToTb(newTrList, dragOffsetTop - newTrEl.offsetTop)
9627
+ }
9628
+ }
9629
+
9630
+ updateRowOffsetTop()
9631
+ updateRowExpandStyle()
9632
+ $xeTable.updateCellAreas()
9633
+ $xeTable.recalculate()
9634
+ }).then(() => {
9635
+ return {
9636
+ status: true
9637
+ }
9515
9638
  })
9516
- }
9639
+ }).catch(() => {
9640
+ return errRest
9641
+ })
9517
9642
  }
9518
9643
  return Promise.resolve(errRest)
9519
9644
  },
@@ -9525,6 +9650,7 @@ export default defineVxeComponent({
9525
9650
  const { lazy } = treeOpts
9526
9651
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
9527
9652
  const { prevDragRow, prevDragPos } = internalData
9653
+ const el = refElem.value
9528
9654
  if (treeConfig && lazy && prevDragToChild) {
9529
9655
  // 懒加载
9530
9656
  const newRowid = getRowid($xeTable, prevDragRow)
@@ -9541,12 +9667,10 @@ export default defineVxeComponent({
9541
9667
  }
9542
9668
  hideDropTip()
9543
9669
  clearRowDropOrigin()
9670
+ clearRowAnimate(el)
9544
9671
  internalData.prevDragToChild = false
9545
9672
  reactData.dragRow = null
9546
9673
  reactData.dragCol = null
9547
- setTimeout(() => {
9548
- reactData.isDragRowMove = false
9549
- }, 500)
9550
9674
  },
9551
9675
  handleRowDragDragoverEvent (evnt) {
9552
9676
  const { treeConfig } = props
@@ -9629,7 +9753,7 @@ export default defineVxeComponent({
9629
9753
  },
9630
9754
  handleColDragSwapColumn () {
9631
9755
  handleUpdateColumn()
9632
- parseColumns(false).then(() => {
9756
+ return parseColumns(false).then(() => {
9633
9757
  $xeTable.updateCellAreas()
9634
9758
  $xeTable.saveCustomStore('update:sort')
9635
9759
  })
@@ -9637,79 +9761,83 @@ export default defineVxeComponent({
9637
9761
  handleColDragSwapEvent (evnt, isSyncColumn, dragCol, prevDragCol, prevDragPos, prevDragToChild) {
9638
9762
  const { mouseConfig } = props
9639
9763
  const columnDragOpts = computeColumnDragOpts.value
9640
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
9641
- const { collectColumn } = internalData
9764
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
9765
+ const { collectColumn, fullColumnIdData } = internalData
9766
+ const el = refElem.value
9642
9767
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
9643
9768
  const errRest = {
9644
9769
  status: false
9645
9770
  }
9646
- if (prevDragCol && dragCol) {
9647
- // 判断是否有拖动
9648
- if (prevDragCol !== dragCol) {
9649
- const dragColumn = dragCol
9650
- const newColumn = prevDragCol
9651
- const dragParams = {
9652
- oldColumn: dragColumn,
9653
- newColumn,
9654
- dragColumn,
9655
- dragPos: prevDragPos as 'left' | 'right',
9656
- dragToChild: !!prevDragToChild,
9657
- offsetIndex: dragOffsetIndex as 0 | 1
9658
- }
9659
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9660
- return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
9661
- if (!status) {
9662
- return errRest
9663
- }
9664
-
9665
- let oafIndex = -1
9666
- let nafIndex = -1
9771
+ if (!(el && prevDragCol && dragCol)) {
9772
+ return Promise.resolve(errRest)
9773
+ }
9774
+ // 判断是否有拖动
9775
+ if (prevDragCol !== dragCol) {
9776
+ const dragColumn = dragCol
9777
+ const newColumn = prevDragCol
9778
+ const dragParams = {
9779
+ oldColumn: dragColumn,
9780
+ newColumn,
9781
+ dragColumn,
9782
+ dragPos: prevDragPos as 'left' | 'right',
9783
+ dragToChild: !!prevDragToChild,
9784
+ offsetIndex: dragOffsetIndex as 0 | 1
9785
+ }
9786
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9787
+ return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
9788
+ if (!status) {
9789
+ return errRest
9790
+ }
9667
9791
 
9668
- const oldAllMaps: Record<string, any> = {}
9792
+ let dragTargetColumn: VxeTableDefines.ColumnInfo | null = null
9793
+ const dragAllTargetCols: VxeTableDefines.ColumnInfo[] = []
9794
+ let dragColWidth = 0
9795
+ if (animation) {
9669
9796
  XEUtils.eachTree([dragColumn], column => {
9670
- oldAllMaps[column.id] = column
9797
+ if (!dragTargetColumn && (!column.children || !column.children.length)) {
9798
+ dragTargetColumn = column
9799
+ dragColWidth += column.renderWidth
9800
+ }
9801
+ dragAllTargetCols.push(column)
9671
9802
  })
9803
+ }
9804
+ if (!dragTargetColumn) {
9805
+ dragTargetColumn = dragColumn
9806
+ }
9807
+ const dragColRest = fullColumnIdData[dragTargetColumn.id] || {}
9808
+ const _dragColIndex = dragColRest._index
9672
9809
 
9673
- let isSelfToChildStatus = false
9810
+ let dragOffsetLeft = -1
9811
+ if (animation) {
9812
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-table--column[colid="${dragTargetColumn.id}"]`)
9813
+ if (oldTrEl) {
9814
+ dragOffsetLeft = oldTrEl.offsetLeft
9815
+ }
9816
+ }
9674
9817
 
9675
- if (dragColumn.parentId && newColumn.parentId) {
9676
- // 子到子
9818
+ let oafIndex = -1
9819
+ let nafIndex = -1
9677
9820
 
9678
- if (isPeerDrag && !isCrossDrag) {
9679
- if (dragColumn.parentId !== newColumn.parentId) {
9680
- // 非同级
9681
- return errRest
9682
- }
9683
- } else {
9684
- if (!isCrossDrag) {
9685
- return errRest
9686
- }
9821
+ const oldAllMaps: Record<string, any> = {}
9822
+ XEUtils.eachTree([dragColumn], column => {
9823
+ oldAllMaps[column.id] = column
9824
+ })
9687
9825
 
9688
- if (oldAllMaps[newColumn.id]) {
9689
- isSelfToChildStatus = true
9690
- if (!(isCrossDrag && isSelfToChildDrag)) {
9691
- if (VxeUI.modal) {
9692
- VxeUI.modal.message({
9693
- status: 'error',
9694
- content: getI18n('vxe.error.treeDragChild')
9695
- })
9696
- }
9697
- return errRest
9698
- }
9699
- }
9700
- }
9701
- } else if (dragColumn.parentId) {
9702
- // 子到根
9826
+ let isSelfToChildStatus = false
9703
9827
 
9704
- if (!isCrossDrag) {
9828
+ if (dragColumn.parentId && newColumn.parentId) {
9829
+ // 子到子
9830
+
9831
+ if (isPeerDrag && !isCrossDrag) {
9832
+ if (dragColumn.parentId !== newColumn.parentId) {
9833
+ // 非同级
9705
9834
  return errRest
9706
9835
  }
9707
- } else if (newColumn.parentId) {
9708
- // 根到子
9709
-
9836
+ } else {
9710
9837
  if (!isCrossDrag) {
9711
9838
  return errRest
9712
9839
  }
9840
+
9713
9841
  if (oldAllMaps[newColumn.id]) {
9714
9842
  isSelfToChildStatus = true
9715
9843
  if (!(isCrossDrag && isSelfToChildDrag)) {
@@ -9722,111 +9850,214 @@ export default defineVxeComponent({
9722
9850
  return errRest
9723
9851
  }
9724
9852
  }
9725
- } else {
9726
- // 根到根
9727
9853
  }
9854
+ } else if (dragColumn.parentId) {
9855
+ // 子到根
9728
9856
 
9729
- const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
9857
+ if (!isCrossDrag) {
9858
+ return errRest
9859
+ }
9860
+ } else if (newColumn.parentId) {
9861
+ // 根到子
9730
9862
 
9731
- // 改变层级
9732
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9733
- if (oldewMatchRest) {
9734
- const { items: oCols, index: oIndex } = oldewMatchRest
9735
- const childList = dragColumn.children || []
9736
- childList.forEach(column => {
9737
- column.parentId = dragColumn.parentId
9738
- })
9739
- oCols.splice(oIndex, 1, ...childList)
9740
- dragColumn.children = []
9741
- }
9742
- } else {
9743
- if (oldewMatchRest) {
9744
- const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
9745
- oCols.splice(oIndex, 1)
9746
- if (!oParent) {
9747
- oafIndex = oIndex
9863
+ if (!isCrossDrag) {
9864
+ return errRest
9865
+ }
9866
+ if (oldAllMaps[newColumn.id]) {
9867
+ isSelfToChildStatus = true
9868
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9869
+ if (VxeUI.modal) {
9870
+ VxeUI.modal.message({
9871
+ status: 'error',
9872
+ content: getI18n('vxe.error.treeDragChild')
9873
+ })
9748
9874
  }
9875
+ return errRest
9749
9876
  }
9750
9877
  }
9878
+ } else {
9879
+ // 根到根
9880
+ }
9751
9881
 
9752
- const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
9753
- if (newMatchRest) {
9754
- const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
9755
- // 转子级
9756
- if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
9757
- dragColumn.parentId = newColumn.id
9758
- newColumn.children = (newColumn.children || []).concat([dragColumn])
9759
- } else {
9760
- dragColumn.parentId = newColumn.parentId
9761
- nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
9762
- }
9763
- if (!nParent) {
9764
- nafIndex = nIndex
9882
+ const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
9883
+
9884
+ // 改变层级
9885
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9886
+ if (oldewMatchRest) {
9887
+ const { items: oCols, index: oIndex } = oldewMatchRest
9888
+ const childList = dragColumn.children || []
9889
+ childList.forEach(column => {
9890
+ column.parentId = dragColumn.parentId
9891
+ })
9892
+ oCols.splice(oIndex, 1, ...childList)
9893
+ dragColumn.children = []
9894
+ }
9895
+ } else {
9896
+ if (oldewMatchRest) {
9897
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
9898
+ oCols.splice(oIndex, 1)
9899
+ if (!oParent) {
9900
+ oafIndex = oIndex
9765
9901
  }
9766
9902
  }
9903
+ }
9767
9904
 
9768
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9769
- if (!parentColumn) {
9770
- const sortIndex = index + 1
9771
- column.renderSortNumber = sortIndex
9772
- }
9773
- })
9905
+ const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
9906
+ if (newMatchRest) {
9907
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
9908
+ // 转子级
9909
+ if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
9910
+ dragColumn.parentId = newColumn.id
9911
+ newColumn.children = (newColumn.children || []).concat([dragColumn])
9912
+ } else {
9913
+ dragColumn.parentId = newColumn.parentId
9914
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
9915
+ }
9916
+ if (!nParent) {
9917
+ nafIndex = nIndex
9918
+ }
9919
+ }
9774
9920
 
9775
- reactData.isDragColMove = true
9776
- if (mouseConfig) {
9777
- if ($xeTable.clearSelected) {
9778
- $xeTable.clearSelected()
9779
- }
9780
- if ($xeTable.clearCellAreas) {
9781
- $xeTable.clearCellAreas()
9782
- $xeTable.clearCopyCellArea()
9783
- }
9921
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9922
+ if (!parentColumn) {
9923
+ const sortIndex = index + 1
9924
+ column.renderSortNumber = sortIndex
9784
9925
  }
9926
+ })
9785
9927
 
9786
- if (evnt) {
9787
- dispatchEvent('column-dragend', {
9788
- oldColumn: dragColumn,
9789
- newColumn,
9790
- dragColumn,
9791
- dragPos: prevDragPos,
9792
- dragToChild: isDragToChildFlag,
9793
- offsetIndex: dragOffsetIndex,
9794
- _index: {
9795
- newIndex: nafIndex,
9796
- oldIndex: oafIndex
9797
- }
9798
- }, evnt)
9928
+ if (mouseConfig) {
9929
+ if ($xeTable.clearSelected) {
9930
+ $xeTable.clearSelected()
9931
+ }
9932
+ if ($xeTable.clearCellAreas) {
9933
+ $xeTable.clearCellAreas()
9934
+ $xeTable.clearCopyCellArea()
9799
9935
  }
9936
+ }
9937
+
9938
+ if (evnt) {
9939
+ dispatchEvent('column-dragend', {
9940
+ oldColumn: dragColumn,
9941
+ newColumn,
9942
+ dragColumn,
9943
+ dragPos: prevDragPos,
9944
+ dragToChild: isDragToChildFlag,
9945
+ offsetIndex: dragOffsetIndex,
9946
+ _index: {
9947
+ newIndex: nafIndex,
9948
+ oldIndex: oafIndex
9949
+ }
9950
+ }, evnt)
9951
+ }
9800
9952
 
9953
+ return nextTick().then(() => {
9801
9954
  if (isSyncColumn) {
9802
- $xeTable.handleColDragSwapColumn()
9955
+ return $xeTable.handleColDragSwapColumn()
9956
+ }
9957
+ }).then(() => {
9958
+ if (animation) {
9959
+ const { tableColumn } = reactData
9960
+ const { visibleColumn, fullColumnIdData } = internalData
9961
+ let dragNewColumn: VxeTableDefines.ColumnInfo | null = null
9962
+ const dragNewColMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
9963
+ XEUtils.eachTree([dragColumn], column => {
9964
+ if (!dragNewColumn && (!column.children || !column.children.length)) {
9965
+ dragNewColumn = column
9966
+ }
9967
+ dragNewColMaps[column.id] = column
9968
+ })
9969
+ if (!dragNewColumn) {
9970
+ dragNewColumn = dragColumn
9971
+ }
9972
+
9973
+ if (dragColWidth && dragAllTargetCols.length) {
9974
+ const _newColIndex = XEUtils.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id)
9975
+ const firstCol = tableColumn[0]
9976
+ const firstColRest = fullColumnIdData[firstCol.id]
9977
+
9978
+ if (firstColRest) {
9979
+ const _firstColIndex = firstColRest._index
9980
+ const _lastColIndex = _firstColIndex + tableColumn.length
9981
+ let csIndex = -1
9982
+ let ceIndex = -1
9983
+ let offsetRate = 1
9984
+ if (_dragColIndex < _firstColIndex) {
9985
+ // 从左往右虚拟拖拽
9986
+ csIndex = 0
9987
+ ceIndex = _newColIndex - _firstColIndex
9988
+ } else if (_dragColIndex > _lastColIndex) {
9989
+ // 从右往左虚拟拖拽
9990
+ const $newRowIndex = dragColRest.$index
9991
+ csIndex = $newRowIndex + 1
9992
+ ceIndex = tableColumn.length
9993
+ offsetRate = -1
9994
+ } else {
9995
+ if (_newColIndex > _dragColIndex) {
9996
+ // 从左往右拖拽
9997
+ csIndex = _dragColIndex - _firstColIndex
9998
+ ceIndex = csIndex + _newColIndex - _dragColIndex
9999
+ } else {
10000
+ // 从右往左拖拽
10001
+ csIndex = _newColIndex - _firstColIndex + 1
10002
+ ceIndex = csIndex + _dragColIndex - _newColIndex
10003
+ offsetRate = -1
10004
+ }
10005
+ }
10006
+
10007
+ const dragRangeList: VxeTableDefines.ColumnInfo[] = []
10008
+ const dragRangeMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
10009
+ for (let i = csIndex; i < ceIndex; i++) {
10010
+ const column = tableColumn[i]
10011
+ if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
10012
+ dragRangeMaps[column.id] = column
10013
+ dragRangeList.push(column)
10014
+ }
10015
+ }
10016
+ XEUtils.eachTree([newColumn], column => {
10017
+ if (!dragRangeMaps[column.id]) {
10018
+ dragRangeMaps[column.id] = column
10019
+ dragRangeList.push(column)
10020
+ }
10021
+ })
10022
+ if (dragRangeList.length) {
10023
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
10024
+ moveColAnimateToLr(dtTrList, offsetRate * dragColWidth)
10025
+ }
10026
+ }
10027
+
10028
+ const newTrList = el.querySelectorAll<HTMLElement>(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
10029
+ const newTdEl = newTrList[0]
10030
+ if (dragOffsetLeft > -1 && newTdEl) {
10031
+ moveColAnimateToLr(newTrList, dragOffsetLeft - newTdEl.offsetLeft)
10032
+ }
10033
+ }
9803
10034
  }
9804
10035
 
10036
+ updateColumnOffsetLeft()
10037
+ loadScrollXData()
10038
+ $xeTable.updateCellAreas()
10039
+
9805
10040
  return {
9806
10041
  status: true
9807
10042
  }
9808
- }).catch(() => {
9809
- return errRest
9810
10043
  })
9811
- }
10044
+ }).catch(() => {
10045
+ return errRest
10046
+ })
9812
10047
  }
9813
10048
  return Promise.resolve(errRest)
9814
10049
  },
9815
10050
  handleHeaderCellDragDragendEvent (evnt) {
9816
10051
  const { dragCol } = reactData
9817
10052
  const { prevDragCol, prevDragPos, prevDragToChild } = internalData
10053
+ const el = refElem.value
9818
10054
  $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild)
9819
10055
  hideDropTip()
9820
10056
  clearColDropOrigin()
10057
+ clearColAnimate(el)
9821
10058
  internalData.prevDragToChild = false
9822
10059
  reactData.dragRow = null
9823
10060
  reactData.dragCol = null
9824
- setTimeout(() => {
9825
- reactData.isDragColMove = false
9826
- $xeTable.recalculate().then(() => {
9827
- loadScrollXData()
9828
- })
9829
- }, 500)
9830
10061
  },
9831
10062
  handleHeaderCellDragDragoverEvent (evnt) {
9832
10063
  const { dragCol } = reactData
@@ -9900,7 +10131,6 @@ export default defineVxeComponent({
9900
10131
  const { column } = params
9901
10132
  const dragEl = evnt.currentTarget as HTMLElement
9902
10133
  const thEl = trigger === 'cell' ? dragEl : dragEl.parentElement?.parentElement as HTMLElement
9903
- reactData.isDragColMove = false
9904
10134
  clearColDropOrigin()
9905
10135
  if (dragStartMethod && !dragStartMethod(params)) {
9906
10136
  thEl.draggable = false
@@ -9921,7 +10151,6 @@ export default defineVxeComponent({
9921
10151
  hideDropTip()
9922
10152
  reactData.dragRow = null
9923
10153
  reactData.dragCol = null
9924
- reactData.isDragColMove = false
9925
10154
  },
9926
10155
  handleScrollEvent (evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
9927
10156
  const { highlightHoverRow } = props
@@ -9986,8 +10215,6 @@ export default defineVxeComponent({
9986
10215
  }
9987
10216
  internalData.lastScrollTop = scrollTop
9988
10217
  }
9989
- reactData.isDragColMove = false
9990
- reactData.isDragRowMove = false
9991
10218
  reactData.lastScrollTime = Date.now()
9992
10219
  const evntParams = {
9993
10220
  scrollTop,
@@ -11494,12 +11721,7 @@ export default defineVxeComponent({
11494
11721
  mergeCellFlag.value++
11495
11722
  })
11496
11723
  watch(mergeCellFlag, () => {
11497
- tableMethods.clearMergeCells()
11498
- nextTick(() => {
11499
- if (props.mergeCells) {
11500
- tableMethods.setMergeCells(props.mergeCells)
11501
- }
11502
- })
11724
+ handleUpdateMergeBodyCells(props.mergeCells || [])
11503
11725
  })
11504
11726
 
11505
11727
  const mergeFooterItemFlag = ref(0)
@@ -11510,12 +11732,7 @@ export default defineVxeComponent({
11510
11732
  mergeFooterItemFlag.value++
11511
11733
  })
11512
11734
  watch(mergeFooterItemFlag, () => {
11513
- tableMethods.clearMergeFooterItems()
11514
- nextTick(() => {
11515
- if (props.mergeFooterItems) {
11516
- tableMethods.setMergeFooterItems(props.mergeFooterItems)
11517
- }
11518
- })
11735
+ handleUpdateMergeFooterCells(props.mergeFooterItems || [])
11519
11736
  })
11520
11737
 
11521
11738
  watch(computeRowGroupFields, (val) => {
@@ -11823,7 +12040,7 @@ export default defineVxeComponent({
11823
12040
  globalEvents.on($xeTable, 'keydown', handleGlobalKeydownEvent)
11824
12041
  globalEvents.on($xeTable, 'resize', handleGlobalResizeEvent)
11825
12042
  globalEvents.on($xeTable, 'contextmenu', $xeTable.handleGlobalContextmenuEvent)
11826
- tablePrivateMethods.preventEvent(null, 'mounted', { $table: $xeTable })
12043
+ $xeTable.preventEvent(null, 'mounted', { $table: $xeTable })
11827
12044
  })
11828
12045
 
11829
12046
  onBeforeUnmount(() => {
@@ -11860,6 +12077,7 @@ export default defineVxeComponent({
11860
12077
  nextTick(() => {
11861
12078
  if (props.loading) {
11862
12079
  if (!VxeUILoadingComponent && !slots.loading) {
12080
+ errLog('vxe.error.errProp', ['loading=true', 'loading=false | <template #loading>...</template>'])
11863
12081
  errLog('vxe.error.reqComp', ['vxe-loading'])
11864
12082
  }
11865
12083
  }
@@ -11868,6 +12086,24 @@ export default defineVxeComponent({
11868
12086
  (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
11869
12087
  props.tooltipConfig || props.editRules) {
11870
12088
  if (!VxeUITooltipComponent) {
12089
+ if (props.showOverflow === true) {
12090
+ errLog('vxe.error.errProp', ['show-overflow=true', 'show-overflow=title'])
12091
+ }
12092
+ if (props.showOverflow === 'tooltip') {
12093
+ errLog('vxe.error.errProp', ['show-overflow=tooltip', 'show-overflow=title'])
12094
+ }
12095
+ if (props.showHeaderOverflow === true) {
12096
+ errLog('vxe.error.errProp', ['show-header-overflow=true', 'show-header-overflow=title'])
12097
+ }
12098
+ if (props.showHeaderOverflow === 'tooltip') {
12099
+ errLog('vxe.error.errProp', ['show-header-overflow=tooltip', 'show-header-overflow=title'])
12100
+ }
12101
+ if (props.showFooterOverflow === true) {
12102
+ errLog('vxe.error.errProp', ['show-footer-overflow=true', 'show-footer-overflow=title'])
12103
+ }
12104
+ if (props.showFooterOverflow === 'tooltip') {
12105
+ errLog('vxe.error.errProp', ['show-footer-overflow=tooltip', 'show-footer-overflow=title'])
12106
+ }
11871
12107
  errLog('vxe.error.reqComp', ['vxe-tooltip'])
11872
12108
  }
11873
12109
  }