vxe-table 3.10.16 → 3.11.0
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.
- package/README.md +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/custom/mixin.js +5 -1
- package/es/table/module/edit/mixin.js +24 -15
- package/es/table/src/body.js +40 -24
- package/es/table/src/cell.js +75 -32
- package/es/table/src/footer.js +159 -131
- package/es/table/src/header.js +128 -90
- package/es/table/src/methods.js +284 -65
- package/es/table/src/props.js +5 -1
- package/es/table/src/table.js +64 -20
- package/es/table/style.css +33 -20
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +9 -4
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +33 -20
- package/es/vxe-table/style.min.css +1 -1
- package/helper/vetur/attributes.json +1 -1
- package/helper/vetur/tags.json +1 -1
- package/lib/index.umd.js +906 -449
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/custom/mixin.js +5 -1
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/module/edit/mixin.js +24 -15
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/src/body.js +31 -15
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +82 -35
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/footer.js +198 -161
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +169 -128
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +313 -68
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +5 -1
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +70 -20
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/style/style.css +33 -20
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +9 -4
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +33 -20
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +3 -3
- package/packages/table/module/custom/mixin.ts +5 -1
- package/packages/table/module/edit/mixin.ts +24 -15
- package/packages/table/src/body.ts +43 -25
- package/packages/table/src/cell.ts +120 -67
- package/packages/table/src/footer.ts +164 -150
- package/packages/table/src/header.ts +136 -90
- package/packages/table/src/methods.ts +296 -67
- package/packages/table/src/props.ts +5 -1
- package/packages/table/src/table.ts +71 -19
- package/packages/ui/index.ts +8 -3
- package/styles/components/table.scss +42 -35
- /package/es/{iconfont.1731633464058.ttf → iconfont.1731890707082.ttf} +0 -0
- /package/es/{iconfont.1731633464058.woff → iconfont.1731890707082.woff} +0 -0
- /package/es/{iconfont.1731633464058.woff2 → iconfont.1731890707082.woff2} +0 -0
- /package/lib/{iconfont.1731633464058.ttf → iconfont.1731890707082.ttf} +0 -0
- /package/lib/{iconfont.1731633464058.woff → iconfont.1731890707082.woff} +0 -0
- /package/lib/{iconfont.1731633464058.woff2 → iconfont.1731890707082.woff2} +0 -0
|
@@ -350,67 +350,119 @@ function updateRowDropOrigin ($xeTable: any, row: any) {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
|
|
354
|
-
const
|
|
353
|
+
const updateRowDropTipContent = ($xeTable: any, tdEl: HTMLElement) => {
|
|
354
|
+
const reactData = $xeTable
|
|
355
|
+
const props = $xeTable
|
|
356
|
+
|
|
357
|
+
const { dragConfig } = props
|
|
358
|
+
const { dragRow } = reactData
|
|
359
|
+
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
360
|
+
const { tooltipMethod } = rowDragOpts
|
|
361
|
+
const rTooltipMethod = tooltipMethod || (dragConfig ? dragConfig.rowTooltipMethod : null)
|
|
362
|
+
let tipContent = ''
|
|
363
|
+
if (rTooltipMethod) {
|
|
364
|
+
tipContent = `${rTooltipMethod({
|
|
365
|
+
row: dragRow
|
|
366
|
+
}) || ''}`
|
|
367
|
+
} else {
|
|
368
|
+
tipContent = getI18n('vxe.table.dragTip', [tdEl.textContent || ''])
|
|
369
|
+
}
|
|
370
|
+
reactData.dragTipText = tipContent
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const updateColDropOrigin = ($xeTable: any, column: VxeTableDefines.ColumnInfo) => {
|
|
374
|
+
const el = $xeTable.$el as HTMLElement
|
|
355
375
|
if (el) {
|
|
356
|
-
const clss = '
|
|
357
|
-
XEUtils.arrayEach(el.querySelectorAll(
|
|
358
|
-
|
|
376
|
+
const clss = 'col--drag-origin'
|
|
377
|
+
XEUtils.arrayEach(el.querySelectorAll(`[colid="${column.id}"]`), (elem) => {
|
|
378
|
+
addClass(elem, clss)
|
|
359
379
|
})
|
|
360
380
|
}
|
|
361
381
|
}
|
|
362
382
|
|
|
363
|
-
|
|
364
|
-
const el = $xeTable.$el
|
|
383
|
+
const clearColDropOrigin = ($xeTable: any) => {
|
|
384
|
+
const el = $xeTable.$el as HTMLElement
|
|
365
385
|
if (el) {
|
|
366
|
-
const clss = '
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
elem.setAttribute('drag-pos', dragPos)
|
|
386
|
+
const clss = 'col--drag-origin'
|
|
387
|
+
XEUtils.arrayEach(el.querySelectorAll(`.${clss}`), (elem) => {
|
|
388
|
+
(elem as HTMLTableCellElement).draggable = false
|
|
389
|
+
removeClass(elem, clss)
|
|
371
390
|
})
|
|
372
391
|
}
|
|
373
392
|
}
|
|
374
393
|
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
394
|
+
const updateColDropTipContent = ($xeTable: any, tdEl: HTMLElement) => {
|
|
395
|
+
const reactData = $xeTable
|
|
396
|
+
|
|
397
|
+
const { dragCol } = reactData
|
|
398
|
+
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
399
|
+
const { tooltipMethod } = columnDragOpts
|
|
400
|
+
let tipContent = ''
|
|
401
|
+
if (tooltipMethod) {
|
|
402
|
+
tipContent = `${tooltipMethod({
|
|
403
|
+
column: dragCol
|
|
404
|
+
}) || ''}`
|
|
405
|
+
} else {
|
|
406
|
+
tipContent = getI18n('vxe.table.dragTip', [tdEl.textContent || ''])
|
|
379
407
|
}
|
|
380
|
-
|
|
408
|
+
reactData.dragTipText = tipContent
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function showDropTip ($xeTable: any, evnt: DragEvent | MouseEvent, trEl: HTMLElement | null, thEl: HTMLElement | null, dragPos: string) {
|
|
412
|
+
const reactData = $xeTable
|
|
413
|
+
|
|
414
|
+
const el = $xeTable.$refs.refElem as HTMLElement
|
|
381
415
|
if (!el) {
|
|
382
416
|
return
|
|
383
417
|
}
|
|
418
|
+
const { scrollbarWidth, scrollbarHeight } = reactData
|
|
419
|
+
const wrapperRect = el.getBoundingClientRect()
|
|
420
|
+
if (trEl) {
|
|
421
|
+
const rdLineEl = $xeTable.$refs.refDragRowLineElem as HTMLElement
|
|
422
|
+
if (rdLineEl) {
|
|
423
|
+
const trRect = trEl.getBoundingClientRect()
|
|
424
|
+
let top = Math.max(1, trRect.y - wrapperRect.y)
|
|
425
|
+
if (dragPos === 'bottom') {
|
|
426
|
+
top = Math.min(wrapperRect.height - 1, trRect.y - wrapperRect.y + trRect.height)
|
|
427
|
+
}
|
|
428
|
+
rdLineEl.style.top = `${top}px`
|
|
429
|
+
rdLineEl.style.width = `${wrapperRect.width - scrollbarWidth}px`
|
|
430
|
+
rdLineEl.style.display = 'block'
|
|
431
|
+
}
|
|
432
|
+
} else if (thEl) {
|
|
433
|
+
const cdLineEl = $xeTable.$refs.refDragColLineElem as HTMLElement
|
|
434
|
+
if (cdLineEl) {
|
|
435
|
+
const thRect = thEl.getBoundingClientRect()
|
|
436
|
+
let left = Math.max(1, thRect.x - wrapperRect.x)
|
|
437
|
+
if (dragPos === 'right') {
|
|
438
|
+
left = Math.min(wrapperRect.width - 2, thRect.x - wrapperRect.x + thRect.width)
|
|
439
|
+
}
|
|
440
|
+
cdLineEl.style.left = `${left}px`
|
|
441
|
+
cdLineEl.style.height = `${wrapperRect.height - scrollbarHeight}px`
|
|
442
|
+
cdLineEl.style.display = 'block'
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const rdTipEl = $xeTable.$refs.refDragTipElem as HTMLElement
|
|
384
446
|
if (rdTipEl) {
|
|
385
|
-
const wrapperRect = el.getBoundingClientRect()
|
|
386
447
|
rdTipEl.style.display = 'block'
|
|
387
448
|
rdTipEl.style.top = `${Math.min(el.clientHeight - el.scrollTop - rdTipEl.clientHeight, evnt.clientY - wrapperRect.y)}px`
|
|
388
449
|
rdTipEl.style.left = `${Math.min(el.clientWidth - el.scrollLeft - rdTipEl.clientWidth - 16, evnt.clientX - wrapperRect.x)}px`
|
|
389
450
|
}
|
|
390
451
|
}
|
|
391
452
|
|
|
392
|
-
const
|
|
393
|
-
const rdTipEl = $xeTable.$refs.
|
|
453
|
+
const hideDropTip = ($xeTable: any) => {
|
|
454
|
+
const rdTipEl = $xeTable.$refs.refDragTipElem as HTMLDivElement
|
|
455
|
+
const rdLineEl = $xeTable.$refs.refDragRowLineElem as HTMLDivElement
|
|
456
|
+
const cdLineEl = $xeTable.$refs.refDragColLineElem as HTMLDivElement
|
|
394
457
|
if (rdTipEl) {
|
|
395
458
|
rdTipEl.style.display = ''
|
|
396
459
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const { dragRow } = reactData
|
|
403
|
-
const dragOpts = $xeTable.computeDragOpts
|
|
404
|
-
const { rowTooltipMethod } = dragOpts
|
|
405
|
-
let tipContent = ''
|
|
406
|
-
if (rowTooltipMethod) {
|
|
407
|
-
tipContent = `${rowTooltipMethod({
|
|
408
|
-
row: dragRow
|
|
409
|
-
}) || ''}`
|
|
410
|
-
} else {
|
|
411
|
-
tipContent = getI18n('vxe.table.dragTip', [tdEl.textContent || ''])
|
|
460
|
+
if (rdLineEl) {
|
|
461
|
+
rdLineEl.style.display = ''
|
|
462
|
+
}
|
|
463
|
+
if (cdLineEl) {
|
|
464
|
+
cdLineEl.style.display = ''
|
|
412
465
|
}
|
|
413
|
-
reactData.dragTipText = tipContent
|
|
414
466
|
}
|
|
415
467
|
|
|
416
468
|
const Methods = {
|
|
@@ -579,6 +631,7 @@ const Methods = {
|
|
|
579
631
|
editStore.removeMaps = {}
|
|
580
632
|
const sYLoad = this.updateScrollYStatus(fullData)
|
|
581
633
|
this.scrollYLoad = sYLoad
|
|
634
|
+
this.isDragRowMove = false
|
|
582
635
|
// 全量数据
|
|
583
636
|
this.tableFullData = fullData
|
|
584
637
|
this.tableFullTreeData = treeData
|
|
@@ -759,6 +812,7 @@ const Methods = {
|
|
|
759
812
|
const tableFullColumn = getColumnList(collectColumn)
|
|
760
813
|
this.tableFullColumn = tableFullColumn
|
|
761
814
|
this._isLoading = true
|
|
815
|
+
this.isDragColMove = false
|
|
762
816
|
this.initColumnSort()
|
|
763
817
|
return Promise.resolve(
|
|
764
818
|
this.restoreCustomStorage()
|
|
@@ -3042,7 +3096,7 @@ const Methods = {
|
|
|
3042
3096
|
!getEventTargetNode(evnt, $el).flag
|
|
3043
3097
|
) {
|
|
3044
3098
|
setTimeout(() => {
|
|
3045
|
-
this.
|
|
3099
|
+
this.handleClearEdit(evnt).then(() => {
|
|
3046
3100
|
// 如果存在校验,点击了表格之外则清除
|
|
3047
3101
|
if (!this.isActivated && editRules && validOpts.autoClear) {
|
|
3048
3102
|
this.validErrorMaps = {}
|
|
@@ -3111,8 +3165,8 @@ const Methods = {
|
|
|
3111
3165
|
if (isEsc) {
|
|
3112
3166
|
this.preventEvent(evnt, 'event.keydown', null, () => {
|
|
3113
3167
|
this.emitEvent('keydown-start', {}, evnt)
|
|
3114
|
-
if (keyboardConfig && mouseConfig && mouseOpts.area && this.
|
|
3115
|
-
this.
|
|
3168
|
+
if (keyboardConfig && mouseConfig && mouseOpts.area && this.handleKeyboardCellAreaEvent) {
|
|
3169
|
+
this.handleKeyboardCellAreaEvent(evnt)
|
|
3116
3170
|
} else if (actived.row || filterStore.visible || ctxMenuStore.visible) {
|
|
3117
3171
|
evnt.stopPropagation()
|
|
3118
3172
|
// 如果按下了 Esc 键,关闭快捷菜单、筛选
|
|
@@ -3122,7 +3176,7 @@ const Methods = {
|
|
|
3122
3176
|
// 如果是激活编辑状态,则取消编辑
|
|
3123
3177
|
if (actived.row) {
|
|
3124
3178
|
const params = actived.args
|
|
3125
|
-
this.
|
|
3179
|
+
this.handleClearEdit(evnt)
|
|
3126
3180
|
// 如果配置了选中功能,则为选中状态
|
|
3127
3181
|
if (mouseConfig && mouseOpts.selected) {
|
|
3128
3182
|
this.$nextTick(() => this.handleSelected(params, evnt))
|
|
@@ -3180,8 +3234,8 @@ const Methods = {
|
|
|
3180
3234
|
} else {
|
|
3181
3235
|
this.moveCtxMenu(evnt, keyCode, ctxMenuStore, 'selected', 39, true, this.ctxMenuList)
|
|
3182
3236
|
}
|
|
3183
|
-
} else if (keyboardConfig && mouseConfig && mouseOpts.area && this.
|
|
3184
|
-
this.
|
|
3237
|
+
} else if (keyboardConfig && mouseConfig && mouseOpts.area && this.handleKeyboardCellAreaEvent) {
|
|
3238
|
+
this.handleKeyboardCellAreaEvent(evnt)
|
|
3185
3239
|
} else if (keyboardConfig && isSpacebar && keyboardOpts.isChecked && selected.row && selected.column && (selected.column.type === 'checkbox' || selected.column.type === 'radio')) {
|
|
3186
3240
|
// 空格键支持选中复选框
|
|
3187
3241
|
evnt.preventDefault()
|
|
@@ -3212,7 +3266,7 @@ const Methods = {
|
|
|
3212
3266
|
// 如果是激活编辑状态,则取消编辑
|
|
3213
3267
|
if (actived.row) {
|
|
3214
3268
|
const params = actived.args
|
|
3215
|
-
this.
|
|
3269
|
+
this.handleClearEdit(evnt)
|
|
3216
3270
|
// 如果配置了选中功能,则为选中状态
|
|
3217
3271
|
if (mouseConfig && mouseOpts.selected) {
|
|
3218
3272
|
this.$nextTick(() => this.handleSelected(params, evnt))
|
|
@@ -4674,6 +4728,9 @@ const Methods = {
|
|
|
4674
4728
|
this.emitEvent('sort-change', params, evnt)
|
|
4675
4729
|
}
|
|
4676
4730
|
},
|
|
4731
|
+
/**
|
|
4732
|
+
* 行拖拽
|
|
4733
|
+
*/
|
|
4677
4734
|
handleRowDragDragstartEvent (evnt: DragEvent) {
|
|
4678
4735
|
const img = new Image()
|
|
4679
4736
|
if (evnt.dataTransfer) {
|
|
@@ -4686,28 +4743,31 @@ const Methods = {
|
|
|
4686
4743
|
const reactData = $xeTable
|
|
4687
4744
|
const internalData = $xeTable
|
|
4688
4745
|
|
|
4689
|
-
const { treeConfig } = props
|
|
4690
|
-
const
|
|
4691
|
-
const { dragEndMethod } =
|
|
4746
|
+
const { treeConfig, dragConfig } = props
|
|
4747
|
+
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
4748
|
+
const { dragEndMethod } = rowDragOpts
|
|
4692
4749
|
const treeOpts = $xeTable.computeTreeOpts
|
|
4693
4750
|
const { transform } = treeOpts
|
|
4694
4751
|
const { dragRow } = reactData
|
|
4695
4752
|
const { afterFullData, afterTreeFullData, tableFullData, tableFullTreeData, prevDragRow, prevDragPos } = internalData
|
|
4753
|
+
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
4754
|
+
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
4696
4755
|
if (prevDragRow && dragRow) {
|
|
4697
4756
|
// 判断是否有拖动
|
|
4698
4757
|
if (prevDragRow !== dragRow) {
|
|
4699
4758
|
Promise.resolve(
|
|
4700
|
-
|
|
4701
|
-
?
|
|
4759
|
+
dEndMethod
|
|
4760
|
+
? dEndMethod({
|
|
4702
4761
|
oldRow: dragRow,
|
|
4703
|
-
newRow: prevDragRow
|
|
4762
|
+
newRow: prevDragRow,
|
|
4763
|
+
dragPos: prevDragPos as any,
|
|
4764
|
+
offsetIndex: dragOffsetIndex
|
|
4704
4765
|
})
|
|
4705
4766
|
: true
|
|
4706
4767
|
).then((status) => {
|
|
4707
4768
|
if (!status) {
|
|
4708
4769
|
return
|
|
4709
4770
|
}
|
|
4710
|
-
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
4711
4771
|
|
|
4712
4772
|
let oafIndex = -1
|
|
4713
4773
|
let nafIndex = -1
|
|
@@ -4747,19 +4807,20 @@ const Methods = {
|
|
|
4747
4807
|
if (!(treeConfig && transform)) {
|
|
4748
4808
|
$xeTable.updateAfterDataIndex()
|
|
4749
4809
|
}
|
|
4750
|
-
$xeTable.updateFooter()
|
|
4751
4810
|
$xeTable.checkSelectionStatus()
|
|
4752
4811
|
if (reactData.scrollYLoad) {
|
|
4753
4812
|
$xeTable.updateScrollYSpace()
|
|
4754
4813
|
}
|
|
4755
4814
|
$xeTable.$nextTick().then(() => {
|
|
4756
4815
|
$xeTable.updateCellAreas()
|
|
4757
|
-
|
|
4816
|
+
$xeTable.recalculate()
|
|
4758
4817
|
})
|
|
4759
4818
|
|
|
4760
4819
|
$xeTable.dispatchEvent('row-dragend', {
|
|
4761
4820
|
oldRow: dragRow,
|
|
4762
4821
|
newRow: prevDragRow,
|
|
4822
|
+
dragPos: prevDragPos,
|
|
4823
|
+
offsetIndex: dragOffsetIndex,
|
|
4763
4824
|
_index: {
|
|
4764
4825
|
newIndex: nafIndex,
|
|
4765
4826
|
oldIndex: oafIndex
|
|
@@ -4769,10 +4830,10 @@ const Methods = {
|
|
|
4769
4830
|
})
|
|
4770
4831
|
}
|
|
4771
4832
|
}
|
|
4772
|
-
|
|
4833
|
+
hideDropTip($xeTable)
|
|
4773
4834
|
clearRowDropOrigin($xeTable)
|
|
4774
|
-
clearRowDropTarget($xeTable)
|
|
4775
4835
|
reactData.dragRow = null
|
|
4836
|
+
reactData.dragCol = null
|
|
4776
4837
|
setTimeout(() => {
|
|
4777
4838
|
reactData.isDragRowMove = false
|
|
4778
4839
|
}, 500)
|
|
@@ -4782,50 +4843,57 @@ const Methods = {
|
|
|
4782
4843
|
const internalData = $xeTable
|
|
4783
4844
|
const reactData = $xeTable
|
|
4784
4845
|
|
|
4846
|
+
const { dragRow } = reactData
|
|
4847
|
+
if (!dragRow) {
|
|
4848
|
+
evnt.preventDefault()
|
|
4849
|
+
return
|
|
4850
|
+
}
|
|
4785
4851
|
const trEl = evnt.currentTarget as HTMLElement
|
|
4786
4852
|
const rowid = trEl.getAttribute('rowid')
|
|
4787
4853
|
const row = $xeTable.getRowById(rowid)
|
|
4788
|
-
clearRowDropTarget($xeTable)
|
|
4789
4854
|
if (row) {
|
|
4790
4855
|
evnt.preventDefault()
|
|
4791
4856
|
evnt.preventDefault()
|
|
4792
4857
|
const { dragRow } = reactData
|
|
4793
4858
|
const offsetY = evnt.clientY - trEl.getBoundingClientRect().y
|
|
4794
4859
|
const dragPos = offsetY < trEl.clientHeight / 2 ? 'top' : 'bottom'
|
|
4795
|
-
updateRowDropTarget($xeTable, row, dragPos)
|
|
4796
4860
|
internalData.prevDragRow = row
|
|
4797
4861
|
internalData.prevDragPos = dragPos
|
|
4862
|
+
showDropTip($xeTable, evnt, trEl, null, dragPos)
|
|
4798
4863
|
$xeTable.dispatchEvent('row-dragover', {
|
|
4799
4864
|
oldRow: dragRow,
|
|
4800
4865
|
targetRow: row,
|
|
4801
4866
|
dragPos
|
|
4802
4867
|
}, evnt)
|
|
4803
4868
|
}
|
|
4804
|
-
showRowDropTip(evnt, $xeTable)
|
|
4805
4869
|
},
|
|
4806
4870
|
handleCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
4807
4871
|
const $xeTable = this
|
|
4872
|
+
const props = $xeTable
|
|
4808
4873
|
const reactData = $xeTable
|
|
4809
4874
|
|
|
4810
4875
|
evnt.stopPropagation()
|
|
4811
|
-
const
|
|
4812
|
-
const
|
|
4876
|
+
const { dragConfig } = props
|
|
4877
|
+
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
4878
|
+
const { dragStartMethod } = rowDragOpts
|
|
4813
4879
|
const { row } = params
|
|
4814
4880
|
const dragEl = evnt.currentTarget as HTMLElement
|
|
4815
|
-
const tdEl = dragEl.
|
|
4816
|
-
const trEl = tdEl.
|
|
4881
|
+
const tdEl = dragEl.parentElement?.parentElement as HTMLElement
|
|
4882
|
+
const trEl = tdEl.parentElement as HTMLElement
|
|
4883
|
+
const dStartMethod = dragStartMethod || (dragConfig ? dragConfig.dragStartMethod : null)
|
|
4817
4884
|
reactData.isDragRowMove = false
|
|
4818
4885
|
clearRowDropOrigin($xeTable)
|
|
4819
|
-
if (
|
|
4886
|
+
if (dStartMethod && !dStartMethod(params)) {
|
|
4820
4887
|
trEl.draggable = false
|
|
4821
4888
|
reactData.dragRow = null
|
|
4822
|
-
|
|
4889
|
+
reactData.dragCol = null
|
|
4890
|
+
hideDropTip($xeTable)
|
|
4823
4891
|
return
|
|
4824
4892
|
}
|
|
4825
4893
|
reactData.dragRow = row
|
|
4894
|
+
reactData.dragCol = null
|
|
4826
4895
|
trEl.draggable = true
|
|
4827
4896
|
updateRowDropOrigin($xeTable, row)
|
|
4828
|
-
showRowDropTip(evnt, $xeTable)
|
|
4829
4897
|
updateRowDropTipContent($xeTable, tdEl)
|
|
4830
4898
|
$xeTable.dispatchEvent('row-dragstart', params, evnt)
|
|
4831
4899
|
},
|
|
@@ -4834,10 +4902,171 @@ const Methods = {
|
|
|
4834
4902
|
const reactData = $xeTable
|
|
4835
4903
|
|
|
4836
4904
|
clearRowDropOrigin($xeTable)
|
|
4837
|
-
|
|
4905
|
+
hideDropTip($xeTable)
|
|
4838
4906
|
reactData.dragRow = null
|
|
4907
|
+
reactData.dragCol = null
|
|
4839
4908
|
reactData.isDragRowMove = false
|
|
4840
4909
|
},
|
|
4910
|
+
/**
|
|
4911
|
+
* 列拖拽
|
|
4912
|
+
*/
|
|
4913
|
+
handleHeaderCellDragDragstartEvent (evnt: DragEvent) {
|
|
4914
|
+
const img = new Image()
|
|
4915
|
+
if (evnt.dataTransfer) {
|
|
4916
|
+
evnt.dataTransfer.setDragImage(img, 0, 0)
|
|
4917
|
+
}
|
|
4918
|
+
},
|
|
4919
|
+
handleHeaderCellDragDragendEvent (evnt: DragEvent) {
|
|
4920
|
+
const $xeTable = this
|
|
4921
|
+
const props = $xeTable
|
|
4922
|
+
const reactData = $xeTable
|
|
4923
|
+
const internalData = $xeTable
|
|
4924
|
+
|
|
4925
|
+
const { mouseConfig } = props
|
|
4926
|
+
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
4927
|
+
const { dragEndMethod } = columnDragOpts
|
|
4928
|
+
const { dragCol } = reactData
|
|
4929
|
+
const { collectColumn, prevDragCol, prevDragPos } = internalData
|
|
4930
|
+
const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
|
|
4931
|
+
if (prevDragCol && dragCol) {
|
|
4932
|
+
// 判断是否有拖动
|
|
4933
|
+
if (prevDragCol !== dragCol) {
|
|
4934
|
+
Promise.resolve(
|
|
4935
|
+
dragEndMethod
|
|
4936
|
+
? dragEndMethod({
|
|
4937
|
+
oldColumn: dragCol,
|
|
4938
|
+
newColumn: prevDragCol,
|
|
4939
|
+
dragPos: prevDragPos as any,
|
|
4940
|
+
offsetIndex: dragOffsetIndex
|
|
4941
|
+
})
|
|
4942
|
+
: true
|
|
4943
|
+
).then((status) => {
|
|
4944
|
+
if (!status) {
|
|
4945
|
+
return
|
|
4946
|
+
}
|
|
4947
|
+
|
|
4948
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parent) => {
|
|
4949
|
+
if (!parent) {
|
|
4950
|
+
const sortIndex = index + 1
|
|
4951
|
+
column.renderSortNumber = sortIndex
|
|
4952
|
+
}
|
|
4953
|
+
})
|
|
4954
|
+
|
|
4955
|
+
const oafIndex = XEUtils.findIndexOf(collectColumn, item => item.id === dragCol.id)
|
|
4956
|
+
const nafIndex = XEUtils.findIndexOf(collectColumn, item => item.id === prevDragCol.id) + dragOffsetIndex
|
|
4957
|
+
|
|
4958
|
+
const newTargetCol = collectColumn[nafIndex]
|
|
4959
|
+
if (newTargetCol) {
|
|
4960
|
+
// 插入最后位置
|
|
4961
|
+
dragCol.renderSortNumber = newTargetCol.renderSortNumber
|
|
4962
|
+
newTargetCol.renderSortNumber = dragCol.renderSortNumber + 0.5
|
|
4963
|
+
} else {
|
|
4964
|
+
// 插入新位置
|
|
4965
|
+
dragCol.renderSortNumber = collectColumn.length + 1.5
|
|
4966
|
+
}
|
|
4967
|
+
|
|
4968
|
+
reactData.isDragColMove = true
|
|
4969
|
+
if (mouseConfig) {
|
|
4970
|
+
if ($xeTable.clearSelected) {
|
|
4971
|
+
$xeTable.clearSelected()
|
|
4972
|
+
}
|
|
4973
|
+
if ($xeTable.clearCellAreas) {
|
|
4974
|
+
$xeTable.clearCellAreas()
|
|
4975
|
+
$xeTable.clearCopyCellArea()
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
$xeTable.analyColumnWidth()
|
|
4979
|
+
$xeTable.$nextTick().then(() => {
|
|
4980
|
+
$xeTable.updateCellAreas()
|
|
4981
|
+
$xeTable.refreshColumn(true)
|
|
4982
|
+
})
|
|
4983
|
+
|
|
4984
|
+
$xeTable.dispatchEvent('column-dragend', {
|
|
4985
|
+
oldColumn: dragCol,
|
|
4986
|
+
newColumn: prevDragCol,
|
|
4987
|
+
dragPos: prevDragPos,
|
|
4988
|
+
offsetIndex: dragOffsetIndex,
|
|
4989
|
+
_index: {
|
|
4990
|
+
newIndex: nafIndex,
|
|
4991
|
+
oldIndex: oafIndex
|
|
4992
|
+
}
|
|
4993
|
+
}, evnt)
|
|
4994
|
+
}).catch(() => {
|
|
4995
|
+
})
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4998
|
+
hideDropTip($xeTable)
|
|
4999
|
+
clearColDropOrigin($xeTable)
|
|
5000
|
+
reactData.dragRow = null
|
|
5001
|
+
reactData.dragCol = null
|
|
5002
|
+
setTimeout(() => {
|
|
5003
|
+
reactData.isDragColMove = false
|
|
5004
|
+
}, 500)
|
|
5005
|
+
},
|
|
5006
|
+
handleHeaderCellDragDragoverEvent (evnt: DragEvent) {
|
|
5007
|
+
const $xeTable = this
|
|
5008
|
+
const reactData = $xeTable
|
|
5009
|
+
const internalData = $xeTable
|
|
5010
|
+
|
|
5011
|
+
const { dragCol } = reactData
|
|
5012
|
+
if (!dragCol) {
|
|
5013
|
+
evnt.preventDefault()
|
|
5014
|
+
return
|
|
5015
|
+
}
|
|
5016
|
+
const thEl = evnt.currentTarget as HTMLElement
|
|
5017
|
+
const colid = thEl.getAttribute('colid')
|
|
5018
|
+
const column = $xeTable.getColumnById(colid)
|
|
5019
|
+
if (column) {
|
|
5020
|
+
evnt.preventDefault()
|
|
5021
|
+
const { dragCol } = reactData
|
|
5022
|
+
const offsetX = evnt.clientX - thEl.getBoundingClientRect().x
|
|
5023
|
+
const dragPos = offsetX < thEl.clientWidth / 2 ? 'left' : 'right'
|
|
5024
|
+
internalData.prevDragCol = column
|
|
5025
|
+
internalData.prevDragPos = dragPos
|
|
5026
|
+
showDropTip($xeTable, evnt, null, thEl, dragPos)
|
|
5027
|
+
$xeTable.dispatchEvent('column-dragover', {
|
|
5028
|
+
oldColumn: dragCol,
|
|
5029
|
+
targetColumn: column,
|
|
5030
|
+
dragPos
|
|
5031
|
+
}, evnt)
|
|
5032
|
+
}
|
|
5033
|
+
},
|
|
5034
|
+
handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
5035
|
+
const $xeTable = this
|
|
5036
|
+
const reactData = $xeTable
|
|
5037
|
+
|
|
5038
|
+
evnt.stopPropagation()
|
|
5039
|
+
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
5040
|
+
const { dragStartMethod } = columnDragOpts
|
|
5041
|
+
const { column } = params
|
|
5042
|
+
const dragEl = evnt.currentTarget as HTMLElement
|
|
5043
|
+
const thEl = dragEl.parentElement?.parentElement as HTMLElement
|
|
5044
|
+
reactData.isDragColMove = false
|
|
5045
|
+
clearColDropOrigin($xeTable)
|
|
5046
|
+
if (dragStartMethod && !dragStartMethod(params)) {
|
|
5047
|
+
thEl.draggable = false
|
|
5048
|
+
reactData.dragRow = null
|
|
5049
|
+
reactData.dragCol = null
|
|
5050
|
+
hideDropTip($xeTable)
|
|
5051
|
+
return
|
|
5052
|
+
}
|
|
5053
|
+
reactData.dragCol = column
|
|
5054
|
+
reactData.dragRow = null
|
|
5055
|
+
thEl.draggable = true
|
|
5056
|
+
updateColDropOrigin($xeTable, column)
|
|
5057
|
+
updateColDropTipContent($xeTable, thEl)
|
|
5058
|
+
$xeTable.dispatchEvent('column-dragstart', params, evnt)
|
|
5059
|
+
},
|
|
5060
|
+
handleHeaderCellDragMouseupEvent () {
|
|
5061
|
+
const $xeTable = this
|
|
5062
|
+
const reactData = $xeTable
|
|
5063
|
+
|
|
5064
|
+
clearColDropOrigin($xeTable)
|
|
5065
|
+
hideDropTip($xeTable)
|
|
5066
|
+
reactData.dragRow = null
|
|
5067
|
+
reactData.dragCol = null
|
|
5068
|
+
reactData.isDragColMove = false
|
|
5069
|
+
},
|
|
4841
5070
|
setPendingRow (rows: any, status: any) {
|
|
4842
5071
|
const pendingMaps = { ...this.pendingRowMaps }
|
|
4843
5072
|
const pendingList = [...this.pendingRowList]
|
|
@@ -6313,8 +6542,8 @@ const Methods = {
|
|
|
6313
6542
|
}
|
|
6314
6543
|
},
|
|
6315
6544
|
updateCellAreas () {
|
|
6316
|
-
if (this.mouseConfig && this.mouseOpts.area && this.
|
|
6317
|
-
return this.
|
|
6545
|
+
if (this.mouseConfig && this.mouseOpts.area && this.handleRecalculateCellAreas) {
|
|
6546
|
+
return this.handleRecalculateCellAreas()
|
|
6318
6547
|
}
|
|
6319
6548
|
return this.$nextTick()
|
|
6320
6549
|
},
|
|
@@ -165,8 +165,12 @@ export default {
|
|
|
165
165
|
cellConfig: Object as PropType<VxeTablePropTypes.CellConfig>,
|
|
166
166
|
// 行配置信息
|
|
167
167
|
rowConfig: Object,
|
|
168
|
-
//
|
|
168
|
+
// 已废弃,被 rowDragConfig 替换
|
|
169
169
|
dragConfig: Object as PropType<VxeTablePropTypes.DragConfig>,
|
|
170
|
+
// 行拖拽排序配置项
|
|
171
|
+
rowDragConfig: Object as PropType<VxeTablePropTypes.RowDragConfig>,
|
|
172
|
+
// 列拖拽排序配置项
|
|
173
|
+
columnDragConfig: Object as PropType<VxeTablePropTypes.ColumnDragConfig>,
|
|
170
174
|
// 列调整配置项
|
|
171
175
|
resizableConfig: Object,
|
|
172
176
|
// 序号配置项
|