vxe-table 3.11.30-beta.0 → 3.11.30

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.
@@ -4006,11 +4006,13 @@ const Methods = {
4006
4006
  }
4007
4007
  },
4008
4008
  handleCheckedCheckboxRow (rows: any, value: any, isForce: any) {
4009
+ const $xeTable = this
4010
+
4009
4011
  if (rows && !XEUtils.isArray(rows)) {
4010
4012
  rows = [rows]
4011
4013
  }
4012
- this.handleBatchSelectRows(rows, !!value, isForce)
4013
- this.checkSelectionStatus()
4014
+ $xeTable.handleBatchSelectRows(rows, !!value, isForce)
4015
+ $xeTable.checkSelectionStatus()
4014
4016
  return this.$nextTick()
4015
4017
  },
4016
4018
  /**
@@ -4037,216 +4039,97 @@ const Methods = {
4037
4039
  return !!treeIndeterminateMaps[getRowid(this, row)] && !this.isCheckedByCheckboxRow(row)
4038
4040
  },
4039
4041
  /**
4040
- * 多行
4042
+ * 切换选中
4041
4043
  * 多选,行选中事件
4042
- * value 选中true 不选false 半选-1
4043
4044
  */
4044
- handleBatchSelectRows (rows: any[], value: any, isForce: any) {
4045
+ handleBatchSelectRows (rows: any[], checked: boolean, isForce?: boolean) {
4045
4046
  const $xeTable = this
4046
- const { treeConfig } = $xeTable
4047
+ const props = $xeTable
4048
+ const reactData = $xeTable
4047
4049
 
4048
- const { selectCheckboxMaps, checkboxOpts } = this
4050
+ const { treeConfig } = props
4051
+ const { selectCheckboxMaps } = reactData
4052
+ const selectRowMaps = Object.assign({}, selectCheckboxMaps)
4053
+ const treeOpts = $xeTable.computeTreeOpts
4054
+ const { transform, mapChildrenField } = treeOpts
4055
+ const childrenField = treeOpts.children || treeOpts.childrenField
4056
+ const checkboxOpts = $xeTable.computeCheckboxOpts
4049
4057
  const { checkField, checkStrictly, checkMethod } = checkboxOpts
4058
+ const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
4050
4059
  if (checkField) {
4060
+ // 树结构
4051
4061
  if (treeConfig && !checkStrictly) {
4052
- rows.forEach(row => {
4053
- this.handleSelectRow({ row }, value, isForce)
4054
- })
4055
- } else {
4056
- rows.forEach(row => {
4062
+ // 更新子节点状态
4063
+ XEUtils.eachTree(rows, (row) => {
4057
4064
  if (isForce || (!checkMethod || checkMethod({ row }))) {
4058
- XEUtils.set(row, checkField, value)
4059
- this.handleCheckboxReserveRow(row, value)
4065
+ XEUtils.set(row, checkField, checked)
4066
+ if (indeterminateField) {
4067
+ XEUtils.set(row, indeterminateField, false)
4068
+ }
4069
+ $xeTable.handleCheckboxReserveRow(row, checked)
4060
4070
  }
4061
- })
4062
- }
4063
- } else {
4064
- if (treeConfig && !checkStrictly) {
4065
- rows.forEach(row => {
4066
- this.handleSelectRow({ row }, value, isForce)
4067
- })
4071
+ }, { children: transform ? mapChildrenField : childrenField })
4072
+ reactData.selectCheckboxMaps = selectRowMaps
4073
+ return
4068
4074
  } else {
4069
- const selectRowMaps = Object.assign({}, selectCheckboxMaps)
4075
+ // 列表
4070
4076
  rows.forEach(row => {
4071
- const rowid = getRowid($xeTable, row)
4072
4077
  if (isForce || (!checkMethod || checkMethod({ row }))) {
4073
- if (value) {
4074
- if (!selectRowMaps[rowid]) {
4075
- selectRowMaps[rowid] = row
4076
- }
4077
- } else {
4078
- if (selectRowMaps[rowid]) {
4079
- delete selectRowMaps[rowid]
4080
- }
4081
- }
4082
- this.handleCheckboxReserveRow(row, value)
4078
+ XEUtils.set(row, checkField, checked)
4079
+ $xeTable.handleCheckboxReserveRow(row, checked)
4083
4080
  }
4084
4081
  })
4085
- this.selectCheckboxMaps = selectRowMaps
4086
4082
  }
4083
+ reactData.selectCheckboxMaps = selectRowMaps
4084
+ return
4087
4085
  }
4088
- },
4089
- /**
4090
- * 多选,行选中事件
4091
- * value 选中true 不选false 半选-1
4092
- */
4093
- handleSelectRow ({ row }: any, value: any, isForce: any) {
4094
- const { selectCheckboxMaps, afterFullData, treeConfig, treeOpts, treeIndeterminateMaps, checkboxOpts } = this
4095
- const { checkField, checkStrictly, checkMethod } = checkboxOpts
4096
- const selectRowMaps = { ...selectCheckboxMaps }
4097
- const childrenField = treeOpts.children || treeOpts.childrenField
4098
- const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
4099
- const rowid = getRowid(this, row)
4100
- if (checkField) {
4101
- if (treeConfig && !checkStrictly) {
4102
- if (value === -1) {
4103
- if (!treeIndeterminateMaps[rowid]) {
4104
- if (indeterminateField) {
4105
- XEUtils.set(row, indeterminateField, true)
4106
- }
4107
- treeIndeterminateMaps[rowid] = row
4108
- }
4109
- XEUtils.set(row, checkField, false)
4110
- } else {
4111
- // 更新子节点状态
4112
- XEUtils.eachTree([row], (item) => {
4113
- if (this.eqRow(item, row) || (isForce || (!checkMethod || checkMethod({ row: item })))) {
4114
- XEUtils.set(item, checkField, value)
4115
- if (indeterminateField) {
4116
- XEUtils.set(row, indeterminateField, false)
4117
- }
4118
- delete treeIndeterminateMaps[getRowid(this, item)]
4119
- this.handleCheckboxReserveRow(row, value)
4120
- }
4121
- }, { children: childrenField })
4122
- }
4123
- // 如果存在父节点,更新父节点状态
4124
- const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
4125
- if (matchObj && matchObj.parent) {
4126
- let parentStatus
4127
- const vItems: any[] = []
4128
- const vItemMaps: any = {}
4129
- if (!isForce && checkMethod) {
4130
- matchObj.items.forEach((item) => {
4131
- if (checkMethod({ row: item })) {
4132
- const itemRid = getRowid(this, item)
4133
- vItemMaps[itemRid] = item
4134
- vItems.push(item)
4135
- }
4136
- })
4137
- } else {
4138
- matchObj.items.forEach(item => {
4139
- const itemRid = getRowid(this, item)
4140
- vItemMaps[itemRid] = item
4141
- vItems.push(item)
4142
- })
4143
- }
4144
- const indeterminatesItem = XEUtils.find(matchObj.items, item => !!treeIndeterminateMaps[getRowid(this, item)])
4145
- if (indeterminatesItem) {
4146
- parentStatus = -1
4086
+
4087
+ // 树结构
4088
+ if (treeConfig && !checkStrictly) {
4089
+ // 更新子节点状态
4090
+ XEUtils.eachTree(rows, (row) => {
4091
+ const rowid = getRowid($xeTable, row)
4092
+ if (isForce || (!checkMethod || checkMethod({ row }))) {
4093
+ if (checked) {
4094
+ selectRowMaps[rowid] = row
4147
4095
  } else {
4148
- const selectItems: any[] = []
4149
- matchObj.items.forEach(item => {
4150
- if (XEUtils.get(item, checkField)) {
4151
- selectItems.push(item)
4152
- }
4153
- })
4154
- parentStatus = selectItems.filter(item => vItemMaps[getRowid(this, item)]).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
4096
+ if (selectRowMaps[rowid]) {
4097
+ delete selectRowMaps[rowid]
4098
+ }
4155
4099
  }
4156
- this.selectCheckboxMaps = selectRowMaps
4157
- return this.handleSelectRow({ row: matchObj.parent }, parentStatus, isForce)
4100
+ $xeTable.handleCheckboxReserveRow(row, checked)
4158
4101
  }
4159
- } else {
4160
- if (isForce || (!checkMethod || checkMethod({ row }))) {
4161
- XEUtils.set(row, checkField, value)
4162
- this.handleCheckboxReserveRow(row, value)
4163
- }
4164
- }
4165
- } else {
4166
- if (treeConfig && !checkStrictly) {
4167
- if (value === -1) {
4168
- if (!treeIndeterminateMaps[rowid]) {
4169
- if (indeterminateField) {
4170
- XEUtils.set(row, indeterminateField, true)
4171
- }
4172
- treeIndeterminateMaps[rowid] = row
4102
+ }, { children: transform ? mapChildrenField : childrenField })
4103
+ reactData.selectCheckboxMaps = selectRowMaps
4104
+ return
4105
+ }
4106
+
4107
+ // 列表
4108
+ rows.forEach(row => {
4109
+ const rowid = getRowid($xeTable, row)
4110
+ if (isForce || (!checkMethod || checkMethod({ row }))) {
4111
+ if (checked) {
4112
+ if (!selectRowMaps[rowid]) {
4113
+ selectRowMaps[rowid] = row
4173
4114
  }
4115
+ } else {
4174
4116
  if (selectRowMaps[rowid]) {
4175
4117
  delete selectRowMaps[rowid]
4176
4118
  }
4177
- } else {
4178
- // 更新子节点状态
4179
- XEUtils.eachTree([row], (item) => {
4180
- const itemRid = getRowid(this, item)
4181
- if (this.eqRow(item, row) || (isForce || (!checkMethod || checkMethod({ row: item })))) {
4182
- if (value) {
4183
- selectRowMaps[itemRid] = item
4184
- } else {
4185
- if (selectRowMaps[itemRid]) {
4186
- delete selectRowMaps[itemRid]
4187
- }
4188
- }
4189
- if (indeterminateField) {
4190
- XEUtils.set(row, indeterminateField, false)
4191
- }
4192
- delete treeIndeterminateMaps[getRowid(this, item)]
4193
- this.handleCheckboxReserveRow(row, value)
4194
- }
4195
- }, { children: childrenField })
4196
- }
4197
- // 如果存在父节点,更新父节点状态
4198
- const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
4199
- if (matchObj && matchObj.parent) {
4200
- let parentStatus
4201
- const vItems: any[] = []
4202
- const vItemMaps: any = {}
4203
- if (!isForce && checkMethod) {
4204
- matchObj.items.forEach((item) => {
4205
- if (checkMethod({ row: item })) {
4206
- const itemRid = getRowid(this, item)
4207
- vItemMaps[itemRid] = item
4208
- vItems.push(item)
4209
- }
4210
- })
4211
- } else {
4212
- matchObj.items.forEach(item => {
4213
- const itemRid = getRowid(this, item)
4214
- vItemMaps[itemRid] = item
4215
- vItems.push(item)
4216
- })
4217
- }
4218
- const indeterminatesItem = XEUtils.find(matchObj.items, item => !!treeIndeterminateMaps[getRowid(this, item)])
4219
- if (indeterminatesItem) {
4220
- parentStatus = -1
4221
- } else {
4222
- const selectItems: any[] = []
4223
- matchObj.items.forEach(item => {
4224
- const itemRid = getRowid(this, item)
4225
- if (selectRowMaps[itemRid]) {
4226
- selectItems.push(item)
4227
- }
4228
- })
4229
- parentStatus = selectItems.filter(item => vItemMaps[getRowid(this, item)]).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
4230
- }
4231
- this.selectCheckboxMaps = selectRowMaps
4232
- return this.handleSelectRow({ row: matchObj.parent }, parentStatus, isForce)
4233
- }
4234
- } else {
4235
- if (isForce || (!checkMethod || checkMethod({ row }))) {
4236
- if (value) {
4237
- if (!selectRowMaps[rowid]) {
4238
- selectRowMaps[rowid] = row
4239
- }
4240
- } else {
4241
- if (selectRowMaps[rowid]) {
4242
- delete selectRowMaps[rowid]
4243
- }
4244
- }
4245
- this.handleCheckboxReserveRow(row, value)
4246
4119
  }
4120
+ $xeTable.handleCheckboxReserveRow(row, checked)
4247
4121
  }
4248
- }
4249
- this.selectCheckboxMaps = selectRowMaps
4122
+ })
4123
+ reactData.selectCheckboxMaps = selectRowMaps
4124
+ },
4125
+ /**
4126
+ * 即将移除
4127
+ * @deprecated
4128
+ */
4129
+ handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
4130
+ const $xeTable = this
4131
+
4132
+ $xeTable.handleBatchSelectRows([row], checked, isForce)
4250
4133
  },
4251
4134
  handleToggleCheckRowEvent (evnt: any, params: any) {
4252
4135
  const { selectCheckboxMaps, checkboxOpts } = this
@@ -4255,20 +4138,20 @@ const Methods = {
4255
4138
  if (trigger === 'manual') {
4256
4139
  return
4257
4140
  }
4258
- let value = false
4141
+ let checked = false
4259
4142
  if (checkField) {
4260
- value = !XEUtils.get(row, checkField)
4143
+ checked = !XEUtils.get(row, checkField)
4261
4144
  } else {
4262
- value = !selectCheckboxMaps[getRowid(this, row)]
4145
+ checked = !selectCheckboxMaps[getRowid(this, row)]
4263
4146
  }
4264
4147
  if (evnt) {
4265
- this.triggerCheckRowEvent(evnt, params, value)
4148
+ this.triggerCheckRowEvent(evnt, params, checked)
4266
4149
  } else {
4267
- this.handleSelectRow(params, value)
4150
+ this.handleSelectRow(params, checked)
4268
4151
  this.checkSelectionStatus()
4269
4152
  }
4270
4153
  },
4271
- triggerCheckRowEvent (evnt: any, params: any, value: any) {
4154
+ triggerCheckRowEvent (evnt: any, params: any, checked: any) {
4272
4155
  const { checkboxOpts, afterFullData } = this
4273
4156
  const { checkMethod, trigger } = checkboxOpts
4274
4157
  const { row } = params
@@ -4292,13 +4175,13 @@ const Methods = {
4292
4175
  }
4293
4176
  }
4294
4177
  if (!checkMethod || checkMethod({ row })) {
4295
- this.handleSelectRow(params, value)
4178
+ this.handleSelectRow(params, checked)
4296
4179
  this.checkSelectionStatus()
4297
4180
  this.emitEvent('checkbox-change', Object.assign({
4298
4181
  records: this.getCheckboxRecords(),
4299
4182
  reserves: this.getCheckboxReserveRecords(),
4300
4183
  indeterminates: this.getCheckboxIndeterminateRecords(),
4301
- checked: value
4184
+ checked
4302
4185
  }, params), evnt)
4303
4186
  }
4304
4187
  },
@@ -4306,14 +4189,19 @@ const Methods = {
4306
4189
  * 多选,切换某一行的选中状态
4307
4190
  */
4308
4191
  toggleCheckboxRow (row: any) {
4192
+ const $xeTable = this
4193
+
4309
4194
  const { selectCheckboxMaps, checkboxOpts } = this
4310
4195
  const { checkField } = checkboxOpts
4311
- const value = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid(this, row)]
4312
- this.handleSelectRow({ row }, value, true)
4313
- this.checkSelectionStatus()
4314
- return this.$nextTick()
4196
+ const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
4197
+ $xeTable.handleBatchSelectRows([row], checked, true)
4198
+ $xeTable.checkSelectionStatus()
4199
+ return $xeTable.$nextTick()
4315
4200
  },
4316
- handleCheckedAllCheckboxRow (value: any, isForce: any) {
4201
+ handleCheckedAllCheckboxRow (checked: any, isForce: any) {
4202
+ const $xeTable = this
4203
+ const reactData = $xeTable
4204
+
4317
4205
  const { afterFullData, treeConfig, treeOpts, selectCheckboxMaps, checkboxReserveRowMap, checkboxOpts, afterFullRowMaps } = this
4318
4206
  const { checkField, reserve, checkStrictly, checkMethod } = checkboxOpts
4319
4207
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
@@ -4331,7 +4219,7 @@ const Methods = {
4331
4219
  // 疑惑!
4332
4220
 
4333
4221
  if (checkStrictly) {
4334
- this.isAllSelected = value
4222
+ this.isAllSelected = checked
4335
4223
  } else {
4336
4224
  /**
4337
4225
  * 绑定属性方式(高性能,有污染)
@@ -4340,10 +4228,10 @@ const Methods = {
4340
4228
  if (checkField) {
4341
4229
  const checkValFn = (row: any) => {
4342
4230
  if (isForce || (!checkMethod || checkMethod({ row }))) {
4343
- if (value) {
4231
+ if (checked) {
4344
4232
  selectRowMaps[getRowid(this, row)] = row
4345
4233
  }
4346
- XEUtils.set(row, checkField, value)
4234
+ XEUtils.set(row, checkField, checked)
4347
4235
  }
4348
4236
  if (treeConfig && indeterminateField) {
4349
4237
  XEUtils.set(row, indeterminateField, false)
@@ -4362,7 +4250,7 @@ const Methods = {
4362
4250
  * 无需任何属性,直接绑定
4363
4251
  */
4364
4252
  if (treeConfig) {
4365
- if (value) {
4253
+ if (checked) {
4366
4254
  /**
4367
4255
  * 如果是树勾选
4368
4256
  * 如果方法成立,则添加到临时集合中
@@ -4387,7 +4275,7 @@ const Methods = {
4387
4275
  }
4388
4276
  }
4389
4277
  } else {
4390
- if (value) {
4278
+ if (checked) {
4391
4279
  /**
4392
4280
  * 如果是行勾选
4393
4281
  * 如果存在选中方法且成立或者本身已勾选,则添加到临时集合中
@@ -4423,7 +4311,7 @@ const Methods = {
4423
4311
  }
4424
4312
  }
4425
4313
  if (reserve) {
4426
- if (value) {
4314
+ if (checked) {
4427
4315
  XEUtils.each(selectRowMaps, (row, rowid) => {
4428
4316
  checkboxReserveRowMap[rowid] = row
4429
4317
  })
@@ -4433,6 +4321,9 @@ const Methods = {
4433
4321
  }
4434
4322
  this.selectCheckboxMaps = checkField ? {} : selectRowMaps
4435
4323
  }
4324
+
4325
+ reactData.isAllSelected = checked
4326
+ reactData.isIndeterminate = false
4436
4327
  this.treeIndeterminateMaps = {}
4437
4328
  this.treeIndeterminateRowMaps = {}
4438
4329
  this.checkSelectionStatus()
@@ -4445,75 +4336,164 @@ const Methods = {
4445
4336
  setAllCheckboxRow (value: any) {
4446
4337
  return this.handleCheckedAllCheckboxRow(value, true)
4447
4338
  },
4448
- checkSelectionStatus () {
4449
- const { afterFullData, selectCheckboxMaps, treeIndeterminateMaps, checkboxOpts, treeConfig } = this
4339
+ updateCheckboxStatus () {
4340
+ const $xeTable = this
4341
+ const props = $xeTable
4342
+ const reactData = $xeTable
4343
+ const internalData = $xeTable
4344
+
4345
+ const { treeConfig } = props
4346
+ const { selectCheckboxMaps, treeIndeterminateMaps } = reactData
4347
+ const selectRowMaps = Object.assign({}, selectCheckboxMaps)
4348
+ const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
4349
+ const treeOpts = $xeTable.computeTreeOpts
4350
+ const { transform, mapChildrenField } = treeOpts
4351
+ const childrenField = treeOpts.children || treeOpts.childrenField
4352
+ const checkboxOpts = $xeTable.computeCheckboxOpts
4450
4353
  const { checkField, checkStrictly, checkMethod } = checkboxOpts
4451
- const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
4452
- if (!checkStrictly) {
4453
- const disableRows = []
4454
- const checkRows = []
4455
- let isAllResolve = false
4456
- let isAllSelected = false
4457
- let isIndeterminate = false
4458
- if (checkField) {
4459
- isAllResolve = afterFullData.every(
4354
+ const { afterTreeFullData } = internalData
4355
+ if (checkStrictly) {
4356
+ return
4357
+ }
4358
+ // 树结构
4359
+ if (treeConfig) {
4360
+ const childRowMaps: Record<string, number> = {}
4361
+ const childRowList: any[][] = []
4362
+ XEUtils.eachTree(afterTreeFullData, (row: any) => {
4363
+ const rowid = getRowid($xeTable, row)
4364
+ const childList = row[transform ? mapChildrenField : childrenField]
4365
+ if (childList && childList.length && !childRowMaps[rowid]) {
4366
+ childRowMaps[rowid] = 1
4367
+ childRowList.unshift([row, rowid, childList])
4368
+ }
4369
+ }, { children: transform ? mapChildrenField : childrenField })
4370
+ childRowList.forEach(vals => {
4371
+ const row: string = vals[0]
4372
+ const rowid: string = vals[1]
4373
+ const childList: any[] = vals[2]
4374
+ let sLen = 0 // 已选
4375
+ let hLen = 0 // 半选
4376
+ let vLen = 0 // 有效行
4377
+ childList.forEach(
4460
4378
  checkMethod
4461
- ? (row: any) => {
4462
- if (!checkMethod({ row })) {
4463
- disableRows.push(row)
4464
- return true
4465
- }
4466
- if (XEUtils.get(row, checkField)) {
4467
- checkRows.push(row)
4468
- return true
4379
+ ? (item) => {
4380
+ const childRowid = getRowid($xeTable, item)
4381
+ const isSelect = checkField ? XEUtils.get(item, checkField) : selectRowMaps[childRowid]
4382
+ if (checkMethod({ row: item })) {
4383
+ if (isSelect) {
4384
+ sLen++
4385
+ } else if (halfRowMaps[childRowid]) {
4386
+ hLen++
4387
+ }
4388
+ vLen++
4389
+ } else {
4390
+ if (isSelect) {
4391
+ sLen++
4392
+ } else if (halfRowMaps[childRowid]) {
4393
+ hLen++
4394
+ }
4469
4395
  }
4470
- return false
4471
4396
  }
4472
- : (row: any) => XEUtils.get(row, checkField)
4397
+ : item => {
4398
+ const childRowid = getRowid($xeTable, item)
4399
+ const isSelect = checkField ? XEUtils.get(item, checkField) : selectRowMaps[childRowid]
4400
+ if (isSelect) {
4401
+ sLen++
4402
+ } else if (halfRowMaps[childRowid]) {
4403
+ hLen++
4404
+ }
4405
+ vLen++
4406
+ }
4473
4407
  )
4474
- isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
4475
- if (treeConfig) {
4476
- if (indeterminateField) {
4477
- isIndeterminate = !isAllSelected && afterFullData.some((row: any) => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField) || !!treeIndeterminateMaps[getRowid(this, row)])
4478
- } else {
4479
- isIndeterminate = !isAllSelected && afterFullData.some((row: any) => XEUtils.get(row, checkField) || !!treeIndeterminateMaps[getRowid(this, row)])
4408
+ const isSelected = sLen >= vLen
4409
+ const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
4410
+ if (checkField) {
4411
+ XEUtils.get(row, checkField, isSelected)
4412
+ }
4413
+ if (isSelected) {
4414
+ if (!checkField) {
4415
+ selectRowMaps[rowid] = row
4416
+ }
4417
+ if (halfRowMaps[rowid]) {
4418
+ delete halfRowMaps[rowid]
4480
4419
  }
4481
4420
  } else {
4482
- if (indeterminateField) {
4483
- isIndeterminate = !isAllSelected && afterFullData.some((row: any) => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField))
4421
+ if (!checkField) {
4422
+ if (selectRowMaps[rowid]) {
4423
+ delete selectRowMaps[rowid]
4424
+ }
4425
+ }
4426
+ if (halfSelect) {
4427
+ halfRowMaps[rowid] = row
4484
4428
  } else {
4485
- isIndeterminate = !isAllSelected && afterFullData.some((row: any) => XEUtils.get(row, checkField))
4429
+ if (halfRowMaps[rowid]) {
4430
+ delete halfRowMaps[rowid]
4431
+ }
4486
4432
  }
4487
4433
  }
4488
- } else {
4489
- isAllResolve = afterFullData.every(
4490
- checkMethod
4491
- ? (row: any) => {
4492
- if (!checkMethod({ row })) {
4493
- disableRows.push(row)
4494
- return true
4495
- }
4496
- if (selectCheckboxMaps[getRowid(this, row)]) {
4497
- checkRows.push(row)
4498
- return true
4499
- }
4500
- return false
4501
- }
4502
- : (row: any) => selectCheckboxMaps[getRowid(this, row)]
4503
- )
4504
- isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
4505
- if (treeConfig) {
4506
- isIndeterminate = !isAllSelected && afterFullData.some((row: any) => {
4507
- const itemRid = getRowid(this, row)
4508
- return treeIndeterminateMaps[itemRid] || selectCheckboxMaps[itemRid]
4509
- })
4434
+ })
4435
+ }
4436
+ reactData.selectCheckboxMaps = selectRowMaps
4437
+ reactData.treeIndeterminateMaps = halfRowMaps
4438
+ },
4439
+ updateAllCheckboxStatus () {
4440
+ const $xeTable = this
4441
+ const props = $xeTable
4442
+ const reactData = $xeTable
4443
+ const internalData = $xeTable
4444
+
4445
+ const { treeConfig } = props
4446
+ const { selectCheckboxMaps, treeIndeterminateMaps } = reactData
4447
+ const checkboxOpts = $xeTable.computeCheckboxOpts
4448
+ const { checkField, checkMethod } = checkboxOpts
4449
+ const { afterFullData, afterTreeFullData } = internalData
4450
+
4451
+ let sLen = 0 // 已选
4452
+ let hLen = 0 // 半选
4453
+ let vLen = 0 // 有效行
4454
+
4455
+ const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
4456
+ rootList.forEach(checkMethod
4457
+ ? row => {
4458
+ const childRowid = getRowid($xeTable, row)
4459
+ const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
4460
+ if (checkMethod({ row })) {
4461
+ if (selected) {
4462
+ sLen++
4463
+ } else if (treeIndeterminateMaps[childRowid]) {
4464
+ hLen++
4465
+ }
4466
+ vLen++
4510
4467
  } else {
4511
- isIndeterminate = !isAllSelected && afterFullData.some((row: any) => selectCheckboxMaps[getRowid(this, row)])
4468
+ if (selected) {
4469
+ sLen++
4470
+ } else if (treeIndeterminateMaps[childRowid]) {
4471
+ hLen++
4472
+ }
4512
4473
  }
4513
4474
  }
4514
- this.isAllSelected = isAllSelected
4515
- this.isIndeterminate = isIndeterminate
4516
- }
4475
+ : row => {
4476
+ const childRowid = getRowid($xeTable, row)
4477
+ const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
4478
+ if (selected) {
4479
+ sLen++
4480
+ } else if (treeIndeterminateMaps[childRowid]) {
4481
+ hLen++
4482
+ }
4483
+ vLen++
4484
+ })
4485
+
4486
+ const isSelected = sLen >= vLen
4487
+ const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
4488
+
4489
+ reactData.isAllSelected = isSelected
4490
+ reactData.isIndeterminate = halfSelect
4491
+ },
4492
+ checkSelectionStatus () {
4493
+ const $xeTable = this
4494
+
4495
+ $xeTable.updateCheckboxStatus()
4496
+ $xeTable.updateAllCheckboxStatus()
4517
4497
  },
4518
4498
  // 还原展开、选中等相关状态
4519
4499
  handleReserveStatus () {