vxe-table 3.5.9 → 3.6.0-beta.0

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.
@@ -1125,9 +1125,9 @@ const Methods = {
1125
1125
  } else {
1126
1126
  const { selection } = this
1127
1127
  if (treeConfig) {
1128
- rowList = XEUtils.filterTree(currTableData, row => selection.indexOf(row) > -1, { children: transform ? mapChildren : children })
1128
+ rowList = XEUtils.filterTree(currTableData, row => this.findRowIndexOf(selection, row) > -1, { children: transform ? mapChildren : children })
1129
1129
  } else {
1130
- rowList = currTableData.filter(row => selection.indexOf(row) > -1)
1130
+ rowList = currTableData.filter(row => this.findRowIndexOf(selection, row) > -1)
1131
1131
  }
1132
1132
  }
1133
1133
  return rowList
@@ -2727,7 +2727,7 @@ const Methods = {
2727
2727
  getCheckboxIndeterminateRecords (isFull) {
2728
2728
  const { treeConfig, treeIndeterminates, afterFullData } = this
2729
2729
  if (treeConfig) {
2730
- return isFull ? treeIndeterminates.slice(0) : treeIndeterminates.filter(row => afterFullData.indexOf(row))
2730
+ return isFull ? treeIndeterminates.slice(0) : treeIndeterminates.filter(row => this.findRowIndexOf(afterFullData, row) > -1)
2731
2731
  }
2732
2732
  return []
2733
2733
  },
@@ -2762,14 +2762,16 @@ const Methods = {
2762
2762
  return this.$nextTick()
2763
2763
  },
2764
2764
  isCheckedByCheckboxRow (row) {
2765
+ const { selection } = this
2765
2766
  const { checkField } = this.checkboxOpts
2766
2767
  if (checkField) {
2767
2768
  return XEUtils.get(row, checkField)
2768
2769
  }
2769
- return this.selection.indexOf(row) > -1
2770
+ return this.findRowIndexOf(selection, row) > -1
2770
2771
  },
2771
2772
  isIndeterminateByCheckboxRow (row) {
2772
- return this.treeIndeterminates.indexOf(row) > -1 && !this.isCheckedByCheckboxRow(row)
2773
+ const { treeIndeterminates } = this
2774
+ return this.findRowIndexOf(treeIndeterminates, row) > -1 && !this.isCheckedByCheckboxRow(row)
2773
2775
  },
2774
2776
  /**
2775
2777
  * 多选,行选中事件
@@ -2781,31 +2783,31 @@ const Methods = {
2781
2783
  if (checkField) {
2782
2784
  if (treeConfig && !checkStrictly) {
2783
2785
  if (value === -1) {
2784
- if (treeIndeterminates.indexOf(row) === -1) {
2786
+ if (this.findRowIndexOf(treeIndeterminates, row) === -1) {
2785
2787
  treeIndeterminates.push(row)
2786
2788
  }
2787
2789
  XEUtils.set(row, checkField, false)
2788
2790
  } else {
2789
2791
  // 更新子节点状态
2790
2792
  XEUtils.eachTree([row], (item) => {
2791
- if (row === item || (!checkMethod || checkMethod({ row: item }))) {
2793
+ if (this.eqRow(item, row) || (!checkMethod || checkMethod({ row: item }))) {
2792
2794
  XEUtils.set(item, checkField, value)
2793
- XEUtils.remove(treeIndeterminates, half => half === item)
2795
+ XEUtils.remove(treeIndeterminates, half => this.eqRow(half, item))
2794
2796
  this.handleCheckboxReserveRow(row, value)
2795
2797
  }
2796
2798
  }, treeOpts)
2797
2799
  }
2798
2800
  // 如果存在父节点,更新父节点状态
2799
- const matchObj = XEUtils.findTree(afterFullData, item => item === row, treeOpts)
2801
+ const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), treeOpts)
2800
2802
  if (matchObj && matchObj.parent) {
2801
2803
  let parentStatus
2802
2804
  const vItems = checkMethod ? matchObj.items.filter((item) => checkMethod({ row: item })) : matchObj.items
2803
- const indeterminatesItem = XEUtils.find(matchObj.items, item => treeIndeterminates.indexOf(item) > -1)
2805
+ const indeterminatesItem = XEUtils.find(matchObj.items, item => this.findRowIndexOf(treeIndeterminates, item) > -1)
2804
2806
  if (indeterminatesItem) {
2805
2807
  parentStatus = -1
2806
2808
  } else {
2807
2809
  const selectItems = matchObj.items.filter(item => XEUtils.get(item, checkField))
2808
- parentStatus = selectItems.filter(item => vItems.indexOf(item) > -1).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
2810
+ parentStatus = selectItems.filter(item => this.findRowIndexOf(vItems, item) > -1).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
2809
2811
  }
2810
2812
  return this.handleSelectRow({ row: matchObj.parent }, parentStatus)
2811
2813
  }
@@ -2818,46 +2820,46 @@ const Methods = {
2818
2820
  } else {
2819
2821
  if (treeConfig && !checkStrictly) {
2820
2822
  if (value === -1) {
2821
- if (treeIndeterminates.indexOf(row) === -1) {
2823
+ if (this.findRowIndexOf(treeIndeterminates, row) === -1) {
2822
2824
  treeIndeterminates.push(row)
2823
2825
  }
2824
- XEUtils.remove(selection, item => item === row)
2826
+ XEUtils.remove(selection, item => this.eqRow(item, row))
2825
2827
  } else {
2826
2828
  // 更新子节点状态
2827
2829
  XEUtils.eachTree([row], (item) => {
2828
- if (row === item || (!checkMethod || checkMethod({ row: item }))) {
2830
+ if (this.eqRow(item, row) || (!checkMethod || checkMethod({ row: item }))) {
2829
2831
  if (value) {
2830
2832
  selection.push(item)
2831
2833
  } else {
2832
- XEUtils.remove(selection, select => select === item)
2834
+ XEUtils.remove(selection, select => this.eqRow(select, item))
2833
2835
  }
2834
- XEUtils.remove(treeIndeterminates, half => half === item)
2836
+ XEUtils.remove(treeIndeterminates, half => this.eqRow(half, item))
2835
2837
  this.handleCheckboxReserveRow(row, value)
2836
2838
  }
2837
2839
  }, treeOpts)
2838
2840
  }
2839
2841
  // 如果存在父节点,更新父节点状态
2840
- const matchObj = XEUtils.findTree(afterFullData, item => item === row, treeOpts)
2842
+ const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), treeOpts)
2841
2843
  if (matchObj && matchObj.parent) {
2842
2844
  let parentStatus
2843
2845
  const vItems = checkMethod ? matchObj.items.filter((item) => checkMethod({ row: item })) : matchObj.items
2844
- const indeterminatesItem = XEUtils.find(matchObj.items, item => treeIndeterminates.indexOf(item) > -1)
2846
+ const indeterminatesItem = XEUtils.find(matchObj.items, item => this.findRowIndexOf(treeIndeterminates, item) > -1)
2845
2847
  if (indeterminatesItem) {
2846
2848
  parentStatus = -1
2847
2849
  } else {
2848
- const selectItems = matchObj.items.filter(item => selection.indexOf(item) > -1)
2849
- parentStatus = selectItems.filter(item => vItems.indexOf(item) > -1).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
2850
+ const selectItems = matchObj.items.filter(item => this.findRowIndexOf(selection, item) > -1)
2851
+ parentStatus = selectItems.filter(item => this.findRowIndexOf(vItems, item) > -1).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
2850
2852
  }
2851
2853
  return this.handleSelectRow({ row: matchObj.parent }, parentStatus)
2852
2854
  }
2853
2855
  } else {
2854
2856
  if (!checkMethod || checkMethod({ row })) {
2855
2857
  if (value) {
2856
- if (selection.indexOf(row) === -1) {
2858
+ if (this.findRowIndexOf(selection, row) === -1) {
2857
2859
  selection.push(row)
2858
2860
  }
2859
2861
  } else {
2860
- XEUtils.remove(selection, item => item === row)
2862
+ XEUtils.remove(selection, item => this.eqRow(item, row))
2861
2863
  }
2862
2864
  this.handleCheckboxReserveRow(row, value)
2863
2865
  }
@@ -2869,7 +2871,7 @@ const Methods = {
2869
2871
  const { selection, checkboxOpts } = this
2870
2872
  const { checkField } = checkboxOpts
2871
2873
  const { row } = params
2872
- const value = checkField ? !XEUtils.get(row, checkField) : selection.indexOf(row) === -1
2874
+ const value = checkField ? !XEUtils.get(row, checkField) : this.findRowIndexOf(selection, row) === -1
2873
2875
  if (evnt) {
2874
2876
  this.triggerCheckRowEvent(evnt, params, value)
2875
2877
  } else {
@@ -2880,7 +2882,12 @@ const Methods = {
2880
2882
  const { checkMethod } = this.checkboxOpts
2881
2883
  if (!checkMethod || checkMethod({ row: params.row })) {
2882
2884
  this.handleSelectRow(params, value)
2883
- this.emitEvent('checkbox-change', Object.assign({ records: this.getCheckboxRecords(), reserves: this.getCheckboxReserveRecords(), indeterminates: this.getCheckboxIndeterminateRecords(), checked: value }, params), evnt)
2885
+ this.emitEvent('checkbox-change', Object.assign({
2886
+ records: this.getCheckboxRecords(),
2887
+ reserves: this.getCheckboxReserveRecords(),
2888
+ indeterminates: this.getCheckboxIndeterminateRecords(),
2889
+ checked: value
2890
+ }, params), evnt)
2884
2891
  }
2885
2892
  },
2886
2893
  /**
@@ -2898,7 +2905,7 @@ const Methods = {
2898
2905
  const { afterFullData, treeConfig, treeOpts, selection, checkboxReserveRowMap, checkboxOpts } = this
2899
2906
  const { checkField, reserve, checkStrictly, checkMethod } = checkboxOpts
2900
2907
  let selectRows = []
2901
- const beforeSelection = treeConfig ? [] : selection.filter(row => afterFullData.indexOf(row) === -1)
2908
+ const beforeSelection = treeConfig ? [] : selection.filter(row => this.findRowIndexOf(afterFullData, row) === -1)
2902
2909
  if (checkStrictly) {
2903
2910
  this.isAllSelected = value
2904
2911
  } else {
@@ -2945,7 +2952,7 @@ const Methods = {
2945
2952
  */
2946
2953
  if (checkMethod) {
2947
2954
  XEUtils.eachTree(afterFullData, (row) => {
2948
- if (checkMethod({ row }) ? 0 : selection.indexOf(row) > -1) {
2955
+ if (checkMethod({ row }) ? 0 : this.findRowIndexOf(selection, row) > -1) {
2949
2956
  selectRows.push(row)
2950
2957
  }
2951
2958
  }, treeOpts)
@@ -2959,7 +2966,7 @@ const Methods = {
2959
2966
  * 如果不存在选中方法,则添加所有数据到临时集合中
2960
2967
  */
2961
2968
  if (checkMethod) {
2962
- selectRows = afterFullData.filter((row) => selection.indexOf(row) > -1 || checkMethod({ row }))
2969
+ selectRows = afterFullData.filter((row) => this.findRowIndexOf(selection, row) > -1 || checkMethod({ row }))
2963
2970
  } else {
2964
2971
  selectRows = afterFullData.slice(0)
2965
2972
  }
@@ -2970,7 +2977,7 @@ const Methods = {
2970
2977
  * 如果不存在选中方法,无需处理,临时集合默认为空
2971
2978
  */
2972
2979
  if (checkMethod) {
2973
- selectRows = afterFullData.filter((row) => checkMethod({ row }) ? 0 : selection.indexOf(row) > -1)
2980
+ selectRows = afterFullData.filter((row) => checkMethod({ row }) ? 0 : this.findRowIndexOf(selection, row) > -1)
2974
2981
  }
2975
2982
  }
2976
2983
  }
@@ -3017,9 +3024,9 @@ const Methods = {
3017
3024
  isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
3018
3025
  if (treeConfig) {
3019
3026
  if (halfField) {
3020
- isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row, halfField) || treeIndeterminates.indexOf(row) > -1)
3027
+ isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row, halfField) || this.findRowIndexOf(treeIndeterminates, row) > -1)
3021
3028
  } else {
3022
- isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || treeIndeterminates.indexOf(row) > -1)
3029
+ isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || this.findRowIndexOf(treeIndeterminates, row) > -1)
3023
3030
  }
3024
3031
  } else {
3025
3032
  if (halfField) {
@@ -3036,19 +3043,19 @@ const Methods = {
3036
3043
  disableRows.push(row)
3037
3044
  return true
3038
3045
  }
3039
- if (selection.indexOf(row) > -1) {
3046
+ if (this.findRowIndexOf(selection, row) > -1) {
3040
3047
  checkRows.push(row)
3041
3048
  return true
3042
3049
  }
3043
3050
  return false
3044
3051
  }
3045
- : row => selection.indexOf(row) > -1
3052
+ : row => this.findRowIndexOf(selection, row) > -1
3046
3053
  )
3047
3054
  isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
3048
3055
  if (treeConfig) {
3049
- isIndeterminate = !isAllSelected && afterFullData.some(row => treeIndeterminates.indexOf(row) > -1 || selection.indexOf(row) > -1)
3056
+ isIndeterminate = !isAllSelected && afterFullData.some(row => this.findRowIndexOf(treeIndeterminates, row) > -1 || this.findRowIndexOf(selection, row) > -1)
3050
3057
  } else {
3051
- isIndeterminate = !isAllSelected && afterFullData.some(row => selection.indexOf(row) > -1)
3058
+ isIndeterminate = !isAllSelected && afterFullData.some(row => this.findRowIndexOf(selection, row) > -1)
3052
3059
  }
3053
3060
  }
3054
3061
  this.isAllSelected = isAllSelected
@@ -3695,7 +3702,7 @@ const Methods = {
3695
3702
  const rest = fullAllDataRowMap.get(row)
3696
3703
  if (lazy && rest) {
3697
3704
  rest.expandLoaded = false
3698
- XEUtils.remove(expandLazyLoadeds, item => row === item)
3705
+ XEUtils.remove(expandLazyLoadeds, item => this.eqRow(item, row))
3699
3706
  }
3700
3707
  return this.$nextTick()
3701
3708
  },
@@ -3706,7 +3713,7 @@ const Methods = {
3706
3713
  reloadRowExpand (row) {
3707
3714
  const { expandOpts, expandLazyLoadeds } = this
3708
3715
  const { lazy } = expandOpts
3709
- if (lazy && expandLazyLoadeds.indexOf(row) === -1) {
3716
+ if (lazy && this.findRowIndexOf(expandLazyLoadeds, row) === -1) {
3710
3717
  this.clearRowExpandLoaded(row)
3711
3718
  .then(() => this.handleAsyncRowExpand(row))
3712
3719
  }
@@ -3726,7 +3733,7 @@ const Methods = {
3726
3733
  const { expandOpts, expandLazyLoadeds, expandColumn: column } = this
3727
3734
  const { row } = params
3728
3735
  const { lazy } = expandOpts
3729
- if (!lazy || expandLazyLoadeds.indexOf(row) === -1) {
3736
+ if (!lazy || this.findRowIndexOf(expandLazyLoadeds, row) === -1) {
3730
3737
  const expanded = !this.isExpandByRow(row)
3731
3738
  const columnIndex = this.getColumnIndex(column)
3732
3739
  const $columnIndex = this.getVMColumnIndex(column)
@@ -3775,7 +3782,7 @@ const Methods = {
3775
3782
  }).catch(() => {
3776
3783
  rest.expandLoaded = false
3777
3784
  }).finally(() => {
3778
- XEUtils.remove(this.expandLazyLoadeds, item => item === row)
3785
+ XEUtils.remove(this.expandLazyLoadeds, item => this.eqRow(item, row))
3779
3786
  resolve(this.$nextTick().then(this.recalculate))
3780
3787
  })
3781
3788
  })
@@ -3806,9 +3813,9 @@ const Methods = {
3806
3813
  const validRows = toggleMethod ? rows.filter(row => toggleMethod({ expanded, column, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) })) : rows
3807
3814
  if (expanded) {
3808
3815
  validRows.forEach(row => {
3809
- if (rowExpandeds.indexOf(row) === -1) {
3816
+ if (this.findRowIndexOf(rowExpandeds, row) === -1) {
3810
3817
  const rest = fullAllDataRowMap.get(row)
3811
- const isLoad = lazy && !rest.expandLoaded && expandLazyLoadeds.indexOf(row) === -1
3818
+ const isLoad = lazy && !rest.expandLoaded && this.findRowIndexOf(expandLazyLoadeds, row) === -1
3812
3819
  if (isLoad) {
3813
3820
  lazyRests.push(this.handleAsyncRowExpand(row))
3814
3821
  } else {
@@ -3817,7 +3824,7 @@ const Methods = {
3817
3824
  }
3818
3825
  })
3819
3826
  } else {
3820
- XEUtils.remove(rowExpandeds, row => validRows.indexOf(row) > -1)
3827
+ XEUtils.remove(rowExpandeds, row => this.findRowIndexOf(validRows, row) > -1)
3821
3828
  }
3822
3829
  if (reserve) {
3823
3830
  validRows.forEach(row => this.handleRowExpandReserve(row, expanded))
@@ -3831,7 +3838,8 @@ const Methods = {
3831
3838
  * @param {Row} row 行对象
3832
3839
  */
3833
3840
  isExpandByRow (row) {
3834
- return this.rowExpandeds.indexOf(row) > -1
3841
+ const { rowExpandeds } = this
3842
+ return this.findRowIndexOf(rowExpandeds, row) > -1
3835
3843
  },
3836
3844
  /**
3837
3845
  * 手动清空展开行状态,数据会恢复成未展开的状态