vxe-table 3.10.7 → 3.10.8

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.
@@ -74,16 +74,20 @@ function renderCellDragIcon (h: CreateElement, params: any) {
74
74
  }
75
75
 
76
76
  function renderCellBaseVNs (h: CreateElement, params: any, content: any) {
77
- const { $table, column, row } = params
77
+ const { $table, column, row, level } = params
78
78
  const { dragSort } = column
79
- const vns: any[] = XEUtils.isArray(content) ? content : [content]
79
+ const tableProps = $table
80
+ const { treeConfig } = tableProps
80
81
  const rowOpts = $table.computeRowOpts
81
82
  const dragOpts = $table.computeDragOpts
82
83
  const { showRowIcon, rowVisibleMethod } = dragOpts
84
+ const vns: any[] = XEUtils.isArray(content) ? content : [content]
83
85
  if (dragSort && rowOpts.drag && (showRowIcon && (!rowVisibleMethod || rowVisibleMethod({ row, column })))) {
84
- vns.unshift(
85
- renderCellDragIcon(h, params)
86
- )
86
+ if (!treeConfig || !level) {
87
+ vns.unshift(
88
+ renderCellDragIcon(h, params)
89
+ )
90
+ }
87
91
  }
88
92
  return vns
89
93
  }
@@ -56,7 +56,7 @@ export default {
56
56
  },
57
57
  render (h: CreateElement) {
58
58
  const { _e, $parent: $xetable, fixedType, headerColumn, tableColumn, fixedColumn } = this
59
- const { $listeners: tableListeners, tId, isGroup, visibleColumn, resizable, border, columnKey, headerRowClassName, headerCellClassName, headerRowStyle, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, highlightCurrentColumn, currentColumn, scrollXLoad, overflowX, scrollbarWidth, sortOpts, mouseConfig, columnOpts } = $xetable
59
+ const { $listeners: tableListeners, tId, isGroup, visibleColumn, resizable: allResizable, border, columnKey, headerRowClassName, headerCellClassName, headerRowStyle, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, highlightCurrentColumn, currentColumn, scrollXLoad, overflowX, scrollbarWidth, sortOpts, mouseConfig, columnOpts } = $xetable
60
60
  let headerGroups = headerColumn
61
61
  let renderColumnList = tableColumn
62
62
  if (isGroup) {
@@ -188,7 +188,7 @@ export default {
188
188
  /**
189
189
  * 列宽拖动
190
190
  */
191
- !fixedHiddenColumn && !isColGroup && (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || resizable))
191
+ !fixedHiddenColumn && !isColGroup && (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
192
192
  ? h('div', {
193
193
  class: ['vxe-resizable', {
194
194
  'is--line': !border || border === 'none'
@@ -339,6 +339,17 @@ function clearRowDropOrigin ($xeTable: any) {
339
339
  }
340
340
  }
341
341
 
342
+ function updateRowDropOrigin ($xeTable: any, row: any) {
343
+ const el = $xeTable.$el
344
+ if (el) {
345
+ const clss = 'row--drag-origin'
346
+ const rowid = getRowid($xeTable, row)
347
+ XEUtils.arrayEach(el.querySelectorAll(`[rowid="${rowid}"]`), (elem) => {
348
+ addClass(elem, clss)
349
+ })
350
+ }
351
+ }
352
+
342
353
  function clearRowDropTarget ($xeTable: any) {
343
354
  const el = $xeTable.$el
344
355
  if (el) {
@@ -349,6 +360,18 @@ function clearRowDropTarget ($xeTable: any) {
349
360
  }
350
361
  }
351
362
 
363
+ function updateRowDropTarget ($xeTable: any, row: any, dragPos: string) {
364
+ const el = $xeTable.$el
365
+ if (el) {
366
+ const clss = 'row--drag-active-target'
367
+ const rowid = getRowid($xeTable, row)
368
+ XEUtils.arrayEach(el.querySelectorAll(`[rowid="${rowid}"]`), (elem: any) => {
369
+ addClass(elem, clss)
370
+ elem.setAttribute('drag-pos', dragPos)
371
+ })
372
+ }
373
+ }
374
+
352
375
  function showRowDropTip (evnt: DragEvent | MouseEvent, $xeTable: any) {
353
376
  const rdTipEl = $xeTable.$refs.refRowDragTipElem as HTMLDivElement
354
377
  if (!rdTipEl) {
@@ -4588,7 +4611,7 @@ const Methods = {
4588
4611
  const treeOpts = $xeTable.computeTreeOpts
4589
4612
  const { transform } = treeOpts
4590
4613
  const { dragRow } = reactData
4591
- const { afterFullData, tableFullData, prevDragRow, prevDragPos } = internalData
4614
+ const { afterFullData, afterTreeFullData, tableFullData, tableFullTreeData, prevDragRow, prevDragPos } = internalData
4592
4615
  if (prevDragRow && dragRow) {
4593
4616
  // 判断是否有拖动
4594
4617
  if (prevDragRow !== dragRow) {
@@ -4605,18 +4628,36 @@ const Methods = {
4605
4628
  }
4606
4629
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
4607
4630
 
4608
- // 移出源位置
4609
- const oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
4610
- const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
4611
- afterFullData.splice(oafIndex, 1)
4612
- tableFullData.splice(otfIndex, 1)
4613
- // 插新位置
4614
- const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
4615
- const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
4616
- const nafIndex = pafIndex + dragOffsetIndex
4617
- const ntfIndex = ptfIndex + dragOffsetIndex
4618
- afterFullData.splice(nafIndex, 0, dragRow)
4619
- tableFullData.splice(ntfIndex, 0, dragRow)
4631
+ let oafIndex = -1
4632
+ let nafIndex = -1
4633
+ if (treeConfig) {
4634
+ // 移出源位置
4635
+ oafIndex = $xeTable.findRowIndexOf(afterTreeFullData, dragRow)
4636
+ const otfIndex = $xeTable.findRowIndexOf(tableFullTreeData, dragRow)
4637
+ afterTreeFullData.splice(oafIndex, 1)
4638
+ tableFullTreeData.splice(otfIndex, 1)
4639
+
4640
+ // 插新位置
4641
+ const pafIndex = $xeTable.findRowIndexOf(afterTreeFullData, prevDragRow)
4642
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullTreeData, prevDragRow)
4643
+ nafIndex = pafIndex + dragOffsetIndex
4644
+ const ntfIndex = ptfIndex + dragOffsetIndex
4645
+ afterTreeFullData.splice(nafIndex, 0, dragRow)
4646
+ tableFullTreeData.splice(ntfIndex, 0, dragRow)
4647
+ } else {
4648
+ // 移出源位置
4649
+ oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow)
4650
+ const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow)
4651
+ afterFullData.splice(oafIndex, 1)
4652
+ tableFullData.splice(otfIndex, 1)
4653
+ // 插新位置
4654
+ const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow)
4655
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow)
4656
+ nafIndex = pafIndex + dragOffsetIndex
4657
+ const ntfIndex = ptfIndex + dragOffsetIndex
4658
+ afterFullData.splice(nafIndex, 0, dragRow)
4659
+ tableFullData.splice(ntfIndex, 0, dragRow)
4660
+ }
4620
4661
 
4621
4662
  reactData.isDragRowMove = true
4622
4663
  $xeTable.cacheRowMap()
@@ -4670,8 +4711,7 @@ const Methods = {
4670
4711
  const { dragRow } = reactData
4671
4712
  const offsetY = evnt.clientY - trEl.getBoundingClientRect().y
4672
4713
  const dragPos = offsetY < trEl.clientHeight / 2 ? 'top' : 'bottom'
4673
- addClass(trEl, 'row--drag-active-target')
4674
- trEl.setAttribute('drag-pos', dragPos)
4714
+ updateRowDropTarget($xeTable, row, dragPos)
4675
4715
  internalData.prevDragRow = row
4676
4716
  internalData.prevDragPos = dragPos
4677
4717
  $xeTable.dispatchEvent('row-dragover', {
@@ -4703,7 +4743,7 @@ const Methods = {
4703
4743
  }
4704
4744
  reactData.dragRow = row
4705
4745
  trEl.draggable = true
4706
- addClass(trEl, 'row--drag-origin')
4746
+ updateRowDropOrigin($xeTable, row)
4707
4747
  showRowDropTip(evnt, $xeTable)
4708
4748
  updateRowDropTipContent($xeTable, tdEl)
4709
4749
  $xeTable.dispatchEvent('row-dragstart', params, evnt)