vxe-table 3.10.15 → 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/module/validator/mixin.js +31 -10
- 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 +292 -66
- 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 +945 -460
- 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/module/validator/mixin.js +31 -10
- package/lib/table/module/validator/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 +321 -69
- 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/module/validator/mixin.ts +33 -10
- 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 +304 -68
- 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.1731574584971.ttf → iconfont.1731890707082.ttf} +0 -0
- /package/es/{iconfont.1731574584971.woff → iconfont.1731890707082.woff} +0 -0
- /package/es/{iconfont.1731574584971.woff2 → iconfont.1731890707082.woff2} +0 -0
- /package/lib/{iconfont.1731574584971.ttf → iconfont.1731890707082.ttf} +0 -0
- /package/lib/{iconfont.1731574584971.woff → iconfont.1731890707082.woff} +0 -0
- /package/lib/{iconfont.1731574584971.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()
|
|
@@ -3041,7 +3095,14 @@ const Methods = {
|
|
|
3041
3095
|
// 如果点击了当前表格之外
|
|
3042
3096
|
!getEventTargetNode(evnt, $el).flag
|
|
3043
3097
|
) {
|
|
3044
|
-
setTimeout(() =>
|
|
3098
|
+
setTimeout(() => {
|
|
3099
|
+
this.handleClearEdit(evnt).then(() => {
|
|
3100
|
+
// 如果存在校验,点击了表格之外则清除
|
|
3101
|
+
if (!this.isActivated && editRules && validOpts.autoClear) {
|
|
3102
|
+
this.validErrorMaps = {}
|
|
3103
|
+
}
|
|
3104
|
+
})
|
|
3105
|
+
})
|
|
3045
3106
|
}
|
|
3046
3107
|
})
|
|
3047
3108
|
}
|
|
@@ -3104,8 +3165,8 @@ const Methods = {
|
|
|
3104
3165
|
if (isEsc) {
|
|
3105
3166
|
this.preventEvent(evnt, 'event.keydown', null, () => {
|
|
3106
3167
|
this.emitEvent('keydown-start', {}, evnt)
|
|
3107
|
-
if (keyboardConfig && mouseConfig && mouseOpts.area && this.
|
|
3108
|
-
this.
|
|
3168
|
+
if (keyboardConfig && mouseConfig && mouseOpts.area && this.handleKeyboardCellAreaEvent) {
|
|
3169
|
+
this.handleKeyboardCellAreaEvent(evnt)
|
|
3109
3170
|
} else if (actived.row || filterStore.visible || ctxMenuStore.visible) {
|
|
3110
3171
|
evnt.stopPropagation()
|
|
3111
3172
|
// 如果按下了 Esc 键,关闭快捷菜单、筛选
|
|
@@ -3115,7 +3176,7 @@ const Methods = {
|
|
|
3115
3176
|
// 如果是激活编辑状态,则取消编辑
|
|
3116
3177
|
if (actived.row) {
|
|
3117
3178
|
const params = actived.args
|
|
3118
|
-
this.
|
|
3179
|
+
this.handleClearEdit(evnt)
|
|
3119
3180
|
// 如果配置了选中功能,则为选中状态
|
|
3120
3181
|
if (mouseConfig && mouseOpts.selected) {
|
|
3121
3182
|
this.$nextTick(() => this.handleSelected(params, evnt))
|
|
@@ -3173,8 +3234,8 @@ const Methods = {
|
|
|
3173
3234
|
} else {
|
|
3174
3235
|
this.moveCtxMenu(evnt, keyCode, ctxMenuStore, 'selected', 39, true, this.ctxMenuList)
|
|
3175
3236
|
}
|
|
3176
|
-
} else if (keyboardConfig && mouseConfig && mouseOpts.area && this.
|
|
3177
|
-
this.
|
|
3237
|
+
} else if (keyboardConfig && mouseConfig && mouseOpts.area && this.handleKeyboardCellAreaEvent) {
|
|
3238
|
+
this.handleKeyboardCellAreaEvent(evnt)
|
|
3178
3239
|
} else if (keyboardConfig && isSpacebar && keyboardOpts.isChecked && selected.row && selected.column && (selected.column.type === 'checkbox' || selected.column.type === 'radio')) {
|
|
3179
3240
|
// 空格键支持选中复选框
|
|
3180
3241
|
evnt.preventDefault()
|
|
@@ -3205,7 +3266,7 @@ const Methods = {
|
|
|
3205
3266
|
// 如果是激活编辑状态,则取消编辑
|
|
3206
3267
|
if (actived.row) {
|
|
3207
3268
|
const params = actived.args
|
|
3208
|
-
this.
|
|
3269
|
+
this.handleClearEdit(evnt)
|
|
3209
3270
|
// 如果配置了选中功能,则为选中状态
|
|
3210
3271
|
if (mouseConfig && mouseOpts.selected) {
|
|
3211
3272
|
this.$nextTick(() => this.handleSelected(params, evnt))
|
|
@@ -4667,6 +4728,9 @@ const Methods = {
|
|
|
4667
4728
|
this.emitEvent('sort-change', params, evnt)
|
|
4668
4729
|
}
|
|
4669
4730
|
},
|
|
4731
|
+
/**
|
|
4732
|
+
* 行拖拽
|
|
4733
|
+
*/
|
|
4670
4734
|
handleRowDragDragstartEvent (evnt: DragEvent) {
|
|
4671
4735
|
const img = new Image()
|
|
4672
4736
|
if (evnt.dataTransfer) {
|
|
@@ -4679,28 +4743,31 @@ const Methods = {
|
|
|
4679
4743
|
const reactData = $xeTable
|
|
4680
4744
|
const internalData = $xeTable
|
|
4681
4745
|
|
|
4682
|
-
const { treeConfig } = props
|
|
4683
|
-
const
|
|
4684
|
-
const { dragEndMethod } =
|
|
4746
|
+
const { treeConfig, dragConfig } = props
|
|
4747
|
+
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
4748
|
+
const { dragEndMethod } = rowDragOpts
|
|
4685
4749
|
const treeOpts = $xeTable.computeTreeOpts
|
|
4686
4750
|
const { transform } = treeOpts
|
|
4687
4751
|
const { dragRow } = reactData
|
|
4688
4752
|
const { afterFullData, afterTreeFullData, tableFullData, tableFullTreeData, prevDragRow, prevDragPos } = internalData
|
|
4753
|
+
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
4754
|
+
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
4689
4755
|
if (prevDragRow && dragRow) {
|
|
4690
4756
|
// 判断是否有拖动
|
|
4691
4757
|
if (prevDragRow !== dragRow) {
|
|
4692
4758
|
Promise.resolve(
|
|
4693
|
-
|
|
4694
|
-
?
|
|
4759
|
+
dEndMethod
|
|
4760
|
+
? dEndMethod({
|
|
4695
4761
|
oldRow: dragRow,
|
|
4696
|
-
newRow: prevDragRow
|
|
4762
|
+
newRow: prevDragRow,
|
|
4763
|
+
dragPos: prevDragPos as any,
|
|
4764
|
+
offsetIndex: dragOffsetIndex
|
|
4697
4765
|
})
|
|
4698
4766
|
: true
|
|
4699
4767
|
).then((status) => {
|
|
4700
4768
|
if (!status) {
|
|
4701
4769
|
return
|
|
4702
4770
|
}
|
|
4703
|
-
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
4704
4771
|
|
|
4705
4772
|
let oafIndex = -1
|
|
4706
4773
|
let nafIndex = -1
|
|
@@ -4740,19 +4807,20 @@ const Methods = {
|
|
|
4740
4807
|
if (!(treeConfig && transform)) {
|
|
4741
4808
|
$xeTable.updateAfterDataIndex()
|
|
4742
4809
|
}
|
|
4743
|
-
$xeTable.updateFooter()
|
|
4744
4810
|
$xeTable.checkSelectionStatus()
|
|
4745
4811
|
if (reactData.scrollYLoad) {
|
|
4746
4812
|
$xeTable.updateScrollYSpace()
|
|
4747
4813
|
}
|
|
4748
4814
|
$xeTable.$nextTick().then(() => {
|
|
4749
4815
|
$xeTable.updateCellAreas()
|
|
4750
|
-
|
|
4816
|
+
$xeTable.recalculate()
|
|
4751
4817
|
})
|
|
4752
4818
|
|
|
4753
4819
|
$xeTable.dispatchEvent('row-dragend', {
|
|
4754
4820
|
oldRow: dragRow,
|
|
4755
4821
|
newRow: prevDragRow,
|
|
4822
|
+
dragPos: prevDragPos,
|
|
4823
|
+
offsetIndex: dragOffsetIndex,
|
|
4756
4824
|
_index: {
|
|
4757
4825
|
newIndex: nafIndex,
|
|
4758
4826
|
oldIndex: oafIndex
|
|
@@ -4762,10 +4830,10 @@ const Methods = {
|
|
|
4762
4830
|
})
|
|
4763
4831
|
}
|
|
4764
4832
|
}
|
|
4765
|
-
|
|
4833
|
+
hideDropTip($xeTable)
|
|
4766
4834
|
clearRowDropOrigin($xeTable)
|
|
4767
|
-
clearRowDropTarget($xeTable)
|
|
4768
4835
|
reactData.dragRow = null
|
|
4836
|
+
reactData.dragCol = null
|
|
4769
4837
|
setTimeout(() => {
|
|
4770
4838
|
reactData.isDragRowMove = false
|
|
4771
4839
|
}, 500)
|
|
@@ -4775,50 +4843,57 @@ const Methods = {
|
|
|
4775
4843
|
const internalData = $xeTable
|
|
4776
4844
|
const reactData = $xeTable
|
|
4777
4845
|
|
|
4846
|
+
const { dragRow } = reactData
|
|
4847
|
+
if (!dragRow) {
|
|
4848
|
+
evnt.preventDefault()
|
|
4849
|
+
return
|
|
4850
|
+
}
|
|
4778
4851
|
const trEl = evnt.currentTarget as HTMLElement
|
|
4779
4852
|
const rowid = trEl.getAttribute('rowid')
|
|
4780
4853
|
const row = $xeTable.getRowById(rowid)
|
|
4781
|
-
clearRowDropTarget($xeTable)
|
|
4782
4854
|
if (row) {
|
|
4783
4855
|
evnt.preventDefault()
|
|
4784
4856
|
evnt.preventDefault()
|
|
4785
4857
|
const { dragRow } = reactData
|
|
4786
4858
|
const offsetY = evnt.clientY - trEl.getBoundingClientRect().y
|
|
4787
4859
|
const dragPos = offsetY < trEl.clientHeight / 2 ? 'top' : 'bottom'
|
|
4788
|
-
updateRowDropTarget($xeTable, row, dragPos)
|
|
4789
4860
|
internalData.prevDragRow = row
|
|
4790
4861
|
internalData.prevDragPos = dragPos
|
|
4862
|
+
showDropTip($xeTable, evnt, trEl, null, dragPos)
|
|
4791
4863
|
$xeTable.dispatchEvent('row-dragover', {
|
|
4792
4864
|
oldRow: dragRow,
|
|
4793
4865
|
targetRow: row,
|
|
4794
4866
|
dragPos
|
|
4795
4867
|
}, evnt)
|
|
4796
4868
|
}
|
|
4797
|
-
showRowDropTip(evnt, $xeTable)
|
|
4798
4869
|
},
|
|
4799
4870
|
handleCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
4800
4871
|
const $xeTable = this
|
|
4872
|
+
const props = $xeTable
|
|
4801
4873
|
const reactData = $xeTable
|
|
4802
4874
|
|
|
4803
4875
|
evnt.stopPropagation()
|
|
4804
|
-
const
|
|
4805
|
-
const
|
|
4876
|
+
const { dragConfig } = props
|
|
4877
|
+
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
4878
|
+
const { dragStartMethod } = rowDragOpts
|
|
4806
4879
|
const { row } = params
|
|
4807
4880
|
const dragEl = evnt.currentTarget as HTMLElement
|
|
4808
|
-
const tdEl = dragEl.
|
|
4809
|
-
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)
|
|
4810
4884
|
reactData.isDragRowMove = false
|
|
4811
4885
|
clearRowDropOrigin($xeTable)
|
|
4812
|
-
if (
|
|
4886
|
+
if (dStartMethod && !dStartMethod(params)) {
|
|
4813
4887
|
trEl.draggable = false
|
|
4814
4888
|
reactData.dragRow = null
|
|
4815
|
-
|
|
4889
|
+
reactData.dragCol = null
|
|
4890
|
+
hideDropTip($xeTable)
|
|
4816
4891
|
return
|
|
4817
4892
|
}
|
|
4818
4893
|
reactData.dragRow = row
|
|
4894
|
+
reactData.dragCol = null
|
|
4819
4895
|
trEl.draggable = true
|
|
4820
4896
|
updateRowDropOrigin($xeTable, row)
|
|
4821
|
-
showRowDropTip(evnt, $xeTable)
|
|
4822
4897
|
updateRowDropTipContent($xeTable, tdEl)
|
|
4823
4898
|
$xeTable.dispatchEvent('row-dragstart', params, evnt)
|
|
4824
4899
|
},
|
|
@@ -4827,10 +4902,171 @@ const Methods = {
|
|
|
4827
4902
|
const reactData = $xeTable
|
|
4828
4903
|
|
|
4829
4904
|
clearRowDropOrigin($xeTable)
|
|
4830
|
-
|
|
4905
|
+
hideDropTip($xeTable)
|
|
4831
4906
|
reactData.dragRow = null
|
|
4907
|
+
reactData.dragCol = null
|
|
4832
4908
|
reactData.isDragRowMove = false
|
|
4833
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
|
+
},
|
|
4834
5070
|
setPendingRow (rows: any, status: any) {
|
|
4835
5071
|
const pendingMaps = { ...this.pendingRowMaps }
|
|
4836
5072
|
const pendingList = [...this.pendingRowList]
|
|
@@ -6306,8 +6542,8 @@ const Methods = {
|
|
|
6306
6542
|
}
|
|
6307
6543
|
},
|
|
6308
6544
|
updateCellAreas () {
|
|
6309
|
-
if (this.mouseConfig && this.mouseOpts.area && this.
|
|
6310
|
-
return this.
|
|
6545
|
+
if (this.mouseConfig && this.mouseOpts.area && this.handleRecalculateCellAreas) {
|
|
6546
|
+
return this.handleRecalculateCellAreas()
|
|
6311
6547
|
}
|
|
6312
6548
|
return this.$nextTick()
|
|
6313
6549
|
},
|
|
@@ -6370,7 +6606,7 @@ const Methods = {
|
|
|
6370
6606
|
} as any
|
|
6371
6607
|
|
|
6372
6608
|
// Module methods
|
|
6373
|
-
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',')
|
|
6609
|
+
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',')
|
|
6374
6610
|
|
|
6375
6611
|
funcs.forEach(name => {
|
|
6376
6612
|
Methods[name] = function (...args: any[]) {
|
|
@@ -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
|
// 序号配置项
|