vxe-table 3.14.0 → 3.14.2

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 (46) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/module/edit/mixin.js +95 -65
  3. package/es/table/module/keyboard/mixin.js +3 -2
  4. package/es/table/module/validator/mixin.js +2 -5
  5. package/es/table/src/body.js +6 -7
  6. package/es/table/src/methods.js +301 -286
  7. package/es/table/src/table.js +21 -15
  8. package/es/ui/index.js +1 -1
  9. package/es/ui/src/dom.js +0 -1
  10. package/es/ui/src/log.js +1 -1
  11. package/lib/index.umd.js +501 -498
  12. package/lib/index.umd.min.js +1 -1
  13. package/lib/style.css +1 -1
  14. package/lib/table/module/edit/mixin.js +108 -99
  15. package/lib/table/module/edit/mixin.min.js +1 -1
  16. package/lib/table/module/keyboard/mixin.js +2 -1
  17. package/lib/table/module/keyboard/mixin.min.js +1 -1
  18. package/lib/table/module/validator/mixin.js +3 -9
  19. package/lib/table/module/validator/mixin.min.js +1 -1
  20. package/lib/table/src/body.js +6 -7
  21. package/lib/table/src/body.min.js +1 -1
  22. package/lib/table/src/methods.js +352 -355
  23. package/lib/table/src/methods.min.js +1 -1
  24. package/lib/table/src/table.js +21 -15
  25. package/lib/table/src/table.min.js +1 -1
  26. package/lib/ui/index.js +1 -1
  27. package/lib/ui/index.min.js +1 -1
  28. package/lib/ui/src/dom.js +0 -2
  29. package/lib/ui/src/dom.min.js +1 -1
  30. package/lib/ui/src/log.js +1 -1
  31. package/lib/ui/src/log.min.js +1 -1
  32. package/package.json +2 -2
  33. package/packages/table/module/edit/mixin.ts +129 -89
  34. package/packages/table/module/keyboard/mixin.ts +4 -2
  35. package/packages/table/module/validator/mixin.ts +3 -6
  36. package/packages/table/src/body.ts +6 -7
  37. package/packages/table/src/methods.ts +345 -301
  38. package/packages/table/src/table.ts +24 -18
  39. package/packages/table/src/util.ts +2 -2
  40. package/packages/ui/src/dom.ts +0 -2
  41. /package/es/{iconfont.1742955973002.ttf → iconfont.1743125678150.ttf} +0 -0
  42. /package/es/{iconfont.1742955973002.woff → iconfont.1743125678150.woff} +0 -0
  43. /package/es/{iconfont.1742955973002.woff2 → iconfont.1743125678150.woff2} +0 -0
  44. /package/lib/{iconfont.1742955973002.ttf → iconfont.1743125678150.ttf} +0 -0
  45. /package/lib/{iconfont.1742955973002.woff → iconfont.1743125678150.woff} +0 -0
  46. /package/lib/{iconfont.1742955973002.woff2 → iconfont.1743125678150.woff2} +0 -0
@@ -1,5 +1,5 @@
1
1
  import XEUtils from 'xe-utils'
2
- import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, getOffsetPos, setScrollTop, setScrollLeft, toCssUnit } from '../../ui/src/dom'
2
+ import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, getOffsetPos, setScrollTop, setScrollLeft, toCssUnit } from '../../ui/src/dom'
3
3
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
4
4
  import { VxeUI } from '../../ui'
5
5
  import Cell from './cell'
@@ -11,6 +11,8 @@ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, Table
11
11
 
12
12
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
13
13
 
14
+ const browseObj = XEUtils.browse()
15
+
14
16
  const supportMaxRow = 5e6
15
17
  const customStorageKey = 'VXE_CUSTOM_STORE'
16
18
  const maxYHeight = 5e6
@@ -325,12 +327,12 @@ const updateScrollYStatus = ($xeTable: VxeTableConstructor, fullData?: any[]) =>
325
327
  const internalData = $xeTable as unknown as TableInternalData
326
328
 
327
329
  const { treeConfig } = props
328
- const sYOpts = $xeTable.computeSYOpts
330
+ const virtualYOpts = $xeTable.computeVirtualYOpts
329
331
  const treeOpts = $xeTable.computeTreeOpts
330
332
  const { transform } = treeOpts
331
333
  const allList = fullData || internalData.tableFullData
332
334
  // 如果gt为0,则总是启用
333
- const scrollYLoad = (transform || !treeConfig) && !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt < allList.length)
335
+ const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length)
334
336
  reactData.scrollYLoad = scrollYLoad
335
337
  return scrollYLoad
336
338
  }
@@ -441,7 +443,7 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
441
443
  const reactData = $xeTable as unknown as TableReactData
442
444
  const internalData = $xeTable as unknown as TableInternalData
443
445
 
444
- const { border, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
446
+ const { showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
445
447
  const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, overflowX, scrollbarWidth, overflowY, scrollbarHeight, scrollXWidth, columnStore, editStore, isAllOverflow, expandColumn } = reactData
446
448
  const { visibleColumn, tableHeight, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData
447
449
  const el = $xeTable.$refs.refElem as HTMLDivElement
@@ -602,33 +604,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
602
604
  if (tableElem) {
603
605
  tableElem.style.width = tWidth ? `${tWidth}px` : ''
604
606
  }
605
-
606
- const listElem = getRefElem(elemStore[`${name}-${layout}-list`])
607
- if (isGroup && listElem) {
608
- XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem: any) => {
609
- const colNode = $xeTable.getColumnNode(thElem)
610
- if (colNode) {
611
- const column = colNode.item
612
- const { showHeaderOverflow } = column
613
- const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow
614
- const showEllipsis = cellOverflow === 'ellipsis'
615
- const showTitle = cellOverflow === 'title'
616
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
617
- const hasEllipsis = showTitle || showTooltip || showEllipsis
618
- let childWidth = 0
619
- let countChild = 0
620
- if (hasEllipsis) {
621
- XEUtils.eachTree(column.children, (item) => {
622
- if (!item.children || !column.children.length) {
623
- countChild++
624
- }
625
- childWidth += item.renderWidth
626
- }, { children: 'children' })
627
- }
628
- thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : ''
629
- }
630
- })
631
- }
632
607
  } else if (layout === 'body') {
633
608
  if (currScrollElem) {
634
609
  currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : ''
@@ -681,7 +656,7 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
681
656
  if (tableElem) {
682
657
  tableElem.style.width = tWidth ? `${tWidth}px` : ''
683
658
  // 兼容性处理
684
- tableElem.style.paddingRight = osbWidth && fixedType && (browse['-moz'] || browse.safari) ? `${osbWidth}px` : ''
659
+ tableElem.style.paddingRight = osbWidth && fixedType && (browseObj['-moz'] || browseObj.safari) ? `${osbWidth}px` : ''
685
660
  }
686
661
  const emptyBlockElem = getRefElem(elemStore[`${name}-${layout}-emptyBlock`])
687
662
  if (emptyBlockElem) {
@@ -765,6 +740,112 @@ function handleChangeCell ($xeTable: VxeTableConstructor & VxeTablePrivateMethod
765
740
  })
766
741
  }
767
742
 
743
+ function handleDefaultSort ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
744
+ const props = $xeTable
745
+
746
+ const { sortConfig } = props
747
+ if (sortConfig) {
748
+ const sortOpts = $xeTable.computeSortOpts
749
+ let { defaultSort } = sortOpts
750
+ if (defaultSort) {
751
+ if (!XEUtils.isArray(defaultSort)) {
752
+ defaultSort = [defaultSort]
753
+ }
754
+ if (defaultSort.length) {
755
+ (sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item: any, index: number) => {
756
+ const { field, order } = item
757
+ if (field && order) {
758
+ const column = $xeTable.getColumnByField(field)
759
+ if (column && column.sortable) {
760
+ column.order = order
761
+ column.sortTime = Date.now() + index
762
+ }
763
+ }
764
+ })
765
+ if (!sortOpts.remote) {
766
+ $xeTable.handleTableData(true).then(updateStyle)
767
+ }
768
+ }
769
+ }
770
+ }
771
+ }
772
+
773
+ /**
774
+ * 处理默认勾选
775
+ */
776
+ function handleDefaultSelectionChecked ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
777
+ const props = $xeTable
778
+ const internalData = $xeTable as unknown as TableInternalData
779
+
780
+ const { checkboxConfig } = props
781
+ if (checkboxConfig) {
782
+ const { fullDataRowIdData } = internalData
783
+ const checkboxOpts = $xeTable.computeCheckboxOpts
784
+ const { checkAll, checkRowKeys } = checkboxOpts
785
+ if (checkAll) {
786
+ handleCheckedAllCheckboxRow($xeTable, true, true)
787
+ } else if (checkRowKeys) {
788
+ const defSelection: any[] = []
789
+ checkRowKeys.forEach((rowid: any) => {
790
+ if (fullDataRowIdData[rowid]) {
791
+ defSelection.push(fullDataRowIdData[rowid].row)
792
+ }
793
+ })
794
+ handleCheckedCheckboxRow($xeTable, defSelection, true, true)
795
+ }
796
+ }
797
+ }
798
+
799
+ /**
800
+ * 处理单选框默认勾选
801
+ */
802
+ function handleDefaultRadioChecked ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
803
+ const props = $xeTable
804
+ const internalData = $xeTable as unknown as TableInternalData
805
+
806
+ const { radioConfig } = props
807
+ if (radioConfig) {
808
+ const { fullDataRowIdData } = internalData
809
+ const radioOpts = $xeTable.computeRadioOpts
810
+ const { checkRowKey: rowid, reserve } = radioOpts
811
+ if (rowid) {
812
+ if (fullDataRowIdData[rowid]) {
813
+ handleCheckedRadioRow(fullDataRowIdData[rowid].row, true)
814
+ }
815
+ if (reserve) {
816
+ const rowkey = getRowkey($xeTable)
817
+ internalData.radioReserveRow = { [rowkey]: rowid }
818
+ }
819
+ }
820
+ }
821
+ }
822
+
823
+ /**
824
+ * 处理默认展开行
825
+ */
826
+ function handleDefaultRowExpand ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
827
+ const props = $xeTable
828
+ const internalData = $xeTable as unknown as TableInternalData
829
+
830
+ const { expandConfig } = props
831
+ if (expandConfig) {
832
+ const { fullDataRowIdData } = internalData
833
+ const expandOpts = $xeTable.computeExpandOpts
834
+ const { expandAll, expandRowKeys } = expandOpts
835
+ if (expandAll) {
836
+ $xeTable.setAllRowExpand(true)
837
+ } else if (expandRowKeys) {
838
+ const defExpandeds: any[] = []
839
+ expandRowKeys.forEach((rowid: any) => {
840
+ if (fullDataRowIdData[rowid]) {
841
+ defExpandeds.push(fullDataRowIdData[rowid].row)
842
+ }
843
+ })
844
+ $xeTable.setRowExpand(defExpandeds, true)
845
+ }
846
+ }
847
+ }
848
+
768
849
  function handleRadioReserveRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
769
850
  const internalData = $xeTable as unknown as TableInternalData
770
851
 
@@ -1247,18 +1328,18 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
1247
1328
  }
1248
1329
 
1249
1330
  function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any[]) {
1250
- const props = $xeTable
1331
+ // const props = $xeTable
1251
1332
  const internalData = $xeTable as unknown as TableInternalData
1252
1333
 
1253
1334
  if (merges) {
1254
- const { treeConfig } = props
1335
+ // const { treeConfig } = props
1255
1336
  const { visibleColumn } = internalData
1256
1337
  if (!XEUtils.isArray(merges)) {
1257
1338
  merges = [merges]
1258
1339
  }
1259
- if (treeConfig && merges.length) {
1260
- errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1261
- }
1340
+ // if (treeConfig && merges.length) {
1341
+ // errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1342
+ // }
1262
1343
  merges.forEach((item) => {
1263
1344
  let { row, col, rowspan, colspan } = item
1264
1345
  if (rowList && XEUtils.isNumber(row)) {
@@ -1299,19 +1380,19 @@ function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.Merge
1299
1380
  }
1300
1381
 
1301
1382
  function removeMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any) {
1302
- const props = $xeTable
1383
+ // const props = $xeTable
1303
1384
  const internalData = $xeTable as unknown as TableInternalData
1304
1385
 
1305
1386
  const rest: any[] = []
1306
1387
  if (merges) {
1307
- const { treeConfig } = props
1388
+ // const { treeConfig } = props
1308
1389
  const { visibleColumn } = internalData
1309
1390
  if (!XEUtils.isArray(merges)) {
1310
1391
  merges = [merges]
1311
1392
  }
1312
- if (treeConfig && merges.length) {
1313
- errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1314
- }
1393
+ // if (treeConfig && merges.length) {
1394
+ // errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1395
+ // }
1315
1396
  merges.forEach((item: any) => {
1316
1397
  let { row, col } = item
1317
1398
  if (rowList && XEUtils.isNumber(row)) {
@@ -1769,7 +1850,7 @@ function hideDropTip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1769
1850
  * @param {Event} evnt 事件
1770
1851
  * @param {Row} row 行对象
1771
1852
  */
1772
- function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement | null, params: any) {
1853
+ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement | null, tipElem: HTMLElement | null, params: any) {
1773
1854
  const reactData = $xeTable as unknown as TableReactData
1774
1855
 
1775
1856
  const tipOverEl = overflowElem || tdEl
@@ -1784,7 +1865,8 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
1784
1865
  const customContent = contentMethod ? contentMethod(params) : null
1785
1866
  const useCustom = contentMethod && !XEUtils.eqNull(customContent)
1786
1867
  const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ? tipOverEl.innerText : tipOverEl.textContent).trim()
1787
- if (content && (showAll || useCustom || (tipOverEl.scrollWidth > tipOverEl.clientWidth))) {
1868
+ const isOver = tipOverEl.scrollWidth > tipOverEl.clientWidth
1869
+ if (content && (showAll || useCustom || isOver)) {
1788
1870
  Object.assign(tooltipStore, {
1789
1871
  row,
1790
1872
  column,
@@ -1794,7 +1876,7 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
1794
1876
  $xeTable.$nextTick(() => {
1795
1877
  const $tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
1796
1878
  if ($tooltip && $tooltip.open) {
1797
- $tooltip.open(tipOverEl, formatText(content))
1879
+ $tooltip.open(isOver ? tipOverEl : tipElem, formatText(content))
1798
1880
  }
1799
1881
  })
1800
1882
  }
@@ -1812,7 +1894,7 @@ function handleScrollToRowColumn ($xeTable: VxeTableConstructor & VxeTablePrivat
1812
1894
  return $xeTable.$nextTick()
1813
1895
  }
1814
1896
 
1815
- const handleRowExpandReserve = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any, expanded: boolean) => {
1897
+ function handleRowExpandReserve ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any, expanded: boolean) {
1816
1898
  const internalData = $xeTable as unknown as TableInternalData
1817
1899
 
1818
1900
  const { rowExpandedReserveRowMap } = internalData
@@ -1827,6 +1909,24 @@ const handleRowExpandReserve = ($xeTable: VxeTableConstructor & VxeTablePrivateM
1827
1909
  }
1828
1910
  }
1829
1911
 
1912
+ function handleDefaultMergeCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1913
+ const props = $xeTable
1914
+
1915
+ const { mergeCells } = props
1916
+ if (mergeCells) {
1917
+ $xeTable.setMergeCells(mergeCells)
1918
+ }
1919
+ }
1920
+
1921
+ function handleDefaultMergeFooterItems ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1922
+ const props = $xeTable
1923
+
1924
+ const { mergeFooterItems } = props
1925
+ if (mergeFooterItems) {
1926
+ $xeTable.setMergeFooterItems(mergeFooterItems)
1927
+ }
1928
+ }
1929
+
1830
1930
  // 计算可视渲染相关数据
1831
1931
  function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1832
1932
  const reactData = $xeTable as unknown as TableReactData
@@ -1916,6 +2016,28 @@ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivat
1916
2016
  })
1917
2017
  }
1918
2018
 
2019
+ /**
2020
+ * 处理数据加载默认行为
2021
+ * 默认执行一次,除非被重置
2022
+ */
2023
+ function handleLoadDefaults ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2024
+ handleDefaultSelectionChecked($xeTable)
2025
+ handleDefaultRadioChecked($xeTable)
2026
+ handleDefaultRowExpand($xeTable)
2027
+ handleDefaultTreeExpand($xeTable)
2028
+ handleDefaultMergeCells($xeTable)
2029
+ handleDefaultMergeFooterItems($xeTable)
2030
+ $xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()))
2031
+ }
2032
+
2033
+ /**
2034
+ * 处理初始化的默认行为
2035
+ * 只会执行一次
2036
+ */
2037
+ function handleInitDefaults ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2038
+ handleDefaultSort($xeTable)
2039
+ }
2040
+
1919
2041
  function handleTableColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1920
2042
  const reactData = $xeTable as unknown as TableReactData
1921
2043
  const internalData = $xeTable as unknown as TableInternalData
@@ -1989,7 +2111,7 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
1989
2111
  const centerList: VxeTableDefines.ColumnInfo[] = []
1990
2112
  const rightList: VxeTableDefines.ColumnInfo[] = []
1991
2113
  const { isGroup, columnStore } = reactData
1992
- const sXOpts = $xeTable.computeSXOpts
2114
+ const virtualXOpts = $xeTable.computeVirtualXOpts
1993
2115
  const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData
1994
2116
  // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
1995
2117
  if (isGroup) {
@@ -2045,7 +2167,7 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
2045
2167
  }
2046
2168
  const visibleColumn = leftList.concat(centerList).concat(rightList)
2047
2169
  // 如果gt为0,则总是启用
2048
- const scrollXLoad = !!sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt < tableFullColumn.length)
2170
+ const scrollXLoad = !!virtualXOpts.enabled && virtualXOpts.gt > -1 && (virtualXOpts.gt === 0 || virtualXOpts.gt < tableFullColumn.length)
2049
2171
  reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
2050
2172
  Object.assign(columnStore, { leftList, centerList, rightList })
2051
2173
  if (scrollXLoad) {
@@ -2659,10 +2781,15 @@ const Methods = {
2659
2781
  */
2660
2782
  loadTableData (datas: any[], isReset: boolean) {
2661
2783
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2784
+ const props = $xeTable
2662
2785
  const reactData = $xeTable as unknown as TableReactData
2663
2786
  const internalData = $xeTable as unknown as TableInternalData
2664
2787
 
2665
- const { keepSource, treeConfig, treeOpts, editStore, scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop, scrollYLoad: oldScrollYLoad, sXOpts, sYOpts } = this
2788
+ const { keepSource, treeConfig } = props
2789
+ const { scrollYLoad: oldScrollYLoad } = reactData
2790
+ const { scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop } = internalData
2791
+ const treeOpts = $xeTable.computeTreeOpts
2792
+ const { transform } = treeOpts
2666
2793
  const childrenField = treeOpts.children || treeOpts.childrenField
2667
2794
  let treeData = []
2668
2795
  let fullData = datas ? datas.slice(0) : []
@@ -2671,7 +2798,7 @@ const Methods = {
2671
2798
  }
2672
2799
  if (treeConfig) {
2673
2800
  // 树结构自动转换
2674
- if (treeOpts.transform) {
2801
+ if (transform) {
2675
2802
  if (!treeOpts.rowField) {
2676
2803
  errLog('vxe.error.reqProp', ['table.tree-config.rowField'])
2677
2804
  }
@@ -2709,8 +2836,8 @@ const Methods = {
2709
2836
  scrollXStore.endIndex = 1
2710
2837
  reactData.isRowLoading = true
2711
2838
  reactData.scrollVMLoading = false
2712
- editStore.insertMaps = {}
2713
- editStore.removeMaps = {}
2839
+ internalData.insertRowMaps = {}
2840
+ internalData.removeRowMaps = {}
2714
2841
  const sYLoad = updateScrollYStatus($xeTable, fullData)
2715
2842
  reactData.isDragColMove = false
2716
2843
  reactData.isDragRowMove = false
@@ -2728,15 +2855,15 @@ const Methods = {
2728
2855
  if (keepSource) {
2729
2856
  $xeTable.cacheSourceMap(fullData)
2730
2857
  }
2731
- if (this.clearCellAreas && this.mouseConfig) {
2732
- this.clearCellAreas()
2733
- this.clearCopyCellArea()
2858
+ if ($xeTable.clearCellAreas && props.mouseConfig) {
2859
+ $xeTable.clearCellAreas()
2860
+ $xeTable.clearCopyCellArea()
2734
2861
  }
2735
- this.clearMergeCells()
2736
- this.clearMergeFooterItems()
2737
- this.handleTableData(true)
2738
- this.updateFooter()
2739
- return this.$nextTick().then(() => {
2862
+ $xeTable.clearMergeCells()
2863
+ $xeTable.clearMergeFooterItems()
2864
+ $xeTable.handleTableData(true)
2865
+ $xeTable.updateFooter()
2866
+ return $xeTable.$nextTick().then(() => {
2740
2867
  updateHeight($xeTable)
2741
2868
  updateStyle($xeTable)
2742
2869
  }).then(() => {
@@ -2750,50 +2877,52 @@ const Methods = {
2750
2877
  if (sYLoad) {
2751
2878
  // if (showOverflow) {
2752
2879
  // if (!rowOpts.height) {
2753
- // const errColumn = this.tableFullColumn.find((column: any) => column.showOverflow === false)
2880
+ // const errColumn = internalData.tableFullColumn.find((column: any) => column.showOverflow === false)
2754
2881
  // if (errColumn) {
2755
2882
  // errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
2756
2883
  // }
2757
2884
  // }
2758
2885
  // }
2759
2886
 
2760
- if (!(this.height || this.maxHeight)) {
2887
+ if (!(props.height || props.maxHeight)) {
2761
2888
  errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}'])
2762
2889
  }
2763
- // if (!this.showOverflow) {
2890
+ // if (!props.showOverflow) {
2764
2891
  // warnLog('vxe.error.reqProp', ['table.show-overflow'])
2765
2892
  // }
2766
- if (this.spanMethod) {
2893
+ if (props.spanMethod) {
2767
2894
  errLog('vxe.error.scrollErrProp', ['table.span-method'])
2768
2895
  }
2769
2896
  }
2770
2897
 
2771
2898
  handleReserveStatus($xeTable)
2772
- this.checkSelectionStatus()
2899
+ $xeTable.checkSelectionStatus()
2773
2900
  return new Promise<void>(resolve => {
2774
2901
  this.$nextTick()
2775
- .then(() => this.recalculate())
2902
+ .then(() => $xeTable.recalculate())
2776
2903
  .then(() => {
2777
2904
  let targetScrollLeft = lastScrollLeft
2778
2905
  let targetScrollTop = lastScrollTop
2906
+ const virtualXOpts = $xeTable.computeVirtualXOpts
2907
+ const virtualYOpts = $xeTable.computeVirtualYOpts
2779
2908
  // 是否在更新数据之后自动滚动重置滚动条
2780
- if (sXOpts.scrollToLeftOnChange) {
2909
+ if (virtualXOpts.scrollToLeftOnChange) {
2781
2910
  targetScrollLeft = 0
2782
2911
  }
2783
- if (sYOpts.scrollToTopOnChange) {
2912
+ if (virtualYOpts.scrollToTopOnChange) {
2784
2913
  targetScrollTop = 0
2785
2914
  }
2786
2915
  reactData.isRowLoading = false
2787
2916
  calcCellHeight($xeTable)
2788
2917
  // 是否变更虚拟滚动
2789
2918
  if (oldScrollYLoad === sYLoad) {
2790
- restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
2919
+ restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
2791
2920
  .then(() => {
2792
2921
  resolve()
2793
2922
  })
2794
2923
  } else {
2795
2924
  setTimeout(() => {
2796
- restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
2925
+ restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
2797
2926
  .then(() => {
2798
2927
  resolve()
2799
2928
  })
@@ -2808,12 +2937,14 @@ const Methods = {
2808
2937
  * @param {Array} datas 数据
2809
2938
  */
2810
2939
  loadData (datas: any) {
2940
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2941
+
2811
2942
  const { initStatus } = this
2812
2943
  return this.loadTableData(datas, false).then(() => {
2813
2944
  this.inited = true
2814
2945
  this.initStatus = true
2815
2946
  if (!initStatus) {
2816
- this.handleLoadDefaults()
2947
+ handleLoadDefaults($xeTable)
2817
2948
  }
2818
2949
  return this.recalculate()
2819
2950
  })
@@ -2823,6 +2954,8 @@ const Methods = {
2823
2954
  * @param {Array} datas 数据
2824
2955
  */
2825
2956
  reloadData (datas: any) {
2957
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2958
+
2826
2959
  return this.clearAll()
2827
2960
  .then(() => {
2828
2961
  this.inited = true
@@ -2830,7 +2963,7 @@ const Methods = {
2830
2963
  return this.loadTableData(datas, true)
2831
2964
  })
2832
2965
  .then(() => {
2833
- this.handleLoadDefaults()
2966
+ handleLoadDefaults($xeTable)
2834
2967
  return this.recalculate()
2835
2968
  })
2836
2969
  },
@@ -2991,12 +3124,19 @@ const Methods = {
2991
3124
  internalData.tableSourceData = sourceData
2992
3125
  },
2993
3126
  getParams () {
2994
- return this.params
3127
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3128
+ const props = $xeTable
3129
+
3130
+ return props.params
2995
3131
  },
2996
3132
  loadTreeChildren (row: any, childRecords: any) {
2997
- const $xeTable = this
3133
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3134
+ const props = $xeTable
3135
+ const internalData = $xeTable as unknown as TableInternalData
2998
3136
 
2999
- const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = this
3137
+ const { keepSource } = props
3138
+ const { tableSourceData, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = internalData
3139
+ const treeOpts = $xeTable.computeTreeOpts
3000
3140
  const { transform, mapChildrenField } = treeOpts
3001
3141
  const childrenField = treeOpts.children || treeOpts.childrenField
3002
3142
  const parentRest = fullAllDataRowIdData[getRowid($xeTable, row)]
@@ -3004,7 +3144,7 @@ const Methods = {
3004
3144
  return this.createData(childRecords).then((rows: any) => {
3005
3145
  if (keepSource) {
3006
3146
  const rowid = getRowid(this, row)
3007
- const matchObj = XEUtils.findTree(tableSourceData as any[], (item) => rowid === getRowid(this, item), { children: childrenField })
3147
+ const matchObj = XEUtils.findTree(tableSourceData, (item) => rowid === getRowid(this, item), { children: childrenField })
3008
3148
  if (matchObj) {
3009
3149
  matchObj.item[childrenField] = XEUtils.clone(rows, true)
3010
3150
  }
@@ -3032,18 +3172,23 @@ const Methods = {
3032
3172
  * 根据 tr 元素获取对应的 row 信息
3033
3173
  * @param {Element} tr 元素
3034
3174
  */
3035
- getRowNode (tr: any) {
3175
+ getRowNode (tr: HTMLElement) {
3176
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3177
+ const internalData = $xeTable as unknown as TableInternalData
3178
+
3036
3179
  if (tr) {
3037
- const { fullAllDataRowIdData } = this
3180
+ const { fullAllDataRowIdData } = internalData
3038
3181
  const rowid = tr.getAttribute('rowid')
3039
- const rowRest = fullAllDataRowIdData[rowid]
3040
- if (rowRest) {
3041
- return {
3042
- rowid: rowRest.rowid,
3043
- item: rowRest.row,
3044
- index: rowRest.index,
3045
- items: rowRest.items,
3046
- parent: rowRest.parent
3182
+ if (rowid) {
3183
+ const rowRest = fullAllDataRowIdData[rowid]
3184
+ if (rowRest) {
3185
+ return {
3186
+ rowid: rowRest.rowid,
3187
+ item: rowRest.row,
3188
+ index: rowRest.index,
3189
+ items: rowRest.items,
3190
+ parent: rowRest.parent
3191
+ }
3047
3192
  }
3048
3193
  }
3049
3194
  }
@@ -3053,9 +3198,12 @@ const Methods = {
3053
3198
  * 根据 th/td 元素获取对应的 column 信息
3054
3199
  * @param {Element} cell 元素
3055
3200
  */
3056
- getColumnNode (cell: any) {
3201
+ getColumnNode (cell: HTMLElement) {
3202
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3203
+ const internalData = $xeTable as unknown as TableInternalData
3204
+
3057
3205
  if (cell) {
3058
- const { fullColumnIdData } = this
3206
+ const { fullColumnIdData } = internalData
3059
3207
  const colid = cell.getAttribute('colid')
3060
3208
  if (colid) {
3061
3209
  const colRest = fullColumnIdData[colid]
@@ -3146,15 +3294,23 @@ const Methods = {
3146
3294
  * 定义行数据中的列属性,如果不存在则定义
3147
3295
  * @param {Row} records 行数据
3148
3296
  */
3149
- defineField (records: any) {
3150
- const { radioOpts, checkboxOpts, treeConfig, treeOpts, expandOpts } = this
3297
+ defineField (records: any[]) {
3298
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3299
+ const props = $xeTable
3300
+ const internalData = $xeTable as unknown as TableInternalData
3301
+
3302
+ const { treeConfig } = props
3303
+ const expandOpts = $xeTable.computeExpandOpts
3304
+ const treeOpts = $xeTable.computeTreeOpts
3305
+ const radioOpts = $xeTable.computeRadioOpts
3306
+ const checkboxOpts = $xeTable.computeCheckboxOpts
3151
3307
  const childrenField = treeOpts.children || treeOpts.childrenField
3152
- const rowkey = getRowkey(this)
3308
+ const rowkey = getRowkey($xeTable)
3153
3309
  if (!XEUtils.isArray(records)) {
3154
3310
  records = [records || {}]
3155
3311
  }
3156
- return records.map((record: any) => {
3157
- this.tableFullColumn.forEach((column: any) => {
3312
+ return records.map((record) => {
3313
+ internalData.tableFullColumn.forEach(column => {
3158
3314
  const { field, editRender } = column
3159
3315
  if (field && !XEUtils.has(record, field)) {
3160
3316
  let cellValue = null
@@ -3191,8 +3347,10 @@ const Methods = {
3191
3347
  * @param {Array} records 新数据
3192
3348
  */
3193
3349
  createData (records: any) {
3194
- return this.$nextTick().then(() => {
3195
- return this.defineField(records)
3350
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3351
+
3352
+ return $xeTable.$nextTick().then(() => {
3353
+ return $xeTable.defineField(records)
3196
3354
  })
3197
3355
  },
3198
3356
  /**
@@ -3201,11 +3359,13 @@ const Methods = {
3201
3359
  * @param {Array/Object} records 新数据
3202
3360
  */
3203
3361
  createRow (records: any) {
3362
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3363
+
3204
3364
  const isArr = XEUtils.isArray(records)
3205
3365
  if (!isArr) {
3206
3366
  records = [records]
3207
3367
  }
3208
- return this.createData(records).then((rows: any) => isArr ? rows : rows[0])
3368
+ return $xeTable.createData(records).then((rows: any) => isArr ? rows : rows[0])
3209
3369
  },
3210
3370
  /**
3211
3371
  * 还原数据
@@ -3221,9 +3381,7 @@ const Methods = {
3221
3381
  const internalData = $xeTable as unknown as TableInternalData
3222
3382
 
3223
3383
  const { keepSource, treeConfig } = props
3224
- const { editStore } = reactData
3225
- const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
3226
- const removeTempMaps = { ...editStore.removeMaps }
3384
+ const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData, removeRowMaps } = internalData
3227
3385
  const treeOpts = $xeTable.computeTreeOpts
3228
3386
  const { transform } = treeOpts
3229
3387
  const { handleGetRowId } = createHandleGetRowId($xeTable)
@@ -3257,7 +3415,9 @@ const Methods = {
3257
3415
  XEUtils.destructuring(row, XEUtils.clone(oRow, true))
3258
3416
  }
3259
3417
  if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
3260
- delete removeTempMaps[rowid]
3418
+ if (removeRowMaps[rowid]) {
3419
+ delete removeRowMaps[rowid]
3420
+ }
3261
3421
  tableFullData.unshift(row)
3262
3422
  afterFullData.unshift(row)
3263
3423
  reDelFlag = true
@@ -3269,7 +3429,7 @@ const Methods = {
3269
3429
  }
3270
3430
  if (rows) {
3271
3431
  if (reDelFlag) {
3272
- editStore.removeMaps = removeTempMaps
3432
+ reactData.removeRowFlag++
3273
3433
  $xeTable.updateFooter()
3274
3434
  $xeTable.cacheRowMap(false)
3275
3435
  $xeTable.handleTableData(treeConfig && transform)
@@ -3298,7 +3458,10 @@ const Methods = {
3298
3458
  * @param {String} field 字段名
3299
3459
  */
3300
3460
  clearData (rows: any, field: any) {
3301
- const { tableFullData, visibleColumn } = this
3461
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3462
+ const internalData = $xeTable as unknown as TableInternalData
3463
+
3464
+ const { tableFullData, visibleColumn } = internalData
3302
3465
  if (!arguments.length) {
3303
3466
  rows = tableFullData
3304
3467
  } else if (rows && !XEUtils.isArray(rows)) {
@@ -3315,7 +3478,7 @@ const Methods = {
3315
3478
  })
3316
3479
  })
3317
3480
  }
3318
- return this.$nextTick()
3481
+ return $xeTable.$nextTick()
3319
3482
  },
3320
3483
  getCellElement (row: any, fieldOrColumn: any) {
3321
3484
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -3405,18 +3568,18 @@ const Methods = {
3405
3568
  isInsertByRow (row: any) {
3406
3569
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3407
3570
  const reactData = $xeTable as unknown as TableReactData
3571
+ const internalData = $xeTable as unknown as TableInternalData
3408
3572
 
3409
- const { editStore } = reactData
3410
3573
  const rowid = getRowid($xeTable, row)
3411
- return !!editStore.insertMaps[rowid]
3574
+ return !!reactData.insertRowFlag && !!internalData.insertRowMaps[rowid]
3412
3575
  },
3413
3576
  isRemoveByRow (row: any) {
3414
3577
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3415
3578
  const reactData = $xeTable as unknown as TableReactData
3579
+ const internalData = $xeTable as unknown as TableInternalData
3416
3580
 
3417
- const { editStore } = reactData
3418
3581
  const rowid = getRowid($xeTable, row)
3419
- return !!editStore.removeMaps[rowid]
3582
+ return !!reactData.removeRowFlag && !!internalData.removeRowMaps[rowid]
3420
3583
  },
3421
3584
  /**
3422
3585
  * 删除所有新增的临时数据
@@ -3424,10 +3587,9 @@ const Methods = {
3424
3587
  */
3425
3588
  removeInsertRow () {
3426
3589
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3427
- const reactData = $xeTable as unknown as TableReactData
3590
+ const internalData = $xeTable as unknown as TableInternalData
3428
3591
 
3429
- const { editStore } = reactData
3430
- editStore.insertMaps = {}
3592
+ internalData.insertRowMaps = {}
3431
3593
  return $xeTable.remove($xeTable.getInsertRecords())
3432
3594
  },
3433
3595
  /**
@@ -3470,14 +3632,19 @@ const Methods = {
3470
3632
  * @param {Number} columnIndex 索引
3471
3633
  */
3472
3634
  getColumns (columnIndex: any) {
3473
- const columns = this.visibleColumn
3474
- return XEUtils.isUndefined(columnIndex) ? columns.slice(0) : columns[columnIndex]
3635
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3636
+ const internalData = $xeTable as unknown as TableInternalData
3637
+
3638
+ const { visibleColumn } = internalData
3639
+ return XEUtils.isUndefined(columnIndex) ? visibleColumn.slice(0) : visibleColumn[columnIndex]
3475
3640
  },
3476
3641
  /**
3477
3642
  * 根据列获取列的唯一主键
3478
3643
  */
3479
3644
  getColid (fieldOrColumn: any) {
3480
- const column = handleFieldOrColumn(this, fieldOrColumn)
3645
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3646
+
3647
+ const column = handleFieldOrColumn($xeTable, fieldOrColumn)
3481
3648
  return column ? column.id : null
3482
3649
  },
3483
3650
  /**
@@ -3485,7 +3652,10 @@ const Methods = {
3485
3652
  * @param {String} colid 列主键
3486
3653
  */
3487
3654
  getColumnById (colid: any) {
3488
- const fullColumnIdData = this.fullColumnIdData
3655
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3656
+ const internalData = $xeTable as unknown as TableInternalData
3657
+
3658
+ const { fullColumnIdData } = internalData
3489
3659
  return fullColumnIdData[colid] ? fullColumnIdData[colid].column : null
3490
3660
  },
3491
3661
  /**
@@ -3493,7 +3663,10 @@ const Methods = {
3493
3663
  * @param {String} field 字段名
3494
3664
  */
3495
3665
  getColumnByField (field: any) {
3496
- const fullColumnFieldData = this.fullColumnFieldData
3666
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3667
+ const internalData = $xeTable as unknown as TableInternalData
3668
+
3669
+ const { fullColumnFieldData } = internalData
3497
3670
  return fullColumnFieldData[field] ? fullColumnFieldData[field].column : null
3498
3671
  },
3499
3672
  getParentColumn (fieldOrColumn: any) {
@@ -3506,11 +3679,15 @@ const Methods = {
3506
3679
  * 收集到的全量列、全量表头列、处理条件之后的全量表头列、当前渲染中的表头列
3507
3680
  */
3508
3681
  getTableColumn () {
3682
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3683
+ const reactData = $xeTable as unknown as TableReactData
3684
+ const internalData = $xeTable as unknown as TableInternalData
3685
+
3509
3686
  return {
3510
- collectColumn: this.collectColumn.slice(0),
3511
- fullColumn: this.tableFullColumn.slice(0),
3512
- visibleColumn: this.visibleColumn.slice(0),
3513
- tableColumn: this.tableColumn.slice(0)
3687
+ collectColumn: internalData.collectColumn.slice(0),
3688
+ fullColumn: internalData.tableFullColumn.slice(0),
3689
+ visibleColumn: internalData.visibleColumn.slice(0),
3690
+ tableColumn: reactData.tableColumn.slice(0)
3514
3691
  }
3515
3692
  },
3516
3693
  /**
@@ -3850,9 +4027,9 @@ const Methods = {
3850
4027
  * 只对 tree-config 有效,获取行的子级
3851
4028
  */
3852
4029
  getTreeRowChildren (rowOrRowid: any) {
3853
- const $xeTable = this
4030
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3854
4031
  const props = $xeTable
3855
- const internalData = $xeTable
4032
+ const internalData = $xeTable as unknown as TableInternalData
3856
4033
 
3857
4034
  const { treeConfig } = props
3858
4035
  const { fullAllDataRowIdData } = internalData
@@ -3933,9 +4110,15 @@ const Methods = {
3933
4110
  * 如果存在排序,继续处理
3934
4111
  */
3935
4112
  getTableData () {
3936
- const { treeConfig, tableFullData, afterFullData, tableData, footerTableData, tableFullTreeData } = this
4113
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4114
+ const props = $xeTable
4115
+ const reactData = $xeTable as unknown as TableReactData
4116
+ const internalData = $xeTable as unknown as TableInternalData
4117
+
4118
+ const { tableData, footerTableData } = reactData
4119
+ const { tableFullData, afterFullData, tableFullTreeData } = internalData
3937
4120
  return {
3938
- fullData: treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
4121
+ fullData: props.treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
3939
4122
  visibleData: afterFullData.slice(0),
3940
4123
  tableData: tableData.slice(0),
3941
4124
  footerData: footerTableData.slice(0)
@@ -3979,35 +4162,16 @@ const Methods = {
3979
4162
  handleLoadDefaults () {
3980
4163
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3981
4164
 
3982
- if (this.checkboxConfig) {
3983
- this.handleDefaultSelectionChecked()
3984
- }
3985
- if (this.radioConfig) {
3986
- this.handleDefaultRadioChecked()
3987
- }
3988
- if (this.expandConfig) {
3989
- this.handleDefaultRowExpand()
3990
- }
3991
- if (this.treeConfig) {
3992
- handleDefaultTreeExpand($xeTable)
3993
- }
3994
- if (this.mergeCells) {
3995
- this.handleDefaultMergeCells()
3996
- }
3997
- if (this.mergeFooterItems) {
3998
- this.handleDefaultMergeFooterItems()
3999
- }
4000
- this.$nextTick(() => setTimeout(this.recalculate))
4165
+ handleLoadDefaults($xeTable)
4001
4166
  },
4002
4167
  /**
4003
4168
  * 处理初始化的默认行为
4004
4169
  * 只会执行一次
4005
4170
  */
4006
4171
  handleInitDefaults () {
4007
- const { sortConfig } = this
4008
- if (sortConfig) {
4009
- this.handleDefaultSort()
4010
- }
4172
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4173
+
4174
+ handleInitDefaults($xeTable)
4011
4175
  },
4012
4176
  /**
4013
4177
  * 设置为固定列
@@ -4051,8 +4215,8 @@ const Methods = {
4051
4215
  /**
4052
4216
  * 取消指定固定列
4053
4217
  */
4054
- clearColumnFixed (fieldOrColumn: any) {
4055
- const $xeTable = this
4218
+ clearColumnFixed (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4219
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4056
4220
 
4057
4221
  let status = false
4058
4222
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4077,8 +4241,8 @@ const Methods = {
4077
4241
  /**
4078
4242
  * 隐藏指定列
4079
4243
  */
4080
- hideColumn (fieldOrColumn: any) {
4081
- const $xeTable = this
4244
+ hideColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4245
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4082
4246
 
4083
4247
  let status = false
4084
4248
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4099,8 +4263,8 @@ const Methods = {
4099
4263
  /**
4100
4264
  * 显示指定列
4101
4265
  */
4102
- showColumn (fieldOrColumn: any) {
4103
- const $xeTable = this
4266
+ showColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4267
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4104
4268
 
4105
4269
  let status = false
4106
4270
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4173,67 +4337,35 @@ const Methods = {
4173
4337
  return this.resetCustom(options)
4174
4338
  },
4175
4339
  handleCustom () {
4176
- const { mouseConfig } = this
4177
- if (mouseConfig) {
4178
- if (this.clearSelected) {
4179
- this.clearSelected()
4180
- }
4181
- if (this.clearCellAreas) {
4182
- this.clearCellAreas()
4183
- this.clearCopyCellArea()
4184
- }
4185
- }
4186
- this.analyColumnWidth()
4187
- return this.refreshColumn(true)
4188
- },
4189
- handleCustomRestore (storeData: any) {
4190
4340
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4191
- const reactData = $xeTable as unknown as TableReactData
4192
- const internalData = $xeTable as unknown as TableInternalData
4341
+ const props = $xeTable
4193
4342
 
4194
- let { collectColumn } = internalData
4195
- const { resizableData, sortData, visibleData, fixedData } = storeData
4196
- let hasCustomSort = false
4197
- // 处理还原
4198
- if (resizableData || sortData || visibleData || fixedData) {
4199
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentRow) => {
4200
- const colKey = column.getKey()
4201
- // 支持一级
4202
- if (!parentRow) {
4203
- if (fixedData && fixedData[colKey] !== undefined) {
4204
- column.fixed = fixedData[colKey]
4205
- }
4206
- if (sortData && XEUtils.isNumber(sortData[colKey])) {
4207
- hasCustomSort = true
4208
- column.renderSortNumber = sortData[colKey]
4209
- }
4210
- }
4211
- if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
4212
- column.resizeWidth = resizableData[colKey]
4213
- }
4214
- if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
4215
- column.visible = visibleData[colKey]
4216
- }
4217
- })
4218
- // 如果自定义了顺序
4219
- if (hasCustomSort) {
4220
- collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
4221
- internalData.collectColumn = collectColumn
4222
- internalData.tableFullColumn = getColumnList(collectColumn)
4343
+ const { mouseConfig } = props
4344
+ if (mouseConfig) {
4345
+ if ($xeTable.clearSelected) {
4346
+ $xeTable.clearSelected()
4347
+ }
4348
+ if ($xeTable.clearCellAreas) {
4349
+ $xeTable.clearCellAreas()
4350
+ $xeTable.clearCopyCellArea()
4223
4351
  }
4224
- reactData.isCustomStatus = true
4225
- } else {
4226
- reactData.isCustomStatus = false
4227
4352
  }
4353
+ $xeTable.analyColumnWidth()
4354
+ return $xeTable.refreshColumn(true)
4228
4355
  },
4229
4356
  /**
4230
4357
  * 还原自定义列操作状态
4231
4358
  */
4232
4359
  restoreCustomStorage () {
4233
- const { tableId, customConfig, customOpts } = this
4360
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4361
+ const props = $xeTable
4362
+
4363
+ const { customConfig } = props
4364
+ const tableId = $xeTable.computeTableId
4365
+ const customOpts = $xeTable.computeCustomOpts
4234
4366
  const { storage, restoreStore } = customOpts
4235
4367
  const isAllCustom = storage === true
4236
- const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {})
4368
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
4237
4369
  const isCustomResizable = isAllCustom || storageOpts.resizable
4238
4370
  const isCustomVisible = isAllCustom || storageOpts.visible
4239
4371
  const isCustomFixed = isAllCustom || storageOpts.fixed
@@ -4251,10 +4383,10 @@ const Methods = {
4251
4383
  if (!storeData) {
4252
4384
  return
4253
4385
  }
4254
- return this.handleCustomRestore(storeData)
4386
+ return handleCustomRestore($xeTable, storeData)
4255
4387
  }).catch(e => e)
4256
4388
  } else {
4257
- return this.handleCustomRestore(storeData)
4389
+ return handleCustomRestore($xeTable, storeData)
4258
4390
  }
4259
4391
  }
4260
4392
  },
@@ -5580,7 +5712,7 @@ const Methods = {
5580
5712
  return
5581
5713
  }
5582
5714
  if (tooltipStore.column !== column || !tooltipStore.visible) {
5583
- handleTooltip($xeTable, evnt, thEl, thEl.querySelector<HTMLElement>('.vxe-cell--title') || cellEl, params)
5715
+ handleTooltip($xeTable, evnt, thEl, thEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), thEl.querySelector<HTMLElement>('.vxe-cell--title') || cellEl, params)
5584
5716
  }
5585
5717
  },
5586
5718
  /**
@@ -5611,7 +5743,7 @@ const Methods = {
5611
5743
  }
5612
5744
  }
5613
5745
  if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
5614
- handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), params)
5746
+ handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), params)
5615
5747
  }
5616
5748
  },
5617
5749
  /**
@@ -5626,7 +5758,7 @@ const Methods = {
5626
5758
  const tdEl = evnt.currentTarget as HTMLTableCellElement
5627
5759
  handleTargetEnterEvent($xeTable, tooltipStore.column !== column || !!tooltipStore.row)
5628
5760
  if (tooltipStore.column !== column || !tooltipStore.visible) {
5629
- handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper') as HTMLElement, params)
5761
+ handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper') as HTMLElement, params)
5630
5762
  }
5631
5763
  },
5632
5764
  openTooltip (target: any, content: any) {
@@ -5708,26 +5840,6 @@ const Methods = {
5708
5840
  }
5709
5841
  return []
5710
5842
  },
5711
- /**
5712
- * 处理默认勾选
5713
- */
5714
- handleDefaultSelectionChecked () {
5715
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5716
-
5717
- const { fullDataRowIdData, checkboxOpts } = this
5718
- const { checkAll, checkRowKeys } = checkboxOpts
5719
- if (checkAll) {
5720
- handleCheckedAllCheckboxRow($xeTable, true, true)
5721
- } else if (checkRowKeys) {
5722
- const defSelection: any[] = []
5723
- checkRowKeys.forEach((rowid: any) => {
5724
- if (fullDataRowIdData[rowid]) {
5725
- defSelection.push(fullDataRowIdData[rowid].row)
5726
- }
5727
- })
5728
- handleCheckedCheckboxRow($xeTable, defSelection, true, true)
5729
- }
5730
- },
5731
5843
  handleCheckedCheckboxRow (rows: any[], value: boolean, isForce?: boolean) {
5732
5844
  const $xeTable = this
5733
5845
 
@@ -6320,24 +6432,6 @@ const Methods = {
6320
6432
  reactData.updateCheckboxFlag++
6321
6433
  return this.$nextTick()
6322
6434
  },
6323
- /**
6324
- * 处理单选框默认勾选
6325
- */
6326
- handleDefaultRadioChecked () {
6327
- const $xeTable = this
6328
-
6329
- const { radioOpts, fullDataRowIdData } = this
6330
- const { checkRowKey: rowid, reserve } = radioOpts
6331
- if (rowid) {
6332
- if (fullDataRowIdData[rowid]) {
6333
- handleCheckedRadioRow($xeTable, fullDataRowIdData[rowid].row, true)
6334
- }
6335
- if (reserve) {
6336
- const rowkey = getRowkey(this)
6337
- this.radioReserveRow = { [rowkey]: rowid }
6338
- }
6339
- }
6340
- },
6341
6435
  /**
6342
6436
  * 单选,行选中事件
6343
6437
  */
@@ -6727,32 +6821,6 @@ const Methods = {
6727
6821
  }
6728
6822
  this.emitEvent('cell-dblclick', params, evnt)
6729
6823
  },
6730
- handleDefaultSort () {
6731
- const $xeTable = this
6732
-
6733
- const { sortConfig, sortOpts } = this
6734
- let { defaultSort } = sortOpts
6735
- if (defaultSort) {
6736
- if (!XEUtils.isArray(defaultSort)) {
6737
- defaultSort = [defaultSort]
6738
- }
6739
- if (defaultSort.length) {
6740
- (sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item: any, index: any) => {
6741
- const { field, order } = item
6742
- if (field && order) {
6743
- const column = this.getColumnByField(field)
6744
- if (column && column.sortable) {
6745
- column.order = order
6746
- column.sortTime = Date.now() + index
6747
- }
6748
- }
6749
- })
6750
- if (!sortOpts.remote) {
6751
- this.handleTableData(true).then(() => updateStyle($xeTable))
6752
- }
6753
- }
6754
- }
6755
- },
6756
6824
  handleColumnSortEvent (evnt: any, column: any) {
6757
6825
  const $xeTable = this
6758
6826
  const props = $xeTable
@@ -7918,24 +7986,6 @@ const Methods = {
7918
7986
  toggleRowExpand (row: any) {
7919
7987
  return this.setRowExpand(row, !this.isRowExpandByRow(row))
7920
7988
  },
7921
- /**
7922
- * 处理默认展开行
7923
- */
7924
- handleDefaultRowExpand () {
7925
- const { expandOpts, fullDataRowIdData } = this
7926
- const { expandAll, expandRowKeys } = expandOpts
7927
- if (expandAll) {
7928
- this.setAllRowExpand(true)
7929
- } else if (expandRowKeys) {
7930
- const defExpandeds: any[] = []
7931
- expandRowKeys.forEach((rowid: any) => {
7932
- if (fullDataRowIdData[rowid]) {
7933
- defExpandeds.push(fullDataRowIdData[rowid].row)
7934
- }
7935
- })
7936
- this.setRowExpand(defExpandeds, true)
7937
- }
7938
- },
7939
7989
  /**
7940
7990
  * 设置所有行的展开与否
7941
7991
  * @param {Boolean} expanded 是否展开
@@ -8526,8 +8576,8 @@ const Methods = {
8526
8576
  triggerScrollXEvent () {
8527
8577
  const $xeTable = this
8528
8578
 
8529
- const sXOpts = $xeTable.computeSXOpts
8530
- if (sXOpts.immediate) {
8579
+ const virtualXOpts = $xeTable.computeVirtualXOpts
8580
+ if (virtualXOpts.immediate) {
8531
8581
  loadScrollXData($xeTable)
8532
8582
  } else {
8533
8583
  lazyScrollXData($xeTable)
@@ -8539,8 +8589,8 @@ const Methods = {
8539
8589
  triggerScrollYEvent () {
8540
8590
  const $xeTable = this
8541
8591
 
8542
- const sYOpts = $xeTable.computeSYOpts
8543
- if (sYOpts.immediate) {
8592
+ const virtualYOpts = $xeTable.computeVirtualYOpts
8593
+ if (virtualYOpts.immediate) {
8544
8594
  loadScrollYData($xeTable)
8545
8595
  } else {
8546
8596
  lazyScrollYData($xeTable)
@@ -8751,8 +8801,8 @@ const Methods = {
8751
8801
  }
8752
8802
 
8753
8803
  const wheelSpeed = getWheelSpeed(reactData.lastScrollTime)
8754
- const deltaTop = Math.ceil((shiftKey ? deltaX : deltaY) * wheelSpeed)
8755
- const deltaLeft = Math.ceil((shiftKey ? deltaY : deltaX) * wheelSpeed)
8804
+ const deltaTop = shiftKey ? 0 : Math.ceil(deltaY * wheelSpeed)
8805
+ const deltaLeft = Math.ceil((shiftKey ? (deltaY || deltaX) : deltaX) * wheelSpeed)
8756
8806
 
8757
8807
  const isTopWheel = deltaTop < 0
8758
8808
  const currScrollTop = bodyScrollElem.scrollTop
@@ -9272,9 +9322,6 @@ const Methods = {
9272
9322
  }
9273
9323
  })
9274
9324
  },
9275
- handleDefaultMergeCells () {
9276
- this.setMergeCells(this.mergeCells)
9277
- },
9278
9325
  /**
9279
9326
  * 设置合并单元格
9280
9327
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
@@ -9325,9 +9372,6 @@ const Methods = {
9325
9372
  return updateStyle($xeTable)
9326
9373
  })
9327
9374
  },
9328
- handleDefaultMergeFooterItems () {
9329
- this.setMergeFooterItems(this.mergeFooterItems)
9330
- },
9331
9375
  setMergeFooterItems (merges: any) {
9332
9376
  const $xeTable = this
9333
9377