vxe-table 4.14.0-beta.1 → 4.14.0-beta.3

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 (77) hide show
  1. package/README.en.md +2 -1
  2. package/README.ja-JP.md +2 -1
  3. package/README.md +4 -2
  4. package/README.zh-TW.md +2 -1
  5. package/es/grid/src/grid.js +28 -19
  6. package/es/index.css +1 -1
  7. package/es/index.min.css +1 -1
  8. package/es/style.css +1 -1
  9. package/es/style.min.css +1 -1
  10. package/es/table/module/custom/hook.js +0 -4
  11. package/es/table/module/custom/panel.js +0 -1
  12. package/es/table/src/anime.js +46 -0
  13. package/es/table/src/body.js +9 -24
  14. package/es/table/src/columnInfo.js +5 -0
  15. package/es/table/src/footer.js +5 -22
  16. package/es/table/src/header.js +4 -21
  17. package/es/table/src/table.js +565 -357
  18. package/es/table/src/util.js +1 -1
  19. package/es/table/style.css +8 -8
  20. package/es/table/style.min.css +1 -1
  21. package/es/ui/index.js +2 -1
  22. package/es/ui/src/log.js +1 -1
  23. package/es/vxe-table/style.css +8 -8
  24. package/es/vxe-table/style.min.css +1 -1
  25. package/lib/grid/src/grid.js +33 -21
  26. package/lib/grid/src/grid.min.js +1 -1
  27. package/lib/index.css +1 -1
  28. package/lib/index.min.css +1 -1
  29. package/lib/index.umd.js +141 -127
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/style.css +1 -1
  32. package/lib/style.min.css +1 -1
  33. package/lib/table/module/custom/hook.js +0 -4
  34. package/lib/table/module/custom/hook.min.js +1 -1
  35. package/lib/table/module/custom/panel.js +0 -1
  36. package/lib/table/module/custom/panel.min.js +1 -1
  37. package/lib/table/src/anime.js +56 -0
  38. package/lib/table/src/anime.min.js +1 -0
  39. package/lib/table/src/body.js +3 -26
  40. package/lib/table/src/body.min.js +1 -1
  41. package/lib/table/src/columnInfo.js +5 -0
  42. package/lib/table/src/columnInfo.min.js +1 -1
  43. package/lib/table/src/footer.js +2 -20
  44. package/lib/table/src/footer.min.js +1 -1
  45. package/lib/table/src/header.js +2 -19
  46. package/lib/table/src/header.min.js +1 -1
  47. package/lib/table/src/table.js +46 -33
  48. package/lib/table/src/table.min.js +1 -1
  49. package/lib/table/src/util.js +2 -2
  50. package/lib/table/src/util.min.js +1 -1
  51. package/lib/table/style/style.css +8 -8
  52. package/lib/table/style/style.min.css +1 -1
  53. package/lib/ui/index.js +2 -1
  54. package/lib/ui/index.min.js +1 -1
  55. package/lib/ui/src/log.js +1 -1
  56. package/lib/ui/src/log.min.js +1 -1
  57. package/lib/vxe-table/style/style.css +8 -8
  58. package/lib/vxe-table/style/style.min.css +1 -1
  59. package/package.json +1 -1
  60. package/packages/grid/src/grid.ts +30 -20
  61. package/packages/table/module/custom/hook.ts +0 -4
  62. package/packages/table/module/custom/panel.ts +0 -1
  63. package/packages/table/src/anime.ts +52 -0
  64. package/packages/table/src/body.ts +15 -38
  65. package/packages/table/src/columnInfo.ts +5 -0
  66. package/packages/table/src/footer.ts +5 -22
  67. package/packages/table/src/header.ts +4 -21
  68. package/packages/table/src/table.ts +573 -360
  69. package/packages/table/src/util.ts +1 -1
  70. package/packages/ui/index.ts +1 -0
  71. package/styles/components/table.scss +9 -9
  72. /package/es/{iconfont.1750910518778.ttf → iconfont.1751247415649.ttf} +0 -0
  73. /package/es/{iconfont.1750910518778.woff → iconfont.1751247415649.woff} +0 -0
  74. /package/es/{iconfont.1750910518778.woff2 → iconfont.1751247415649.woff2} +0 -0
  75. /package/lib/{iconfont.1750910518778.ttf → iconfont.1751247415649.ttf} +0 -0
  76. /package/lib/{iconfont.1750910518778.woff → iconfont.1751247415649.woff} +0 -0
  77. /package/lib/{iconfont.1750910518778.woff2 → iconfont.1751247415649.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'
@@ -570,14 +571,14 @@ export default defineVxeComponent({
570
571
  const computeHeaderCellOpts = computed(() => {
571
572
  const headerCellOpts = Object.assign({}, getConfig().table.headerCellConfig, props.headerCellConfig)
572
573
  const cellOpts = computeCellOpts.value
573
- headerCellOpts.height = XEUtils.toNumber(getCellHeight(headerCellOpts.height || cellOpts.height))
574
+ headerCellOpts.height = XEUtils.toNumber(getCalcHeight(headerCellOpts.height || cellOpts.height))
574
575
  return headerCellOpts
575
576
  })
576
577
 
577
578
  const computeFooterCellOpts = computed(() => {
578
579
  const footerCellOpts = Object.assign({}, getConfig().table.footerCellConfig, props.footerCellConfig)
579
580
  const cellOpts = computeCellOpts.value
580
- footerCellOpts.height = XEUtils.toNumber(getCellHeight(footerCellOpts.height || cellOpts.height))
581
+ footerCellOpts.height = XEUtils.toNumber(getCalcHeight(footerCellOpts.height || cellOpts.height))
581
582
  return footerCellOpts
582
583
  })
583
584
 
@@ -772,10 +773,10 @@ export default defineVxeComponent({
772
773
  })
773
774
 
774
775
  const computeTableRowExpandedList = computed(() => {
775
- const { rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData
776
+ const { tableData, rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData
776
777
  const { visibleDataRowIdData, rowExpandedMaps } = internalData
777
778
  const expandList: any[] = []
778
- if (expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
779
+ if (tableData.length && expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
779
780
  XEUtils.each(rowExpandedMaps, (row, rowid) => {
780
781
  if (visibleDataRowIdData[rowid]) {
781
782
  expandList.push(row)
@@ -3113,7 +3114,7 @@ export default defineVxeComponent({
3113
3114
  }
3114
3115
  }
3115
3116
 
3116
- const handleRecalculateLayout = (reFull: boolean) => {
3117
+ const handleRecalculateStyle = (reFull: boolean, reWidth: boolean, reHeight: boolean) => {
3117
3118
  const el = refElem.value
3118
3119
  internalData.rceRunTime = Date.now()
3119
3120
  if (!el || !el.clientWidth) {
@@ -3127,19 +3128,28 @@ export default defineVxeComponent({
3127
3128
  calcVarRowHeightConfig('small', smallEl)
3128
3129
  calcVarRowHeightConfig('mini', miniEl)
3129
3130
  }
3130
- calcCellWidth()
3131
- autoCellWidth()
3131
+ if (reWidth) {
3132
+ calcCellWidth()
3133
+ }
3134
+ if (reFull) {
3135
+ autoCellWidth()
3136
+ }
3132
3137
  calcScrollbar()
3133
3138
  updateStyle()
3134
3139
  updateRowExpandStyle()
3135
3140
  return computeScrollLoad().then(() => {
3136
3141
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
3137
- calcCellWidth()
3142
+ if (reWidth) {
3143
+ calcCellWidth()
3144
+ }
3138
3145
  if (reFull) {
3139
3146
  autoCellWidth()
3140
3147
  }
3141
- calcScrollbar()
3148
+ if (reHeight) {
3149
+ calcCellHeight()
3150
+ }
3142
3151
  updateStyle()
3152
+ calcScrollbar()
3143
3153
  if (reFull) {
3144
3154
  updateRowOffsetTop()
3145
3155
  }
@@ -3150,6 +3160,39 @@ export default defineVxeComponent({
3150
3160
  })
3151
3161
  }
3152
3162
 
3163
+ const handleLazyRecalculate = (reFull: boolean, reWidth: boolean, reHeight: boolean) => {
3164
+ return new Promise<void>(resolve => {
3165
+ const { rceTimeout, rceRunTime } = internalData
3166
+ const resizeOpts = computeResizeOpts.value
3167
+ const refreshDelay = resizeOpts.refreshDelay || 20
3168
+ const el = refElem.value
3169
+ if (el && el.clientWidth) {
3170
+ autoCellWidth()
3171
+ updateRowExpandStyle()
3172
+ }
3173
+ if (rceTimeout) {
3174
+ clearTimeout(rceTimeout)
3175
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3176
+ resolve(
3177
+ handleRecalculateStyle(!!reFull, reWidth, reHeight)
3178
+ )
3179
+ } else {
3180
+ nextTick(() => {
3181
+ resolve()
3182
+ })
3183
+ }
3184
+ } else {
3185
+ resolve(
3186
+ handleRecalculateStyle(!!reFull, reWidth, reHeight)
3187
+ )
3188
+ }
3189
+ internalData.rceTimeout = setTimeout(() => {
3190
+ internalData.rceTimeout = undefined
3191
+ handleRecalculateStyle(!!reFull, reWidth, reHeight)
3192
+ }, refreshDelay)
3193
+ })
3194
+ }
3195
+
3153
3196
  const handleUpdateAggValues = () => {
3154
3197
  const { visibleColumn } = internalData
3155
3198
  const aggCols: VxeTableDefines.ColumnInfo[] = []
@@ -3365,8 +3408,6 @@ export default defineVxeComponent({
3365
3408
  internalData.removeRowMaps = {}
3366
3409
  reactData.removeRowFlag++
3367
3410
  const sYLoad = updateScrollYStatus(fullData)
3368
- reactData.isDragColMove = false
3369
- reactData.isDragRowMove = false
3370
3411
  // 全量数据
3371
3412
  internalData.tableFullData = fullData
3372
3413
  internalData.tableFullTreeData = isRGroup ? [] : treeData
@@ -3430,11 +3471,11 @@ export default defineVxeComponent({
3430
3471
  $xeTable.checkSelectionStatus()
3431
3472
  return new Promise<void>(resolve => {
3432
3473
  nextTick()
3433
- .then(() => handleRecalculateLayout(false))
3474
+ .then(() => handleRecalculateStyle(false, false, false))
3434
3475
  .then(() => {
3435
3476
  calcCellHeight()
3436
3477
  updateRowOffsetTop()
3437
- return handleRecalculateLayout(false)
3478
+ return handleRecalculateStyle(false, false, false)
3438
3479
  })
3439
3480
  .then(() => {
3440
3481
  let targetScrollLeft = lastScrollLeft
@@ -3449,7 +3490,7 @@ export default defineVxeComponent({
3449
3490
  targetScrollTop = 0
3450
3491
  }
3451
3492
  reactData.isRowLoading = false
3452
- handleRecalculateLayout(false)
3493
+ handleRecalculateStyle(false, false, false)
3453
3494
  // 是否变更虚拟滚动
3454
3495
  if (oldScrollYLoad === sYLoad) {
3455
3496
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
@@ -3687,7 +3728,6 @@ export default defineVxeComponent({
3687
3728
  const tableFullColumn = getColumnList(collectColumn)
3688
3729
  internalData.tableFullColumn = tableFullColumn
3689
3730
  reactData.isColLoading = true
3690
- reactData.isDragColMove = false
3691
3731
  initColumnSort()
3692
3732
  return Promise.resolve(
3693
3733
  restoreCustomStorage()
@@ -3825,7 +3865,7 @@ export default defineVxeComponent({
3825
3865
  updateAfterDataIndex()
3826
3866
  return nextTick()
3827
3867
  }).then(() => {
3828
- return $xeTable.recalculate(true)
3868
+ return handleLazyRecalculate(true, true, true)
3829
3869
  }).then(() => {
3830
3870
  setTimeout(() => {
3831
3871
  $xeTable.updateCellAreas()
@@ -3898,7 +3938,7 @@ export default defineVxeComponent({
3898
3938
  updateAfterDataIndex()
3899
3939
  return nextTick()
3900
3940
  }).then(() => {
3901
- return $xeTable.recalculate(true)
3941
+ return handleLazyRecalculate(true, true, true)
3902
3942
  }).then(() => {
3903
3943
  setTimeout(() => {
3904
3944
  $xeTable.updateCellAreas()
@@ -4261,23 +4301,23 @@ export default defineVxeComponent({
4261
4301
  */
4262
4302
  updateData () {
4263
4303
  const { scrollXLoad, scrollYLoad } = reactData
4264
- return tablePrivateMethods.handleTableData(true).then(() => {
4265
- tableMethods.updateFooter()
4304
+ return $xeTable.handleTableData(true).then(() => {
4305
+ $xeTable.updateFooter()
4266
4306
  if (scrollXLoad || scrollYLoad) {
4267
4307
  if (scrollXLoad) {
4268
- tablePrivateMethods.updateScrollXSpace()
4308
+ $xeTable.updateScrollXSpace()
4269
4309
  }
4270
4310
  if (scrollYLoad) {
4271
- tablePrivateMethods.updateScrollYSpace()
4311
+ $xeTable.updateScrollYSpace()
4272
4312
  }
4273
- return tableMethods.refreshScroll()
4313
+ return $xeTable.refreshScroll()
4274
4314
  }
4275
4315
  }).then(() => {
4276
- tableMethods.updateCellAreas()
4277
- return tableMethods.recalculate(true)
4316
+ $xeTable.updateCellAreas()
4317
+ return handleLazyRecalculate(true, true, true)
4278
4318
  }).then(() => {
4279
4319
  // 存在滚动行为未结束情况
4280
- setTimeout(() => $xeTable.recalculate(), 50)
4320
+ setTimeout(() => handleLazyRecalculate(false, true, true), 50)
4281
4321
  })
4282
4322
  },
4283
4323
  /**
@@ -4292,7 +4332,7 @@ export default defineVxeComponent({
4292
4332
  if (!initStatus) {
4293
4333
  handleLoadDefaults()
4294
4334
  }
4295
- return tableMethods.recalculate()
4335
+ return handleLazyRecalculate(false, true, true)
4296
4336
  })
4297
4337
  },
4298
4338
  /**
@@ -4300,14 +4340,14 @@ export default defineVxeComponent({
4300
4340
  * @param {Array} datas 数据
4301
4341
  */
4302
4342
  reloadData (datas) {
4303
- return tableMethods.clearAll()
4343
+ return $xeTable.clearAll()
4304
4344
  .then(() => {
4305
4345
  internalData.inited = true
4306
4346
  internalData.initStatus = true
4307
4347
  return loadTableData(datas, true)
4308
4348
  }).then(() => {
4309
4349
  handleLoadDefaults()
4310
- return tableMethods.recalculate()
4350
+ return handleLazyRecalculate(false, true, true)
4311
4351
  })
4312
4352
  },
4313
4353
  /**
@@ -4610,7 +4650,7 @@ export default defineVxeComponent({
4610
4650
  }
4611
4651
  return nextTick().then(() => {
4612
4652
  $xeTable.updateCellAreas()
4613
- return $xeTable.recalculate()
4653
+ return handleLazyRecalculate(false, true, true)
4614
4654
  })
4615
4655
  }
4616
4656
  return $xeTable.reloadData(tableSourceData)
@@ -5215,9 +5255,9 @@ export default defineVxeComponent({
5215
5255
  handleUpdateColumn()
5216
5256
  }
5217
5257
  return parseColumns(true).then(() => {
5218
- return tableMethods.refreshScroll()
5258
+ return $xeTable.refreshScroll()
5219
5259
  }).then(() => {
5220
- return tableMethods.recalculate()
5260
+ return handleLazyRecalculate(false, true, true)
5221
5261
  })
5222
5262
  },
5223
5263
  setRowHeightConf (heightConf) {
@@ -5353,36 +5393,8 @@ export default defineVxeComponent({
5353
5393
  * 刷新布局
5354
5394
  */
5355
5395
  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
- })
5396
+ const isForce = !!reFull
5397
+ return handleLazyRecalculate(isForce, isForce, isForce)
5386
5398
  },
5387
5399
  openTooltip (target, content) {
5388
5400
  const $commTip = refCommTooltip.value
@@ -6179,7 +6191,7 @@ export default defineVxeComponent({
6179
6191
  reactData.rowExpandedFlag++
6180
6192
  return Promise.all(lazyRests)
6181
6193
  .then(() => nextTick())
6182
- .then(() => $xeTable.recalculate(true))
6194
+ .then(() => handleLazyRecalculate(true, true, true))
6183
6195
  .then(() => {
6184
6196
  updateRowOffsetTop()
6185
6197
  updateRowExpandStyle()
@@ -6217,7 +6229,7 @@ export default defineVxeComponent({
6217
6229
  }
6218
6230
  return nextTick().then(() => {
6219
6231
  if (expList.length) {
6220
- return $xeTable.recalculate(true)
6232
+ return handleLazyRecalculate(true, true, true)
6221
6233
  }
6222
6234
  }).then(() => {
6223
6235
  updateRowOffsetTop()
@@ -6328,7 +6340,7 @@ export default defineVxeComponent({
6328
6340
  $xeTable.handleTableData()
6329
6341
  updateAfterDataIndex()
6330
6342
  reactData.rowGroupExpandedFlag++
6331
- return $xeTable.recalculate(true)
6343
+ return handleLazyRecalculate(true, true, true)
6332
6344
  },
6333
6345
  clearRowGroupExpand () {
6334
6346
  internalData.rowGroupExpandedMaps = {}
@@ -6336,7 +6348,7 @@ export default defineVxeComponent({
6336
6348
  $xeTable.handleTableData()
6337
6349
  updateAfterDataIndex()
6338
6350
  reactData.rowGroupExpandedFlag++
6339
- return $xeTable.recalculate(true)
6351
+ return handleLazyRecalculate(true, true, true)
6340
6352
  },
6341
6353
  getTreeExpandRecords () {
6342
6354
  const rest: any[] = []
@@ -7428,10 +7440,10 @@ export default defineVxeComponent({
7428
7440
  }
7429
7441
  const el = refElem.value
7430
7442
  if (!el || !el.clientWidth) {
7431
- return nextTick()
7443
+ return
7432
7444
  }
7433
- tableMethods.recalculate(true)
7434
- tableMethods.updateCellAreas()
7445
+ handleLazyRecalculate(true, true, true)
7446
+ $xeTable.updateCellAreas()
7435
7447
  }
7436
7448
 
7437
7449
  const handleTargetEnterEvent = (isClear: boolean) => {
@@ -7454,8 +7466,6 @@ export default defineVxeComponent({
7454
7466
  hideDropTip()
7455
7467
  reactData.dragRow = null
7456
7468
  reactData.dragCol = null
7457
- reactData.isDragColMove = false
7458
- reactData.isDragRowMove = false
7459
7469
  }
7460
7470
  }
7461
7471
 
@@ -8421,7 +8431,8 @@ export default defineVxeComponent({
8421
8431
  const childList: any[] = vals[2]
8422
8432
  let sLen = 0 // 已选
8423
8433
  let hLen = 0 // 半选
8424
- let vLen = 0 // 有效行
8434
+ let vLen = 0 // 有效子行
8435
+ const cLen = childList.length // 有效子行
8425
8436
  childList.forEach(
8426
8437
  checkMethod
8427
8438
  ? (item) => {
@@ -8454,15 +8465,25 @@ export default defineVxeComponent({
8454
8465
  }
8455
8466
  )
8456
8467
 
8457
- let isSelected = (sLen >= vLen && (vLen >= 1 || hLen >= 1))
8458
- if (checkMethod) {
8459
- if (checkMethod({ $table: $xeTable, row })) {
8460
- isSelected = sLen >= vLen
8468
+ let isSelected = false
8469
+ if (cLen > 0) {
8470
+ if (vLen > 0) {
8471
+ isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen
8461
8472
  } else {
8462
- isSelected = selectCheckboxMaps[rowid]
8473
+ // 如果存在子项禁用
8474
+ if ((sLen > 0 && sLen >= vLen)) {
8475
+ isSelected = true
8476
+ } else if (selectCheckboxMaps[rowid]) {
8477
+ isSelected = true
8478
+ } else {
8479
+ isSelected = false
8480
+ }
8463
8481
  }
8482
+ } else {
8483
+ // 如果无子项
8484
+ isSelected = selectCheckboxMaps[rowid]
8464
8485
  }
8465
- const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
8486
+ const halfSelect = !isSelected && (sLen > 0 || hLen > 0)
8466
8487
 
8467
8488
  if (checkField) {
8468
8489
  XEUtils.set(row, checkField, isSelected)
@@ -8501,7 +8522,9 @@ export default defineVxeComponent({
8501
8522
  const { handleGetRowId } = createHandleGetRowId($xeTable)
8502
8523
 
8503
8524
  let sLen = 0 // 已选
8525
+ let dsLen = 0 // 禁用的已选
8504
8526
  let hLen = 0 // 半选
8527
+ let dhLen = 0 // 禁用的半选
8505
8528
  let vLen = 0 // 有效行
8506
8529
 
8507
8530
  const rootList = (treeConfig ? afterTreeFullData : (isRowGroupStatus ? afterGroupFullData : afterFullData))
@@ -8518,9 +8541,9 @@ export default defineVxeComponent({
8518
8541
  vLen++
8519
8542
  } else {
8520
8543
  if (selected) {
8521
- sLen++
8544
+ dsLen++
8522
8545
  } else if (treeIndeterminateRowMaps[childRowid]) {
8523
- hLen++
8546
+ dhLen++
8524
8547
  }
8525
8548
  }
8526
8549
  }
@@ -8536,7 +8559,7 @@ export default defineVxeComponent({
8536
8559
  })
8537
8560
 
8538
8561
  const isSelected = rootList.length > 0 ? (vLen > 0 ? (sLen >= vLen) : (sLen >= rootList.length)) : false
8539
- let halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
8562
+ let halfSelect = !isSelected && (sLen > 0 || hLen > 0 || dsLen > 0 || dhLen > 0)
8540
8563
 
8541
8564
  // 如果复选框启用保留记录,当保留数据存在时显示半选
8542
8565
  if (!isSelected && !halfSelect && showReserveStatus) {
@@ -9328,88 +9351,81 @@ export default defineVxeComponent({
9328
9351
  const { treeConfig, dragConfig } = props
9329
9352
  const rowDragOpts = computeRowDragOpts.value
9330
9353
  const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
9331
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
9354
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
9332
9355
  const treeOpts = computeTreeOpts.value
9356
+ const cellOpts = computeCellOpts.value
9357
+ const rowOpts = computeRowOpts.value
9358
+ const defaultRowHeight = computeDefaultRowHeight.value
9333
9359
  const { transform, rowField, mapChildrenField, parentField } = treeOpts
9334
9360
  const childrenField = treeOpts.children || treeOpts.childrenField
9335
9361
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
9336
9362
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
9363
+ const el = refElem.value
9337
9364
  const errRest = {
9338
9365
  status: false
9339
9366
  }
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
9367
+ if (!(el && prevDragRow && dragRow)) {
9368
+ return Promise.resolve(errRest)
9369
+ }
9370
+ // 判断是否有拖动
9371
+ if (prevDragRow !== dragRow) {
9372
+ const dragParams = {
9373
+ oldRow: dragRow,
9374
+ newRow: prevDragRow,
9375
+ dragRow,
9376
+ dragPos: prevDragPos as 'top' | 'bottom',
9377
+ dragToChild: !!prevDragToChild,
9378
+ offsetIndex: dragOffsetIndex as 0 | 1
9379
+ }
9380
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9381
+ return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
9382
+ if (!status) {
9383
+ return errRest
9384
+ }
9385
+
9386
+ const dragRowid = getRowid($xeTable, dragRow)
9387
+ const dragRowRest = fullAllDataRowIdData[dragRowid] || {}
9388
+ const _dragRowIndex = dragRowRest._index
9389
+ let dragRowHeight = 0
9390
+ let dragOffsetTop = -1
9391
+ if (animation) {
9392
+ dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight)
9393
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-body--row[rowid="${dragRowid}"]`)
9394
+ if (oldTrEl) {
9395
+ dragOffsetTop = oldTrEl.offsetTop
9355
9396
  }
9397
+ }
9356
9398
 
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
- // 子到根
9399
+ let oafIndex = -1
9400
+ let nafIndex = -1
9401
+ // 如果为树结构
9402
+ if (treeConfig) {
9403
+ if (transform) {
9404
+ // 移出源位置
9405
+ const oldRest = dragRowRest
9406
+ const newRowid = getRowid($xeTable, prevDragRow)
9407
+ const newRest = fullAllDataRowIdData[newRowid]
9406
9408
 
9407
- if (!isCrossDrag) {
9409
+ if (oldRest && newRest) {
9410
+ const { level: oldLevel } = oldRest
9411
+ const { level: newLevel } = newRest
9412
+
9413
+ const oldAllMaps: Record<string, any> = {}
9414
+ XEUtils.eachTree([dragRow], item => {
9415
+ oldAllMaps[getRowid($xeTable, item)] = item
9416
+ }, { children: mapChildrenField })
9417
+
9418
+ let isSelfToChildStatus = false
9419
+
9420
+ if (oldLevel && newLevel) {
9421
+ // 子到子
9422
+
9423
+ if (isPeerDrag && !isCrossDrag) {
9424
+ if (oldRest.row[parentField] !== newRest.row[parentField]) {
9425
+ // 非同级
9408
9426
  return errRest
9409
9427
  }
9410
- } else if (newLevel) {
9411
- // 根到子
9412
-
9428
+ } else {
9413
9429
  if (!isCrossDrag) {
9414
9430
  return errRest
9415
9431
  }
@@ -9425,95 +9441,171 @@ export default defineVxeComponent({
9425
9441
  return errRest
9426
9442
  }
9427
9443
  }
9428
- } else {
9429
- // 根到根
9430
9444
  }
9445
+ } else if (oldLevel) {
9446
+ // 子到根
9431
9447
 
9432
- const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9433
- key: rowField,
9434
- parentKey: parentField,
9435
- children: mapChildrenField
9436
- })
9448
+ if (!isCrossDrag) {
9449
+ return errRest
9450
+ }
9451
+ } else if (newLevel) {
9452
+ // 根到子
9453
+
9454
+ if (!isCrossDrag) {
9455
+ return errRest
9456
+ }
9457
+ if (oldAllMaps[newRowid]) {
9458
+ isSelfToChildStatus = true
9459
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9460
+ if (VxeUI.modal) {
9461
+ VxeUI.modal.message({
9462
+ status: 'error',
9463
+ content: getI18n('vxe.error.treeDragChild')
9464
+ })
9465
+ }
9466
+ return errRest
9467
+ }
9468
+ }
9469
+ } else {
9470
+ // 根到根
9471
+ }
9437
9472
 
9438
- // 移出
9439
- const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
9440
- fullList.splice(otfIndex, 1)
9473
+ const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9474
+ key: rowField,
9475
+ parentKey: parentField,
9476
+ children: mapChildrenField
9477
+ })
9441
9478
 
9442
- // 插入
9443
- const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
9444
- const ntfIndex = ptfIndex + dragOffsetIndex
9445
- fullList.splice(ntfIndex, 0, dragRow)
9479
+ // 移出
9480
+ const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
9481
+ fullList.splice(otfIndex, 1)
9446
9482
 
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]
9483
+ // 插入
9484
+ const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
9485
+ const ntfIndex = ptfIndex + dragOffsetIndex
9486
+ fullList.splice(ntfIndex, 0, dragRow)
9454
9487
 
9455
- internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
9456
- key: rowField,
9457
- parentKey: parentField,
9458
- children: childrenField,
9459
- mapChildren: mapChildrenField
9488
+ // 改变层级
9489
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9490
+ XEUtils.each(dragRow[childrenField], childRow => {
9491
+ childRow[parentField] = dragRow[parentField]
9460
9492
  })
9461
9493
  }
9494
+ dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField]
9495
+
9496
+ internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
9497
+ key: rowField,
9498
+ parentKey: parentField,
9499
+ children: childrenField,
9500
+ mapChildren: mapChildrenField
9501
+ })
9462
9502
  }
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
9503
  }
9504
+ } else {
9505
+ // 移出
9506
+ oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
9507
+ const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
9508
+ afterFullData.splice(oafIndex, 1)
9509
+ tableFullData.splice(otfIndex, 1)
9510
+ // 插入
9511
+ const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
9512
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
9513
+ nafIndex = pafIndex + dragOffsetIndex
9514
+ const ntfIndex = ptfIndex + dragOffsetIndex
9515
+ afterFullData.splice(nafIndex, 0, dragRow)
9516
+ tableFullData.splice(ntfIndex, 0, dragRow)
9517
+ }
9477
9518
 
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
- }
9519
+ $xeTable.handleTableData(treeConfig && transform)
9520
+ $xeTable.cacheRowMap(false)
9521
+ updateScrollYStatus()
9522
+ if (!(treeConfig && transform)) {
9523
+ $xeTable.updateAfterDataIndex()
9524
+ }
9525
+ $xeTable.checkSelectionStatus()
9526
+ if (reactData.scrollYLoad) {
9527
+ $xeTable.updateScrollYSpace()
9528
+ }
9489
9529
 
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
9530
+ if (evnt) {
9531
+ dispatchEvent('row-dragend', {
9532
+ oldRow: dragRow,
9533
+ newRow: prevDragRow,
9534
+ dragRow,
9535
+ dragPos: prevDragPos as any,
9536
+ dragToChild: isDragToChildFlag,
9537
+ offsetIndex: dragOffsetIndex,
9538
+ _index: {
9539
+ newIndex: nafIndex,
9540
+ oldIndex: oafIndex
9541
+ }
9542
+ }, evnt)
9543
+ }
9544
+
9545
+ return nextTick().then(() => {
9546
+ if (animation) {
9547
+ const { tableData } = reactData
9548
+ const dragRowRest = fullAllDataRowIdData[dragRowid]
9549
+ const _newRowIndex = dragRowRest._index
9550
+ const firstRow = tableData[0]
9551
+ const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)]
9552
+
9553
+ if (firstRowRest) {
9554
+ const _firstRowIndex = firstRowRest._index
9555
+ const _lastRowIndex = _firstRowIndex + tableData.length
9556
+
9557
+ let rsIndex = -1
9558
+ let reIndex = -1
9559
+ let offsetRate = 1
9560
+ if (_dragRowIndex < _firstRowIndex) {
9561
+ // 从上往下虚拟拖拽
9562
+ rsIndex = 0
9563
+ reIndex = _newRowIndex - _firstRowIndex
9564
+ } else if (_dragRowIndex > _lastRowIndex) {
9565
+ // 从下往上虚拟拖拽
9566
+ const $newRowIndex = dragRowRest.$index
9567
+ rsIndex = $newRowIndex + 1
9568
+ reIndex = tableData.length
9569
+ offsetRate = -1
9570
+ } else {
9571
+ if (_newRowIndex > _dragRowIndex) {
9572
+ // 从上往下拖拽
9573
+ rsIndex = _dragRowIndex - _firstRowIndex
9574
+ reIndex = rsIndex + _newRowIndex - _dragRowIndex
9575
+ } else {
9576
+ // 从下往上拖拽
9577
+ rsIndex = _newRowIndex - _firstRowIndex
9578
+ reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1
9579
+ offsetRate = -1
9580
+ }
9501
9581
  }
9502
- }, evnt)
9503
- }
9504
9582
 
9505
- return nextTick().then(() => {
9506
- $xeTable.updateCellAreas()
9507
- $xeTable.recalculate()
9508
- }).then(() => {
9509
- return {
9510
- status: true
9583
+ const dragRangeList = tableData.slice(rsIndex, reIndex)
9584
+ if (dragRangeList.length) {
9585
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(row => `.vxe-body--row[rowid="${getRowid($xeTable, row)}"]`).join(','))
9586
+ moveRowAnimateToTb(dtTrList, offsetRate * dragRowHeight)
9587
+ }
9588
+ }
9589
+
9590
+ const newTrList = el.querySelectorAll<HTMLElement>(`.vxe-body--row[rowid="${dragRowid}"]`)
9591
+ const newTrEl = newTrList[0]
9592
+ if (dragOffsetTop > -1 && newTrEl) {
9593
+ moveRowAnimateToTb(newTrList, dragOffsetTop - newTrEl.offsetTop)
9511
9594
  }
9512
- })
9513
- }).catch(() => {
9514
- return errRest
9595
+ }
9596
+
9597
+ updateRowOffsetTop()
9598
+ updateRowExpandStyle()
9599
+ $xeTable.updateCellAreas()
9600
+ $xeTable.recalculate()
9601
+ }).then(() => {
9602
+ return {
9603
+ status: true
9604
+ }
9515
9605
  })
9516
- }
9606
+ }).catch(() => {
9607
+ return errRest
9608
+ })
9517
9609
  }
9518
9610
  return Promise.resolve(errRest)
9519
9611
  },
@@ -9525,6 +9617,7 @@ export default defineVxeComponent({
9525
9617
  const { lazy } = treeOpts
9526
9618
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
9527
9619
  const { prevDragRow, prevDragPos } = internalData
9620
+ const el = refElem.value
9528
9621
  if (treeConfig && lazy && prevDragToChild) {
9529
9622
  // 懒加载
9530
9623
  const newRowid = getRowid($xeTable, prevDragRow)
@@ -9541,12 +9634,10 @@ export default defineVxeComponent({
9541
9634
  }
9542
9635
  hideDropTip()
9543
9636
  clearRowDropOrigin()
9637
+ clearRowAnimate(el)
9544
9638
  internalData.prevDragToChild = false
9545
9639
  reactData.dragRow = null
9546
9640
  reactData.dragCol = null
9547
- setTimeout(() => {
9548
- reactData.isDragRowMove = false
9549
- }, 500)
9550
9641
  },
9551
9642
  handleRowDragDragoverEvent (evnt) {
9552
9643
  const { treeConfig } = props
@@ -9629,7 +9720,7 @@ export default defineVxeComponent({
9629
9720
  },
9630
9721
  handleColDragSwapColumn () {
9631
9722
  handleUpdateColumn()
9632
- parseColumns(false).then(() => {
9723
+ return parseColumns(false).then(() => {
9633
9724
  $xeTable.updateCellAreas()
9634
9725
  $xeTable.saveCustomStore('update:sort')
9635
9726
  })
@@ -9637,79 +9728,83 @@ export default defineVxeComponent({
9637
9728
  handleColDragSwapEvent (evnt, isSyncColumn, dragCol, prevDragCol, prevDragPos, prevDragToChild) {
9638
9729
  const { mouseConfig } = props
9639
9730
  const columnDragOpts = computeColumnDragOpts.value
9640
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
9641
- const { collectColumn } = internalData
9731
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
9732
+ const { collectColumn, fullColumnIdData } = internalData
9733
+ const el = refElem.value
9642
9734
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
9643
9735
  const errRest = {
9644
9736
  status: false
9645
9737
  }
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
9738
+ if (!(el && prevDragCol && dragCol)) {
9739
+ return Promise.resolve(errRest)
9740
+ }
9741
+ // 判断是否有拖动
9742
+ if (prevDragCol !== dragCol) {
9743
+ const dragColumn = dragCol
9744
+ const newColumn = prevDragCol
9745
+ const dragParams = {
9746
+ oldColumn: dragColumn,
9747
+ newColumn,
9748
+ dragColumn,
9749
+ dragPos: prevDragPos as 'left' | 'right',
9750
+ dragToChild: !!prevDragToChild,
9751
+ offsetIndex: dragOffsetIndex as 0 | 1
9752
+ }
9753
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9754
+ return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
9755
+ if (!status) {
9756
+ return errRest
9757
+ }
9667
9758
 
9668
- const oldAllMaps: Record<string, any> = {}
9759
+ let dragTargetColumn: VxeTableDefines.ColumnInfo | null = null
9760
+ const dragAllTargetCols: VxeTableDefines.ColumnInfo[] = []
9761
+ let dragColWidth = 0
9762
+ if (animation) {
9669
9763
  XEUtils.eachTree([dragColumn], column => {
9670
- oldAllMaps[column.id] = column
9764
+ if (!dragTargetColumn && (!column.children || !column.children.length)) {
9765
+ dragTargetColumn = column
9766
+ dragColWidth += column.renderWidth
9767
+ }
9768
+ dragAllTargetCols.push(column)
9671
9769
  })
9770
+ }
9771
+ if (!dragTargetColumn) {
9772
+ dragTargetColumn = dragColumn
9773
+ }
9774
+ const dragColRest = fullColumnIdData[dragTargetColumn.id] || {}
9775
+ const _dragColIndex = dragColRest._index
9672
9776
 
9673
- let isSelfToChildStatus = false
9777
+ let dragOffsetLeft = -1
9778
+ if (animation) {
9779
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-table--column[colid="${dragTargetColumn.id}"]`)
9780
+ if (oldTrEl) {
9781
+ dragOffsetLeft = oldTrEl.offsetLeft
9782
+ }
9783
+ }
9674
9784
 
9675
- if (dragColumn.parentId && newColumn.parentId) {
9676
- // 子到子
9785
+ let oafIndex = -1
9786
+ let nafIndex = -1
9677
9787
 
9678
- if (isPeerDrag && !isCrossDrag) {
9679
- if (dragColumn.parentId !== newColumn.parentId) {
9680
- // 非同级
9681
- return errRest
9682
- }
9683
- } else {
9684
- if (!isCrossDrag) {
9685
- return errRest
9686
- }
9788
+ const oldAllMaps: Record<string, any> = {}
9789
+ XEUtils.eachTree([dragColumn], column => {
9790
+ oldAllMaps[column.id] = column
9791
+ })
9687
9792
 
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
- // 子到根
9793
+ let isSelfToChildStatus = false
9703
9794
 
9704
- if (!isCrossDrag) {
9795
+ if (dragColumn.parentId && newColumn.parentId) {
9796
+ // 子到子
9797
+
9798
+ if (isPeerDrag && !isCrossDrag) {
9799
+ if (dragColumn.parentId !== newColumn.parentId) {
9800
+ // 非同级
9705
9801
  return errRest
9706
9802
  }
9707
- } else if (newColumn.parentId) {
9708
- // 根到子
9709
-
9803
+ } else {
9710
9804
  if (!isCrossDrag) {
9711
9805
  return errRest
9712
9806
  }
9807
+
9713
9808
  if (oldAllMaps[newColumn.id]) {
9714
9809
  isSelfToChildStatus = true
9715
9810
  if (!(isCrossDrag && isSelfToChildDrag)) {
@@ -9722,111 +9817,214 @@ export default defineVxeComponent({
9722
9817
  return errRest
9723
9818
  }
9724
9819
  }
9725
- } else {
9726
- // 根到根
9727
9820
  }
9821
+ } else if (dragColumn.parentId) {
9822
+ // 子到根
9728
9823
 
9729
- const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
9824
+ if (!isCrossDrag) {
9825
+ return errRest
9826
+ }
9827
+ } else if (newColumn.parentId) {
9828
+ // 根到子
9730
9829
 
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
9830
+ if (!isCrossDrag) {
9831
+ return errRest
9832
+ }
9833
+ if (oldAllMaps[newColumn.id]) {
9834
+ isSelfToChildStatus = true
9835
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9836
+ if (VxeUI.modal) {
9837
+ VxeUI.modal.message({
9838
+ status: 'error',
9839
+ content: getI18n('vxe.error.treeDragChild')
9840
+ })
9748
9841
  }
9842
+ return errRest
9749
9843
  }
9750
9844
  }
9845
+ } else {
9846
+ // 根到根
9847
+ }
9751
9848
 
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
9849
+ const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
9850
+
9851
+ // 改变层级
9852
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9853
+ if (oldewMatchRest) {
9854
+ const { items: oCols, index: oIndex } = oldewMatchRest
9855
+ const childList = dragColumn.children || []
9856
+ childList.forEach(column => {
9857
+ column.parentId = dragColumn.parentId
9858
+ })
9859
+ oCols.splice(oIndex, 1, ...childList)
9860
+ dragColumn.children = []
9861
+ }
9862
+ } else {
9863
+ if (oldewMatchRest) {
9864
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
9865
+ oCols.splice(oIndex, 1)
9866
+ if (!oParent) {
9867
+ oafIndex = oIndex
9765
9868
  }
9766
9869
  }
9870
+ }
9767
9871
 
9768
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9769
- if (!parentColumn) {
9770
- const sortIndex = index + 1
9771
- column.renderSortNumber = sortIndex
9772
- }
9773
- })
9872
+ const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
9873
+ if (newMatchRest) {
9874
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
9875
+ // 转子级
9876
+ if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
9877
+ dragColumn.parentId = newColumn.id
9878
+ newColumn.children = (newColumn.children || []).concat([dragColumn])
9879
+ } else {
9880
+ dragColumn.parentId = newColumn.parentId
9881
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
9882
+ }
9883
+ if (!nParent) {
9884
+ nafIndex = nIndex
9885
+ }
9886
+ }
9774
9887
 
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
- }
9888
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9889
+ if (!parentColumn) {
9890
+ const sortIndex = index + 1
9891
+ column.renderSortNumber = sortIndex
9784
9892
  }
9893
+ })
9785
9894
 
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)
9895
+ if (mouseConfig) {
9896
+ if ($xeTable.clearSelected) {
9897
+ $xeTable.clearSelected()
9898
+ }
9899
+ if ($xeTable.clearCellAreas) {
9900
+ $xeTable.clearCellAreas()
9901
+ $xeTable.clearCopyCellArea()
9799
9902
  }
9903
+ }
9800
9904
 
9905
+ if (evnt) {
9906
+ dispatchEvent('column-dragend', {
9907
+ oldColumn: dragColumn,
9908
+ newColumn,
9909
+ dragColumn,
9910
+ dragPos: prevDragPos,
9911
+ dragToChild: isDragToChildFlag,
9912
+ offsetIndex: dragOffsetIndex,
9913
+ _index: {
9914
+ newIndex: nafIndex,
9915
+ oldIndex: oafIndex
9916
+ }
9917
+ }, evnt)
9918
+ }
9919
+
9920
+ return nextTick().then(() => {
9801
9921
  if (isSyncColumn) {
9802
- $xeTable.handleColDragSwapColumn()
9922
+ return $xeTable.handleColDragSwapColumn()
9803
9923
  }
9924
+ }).then(() => {
9925
+ if (animation) {
9926
+ const { tableColumn } = reactData
9927
+ const { visibleColumn, fullColumnIdData } = internalData
9928
+ let dragNewColumn: VxeTableDefines.ColumnInfo | null = null
9929
+ const dragNewColMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
9930
+ XEUtils.eachTree([dragColumn], column => {
9931
+ if (!dragNewColumn && (!column.children || !column.children.length)) {
9932
+ dragNewColumn = column
9933
+ }
9934
+ dragNewColMaps[column.id] = column
9935
+ })
9936
+ if (!dragNewColumn) {
9937
+ dragNewColumn = dragColumn
9938
+ }
9939
+
9940
+ if (dragColWidth && dragAllTargetCols.length) {
9941
+ const _newColIndex = XEUtils.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id)
9942
+ const firstCol = tableColumn[0]
9943
+ const firstColRest = fullColumnIdData[firstCol.id]
9944
+
9945
+ if (firstColRest) {
9946
+ const _firstColIndex = firstColRest._index
9947
+ const _lastColIndex = _firstColIndex + tableColumn.length
9948
+ let csIndex = -1
9949
+ let ceIndex = -1
9950
+ let offsetRate = 1
9951
+ if (_dragColIndex < _firstColIndex) {
9952
+ // 从左往右虚拟拖拽
9953
+ csIndex = 0
9954
+ ceIndex = _newColIndex - _firstColIndex
9955
+ } else if (_dragColIndex > _lastColIndex) {
9956
+ // 从右往左虚拟拖拽
9957
+ const $newRowIndex = dragColRest.$index
9958
+ csIndex = $newRowIndex + 1
9959
+ ceIndex = tableColumn.length
9960
+ offsetRate = -1
9961
+ } else {
9962
+ if (_newColIndex > _dragColIndex) {
9963
+ // 从左往右拖拽
9964
+ csIndex = _dragColIndex - _firstColIndex
9965
+ ceIndex = csIndex + _newColIndex - _dragColIndex
9966
+ } else {
9967
+ // 从右往左拖拽
9968
+ csIndex = _newColIndex - _firstColIndex + 1
9969
+ ceIndex = csIndex + _dragColIndex - _newColIndex
9970
+ offsetRate = -1
9971
+ }
9972
+ }
9973
+
9974
+ const dragRangeList: VxeTableDefines.ColumnInfo[] = []
9975
+ const dragRangeMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
9976
+ for (let i = csIndex; i < ceIndex; i++) {
9977
+ const column = tableColumn[i]
9978
+ if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
9979
+ dragRangeMaps[column.id] = column
9980
+ dragRangeList.push(column)
9981
+ }
9982
+ }
9983
+ XEUtils.eachTree([newColumn], column => {
9984
+ if (!dragRangeMaps[column.id]) {
9985
+ dragRangeMaps[column.id] = column
9986
+ dragRangeList.push(column)
9987
+ }
9988
+ })
9989
+ if (dragRangeList.length) {
9990
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
9991
+ moveColAnimateToLr(dtTrList, offsetRate * dragColWidth)
9992
+ }
9993
+ }
9994
+
9995
+ const newTrList = el.querySelectorAll<HTMLElement>(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
9996
+ const newTdEl = newTrList[0]
9997
+ if (dragOffsetLeft > -1 && newTdEl) {
9998
+ moveColAnimateToLr(newTrList, dragOffsetLeft - newTdEl.offsetLeft)
9999
+ }
10000
+ }
10001
+ }
10002
+
10003
+ updateColumnOffsetLeft()
10004
+ loadScrollXData()
10005
+ $xeTable.updateCellAreas()
9804
10006
 
9805
10007
  return {
9806
10008
  status: true
9807
10009
  }
9808
- }).catch(() => {
9809
- return errRest
9810
10010
  })
9811
- }
10011
+ }).catch(() => {
10012
+ return errRest
10013
+ })
9812
10014
  }
9813
10015
  return Promise.resolve(errRest)
9814
10016
  },
9815
10017
  handleHeaderCellDragDragendEvent (evnt) {
9816
10018
  const { dragCol } = reactData
9817
10019
  const { prevDragCol, prevDragPos, prevDragToChild } = internalData
10020
+ const el = refElem.value
9818
10021
  $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild)
9819
10022
  hideDropTip()
9820
10023
  clearColDropOrigin()
10024
+ clearColAnimate(el)
9821
10025
  internalData.prevDragToChild = false
9822
10026
  reactData.dragRow = null
9823
10027
  reactData.dragCol = null
9824
- setTimeout(() => {
9825
- reactData.isDragColMove = false
9826
- $xeTable.recalculate().then(() => {
9827
- loadScrollXData()
9828
- })
9829
- }, 500)
9830
10028
  },
9831
10029
  handleHeaderCellDragDragoverEvent (evnt) {
9832
10030
  const { dragCol } = reactData
@@ -9900,7 +10098,6 @@ export default defineVxeComponent({
9900
10098
  const { column } = params
9901
10099
  const dragEl = evnt.currentTarget as HTMLElement
9902
10100
  const thEl = trigger === 'cell' ? dragEl : dragEl.parentElement?.parentElement as HTMLElement
9903
- reactData.isDragColMove = false
9904
10101
  clearColDropOrigin()
9905
10102
  if (dragStartMethod && !dragStartMethod(params)) {
9906
10103
  thEl.draggable = false
@@ -9921,7 +10118,6 @@ export default defineVxeComponent({
9921
10118
  hideDropTip()
9922
10119
  reactData.dragRow = null
9923
10120
  reactData.dragCol = null
9924
- reactData.isDragColMove = false
9925
10121
  },
9926
10122
  handleScrollEvent (evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
9927
10123
  const { highlightHoverRow } = props
@@ -9986,8 +10182,6 @@ export default defineVxeComponent({
9986
10182
  }
9987
10183
  internalData.lastScrollTop = scrollTop
9988
10184
  }
9989
- reactData.isDragColMove = false
9990
- reactData.isDragRowMove = false
9991
10185
  reactData.lastScrollTime = Date.now()
9992
10186
  const evntParams = {
9993
10187
  scrollTop,
@@ -11860,6 +12054,7 @@ export default defineVxeComponent({
11860
12054
  nextTick(() => {
11861
12055
  if (props.loading) {
11862
12056
  if (!VxeUILoadingComponent && !slots.loading) {
12057
+ errLog('vxe.error.errProp', ['loading=true', 'loading=false | <template #loading>...</template>'])
11863
12058
  errLog('vxe.error.reqComp', ['vxe-loading'])
11864
12059
  }
11865
12060
  }
@@ -11868,6 +12063,24 @@ export default defineVxeComponent({
11868
12063
  (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
11869
12064
  props.tooltipConfig || props.editRules) {
11870
12065
  if (!VxeUITooltipComponent) {
12066
+ if (props.showOverflow === true) {
12067
+ errLog('vxe.error.errProp', ['show-overflow=true', 'show-overflow=title'])
12068
+ }
12069
+ if (props.showOverflow === 'tooltip') {
12070
+ errLog('vxe.error.errProp', ['show-overflow=tooltip', 'show-overflow=title'])
12071
+ }
12072
+ if (props.showHeaderOverflow === true) {
12073
+ errLog('vxe.error.errProp', ['show-header-overflow=true', 'show-header-overflow=title'])
12074
+ }
12075
+ if (props.showHeaderOverflow === 'tooltip') {
12076
+ errLog('vxe.error.errProp', ['show-header-overflow=tooltip', 'show-header-overflow=title'])
12077
+ }
12078
+ if (props.showFooterOverflow === true) {
12079
+ errLog('vxe.error.errProp', ['show-footer-overflow=true', 'show-footer-overflow=title'])
12080
+ }
12081
+ if (props.showFooterOverflow === 'tooltip') {
12082
+ errLog('vxe.error.errProp', ['show-footer-overflow=tooltip', 'show-footer-overflow=title'])
12083
+ }
11871
12084
  errLog('vxe.error.reqComp', ['vxe-tooltip'])
11872
12085
  }
11873
12086
  }