@yibozhang/pro-table 0.1.18 → 0.1.19

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.
@@ -694,8 +694,6 @@
694
694
  this._selectedTableRow = null;
695
695
  // 选中的行数据(用于复选框选择)- 保留用于兼容性
696
696
  this._selectedRows = [];
697
- // 使用 Set 存储选中项的 ID,支持跨页选中
698
- this._selectedRowIds = new Set();
699
697
  // 全选状态
700
698
  this._checkedAll = false;
701
699
  // 半选状态(部分选中)
@@ -1388,16 +1386,6 @@
1388
1386
  }
1389
1387
  // 直接设置数据对象的 checked 属性
1390
1388
  data.checked = checked;
1391
- // 同步更新 _selectedRowIds(用于跨页选中)
1392
- var id = this.getRowId(data);
1393
- if (id !== undefined) {
1394
- if (checked) {
1395
- this._selectedRowIds.add(id);
1396
- }
1397
- else {
1398
- this._selectedRowIds.delete(id);
1399
- }
1400
- }
1401
1389
  // 同步更新 _selectedRows(用于兼容性)
1402
1390
  var index = this._selectedRows.findIndex(function (row) { return _this.isSameRow(row, data); });
1403
1391
  if (checked) {
@@ -1447,16 +1435,6 @@
1447
1435
  // 批量设置 checked 属性
1448
1436
  availableRows.forEach(function (row) {
1449
1437
  row.checked = checked;
1450
- // 同步更新 _selectedRowIds(用于跨页选中)
1451
- var id = _this.getRowId(row);
1452
- if (id !== undefined) {
1453
- if (checked) {
1454
- _this._selectedRowIds.add(id);
1455
- }
1456
- else {
1457
- _this._selectedRowIds.delete(id);
1458
- }
1459
- }
1460
1438
  });
1461
1439
  // 同步更新 _selectedRows(用于兼容性)
1462
1440
  if (checked) {
@@ -1483,17 +1461,7 @@
1483
1461
  return;
1484
1462
  }
1485
1463
  // 数据对象的 checked 属性已经通过双向绑定自动更新
1486
- // 这里只需要同步更新 _selectedRowIds 和 _selectedRows
1487
- // 同步更新 _selectedRowIds(用于跨页选中)
1488
- var id = this.getRowId(data);
1489
- if (id !== undefined) {
1490
- if (checked) {
1491
- this._selectedRowIds.add(id);
1492
- }
1493
- else {
1494
- this._selectedRowIds.delete(id);
1495
- }
1496
- }
1464
+ // 这里只需要同步更新 _selectedRows
1497
1465
  // 同步更新 _selectedRows(用于兼容性)
1498
1466
  var index = this._selectedRows.findIndex(function (row) { return _this.isSameRow(row, data); });
1499
1467
  if (checked) {
@@ -1543,8 +1511,6 @@
1543
1511
  row.checked = false;
1544
1512
  });
1545
1513
  }
1546
- // 清空选中集合
1547
- this._selectedRowIds.clear();
1548
1514
  this._selectedRows = [];
1549
1515
  this._checkedAll = false;
1550
1516
  this._indeterminate = false;
@@ -1616,8 +1582,7 @@
1616
1582
  };
1617
1583
  ProTableComponent.prototype.handleQuery = function (afterDelete) {
1618
1584
  return __awaiter(this, void 0, void 0, function () {
1619
- var previousDataSource, result, newDataIds_1, error_4;
1620
- var _this = this;
1585
+ var result, error_4;
1621
1586
  return __generator(this, function (_d) {
1622
1587
  switch (_d.label) {
1623
1588
  case 0:
@@ -1628,7 +1593,6 @@
1628
1593
  this._pageInfo.pageIndex > 1) {
1629
1594
  this._pageInfo.pageIndex = this._pageInfo.pageIndex - 1;
1630
1595
  }
1631
- previousDataSource = afterDelete && this.showCheckbox ? __spread(this.dataSource) : [];
1632
1596
  this._loading = true;
1633
1597
  if (!this.request) return [3 /*break*/, 6];
1634
1598
  _d.label = 1;
@@ -1642,34 +1606,11 @@
1642
1606
  : {})))];
1643
1607
  case 2:
1644
1608
  result = _d.sent();
1645
- // 自动注入 checked 字段,支持跨页选中
1609
+ // 查询后默认不保留跨页选中状态:每次返回的数据均初始化为未选中
1646
1610
  if (this.showCheckbox) {
1647
1611
  this.dataSource = (result.data || []).map(function (item) {
1648
- var id = _this.getRowId(item);
1649
- // 如果数据已有 checked 属性,保留;否则根据 _selectedRowIds 判断
1650
- var checked = item.checked !== undefined
1651
- ? item.checked
1652
- : id !== undefined
1653
- ? _this._selectedRowIds.has(id)
1654
- : false;
1655
- return Object.assign(Object.assign({}, item), { checked: checked });
1612
+ return Object.assign(Object.assign({}, item), { checked: false });
1656
1613
  });
1657
- // 删除后查询:移除被删除项的选中状态
1658
- if (afterDelete && previousDataSource.length > 0) {
1659
- newDataIds_1 = new Set(this.dataSource.map(function (item) { return _this.getRowId(item); }));
1660
- // 遍历之前的数据源,如果不在新数据源中,说明被删除了,需要清除其选中状态
1661
- previousDataSource.forEach(function (oldItem) {
1662
- var oldId = _this.getRowId(oldItem);
1663
- if (oldId !== undefined && !newDataIds_1.has(oldId)) {
1664
- // 被删除的项,从选中集合中移除
1665
- _this._selectedRowIds.delete(oldId);
1666
- // 如果数据对象还在其他地方引用,清除其选中状态
1667
- if (oldItem.checked !== undefined) {
1668
- oldItem.checked = false;
1669
- }
1670
- }
1671
- });
1672
- }
1673
1614
  }
1674
1615
  else {
1675
1616
  this.dataSource = result.data || [];
@@ -1680,9 +1621,9 @@
1680
1621
  this.sortDataSourceInPlace();
1681
1622
  }
1682
1623
  this._pageInfo.total = result.total || 0;
1683
- // 更新全选状态
1624
+ // 取消跨页多选:查询后清空选中状态
1684
1625
  if (this.showCheckbox) {
1685
- this.updateCheckAllStatus();
1626
+ this.clearSelectedRows();
1686
1627
  }
1687
1628
  return [3 /*break*/, 5];
1688
1629
  case 3:
@@ -1735,12 +1676,11 @@
1735
1676
  };
1736
1677
  ProTableComponent.prototype.handleTableRowClick = function (data) {
1737
1678
  this._selectedTableRow = data;
1738
- // 如果开启了复选框,点击行时只选中点击行(如果行未被禁用)
1739
1679
  if (this.showCheckbox && !this.isRowDisabled(data)) {
1740
1680
  // 先清空所有选中行
1741
1681
  this._selectedRows = [];
1742
- // 只选中当前点击的行
1743
- this.toggleRowChecked(data, true);
1682
+ var nextChecked = !this.isRowChecked(data);
1683
+ this.toggleRowChecked(data, nextChecked);
1744
1684
  }
1745
1685
  this.onRowClick.emit(this._selectedTableRow);
1746
1686
  };
@@ -1857,7 +1797,7 @@
1857
1797
  actionBarTpl: [{ type: i0.ContentChild, args: ["actionBar",] }],
1858
1798
  imgActionBarTpl: [{ type: i0.ContentChild, args: ["ImgActionBar",] }],
1859
1799
  allTemplates: [{ type: i0.ContentChildren, args: [i0.TemplateRef,] }],
1860
- onWindowResize: [{ type: i0.HostListener, args: ['window:resize',] }]
1800
+ onWindowResize: [{ type: i0.HostListener, args: ["window:resize",] }]
1861
1801
  };
1862
1802
 
1863
1803
  var PageContainerComponent = /** @class */ (function () {