vxe-table 3.4.7 → 3.4.8

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.
@@ -301,23 +301,14 @@ const Methods = {
301
301
  return this.handleTableData(true).then(this.updateFooter).then(this.recalculate)
302
302
  },
303
303
  handleTableData (force) {
304
- const { treeConfig, scrollYLoad, scrollYStore, fullDataRowIdData, treeExpandeds, treeOpts } = this
305
- let fullList = []
304
+ const { scrollYLoad, scrollYStore, fullDataRowIdData, afterFullData } = this
305
+ let fullList = afterFullData
306
306
  // 是否进行数据处理
307
307
  if (force) {
308
+ // 更新数据,处理筛选和排序
308
309
  this.updateAfterFullData()
309
- }
310
- // 如果为虚拟树,将树结构拍平
311
- if (treeConfig && treeOpts.transform) {
312
- const expandMaps = new Map()
313
- XEUtils.eachTree(this.afterTreeFullData, (row, index, items, path, parent) => {
314
- if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
315
- expandMaps.set(row, 1)
316
- fullList.push(row)
317
- }
318
- }, { children: treeOpts.mapChildren })
319
- } else {
320
- fullList = this.afterFullData
310
+ // 如果为虚拟树,将树结构拍平
311
+ fullList = this.handleVirtualTreeToList()
321
312
  }
322
313
  const tableData = scrollYLoad ? fullList.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullList.slice(0)
323
314
  tableData.forEach((row, $index) => {
@@ -1111,6 +1102,27 @@ const Methods = {
1111
1102
  }
1112
1103
  return rowList
1113
1104
  },
1105
+ /**
1106
+ * 如果为虚拟树,将树结构拍平
1107
+ * @returns
1108
+ */
1109
+ handleVirtualTreeToList () {
1110
+ const { treeOpts, treeConfig, treeExpandeds, afterTreeFullData, afterFullData } = this
1111
+ if (treeConfig && treeOpts.transform) {
1112
+ const fullData = []
1113
+ const expandMaps = new Map()
1114
+ XEUtils.eachTree(afterTreeFullData, (row, index, items, path, parent) => {
1115
+ if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
1116
+ expandMaps.set(row, 1)
1117
+ fullData.push(row)
1118
+ }
1119
+ }, { children: treeOpts.mapChildren })
1120
+ this.afterFullData = fullData
1121
+ this.updateScrollYStatus(fullData)
1122
+ return fullData
1123
+ }
1124
+ return afterFullData
1125
+ },
1114
1126
  /**
1115
1127
  * 获取处理后全量的表格数据
1116
1128
  * 如果存在筛选条件,继续处理
@@ -3807,12 +3819,16 @@ const Methods = {
3807
3819
  },
3808
3820
  clearTreeExpandLoaded (row) {
3809
3821
  const { treeOpts, treeExpandeds, fullAllDataRowMap } = this
3810
- const { lazy } = treeOpts
3822
+ const { transform, lazy } = treeOpts
3811
3823
  const rest = fullAllDataRowMap.get(row)
3812
3824
  if (lazy && rest) {
3813
3825
  rest.treeLoaded = false
3814
3826
  XEUtils.remove(treeExpandeds, item => row === item)
3815
3827
  }
3828
+ if (transform) {
3829
+ this.handleVirtualTreeToList()
3830
+ return this.handleTableData()
3831
+ }
3816
3832
  return this.$nextTick()
3817
3833
  },
3818
3834
  /**
@@ -3989,6 +4005,7 @@ const Methods = {
3989
4005
  */
3990
4006
  handleVirtualTreeExpand (rows, expanded) {
3991
4007
  return this.handleBaseTreeExpand(rows, expanded).then(() => {
4008
+ this.handleVirtualTreeToList()
3992
4009
  return this.handleTableData()
3993
4010
  }).then(() => {
3994
4011
  return this.recalculate()
@@ -4031,13 +4048,16 @@ const Methods = {
4031
4048
  */
4032
4049
  clearTreeExpand () {
4033
4050
  const { treeOpts, treeExpandeds, tableFullData } = this
4034
- const { reserve } = treeOpts
4051
+ const { transform, reserve } = treeOpts
4035
4052
  const isExists = treeExpandeds.length
4036
4053
  this.treeExpandeds = []
4037
4054
  if (reserve) {
4038
4055
  XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), treeOpts)
4039
4056
  }
4040
4057
  return this.handleTableData().then(() => {
4058
+ if (transform) {
4059
+ this.handleVirtualTreeToList()
4060
+ }
4041
4061
  if (isExists) {
4042
4062
  this.recalculate()
4043
4063
  }