vxe-table 4.8.16 → 4.9.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.
Files changed (82) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/README.zh-TW.md +1 -1
  4. package/es/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/custom/hook.js +4 -0
  7. package/es/table/module/edit/hook.js +46 -34
  8. package/es/table/module/filter/hook.js +2 -3
  9. package/es/table/module/keyboard/hook.js +2 -2
  10. package/es/table/src/body.js +31 -24
  11. package/es/table/src/cell.js +99 -59
  12. package/es/table/src/emits.js +3 -0
  13. package/es/table/src/footer.js +177 -147
  14. package/es/table/src/header.js +144 -107
  15. package/es/table/src/props.js +5 -1
  16. package/es/table/src/table.js +346 -108
  17. package/es/table/src/util.js +9 -0
  18. package/es/table/style.css +33 -20
  19. package/es/table/style.min.css +1 -1
  20. package/es/ui/index.js +9 -4
  21. package/es/ui/src/log.js +1 -1
  22. package/es/vxe-table/style.css +33 -20
  23. package/es/vxe-table/style.min.css +1 -1
  24. package/helper/vetur/attributes.json +1 -1
  25. package/helper/vetur/tags.json +1 -1
  26. package/lib/index.umd.js +1032 -580
  27. package/lib/index.umd.min.js +1 -1
  28. package/lib/style.css +1 -1
  29. package/lib/style.min.css +1 -1
  30. package/lib/table/module/custom/hook.js +4 -0
  31. package/lib/table/module/custom/hook.min.js +1 -1
  32. package/lib/table/module/edit/hook.js +54 -42
  33. package/lib/table/module/edit/hook.min.js +1 -1
  34. package/lib/table/module/filter/hook.js +1 -2
  35. package/lib/table/module/filter/hook.min.js +1 -1
  36. package/lib/table/module/keyboard/hook.js +2 -2
  37. package/lib/table/module/keyboard/hook.min.js +1 -1
  38. package/lib/table/src/body.js +34 -21
  39. package/lib/table/src/body.min.js +1 -1
  40. package/lib/table/src/cell.js +110 -51
  41. package/lib/table/src/cell.min.js +1 -1
  42. package/lib/table/src/emits.js +1 -1
  43. package/lib/table/src/emits.min.js +1 -1
  44. package/lib/table/src/footer.js +222 -183
  45. package/lib/table/src/footer.min.js +1 -1
  46. package/lib/table/src/header.js +188 -150
  47. package/lib/table/src/header.min.js +1 -1
  48. package/lib/table/src/props.js +5 -1
  49. package/lib/table/src/props.min.js +1 -1
  50. package/lib/table/src/table.js +380 -110
  51. package/lib/table/src/table.min.js +1 -1
  52. package/lib/table/src/util.js +10 -0
  53. package/lib/table/src/util.min.js +1 -1
  54. package/lib/table/style/style.css +33 -20
  55. package/lib/table/style/style.min.css +1 -1
  56. package/lib/ui/index.js +9 -4
  57. package/lib/ui/index.min.js +1 -1
  58. package/lib/ui/src/log.js +1 -1
  59. package/lib/ui/src/log.min.js +1 -1
  60. package/lib/vxe-table/style/style.css +33 -20
  61. package/lib/vxe-table/style/style.min.css +1 -1
  62. package/package.json +3 -3
  63. package/packages/table/module/custom/hook.ts +4 -0
  64. package/packages/table/module/edit/hook.ts +47 -34
  65. package/packages/table/module/filter/hook.ts +2 -3
  66. package/packages/table/module/keyboard/hook.ts +2 -2
  67. package/packages/table/src/body.ts +46 -31
  68. package/packages/table/src/cell.ts +140 -92
  69. package/packages/table/src/emits.ts +3 -0
  70. package/packages/table/src/footer.ts +189 -152
  71. package/packages/table/src/header.ts +157 -116
  72. package/packages/table/src/props.ts +5 -1
  73. package/packages/table/src/table.ts +358 -109
  74. package/packages/table/src/util.ts +10 -0
  75. package/packages/ui/index.ts +8 -3
  76. package/styles/components/table.scss +42 -35
  77. /package/es/{iconfont.1731633504443.ttf → iconfont.1731895336421.ttf} +0 -0
  78. /package/es/{iconfont.1731633504443.woff → iconfont.1731895336421.woff} +0 -0
  79. /package/es/{iconfont.1731633504443.woff2 → iconfont.1731895336421.woff2} +0 -0
  80. /package/lib/{iconfont.1731633504443.ttf → iconfont.1731895336421.ttf} +0 -0
  81. /package/lib/{iconfont.1731633504443.woff → iconfont.1731895336421.woff} +0 -0
  82. /package/lib/{iconfont.1731633504443.woff2 → iconfont.1731895336421.woff2} +0 -0
@@ -256,6 +256,41 @@ hooks.add('tableEditModule', {
256
256
  })
257
257
  }
258
258
 
259
+ const handleClearEdit = (evnt: Event | null, targetRow?: any) => {
260
+ const { editStore } = reactData
261
+ const { actived, focused } = editStore
262
+ const { row, column } = actived
263
+ const validOpts = computeValidOpts.value
264
+ if (row || column) {
265
+ if (targetRow && getRowid($xeTable, targetRow) !== getRowid($xeTable, row)) {
266
+ return nextTick()
267
+ }
268
+ syncActivedCell()
269
+ actived.args = null
270
+ actived.row = null
271
+ actived.column = null
272
+ $xeTable.updateFooter()
273
+ $xeTable.dispatchEvent('edit-closed', {
274
+ row,
275
+ rowIndex: $xeTable.getRowIndex(row),
276
+ $rowIndex: $xeTable.getVMRowIndex(row),
277
+ column,
278
+ columnIndex: $xeTable.getColumnIndex(column),
279
+ $columnIndex: $xeTable.getVMColumnIndex(column)
280
+ }, evnt || null)
281
+ }
282
+ if (validOpts.autoClear) {
283
+ if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
284
+ if ($xeTable.clearValidate) {
285
+ return $xeTable.clearValidate()
286
+ }
287
+ }
288
+ }
289
+ focused.row = null
290
+ focused.column = null
291
+ return nextTick()
292
+ }
293
+
259
294
  editMethods = {
260
295
  /**
261
296
  * 往表格中插入临时数据
@@ -514,46 +549,18 @@ hooks.add('tableEditModule', {
514
549
  }
515
550
  return null
516
551
  },
517
- clearActived (evnt) {
552
+ clearActived (row) {
518
553
  // 即将废弃
519
554
  if (process.env.VUE_APP_VXE_ENV === 'development') {
520
555
  warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit'])
521
556
  }
522
- return this.clearEdit(evnt)
557
+ return this.clearEdit(row)
523
558
  },
524
559
  /**
525
560
  * 清除激活的编辑
526
561
  */
527
- clearEdit (evnt) {
528
- const { editStore } = reactData
529
- const { actived, focused } = editStore
530
- const { row, column } = actived
531
- const validOpts = computeValidOpts.value
532
- if (row || column) {
533
- syncActivedCell()
534
- actived.args = null
535
- actived.row = null
536
- actived.column = null
537
- $xeTable.updateFooter()
538
- $xeTable.dispatchEvent('edit-closed', {
539
- row,
540
- rowIndex: $xeTable.getRowIndex(row),
541
- $rowIndex: $xeTable.getVMRowIndex(row),
542
- column,
543
- columnIndex: $xeTable.getColumnIndex(column),
544
- $columnIndex: $xeTable.getVMColumnIndex(column)
545
- }, evnt || null)
546
- }
547
- if (validOpts.autoClear) {
548
- if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
549
- if ($xeTable.clearValidate) {
550
- return $xeTable.clearValidate()
551
- }
552
- }
553
- }
554
- focused.row = null
555
- focused.column = null
556
- return nextTick()
562
+ clearEdit (row) {
563
+ return handleClearEdit(null, row)
557
564
  },
558
565
  /**
559
566
  * 清除所选中源状态
@@ -687,7 +694,7 @@ hooks.add('tableEditModule', {
687
694
  }
688
695
  $xeTable.closeTooltip()
689
696
  if (actived.column) {
690
- editMethods.clearEdit(evnt)
697
+ handleClearEdit(evnt)
691
698
  }
692
699
  type = 'edit-activated'
693
700
  column.renderHeight = cell.offsetHeight
@@ -765,6 +772,12 @@ hooks.add('tableEditModule', {
765
772
  handleActived (params, evnt) {
766
773
  return editPrivateMethods.handleEdit(params, evnt)
767
774
  },
775
+ /**
776
+ * 处理取消编辑
777
+ * @param evnt
778
+ * @returns
779
+ */
780
+ handleClearEdit,
768
781
  /**
769
782
  * 处理聚焦
770
783
  */
@@ -836,7 +849,7 @@ hooks.add('tableEditModule', {
836
849
  const selectMethod = () => {
837
850
  if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
838
851
  if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
839
- editMethods.clearEdit(evnt)
852
+ handleClearEdit(evnt)
840
853
  editMethods.clearSelected()
841
854
  if ($xeTable.clearCellAreas) {
842
855
  $xeTable.clearCellAreas()
@@ -1,7 +1,7 @@
1
1
  import { nextTick } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../../ui'
4
- import { toFilters, handleFieldOrColumn } from '../../src/util'
4
+ import { toFilters, handleFieldOrColumn, getRefElem } from '../../src/util'
5
5
  import { getDomNode, triggerEvent } from '../../../ui/src/dom'
6
6
  import { isEnableConf } from '../../../ui/src/utils'
7
7
 
@@ -251,8 +251,7 @@ hooks.add('tableFilterModule', {
251
251
  const { elemStore } = internalData
252
252
  const { fixed } = column
253
253
  return $xeTable.scrollToColumn(column).then(() => {
254
- const headerWrapperRef = elemStore[`${fixed || 'main'}-header-wrapper`] || elemStore['main-header-wrapper']
255
- const headerWrapperElem = headerWrapperRef ? headerWrapperRef.value : null
254
+ const headerWrapperElem = getRefElem(elemStore[`${fixed || 'main'}-header-wrapper`] || elemStore['main-header-wrapper'])
256
255
  if (headerWrapperElem) {
257
256
  const filterBtnElem = headerWrapperElem.querySelector(`.vxe-header--column.${column.id} .vxe-filter--btn`) as HTMLElement
258
257
  triggerEvent(filterBtnElem, 'click')
@@ -1,5 +1,6 @@
1
1
  import XEUtils from 'xe-utils'
2
2
  import { VxeUI } from '../../../ui'
3
+ import { getRefElem } from '../../src/util'
3
4
  import { browse, hasClass, getAbsolutePos, addClass, removeClass, getEventTargetNode } from '../../../ui/src/dom'
4
5
 
5
6
  import type { TableKeyboardPrivateMethods } from '../../../../types'
@@ -79,8 +80,7 @@ hooks.add('tableKeyboardModule', {
79
80
  const { elemStore } = internalData
80
81
  const disX = evnt.clientX
81
82
  const disY = evnt.clientY
82
- const bodyWrapperRef = elemStore[`${column.fixed || 'main'}-body-wrapper`] || elemStore['main-body-wrapper']
83
- const bodyWrapperElem = bodyWrapperRef ? bodyWrapperRef.value : null
83
+ const bodyWrapperElem = getRefElem(elemStore[`${column.fixed || 'main'}-body-wrapper`] || elemStore['main-body-wrapper'])
84
84
  if (!bodyWrapperElem) {
85
85
  return
86
86
  }
@@ -1,7 +1,7 @@
1
1
  import { createCommentVNode, defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, ComputedRef, onBeforeUnmount, onMounted, onUnmounted } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../ui'
4
- import { mergeBodyMethod, getRowid, XEBodyScrollElement } from './util'
4
+ import { mergeBodyMethod, getRowid, XEBodyScrollElement, getRefElem } from './util'
5
5
  import { updateCellTitle, getPropClass, setScrollTop, setScrollLeft } from '../../ui/src/dom'
6
6
  import { isEnableConf } from '../../ui/src/utils'
7
7
  import { getSlotVNs } from '../../ui/src/vn'
@@ -359,7 +359,7 @@ export default defineComponent({
359
359
  getPropClass(className, params),
360
360
  getPropClass(allCellClassName, params)
361
361
  ],
362
- key: columnKey || columnOpts.useKey || rowOpts.useKey ? colid : $columnIndex,
362
+ key: columnKey || columnOpts.useKey || rowOpts.useKey || columnOpts.drag ? colid : $columnIndex,
363
363
  ...attrs,
364
364
  style: Object.assign({
365
365
  height: cellHeight
@@ -370,13 +370,14 @@ export default defineComponent({
370
370
 
371
371
  const renderRows = (fixedType: any, tableData: any, tableColumn: any) => {
372
372
  const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, showOverflow: allColumnOverflow, editConfig, treeConfig } = tableProps
373
- const { hasFixedColumn, treeExpandedMaps, scrollYLoad, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, pendingRowList } = tableReactData
373
+ const { hasFixedColumn, treeExpandedMaps, scrollYLoad, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, pendingRowList, isDragColMove } = tableReactData
374
374
  const { fullAllDataRowIdData } = tableInternalData
375
375
  const checkboxOpts = computeCheckboxOpts.value
376
376
  const radioOpts = computeRadioOpts.value
377
377
  const treeOpts = computeTreeOpts.value
378
378
  const editOpts = computeEditOpts.value
379
379
  const rowOpts = computeRowOpts.value
380
+ const columnOpts = computeColumnOpts.value
380
381
  const { transform } = treeOpts
381
382
  const childrenField = treeOpts.children || treeOpts.childrenField
382
383
  const rows: any[] = []
@@ -431,30 +432,44 @@ export default defineComponent({
431
432
  rowChildren = row[childrenField]
432
433
  isExpandTree = rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
433
434
  }
435
+ const trClass = [
436
+ 'vxe-body--row',
437
+ treeConfig ? `row--level-${rowLevel}` : '',
438
+ {
439
+ 'row--stripe': stripe && ($xeTable.getVTRowIndex(row) + 1) % 2 === 0,
440
+ 'is--new': isNewRow,
441
+ 'is--expand-row': isExpandRow,
442
+ 'is--expand-tree': isExpandTree,
443
+ 'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
444
+ 'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
445
+ 'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
446
+ 'row--pending': pendingRowList.length && !!pendingRowMaps[rowid]
447
+ },
448
+ getPropClass(rowClassName, params)
449
+ ]
450
+ const tdVNs = tableColumn.map((column: any, $columnIndex: any) => {
451
+ return renderColumn(seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
452
+ })
434
453
  rows.push(
435
- h('tr', {
436
- class: [
437
- 'vxe-body--row',
438
- treeConfig ? `row--level-${rowLevel}` : '',
439
- {
440
- 'row--stripe': stripe && ($xeTable.getVTRowIndex(row) + 1) % 2 === 0,
441
- 'is--new': isNewRow,
442
- 'is--expand-row': isExpandRow,
443
- 'is--expand-tree': isExpandTree,
444
- 'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
445
- 'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
446
- 'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
447
- 'row--pending': pendingRowList.length && !!pendingRowMaps[rowid]
448
- },
449
- getPropClass(rowClassName, params)
450
- ],
451
- rowid: rowid,
452
- style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : null,
453
- key: rowKey || rowOpts.useKey || rowOpts.drag || treeConfig ? rowid : $rowIndex,
454
- ...trOn
455
- }, tableColumn.map((column: any, $columnIndex: any) => {
456
- return renderColumn(seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
457
- }))
454
+ columnOpts.drag
455
+ ? h(TransitionGroup, {
456
+ name: `vxe-header--col-list${isDragColMove ? '' : '-disabled'}`,
457
+ tag: 'tr',
458
+ class: trClass,
459
+ rowid: rowid,
460
+ style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : null,
461
+ key: rowKey || rowOpts.useKey || rowOpts.drag || treeConfig ? rowid : $rowIndex,
462
+ ...trOn
463
+ }, {
464
+ default: () => tdVNs
465
+ })
466
+ : h('tr', {
467
+ class: trClass,
468
+ rowid: rowid,
469
+ style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : null,
470
+ key: rowKey || rowOpts.useKey || rowOpts.drag || treeConfig ? rowid : $rowIndex,
471
+ ...trOn
472
+ }, tdVNs)
458
473
  )
459
474
  // 如果行被展开了
460
475
  if (isExpandRow) {
@@ -578,10 +593,8 @@ export default defineComponent({
578
593
  const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
579
594
  const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
580
595
  const bodyElem = tableBody.$el as HTMLDivElement
581
- const bodyYRef = elemStore['main-body-ySpace']
582
- const bodyYElem = bodyYRef ? bodyYRef.value : null
583
- const bodyXRef = elemStore['main-body-xSpace']
584
- const bodyXElem = bodyXRef ? bodyXRef.value : null
596
+ const bodyYElem = getRefElem(elemStore['main-body-ySpace'])
597
+ const bodyXElem = getRefElem(elemStore['main-body-xSpace'])
585
598
  const bodyHeight = scrollYLoad && bodyYElem ? bodyYElem.clientHeight : bodyElem.clientHeight
586
599
  const bodyWidth = scrollXLoad && bodyXElem ? bodyXElem.clientWidth : bodyElem.clientWidth
587
600
  const remainSize = isPrevWheelTop === isTopWheel ? Math.max(0, wheelYSize - wheelYTotal) : 0
@@ -712,6 +725,7 @@ export default defineComponent({
712
725
  const emptyOpts = computeEmptyOpts.value
713
726
  const keyboardOpts = computeKeyboardOpts.value
714
727
  const mouseOpts = computeMouseOpts.value
728
+ const columnOpts = computeColumnOpts.value
715
729
  // const isMergeLeftFixedExceeded = computeIsMergeLeftFixedExceeded.value
716
730
  // const isMergeRightFixedExceeded = computeIsMergeRightFixedExceeded.value
717
731
  // 如果是使用优化模式
@@ -787,8 +801,9 @@ export default defineComponent({
787
801
  /**
788
802
  * 内容
789
803
  */
790
- rowOpts.drag
804
+ rowOpts.drag || columnOpts.drag
791
805
  ? h(TransitionGroup, {
806
+ ref: refBodyTBody,
792
807
  name: `vxe-body--row-list${isDragRowMove ? '' : '-disabled'}`,
793
808
  tag: 'tbody'
794
809
  }, {
@@ -13,45 +13,46 @@ const { getI18n, getIcon, renderer, formats, renderEmptyElement } = VxeUI
13
13
  function renderTitlePrefixIcon (params: VxeTableDefines.CellRenderHeaderParams) {
14
14
  const { $table, column } = params
15
15
  const titlePrefix = column.titlePrefix || column.titleHelp
16
- return titlePrefix
17
- ? [
18
- h('i', {
19
- class: ['vxe-cell-title-prefix-icon', titlePrefix.icon || getIcon().TABLE_TITLE_PREFIX],
20
- onMouseenter (evnt: MouseEvent) {
21
- $table.triggerHeaderTitleEvent(evnt, titlePrefix, params)
22
- },
23
- onMouseleave (evnt: MouseEvent) {
24
- $table.handleTargetLeaveEvent(evnt)
25
- }
26
- })
27
- ]
28
- : []
16
+ if (titlePrefix) {
17
+ return h('i', {
18
+ class: ['vxe-cell-title-prefix-icon', titlePrefix.icon || getIcon().TABLE_TITLE_PREFIX],
19
+ onMouseenter (evnt: MouseEvent) {
20
+ $table.triggerHeaderTitleEvent(evnt, titlePrefix, params)
21
+ },
22
+ onMouseleave (evnt: MouseEvent) {
23
+ $table.handleTargetLeaveEvent(evnt)
24
+ }
25
+ })
26
+ }
27
+ return renderEmptyElement($table)
29
28
  }
30
29
 
31
30
  function renderTitleSuffixIcon (params: VxeTableDefines.CellRenderHeaderParams) {
32
31
  const { $table, column } = params
33
32
  const titleSuffix = column.titleSuffix
34
- return titleSuffix
35
- ? [
36
- h('i', {
37
- class: ['vxe-cell-title-suffix-icon', titleSuffix.icon || getIcon().TABLE_TITLE_SUFFIX],
38
- onMouseenter (evnt: MouseEvent) {
39
- $table.triggerHeaderTitleEvent(evnt, titleSuffix, params)
40
- },
41
- onMouseleave (evnt: MouseEvent) {
42
- $table.handleTargetLeaveEvent(evnt)
43
- }
44
- })
45
- ]
46
- : []
33
+ if (titleSuffix) {
34
+ h('i', {
35
+ class: ['vxe-cell-title-suffix-icon', titleSuffix.icon || getIcon().TABLE_TITLE_SUFFIX],
36
+ onMouseenter (evnt: MouseEvent) {
37
+ $table.triggerHeaderTitleEvent(evnt, titleSuffix, params)
38
+ },
39
+ onMouseleave (evnt: MouseEvent) {
40
+ $table.handleTargetLeaveEvent(evnt)
41
+ }
42
+ })
43
+ }
44
+ return renderEmptyElement($table)
47
45
  }
48
46
 
49
47
  function renderCellDragIcon (params: VxeTableDefines.CellRenderBodyParams) {
50
48
  const { $table } = params
51
- const { computeDragOpts } = $table.getComputeMaps()
52
- const dragOpts = computeDragOpts.value
53
- const { rowIcon, rowDisabledMethod } = dragOpts
54
- const isDisabled = rowDisabledMethod && rowDisabledMethod(params)
49
+ const tableProps = $table.props
50
+ const { dragConfig } = tableProps
51
+ const { computeRowDragOpts } = $table.getComputeMaps()
52
+ const rowDragOpts = computeRowDragOpts.value
53
+ const { icon, disabledMethod } = rowDragOpts
54
+ const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null)
55
+ const isDisabled = rDisabledMethod && rDisabledMethod(params)
55
56
  return h('span', {
56
57
  key: 'dg',
57
58
  class: ['vxe-cell--drag-handle', {
@@ -65,7 +66,7 @@ function renderCellDragIcon (params: VxeTableDefines.CellRenderBodyParams) {
65
66
  onMouseup: $table.handleCellDragMouseupEvent
66
67
  }, [
67
68
  h('i', {
68
- class: rowIcon || getIcon().TABLE_DRAG_ROW
69
+ class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW
69
70
  })
70
71
  ])
71
72
  }
@@ -74,13 +75,14 @@ function renderCellBaseVNs (params: VxeTableDefines.CellRenderBodyParams, conten
74
75
  const { $table, column, level } = params
75
76
  const { dragSort } = column
76
77
  const tableProps = $table.props
77
- const { treeConfig } = tableProps
78
- const { computeRowOpts, computeDragOpts } = $table.getComputeMaps()
78
+ const { treeConfig, dragConfig } = tableProps
79
+ const { computeRowOpts, computeRowDragOpts } = $table.getComputeMaps()
79
80
  const rowOpts = computeRowOpts.value
80
- const dragOpts = computeDragOpts.value
81
- const { showRowIcon, rowVisibleMethod } = dragOpts
81
+ const rowDragOpts = computeRowDragOpts.value
82
+ const { showIcon, visibleMethod } = rowDragOpts
83
+ const rVisibleMethod = visibleMethod || (dragConfig ? dragConfig.rowVisibleMethod : null)
82
84
  const vns: VxeComponentSlotType[] = XEUtils.isArray(content) ? content : [content]
83
- if (dragSort && rowOpts.drag && (showRowIcon && (!rowVisibleMethod || rowVisibleMethod(params)))) {
85
+ if (dragSort && rowOpts.drag && ((showIcon || (dragConfig ? dragConfig.showRowIcon : false)) && (!rVisibleMethod || rVisibleMethod(params)))) {
84
86
  if (!treeConfig || !level) {
85
87
  vns.unshift(
86
88
  renderCellDragIcon(params)
@@ -90,6 +92,46 @@ function renderCellBaseVNs (params: VxeTableDefines.CellRenderBodyParams, conten
90
92
  return vns
91
93
  }
92
94
 
95
+ function renderHeaderCellDragIcon (params: VxeTableDefines.CellRenderHeaderParams) {
96
+ const { $table, column } = params
97
+ const { computeColumnOpts, computeColumnDragOpts } = $table.getComputeMaps()
98
+ const columnOpts = computeColumnOpts.value
99
+ const columnDragOpts = computeColumnDragOpts.value
100
+ const { showIcon, icon, visibleMethod, disabledMethod } = columnDragOpts
101
+ const isDisabled = disabledMethod && disabledMethod(params)
102
+ if (columnOpts.drag && showIcon && (!visibleMethod || visibleMethod(params))) {
103
+ if (!(column.fixed || column.parentId)) {
104
+ return h('span', {
105
+ key: 'dg',
106
+ class: ['vxe-cell--drag-handle', {
107
+ 'is--disabled': isDisabled
108
+ }],
109
+ onMousedown (evnt) {
110
+ if (!isDisabled) {
111
+ $table.handleHeaderCellDragMousedownEvent(evnt, params)
112
+ }
113
+ },
114
+ onMouseup: $table.handleHeaderCellDragMouseupEvent
115
+ }, [
116
+ h('i', {
117
+ class: icon || getIcon().TABLE_DRAG_COLUMN
118
+ })
119
+ ])
120
+ }
121
+ }
122
+ return renderEmptyElement($table)
123
+ }
124
+
125
+ function renderHeaderCellBaseVNs (params: VxeTableDefines.CellRenderHeaderParams, content: VNode | VNode[]) {
126
+ const vns = [
127
+ renderTitlePrefixIcon(params),
128
+ renderHeaderCellDragIcon(params),
129
+ ...(XEUtils.isArray(content) ? content : [content]),
130
+ renderTitleSuffixIcon(params)
131
+ ]
132
+ return vns
133
+ }
134
+
93
135
  function renderTitleContent (params: VxeTableDefines.CellRenderHeaderParams, content: VxeComponentSlotType | VxeComponentSlotType[]) {
94
136
  const { $table, column } = params
95
137
  const { props, reactData } = $table
@@ -264,7 +306,7 @@ export const Cell = {
264
306
  return createColumn($xeTable, columnOpts, renConfs)
265
307
  },
266
308
  /**
267
- * 单元格
309
+ * 列头标题
268
310
  */
269
311
  renderHeaderTitle (params: VxeTableDefines.CellRenderHeaderParams) {
270
312
  const { $table, column } = params
@@ -286,7 +328,7 @@ export const Cell = {
286
328
  return renderTitleContent(params, formatText(column.getTitle(), 1))
287
329
  },
288
330
  renderDefaultHeader (params: VxeTableDefines.CellRenderHeaderParams) {
289
- return renderTitlePrefixIcon(params).concat(Cell.renderHeaderTitle(params)).concat(renderTitleSuffixIcon(params))
331
+ return renderHeaderCellBaseVNs(params, Cell.renderHeaderTitle(params))
290
332
  },
291
333
  renderDefaultCell (params: VxeTableDefines.CellRenderBodyParams) {
292
334
  const { $table, row, column } = params
@@ -404,13 +446,13 @@ export const Cell = {
404
446
  },
405
447
 
406
448
  /**
407
- * 索引
449
+ * 序号
408
450
  */
409
451
  renderSeqHeader (params: VxeTableDefines.CellRenderHeaderParams) {
410
452
  const { $table, column } = params
411
453
  const { slots } = column
412
454
  const headerSlot = slots ? slots.header : null
413
- return renderTitleContent(params, headerSlot ? $table.callSlot(headerSlot, params) : formatText(column.getTitle(), 1))
455
+ return renderHeaderCellBaseVNs(params, renderTitleContent(params, headerSlot ? $table.callSlot(headerSlot, params) : formatText(column.getTitle(), 1)))
414
456
  },
415
457
  renderSeqCell (params: VxeTableDefines.CellRenderBodyParams) {
416
458
  const { $table, column } = params
@@ -441,13 +483,15 @@ export const Cell = {
441
483
  const { slots } = column
442
484
  const headerSlot = slots ? slots.header : null
443
485
  const titleSlot = slots ? slots.title : null
444
- return renderTitleContent(params, headerSlot
445
- ? $table.callSlot(headerSlot, params)
446
- : [
447
- h('span', {
448
- class: 'vxe-radio--label'
449
- }, titleSlot ? $table.callSlot(titleSlot, params) : formatText(column.getTitle(), 1))
450
- ])
486
+ return renderHeaderCellBaseVNs(params,
487
+ renderTitleContent(params, headerSlot
488
+ ? $table.callSlot(headerSlot, params)
489
+ : [
490
+ h('span', {
491
+ class: 'vxe-radio--label'
492
+ }, titleSlot ? $table.callSlot(titleSlot, params) : formatText(column.getTitle(), 1))
493
+ ])
494
+ )
451
495
  },
452
496
  renderRadioCell (params: VxeTableDefines.CellRenderBodyParams) {
453
497
  const { $table, column, isHidden } = params
@@ -535,36 +579,38 @@ export const Cell = {
535
579
  }
536
580
  const checkboxParams = { ...params, checked: isAllCheckboxSelected, disabled: isAllCheckboxDisabled, indeterminate: isAllCheckboxIndeterminate }
537
581
  if (headerSlot) {
538
- return renderTitleContent(checkboxParams, $table.callSlot(headerSlot, checkboxParams))
582
+ return renderHeaderCellBaseVNs(params, renderTitleContent(checkboxParams, $table.callSlot(headerSlot, checkboxParams)))
539
583
  }
540
584
  if (checkboxOpts.checkStrictly ? !checkboxOpts.showHeader : checkboxOpts.showHeader === false) {
541
- return renderTitleContent(checkboxParams, [
585
+ return renderHeaderCellBaseVNs(params, renderTitleContent(checkboxParams, [
542
586
  h('span', {
543
587
  class: 'vxe-checkbox--label'
544
588
  }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)
545
- ])
589
+ ]))
546
590
  }
547
- return renderTitleContent(checkboxParams, [
548
- h('span', {
549
- class: ['vxe-cell--checkbox', {
550
- 'is--checked': isAllCheckboxSelected,
551
- 'is--disabled': isAllCheckboxDisabled,
552
- 'is--indeterminate': isAllCheckboxIndeterminate
553
- }],
554
- title: getI18n('vxe.table.allTitle'),
555
- ...ons
556
- }, [
591
+ return renderHeaderCellBaseVNs(params,
592
+ renderTitleContent(checkboxParams, [
557
593
  h('span', {
558
- class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
559
- })
560
- ].concat(titleSlot || headerTitle
561
- ? [
562
- h('span', {
563
- class: 'vxe-checkbox--label'
564
- }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)
565
- ]
566
- : []))
567
- ])
594
+ class: ['vxe-cell--checkbox', {
595
+ 'is--checked': isAllCheckboxSelected,
596
+ 'is--disabled': isAllCheckboxDisabled,
597
+ 'is--indeterminate': isAllCheckboxIndeterminate
598
+ }],
599
+ title: getI18n('vxe.table.allTitle'),
600
+ ...ons
601
+ }, [
602
+ h('span', {
603
+ class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
604
+ })
605
+ ].concat(titleSlot || headerTitle
606
+ ? [
607
+ h('span', {
608
+ class: 'vxe-checkbox--label'
609
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)
610
+ ]
611
+ : []))
612
+ ])
613
+ )
568
614
  },
569
615
  renderCheckboxCell (params: VxeTableDefines.CellRenderBodyParams) {
570
616
  const { $table, row, column, isHidden } = params
@@ -786,23 +832,21 @@ export const Cell = {
786
832
  ])
787
833
  },
788
834
  renderTreeHTMLCell (params: VxeTableDefines.CellRenderBodyParams) {
789
- return Cell.renderTreeIcon(params, Cell.renderHTMLCell(params) as VNode[])
835
+ return Cell.renderTreeIcon(params, Cell.renderHTMLCell(params))
790
836
  },
791
837
 
792
838
  /**
793
839
  * 排序和筛选
794
840
  */
795
841
  renderSortAndFilterHeader (params: VxeTableDefines.CellRenderHeaderParams) {
796
- return Cell.renderDefaultHeader(params)
797
- .concat(Cell.renderSortIcon(params))
798
- .concat(Cell.renderFilterIcon(params))
842
+ return renderHeaderCellBaseVNs(params, Cell.renderHeaderTitle(params).concat(Cell.renderSortIcon(params).concat(Cell.renderFilterIcon(params))))
799
843
  },
800
844
 
801
845
  /**
802
846
  * 排序
803
847
  */
804
848
  renderSortHeader (params: VxeTableDefines.CellRenderHeaderParams) {
805
- return Cell.renderDefaultHeader(params).concat(Cell.renderSortIcon(params))
849
+ return renderHeaderCellBaseVNs(params, Cell.renderHeaderTitle(params).concat(Cell.renderSortIcon(params)))
806
850
  },
807
851
  renderSortIcon (params: VxeTableDefines.CellRenderHeaderParams | VxeTableDefines.CellRenderHeaderParams) {
808
852
  const { $table, column } = params
@@ -845,7 +889,7 @@ export const Cell = {
845
889
  * 筛选
846
890
  */
847
891
  renderFilterHeader (params: VxeTableDefines.CellRenderHeaderParams) {
848
- return Cell.renderDefaultHeader(params).concat(Cell.renderFilterIcon(params))
892
+ return renderHeaderCellBaseVNs(params, Cell.renderHeaderTitle(params).concat(Cell.renderFilterIcon(params)))
849
893
  },
850
894
  renderFilterIcon (params: VxeTableDefines.CellRenderHeaderParams) {
851
895
  const { $table, column, hasFilter } = params
@@ -892,22 +936,26 @@ export const Cell = {
892
936
  isRequired = columnRules.some((rule) => rule.required)
893
937
  }
894
938
  }
895
- return (isEnableConf(editConfig)
896
- ? [
897
- isRequired && editOpts.showAsterisk
898
- ? h('i', {
899
- class: 'vxe-cell--required-icon'
900
- })
901
- : null,
902
- isEnableConf(editRender) && editOpts.showIcon
903
- ? h('i', {
904
- class: ['vxe-cell--edit-icon', editOpts.icon || getIcon().TABLE_EDIT]
905
- })
906
- : null
907
- ]
908
- : []).concat(Cell.renderDefaultHeader(params))
909
- .concat(sortable ? Cell.renderSortIcon(params) : [])
910
- .concat(filters ? Cell.renderFilterIcon(params) : [])
939
+ let editIconVNs: VNode[] = []
940
+ if (isEnableConf(editConfig)) {
941
+ editIconVNs = [
942
+ isRequired && editOpts.showAsterisk
943
+ ? h('i', {
944
+ class: 'vxe-cell--required-icon'
945
+ })
946
+ : renderEmptyElement($table),
947
+ isEnableConf(editRender) && editOpts.showIcon
948
+ ? h('i', {
949
+ class: ['vxe-cell--edit-icon', editOpts.icon || getIcon().TABLE_EDIT]
950
+ })
951
+ : renderEmptyElement($table)
952
+ ]
953
+ }
954
+ return renderHeaderCellBaseVNs(params,
955
+ editIconVNs.concat(Cell.renderHeaderTitle(params))
956
+ .concat(sortable ? Cell.renderSortIcon(params) : [])
957
+ .concat(filters ? Cell.renderFilterIcon(params) : [])
958
+ )
911
959
  },
912
960
  // 行格编辑模式
913
961
  renderRowEdit (params: VxeTableDefines.CellRenderBodyParams) {
@@ -45,6 +45,9 @@ export default [
45
45
  'row-dragstart',
46
46
  'row-dragover',
47
47
  'row-dragend',
48
+ 'column-dragstart',
49
+ 'column-dragover',
50
+ 'column-dragend',
48
51
 
49
52
  'edit-actived', // 废弃
50
53