vxe-table 3.18.0-beta.8 → 3.18.1

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 (54) hide show
  1. package/es/locale/lang/en-US.js +12 -12
  2. package/es/style.css +1 -1
  3. package/es/table/module/edit/mixin.js +58 -20
  4. package/es/table/module/filter/mixin.js +12 -10
  5. package/es/table/module/keyboard/mixin.js +175 -172
  6. package/es/table/module/menu/mixin.js +16 -9
  7. package/es/table/module/validator/mixin.js +4 -2
  8. package/es/table/src/methods.js +344 -46
  9. package/es/table/src/store.js +8 -0
  10. package/es/table/src/table.js +35 -9
  11. package/es/ui/index.js +1 -1
  12. package/es/ui/src/log.js +1 -1
  13. package/lib/index.umd.js +713 -289
  14. package/lib/index.umd.min.js +1 -1
  15. package/lib/locale/lang/en-US.js +12 -12
  16. package/lib/locale/lang/en-US.min.js +1 -1
  17. package/lib/locale/lang/en-US.umd.js +12 -12
  18. package/lib/style.css +1 -1
  19. package/lib/table/module/edit/mixin.js +55 -16
  20. package/lib/table/module/edit/mixin.min.js +1 -1
  21. package/lib/table/module/filter/mixin.js +12 -10
  22. package/lib/table/module/filter/mixin.min.js +1 -1
  23. package/lib/table/module/keyboard/mixin.js +184 -185
  24. package/lib/table/module/keyboard/mixin.min.js +1 -1
  25. package/lib/table/module/menu/mixin.js +20 -13
  26. package/lib/table/module/menu/mixin.min.js +1 -1
  27. package/lib/table/module/validator/mixin.js +4 -2
  28. package/lib/table/module/validator/mixin.min.js +1 -1
  29. package/lib/table/src/methods.js +388 -52
  30. package/lib/table/src/methods.min.js +1 -1
  31. package/lib/table/src/store.js +15 -0
  32. package/lib/table/src/store.min.js +1 -0
  33. package/lib/table/src/table.js +39 -9
  34. package/lib/table/src/table.min.js +1 -1
  35. package/lib/ui/index.js +1 -1
  36. package/lib/ui/index.min.js +1 -1
  37. package/lib/ui/src/log.js +1 -1
  38. package/lib/ui/src/log.min.js +1 -1
  39. package/package.json +1 -1
  40. package/packages/locale/lang/en-US.ts +12 -12
  41. package/packages/table/module/edit/mixin.ts +59 -23
  42. package/packages/table/module/filter/mixin.ts +17 -13
  43. package/packages/table/module/keyboard/mixin.ts +169 -165
  44. package/packages/table/module/menu/mixin.ts +16 -9
  45. package/packages/table/module/validator/mixin.ts +8 -4
  46. package/packages/table/src/methods.ts +362 -50
  47. package/packages/table/src/store.ts +15 -0
  48. package/packages/table/src/table.ts +37 -9
  49. /package/es/{iconfont.1755775629306.ttf → iconfont.1756272539382.ttf} +0 -0
  50. /package/es/{iconfont.1755775629306.woff → iconfont.1756272539382.woff} +0 -0
  51. /package/es/{iconfont.1755775629306.woff2 → iconfont.1756272539382.woff2} +0 -0
  52. /package/lib/{iconfont.1755775629306.ttf → iconfont.1756272539382.ttf} +0 -0
  53. /package/lib/{iconfont.1755775629306.woff → iconfont.1756272539382.woff} +0 -0
  54. /package/lib/{iconfont.1755775629306.woff2 → iconfont.1756272539382.woff2} +0 -0
@@ -7,6 +7,7 @@ import { getRowUniqueId, clearTableAllStatus, getColumnList, toFilters, getRowke
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
8
  import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime'
9
9
  import { warnLog, errLog } from '../../ui/src/log'
10
+ import { getCrossTableDragRowInfo } from './store'
10
11
 
11
12
  import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, VxeToolbarInstance, TableInternalData, VxeGridConstructor, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes, VxeGridPrivateMethods } from '../../../types'
12
13
 
@@ -19,6 +20,11 @@ const customStorageKey = 'VXE_CUSTOM_STORE'
19
20
  const maxYHeight = 5e6
20
21
  const maxXWidth = 5e6
21
22
 
23
+ let crossTableDragRowObj: {
24
+ $oldTable: VxeTableConstructor & VxeTablePrivateMethods
25
+ $newTable: (VxeTableConstructor & VxeTablePrivateMethods) | null
26
+ } | null = null
27
+
22
28
  function eqCellValue (row1: any, row2: any, field: any) {
23
29
  const val1 = XEUtils.get(row1, field)
24
30
  const val2 = XEUtils.get(row2, field)
@@ -1001,22 +1007,27 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1001
1007
  emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - osbHeight}px` : ''
1002
1008
  }
1003
1009
 
1010
+ const scrollbarXConf = scrollbarOpts.x || {}
1004
1011
  const scrollbarXToTop = $xeTable.computeScrollbarXToTop
1012
+ const scrollbarYConf = scrollbarOpts.y || {}
1005
1013
  const scrollbarYToLeft = $xeTable.computeScrollbarYToLeft
1006
1014
 
1007
1015
  let xScrollbarVisible = overflowX ? 'visible' : 'hidden'
1008
- if ($xeGanttView) {
1016
+ if (scrollbarXConf.visible === 'visible' || $xeGanttView) {
1009
1017
  osbHeight = scrollbarHeight
1010
1018
  xScrollbarVisible = 'visible'
1011
- } else if (scrollbarOpts.x && scrollbarOpts.x.visible === false) {
1019
+ } else if (scrollbarXConf.visible === 'hidden' || scrollbarXConf.visible === false) {
1012
1020
  osbHeight = 0
1013
1021
  xScrollbarVisible = 'hidden'
1014
1022
  }
1015
1023
 
1016
1024
  let yScrollbarVisible = overflowY ? 'visible' : 'hidden'
1017
- if ((scrollbarOpts.y && scrollbarOpts.y.visible === false) || ($xeGanttView && !scrollbarYToLeft)) {
1025
+ if ((scrollbarYConf.visible === 'hidden' || scrollbarYConf.visible === false) || ($xeGanttView && !scrollbarYToLeft)) {
1018
1026
  osbWidth = 0
1019
1027
  yScrollbarVisible = 'hidden'
1028
+ } else if (scrollbarYConf.visible === 'visible') {
1029
+ osbWidth = scrollbarWidth
1030
+ yScrollbarVisible = 'visible'
1020
1031
  }
1021
1032
 
1022
1033
  let tbHeight = 0
@@ -2435,6 +2446,13 @@ function handleTargetEnterEvent ($xeTable: VxeTableConstructor, isClear: boolean
2435
2446
  }
2436
2447
  }
2437
2448
 
2449
+ function clearCrossTableDragStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2450
+ const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
2451
+
2452
+ crossTableDragRowObj = null
2453
+ crossTableDragRowInfo.row = null
2454
+ }
2455
+
2438
2456
  function clearDragStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2439
2457
  const reactData = $xeTable as unknown as TableReactData
2440
2458
 
@@ -2443,6 +2461,7 @@ function clearDragStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
2443
2461
  clearColDropOrigin($xeTable)
2444
2462
  clearRowDropOrigin($xeTable)
2445
2463
  hideDropTip($xeTable)
2464
+ clearCrossTableDragStatus($xeTable)
2446
2465
  reactData.dragRow = null
2447
2466
  reactData.dragCol = null
2448
2467
  }
@@ -2642,6 +2661,28 @@ function hideDropTip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2642
2661
  }
2643
2662
  }
2644
2663
 
2664
+ function clearRowDragData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2665
+ const $xeGantt = $xeTable.$xeGantt
2666
+ const reactData = $xeTable as unknown as TableReactData
2667
+ const internalData = $xeTable as unknown as TableInternalData
2668
+
2669
+ let wrapperEl = $xeTable.$refs.refElem as HTMLDivElement
2670
+ const dtClss = ['.vxe-body--row']
2671
+ if ($xeGantt) {
2672
+ const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem as HTMLDivElement
2673
+ if (ganttContainerElem) {
2674
+ wrapperEl = ganttContainerElem
2675
+ }
2676
+ dtClss.push('.vxe-gantt-view--body-row', '.vxe-gantt-view--chart-row')
2677
+ }
2678
+ hideDropTip($xeTable)
2679
+ clearRowDropOrigin($xeTable)
2680
+ clearRowAnimate(wrapperEl, dtClss)
2681
+ internalData.prevDragToChild = false
2682
+ reactData.dragRow = null
2683
+ reactData.dragCol = null
2684
+ }
2685
+
2645
2686
  /**
2646
2687
  * 处理显示 tooltip
2647
2688
  * @param {Event} evnt 事件
@@ -4977,7 +5018,9 @@ const Methods = {
4977
5018
  }
4978
5019
  }
4979
5020
  }
4980
- return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true)
5021
+ const rest = $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true)
5022
+ clearRowDragData($xeTable)
5023
+ return rest
4981
5024
  },
4982
5025
  /**
4983
5026
  * 获取表格的全量列
@@ -6399,7 +6442,7 @@ const Methods = {
6399
6442
  !getEventTargetNode(evnt, $el).flag
6400
6443
  ) {
6401
6444
  setTimeout(() => {
6402
- this.handleClearEdit(evnt).then(() => {
6445
+ $xeTable.handleClearEdit(evnt).then(() => {
6403
6446
  // 如果存在校验,点击了表格之外则清除
6404
6447
  if (!this.isActivated && editRules && validOpts.autoClear) {
6405
6448
  this.validErrorMaps = {}
@@ -6414,17 +6457,17 @@ const Methods = {
6414
6457
  }
6415
6458
  } else if (mouseConfig) {
6416
6459
  if (!getEventTargetNode(evnt, $el).flag && !($xeGGWrapper && getEventTargetNode(evnt, $xeGGWrapper.$el).flag) && !(tableMenu && getEventTargetNode(evnt, tableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
6417
- if (this.clearSelected) {
6418
- this.clearSelected()
6460
+ if ($xeTable.clearSelected) {
6461
+ $xeTable.clearSelected()
6419
6462
  }
6420
6463
  if (areaOpts.autoClear) {
6421
- if (this.getCellAreas) {
6422
- const cellAreas = this.getCellAreas()
6464
+ if ($xeTable.getCellAreas) {
6465
+ const cellAreas = $xeTable.getCellAreas()
6423
6466
  if (cellAreas && cellAreas.length && !getEventTargetNode(evnt, document.body, 'vxe-table--ignore-areas-clear').flag) {
6424
- this.preventEvent(evnt, 'event.clearAreas', {}, () => {
6425
- this.clearCellAreas()
6426
- this.clearCopyCellArea()
6427
- this.emitEvent('clear-cell-area-selection', { cellAreas }, evnt)
6467
+ $xeTable.preventEvent(evnt, 'event.clearAreas', {}, () => {
6468
+ $xeTable.clearCellAreas()
6469
+ $xeTable.clearCopyCellArea()
6470
+ $xeTable.dispatchEvent('clear-cell-area-selection', { cellAreas }, evnt)
6428
6471
  })
6429
6472
  }
6430
6473
  }
@@ -6461,13 +6504,15 @@ const Methods = {
6461
6504
  * 表格键盘事件
6462
6505
  */
6463
6506
  keydownEvent (evnt: any) {
6507
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6508
+
6464
6509
  const { filterStore, ctxMenuStore, editStore, keyboardConfig, mouseConfig, mouseOpts, keyboardOpts } = this
6465
6510
  const { actived } = editStore
6466
6511
  const { keyCode } = evnt
6467
6512
  const isEsc = keyCode === 27
6468
6513
  if (isEsc) {
6469
6514
  this.preventEvent(evnt, 'event.keydown', null, () => {
6470
- this.emitEvent('keydown-start', {}, evnt)
6515
+ $xeTable.dispatchEvent('keydown-start', {}, evnt)
6471
6516
  if (keyboardConfig && mouseConfig && mouseOpts.area && this.handleKeyboardCellAreaEvent) {
6472
6517
  this.handleKeyboardCellAreaEvent(evnt)
6473
6518
  } else if (actived.row || filterStore.visible || ctxMenuStore.visible) {
@@ -6487,8 +6532,8 @@ const Methods = {
6487
6532
  }
6488
6533
  }
6489
6534
  }
6490
- this.emitEvent('keydown', {}, evnt)
6491
- this.emitEvent('keydown-end', {}, evnt)
6535
+ $xeTable.dispatchEvent('keydown', {}, evnt)
6536
+ $xeTable.dispatchEvent('keydown-end', {}, evnt)
6492
6537
  })
6493
6538
  }
6494
6539
  },
@@ -6796,6 +6841,8 @@ const Methods = {
6796
6841
  }
6797
6842
  },
6798
6843
  handleGlobalPasteEvent (evnt: any) {
6844
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6845
+
6799
6846
  const { isActivated, keyboardConfig, keyboardOpts, mouseConfig, mouseOpts, editStore, filterStore } = this
6800
6847
  const { actived } = editStore
6801
6848
  if (isActivated && !filterStore.visible) {
@@ -6804,10 +6851,12 @@ const Methods = {
6804
6851
  this.handlePasteCellAreaEvent(evnt)
6805
6852
  }
6806
6853
  }
6807
- this.emitEvent('paste', {}, evnt)
6854
+ $xeTable.dispatchEvent('paste', {}, evnt)
6808
6855
  }
6809
6856
  },
6810
6857
  handleGlobalCopyEvent (evnt: any) {
6858
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6859
+
6811
6860
  const { isActivated, keyboardConfig, keyboardOpts, mouseConfig, mouseOpts, editStore, filterStore } = this
6812
6861
  const { actived } = editStore
6813
6862
  if (isActivated && !filterStore.visible) {
@@ -6816,10 +6865,12 @@ const Methods = {
6816
6865
  this.handleCopyCellAreaEvent(evnt)
6817
6866
  }
6818
6867
  }
6819
- this.emitEvent('copy', {}, evnt)
6868
+ $xeTable.dispatchEvent('copy', {}, evnt)
6820
6869
  }
6821
6870
  },
6822
6871
  handleGlobalCutEvent (evnt: any) {
6872
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6873
+
6823
6874
  const { isActivated, keyboardConfig, keyboardOpts, mouseConfig, mouseOpts, editStore, filterStore } = this
6824
6875
  const { actived } = editStore
6825
6876
  if (isActivated && !filterStore.visible) {
@@ -6828,7 +6879,7 @@ const Methods = {
6828
6879
  this.handleCutCellAreaEvent(evnt)
6829
6880
  }
6830
6881
  }
6831
- this.emitEvent('cut', {}, evnt)
6882
+ $xeTable.dispatchEvent('cut', {}, evnt)
6832
6883
  }
6833
6884
  },
6834
6885
  handleGlobalResizeEvent () {
@@ -8028,7 +8079,9 @@ const Methods = {
8028
8079
  return $xeTable.$nextTick()
8029
8080
  },
8030
8081
  triggerHeaderCellDblclickEvent (evnt: any, params: any) {
8031
- this.emitEvent('header-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, params), evnt)
8082
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8083
+
8084
+ $xeTable.dispatchEvent('header-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, params), evnt)
8032
8085
  },
8033
8086
  getCurrentColumn () {
8034
8087
  return this.columnOpts.isCurrent || this.highlightCurrentColumn ? this.currentColumn : null
@@ -8213,7 +8266,7 @@ const Methods = {
8213
8266
  }
8214
8267
  }
8215
8268
  }
8216
- this.emitEvent('cell-dblclick', params, evnt)
8269
+ $xeTable.dispatchEvent('cell-dblclick', params, evnt)
8217
8270
  },
8218
8271
  handleColumnSortEvent (evnt: any, column: any) {
8219
8272
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -8659,9 +8712,237 @@ const Methods = {
8659
8712
  }
8660
8713
  return Promise.resolve(errRest)
8661
8714
  },
8662
- handleRowDragDragendEvent (evnt: DragEvent) {
8715
+ /**
8716
+ * 处理跨表拖拽完成
8717
+ */
8718
+ handleCrossTableRowDragFinishEvent (evnt: DragEvent) {
8663
8719
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8664
8720
  const $xeGantt = $xeTable.$xeGantt
8721
+ const reactData = $xeTable as unknown as TableReactData
8722
+ const internalData = $xeTable as unknown as TableInternalData
8723
+ const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
8724
+
8725
+ const { tableData } = reactData
8726
+ const { fullAllDataRowIdData } = internalData
8727
+ const rowOpts = $xeTable.computeRowOpts
8728
+ const cellOpts = $xeTable.computeCellOpts
8729
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight
8730
+ const rowDragOpts = $xeTable.computeRowDragOpts
8731
+ const { animation, isCrossTableDrag } = rowDragOpts
8732
+ const treeOpts = $xeTable.computeTreeOpts
8733
+ const { mapChildrenField } = treeOpts
8734
+ const el = $xeTable.$refs.refElem as HTMLDivElement
8735
+ if (isCrossTableDrag && crossTableDragRowObj && crossTableDragRowInfo) {
8736
+ const { row: dragRow } = crossTableDragRowInfo
8737
+ if (dragRow) {
8738
+ const dragRowid = getRowid($xeTable, dragRow)
8739
+ const dragRowRest = fullAllDataRowIdData[dragRowid]
8740
+ let dragRowHeight = 0
8741
+ let rsIndex = -1
8742
+ if (dragRowRest) {
8743
+ if (animation) {
8744
+ dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight)
8745
+ }
8746
+ rsIndex = dragRowRest.$index
8747
+ }
8748
+ const dragRangeList = rsIndex > -1 && rsIndex < tableData.length - 1 ? tableData.slice(rsIndex + 1) : []
8749
+ const dragList = XEUtils.toTreeArray([dragRow], {
8750
+ updated: true,
8751
+ children: mapChildrenField
8752
+ })
8753
+ $xeTable.remove(dragList).then(() => {
8754
+ if (animation && dragRowHeight && dragRangeList.length) {
8755
+ const $xeGanttView = internalData.xeGanttView
8756
+ let wrapperEl = el
8757
+ if ($xeGantt && $xeGanttView) {
8758
+ const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem as HTMLDivElement
8759
+ if (ganttContainerElem) {
8760
+ wrapperEl = ganttContainerElem
8761
+ }
8762
+ }
8763
+
8764
+ const dtClss: string[] = []
8765
+ dragRangeList.forEach(row => {
8766
+ const rowid = getRowid($xeTable, row)
8767
+ dtClss.push(`.vxe-body--row[rowid="${rowid}"]`)
8768
+ if ($xeGantt) {
8769
+ dtClss.push(`.vxe-gantt-view--body-row[rowid="${rowid}"]`, `.vxe-gantt-view--chart-row[rowid="${rowid}"]`)
8770
+ }
8771
+ })
8772
+ const dtTrList = wrapperEl.querySelectorAll<HTMLElement>(dtClss.join(','))
8773
+ moveRowAnimateToTb(dtTrList, dragRowHeight)
8774
+ }
8775
+ })
8776
+ $xeTable.dispatchEvent('row-remove-dragend', {
8777
+ row: dragRow
8778
+ }, evnt)
8779
+ clearRowDragData($xeTable)
8780
+ clearCrossTableDragStatus($xeTable)
8781
+ }
8782
+ }
8783
+ },
8784
+ /**
8785
+ * 处理跨表拖至新的空表
8786
+ */
8787
+ handleCrossTableRowDragoverEmptyEvent (evnt: DragEvent) {
8788
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8789
+ const reactData = $xeTable as unknown as TableReactData
8790
+ const internalData = $xeTable as unknown as TableInternalData
8791
+
8792
+ const { tableData } = reactData
8793
+ const rowDragOpts = $xeTable.computeRowDragOpts
8794
+ const { isCrossTableDrag } = rowDragOpts
8795
+ if (isCrossTableDrag && crossTableDragRowObj && !tableData.length) {
8796
+ const { $oldTable } = crossTableDragRowObj
8797
+ if ($oldTable && $oldTable.xID !== $xeTable.xID) {
8798
+ evnt.preventDefault()
8799
+ crossTableDragRowObj.$newTable = $xeTable
8800
+ internalData.prevDragRow = null
8801
+ }
8802
+ }
8803
+ },
8804
+ /**
8805
+ * 处理跨表拖插入
8806
+ */
8807
+ handleCrossTableRowDragInsertEvent (evnt: DragEvent) {
8808
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8809
+ const $xeGantt = $xeTable.$xeGantt
8810
+ const props = $xeTable
8811
+ const reactData = $xeTable as unknown as TableReactData
8812
+ const internalData = $xeTable as unknown as TableInternalData
8813
+ const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
8814
+
8815
+ const { treeConfig } = props
8816
+ const { prevDragRow, prevDragPos, prevDragToChild } = internalData
8817
+ const rowDragOpts = $xeTable.computeRowDragOpts
8818
+ const { animation, isSelfToChildDrag, isCrossTableDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
8819
+ const rowOpts = $xeTable.computeRowOpts
8820
+ const cellOpts = $xeTable.computeCellOpts
8821
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight
8822
+ const treeOpts = $xeTable.computeTreeOpts
8823
+ const { parentField, mapChildrenField } = treeOpts
8824
+ const childrenField = treeOpts.children || treeOpts.childrenField
8825
+ // 跨表拖拽
8826
+ if (isCrossTableDrag && crossTableDragRowObj && crossTableDragRowInfo) {
8827
+ const { row: oldRow } = crossTableDragRowInfo
8828
+ const { $oldTable } = crossTableDragRowObj
8829
+ const el = $xeTable.$refs.refElem as HTMLDivElement
8830
+ if ($oldTable && oldRow) {
8831
+ const dragRow = oldRow
8832
+ let dragOffsetIndex = -1
8833
+ if (prevDragRow) {
8834
+ dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
8835
+ }
8836
+ const dragParams = {
8837
+ oldRow: dragRow,
8838
+ newRow: prevDragRow,
8839
+ dragRow,
8840
+ dragPos: prevDragPos as 'top' | 'bottom',
8841
+ dragToChild: !!prevDragToChild,
8842
+ offsetIndex: dragOffsetIndex as 0 | 1
8843
+ }
8844
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
8845
+ const errRest = {
8846
+ status: false
8847
+ }
8848
+ Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
8849
+ if (!status) {
8850
+ return errRest
8851
+ }
8852
+ let insertRest: Promise<any> = Promise.resolve()
8853
+ if (treeConfig) {
8854
+ const dragList = XEUtils.toTreeArray([dragRow], {
8855
+ updated: true,
8856
+ children: mapChildrenField
8857
+ })
8858
+ $oldTable.handleCrossTableRowDragFinishEvent(evnt)
8859
+ if (prevDragRow) {
8860
+ dragRow[parentField] = prevDragRow[parentField]
8861
+ } else {
8862
+ dragRow[parentField] = null
8863
+ }
8864
+ dragList.forEach(row => {
8865
+ row[childrenField] = undefined
8866
+ row[mapChildrenField] = undefined
8867
+ })
8868
+ if (prevDragRow) {
8869
+ if (prevDragPos === 'bottom') {
8870
+ insertRest = $xeTable.insertNextAt(dragList, prevDragRow)
8871
+ } else {
8872
+ insertRest = $xeTable.insertAt(dragList, prevDragRow)
8873
+ }
8874
+ } else {
8875
+ insertRest = $xeTable.insert(dragList)
8876
+ }
8877
+ } else {
8878
+ $oldTable.handleCrossTableRowDragFinishEvent(evnt)
8879
+ if (prevDragRow) {
8880
+ if (prevDragPos === 'bottom') {
8881
+ insertRest = $xeTable.insertNextAt(dragRow, prevDragRow)
8882
+ } else {
8883
+ insertRest = $xeTable.insertAt(dragRow, prevDragRow)
8884
+ }
8885
+ } else {
8886
+ insertRest = $xeTable.insert(dragRow)
8887
+ }
8888
+ }
8889
+ $xeTable.dispatchEvent('row-insert-dragend', {
8890
+ oldRow,
8891
+ newRow: prevDragRow,
8892
+ dragRow,
8893
+ dragPos: prevDragPos as any,
8894
+ dragToChild: isDragToChildFlag,
8895
+ offsetIndex: dragOffsetIndex
8896
+ }, evnt)
8897
+ clearRowDragData($xeTable)
8898
+
8899
+ insertRest.then(() => {
8900
+ const { tableData } = reactData
8901
+ const { fullAllDataRowIdData } = internalData
8902
+ const oldRowid = getRowid($xeTable, dragRow)
8903
+ const oldRowRest = fullAllDataRowIdData[oldRowid]
8904
+ let dragRowHeight = 0
8905
+ let rsIndex = -1
8906
+ if (oldRowRest) {
8907
+ if (animation) {
8908
+ dragRowHeight = getCellRestHeight(oldRowRest, cellOpts, rowOpts, defaultRowHeight)
8909
+ }
8910
+ rsIndex = oldRowRest.$index
8911
+ }
8912
+ const dragRangeList = rsIndex > -1 ? tableData.slice(rsIndex) : []
8913
+ if (animation && dragRowHeight && dragRangeList.length) {
8914
+ const $xeGanttView = internalData.xeGanttView
8915
+ let wrapperEl = el
8916
+ if ($xeGantt && $xeGanttView) {
8917
+ const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem as HTMLDivElement
8918
+ if (ganttContainerElem) {
8919
+ wrapperEl = ganttContainerElem
8920
+ }
8921
+ }
8922
+
8923
+ const dtClss: string[] = []
8924
+ dragRangeList.forEach(row => {
8925
+ const rowid = getRowid($xeTable, row)
8926
+ dtClss.push(`.vxe-body--row[rowid="${rowid}"]`)
8927
+ if ($xeGantt) {
8928
+ dtClss.push(`.vxe-gantt-view--body-row[rowid="${rowid}"]`, `.vxe-gantt-view--chart-row[rowid="${rowid}"]`)
8929
+ }
8930
+ })
8931
+ const dtTrList = wrapperEl.querySelectorAll<HTMLElement>(dtClss.join(','))
8932
+ moveRowAnimateToTb(dtTrList, -dragRowHeight)
8933
+ }
8934
+ })
8935
+ })
8936
+ }
8937
+ }
8938
+ },
8939
+ hideCrossTableRowDropClearStatus () {
8940
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8941
+
8942
+ hideDropTip($xeTable)
8943
+ },
8944
+ handleRowDragDragendEvent (evnt: DragEvent) {
8945
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8665
8946
  const props = $xeTable
8666
8947
  const reactData = $xeTable as unknown as TableReactData
8667
8948
  const internalData = $xeTable as unknown as TableInternalData
@@ -8673,8 +8954,18 @@ const Methods = {
8673
8954
  const { lazy } = treeOpts
8674
8955
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
8675
8956
  const { prevDragRow, prevDragPos } = internalData
8676
- let wrapperEl = $xeTable.$refs.refElem as HTMLDivElement
8677
-
8957
+ const rowDragOpts = $xeTable.computeRowDragOpts
8958
+ const { isCrossTableDrag, isCrossDrag } = rowDragOpts
8959
+ // 跨表拖拽
8960
+ if (isCrossTableDrag && crossTableDragRowObj) {
8961
+ const { $newTable } = crossTableDragRowObj
8962
+ if ($newTable && $newTable.xID !== $xeTable.xID) {
8963
+ if (!treeConfig || isCrossDrag) {
8964
+ $newTable.handleCrossTableRowDragInsertEvent(evnt)
8965
+ }
8966
+ return
8967
+ }
8968
+ }
8678
8969
  if (treeConfig && lazy && prevDragToChild) {
8679
8970
  // 懒加载
8680
8971
  const newRowid = getRowid($xeTable, prevDragRow)
@@ -8689,20 +8980,8 @@ const Methods = {
8689
8980
  } else {
8690
8981
  $xeTable.handleRowDragSwapEvent(evnt, true, dragRow, prevDragRow, prevDragPos, prevDragToChild)
8691
8982
  }
8692
- const dtClss = ['.vxe-body--row']
8693
- if ($xeGantt) {
8694
- const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem as HTMLDivElement
8695
- if (ganttContainerElem) {
8696
- wrapperEl = ganttContainerElem
8697
- }
8698
- dtClss.push('.vxe-gantt-view--body-row', '.vxe-gantt-view--chart-row')
8699
- }
8700
- hideDropTip($xeTable)
8701
- clearRowDropOrigin($xeTable)
8702
- clearRowAnimate(wrapperEl, dtClss)
8703
- internalData.prevDragToChild = false
8704
- reactData.dragRow = null
8705
- reactData.dragCol = null
8983
+ clearRowDragData($xeTable)
8984
+ clearCrossTableDragStatus($xeTable)
8706
8985
  },
8707
8986
  handleRowDragDragoverEvent (evnt: DragEvent) {
8708
8987
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -8717,8 +8996,8 @@ const Methods = {
8717
8996
  const { lazy, transform, parentField } = treeOpts
8718
8997
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
8719
8998
  const rowDragOpts = $xeTable.computeRowDragOpts
8720
- const { isPeerDrag, isCrossDrag, isToChildDrag } = rowDragOpts
8721
- if (!dragRow) {
8999
+ const { isPeerDrag, isCrossDrag, isToChildDrag, isCrossTableDrag } = rowDragOpts
9000
+ if (!dragRow && !(isCrossTableDrag && (!treeConfig || isCrossDrag) && crossTableDragRowObj)) {
8722
9001
  evnt.preventDefault()
8723
9002
  return
8724
9003
  }
@@ -8727,19 +9006,40 @@ const Methods = {
8727
9006
  const rowid = trEl.getAttribute('rowid') || ''
8728
9007
  const rest = fullAllDataRowIdData[rowid]
8729
9008
  if (rest) {
9009
+ evnt.preventDefault()
8730
9010
  const row = rest.row
8731
9011
  const rowid = getRowid($xeTable, row)
8732
9012
  const rowRest = fullAllDataRowIdData[rowid]
8733
- evnt.preventDefault()
8734
- const { dragRow } = reactData
8735
9013
  const offsetY = evnt.clientY - trEl.getBoundingClientRect().y
8736
9014
  const dragPos = offsetY < trEl.clientHeight / 2 ? 'top' : 'bottom'
8737
- internalData.prevDragToChild = !!(treeConfig && transform && isToChildDrag && isControlKey)
9015
+ internalData.prevDragToChild = !!(treeConfig && transform && (isCrossDrag && isToChildDrag) && isControlKey)
8738
9016
  internalData.prevDragRow = row
8739
9017
  internalData.prevDragPos = dragPos
9018
+ // 跨表拖拽
9019
+ if (isCrossTableDrag && (!treeConfig || isCrossDrag) && crossTableDragRowObj) {
9020
+ const { $oldTable, $newTable } = crossTableDragRowObj
9021
+ if ($oldTable) {
9022
+ const oldTableReactData = $oldTable as unknown as TableReactData
9023
+ if ($oldTable.xID === $xeTable.xID) {
9024
+ if ($newTable) {
9025
+ $newTable.hideCrossTableRowDropClearStatus()
9026
+ }
9027
+ reactData.isCrossDragRow = false
9028
+ oldTableReactData.isCrossDragRow = false
9029
+ crossTableDragRowObj.$newTable = null
9030
+ } else if (!treeConfig || isCrossDrag) {
9031
+ $oldTable.hideCrossTableRowDropClearStatus()
9032
+ oldTableReactData.isCrossDragRow = true
9033
+ reactData.dragTipText = oldTableReactData.dragTipText
9034
+ crossTableDragRowObj.$newTable = $xeTable
9035
+ showDropTip($xeTable, evnt, trEl, null, true, dragPos)
9036
+ return
9037
+ }
9038
+ }
9039
+ }
8740
9040
  if ($xeTable.eqRow(dragRow, row) ||
8741
- (isControlKey && treeConfig && lazy && row[hasChildField] && rowRest && !rowRest.treeLoaded) ||
8742
- (!isCrossDrag && treeConfig && transform && (isPeerDrag ? dragRow[parentField] !== row[parentField] : rest.level))
9041
+ (isControlKey && treeConfig && lazy && row[hasChildField] && rowRest && !rowRest.treeLoaded) ||
9042
+ (!isCrossDrag && treeConfig && transform && (isPeerDrag ? dragRow[parentField] !== row[parentField] : rest.level))
8743
9043
  ) {
8744
9044
  showDropTip($xeTable, evnt, trEl, null, false, dragPos)
8745
9045
  return
@@ -8752,15 +9052,19 @@ const Methods = {
8752
9052
  }, evnt)
8753
9053
  }
8754
9054
  },
8755
- handleCellDragMousedownEvent (evnt: MouseEvent, params: any) {
9055
+ handleCellDragMousedownEvent (evnt: DragEvent, params: {
9056
+ row: any;
9057
+ column: VxeTableDefines.ColumnInfo<any>;
9058
+ }) {
8756
9059
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8757
9060
  const props = $xeTable
8758
9061
  const reactData = $xeTable as unknown as TableReactData
9062
+ const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
8759
9063
 
8760
9064
  evnt.stopPropagation()
8761
9065
  const { dragConfig } = props
8762
9066
  const rowDragOpts = $xeTable.computeRowDragOpts
8763
- const { trigger, dragStartMethod } = rowDragOpts
9067
+ const { isCrossTableDrag, trigger, dragStartMethod } = rowDragOpts
8764
9068
  const { row } = params
8765
9069
  const dragEl = evnt.currentTarget as HTMLElement
8766
9070
  const tdEl = trigger === 'cell' || trigger === 'row' ? dragEl : dragEl.parentElement?.parentElement as HTMLElement
@@ -8771,10 +9075,16 @@ const Methods = {
8771
9075
  trEl.draggable = false
8772
9076
  reactData.dragRow = null
8773
9077
  reactData.dragCol = null
9078
+ clearCrossTableDragStatus($xeTable)
8774
9079
  hideDropTip($xeTable)
8775
9080
  return
8776
9081
  }
9082
+ if (isCrossTableDrag) {
9083
+ crossTableDragRowInfo.row = row
9084
+ crossTableDragRowObj = { $oldTable: $xeTable, $newTable: null }
9085
+ }
8777
9086
  reactData.dragRow = row
9087
+ reactData.isCrossDragRow = false
8778
9088
  reactData.dragCol = null
8779
9089
  trEl.draggable = true
8780
9090
  updateRowDropOrigin($xeTable, row)
@@ -9113,6 +9423,7 @@ const Methods = {
9113
9423
  internalData.prevDragToChild = false
9114
9424
  reactData.dragRow = null
9115
9425
  reactData.dragCol = null
9426
+ clearCrossTableDragStatus($xeTable)
9116
9427
  },
9117
9428
  handleHeaderCellDragDragoverEvent (evnt: DragEvent) {
9118
9429
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -9199,11 +9510,13 @@ const Methods = {
9199
9510
  reactData.dragRow = null
9200
9511
  reactData.dragCol = null
9201
9512
  hideDropTip($xeTable)
9513
+ clearCrossTableDragStatus($xeTable)
9202
9514
  return
9203
9515
  }
9204
9516
  reactData.dragCol = column
9205
9517
  reactData.dragRow = null
9206
9518
  thEl.draggable = true
9519
+ clearCrossTableDragStatus($xeTable)
9207
9520
  updateColDropOrigin($xeTable, column)
9208
9521
  updateColDropTipContent($xeTable, thEl)
9209
9522
  $xeTable.dispatchEvent('column-dragstart', params, evnt)
@@ -9214,6 +9527,7 @@ const Methods = {
9214
9527
 
9215
9528
  clearColDropOrigin($xeTable)
9216
9529
  hideDropTip($xeTable)
9530
+ clearCrossTableDragStatus($xeTable)
9217
9531
  reactData.dragRow = null
9218
9532
  reactData.dragCol = null
9219
9533
  },
@@ -11377,10 +11691,8 @@ const Methods = {
11377
11691
  // 已废弃,使用 dispatchEvent
11378
11692
  emitEvent (type: any, params: any, evnt: any) {
11379
11693
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
11380
- const $xeGrid = $xeTable.$xeGrid
11381
- const $xeGantt = $xeTable.$xeGantt
11382
11694
 
11383
- $xeTable.$emit(type, createEvent(evnt, { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, $event: evnt }))
11695
+ $xeTable.dispatchEvent(type, params, evnt)
11384
11696
  },
11385
11697
  focus () {
11386
11698
  this.isActivated = true
@@ -0,0 +1,15 @@
1
+ import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types'
2
+
3
+ interface CrossTableDragRowObj {
4
+ row: any
5
+ }
6
+
7
+ // 跨表拖拽
8
+ export const crossTableDragRowGlobal: CrossTableDragRowObj = {
9
+ row: null
10
+ }
11
+
12
+ export function getCrossTableDragRowInfo ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
13
+ const crossTableDragRowInfo = ($xeTable as any).crossTableDragRowInfo as CrossTableDragRowObj
14
+ return crossTableDragRowInfo
15
+ }