vxe-table 3.13.17 → 3.13.19

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 (69) hide show
  1. package/es/grid/src/grid.js +42 -72
  2. package/es/style.css +1 -1
  3. package/es/table/module/custom/panel.js +25 -27
  4. package/es/table/module/edit/mixin.js +3 -5
  5. package/es/table/module/export/export-panel.js +22 -24
  6. package/es/table/module/export/import-panel.js +14 -16
  7. package/es/table/module/export/mixin.js +15 -31
  8. package/es/table/module/validator/mixin.js +1 -3
  9. package/es/table/render/index.js +90 -61
  10. package/es/table/src/columnInfo.js +30 -32
  11. package/es/table/src/methods.js +141 -80
  12. package/es/table/src/table.js +16 -18
  13. package/es/table/src/util.js +5 -7
  14. package/es/toolbar/src/toolbar.js +18 -26
  15. package/es/ui/index.js +1 -1
  16. package/es/ui/src/log.js +1 -1
  17. package/lib/grid/src/grid.js +42 -72
  18. package/lib/grid/src/grid.min.js +1 -1
  19. package/lib/index.umd.js +447 -411
  20. package/lib/index.umd.min.js +1 -1
  21. package/lib/style.css +1 -1
  22. package/lib/table/module/custom/panel.js +31 -33
  23. package/lib/table/module/custom/panel.min.js +1 -1
  24. package/lib/table/module/edit/mixin.js +3 -5
  25. package/lib/table/module/edit/mixin.min.js +1 -1
  26. package/lib/table/module/export/export-panel.js +22 -24
  27. package/lib/table/module/export/export-panel.min.js +1 -1
  28. package/lib/table/module/export/import-panel.js +14 -16
  29. package/lib/table/module/export/import-panel.min.js +1 -1
  30. package/lib/table/module/export/mixin.js +15 -31
  31. package/lib/table/module/export/mixin.min.js +1 -1
  32. package/lib/table/module/validator/mixin.js +1 -3
  33. package/lib/table/module/validator/mixin.min.js +1 -1
  34. package/lib/table/render/index.js +98 -66
  35. package/lib/table/render/index.min.js +1 -1
  36. package/lib/table/src/columnInfo.js +32 -34
  37. package/lib/table/src/columnInfo.min.js +1 -1
  38. package/lib/table/src/methods.js +148 -78
  39. package/lib/table/src/methods.min.js +1 -1
  40. package/lib/table/src/table.js +13 -15
  41. package/lib/table/src/table.min.js +1 -1
  42. package/lib/table/src/util.js +4 -6
  43. package/lib/table/src/util.min.js +1 -1
  44. package/lib/toolbar/src/toolbar.js +18 -26
  45. package/lib/toolbar/src/toolbar.min.js +1 -1
  46. package/lib/ui/index.js +1 -1
  47. package/lib/ui/index.min.js +1 -1
  48. package/lib/ui/src/log.js +1 -1
  49. package/lib/ui/src/log.min.js +1 -1
  50. package/package.json +2 -2
  51. package/packages/grid/src/grid.ts +42 -72
  52. package/packages/table/module/custom/panel.ts +25 -27
  53. package/packages/table/module/edit/mixin.ts +3 -5
  54. package/packages/table/module/export/export-panel.ts +22 -24
  55. package/packages/table/module/export/import-panel.ts +14 -16
  56. package/packages/table/module/export/mixin.ts +15 -31
  57. package/packages/table/module/validator/mixin.ts +1 -3
  58. package/packages/table/render/index.ts +89 -59
  59. package/packages/table/src/columnInfo.ts +30 -32
  60. package/packages/table/src/methods.ts +143 -78
  61. package/packages/table/src/table.ts +13 -15
  62. package/packages/table/src/util.ts +4 -6
  63. package/packages/toolbar/src/toolbar.ts +18 -26
  64. /package/es/{iconfont.1741051533862.ttf → iconfont.1741224103306.ttf} +0 -0
  65. /package/es/{iconfont.1741051533862.woff → iconfont.1741224103306.woff} +0 -0
  66. /package/es/{iconfont.1741051533862.woff2 → iconfont.1741224103306.woff2} +0 -0
  67. /package/lib/{iconfont.1741051533862.ttf → iconfont.1741224103306.ttf} +0 -0
  68. /package/lib/{iconfont.1741051533862.woff → iconfont.1741224103306.woff} +0 -0
  69. /package/lib/{iconfont.1741051533862.woff2 → iconfont.1741224103306.woff2} +0 -0
@@ -184,10 +184,8 @@ function getComponentOns (renderOpts: any, params: any, eFns?: {
184
184
  const ons: any = {}
185
185
  XEUtils.objectEach(events, (func, key: any) => {
186
186
  ons[getOnName(key)] = function (...args: any[]) {
187
- if (process.env.VUE_APP_VXE_ENV === 'development') {
188
- if (!XEUtils.isFunction(func)) {
189
- errLog('vxe.error.errFunc', [func])
190
- }
187
+ if (!XEUtils.isFunction(func)) {
188
+ errLog('vxe.error.errFunc', [func])
191
189
  }
192
190
  func(params, ...args)
193
191
  }
@@ -622,6 +620,62 @@ function handleExportTreeSelectMethod (params: any) {
622
620
  return options.original ? getCellValue(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params)
623
621
  }
624
622
 
623
+ function handleNumberCell (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, params: VxeGlobalRendererHandles.RenderTableDefaultParams) {
624
+ const { props = {}, showNegativeStatus } = renderOpts
625
+ const { row, column } = params
626
+ const { type } = props
627
+ let cellValue = XEUtils.get(row, column.field)
628
+ let isNegative = false
629
+ if (!isEmptyValue(cellValue)) {
630
+ const numberInputConfig = getConfig().numberInput || {}
631
+ if (type === 'float') {
632
+ const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
633
+ const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
634
+ cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
635
+ if (!autoFill) {
636
+ cellValue = XEUtils.toNumber(cellValue)
637
+ }
638
+ if (showNegativeStatus) {
639
+ if (cellValue < 0) {
640
+ isNegative = true
641
+ }
642
+ }
643
+ } else if (type === 'amount') {
644
+ const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
645
+ const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
646
+ const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
647
+ cellValue = XEUtils.toNumber(cellValue)
648
+ if (showNegativeStatus) {
649
+ if (cellValue < 0) {
650
+ isNegative = true
651
+ }
652
+ }
653
+ cellValue = XEUtils.commafy(cellValue, { digits })
654
+ if (!autoFill) {
655
+ const [iStr, dStr] = cellValue.split('.')
656
+ if (dStr) {
657
+ const dRest = dStr.replace(/0+$/, '')
658
+ cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
659
+ }
660
+ }
661
+ if (showCurrency) {
662
+ cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
663
+ }
664
+ } else {
665
+ if (showNegativeStatus) {
666
+ if (XEUtils.toNumber(cellValue) < 0) {
667
+ isNegative = true
668
+ }
669
+ }
670
+ }
671
+ }
672
+ return getCellLabelVNs(h, renderOpts, params, cellValue, isNegative
673
+ ? {
674
+ class: 'is--negative'
675
+ }
676
+ : {})
677
+ }
678
+
625
679
  /**
626
680
  * 表格 - 渲染器
627
681
  */
@@ -687,64 +741,19 @@ renderer.mixin({
687
741
  renderTableFilter: defaultFilterRender,
688
742
  tableFilterDefaultMethod: handleInputFilterMethod
689
743
  },
744
+ FormatNumberInput: {
745
+ renderTableDefault: handleNumberCell,
746
+ tableFilterDefaultMethod: handleInputFilterMethod,
747
+ tableExportMethod (params) {
748
+ const { row, column } = params
749
+ const cellValue = XEUtils.get(row, column.field)
750
+ return cellValue
751
+ }
752
+ },
690
753
  VxeNumberInput: {
691
754
  tableAutoFocus: 'input',
692
755
  renderTableEdit: defaultEditRender,
693
- renderTableCell (h, renderOpts, params) {
694
- const { props = {}, showNegativeStatus } = renderOpts
695
- const { row, column } = params
696
- const { type } = props
697
- let cellValue = XEUtils.get(row, column.field)
698
- let isNegative = false
699
- if (!isEmptyValue(cellValue)) {
700
- const numberInputConfig = getConfig().numberInput || {}
701
- if (type === 'float') {
702
- const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
703
- const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
704
- cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
705
- if (!autoFill) {
706
- cellValue = XEUtils.toNumber(cellValue)
707
- }
708
- if (showNegativeStatus) {
709
- if (cellValue < 0) {
710
- isNegative = true
711
- }
712
- }
713
- } else if (type === 'amount') {
714
- const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
715
- const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
716
- const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
717
- cellValue = XEUtils.toNumber(cellValue)
718
- if (showNegativeStatus) {
719
- if (cellValue < 0) {
720
- isNegative = true
721
- }
722
- }
723
- cellValue = XEUtils.commafy(cellValue, { digits })
724
- if (!autoFill) {
725
- const [iStr, dStr] = cellValue.split('.')
726
- if (dStr) {
727
- const dRest = dStr.replace(/0+$/, '')
728
- cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
729
- }
730
- }
731
- if (showCurrency) {
732
- cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
733
- }
734
- } else {
735
- if (showNegativeStatus) {
736
- if (XEUtils.toNumber(cellValue) < 0) {
737
- isNegative = true
738
- }
739
- }
740
- }
741
- }
742
- return getCellLabelVNs(h, renderOpts, params, cellValue, isNegative
743
- ? {
744
- class: 'is--negative'
745
- }
746
- : {})
747
- },
756
+ renderTableCell: handleNumberCell,
748
757
  renderTableFooter (h, renderOpts, params) {
749
758
  const { props = {} } = renderOpts
750
759
  const { row, column, _columnIndex } = params
@@ -851,11 +860,22 @@ renderer.mixin({
851
860
  tableFilterDefaultMethod: handleFilterMethod,
852
861
  tableExportMethod: handleExportSelectMethod
853
862
  },
863
+ /**
864
+ * 已废弃,被 FormatSelect 替换
865
+ * @deprecated
866
+ */
854
867
  formatOption: {
855
868
  renderTableDefault (h, renderOpts, params) {
856
869
  return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params))
857
870
  }
858
871
  },
872
+ FormatSelect: {
873
+ renderTableDefault (h, renderOpts, params) {
874
+ return getCellLabelVNs(h, renderOpts, params, getSelectCellValue(renderOpts, params))
875
+ },
876
+ tableFilterDefaultMethod: handleFilterMethod,
877
+ tableExportMethod: handleExportSelectMethod
878
+ },
859
879
  VxeTreeSelect: {
860
880
  tableAutoFocus: 'input',
861
881
  renderTableEdit: defaultTableOrTreeSelectEditRender,
@@ -872,11 +892,21 @@ renderer.mixin({
872
892
  },
873
893
  tableExportMethod: handleExportTreeSelectMethod
874
894
  },
895
+ /**
896
+ * 已废弃,被 FormatTreeSelect 替换
897
+ * @deprecated
898
+ */
875
899
  formatTree: {
876
900
  renderTableDefault (h, renderOpts, params) {
877
901
  return getCellLabelVNs(h, renderOpts, params, getTreeSelectCellValue(renderOpts, params))
878
902
  }
879
903
  },
904
+ FormatTreeSelect: {
905
+ renderTableDefault (h, renderOpts, params) {
906
+ return getCellLabelVNs(h, renderOpts, params, getTreeSelectCellValue(renderOpts, params))
907
+ },
908
+ tableExportMethod: handleExportTreeSelectMethod
909
+ },
880
910
  VxeColorPicker: {
881
911
  tableAutoFocus: 'input',
882
912
  renderTableEdit (h, renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
@@ -15,40 +15,38 @@ export class ColumnInfo {
15
15
  const visible = XEUtils.isBoolean(_vm.visible) ? _vm.visible : true
16
16
  const tableProps = $xetable
17
17
 
18
- if (process.env.VUE_APP_VXE_ENV === 'development') {
19
- const types = ['seq', 'checkbox', 'radio', 'expand', 'html']
20
- if (_vm.type && types.indexOf(_vm.type) === -1) {
21
- warnLog('vxe.error.errProp', [`type=${_vm.type}`, types.join(', ')])
22
- }
23
- if (XEUtils.isBoolean(_vm.cellRender) || (_vm.cellRender && !XEUtils.isObject(_vm.cellRender))) {
24
- warnLog('vxe.error.errProp', [`column.cell-render=${_vm.cellRender}`, 'column.cell-render={}'])
25
- }
26
- if (XEUtils.isBoolean(_vm.editRender) || (_vm.editRender && !XEUtils.isObject(_vm.editRender))) {
27
- warnLog('vxe.error.errProp', [`column.edit-render=${_vm.editRender}`, 'column.edit-render={}'])
18
+ const types = ['seq', 'checkbox', 'radio', 'expand', 'html']
19
+ if (_vm.type && types.indexOf(_vm.type) === -1) {
20
+ warnLog('vxe.error.errProp', [`type=${_vm.type}`, types.join(', ')])
21
+ }
22
+ if (XEUtils.isBoolean(_vm.cellRender) || (_vm.cellRender && !XEUtils.isObject(_vm.cellRender))) {
23
+ warnLog('vxe.error.errProp', [`column.cell-render=${_vm.cellRender}`, 'column.cell-render={}'])
24
+ }
25
+ if (XEUtils.isBoolean(_vm.editRender) || (_vm.editRender && !XEUtils.isObject(_vm.editRender))) {
26
+ warnLog('vxe.error.errProp', [`column.edit-render=${_vm.editRender}`, 'column.edit-render={}'])
27
+ }
28
+ if (_vm.type === 'expand') {
29
+ const { treeConfig } = tableProps
30
+ if (treeConfig && ($xetable.treeOpts.showLine || $xetable.treeOpts.line)) {
31
+ errLog('vxe.error.errConflicts', ['tree-config.line', 'column.type=expand'])
28
32
  }
29
- if (_vm.type === 'expand') {
30
- const { treeConfig } = tableProps
31
- if (treeConfig && ($xetable.treeOpts.showLine || $xetable.treeOpts.line)) {
32
- errLog('vxe.error.errConflicts', ['tree-config.line', 'column.type=expand'])
33
+ }
34
+ if (_vm.remoteSort) {
35
+ warnLog('vxe.error.delProp', ['column.remote-sort', 'sort-config.remote'])
36
+ }
37
+ if (_vm.sortMethod) {
38
+ warnLog('vxe.error.delProp', ['column.sort-method', 'sort-config.sortMethod'])
39
+ }
40
+ if (formatter) {
41
+ if (XEUtils.isString(formatter)) {
42
+ const gFormatOpts = formats.get(formatter) || XEUtils[formatter]
43
+ if (!gFormatOpts || !XEUtils.isFunction(gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod)) {
44
+ errLog('vxe.error.notFormats', [formatter])
33
45
  }
34
- }
35
- if (_vm.remoteSort) {
36
- warnLog('vxe.error.delProp', ['column.remote-sort', 'sort-config.remote'])
37
- }
38
- if (_vm.sortMethod) {
39
- warnLog('vxe.error.delProp', ['column.sort-method', 'sort-config.sortMethod'])
40
- }
41
- if (formatter) {
42
- if (XEUtils.isString(formatter)) {
43
- const gFormatOpts = formats.get(formatter) || XEUtils[formatter]
44
- if (!gFormatOpts || !XEUtils.isFunction(gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod)) {
45
- errLog('vxe.error.notFormats', [formatter])
46
- }
47
- } else if (XEUtils.isArray(formatter)) {
48
- const gFormatOpts = formats.get(formatter[0]) || XEUtils[formatter[0]]
49
- if (!gFormatOpts || !XEUtils.isFunction(gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod)) {
50
- errLog('vxe.error.notFormats', [formatter[0]])
51
- }
46
+ } else if (XEUtils.isArray(formatter)) {
47
+ const gFormatOpts = formats.get(formatter[0]) || XEUtils[formatter[0]]
48
+ if (!gFormatOpts || !XEUtils.isFunction(gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod)) {
49
+ errLog('vxe.error.notFormats', [formatter[0]])
52
50
  }
53
51
  }
54
52
  }
@@ -7,7 +7,7 @@ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible,
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
8
  import { warnLog, errLog } from '../../ui/src/log'
9
9
 
10
- import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
10
+ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeGridConstructor, GridPrivateMethods, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
11
11
 
12
12
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
13
13
 
@@ -2297,10 +2297,26 @@ const Methods = {
2297
2297
  * 获取父容器的高度
2298
2298
  */
2299
2299
  getParentHeight () {
2300
- const { $el, $xegrid, height } = this
2301
- const parentElem = $el.parentNode
2302
- const parentPaddingSize = height === '100%' || height === 'auto' ? getPaddingTopBottomSize(parentElem) : 0
2303
- return Math.floor($xegrid ? $xegrid.getParentHeight() : XEUtils.toNumber(getComputedStyle(parentElem).height) - parentPaddingSize)
2300
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2301
+ const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
2302
+ const props = $xeTable
2303
+
2304
+ const { height } = props
2305
+ const el = $xeTable.$refs.refElem as HTMLDivElement
2306
+ if (el) {
2307
+ const parentElem = el.parentNode as HTMLElement
2308
+ const parentPaddingSize = height === '100%' || height === 'auto' ? getPaddingTopBottomSize(parentElem) : 0
2309
+ let parentWrapperHeight = 0
2310
+ if (parentElem) {
2311
+ if ($xeGrid && hasClass(parentElem, 'vxe-grid--table-wrapper')) {
2312
+ parentWrapperHeight = $xeGrid.getParentHeight()
2313
+ } else {
2314
+ parentWrapperHeight = parentElem.clientHeight
2315
+ }
2316
+ }
2317
+ return Math.floor(parentWrapperHeight - parentPaddingSize)
2318
+ }
2319
+ return 0
2304
2320
  },
2305
2321
  /**
2306
2322
  * 获取需要排除的高度
@@ -2393,28 +2409,26 @@ const Methods = {
2393
2409
  if (treeConfig) {
2394
2410
  // 树结构自动转换
2395
2411
  if (treeOpts.transform) {
2396
- if (process.env.VUE_APP_VXE_ENV === 'development') {
2397
- if (!treeOpts.rowField) {
2398
- errLog('vxe.error.reqProp', ['table.tree-config.rowField'])
2399
- }
2400
- if (!treeOpts.parentField) {
2401
- errLog('vxe.error.reqProp', ['table.tree-config.parentField'])
2402
- }
2403
- if (!childrenField) {
2404
- errLog('vxe.error.reqProp', ['tree-config.childrenField'])
2405
- }
2406
- if (!treeOpts.mapChildrenField) {
2407
- errLog('vxe.error.reqProp', ['tree-config.mapChildrenField'])
2408
- }
2409
- if (childrenField === treeOpts.mapChildrenField) {
2410
- errLog('vxe.error.errConflicts', ['tree-config.childrenField', 'tree-config.mapChildrenField'])
2411
- }
2412
- // fullData.forEach(row => {
2413
- // if (row[childrenField] && row[childrenField].length) {
2414
- // warnLog('vxe.error.errConflicts', ['tree-config.transform', `row.${childrenField}`])
2415
- // }
2416
- // })
2412
+ if (!treeOpts.rowField) {
2413
+ errLog('vxe.error.reqProp', ['table.tree-config.rowField'])
2414
+ }
2415
+ if (!treeOpts.parentField) {
2416
+ errLog('vxe.error.reqProp', ['table.tree-config.parentField'])
2417
2417
  }
2418
+ if (!childrenField) {
2419
+ errLog('vxe.error.reqProp', ['tree-config.childrenField'])
2420
+ }
2421
+ if (!treeOpts.mapChildrenField) {
2422
+ errLog('vxe.error.reqProp', ['tree-config.mapChildrenField'])
2423
+ }
2424
+ if (childrenField === treeOpts.mapChildrenField) {
2425
+ errLog('vxe.error.errConflicts', ['tree-config.childrenField', 'tree-config.mapChildrenField'])
2426
+ }
2427
+ // fullData.forEach(row => {
2428
+ // if (row[childrenField] && row[childrenField].length) {
2429
+ // warnLog('vxe.error.errConflicts', ['tree-config.transform', `row.${childrenField}`])
2430
+ // }
2431
+ // })
2418
2432
  treeData = XEUtils.toArrayTree(fullData, {
2419
2433
  key: treeOpts.rowField,
2420
2434
  parentKey: treeOpts.parentField,
@@ -2480,16 +2494,14 @@ const Methods = {
2480
2494
  // }
2481
2495
  // }
2482
2496
 
2483
- if (process.env.VUE_APP_VXE_ENV === 'development') {
2484
- if (!(this.height || this.maxHeight)) {
2485
- errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}'])
2486
- }
2487
- // if (!this.showOverflow) {
2488
- // warnLog('vxe.error.reqProp', ['table.show-overflow'])
2489
- // }
2490
- if (this.spanMethod) {
2491
- warnLog('vxe.error.scrollErrProp', ['table.span-method'])
2492
- }
2497
+ if (!(this.height || this.maxHeight)) {
2498
+ errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}'])
2499
+ }
2500
+ // if (!this.showOverflow) {
2501
+ // warnLog('vxe.error.reqProp', ['table.show-overflow'])
2502
+ // }
2503
+ if (this.spanMethod) {
2504
+ errLog('vxe.error.scrollErrProp', ['table.span-method'])
2493
2505
  }
2494
2506
  }
2495
2507
 
@@ -2634,17 +2646,19 @@ const Methods = {
2634
2646
  cacheRowMap () {
2635
2647
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2636
2648
  const props = $xeTable
2649
+ const reactData = $xeTable as unknown as TableReactData
2637
2650
  const internalData = $xeTable as unknown as TableInternalData
2638
2651
 
2639
2652
  const { treeConfig } = props
2640
- const treeOpts = $xeTable.computeTreeOpts
2653
+ const { treeExpandedMaps } = reactData
2641
2654
  const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
2655
+ const treeOpts = $xeTable.computeTreeOpts
2642
2656
  const childrenField = treeOpts.children || treeOpts.childrenField
2643
2657
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
2644
2658
  const rowkey = getRowkey($xeTable)
2645
- const isLazy = treeConfig && treeOpts.lazy
2646
- const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
2659
+ const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
2647
2660
  const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
2661
+ const treeTempExpandedMaps = { ...treeExpandedMaps }
2648
2662
  const handleRow = (row: any, index: number, items: any, path?: any[], parentRow?: any, nodes?: any[]) => {
2649
2663
  let rowid = getRowid($xeTable, row)
2650
2664
  const seq = treeConfig && path ? toTreePathSeq(path) : index + 1
@@ -2653,13 +2667,24 @@ const Methods = {
2653
2667
  rowid = getRowUniqueId()
2654
2668
  XEUtils.set(row, rowkey, rowid)
2655
2669
  }
2656
- if (isLazy && row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
2657
- row[childrenField] = null
2670
+ if (treeConfig && treeOpts.lazy) {
2671
+ const treeExpRest = treeExpandedMaps[rowid]
2672
+ if (row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
2673
+ row[childrenField] = null
2674
+ }
2675
+ if (treeExpRest) {
2676
+ if (!row[childrenField] || !row[childrenField].length) {
2677
+ delete treeTempExpandedMaps[rowid]
2678
+ }
2679
+ }
2658
2680
  }
2659
2681
  let rowRest = fullAllDataRowIdData[rowid]
2660
2682
  if (!rowRest) {
2661
2683
  rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
2662
2684
  }
2685
+ rowRest.treeLoaded = false
2686
+ rowRest.expandLoaded = false
2687
+
2663
2688
  rowRest.row = row
2664
2689
  rowRest.items = items
2665
2690
  rowRest.parent = parentRow
@@ -2668,13 +2693,14 @@ const Methods = {
2668
2693
  fullDataRowIdMaps[rowid] = rowRest
2669
2694
  fullAllDataRowIdMaps[rowid] = rowRest
2670
2695
  }
2671
- internalData.fullDataRowIdData = fullDataRowIdMaps
2672
- internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
2673
2696
  if (treeConfig) {
2674
2697
  XEUtils.eachTree(tableFullTreeData, handleRow, { children: childrenField })
2675
2698
  } else {
2676
2699
  tableFullData.forEach(handleRow)
2677
2700
  }
2701
+ internalData.fullDataRowIdData = fullDataRowIdMaps
2702
+ internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
2703
+ reactData.treeExpandedMaps = treeTempExpandedMaps
2678
2704
  },
2679
2705
  cacheSourceMap (fullData: any[]) {
2680
2706
  let { treeConfig, treeOpts, sourceDataRowIdData } = this
@@ -3010,12 +3036,20 @@ const Methods = {
3010
3036
  * 如果还额外传了 field 则还原指定的单元格数据
3011
3037
  */
3012
3038
  revertData (rows: any, field: any) {
3013
- const { keepSource, tableSourceData, treeConfig } = this
3039
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3040
+ const props = $xeTable
3041
+ const reactData = $xeTable as unknown as TableReactData
3042
+ const internalData = $xeTable as unknown as TableInternalData
3043
+
3044
+ const { keepSource, treeConfig } = props
3045
+ const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
3046
+ const treeOpts = $xeTable.computeTreeOpts
3047
+ const { transform } = treeOpts
3014
3048
  if (!keepSource) {
3015
3049
  if (process.env.VUE_APP_VXE_ENV === 'development') {
3016
- warnLog('vxe.error.reqProp', ['keep-source'])
3050
+ errLog('vxe.error.reqProp', ['keep-source'])
3017
3051
  }
3018
- return this.$nextTick()
3052
+ return $xeTable.$nextTick()
3019
3053
  }
3020
3054
  let targetRows = rows
3021
3055
  if (rows) {
@@ -3023,30 +3057,52 @@ const Methods = {
3023
3057
  targetRows = [rows]
3024
3058
  }
3025
3059
  } else {
3026
- targetRows = XEUtils.toArray(this.getUpdateRecords())
3060
+ targetRows = XEUtils.toArray($xeTable.getUpdateRecords())
3027
3061
  }
3062
+ let reDelFlag = false
3028
3063
  if (targetRows.length) {
3029
- targetRows.forEach((row: any) => {
3030
- if (!this.isInsertByRow(row)) {
3031
- const rowIndex = this.getRowIndex(row)
3032
- if (treeConfig && rowIndex === -1) {
3033
- errLog('vxe.error.noTree', ['revertData'])
3034
- }
3035
- const oRow = tableSourceData[rowIndex]
3036
- if (oRow && row) {
3037
- if (field) {
3038
- XEUtils.set(row, field, XEUtils.clone(XEUtils.get(oRow, field), true))
3039
- } else {
3040
- XEUtils.destructuring(row, XEUtils.clone(oRow, true))
3064
+ targetRows.forEach((item: any) => {
3065
+ const rowid = getRowid($xeTable, item)
3066
+ const rowRest = fullAllDataRowIdData[rowid]
3067
+ if (rowRest) {
3068
+ const row = rowRest.row
3069
+ if (!$xeTable.isInsertByRow(row)) {
3070
+ const oRow = sourceDataRowIdData[rowid]
3071
+ if (oRow && row) {
3072
+ if (field) {
3073
+ XEUtils.set(row, field, XEUtils.clone(XEUtils.get(oRow, field), true))
3074
+ } else {
3075
+ XEUtils.destructuring(row, XEUtils.clone(oRow, true))
3076
+ }
3077
+ if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
3078
+ tableFullData.unshift(row)
3079
+ afterFullData.unshift(row)
3080
+ reDelFlag = true
3081
+ }
3041
3082
  }
3042
3083
  }
3043
3084
  }
3044
3085
  })
3045
3086
  }
3046
3087
  if (rows) {
3047
- return this.$nextTick()
3088
+ if (reDelFlag) {
3089
+ $xeTable.updateFooter()
3090
+ $xeTable.cacheRowMap(false)
3091
+ $xeTable.handleTableData(treeConfig && transform)
3092
+ if (!(treeConfig && transform)) {
3093
+ $xeTable.updateAfterDataIndex()
3094
+ }
3095
+ $xeTable.checkSelectionStatus()
3096
+ if (reactData.scrollYLoad) {
3097
+ $xeTable.updateScrollYSpace()
3098
+ }
3099
+ }
3100
+ return $xeTable.$nextTick().then(() => {
3101
+ $xeTable.updateCellAreas()
3102
+ return $xeTable.recalculate()
3103
+ })
3048
3104
  }
3049
- return this.reloadData(tableSourceData)
3105
+ return $xeTable.reloadData(tableSourceData)
3050
3106
  },
3051
3107
  /**
3052
3108
  * 清空单元格内容
@@ -3162,17 +3218,28 @@ const Methods = {
3162
3218
  * @param {Row} row 行对象
3163
3219
  */
3164
3220
  isInsertByRow (row: any) {
3165
- const { editStore } = this
3166
- const rowid = getRowid(this, row)
3221
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3222
+ const reactData = $xeTable as unknown as TableReactData
3223
+
3224
+ const { editStore } = reactData
3225
+ const rowid = getRowid($xeTable, row)
3167
3226
  return !!editStore.insertMaps[rowid]
3168
3227
  },
3228
+ isRemoveByRow (row: any) {
3229
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3230
+ const reactData = $xeTable as unknown as TableReactData
3231
+
3232
+ const { editStore } = reactData
3233
+ const rowid = getRowid($xeTable, row)
3234
+ return !!editStore.removeMaps[rowid]
3235
+ },
3169
3236
  /**
3170
3237
  * 删除所有新增的临时数据
3171
3238
  * @returns
3172
3239
  */
3173
3240
  removeInsertRow () {
3174
- const $xeTable = this
3175
- const reactData = $xeTable
3241
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3242
+ const reactData = $xeTable as unknown as TableReactData
3176
3243
 
3177
3244
  const { editStore } = reactData
3178
3245
  editStore.insertMaps = {}
@@ -9016,19 +9083,17 @@ const funcs = 'setFilter,openFilter,clearFilter,saveFilterPanel,resetFilterPanel
9016
9083
 
9017
9084
  funcs.forEach(name => {
9018
9085
  Methods[name] = function (...args: any[]) {
9019
- if (process.env.VUE_APP_VXE_ENV === 'development') {
9020
- if (!this[`_${name}`]) {
9021
- if ('openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',').includes(name)) {
9022
- errLog('vxe.error.reqModule', ['VxeTableExportModule'])
9023
- } else if ('fullValidate,validate'.split(',').includes(name)) {
9024
- errLog('vxe.error.reqModule', ['VxeTableValidatorModule'])
9025
- } else if ('setFilter,openFilter,clearFilter,getCheckedFilters'.split(',').includes(name)) {
9026
- errLog('vxe.error.reqModule', ['VxeTableFilterModule'])
9027
- } else if ('insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell'.split(',').includes(name)) {
9028
- errLog('vxe.error.reqModule', ['VxeTableEditModule'])
9029
- } else if ('openCustom'.split(',').includes(name)) {
9030
- errLog('vxe.error.reqModule', ['VxeTableCustomModule'])
9031
- }
9086
+ if (!this[`_${name}`]) {
9087
+ if ('openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',').includes(name)) {
9088
+ errLog('vxe.error.reqModule', ['VxeTableExportModule'])
9089
+ } else if ('fullValidate,validate'.split(',').includes(name)) {
9090
+ errLog('vxe.error.reqModule', ['VxeTableValidatorModule'])
9091
+ } else if ('setFilter,openFilter,clearFilter,getCheckedFilters'.split(',').includes(name)) {
9092
+ errLog('vxe.error.reqModule', ['VxeTableFilterModule'])
9093
+ } else if ('insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell'.split(',').includes(name)) {
9094
+ errLog('vxe.error.reqModule', ['VxeTableEditModule'])
9095
+ } else if ('openCustom'.split(',').includes(name)) {
9096
+ errLog('vxe.error.reqModule', ['VxeTableCustomModule'])
9032
9097
  }
9033
9098
  }
9034
9099
  return this[`_${name}`] ? this[`_${name}`](...args) : null
@@ -1577,27 +1577,25 @@ export default {
1577
1577
  }
1578
1578
  }
1579
1579
 
1580
- if (process.env.VUE_APP_VXE_ENV === 'development') {
1581
- // 使用已安装的组件,如果未安装则不渲染
1582
- const VxeUILoadingComponent = VxeUI.getComponent<VxeLoadingComponent>('VxeLoading')
1583
- const VxeUITooltipComponent = VxeUI.getComponent<VxeTooltipComponent>('VxeTooltip')
1580
+ // 使用已安装的组件,如果未安装则不渲染
1581
+ const VxeUILoadingComponent = VxeUI.getComponent<VxeLoadingComponent>('VxeLoading')
1582
+ const VxeUITooltipComponent = VxeUI.getComponent<VxeTooltipComponent>('VxeTooltip')
1584
1583
 
1585
- $xeTable.$nextTick(() => {
1586
- if (props.loading) {
1587
- if (!VxeUILoadingComponent && !this.$scopedSlots.loading) {
1588
- errLog('vxe.error.reqComp', ['vxe-loading'])
1589
- }
1584
+ $xeTable.$nextTick(() => {
1585
+ if (props.loading) {
1586
+ if (!VxeUILoadingComponent && !this.$scopedSlots.loading) {
1587
+ errLog('vxe.error.reqComp', ['vxe-loading'])
1590
1588
  }
1591
- if ((props.showOverflow === true || props.showOverflow === 'tooltip') ||
1589
+ }
1590
+ if ((props.showOverflow === true || props.showOverflow === 'tooltip') ||
1592
1591
  (props.showHeaderOverflow === true || props.showHeaderOverflow === 'tooltip') ||
1593
1592
  (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
1594
1593
  props.tooltipConfig || props.editRules) {
1595
- if (!VxeUITooltipComponent) {
1596
- errLog('vxe.error.reqComp', ['vxe-tooltip'])
1597
- }
1594
+ if (!VxeUITooltipComponent) {
1595
+ errLog('vxe.error.reqComp', ['vxe-tooltip'])
1598
1596
  }
1599
- })
1600
- }
1597
+ }
1598
+ })
1601
1599
  if (this.autoResize) {
1602
1600
  const resizeObserver = globalResize.create(() => {
1603
1601
  if (this.autoResize) {
@@ -151,12 +151,10 @@ export function assembleColumn (_vm: any) {
151
151
  const { $el, $xetable, $xecolumn, columnConfig } = _vm
152
152
  const groupConfig = $xecolumn ? $xecolumn.columnConfig : null
153
153
  if (groupConfig) {
154
- if (process.env.VUE_APP_VXE_ENV === 'development') {
155
- if ($xecolumn.$options._componentTag === 'vxe-table-column') {
156
- errLog('vxe.error.groupTag', [`<vxe-table-colgroup title=${$xecolumn.title} ...>`, `<vxe-table-column title=${$xecolumn.title} ...>`])
157
- } else if ($xecolumn.$options._componentTag === 'vxe-column') {
158
- warnLog('vxe.error.groupTag', [`<vxe-colgroup title=${$xecolumn.title} ...>`, `<vxe-column title=${$xecolumn.title} ...>`])
159
- }
154
+ if ($xecolumn.$options._componentTag === 'vxe-table-column') {
155
+ errLog('vxe.error.groupTag', [`<vxe-table-colgroup title=${$xecolumn.title} ...>`, `<vxe-table-column title=${$xecolumn.title} ...>`])
156
+ } else if ($xecolumn.$options._componentTag === 'vxe-column') {
157
+ warnLog('vxe.error.groupTag', [`<vxe-colgroup title=${$xecolumn.title} ...>`, `<vxe-column title=${$xecolumn.title} ...>`])
160
158
  }
161
159
  if (!groupConfig.children) {
162
160
  groupConfig.children = []