vxe-table 3.14.0 → 3.14.1

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 (38) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/module/edit/mixin.js +92 -63
  3. package/es/table/module/validator/mixin.js +2 -5
  4. package/es/table/src/body.js +6 -7
  5. package/es/table/src/methods.js +291 -278
  6. package/es/table/src/table.js +15 -15
  7. package/es/ui/index.js +1 -1
  8. package/es/ui/src/log.js +1 -1
  9. package/lib/index.umd.js +478 -484
  10. package/lib/index.umd.min.js +1 -1
  11. package/lib/style.css +1 -1
  12. package/lib/table/module/edit/mixin.js +106 -98
  13. package/lib/table/module/edit/mixin.min.js +1 -1
  14. package/lib/table/module/validator/mixin.js +3 -9
  15. package/lib/table/module/validator/mixin.min.js +1 -1
  16. package/lib/table/src/body.js +6 -7
  17. package/lib/table/src/body.min.js +1 -1
  18. package/lib/table/src/methods.js +343 -348
  19. package/lib/table/src/methods.min.js +1 -1
  20. package/lib/table/src/table.js +15 -15
  21. package/lib/table/src/table.min.js +1 -1
  22. package/lib/ui/index.js +1 -1
  23. package/lib/ui/index.min.js +1 -1
  24. package/lib/ui/src/log.js +1 -1
  25. package/lib/ui/src/log.min.js +1 -1
  26. package/package.json +2 -2
  27. package/packages/table/module/edit/mixin.ts +125 -87
  28. package/packages/table/module/validator/mixin.ts +3 -6
  29. package/packages/table/src/body.ts +6 -7
  30. package/packages/table/src/methods.ts +334 -293
  31. package/packages/table/src/table.ts +18 -18
  32. package/packages/table/src/util.ts +2 -2
  33. /package/es/{iconfont.1742955973002.ttf → iconfont.1743045564244.ttf} +0 -0
  34. /package/es/{iconfont.1742955973002.woff → iconfont.1743045564244.woff} +0 -0
  35. /package/es/{iconfont.1742955973002.woff2 → iconfont.1743045564244.woff2} +0 -0
  36. /package/lib/{iconfont.1742955973002.ttf → iconfont.1743045564244.ttf} +0 -0
  37. /package/lib/{iconfont.1742955973002.woff → iconfont.1743045564244.woff} +0 -0
  38. /package/lib/{iconfont.1742955973002.woff2 → iconfont.1743045564244.woff2} +0 -0
@@ -325,12 +325,12 @@ const updateScrollYStatus = ($xeTable: VxeTableConstructor, fullData?: any[]) =>
325
325
  const internalData = $xeTable as unknown as TableInternalData
326
326
 
327
327
  const { treeConfig } = props
328
- const sYOpts = $xeTable.computeSYOpts
328
+ const virtualYOpts = $xeTable.computeVirtualYOpts
329
329
  const treeOpts = $xeTable.computeTreeOpts
330
330
  const { transform } = treeOpts
331
331
  const allList = fullData || internalData.tableFullData
332
332
  // 如果gt为0,则总是启用
333
- const scrollYLoad = (transform || !treeConfig) && !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt < allList.length)
333
+ const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length)
334
334
  reactData.scrollYLoad = scrollYLoad
335
335
  return scrollYLoad
336
336
  }
@@ -441,7 +441,7 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
441
441
  const reactData = $xeTable as unknown as TableReactData
442
442
  const internalData = $xeTable as unknown as TableInternalData
443
443
 
444
- const { border, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
444
+ const { showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
445
445
  const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, overflowX, scrollbarWidth, overflowY, scrollbarHeight, scrollXWidth, columnStore, editStore, isAllOverflow, expandColumn } = reactData
446
446
  const { visibleColumn, tableHeight, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData
447
447
  const el = $xeTable.$refs.refElem as HTMLDivElement
@@ -602,33 +602,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
602
602
  if (tableElem) {
603
603
  tableElem.style.width = tWidth ? `${tWidth}px` : ''
604
604
  }
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
605
  } else if (layout === 'body') {
633
606
  if (currScrollElem) {
634
607
  currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : ''
@@ -765,6 +738,112 @@ function handleChangeCell ($xeTable: VxeTableConstructor & VxeTablePrivateMethod
765
738
  })
766
739
  }
767
740
 
741
+ function handleDefaultSort ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
742
+ const props = $xeTable
743
+
744
+ const { sortConfig } = props
745
+ if (sortConfig) {
746
+ const sortOpts = $xeTable.computeSortOpts
747
+ let { defaultSort } = sortOpts
748
+ if (defaultSort) {
749
+ if (!XEUtils.isArray(defaultSort)) {
750
+ defaultSort = [defaultSort]
751
+ }
752
+ if (defaultSort.length) {
753
+ (sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item: any, index: number) => {
754
+ const { field, order } = item
755
+ if (field && order) {
756
+ const column = $xeTable.getColumnByField(field)
757
+ if (column && column.sortable) {
758
+ column.order = order
759
+ column.sortTime = Date.now() + index
760
+ }
761
+ }
762
+ })
763
+ if (!sortOpts.remote) {
764
+ $xeTable.handleTableData(true).then(updateStyle)
765
+ }
766
+ }
767
+ }
768
+ }
769
+ }
770
+
771
+ /**
772
+ * 处理默认勾选
773
+ */
774
+ function handleDefaultSelectionChecked ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
775
+ const props = $xeTable
776
+ const internalData = $xeTable as unknown as TableInternalData
777
+
778
+ const { checkboxConfig } = props
779
+ if (checkboxConfig) {
780
+ const { fullDataRowIdData } = internalData
781
+ const checkboxOpts = $xeTable.computeCheckboxOpts
782
+ const { checkAll, checkRowKeys } = checkboxOpts
783
+ if (checkAll) {
784
+ handleCheckedAllCheckboxRow($xeTable, true, true)
785
+ } else if (checkRowKeys) {
786
+ const defSelection: any[] = []
787
+ checkRowKeys.forEach((rowid: any) => {
788
+ if (fullDataRowIdData[rowid]) {
789
+ defSelection.push(fullDataRowIdData[rowid].row)
790
+ }
791
+ })
792
+ handleCheckedCheckboxRow($xeTable, defSelection, true, true)
793
+ }
794
+ }
795
+ }
796
+
797
+ /**
798
+ * 处理单选框默认勾选
799
+ */
800
+ function handleDefaultRadioChecked ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
801
+ const props = $xeTable
802
+ const internalData = $xeTable as unknown as TableInternalData
803
+
804
+ const { radioConfig } = props
805
+ if (radioConfig) {
806
+ const { fullDataRowIdData } = internalData
807
+ const radioOpts = $xeTable.computeRadioOpts
808
+ const { checkRowKey: rowid, reserve } = radioOpts
809
+ if (rowid) {
810
+ if (fullDataRowIdData[rowid]) {
811
+ handleCheckedRadioRow(fullDataRowIdData[rowid].row, true)
812
+ }
813
+ if (reserve) {
814
+ const rowkey = getRowkey($xeTable)
815
+ internalData.radioReserveRow = { [rowkey]: rowid }
816
+ }
817
+ }
818
+ }
819
+ }
820
+
821
+ /**
822
+ * 处理默认展开行
823
+ */
824
+ function handleDefaultRowExpand ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
825
+ const props = $xeTable
826
+ const internalData = $xeTable as unknown as TableInternalData
827
+
828
+ const { expandConfig } = props
829
+ if (expandConfig) {
830
+ const { fullDataRowIdData } = internalData
831
+ const expandOpts = $xeTable.computeExpandOpts
832
+ const { expandAll, expandRowKeys } = expandOpts
833
+ if (expandAll) {
834
+ $xeTable.setAllRowExpand(true)
835
+ } else if (expandRowKeys) {
836
+ const defExpandeds: any[] = []
837
+ expandRowKeys.forEach((rowid: any) => {
838
+ if (fullDataRowIdData[rowid]) {
839
+ defExpandeds.push(fullDataRowIdData[rowid].row)
840
+ }
841
+ })
842
+ $xeTable.setRowExpand(defExpandeds, true)
843
+ }
844
+ }
845
+ }
846
+
768
847
  function handleRadioReserveRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
769
848
  const internalData = $xeTable as unknown as TableInternalData
770
849
 
@@ -1247,18 +1326,18 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
1247
1326
  }
1248
1327
 
1249
1328
  function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any[]) {
1250
- const props = $xeTable
1329
+ // const props = $xeTable
1251
1330
  const internalData = $xeTable as unknown as TableInternalData
1252
1331
 
1253
1332
  if (merges) {
1254
- const { treeConfig } = props
1333
+ // const { treeConfig } = props
1255
1334
  const { visibleColumn } = internalData
1256
1335
  if (!XEUtils.isArray(merges)) {
1257
1336
  merges = [merges]
1258
1337
  }
1259
- if (treeConfig && merges.length) {
1260
- errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1261
- }
1338
+ // if (treeConfig && merges.length) {
1339
+ // errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1340
+ // }
1262
1341
  merges.forEach((item) => {
1263
1342
  let { row, col, rowspan, colspan } = item
1264
1343
  if (rowList && XEUtils.isNumber(row)) {
@@ -1299,19 +1378,19 @@ function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.Merge
1299
1378
  }
1300
1379
 
1301
1380
  function removeMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any) {
1302
- const props = $xeTable
1381
+ // const props = $xeTable
1303
1382
  const internalData = $xeTable as unknown as TableInternalData
1304
1383
 
1305
1384
  const rest: any[] = []
1306
1385
  if (merges) {
1307
- const { treeConfig } = props
1386
+ // const { treeConfig } = props
1308
1387
  const { visibleColumn } = internalData
1309
1388
  if (!XEUtils.isArray(merges)) {
1310
1389
  merges = [merges]
1311
1390
  }
1312
- if (treeConfig && merges.length) {
1313
- errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1314
- }
1391
+ // if (treeConfig && merges.length) {
1392
+ // errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1393
+ // }
1315
1394
  merges.forEach((item: any) => {
1316
1395
  let { row, col } = item
1317
1396
  if (rowList && XEUtils.isNumber(row)) {
@@ -1812,7 +1891,7 @@ function handleScrollToRowColumn ($xeTable: VxeTableConstructor & VxeTablePrivat
1812
1891
  return $xeTable.$nextTick()
1813
1892
  }
1814
1893
 
1815
- const handleRowExpandReserve = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any, expanded: boolean) => {
1894
+ function handleRowExpandReserve ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any, expanded: boolean) {
1816
1895
  const internalData = $xeTable as unknown as TableInternalData
1817
1896
 
1818
1897
  const { rowExpandedReserveRowMap } = internalData
@@ -1827,6 +1906,24 @@ const handleRowExpandReserve = ($xeTable: VxeTableConstructor & VxeTablePrivateM
1827
1906
  }
1828
1907
  }
1829
1908
 
1909
+ function handleDefaultMergeCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1910
+ const props = $xeTable
1911
+
1912
+ const { mergeCells } = props
1913
+ if (mergeCells) {
1914
+ $xeTable.setMergeCells(mergeCells)
1915
+ }
1916
+ }
1917
+
1918
+ function handleDefaultMergeFooterItems ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1919
+ const props = $xeTable
1920
+
1921
+ const { mergeFooterItems } = props
1922
+ if (mergeFooterItems) {
1923
+ $xeTable.setMergeFooterItems(mergeFooterItems)
1924
+ }
1925
+ }
1926
+
1830
1927
  // 计算可视渲染相关数据
1831
1928
  function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1832
1929
  const reactData = $xeTable as unknown as TableReactData
@@ -1916,6 +2013,28 @@ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivat
1916
2013
  })
1917
2014
  }
1918
2015
 
2016
+ /**
2017
+ * 处理数据加载默认行为
2018
+ * 默认执行一次,除非被重置
2019
+ */
2020
+ function handleLoadDefaults ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2021
+ handleDefaultSelectionChecked($xeTable)
2022
+ handleDefaultRadioChecked($xeTable)
2023
+ handleDefaultRowExpand($xeTable)
2024
+ handleDefaultTreeExpand($xeTable)
2025
+ handleDefaultMergeCells($xeTable)
2026
+ handleDefaultMergeFooterItems($xeTable)
2027
+ $xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()))
2028
+ }
2029
+
2030
+ /**
2031
+ * 处理初始化的默认行为
2032
+ * 只会执行一次
2033
+ */
2034
+ function handleInitDefaults ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2035
+ handleDefaultSort($xeTable)
2036
+ }
2037
+
1919
2038
  function handleTableColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
1920
2039
  const reactData = $xeTable as unknown as TableReactData
1921
2040
  const internalData = $xeTable as unknown as TableInternalData
@@ -1989,7 +2108,7 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
1989
2108
  const centerList: VxeTableDefines.ColumnInfo[] = []
1990
2109
  const rightList: VxeTableDefines.ColumnInfo[] = []
1991
2110
  const { isGroup, columnStore } = reactData
1992
- const sXOpts = $xeTable.computeSXOpts
2111
+ const virtualXOpts = $xeTable.computeVirtualXOpts
1993
2112
  const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData
1994
2113
  // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
1995
2114
  if (isGroup) {
@@ -2045,7 +2164,7 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
2045
2164
  }
2046
2165
  const visibleColumn = leftList.concat(centerList).concat(rightList)
2047
2166
  // 如果gt为0,则总是启用
2048
- const scrollXLoad = !!sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt < tableFullColumn.length)
2167
+ const scrollXLoad = !!virtualXOpts.enabled && virtualXOpts.gt > -1 && (virtualXOpts.gt === 0 || virtualXOpts.gt < tableFullColumn.length)
2049
2168
  reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
2050
2169
  Object.assign(columnStore, { leftList, centerList, rightList })
2051
2170
  if (scrollXLoad) {
@@ -2659,10 +2778,15 @@ const Methods = {
2659
2778
  */
2660
2779
  loadTableData (datas: any[], isReset: boolean) {
2661
2780
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2781
+ const props = $xeTable
2662
2782
  const reactData = $xeTable as unknown as TableReactData
2663
2783
  const internalData = $xeTable as unknown as TableInternalData
2664
2784
 
2665
- const { keepSource, treeConfig, treeOpts, editStore, scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop, scrollYLoad: oldScrollYLoad, sXOpts, sYOpts } = this
2785
+ const { keepSource, treeConfig } = props
2786
+ const { scrollYLoad: oldScrollYLoad } = reactData
2787
+ const { scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop } = internalData
2788
+ const treeOpts = $xeTable.computeTreeOpts
2789
+ const { transform } = treeOpts
2666
2790
  const childrenField = treeOpts.children || treeOpts.childrenField
2667
2791
  let treeData = []
2668
2792
  let fullData = datas ? datas.slice(0) : []
@@ -2671,7 +2795,7 @@ const Methods = {
2671
2795
  }
2672
2796
  if (treeConfig) {
2673
2797
  // 树结构自动转换
2674
- if (treeOpts.transform) {
2798
+ if (transform) {
2675
2799
  if (!treeOpts.rowField) {
2676
2800
  errLog('vxe.error.reqProp', ['table.tree-config.rowField'])
2677
2801
  }
@@ -2709,8 +2833,8 @@ const Methods = {
2709
2833
  scrollXStore.endIndex = 1
2710
2834
  reactData.isRowLoading = true
2711
2835
  reactData.scrollVMLoading = false
2712
- editStore.insertMaps = {}
2713
- editStore.removeMaps = {}
2836
+ internalData.insertRowMaps = {}
2837
+ internalData.removeRowMaps = {}
2714
2838
  const sYLoad = updateScrollYStatus($xeTable, fullData)
2715
2839
  reactData.isDragColMove = false
2716
2840
  reactData.isDragRowMove = false
@@ -2728,15 +2852,15 @@ const Methods = {
2728
2852
  if (keepSource) {
2729
2853
  $xeTable.cacheSourceMap(fullData)
2730
2854
  }
2731
- if (this.clearCellAreas && this.mouseConfig) {
2732
- this.clearCellAreas()
2733
- this.clearCopyCellArea()
2855
+ if ($xeTable.clearCellAreas && props.mouseConfig) {
2856
+ $xeTable.clearCellAreas()
2857
+ $xeTable.clearCopyCellArea()
2734
2858
  }
2735
- this.clearMergeCells()
2736
- this.clearMergeFooterItems()
2737
- this.handleTableData(true)
2738
- this.updateFooter()
2739
- return this.$nextTick().then(() => {
2859
+ $xeTable.clearMergeCells()
2860
+ $xeTable.clearMergeFooterItems()
2861
+ $xeTable.handleTableData(true)
2862
+ $xeTable.updateFooter()
2863
+ return $xeTable.$nextTick().then(() => {
2740
2864
  updateHeight($xeTable)
2741
2865
  updateStyle($xeTable)
2742
2866
  }).then(() => {
@@ -2750,50 +2874,52 @@ const Methods = {
2750
2874
  if (sYLoad) {
2751
2875
  // if (showOverflow) {
2752
2876
  // if (!rowOpts.height) {
2753
- // const errColumn = this.tableFullColumn.find((column: any) => column.showOverflow === false)
2877
+ // const errColumn = internalData.tableFullColumn.find((column: any) => column.showOverflow === false)
2754
2878
  // if (errColumn) {
2755
2879
  // errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
2756
2880
  // }
2757
2881
  // }
2758
2882
  // }
2759
2883
 
2760
- if (!(this.height || this.maxHeight)) {
2884
+ if (!(props.height || props.maxHeight)) {
2761
2885
  errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}'])
2762
2886
  }
2763
- // if (!this.showOverflow) {
2887
+ // if (!props.showOverflow) {
2764
2888
  // warnLog('vxe.error.reqProp', ['table.show-overflow'])
2765
2889
  // }
2766
- if (this.spanMethod) {
2890
+ if (props.spanMethod) {
2767
2891
  errLog('vxe.error.scrollErrProp', ['table.span-method'])
2768
2892
  }
2769
2893
  }
2770
2894
 
2771
2895
  handleReserveStatus($xeTable)
2772
- this.checkSelectionStatus()
2896
+ $xeTable.checkSelectionStatus()
2773
2897
  return new Promise<void>(resolve => {
2774
2898
  this.$nextTick()
2775
- .then(() => this.recalculate())
2899
+ .then(() => $xeTable.recalculate())
2776
2900
  .then(() => {
2777
2901
  let targetScrollLeft = lastScrollLeft
2778
2902
  let targetScrollTop = lastScrollTop
2903
+ const virtualXOpts = $xeTable.computeVirtualXOpts
2904
+ const virtualYOpts = $xeTable.computeVirtualYOpts
2779
2905
  // 是否在更新数据之后自动滚动重置滚动条
2780
- if (sXOpts.scrollToLeftOnChange) {
2906
+ if (virtualXOpts.scrollToLeftOnChange) {
2781
2907
  targetScrollLeft = 0
2782
2908
  }
2783
- if (sYOpts.scrollToTopOnChange) {
2909
+ if (virtualYOpts.scrollToTopOnChange) {
2784
2910
  targetScrollTop = 0
2785
2911
  }
2786
2912
  reactData.isRowLoading = false
2787
2913
  calcCellHeight($xeTable)
2788
2914
  // 是否变更虚拟滚动
2789
2915
  if (oldScrollYLoad === sYLoad) {
2790
- restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
2916
+ restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
2791
2917
  .then(() => {
2792
2918
  resolve()
2793
2919
  })
2794
2920
  } else {
2795
2921
  setTimeout(() => {
2796
- restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
2922
+ restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
2797
2923
  .then(() => {
2798
2924
  resolve()
2799
2925
  })
@@ -2808,12 +2934,14 @@ const Methods = {
2808
2934
  * @param {Array} datas 数据
2809
2935
  */
2810
2936
  loadData (datas: any) {
2937
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2938
+
2811
2939
  const { initStatus } = this
2812
2940
  return this.loadTableData(datas, false).then(() => {
2813
2941
  this.inited = true
2814
2942
  this.initStatus = true
2815
2943
  if (!initStatus) {
2816
- this.handleLoadDefaults()
2944
+ handleLoadDefaults($xeTable)
2817
2945
  }
2818
2946
  return this.recalculate()
2819
2947
  })
@@ -2823,6 +2951,8 @@ const Methods = {
2823
2951
  * @param {Array} datas 数据
2824
2952
  */
2825
2953
  reloadData (datas: any) {
2954
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2955
+
2826
2956
  return this.clearAll()
2827
2957
  .then(() => {
2828
2958
  this.inited = true
@@ -2830,7 +2960,7 @@ const Methods = {
2830
2960
  return this.loadTableData(datas, true)
2831
2961
  })
2832
2962
  .then(() => {
2833
- this.handleLoadDefaults()
2963
+ handleLoadDefaults($xeTable)
2834
2964
  return this.recalculate()
2835
2965
  })
2836
2966
  },
@@ -2991,12 +3121,19 @@ const Methods = {
2991
3121
  internalData.tableSourceData = sourceData
2992
3122
  },
2993
3123
  getParams () {
2994
- return this.params
3124
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3125
+ const props = $xeTable
3126
+
3127
+ return props.params
2995
3128
  },
2996
3129
  loadTreeChildren (row: any, childRecords: any) {
2997
- const $xeTable = this
3130
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3131
+ const props = $xeTable
3132
+ const internalData = $xeTable as unknown as TableInternalData
2998
3133
 
2999
- const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = this
3134
+ const { keepSource } = props
3135
+ const { tableSourceData, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = internalData
3136
+ const treeOpts = $xeTable.computeTreeOpts
3000
3137
  const { transform, mapChildrenField } = treeOpts
3001
3138
  const childrenField = treeOpts.children || treeOpts.childrenField
3002
3139
  const parentRest = fullAllDataRowIdData[getRowid($xeTable, row)]
@@ -3004,7 +3141,7 @@ const Methods = {
3004
3141
  return this.createData(childRecords).then((rows: any) => {
3005
3142
  if (keepSource) {
3006
3143
  const rowid = getRowid(this, row)
3007
- const matchObj = XEUtils.findTree(tableSourceData as any[], (item) => rowid === getRowid(this, item), { children: childrenField })
3144
+ const matchObj = XEUtils.findTree(tableSourceData, (item) => rowid === getRowid(this, item), { children: childrenField })
3008
3145
  if (matchObj) {
3009
3146
  matchObj.item[childrenField] = XEUtils.clone(rows, true)
3010
3147
  }
@@ -3032,18 +3169,23 @@ const Methods = {
3032
3169
  * 根据 tr 元素获取对应的 row 信息
3033
3170
  * @param {Element} tr 元素
3034
3171
  */
3035
- getRowNode (tr: any) {
3172
+ getRowNode (tr: HTMLElement) {
3173
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3174
+ const internalData = $xeTable as unknown as TableInternalData
3175
+
3036
3176
  if (tr) {
3037
- const { fullAllDataRowIdData } = this
3177
+ const { fullAllDataRowIdData } = internalData
3038
3178
  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
3179
+ if (rowid) {
3180
+ const rowRest = fullAllDataRowIdData[rowid]
3181
+ if (rowRest) {
3182
+ return {
3183
+ rowid: rowRest.rowid,
3184
+ item: rowRest.row,
3185
+ index: rowRest.index,
3186
+ items: rowRest.items,
3187
+ parent: rowRest.parent
3188
+ }
3047
3189
  }
3048
3190
  }
3049
3191
  }
@@ -3053,9 +3195,12 @@ const Methods = {
3053
3195
  * 根据 th/td 元素获取对应的 column 信息
3054
3196
  * @param {Element} cell 元素
3055
3197
  */
3056
- getColumnNode (cell: any) {
3198
+ getColumnNode (cell: HTMLElement) {
3199
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3200
+ const internalData = $xeTable as unknown as TableInternalData
3201
+
3057
3202
  if (cell) {
3058
- const { fullColumnIdData } = this
3203
+ const { fullColumnIdData } = internalData
3059
3204
  const colid = cell.getAttribute('colid')
3060
3205
  if (colid) {
3061
3206
  const colRest = fullColumnIdData[colid]
@@ -3146,15 +3291,23 @@ const Methods = {
3146
3291
  * 定义行数据中的列属性,如果不存在则定义
3147
3292
  * @param {Row} records 行数据
3148
3293
  */
3149
- defineField (records: any) {
3150
- const { radioOpts, checkboxOpts, treeConfig, treeOpts, expandOpts } = this
3294
+ defineField (records: any[]) {
3295
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3296
+ const props = $xeTable
3297
+ const internalData = $xeTable as unknown as TableInternalData
3298
+
3299
+ const { treeConfig } = props
3300
+ const expandOpts = $xeTable.computeExpandOpts
3301
+ const treeOpts = $xeTable.computeTreeOpts
3302
+ const radioOpts = $xeTable.computeRadioOpts
3303
+ const checkboxOpts = $xeTable.computeCheckboxOpts
3151
3304
  const childrenField = treeOpts.children || treeOpts.childrenField
3152
- const rowkey = getRowkey(this)
3305
+ const rowkey = getRowkey($xeTable)
3153
3306
  if (!XEUtils.isArray(records)) {
3154
3307
  records = [records || {}]
3155
3308
  }
3156
- return records.map((record: any) => {
3157
- this.tableFullColumn.forEach((column: any) => {
3309
+ return records.map((record) => {
3310
+ internalData.tableFullColumn.forEach(column => {
3158
3311
  const { field, editRender } = column
3159
3312
  if (field && !XEUtils.has(record, field)) {
3160
3313
  let cellValue = null
@@ -3191,8 +3344,10 @@ const Methods = {
3191
3344
  * @param {Array} records 新数据
3192
3345
  */
3193
3346
  createData (records: any) {
3194
- return this.$nextTick().then(() => {
3195
- return this.defineField(records)
3347
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3348
+
3349
+ return $xeTable.$nextTick().then(() => {
3350
+ return $xeTable.defineField(records)
3196
3351
  })
3197
3352
  },
3198
3353
  /**
@@ -3201,11 +3356,13 @@ const Methods = {
3201
3356
  * @param {Array/Object} records 新数据
3202
3357
  */
3203
3358
  createRow (records: any) {
3359
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3360
+
3204
3361
  const isArr = XEUtils.isArray(records)
3205
3362
  if (!isArr) {
3206
3363
  records = [records]
3207
3364
  }
3208
- return this.createData(records).then((rows: any) => isArr ? rows : rows[0])
3365
+ return $xeTable.createData(records).then((rows: any) => isArr ? rows : rows[0])
3209
3366
  },
3210
3367
  /**
3211
3368
  * 还原数据
@@ -3221,9 +3378,7 @@ const Methods = {
3221
3378
  const internalData = $xeTable as unknown as TableInternalData
3222
3379
 
3223
3380
  const { keepSource, treeConfig } = props
3224
- const { editStore } = reactData
3225
- const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
3226
- const removeTempMaps = { ...editStore.removeMaps }
3381
+ const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData, removeRowMaps } = internalData
3227
3382
  const treeOpts = $xeTable.computeTreeOpts
3228
3383
  const { transform } = treeOpts
3229
3384
  const { handleGetRowId } = createHandleGetRowId($xeTable)
@@ -3257,7 +3412,9 @@ const Methods = {
3257
3412
  XEUtils.destructuring(row, XEUtils.clone(oRow, true))
3258
3413
  }
3259
3414
  if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
3260
- delete removeTempMaps[rowid]
3415
+ if (removeRowMaps[rowid]) {
3416
+ delete removeRowMaps[rowid]
3417
+ }
3261
3418
  tableFullData.unshift(row)
3262
3419
  afterFullData.unshift(row)
3263
3420
  reDelFlag = true
@@ -3269,7 +3426,7 @@ const Methods = {
3269
3426
  }
3270
3427
  if (rows) {
3271
3428
  if (reDelFlag) {
3272
- editStore.removeMaps = removeTempMaps
3429
+ reactData.removeRowFlag++
3273
3430
  $xeTable.updateFooter()
3274
3431
  $xeTable.cacheRowMap(false)
3275
3432
  $xeTable.handleTableData(treeConfig && transform)
@@ -3298,7 +3455,10 @@ const Methods = {
3298
3455
  * @param {String} field 字段名
3299
3456
  */
3300
3457
  clearData (rows: any, field: any) {
3301
- const { tableFullData, visibleColumn } = this
3458
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3459
+ const internalData = $xeTable as unknown as TableInternalData
3460
+
3461
+ const { tableFullData, visibleColumn } = internalData
3302
3462
  if (!arguments.length) {
3303
3463
  rows = tableFullData
3304
3464
  } else if (rows && !XEUtils.isArray(rows)) {
@@ -3315,7 +3475,7 @@ const Methods = {
3315
3475
  })
3316
3476
  })
3317
3477
  }
3318
- return this.$nextTick()
3478
+ return $xeTable.$nextTick()
3319
3479
  },
3320
3480
  getCellElement (row: any, fieldOrColumn: any) {
3321
3481
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -3405,18 +3565,18 @@ const Methods = {
3405
3565
  isInsertByRow (row: any) {
3406
3566
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3407
3567
  const reactData = $xeTable as unknown as TableReactData
3568
+ const internalData = $xeTable as unknown as TableInternalData
3408
3569
 
3409
- const { editStore } = reactData
3410
3570
  const rowid = getRowid($xeTable, row)
3411
- return !!editStore.insertMaps[rowid]
3571
+ return !!reactData.insertRowFlag && !!internalData.insertRowMaps[rowid]
3412
3572
  },
3413
3573
  isRemoveByRow (row: any) {
3414
3574
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3415
3575
  const reactData = $xeTable as unknown as TableReactData
3576
+ const internalData = $xeTable as unknown as TableInternalData
3416
3577
 
3417
- const { editStore } = reactData
3418
3578
  const rowid = getRowid($xeTable, row)
3419
- return !!editStore.removeMaps[rowid]
3579
+ return !!reactData.removeRowFlag && !!internalData.removeRowMaps[rowid]
3420
3580
  },
3421
3581
  /**
3422
3582
  * 删除所有新增的临时数据
@@ -3424,10 +3584,9 @@ const Methods = {
3424
3584
  */
3425
3585
  removeInsertRow () {
3426
3586
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3427
- const reactData = $xeTable as unknown as TableReactData
3587
+ const internalData = $xeTable as unknown as TableInternalData
3428
3588
 
3429
- const { editStore } = reactData
3430
- editStore.insertMaps = {}
3589
+ internalData.insertRowMaps = {}
3431
3590
  return $xeTable.remove($xeTable.getInsertRecords())
3432
3591
  },
3433
3592
  /**
@@ -3470,14 +3629,19 @@ const Methods = {
3470
3629
  * @param {Number} columnIndex 索引
3471
3630
  */
3472
3631
  getColumns (columnIndex: any) {
3473
- const columns = this.visibleColumn
3474
- return XEUtils.isUndefined(columnIndex) ? columns.slice(0) : columns[columnIndex]
3632
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3633
+ const internalData = $xeTable as unknown as TableInternalData
3634
+
3635
+ const { visibleColumn } = internalData
3636
+ return XEUtils.isUndefined(columnIndex) ? visibleColumn.slice(0) : visibleColumn[columnIndex]
3475
3637
  },
3476
3638
  /**
3477
3639
  * 根据列获取列的唯一主键
3478
3640
  */
3479
3641
  getColid (fieldOrColumn: any) {
3480
- const column = handleFieldOrColumn(this, fieldOrColumn)
3642
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3643
+
3644
+ const column = handleFieldOrColumn($xeTable, fieldOrColumn)
3481
3645
  return column ? column.id : null
3482
3646
  },
3483
3647
  /**
@@ -3485,7 +3649,10 @@ const Methods = {
3485
3649
  * @param {String} colid 列主键
3486
3650
  */
3487
3651
  getColumnById (colid: any) {
3488
- const fullColumnIdData = this.fullColumnIdData
3652
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3653
+ const internalData = $xeTable as unknown as TableInternalData
3654
+
3655
+ const { fullColumnIdData } = internalData
3489
3656
  return fullColumnIdData[colid] ? fullColumnIdData[colid].column : null
3490
3657
  },
3491
3658
  /**
@@ -3493,7 +3660,10 @@ const Methods = {
3493
3660
  * @param {String} field 字段名
3494
3661
  */
3495
3662
  getColumnByField (field: any) {
3496
- const fullColumnFieldData = this.fullColumnFieldData
3663
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3664
+ const internalData = $xeTable as unknown as TableInternalData
3665
+
3666
+ const { fullColumnFieldData } = internalData
3497
3667
  return fullColumnFieldData[field] ? fullColumnFieldData[field].column : null
3498
3668
  },
3499
3669
  getParentColumn (fieldOrColumn: any) {
@@ -3506,11 +3676,15 @@ const Methods = {
3506
3676
  * 收集到的全量列、全量表头列、处理条件之后的全量表头列、当前渲染中的表头列
3507
3677
  */
3508
3678
  getTableColumn () {
3679
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3680
+ const reactData = $xeTable as unknown as TableReactData
3681
+ const internalData = $xeTable as unknown as TableInternalData
3682
+
3509
3683
  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)
3684
+ collectColumn: internalData.collectColumn.slice(0),
3685
+ fullColumn: internalData.tableFullColumn.slice(0),
3686
+ visibleColumn: internalData.visibleColumn.slice(0),
3687
+ tableColumn: reactData.tableColumn.slice(0)
3514
3688
  }
3515
3689
  },
3516
3690
  /**
@@ -3850,9 +4024,9 @@ const Methods = {
3850
4024
  * 只对 tree-config 有效,获取行的子级
3851
4025
  */
3852
4026
  getTreeRowChildren (rowOrRowid: any) {
3853
- const $xeTable = this
4027
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3854
4028
  const props = $xeTable
3855
- const internalData = $xeTable
4029
+ const internalData = $xeTable as unknown as TableInternalData
3856
4030
 
3857
4031
  const { treeConfig } = props
3858
4032
  const { fullAllDataRowIdData } = internalData
@@ -3933,9 +4107,15 @@ const Methods = {
3933
4107
  * 如果存在排序,继续处理
3934
4108
  */
3935
4109
  getTableData () {
3936
- const { treeConfig, tableFullData, afterFullData, tableData, footerTableData, tableFullTreeData } = this
4110
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4111
+ const props = $xeTable
4112
+ const reactData = $xeTable as unknown as TableReactData
4113
+ const internalData = $xeTable as unknown as TableInternalData
4114
+
4115
+ const { tableData, footerTableData } = reactData
4116
+ const { tableFullData, afterFullData, tableFullTreeData } = internalData
3937
4117
  return {
3938
- fullData: treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
4118
+ fullData: props.treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
3939
4119
  visibleData: afterFullData.slice(0),
3940
4120
  tableData: tableData.slice(0),
3941
4121
  footerData: footerTableData.slice(0)
@@ -3979,35 +4159,16 @@ const Methods = {
3979
4159
  handleLoadDefaults () {
3980
4160
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3981
4161
 
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))
4162
+ handleLoadDefaults($xeTable)
4001
4163
  },
4002
4164
  /**
4003
4165
  * 处理初始化的默认行为
4004
4166
  * 只会执行一次
4005
4167
  */
4006
4168
  handleInitDefaults () {
4007
- const { sortConfig } = this
4008
- if (sortConfig) {
4009
- this.handleDefaultSort()
4010
- }
4169
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4170
+
4171
+ handleInitDefaults($xeTable)
4011
4172
  },
4012
4173
  /**
4013
4174
  * 设置为固定列
@@ -4051,8 +4212,8 @@ const Methods = {
4051
4212
  /**
4052
4213
  * 取消指定固定列
4053
4214
  */
4054
- clearColumnFixed (fieldOrColumn: any) {
4055
- const $xeTable = this
4215
+ clearColumnFixed (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4216
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4056
4217
 
4057
4218
  let status = false
4058
4219
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4077,8 +4238,8 @@ const Methods = {
4077
4238
  /**
4078
4239
  * 隐藏指定列
4079
4240
  */
4080
- hideColumn (fieldOrColumn: any) {
4081
- const $xeTable = this
4241
+ hideColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4242
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4082
4243
 
4083
4244
  let status = false
4084
4245
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4099,8 +4260,8 @@ const Methods = {
4099
4260
  /**
4100
4261
  * 显示指定列
4101
4262
  */
4102
- showColumn (fieldOrColumn: any) {
4103
- const $xeTable = this
4263
+ showColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4264
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4104
4265
 
4105
4266
  let status = false
4106
4267
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4173,67 +4334,35 @@ const Methods = {
4173
4334
  return this.resetCustom(options)
4174
4335
  },
4175
4336
  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
4337
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4191
- const reactData = $xeTable as unknown as TableReactData
4192
- const internalData = $xeTable as unknown as TableInternalData
4338
+ const props = $xeTable
4193
4339
 
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)
4340
+ const { mouseConfig } = props
4341
+ if (mouseConfig) {
4342
+ if ($xeTable.clearSelected) {
4343
+ $xeTable.clearSelected()
4344
+ }
4345
+ if ($xeTable.clearCellAreas) {
4346
+ $xeTable.clearCellAreas()
4347
+ $xeTable.clearCopyCellArea()
4223
4348
  }
4224
- reactData.isCustomStatus = true
4225
- } else {
4226
- reactData.isCustomStatus = false
4227
4349
  }
4350
+ $xeTable.analyColumnWidth()
4351
+ return $xeTable.refreshColumn(true)
4228
4352
  },
4229
4353
  /**
4230
4354
  * 还原自定义列操作状态
4231
4355
  */
4232
4356
  restoreCustomStorage () {
4233
- const { tableId, customConfig, customOpts } = this
4357
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4358
+ const props = $xeTable
4359
+
4360
+ const { customConfig } = props
4361
+ const tableId = $xeTable.computeTableId
4362
+ const customOpts = $xeTable.computeCustomOpts
4234
4363
  const { storage, restoreStore } = customOpts
4235
4364
  const isAllCustom = storage === true
4236
- const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {})
4365
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
4237
4366
  const isCustomResizable = isAllCustom || storageOpts.resizable
4238
4367
  const isCustomVisible = isAllCustom || storageOpts.visible
4239
4368
  const isCustomFixed = isAllCustom || storageOpts.fixed
@@ -4251,10 +4380,10 @@ const Methods = {
4251
4380
  if (!storeData) {
4252
4381
  return
4253
4382
  }
4254
- return this.handleCustomRestore(storeData)
4383
+ return handleCustomRestore($xeTable, storeData)
4255
4384
  }).catch(e => e)
4256
4385
  } else {
4257
- return this.handleCustomRestore(storeData)
4386
+ return handleCustomRestore($xeTable, storeData)
4258
4387
  }
4259
4388
  }
4260
4389
  },
@@ -5708,26 +5837,6 @@ const Methods = {
5708
5837
  }
5709
5838
  return []
5710
5839
  },
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
5840
  handleCheckedCheckboxRow (rows: any[], value: boolean, isForce?: boolean) {
5732
5841
  const $xeTable = this
5733
5842
 
@@ -6320,24 +6429,6 @@ const Methods = {
6320
6429
  reactData.updateCheckboxFlag++
6321
6430
  return this.$nextTick()
6322
6431
  },
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
6432
  /**
6342
6433
  * 单选,行选中事件
6343
6434
  */
@@ -6727,32 +6818,6 @@ const Methods = {
6727
6818
  }
6728
6819
  this.emitEvent('cell-dblclick', params, evnt)
6729
6820
  },
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
6821
  handleColumnSortEvent (evnt: any, column: any) {
6757
6822
  const $xeTable = this
6758
6823
  const props = $xeTable
@@ -7918,24 +7983,6 @@ const Methods = {
7918
7983
  toggleRowExpand (row: any) {
7919
7984
  return this.setRowExpand(row, !this.isRowExpandByRow(row))
7920
7985
  },
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
7986
  /**
7940
7987
  * 设置所有行的展开与否
7941
7988
  * @param {Boolean} expanded 是否展开
@@ -8526,8 +8573,8 @@ const Methods = {
8526
8573
  triggerScrollXEvent () {
8527
8574
  const $xeTable = this
8528
8575
 
8529
- const sXOpts = $xeTable.computeSXOpts
8530
- if (sXOpts.immediate) {
8576
+ const virtualXOpts = $xeTable.computeVirtualXOpts
8577
+ if (virtualXOpts.immediate) {
8531
8578
  loadScrollXData($xeTable)
8532
8579
  } else {
8533
8580
  lazyScrollXData($xeTable)
@@ -8539,8 +8586,8 @@ const Methods = {
8539
8586
  triggerScrollYEvent () {
8540
8587
  const $xeTable = this
8541
8588
 
8542
- const sYOpts = $xeTable.computeSYOpts
8543
- if (sYOpts.immediate) {
8589
+ const virtualYOpts = $xeTable.computeVirtualYOpts
8590
+ if (virtualYOpts.immediate) {
8544
8591
  loadScrollYData($xeTable)
8545
8592
  } else {
8546
8593
  lazyScrollYData($xeTable)
@@ -8751,8 +8798,8 @@ const Methods = {
8751
8798
  }
8752
8799
 
8753
8800
  const wheelSpeed = getWheelSpeed(reactData.lastScrollTime)
8754
- const deltaTop = Math.ceil((shiftKey ? deltaX : deltaY) * wheelSpeed)
8755
- const deltaLeft = Math.ceil((shiftKey ? deltaY : deltaX) * wheelSpeed)
8801
+ const deltaTop = shiftKey ? 0 : Math.ceil(deltaY * wheelSpeed)
8802
+ const deltaLeft = Math.ceil((shiftKey ? (deltaY || deltaX) : deltaX) * wheelSpeed)
8756
8803
 
8757
8804
  const isTopWheel = deltaTop < 0
8758
8805
  const currScrollTop = bodyScrollElem.scrollTop
@@ -9272,9 +9319,6 @@ const Methods = {
9272
9319
  }
9273
9320
  })
9274
9321
  },
9275
- handleDefaultMergeCells () {
9276
- this.setMergeCells(this.mergeCells)
9277
- },
9278
9322
  /**
9279
9323
  * 设置合并单元格
9280
9324
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
@@ -9325,9 +9369,6 @@ const Methods = {
9325
9369
  return updateStyle($xeTable)
9326
9370
  })
9327
9371
  },
9328
- handleDefaultMergeFooterItems () {
9329
- this.setMergeFooterItems(this.mergeFooterItems)
9330
- },
9331
9372
  setMergeFooterItems (merges: any) {
9332
9373
  const $xeTable = this
9333
9374