vxe-table 3.9.9 → 3.9.10

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.
@@ -338,7 +338,6 @@ const Methods = {
338
338
  const { scrollXLoad, scrollYLoad } = this
339
339
  return this.handleTableData(true).then(() => {
340
340
  this.updateFooter()
341
- this.checkSelectionStatus()
342
341
  if (scrollXLoad || scrollYLoad) {
343
342
  if (scrollXLoad) {
344
343
  this.updateScrollXSpace()
@@ -3352,7 +3351,8 @@ const Methods = {
3352
3351
  if (rows && !XEUtils.isArray(rows)) {
3353
3352
  rows = [rows]
3354
3353
  }
3355
- rows.forEach((row: any) => this.handleSelectRow({ row }, !!value, isForce))
3354
+ this.handleBatchSelectRows(rows, !!value, isForce)
3355
+ this.checkSelectionStatus()
3356
3356
  return this.$nextTick()
3357
3357
  },
3358
3358
  /**
@@ -3361,6 +3361,9 @@ const Methods = {
3361
3361
  * @param {Boolean} value 是否选中
3362
3362
  */
3363
3363
  setCheckboxRow (rows: any, value: any) {
3364
+ if (rows && !XEUtils.isArray(rows)) {
3365
+ rows = [rows]
3366
+ }
3364
3367
  return this.handleCheckedCheckboxRow(rows, value, true)
3365
3368
  },
3366
3369
  isCheckedByCheckboxRow (row: any) {
@@ -3375,6 +3378,56 @@ const Methods = {
3375
3378
  const { treeIndeterminateMaps } = this
3376
3379
  return !!treeIndeterminateMaps[getRowid(this, row)] && !this.isCheckedByCheckboxRow(row)
3377
3380
  },
3381
+ /**
3382
+ * 多行
3383
+ * 多选,行选中事件
3384
+ * value 选中true 不选false 半选-1
3385
+ */
3386
+ handleBatchSelectRows (rows: any[], value: any, isForce: any) {
3387
+ const $xeTable = this
3388
+ const { treeConfig } = $xeTable
3389
+
3390
+ const { selectCheckboxMaps, checkboxOpts } = this
3391
+ const { checkField, checkStrictly, checkMethod } = checkboxOpts
3392
+ if (checkField) {
3393
+ if (treeConfig && !checkStrictly) {
3394
+ rows.forEach(row => {
3395
+ this.handleSelectRow({ row }, value, isForce)
3396
+ })
3397
+ } else {
3398
+ rows.forEach(row => {
3399
+ if (isForce || (!checkMethod || checkMethod({ row }))) {
3400
+ XEUtils.set(row, checkField, value)
3401
+ this.handleCheckboxReserveRow(row, value)
3402
+ }
3403
+ })
3404
+ }
3405
+ } else {
3406
+ if (treeConfig && !checkStrictly) {
3407
+ rows.forEach(row => {
3408
+ this.handleSelectRow({ row }, value, isForce)
3409
+ })
3410
+ } else {
3411
+ const selectRowMaps = Object.assign({}, selectCheckboxMaps)
3412
+ rows.forEach(row => {
3413
+ const rowid = getRowid($xeTable, row)
3414
+ if (isForce || (!checkMethod || checkMethod({ row }))) {
3415
+ if (value) {
3416
+ if (!selectRowMaps[rowid]) {
3417
+ selectRowMaps[rowid] = row
3418
+ }
3419
+ } else {
3420
+ if (selectRowMaps[rowid]) {
3421
+ delete selectRowMaps[rowid]
3422
+ }
3423
+ }
3424
+ this.handleCheckboxReserveRow(row, value)
3425
+ }
3426
+ })
3427
+ this.selectCheckboxMaps = selectRowMaps
3428
+ }
3429
+ }
3430
+ },
3378
3431
  /**
3379
3432
  * 多选,行选中事件
3380
3433
  * value 选中true 不选false 半选-1
@@ -3536,7 +3589,6 @@ const Methods = {
3536
3589
  }
3537
3590
  }
3538
3591
  this.selectCheckboxMaps = selectRowMaps
3539
- this.checkSelectionStatus()
3540
3592
  },
3541
3593
  handleToggleCheckRowEvent (evnt: any, params: any) {
3542
3594
  const { selectCheckboxMaps, checkboxOpts } = this
@@ -3555,6 +3607,7 @@ const Methods = {
3555
3607
  this.triggerCheckRowEvent(evnt, params, value)
3556
3608
  } else {
3557
3609
  this.handleSelectRow(params, value)
3610
+ this.checkSelectionStatus()
3558
3611
  }
3559
3612
  },
3560
3613
  triggerCheckRowEvent (evnt: any, params: any, value: any) {
@@ -3582,6 +3635,7 @@ const Methods = {
3582
3635
  }
3583
3636
  if (!checkMethod || checkMethod({ row })) {
3584
3637
  this.handleSelectRow(params, value)
3638
+ this.checkSelectionStatus()
3585
3639
  this.emitEvent('checkbox-change', Object.assign({
3586
3640
  records: this.getCheckboxRecords(),
3587
3641
  reserves: this.getCheckboxReserveRecords(),
@@ -3598,6 +3652,7 @@ const Methods = {
3598
3652
  const { checkField } = checkboxOpts
3599
3653
  const value = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid(this, row)]
3600
3654
  this.handleSelectRow({ row }, value, true)
3655
+ this.checkSelectionStatus()
3601
3656
  return this.$nextTick()
3602
3657
  },
3603
3658
  handleCheckedAllCheckboxRow (value: any, isForce: any) {