vxe-table 4.14.0-beta.0 → 4.14.0-beta.2

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 (81) 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 +127 -94
  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/module/keyboard/hook.js +2 -2
  13. package/es/table/src/anime.js +46 -0
  14. package/es/table/src/body.js +9 -24
  15. package/es/table/src/columnInfo.js +5 -0
  16. package/es/table/src/footer.js +5 -22
  17. package/es/table/src/header.js +4 -21
  18. package/es/table/src/table.js +562 -358
  19. package/es/table/src/util.js +1 -1
  20. package/es/table/style.css +8 -8
  21. package/es/table/style.min.css +1 -1
  22. package/es/ui/index.js +3 -2
  23. package/es/ui/src/log.js +1 -1
  24. package/es/vxe-table/style.css +8 -8
  25. package/es/vxe-table/style.min.css +1 -1
  26. package/lib/grid/src/grid.js +143 -98
  27. package/lib/grid/src/grid.min.js +1 -1
  28. package/lib/index.css +1 -1
  29. package/lib/index.min.css +1 -1
  30. package/lib/index.umd.js +255 -208
  31. package/lib/index.umd.min.js +1 -1
  32. package/lib/style.css +1 -1
  33. package/lib/style.min.css +1 -1
  34. package/lib/table/module/custom/hook.js +0 -4
  35. package/lib/table/module/custom/hook.min.js +1 -1
  36. package/lib/table/module/custom/panel.js +0 -1
  37. package/lib/table/module/custom/panel.min.js +1 -1
  38. package/lib/table/module/keyboard/hook.js +2 -2
  39. package/lib/table/module/keyboard/hook.min.js +1 -1
  40. package/lib/table/src/anime.js +56 -0
  41. package/lib/table/src/anime.min.js +1 -0
  42. package/lib/table/src/body.js +3 -26
  43. package/lib/table/src/body.min.js +1 -1
  44. package/lib/table/src/columnInfo.js +5 -0
  45. package/lib/table/src/columnInfo.min.js +1 -1
  46. package/lib/table/src/footer.js +2 -20
  47. package/lib/table/src/footer.min.js +1 -1
  48. package/lib/table/src/header.js +2 -19
  49. package/lib/table/src/header.min.js +1 -1
  50. package/lib/table/src/table.js +47 -34
  51. package/lib/table/src/table.min.js +1 -1
  52. package/lib/table/src/util.js +2 -2
  53. package/lib/table/src/util.min.js +1 -1
  54. package/lib/table/style/style.css +8 -8
  55. package/lib/table/style/style.min.css +1 -1
  56. package/lib/ui/index.js +3 -2
  57. package/lib/ui/index.min.js +1 -1
  58. package/lib/ui/src/log.js +1 -1
  59. package/lib/ui/src/log.min.js +1 -1
  60. package/lib/vxe-table/style/style.css +8 -8
  61. package/lib/vxe-table/style/style.min.css +1 -1
  62. package/package.json +1 -1
  63. package/packages/grid/src/grid.ts +136 -101
  64. package/packages/table/module/custom/hook.ts +0 -4
  65. package/packages/table/module/custom/panel.ts +0 -1
  66. package/packages/table/module/keyboard/hook.ts +2 -2
  67. package/packages/table/src/anime.ts +52 -0
  68. package/packages/table/src/body.ts +15 -38
  69. package/packages/table/src/columnInfo.ts +5 -0
  70. package/packages/table/src/footer.ts +5 -22
  71. package/packages/table/src/header.ts +4 -21
  72. package/packages/table/src/table.ts +570 -361
  73. package/packages/table/src/util.ts +1 -1
  74. package/packages/ui/index.ts +2 -1
  75. package/styles/components/table.scss +9 -9
  76. /package/es/{iconfont.1750770364548.ttf → iconfont.1751195167653.ttf} +0 -0
  77. /package/es/{iconfont.1750770364548.woff → iconfont.1751195167653.woff} +0 -0
  78. /package/es/{iconfont.1750770364548.woff2 → iconfont.1751195167653.woff2} +0 -0
  79. /package/lib/{iconfont.1750770364548.ttf → iconfont.1751195167653.ttf} +0 -0
  80. /package/lib/{iconfont.1750770364548.woff → iconfont.1751195167653.woff} +0 -0
  81. /package/lib/{iconfont.1750770364548.woff2 → iconfont.1751195167653.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,169 @@ 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
+ // 根到子
9437
9453
 
9438
- // 移出
9439
- const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
9440
- fullList.splice(otfIndex, 1)
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
+ }
9441
9472
 
9442
- // 插入
9443
- const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow)
9444
- const ntfIndex = ptfIndex + dragOffsetIndex
9445
- fullList.splice(ntfIndex, 0, dragRow)
9473
+ const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9474
+ key: rowField,
9475
+ parentKey: parentField,
9476
+ children: mapChildrenField
9477
+ })
9446
9478
 
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]
9479
+ // 移出
9480
+ const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow)
9481
+ fullList.splice(otfIndex, 1)
9482
+
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
+ }
9529
+
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
+ }
9581
+ }
9489
9582
 
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
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)
9501
9587
  }
9502
- }, evnt)
9503
- }
9588
+ }
9504
9589
 
9505
- return nextTick().then(() => {
9506
- $xeTable.updateCellAreas()
9507
- $xeTable.recalculate()
9508
- }).then(() => {
9509
- return {
9510
- status: true
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
+ $xeTable.updateCellAreas()
9598
+ $xeTable.recalculate()
9599
+ }).then(() => {
9600
+ return {
9601
+ status: true
9602
+ }
9515
9603
  })
9516
- }
9604
+ }).catch(() => {
9605
+ return errRest
9606
+ })
9517
9607
  }
9518
9608
  return Promise.resolve(errRest)
9519
9609
  },
@@ -9525,6 +9615,7 @@ export default defineVxeComponent({
9525
9615
  const { lazy } = treeOpts
9526
9616
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
9527
9617
  const { prevDragRow, prevDragPos } = internalData
9618
+ const el = refElem.value
9528
9619
  if (treeConfig && lazy && prevDragToChild) {
9529
9620
  // 懒加载
9530
9621
  const newRowid = getRowid($xeTable, prevDragRow)
@@ -9541,12 +9632,10 @@ export default defineVxeComponent({
9541
9632
  }
9542
9633
  hideDropTip()
9543
9634
  clearRowDropOrigin()
9635
+ clearRowAnimate(el)
9544
9636
  internalData.prevDragToChild = false
9545
9637
  reactData.dragRow = null
9546
9638
  reactData.dragCol = null
9547
- setTimeout(() => {
9548
- reactData.isDragRowMove = false
9549
- }, 500)
9550
9639
  },
9551
9640
  handleRowDragDragoverEvent (evnt) {
9552
9641
  const { treeConfig } = props
@@ -9629,7 +9718,7 @@ export default defineVxeComponent({
9629
9718
  },
9630
9719
  handleColDragSwapColumn () {
9631
9720
  handleUpdateColumn()
9632
- parseColumns(false).then(() => {
9721
+ return parseColumns(false).then(() => {
9633
9722
  $xeTable.updateCellAreas()
9634
9723
  $xeTable.saveCustomStore('update:sort')
9635
9724
  })
@@ -9637,79 +9726,83 @@ export default defineVxeComponent({
9637
9726
  handleColDragSwapEvent (evnt, isSyncColumn, dragCol, prevDragCol, prevDragPos, prevDragToChild) {
9638
9727
  const { mouseConfig } = props
9639
9728
  const columnDragOpts = computeColumnDragOpts.value
9640
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
9641
- const { collectColumn } = internalData
9729
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
9730
+ const { collectColumn, fullColumnIdData } = internalData
9731
+ const el = refElem.value
9642
9732
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
9643
9733
  const errRest = {
9644
9734
  status: false
9645
9735
  }
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
9736
+ if (!(el && prevDragCol && dragCol)) {
9737
+ return Promise.resolve(errRest)
9738
+ }
9739
+ // 判断是否有拖动
9740
+ if (prevDragCol !== dragCol) {
9741
+ const dragColumn = dragCol
9742
+ const newColumn = prevDragCol
9743
+ const dragParams = {
9744
+ oldColumn: dragColumn,
9745
+ newColumn,
9746
+ dragColumn,
9747
+ dragPos: prevDragPos as 'left' | 'right',
9748
+ dragToChild: !!prevDragToChild,
9749
+ offsetIndex: dragOffsetIndex as 0 | 1
9750
+ }
9751
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
9752
+ return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
9753
+ if (!status) {
9754
+ return errRest
9755
+ }
9667
9756
 
9668
- const oldAllMaps: Record<string, any> = {}
9757
+ let dragTargetColumn: VxeTableDefines.ColumnInfo | null = null
9758
+ const dragAllTargetCols: VxeTableDefines.ColumnInfo[] = []
9759
+ let dragColWidth = 0
9760
+ if (animation) {
9669
9761
  XEUtils.eachTree([dragColumn], column => {
9670
- oldAllMaps[column.id] = column
9762
+ if (!dragTargetColumn && (!column.children || !column.children.length)) {
9763
+ dragTargetColumn = column
9764
+ dragColWidth += column.renderWidth
9765
+ }
9766
+ dragAllTargetCols.push(column)
9671
9767
  })
9768
+ }
9769
+ if (!dragTargetColumn) {
9770
+ dragTargetColumn = dragColumn
9771
+ }
9772
+ const dragColRest = fullColumnIdData[dragTargetColumn.id] || {}
9773
+ const _dragColIndex = dragColRest._index
9672
9774
 
9673
- let isSelfToChildStatus = false
9775
+ let dragOffsetLeft = -1
9776
+ if (animation) {
9777
+ const oldTrEl = el.querySelector<HTMLElement>(`.vxe-table--column[colid="${dragTargetColumn.id}"]`)
9778
+ if (oldTrEl) {
9779
+ dragOffsetLeft = oldTrEl.offsetLeft
9780
+ }
9781
+ }
9674
9782
 
9675
- if (dragColumn.parentId && newColumn.parentId) {
9676
- // 子到子
9783
+ let oafIndex = -1
9784
+ let nafIndex = -1
9677
9785
 
9678
- if (isPeerDrag && !isCrossDrag) {
9679
- if (dragColumn.parentId !== newColumn.parentId) {
9680
- // 非同级
9681
- return errRest
9682
- }
9683
- } else {
9684
- if (!isCrossDrag) {
9685
- return errRest
9686
- }
9786
+ const oldAllMaps: Record<string, any> = {}
9787
+ XEUtils.eachTree([dragColumn], column => {
9788
+ oldAllMaps[column.id] = column
9789
+ })
9687
9790
 
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
- // 子到根
9791
+ let isSelfToChildStatus = false
9703
9792
 
9704
- if (!isCrossDrag) {
9793
+ if (dragColumn.parentId && newColumn.parentId) {
9794
+ // 子到子
9795
+
9796
+ if (isPeerDrag && !isCrossDrag) {
9797
+ if (dragColumn.parentId !== newColumn.parentId) {
9798
+ // 非同级
9705
9799
  return errRest
9706
9800
  }
9707
- } else if (newColumn.parentId) {
9708
- // 根到子
9709
-
9801
+ } else {
9710
9802
  if (!isCrossDrag) {
9711
9803
  return errRest
9712
9804
  }
9805
+
9713
9806
  if (oldAllMaps[newColumn.id]) {
9714
9807
  isSelfToChildStatus = true
9715
9808
  if (!(isCrossDrag && isSelfToChildDrag)) {
@@ -9722,111 +9815,212 @@ export default defineVxeComponent({
9722
9815
  return errRest
9723
9816
  }
9724
9817
  }
9725
- } else {
9726
- // 根到根
9727
9818
  }
9819
+ } else if (dragColumn.parentId) {
9820
+ // 子到根
9728
9821
 
9729
- const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
9822
+ if (!isCrossDrag) {
9823
+ return errRest
9824
+ }
9825
+ } else if (newColumn.parentId) {
9826
+ // 根到子
9730
9827
 
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
9828
+ if (!isCrossDrag) {
9829
+ return errRest
9830
+ }
9831
+ if (oldAllMaps[newColumn.id]) {
9832
+ isSelfToChildStatus = true
9833
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9834
+ if (VxeUI.modal) {
9835
+ VxeUI.modal.message({
9836
+ status: 'error',
9837
+ content: getI18n('vxe.error.treeDragChild')
9838
+ })
9748
9839
  }
9840
+ return errRest
9749
9841
  }
9750
9842
  }
9843
+ } else {
9844
+ // 根到根
9845
+ }
9751
9846
 
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
9847
+ const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
9848
+
9849
+ // 改变层级
9850
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9851
+ if (oldewMatchRest) {
9852
+ const { items: oCols, index: oIndex } = oldewMatchRest
9853
+ const childList = dragColumn.children || []
9854
+ childList.forEach(column => {
9855
+ column.parentId = dragColumn.parentId
9856
+ })
9857
+ oCols.splice(oIndex, 1, ...childList)
9858
+ dragColumn.children = []
9859
+ }
9860
+ } else {
9861
+ if (oldewMatchRest) {
9862
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
9863
+ oCols.splice(oIndex, 1)
9864
+ if (!oParent) {
9865
+ oafIndex = oIndex
9765
9866
  }
9766
9867
  }
9868
+ }
9767
9869
 
9768
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9769
- if (!parentColumn) {
9770
- const sortIndex = index + 1
9771
- column.renderSortNumber = sortIndex
9772
- }
9773
- })
9870
+ const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
9871
+ if (newMatchRest) {
9872
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
9873
+ // 转子级
9874
+ if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
9875
+ dragColumn.parentId = newColumn.id
9876
+ newColumn.children = (newColumn.children || []).concat([dragColumn])
9877
+ } else {
9878
+ dragColumn.parentId = newColumn.parentId
9879
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
9880
+ }
9881
+ if (!nParent) {
9882
+ nafIndex = nIndex
9883
+ }
9884
+ }
9774
9885
 
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
- }
9886
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9887
+ if (!parentColumn) {
9888
+ const sortIndex = index + 1
9889
+ column.renderSortNumber = sortIndex
9784
9890
  }
9891
+ })
9785
9892
 
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)
9893
+ if (mouseConfig) {
9894
+ if ($xeTable.clearSelected) {
9895
+ $xeTable.clearSelected()
9896
+ }
9897
+ if ($xeTable.clearCellAreas) {
9898
+ $xeTable.clearCellAreas()
9899
+ $xeTable.clearCopyCellArea()
9799
9900
  }
9901
+ }
9800
9902
 
9903
+ if (evnt) {
9904
+ dispatchEvent('column-dragend', {
9905
+ oldColumn: dragColumn,
9906
+ newColumn,
9907
+ dragColumn,
9908
+ dragPos: prevDragPos,
9909
+ dragToChild: isDragToChildFlag,
9910
+ offsetIndex: dragOffsetIndex,
9911
+ _index: {
9912
+ newIndex: nafIndex,
9913
+ oldIndex: oafIndex
9914
+ }
9915
+ }, evnt)
9916
+ }
9917
+
9918
+ return nextTick().then(() => {
9801
9919
  if (isSyncColumn) {
9802
- $xeTable.handleColDragSwapColumn()
9920
+ return $xeTable.handleColDragSwapColumn()
9803
9921
  }
9922
+ }).then(() => {
9923
+ if (animation) {
9924
+ const { tableColumn } = reactData
9925
+ const { visibleColumn, fullColumnIdData } = internalData
9926
+ let dragNewColumn: VxeTableDefines.ColumnInfo | null = null
9927
+ const dragNewColMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
9928
+ XEUtils.eachTree([dragColumn], column => {
9929
+ if (!dragNewColumn && (!column.children || !column.children.length)) {
9930
+ dragNewColumn = column
9931
+ }
9932
+ dragNewColMaps[column.id] = column
9933
+ })
9934
+ if (!dragNewColumn) {
9935
+ dragNewColumn = dragColumn
9936
+ }
9937
+
9938
+ if (dragColWidth && dragAllTargetCols.length) {
9939
+ const _newColIndex = XEUtils.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id)
9940
+ const firstCol = tableColumn[0]
9941
+ const firstColRest = fullColumnIdData[firstCol.id]
9942
+
9943
+ if (firstColRest) {
9944
+ const _firstColIndex = firstColRest._index
9945
+ const _lastColIndex = _firstColIndex + tableColumn.length
9946
+ let csIndex = -1
9947
+ let ceIndex = -1
9948
+ let offsetRate = 1
9949
+ if (_dragColIndex < _firstColIndex) {
9950
+ // 从左往右虚拟拖拽
9951
+ csIndex = 0
9952
+ ceIndex = _newColIndex - _firstColIndex
9953
+ } else if (_dragColIndex > _lastColIndex) {
9954
+ // 从右往左虚拟拖拽
9955
+ const $newRowIndex = dragColRest.$index
9956
+ csIndex = $newRowIndex + 1
9957
+ ceIndex = tableColumn.length
9958
+ offsetRate = -1
9959
+ } else {
9960
+ if (_newColIndex > _dragColIndex) {
9961
+ // 从左往右拖拽
9962
+ csIndex = _dragColIndex - _firstColIndex
9963
+ ceIndex = csIndex + _newColIndex - _dragColIndex
9964
+ } else {
9965
+ // 从右往左拖拽
9966
+ csIndex = _newColIndex - _firstColIndex + 1
9967
+ ceIndex = csIndex + _dragColIndex - _newColIndex
9968
+ offsetRate = -1
9969
+ }
9970
+ }
9971
+
9972
+ const dragRangeList: VxeTableDefines.ColumnInfo[] = []
9973
+ const dragRangeMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
9974
+ for (let i = csIndex; i < ceIndex; i++) {
9975
+ const column = tableColumn[i]
9976
+ if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
9977
+ dragRangeMaps[column.id] = column
9978
+ dragRangeList.push(column)
9979
+ }
9980
+ }
9981
+ XEUtils.eachTree([newColumn], column => {
9982
+ if (!dragRangeMaps[column.id]) {
9983
+ dragRangeMaps[column.id] = column
9984
+ dragRangeList.push(column)
9985
+ }
9986
+ })
9987
+ if (dragRangeList.length) {
9988
+ const dtTrList = el.querySelectorAll<HTMLElement>(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
9989
+ moveColAnimateToLr(dtTrList, offsetRate * dragColWidth)
9990
+ }
9991
+ }
9992
+
9993
+ const newTrList = el.querySelectorAll<HTMLElement>(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','))
9994
+ const newTdEl = newTrList[0]
9995
+ if (dragOffsetLeft > -1 && newTdEl) {
9996
+ moveColAnimateToLr(newTrList, dragOffsetLeft - newTdEl.offsetLeft)
9997
+ }
9998
+ }
9999
+ }
10000
+
10001
+ loadScrollXData()
9804
10002
 
9805
10003
  return {
9806
10004
  status: true
9807
10005
  }
9808
- }).catch(() => {
9809
- return errRest
9810
10006
  })
9811
- }
10007
+ }).catch(() => {
10008
+ return errRest
10009
+ })
9812
10010
  }
9813
10011
  return Promise.resolve(errRest)
9814
10012
  },
9815
10013
  handleHeaderCellDragDragendEvent (evnt) {
9816
10014
  const { dragCol } = reactData
9817
10015
  const { prevDragCol, prevDragPos, prevDragToChild } = internalData
10016
+ const el = refElem.value
9818
10017
  $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild)
9819
10018
  hideDropTip()
9820
10019
  clearColDropOrigin()
10020
+ clearColAnimate(el)
9821
10021
  internalData.prevDragToChild = false
9822
10022
  reactData.dragRow = null
9823
10023
  reactData.dragCol = null
9824
- setTimeout(() => {
9825
- reactData.isDragColMove = false
9826
- $xeTable.recalculate().then(() => {
9827
- loadScrollXData()
9828
- })
9829
- }, 500)
9830
10024
  },
9831
10025
  handleHeaderCellDragDragoverEvent (evnt) {
9832
10026
  const { dragCol } = reactData
@@ -9900,7 +10094,6 @@ export default defineVxeComponent({
9900
10094
  const { column } = params
9901
10095
  const dragEl = evnt.currentTarget as HTMLElement
9902
10096
  const thEl = trigger === 'cell' ? dragEl : dragEl.parentElement?.parentElement as HTMLElement
9903
- reactData.isDragColMove = false
9904
10097
  clearColDropOrigin()
9905
10098
  if (dragStartMethod && !dragStartMethod(params)) {
9906
10099
  thEl.draggable = false
@@ -9921,7 +10114,6 @@ export default defineVxeComponent({
9921
10114
  hideDropTip()
9922
10115
  reactData.dragRow = null
9923
10116
  reactData.dragCol = null
9924
- reactData.isDragColMove = false
9925
10117
  },
9926
10118
  handleScrollEvent (evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
9927
10119
  const { highlightHoverRow } = props
@@ -9986,8 +10178,6 @@ export default defineVxeComponent({
9986
10178
  }
9987
10179
  internalData.lastScrollTop = scrollTop
9988
10180
  }
9989
- reactData.isDragColMove = false
9990
- reactData.isDragRowMove = false
9991
10181
  reactData.lastScrollTime = Date.now()
9992
10182
  const evntParams = {
9993
10183
  scrollTop,
@@ -11665,7 +11855,7 @@ export default defineVxeComponent({
11665
11855
  if (rowOpts.height && !props.showOverflow) {
11666
11856
  warnLog('vxe.error.notProp', ['table.show-overflow'])
11667
11857
  }
11668
- if (!$xeTable.triggerCellAreaMousedownEvent) {
11858
+ if (!$xeTable.triggerCellAreaMousednEvent) {
11669
11859
  if (props.areaConfig) {
11670
11860
  warnLog('vxe.error.notProp', ['area-config'])
11671
11861
  }
@@ -11860,6 +12050,7 @@ export default defineVxeComponent({
11860
12050
  nextTick(() => {
11861
12051
  if (props.loading) {
11862
12052
  if (!VxeUILoadingComponent && !slots.loading) {
12053
+ errLog('vxe.error.errProp', ['loading=true', 'loading=false | <template #loading>...</template>'])
11863
12054
  errLog('vxe.error.reqComp', ['vxe-loading'])
11864
12055
  }
11865
12056
  }
@@ -11868,6 +12059,24 @@ export default defineVxeComponent({
11868
12059
  (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
11869
12060
  props.tooltipConfig || props.editRules) {
11870
12061
  if (!VxeUITooltipComponent) {
12062
+ if (props.showOverflow === true) {
12063
+ errLog('vxe.error.errProp', ['show-overflow=true', 'show-overflow=title'])
12064
+ }
12065
+ if (props.showOverflow === 'tooltip') {
12066
+ errLog('vxe.error.errProp', ['show-overflow=tooltip', 'show-overflow=title'])
12067
+ }
12068
+ if (props.showHeaderOverflow === true) {
12069
+ errLog('vxe.error.errProp', ['show-header-overflow=true', 'show-header-overflow=title'])
12070
+ }
12071
+ if (props.showHeaderOverflow === 'tooltip') {
12072
+ errLog('vxe.error.errProp', ['show-header-overflow=tooltip', 'show-header-overflow=title'])
12073
+ }
12074
+ if (props.showFooterOverflow === true) {
12075
+ errLog('vxe.error.errProp', ['show-footer-overflow=true', 'show-footer-overflow=title'])
12076
+ }
12077
+ if (props.showFooterOverflow === 'tooltip') {
12078
+ errLog('vxe.error.errProp', ['show-footer-overflow=tooltip', 'show-footer-overflow=title'])
12079
+ }
11871
12080
  errLog('vxe.error.reqComp', ['vxe-tooltip'])
11872
12081
  }
11873
12082
  }