vxe-table 4.12.0-beta.2 → 4.12.0-beta.21

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 (160) hide show
  1. package/es/grid/src/grid.js +61 -44
  2. package/es/locale/lang/ar-EG.js +7 -1
  3. package/es/locale/lang/de-DE.js +7 -1
  4. package/es/locale/lang/en-US.js +7 -1
  5. package/es/locale/lang/es-ES.js +7 -1
  6. package/es/locale/lang/fr-FR.js +7 -1
  7. package/es/locale/lang/hu-HU.js +7 -1
  8. package/es/locale/lang/hy-AM.js +7 -1
  9. package/es/locale/lang/id-ID.js +7 -1
  10. package/es/locale/lang/it-IT.js +7 -1
  11. package/es/locale/lang/ja-JP.js +7 -1
  12. package/es/locale/lang/ko-KR.js +7 -1
  13. package/es/locale/lang/nb-NO.js +7 -1
  14. package/es/locale/lang/pt-BR.js +7 -1
  15. package/es/locale/lang/ru-RU.js +7 -1
  16. package/es/locale/lang/th-TH.js +7 -1
  17. package/es/locale/lang/ug-CN.js +7 -1
  18. package/es/locale/lang/uk-UA.js +7 -1
  19. package/es/locale/lang/vi-VN.js +7 -1
  20. package/es/locale/lang/zh-CHT.js +7 -1
  21. package/es/locale/lang/zh-CN.js +7 -1
  22. package/es/style.css +1 -1
  23. package/es/table/module/edit/hook.js +8 -10
  24. package/es/table/module/filter/panel.js +12 -2
  25. package/es/table/module/keyboard/hook.js +47 -4
  26. package/es/table/module/validator/hook.js +2 -2
  27. package/es/table/render/index.js +91 -60
  28. package/es/table/src/body.js +22 -17
  29. package/es/table/src/cell.js +25 -20
  30. package/es/table/src/footer.js +9 -4
  31. package/es/table/src/header.js +2 -2
  32. package/es/table/src/props.js +4 -0
  33. package/es/table/src/table.js +616 -411
  34. package/es/table/src/util.js +58 -3
  35. package/es/ui/index.js +1 -1
  36. package/es/ui/src/log.js +1 -1
  37. package/helper/vetur/attributes.json +1 -1
  38. package/helper/vetur/tags.json +1 -1
  39. package/lib/grid/src/grid.js +58 -48
  40. package/lib/grid/src/grid.min.js +1 -1
  41. package/lib/index.umd.js +1281 -12149
  42. package/lib/index.umd.min.js +1 -1
  43. package/lib/locale/lang/ar-EG.js +7 -1
  44. package/lib/locale/lang/ar-EG.min.js +1 -1
  45. package/lib/locale/lang/de-DE.js +7 -1
  46. package/lib/locale/lang/de-DE.min.js +1 -1
  47. package/lib/locale/lang/en-US.js +7 -1
  48. package/lib/locale/lang/en-US.min.js +1 -1
  49. package/lib/locale/lang/en-US.umd.js +7 -1
  50. package/lib/locale/lang/es-ES.js +7 -1
  51. package/lib/locale/lang/es-ES.min.js +1 -1
  52. package/lib/locale/lang/es-ES.umd.js +7 -1
  53. package/lib/locale/lang/fr-FR.js +7 -1
  54. package/lib/locale/lang/fr-FR.min.js +1 -1
  55. package/lib/locale/lang/hu-HU.js +7 -1
  56. package/lib/locale/lang/hu-HU.min.js +1 -1
  57. package/lib/locale/lang/hu-HU.umd.js +7 -1
  58. package/lib/locale/lang/hy-AM.js +7 -1
  59. package/lib/locale/lang/hy-AM.min.js +1 -1
  60. package/lib/locale/lang/id-ID.js +7 -1
  61. package/lib/locale/lang/id-ID.min.js +1 -1
  62. package/lib/locale/lang/it-IT.js +7 -1
  63. package/lib/locale/lang/it-IT.min.js +1 -1
  64. package/lib/locale/lang/ja-JP.js +7 -1
  65. package/lib/locale/lang/ja-JP.min.js +1 -1
  66. package/lib/locale/lang/ja-JP.umd.js +7 -1
  67. package/lib/locale/lang/ko-KR.js +7 -1
  68. package/lib/locale/lang/ko-KR.min.js +1 -1
  69. package/lib/locale/lang/ko-KR.umd.js +7 -1
  70. package/lib/locale/lang/nb-NO.js +7 -1
  71. package/lib/locale/lang/nb-NO.min.js +1 -1
  72. package/lib/locale/lang/pt-BR.js +7 -1
  73. package/lib/locale/lang/pt-BR.min.js +1 -1
  74. package/lib/locale/lang/pt-BR.umd.js +7 -1
  75. package/lib/locale/lang/ru-RU.js +7 -1
  76. package/lib/locale/lang/ru-RU.min.js +1 -1
  77. package/lib/locale/lang/ru-RU.umd.js +7 -1
  78. package/lib/locale/lang/th-TH.js +7 -1
  79. package/lib/locale/lang/th-TH.min.js +1 -1
  80. package/lib/locale/lang/ug-CN.js +7 -1
  81. package/lib/locale/lang/ug-CN.min.js +1 -1
  82. package/lib/locale/lang/uk-UA.js +7 -1
  83. package/lib/locale/lang/uk-UA.min.js +1 -1
  84. package/lib/locale/lang/uk-UA.umd.js +7 -1
  85. package/lib/locale/lang/vi-VN.js +7 -1
  86. package/lib/locale/lang/vi-VN.min.js +1 -1
  87. package/lib/locale/lang/zh-CHT.js +7 -1
  88. package/lib/locale/lang/zh-CHT.min.js +1 -1
  89. package/lib/locale/lang/zh-CN.js +7 -1
  90. package/lib/locale/lang/zh-CN.min.js +1 -1
  91. package/lib/locale/lang/zh-CN.umd.js +7 -1
  92. package/lib/style.css +1 -1
  93. package/lib/table/module/edit/hook.js +10 -11
  94. package/lib/table/module/edit/hook.min.js +1 -1
  95. package/lib/table/module/filter/panel.js +8 -2
  96. package/lib/table/module/filter/panel.min.js +1 -1
  97. package/lib/table/module/keyboard/hook.js +51 -4
  98. package/lib/table/module/keyboard/hook.min.js +1 -1
  99. package/lib/table/module/validator/hook.js +3 -3
  100. package/lib/table/module/validator/hook.min.js +1 -1
  101. package/lib/table/render/index.js +100 -65
  102. package/lib/table/render/index.min.js +1 -1
  103. package/lib/table/src/body.js +27 -17
  104. package/lib/table/src/body.min.js +1 -1
  105. package/lib/table/src/cell.js +37 -21
  106. package/lib/table/src/cell.min.js +1 -1
  107. package/lib/table/src/footer.js +9 -3
  108. package/lib/table/src/footer.min.js +1 -1
  109. package/lib/table/src/header.js +2 -1
  110. package/lib/table/src/header.min.js +1 -1
  111. package/lib/table/src/props.js +4 -0
  112. package/lib/table/src/props.min.js +1 -1
  113. package/lib/table/src/table.js +727 -445
  114. package/lib/table/src/table.min.js +1 -1
  115. package/lib/table/src/util.js +65 -6
  116. package/lib/table/src/util.min.js +1 -1
  117. package/lib/ui/index.js +1 -1
  118. package/lib/ui/index.min.js +1 -1
  119. package/lib/ui/src/log.js +1 -1
  120. package/lib/ui/src/log.min.js +1 -1
  121. package/package.json +2 -2
  122. package/packages/grid/src/grid.ts +65 -50
  123. package/packages/locale/lang/ar-EG.ts +7 -1
  124. package/packages/locale/lang/de-DE.ts +7 -1
  125. package/packages/locale/lang/en-US.ts +7 -1
  126. package/packages/locale/lang/es-ES.ts +7 -1
  127. package/packages/locale/lang/fr-FR.ts +7 -1
  128. package/packages/locale/lang/hu-HU.ts +7 -1
  129. package/packages/locale/lang/hy-AM.ts +7 -1
  130. package/packages/locale/lang/id-ID.ts +7 -1
  131. package/packages/locale/lang/it-IT.ts +7 -1
  132. package/packages/locale/lang/ja-JP.ts +7 -1
  133. package/packages/locale/lang/ko-KR.ts +7 -1
  134. package/packages/locale/lang/nb-NO.ts +7 -1
  135. package/packages/locale/lang/pt-BR.ts +7 -1
  136. package/packages/locale/lang/ru-RU.ts +7 -1
  137. package/packages/locale/lang/th-TH.ts +7 -1
  138. package/packages/locale/lang/ug-CN.ts +7 -1
  139. package/packages/locale/lang/uk-UA.ts +7 -1
  140. package/packages/locale/lang/vi-VN.ts +7 -1
  141. package/packages/locale/lang/zh-CHT.ts +7 -1
  142. package/packages/locale/lang/zh-CN.ts +7 -1
  143. package/packages/table/module/edit/hook.ts +8 -10
  144. package/packages/table/module/filter/panel.ts +12 -2
  145. package/packages/table/module/keyboard/hook.ts +47 -6
  146. package/packages/table/module/validator/hook.ts +2 -2
  147. package/packages/table/render/index.ts +90 -59
  148. package/packages/table/src/body.ts +21 -16
  149. package/packages/table/src/cell.ts +25 -20
  150. package/packages/table/src/footer.ts +9 -4
  151. package/packages/table/src/header.ts +2 -2
  152. package/packages/table/src/props.ts +4 -0
  153. package/packages/table/src/table.ts +625 -411
  154. package/packages/table/src/util.ts +66 -3
  155. /package/es/{iconfont.1741080000843.ttf → iconfont.1742437957812.ttf} +0 -0
  156. /package/es/{iconfont.1741080000843.woff → iconfont.1742437957812.woff} +0 -0
  157. /package/es/{iconfont.1741080000843.woff2 → iconfont.1742437957812.woff2} +0 -0
  158. /package/lib/{iconfont.1741080000843.ttf → iconfont.1742437957812.ttf} +0 -0
  159. /package/lib/{iconfont.1741080000843.woff → iconfont.1742437957812.woff} +0 -0
  160. /package/lib/{iconfont.1741080000843.woff2 → iconfont.1742437957812.woff2} +0 -0
@@ -3,7 +3,7 @@ import { VxeUI } from '../../../ui'
3
3
  import { getRefElem } from '../../src/util'
4
4
  import { browse, hasClass, getAbsolutePos, addClass, removeClass } from '../../../ui/src/dom'
5
5
 
6
- import type { TableKeyboardPrivateMethods } from '../../../../types'
6
+ import type { TableKeyboardPrivateMethods, VxeTableDefines } from '../../../../types'
7
7
 
8
8
  const { hooks } = VxeUI
9
9
 
@@ -33,7 +33,7 @@ hooks.add('tableKeyboardModule', {
33
33
  setupTable ($xeTable) {
34
34
  const { props, reactData, internalData } = $xeTable
35
35
  const { refElem } = $xeTable.getRefMaps()
36
- const { computeEditOpts, computeCheckboxOpts, computeMouseOpts, computeTreeOpts, computeRowOpts, computeCellOpts, computeDefaultRowHeight } = $xeTable.getComputeMaps()
36
+ const { computeEditOpts, computeCheckboxOpts, computeMouseOpts, computeTreeOpts, computeRowOpts, computeColumnOpts, computeCellOpts, computeDefaultRowHeight, computeCurrentRowOpts, computeCurrentColumnOpts } = $xeTable.getComputeMaps()
37
37
 
38
38
  function getCheckboxRangeRows (evnt: MouseEvent, params: any, targetTrElem: HTMLElement, trRect: DOMRect, offsetClientTop: number, moveRange: number) {
39
39
  const { showOverflow } = props
@@ -282,7 +282,11 @@ hooks.add('tableKeyboardModule', {
282
282
  const { editConfig } = props
283
283
  const { afterFullData, visibleColumn } = internalData
284
284
  const editOpts = computeEditOpts.value
285
- let targetRow
285
+ const rowOpts = computeRowOpts.value
286
+ const currentRowOpts = computeCurrentRowOpts.value
287
+ const columnOpts = computeColumnOpts.value
288
+ const currentColumnOpts = computeCurrentColumnOpts.value
289
+ let targetRow: any
286
290
  let targetRowIndex: any
287
291
  let targetColumnIndex: any
288
292
  const params = Object.assign({}, args)
@@ -324,18 +328,28 @@ hooks.add('tableKeyboardModule', {
324
328
  params.columnIndex = targetColumnIndex
325
329
  params.column = targetColumn
326
330
  params.cell = $xeTable.getCellElement(params.row, params.column)
331
+ if (rowOpts.isCurrent && currentRowOpts.isFollowSelected) {
332
+ $xeTable.triggerCurrentRowEvent(evnt, params)
333
+ }
334
+ if (columnOpts.isCurrent && currentColumnOpts.isFollowSelected) {
335
+ $xeTable.triggerCurrentColumnEvent(evnt, params)
336
+ }
327
337
  if (editConfig) {
328
338
  if (editOpts.trigger === 'click' || editOpts.trigger === 'dblclick') {
329
339
  if (editOpts.mode === 'row') {
330
340
  $xeTable.handleEdit(params, evnt)
331
341
  } else {
332
342
  $xeTable.scrollToRow(params.row, params.column)
333
- .then(() => $xeTable.handleSelected(params, evnt))
343
+ .then(() => {
344
+ $xeTable.handleSelected(params, evnt)
345
+ })
334
346
  }
335
347
  }
336
348
  } else {
337
349
  $xeTable.scrollToRow(params.row, params.column)
338
- .then(() => $xeTable.handleSelected(params, evnt))
350
+ .then(() => {
351
+ $xeTable.handleSelected(params, evnt)
352
+ })
339
353
  }
340
354
  }
341
355
  },
@@ -347,7 +361,6 @@ hooks.add('tableKeyboardModule', {
347
361
  const treeOpts = computeTreeOpts.value
348
362
  const childrenField = treeOpts.children || treeOpts.childrenField
349
363
  let targetRow
350
- evnt.preventDefault()
351
364
  if (currentRow) {
352
365
  if (treeConfig) {
353
366
  const { index, items } = XEUtils.findTree(afterFullData, item => item === currentRow, { children: childrenField })
@@ -368,6 +381,7 @@ hooks.add('tableKeyboardModule', {
368
381
  targetRow = afterFullData[0]
369
382
  }
370
383
  if (targetRow) {
384
+ evnt.preventDefault()
371
385
  const params = {
372
386
  $table: $xeTable,
373
387
  row: targetRow,
@@ -378,6 +392,33 @@ hooks.add('tableKeyboardModule', {
378
392
  .then(() => $xeTable.triggerCurrentRowEvent(evnt, params))
379
393
  }
380
394
  },
395
+ // 处理当前列方向键移动
396
+ moveCurrentColumn (isLeftArrow, isRightArrow, evnt) {
397
+ const { currentColumn } = reactData
398
+ const { visibleColumn } = internalData
399
+ let targetCol: VxeTableDefines.ColumnInfo | null = null
400
+ if (currentColumn) {
401
+ const _columnIndex = $xeTable.getVTColumnIndex(currentColumn)
402
+ if (isLeftArrow && _columnIndex > 0) {
403
+ targetCol = visibleColumn[_columnIndex - 1]
404
+ } else if (isRightArrow && _columnIndex < visibleColumn.length - 1) {
405
+ targetCol = visibleColumn[_columnIndex + 1]
406
+ }
407
+ } else {
408
+ targetCol = visibleColumn[0]
409
+ }
410
+ if (targetCol) {
411
+ evnt.preventDefault()
412
+ const params = {
413
+ $table: $xeTable,
414
+ column: targetCol,
415
+ columnIndex: $xeTable.getColumnIndex(targetCol),
416
+ $columnIndex: $xeTable.getVMColumnIndex(targetCol)
417
+ }
418
+ $xeTable.scrollToColumn(targetCol)
419
+ .then(() => $xeTable.triggerCurrentColumnEvent(evnt, params))
420
+ }
421
+ },
381
422
  // 处理可编辑方向键移动
382
423
  moveSelected (args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt) {
383
424
  const { afterFullData, visibleColumn } = internalData
@@ -109,8 +109,8 @@ hooks.add('tableValidatorModule', {
109
109
  const beginValidate = (rows: any, cols: VxeTableDefines.ColumnInfo[] | null, cb: any, isFull?: boolean): Promise<any> => {
110
110
  const validRest: any = {}
111
111
  const { editRules, treeConfig } = props
112
- const { editStore, pendingRowMaps } = reactData
113
- const { afterFullData } = internalData
112
+ const { editStore } = reactData
113
+ const { afterFullData, pendingRowMaps } = internalData
114
114
  const { removeMaps } = editStore
115
115
  const treeOpts = computeTreeOpts.value
116
116
  const childrenField = treeOpts.children || treeOpts.childrenField
@@ -6,10 +6,9 @@ import { getFuncText, formatText, isEmptyValue } from '../../ui/src/utils'
6
6
  import { getOnName, getModelEvent, getChangeEvent } from '../../ui/src/vn'
7
7
  import { errLog } from '../../ui/src/log'
8
8
 
9
- import type { VxeButtonComponent } from 'vxe-pc-ui'
10
9
  import type { VxeGlobalRendererHandles, VxeColumnPropTypes, VxeTableConstructor, VxeTablePrivateMethods } from '../../../types'
11
10
 
12
- const { getConfig, renderer, getI18n } = VxeUI
11
+ const { getConfig, renderer, getI18n, getComponent } = VxeUI
13
12
 
14
13
  const componentDefaultModelProp = 'modelValue'
15
14
 
@@ -41,7 +40,7 @@ function getOldComponentName (name: string) {
41
40
  }
42
41
 
43
42
  function getDefaultComponent ({ name }: any) {
44
- return resolveComponent(name) as ComponentOptions
43
+ return getComponent(name)
45
44
  }
46
45
 
47
46
  /**
@@ -393,7 +392,7 @@ function oldEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOpti
393
392
  */
394
393
  function oldButtonEditRender (renderOpts: any, params: any) {
395
394
  return [
396
- h(resolveComponent('vxe-button') as VxeButtonComponent, {
395
+ h(getComponent('vxe-button'), {
397
396
  ...getCellEditProps(renderOpts, params, null),
398
397
  ...getComponentOns(renderOpts, params)
399
398
  })
@@ -609,6 +608,62 @@ function handleExportTreeSelectMethod (params: any) {
609
608
  return options.original ? getCellValue(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params)
610
609
  }
611
610
 
611
+ function handleNumberCell (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.RenderTableDefaultParams) {
612
+ const { props = {}, showNegativeStatus } = renderOpts
613
+ const { row, column } = params
614
+ const { type } = props
615
+ let cellValue = XEUtils.get(row, column.field)
616
+ let isNegative = false
617
+ if (!isEmptyValue(cellValue)) {
618
+ const numberInputConfig = getConfig().numberInput || {}
619
+ if (type === 'float') {
620
+ const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
621
+ const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
622
+ cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
623
+ if (!autoFill) {
624
+ cellValue = XEUtils.toNumber(cellValue)
625
+ }
626
+ if (showNegativeStatus) {
627
+ if (cellValue < 0) {
628
+ isNegative = true
629
+ }
630
+ }
631
+ } else if (type === 'amount') {
632
+ const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
633
+ const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
634
+ const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
635
+ cellValue = XEUtils.toNumber(cellValue)
636
+ if (showNegativeStatus) {
637
+ if (cellValue < 0) {
638
+ isNegative = true
639
+ }
640
+ }
641
+ cellValue = XEUtils.commafy(cellValue, { digits })
642
+ if (!autoFill) {
643
+ const [iStr, dStr] = cellValue.split('.')
644
+ if (dStr) {
645
+ const dRest = dStr.replace(/0+$/, '')
646
+ cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
647
+ }
648
+ }
649
+ if (showCurrency) {
650
+ cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
651
+ }
652
+ } else {
653
+ if (showNegativeStatus) {
654
+ if (XEUtils.toNumber(cellValue) < 0) {
655
+ isNegative = true
656
+ }
657
+ }
658
+ }
659
+ }
660
+ return getCellLabelVNs(renderOpts, params, cellValue, isNegative
661
+ ? {
662
+ class: 'is--negative'
663
+ }
664
+ : {})
665
+ }
666
+
612
667
  /**
613
668
  * 表格 - 渲染器
614
669
  */
@@ -674,64 +729,19 @@ renderer.mixin({
674
729
  renderTableFilter: defaultFilterRender,
675
730
  tableFilterDefaultMethod: handleInputFilterMethod
676
731
  },
732
+ FormatNumberInput: {
733
+ renderTableDefault: handleNumberCell,
734
+ tableFilterDefaultMethod: handleInputFilterMethod,
735
+ tableExportMethod (params) {
736
+ const { row, column } = params
737
+ const cellValue = XEUtils.get(row, column.field)
738
+ return cellValue
739
+ }
740
+ },
677
741
  VxeNumberInput: {
678
742
  tableAutoFocus: 'input',
679
743
  renderTableEdit: defaultEditRender,
680
- renderTableCell (renderOpts, params) {
681
- const { props = {}, showNegativeStatus } = renderOpts
682
- const { row, column } = params
683
- const { type } = props
684
- let cellValue = XEUtils.get(row, column.field)
685
- let isNegative = false
686
- if (!isEmptyValue(cellValue)) {
687
- const numberInputConfig = getConfig().numberInput || {}
688
- if (type === 'float') {
689
- const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
690
- const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
691
- cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
692
- if (!autoFill) {
693
- cellValue = XEUtils.toNumber(cellValue)
694
- }
695
- if (showNegativeStatus) {
696
- if (cellValue < 0) {
697
- isNegative = true
698
- }
699
- }
700
- } else if (type === 'amount') {
701
- const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
702
- const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
703
- const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
704
- cellValue = XEUtils.toNumber(cellValue)
705
- if (showNegativeStatus) {
706
- if (cellValue < 0) {
707
- isNegative = true
708
- }
709
- }
710
- cellValue = XEUtils.commafy(cellValue, { digits })
711
- if (!autoFill) {
712
- const [iStr, dStr] = cellValue.split('.')
713
- if (dStr) {
714
- const dRest = dStr.replace(/0+$/, '')
715
- cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
716
- }
717
- }
718
- if (showCurrency) {
719
- cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
720
- }
721
- } else {
722
- if (showNegativeStatus) {
723
- if (XEUtils.toNumber(cellValue) < 0) {
724
- isNegative = true
725
- }
726
- }
727
- }
728
- }
729
- return getCellLabelVNs(renderOpts, params, cellValue, isNegative
730
- ? {
731
- class: 'is--negative'
732
- }
733
- : {})
734
- },
744
+ renderTableCell: handleNumberCell,
735
745
  renderTableFooter (renderOpts, params) {
736
746
  const { props = {} } = renderOpts
737
747
  const { row, column, _columnIndex } = params
@@ -841,11 +851,22 @@ renderer.mixin({
841
851
  tableFilterDefaultMethod: handleFilterMethod,
842
852
  tableExportMethod: handleExportSelectMethod
843
853
  },
854
+ /**
855
+ * 已废弃,被 FormatSelect 替换
856
+ * @deprecated
857
+ */
844
858
  formatOption: {
845
859
  renderTableDefault (renderOpts, params) {
846
860
  return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
847
861
  }
848
862
  },
863
+ FormatSelect: {
864
+ renderTableDefault (renderOpts, params) {
865
+ return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params))
866
+ },
867
+ tableFilterDefaultMethod: handleFilterMethod,
868
+ tableExportMethod: handleExportSelectMethod
869
+ },
849
870
  VxeTreeSelect: {
850
871
  tableAutoFocus: 'input',
851
872
  renderTableEdit: defaultTableOrTreeSelectEditRender,
@@ -854,11 +875,21 @@ renderer.mixin({
854
875
  },
855
876
  tableExportMethod: handleExportTreeSelectMethod
856
877
  },
878
+ /**
879
+ * 已废弃,被 FormatTreeSelect 替换
880
+ * @deprecated
881
+ */
857
882
  formatTree: {
858
883
  renderTableDefault (renderOpts, params) {
859
884
  return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
860
885
  }
861
886
  },
887
+ FormatTreeSelect: {
888
+ renderTableDefault (renderOpts, params) {
889
+ return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
890
+ },
891
+ tableExportMethod: handleExportTreeSelectMethod
892
+ },
862
893
  VxeTableSelect: {
863
894
  tableAutoFocus: 'input',
864
895
  renderTableEdit: defaultTableOrTreeSelectEditRender,
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../ui'
4
- import { getOffsetSize, calcTreeLine, mergeBodyMethod, getRowid } from './util'
4
+ import { getOffsetSize, calcTreeLine, mergeBodyMethod, getRowid, createHandleGetRowId } from './util'
5
5
  import { updateCellTitle, getPropClass } from '../../ui/src/dom'
6
6
  import { isEnableConf } from '../../ui/src/utils'
7
7
  import { getSlotVNs } from '../../ui/src/vn'
@@ -45,7 +45,7 @@ export default defineComponent({
45
45
  return !!(isDragResize || (lastScrollTime && Date.now() < lastScrollTime + (delayHover as number)))
46
46
  }
47
47
 
48
- const renderLine = (params: VxeTableDefines.CellRenderBodyParams, cellHeight: number) => {
48
+ const renderLine = (rowid: string, params: VxeTableDefines.CellRenderBodyParams, cellHeight: number) => {
49
49
  const { row, column } = params
50
50
  const { afterFullData } = tableInternalData
51
51
  const { treeConfig } = tableProps
@@ -55,7 +55,6 @@ export default defineComponent({
55
55
  if (slots && (slots as any).line) {
56
56
  return $xeTable.callSlot((slots as any).line, params)
57
57
  }
58
- const rowid = getRowid($xeTable, row)
59
58
  const rest = fullAllDataRowIdData[rowid]
60
59
  let rLevel = 0
61
60
  let prevRow = null
@@ -230,6 +229,7 @@ export default defineComponent({
230
229
  tdOns.onDblclick = (evnt: MouseEvent) => {
231
230
  $xeTable.triggerCellDblclickEvent(evnt, cellParams)
232
231
  }
232
+ let isMergeCell = false
233
233
  // 合并行或列
234
234
  if (mergeList.length) {
235
235
  const spanRest = mergeBodyMethod(mergeList, _rowIndex, _columnIndex)
@@ -239,9 +239,11 @@ export default defineComponent({
239
239
  return null
240
240
  }
241
241
  if (rowspan > 1) {
242
+ isMergeCell = true
242
243
  tdAttrs.rowspan = rowspan
243
244
  }
244
245
  if (colspan > 1) {
246
+ isMergeCell = true
245
247
  tdAttrs.colspan = colspan
246
248
  }
247
249
  }
@@ -276,11 +278,13 @@ export default defineComponent({
276
278
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
277
279
 
278
280
  let isVNPreEmptyStatus = false
279
- if (!dragRow || getRowid($xeTable, dragRow) !== rowid) {
280
- if (scrollYLoad && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
281
- isVNPreEmptyStatus = true
282
- } else if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
283
- isVNPreEmptyStatus = true
281
+ if (!isMergeCell) {
282
+ if (!dragRow || getRowid($xeTable, dragRow) !== rowid) {
283
+ if (scrollYLoad && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
284
+ isVNPreEmptyStatus = true
285
+ } else if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
286
+ isVNPreEmptyStatus = true
287
+ }
284
288
  }
285
289
  }
286
290
 
@@ -307,7 +311,7 @@ export default defineComponent({
307
311
  } else {
308
312
  // 渲染单元格
309
313
  tdVNs.push(
310
- ...renderLine(cellParams, cellHeight),
314
+ ...renderLine(rowid, cellParams, cellHeight),
311
315
  h('div', {
312
316
  key: 'tc',
313
317
  class: ['vxe-cell', {
@@ -431,8 +435,8 @@ export default defineComponent({
431
435
 
432
436
  const renderRows = (fixedType: 'left' | 'right' | '', isOptimizeMode: boolean, tableData: any[], tableColumn: VxeTableDefines.ColumnInfo[]) => {
433
437
  const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps
434
- const { hasFixedColumn, treeExpandedMaps, isColLoading, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove, rowExpandHeightFlag } = tableReactData
435
- const { fullAllDataRowIdData } = tableInternalData
438
+ const { hasFixedColumn, treeExpandedFlag, isColLoading, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedFlag, expandColumn, selectRadioRow, pendingRowFlag, isDragColMove, rowExpandHeightFlag } = tableReactData
439
+ const { fullAllDataRowIdData, treeExpandedMaps, pendingRowMaps, rowExpandedMaps } = tableInternalData
436
440
  const checkboxOpts = computeCheckboxOpts.value
437
441
  const radioOpts = computeRadioOpts.value
438
442
  const treeOpts = computeTreeOpts.value
@@ -443,6 +447,7 @@ export default defineComponent({
443
447
  const { transform, seqMode } = treeOpts
444
448
  const childrenField = treeOpts.children || treeOpts.childrenField
445
449
  const rows: any[] = []
450
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
446
451
  tableData.forEach((row, $rowIndex) => {
447
452
  const trOn: Record<string, any> = {}
448
453
  let rowIndex = $rowIndex
@@ -463,7 +468,7 @@ export default defineComponent({
463
468
  $xeTable.clearHoverRow()
464
469
  }
465
470
  }
466
- const rowid = getRowid($xeTable, row)
471
+ const rowid = handleGetRowId(row)
467
472
  const rowRest = fullAllDataRowIdData[rowid]
468
473
  let rowLevel = 0
469
474
  let seq: string | number = -1
@@ -479,7 +484,7 @@ export default defineComponent({
479
484
  }
480
485
  const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
481
486
  // 行是否被展开
482
- const isExpandRow = expandColumn && !!rowExpandedMaps[rowid]
487
+ const isExpandRow = expandColumn && !!rowExpandedFlag && !!rowExpandedMaps[rowid]
483
488
  // 树节点是否被展开
484
489
  let isExpandTree = false
485
490
  let rowChildren = []
@@ -489,7 +494,7 @@ export default defineComponent({
489
494
  }
490
495
  if (treeConfig && !scrollYLoad && !transform) {
491
496
  rowChildren = row[childrenField]
492
- isExpandTree = rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
497
+ isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
493
498
  }
494
499
  // 拖拽行事件
495
500
  if (rowOpts.drag && (!treeConfig || transform)) {
@@ -508,7 +513,7 @@ export default defineComponent({
508
513
  'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
509
514
  'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
510
515
  'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
511
- 'row--pending': !!pendingRowMaps[rowid]
516
+ 'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid]
512
517
  },
513
518
  getPropClass(rowClassName, params)
514
519
  ]
@@ -657,7 +662,7 @@ export default defineComponent({
657
662
  }
658
663
  }
659
664
 
660
- if (fixedType || !overflowX) {
665
+ if (!isColLoading && (fixedType || !overflowX)) {
661
666
  renderColumnList = visibleColumn
662
667
  }
663
668
 
@@ -415,8 +415,8 @@ export const Cell = {
415
415
  const tableReactData = $table.reactData
416
416
  const tableInternalData = $table.internalData
417
417
  const { computeTreeOpts } = $table.getComputeMaps()
418
- const { treeExpandedMaps, treeExpandLazyLoadedMaps } = tableReactData
419
- const { fullAllDataRowIdData } = tableInternalData
418
+ const { treeExpandedFlag } = tableReactData
419
+ const { fullAllDataRowIdData, treeExpandedMaps, treeExpandLazyLoadedMaps } = tableInternalData
420
420
  const treeOpts = computeTreeOpts.value
421
421
  const { row, column, level } = params
422
422
  const { slots } = column
@@ -436,7 +436,7 @@ export const Cell = {
436
436
  }
437
437
  if (!isHidden) {
438
438
  const rowid = getRowid($table, row)
439
- isActive = !!treeExpandedMaps[rowid]
439
+ isActive = !!treeExpandedFlag && !!treeExpandedMaps[rowid]
440
440
  if (lazy) {
441
441
  const rest = fullAllDataRowIdData[rowid]
442
442
  isLazyLoading = !!treeExpandLazyLoadedMaps[rowid]
@@ -598,7 +598,8 @@ export const Cell = {
598
598
  const headerSlot = slots ? slots.header : null
599
599
  const titleSlot = slots ? slots.title : null
600
600
  const checkboxOpts = computeCheckboxOpts.value
601
- const headerTitle = column.getTitle()
601
+ const { checkStrictly, showHeader, headerTitle } = checkboxOpts
602
+ const colTitle = column.getTitle()
602
603
  const ons: Record<string, any> = {}
603
604
  if (!isHidden) {
604
605
  ons.onClick = (evnt: MouseEvent) => {
@@ -611,11 +612,11 @@ export const Cell = {
611
612
  if (headerSlot) {
612
613
  return renderHeaderCellBaseVNs(params, renderTitleContent(checkboxParams, $table.callSlot(headerSlot, checkboxParams)))
613
614
  }
614
- if (checkboxOpts.checkStrictly ? !checkboxOpts.showHeader : checkboxOpts.showHeader === false) {
615
+ if (checkStrictly ? !showHeader : showHeader === false) {
615
616
  return renderHeaderCellBaseVNs(params, renderTitleContent(checkboxParams, [
616
617
  h('span', {
617
618
  class: 'vxe-checkbox--label'
618
- }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)
619
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : colTitle)
619
620
  ]))
620
621
  }
621
622
  return renderHeaderCellBaseVNs(params,
@@ -626,17 +627,17 @@ export const Cell = {
626
627
  'is--disabled': isAllCheckboxDisabled,
627
628
  'is--indeterminate': isAllCheckboxIndeterminate
628
629
  }],
629
- title: getI18n('vxe.table.allTitle'),
630
+ title: XEUtils.eqNull(headerTitle) ? getI18n('vxe.table.allTitle') : `${headerTitle || ''}`,
630
631
  ...ons
631
632
  }, [
632
633
  h('span', {
633
634
  class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
634
635
  })
635
- ].concat(titleSlot || headerTitle
636
+ ].concat(titleSlot || colTitle
636
637
  ? [
637
638
  h('span', {
638
639
  class: 'vxe-checkbox--label'
639
- }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)
640
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : colTitle)
640
641
  ]
641
642
  : []))
642
643
  ])
@@ -646,8 +647,10 @@ export const Cell = {
646
647
  const { $table, row, column, isHidden } = params
647
648
  const tableProps = $table.props
648
649
  const tableReactData = $table.reactData
650
+ const tableInternalData = $table.internalData
649
651
  const { treeConfig } = tableProps
650
- const { selectCheckboxMaps, treeIndeterminateMaps } = tableReactData
652
+ const { updateCheckboxFlag } = tableReactData
653
+ const { selectCheckboxMaps, treeIndeterminateRowMaps } = tableInternalData
651
654
  const { computeCheckboxOpts } = $table.getComputeMaps()
652
655
  const checkboxOpts = computeCheckboxOpts.value
653
656
  const { labelField, checkMethod, visibleMethod } = checkboxOpts
@@ -661,7 +664,7 @@ export const Cell = {
661
664
  const ons: Record<string, any> = {}
662
665
  if (!isHidden) {
663
666
  const rowid = getRowid($table, row)
664
- isChecked = !!selectCheckboxMaps[rowid]
667
+ isChecked = !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
665
668
  ons.onClick = (evnt: MouseEvent) => {
666
669
  if (!isDisabled && isVisible) {
667
670
  $table.triggerCheckRowEvent(evnt, params, !isChecked)
@@ -671,7 +674,7 @@ export const Cell = {
671
674
  isDisabled = !checkMethod({ row })
672
675
  }
673
676
  if (treeConfig) {
674
- indeterminate = !!treeIndeterminateMaps[rowid]
677
+ indeterminate = !!treeIndeterminateRowMaps[rowid]
675
678
  }
676
679
  }
677
680
  const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
@@ -712,8 +715,10 @@ export const Cell = {
712
715
  const { $table, row, column, isHidden } = params
713
716
  const tableProps = $table.props
714
717
  const tableReactData = $table.reactData
718
+ const tableInternalData = $table.internalData
715
719
  const { treeConfig } = tableProps
716
- const { treeIndeterminateMaps } = tableReactData
720
+ const { updateCheckboxFlag } = tableReactData
721
+ const { treeIndeterminateRowMaps } = tableInternalData
717
722
  const { computeCheckboxOpts } = $table.getComputeMaps()
718
723
  const checkboxOpts = computeCheckboxOpts.value
719
724
  const { labelField, checkField, checkMethod, visibleMethod } = checkboxOpts
@@ -728,7 +733,7 @@ export const Cell = {
728
733
  const ons: Record<string, any> = {}
729
734
  if (!isHidden) {
730
735
  const rowid = getRowid($table, row)
731
- isChecked = XEUtils.get(row, checkField as string)
736
+ isChecked = !!updateCheckboxFlag && XEUtils.get(row, checkField)
732
737
  ons.onClick = (evnt: MouseEvent) => {
733
738
  if (!isDisabled && isVisible) {
734
739
  $table.triggerCheckRowEvent(evnt, params, !isChecked)
@@ -738,7 +743,7 @@ export const Cell = {
738
743
  isDisabled = !checkMethod({ row })
739
744
  }
740
745
  if (treeConfig) {
741
- isIndeterminate = !!treeIndeterminateMaps[rowid]
746
+ isIndeterminate = !!treeIndeterminateRowMaps[rowid]
742
747
  }
743
748
  }
744
749
  const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate: isIndeterminate }
@@ -781,8 +786,8 @@ export const Cell = {
781
786
  */
782
787
  renderExpandCell (params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
783
788
  const { $table, isHidden, row, column } = params
784
- const tableReactData = $table.reactData
785
- const { rowExpandedMaps, rowExpandLazyLoadedMaps } = tableReactData
789
+ const tableInternalData = $table.internalData
790
+ const { rowExpandedMaps, rowExpandLazyLoadedMaps } = tableInternalData
786
791
  const { computeExpandOpts } = $table.getComputeMaps()
787
792
  const expandOpts = computeExpandOpts.value
788
793
  const { lazy, labelField, iconLoaded, showIcon, iconOpen, iconClose, visibleMethod } = expandOpts
@@ -889,7 +894,7 @@ export const Cell = {
889
894
  const { $table, column } = params
890
895
  const { computeSortOpts } = $table.getComputeMaps()
891
896
  const sortOpts = computeSortOpts.value
892
- const { showIcon, allowBtn, iconLayout, iconAsc, iconDesc, iconVisibleMethod } = sortOpts
897
+ const { showIcon, allowBtn, ascTitle, descTitle, iconLayout, iconAsc, iconDesc, iconVisibleMethod } = sortOpts
893
898
  const { order } = column
894
899
  if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
895
900
  return [
@@ -900,7 +905,7 @@ export const Cell = {
900
905
  class: ['vxe-sort--asc-btn', iconAsc || getIcon().TABLE_SORT_ASC, {
901
906
  'sort--active': order === 'asc'
902
907
  }],
903
- title: getI18n('vxe.table.sortAsc'),
908
+ title: XEUtils.eqNull(ascTitle) ? getI18n('vxe.table.sortAsc') : `${ascTitle || ''}`,
904
909
  onClick: allowBtn
905
910
  ? (evnt: Event) => {
906
911
  evnt.stopPropagation()
@@ -912,7 +917,7 @@ export const Cell = {
912
917
  class: ['vxe-sort--desc-btn', iconDesc || getIcon().TABLE_SORT_DESC, {
913
918
  'sort--active': order === 'desc'
914
919
  }],
915
- title: getI18n('vxe.table.sortDesc'),
920
+ title: XEUtils.eqNull(descTitle) ? getI18n('vxe.table.sortDesc') : `${descTitle || ''}`,
916
921
  onClick: allowBtn
917
922
  ? (evnt: Event) => {
918
923
  evnt.stopPropagation()
@@ -137,6 +137,7 @@ export default defineComponent({
137
137
  tfOns.onDblclick = (evnt: MouseEvent) => {
138
138
  $xeTable.dispatchEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
139
139
  }
140
+ let isMergeCell = false
140
141
  // 合并行或列
141
142
  if (mergeFooterList.length) {
142
143
  const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex)
@@ -146,9 +147,11 @@ export default defineComponent({
146
147
  return null
147
148
  }
148
149
  if (rowspan > 1) {
150
+ isMergeCell = true
149
151
  attrs.rowspan = rowspan
150
152
  }
151
153
  if (colspan > 1) {
154
+ isMergeCell = true
152
155
  attrs.colspan = colspan
153
156
  }
154
157
  }
@@ -169,8 +172,10 @@ export default defineComponent({
169
172
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
170
173
 
171
174
  let isVNPreEmptyStatus = false
172
- if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
173
- isVNPreEmptyStatus = true
175
+ if (!isMergeCell) {
176
+ if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
177
+ isVNPreEmptyStatus = true
178
+ }
174
179
  }
175
180
 
176
181
  const tcStyle: Record<string, string> = {}
@@ -267,7 +272,7 @@ export default defineComponent({
267
272
  const { fixedType, fixedColumn, tableColumn } = props
268
273
  const { spanMethod, footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps
269
274
  const { visibleColumn, fullColumnIdData } = tableInternalData
270
- const { isGroup, overflowX, scrollXLoad, scrollYLoad, dragCol } = tableReactData
275
+ const { isGroup, isColLoading, overflowX, scrollXLoad, scrollYLoad, dragCol } = tableReactData
271
276
 
272
277
  let renderColumnList = tableColumn
273
278
  let isOptimizeMode = false
@@ -280,7 +285,7 @@ export default defineComponent({
280
285
  }
281
286
  }
282
287
 
283
- if (fixedType || !overflowX) {
288
+ if (!isColLoading && (fixedType || !overflowX)) {
284
289
  renderColumnList = visibleColumn
285
290
  }
286
291