@nokecy/qc-ui 1.1.30 → 1.1.31

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.
@@ -760,6 +760,54 @@ function AgGridPlus(props) {
760
760
  _logger.logger.info('数据请求成功', {
761
761
  rowCount: rowCount
762
762
  });
763
+
764
+ // 【新增】数据刷新后同步更新选中行数据
765
+ // 场景:用户执行操作(如审核)后刷新列表,选中行的数据已变化
766
+ // 需要从新数据中找到对应的行,同步更新业务层的选中状态
767
+ // 支持两种回调方式:onSelectedRowsChange 和 onSelectionChanged
768
+ if (apiRef.current) {
769
+ // 使用 requestAnimationFrame 确保 AG-Grid 数据更新完成
770
+ requestAnimationFrame(function () {
771
+ if (!apiRef.current) return;
772
+ var selectedNodes = apiRef.current.getSelectedNodes();
773
+ if (selectedNodes.length > 0) {
774
+ // 获取行ID的方法
775
+ var getRowIdMethod = props.getRowId || function (params) {
776
+ return generateUniqueRowId(params.data);
777
+ };
778
+
779
+ // 获取当前选中的行ID列表
780
+ var selectedIds = selectedNodes.filter(function (node) {
781
+ return node.data;
782
+ }).map(function (node) {
783
+ return getRowIdMethod({
784
+ data: node.data,
785
+ level: node.level || 0,
786
+ api: apiRef.current,
787
+ context: null
788
+ });
789
+ });
790
+
791
+ // 【关键】重新选中行以触发 onSelectionChanged
792
+ // 先取消所有选中,再重新选中,这样可以触发选中变化事件
793
+ // 并且新选中的行数据是刷新后的最新数据
794
+ apiRef.current.deselectAll();
795
+
796
+ // 从新数据中找到对应的行并重新选中
797
+ selectedIds.forEach(function (id) {
798
+ var _apiRef$current3;
799
+ var rowNode = (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 ? void 0 : _apiRef$current3.getRowNode(id);
800
+ if (rowNode) {
801
+ rowNode.setSelected(true, false, 'api');
802
+ }
803
+ });
804
+ _logger.logger.debug('数据刷新后重新选中行', {
805
+ selectedIds: selectedIds,
806
+ reselectedCount: selectedIds.length
807
+ });
808
+ }
809
+ });
810
+ }
763
811
  }).catch(function (error) {
764
812
  setLoading(false);
765
813
 
@@ -1024,8 +1072,8 @@ function AgGridPlus(props) {
1024
1072
  });
1025
1073
  }
1026
1074
  if (!allColDefs || displayedData.length === 0) {
1027
- var _apiRef$current3;
1028
- (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 || _apiRef$current3.setGridOption('pinnedBottomRowData', undefined);
1075
+ var _apiRef$current4;
1076
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
1029
1077
  return;
1030
1078
  }
1031
1079
  var calcColFields = allColDefs.filter(function (col) {
@@ -1039,9 +1087,9 @@ function AgGridPlus(props) {
1039
1087
  };
1040
1088
  });
1041
1089
  if (calcColFields.length > 0) {
1042
- var _apiRef$current4;
1090
+ var _apiRef$current5;
1043
1091
  var calculatedValues = calculatefun(calcColFields, displayedData);
1044
- (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', calculatedValues);
1092
+ (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
1045
1093
  }
1046
1094
  }, [allColDefs, calculatefun]);
1047
1095
  var onFilterChanged = function onFilterChanged(event) {
@@ -1417,8 +1465,8 @@ function AgGridPlus(props) {
1417
1465
  },
1418
1466
  onDragStopped: function onDragStopped(e) {
1419
1467
  if (apiRef.current) {
1420
- var _apiRef$current5;
1421
- var _columnState = (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.getColumnState();
1468
+ var _apiRef$current6;
1469
+ var _columnState = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.getColumnState();
1422
1470
  setColumnState(_columnState);
1423
1471
 
1424
1472
  // onColumnStateChanged && onColumnStateChanged(columnState)
@@ -752,6 +752,54 @@ function AgGridPlus(props) {
752
752
  logger.info('数据请求成功', {
753
753
  rowCount: rowCount
754
754
  });
755
+
756
+ // 【新增】数据刷新后同步更新选中行数据
757
+ // 场景:用户执行操作(如审核)后刷新列表,选中行的数据已变化
758
+ // 需要从新数据中找到对应的行,同步更新业务层的选中状态
759
+ // 支持两种回调方式:onSelectedRowsChange 和 onSelectionChanged
760
+ if (apiRef.current) {
761
+ // 使用 requestAnimationFrame 确保 AG-Grid 数据更新完成
762
+ requestAnimationFrame(function () {
763
+ if (!apiRef.current) return;
764
+ var selectedNodes = apiRef.current.getSelectedNodes();
765
+ if (selectedNodes.length > 0) {
766
+ // 获取行ID的方法
767
+ var getRowIdMethod = props.getRowId || function (params) {
768
+ return generateUniqueRowId(params.data);
769
+ };
770
+
771
+ // 获取当前选中的行ID列表
772
+ var selectedIds = selectedNodes.filter(function (node) {
773
+ return node.data;
774
+ }).map(function (node) {
775
+ return getRowIdMethod({
776
+ data: node.data,
777
+ level: node.level || 0,
778
+ api: apiRef.current,
779
+ context: null
780
+ });
781
+ });
782
+
783
+ // 【关键】重新选中行以触发 onSelectionChanged
784
+ // 先取消所有选中,再重新选中,这样可以触发选中变化事件
785
+ // 并且新选中的行数据是刷新后的最新数据
786
+ apiRef.current.deselectAll();
787
+
788
+ // 从新数据中找到对应的行并重新选中
789
+ selectedIds.forEach(function (id) {
790
+ var _apiRef$current3;
791
+ var rowNode = (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 ? void 0 : _apiRef$current3.getRowNode(id);
792
+ if (rowNode) {
793
+ rowNode.setSelected(true, false, 'api');
794
+ }
795
+ });
796
+ logger.debug('数据刷新后重新选中行', {
797
+ selectedIds: selectedIds,
798
+ reselectedCount: selectedIds.length
799
+ });
800
+ }
801
+ });
802
+ }
755
803
  }).catch(function (error) {
756
804
  setLoading(false);
757
805
 
@@ -1016,8 +1064,8 @@ function AgGridPlus(props) {
1016
1064
  });
1017
1065
  }
1018
1066
  if (!allColDefs || displayedData.length === 0) {
1019
- var _apiRef$current3;
1020
- (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 || _apiRef$current3.setGridOption('pinnedBottomRowData', undefined);
1067
+ var _apiRef$current4;
1068
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
1021
1069
  return;
1022
1070
  }
1023
1071
  var calcColFields = allColDefs.filter(function (col) {
@@ -1031,9 +1079,9 @@ function AgGridPlus(props) {
1031
1079
  };
1032
1080
  });
1033
1081
  if (calcColFields.length > 0) {
1034
- var _apiRef$current4;
1082
+ var _apiRef$current5;
1035
1083
  var calculatedValues = calculatefun(calcColFields, displayedData);
1036
- (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', calculatedValues);
1084
+ (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
1037
1085
  }
1038
1086
  }, [allColDefs, calculatefun]);
1039
1087
  var onFilterChanged = function onFilterChanged(event) {
@@ -1409,8 +1457,8 @@ function AgGridPlus(props) {
1409
1457
  },
1410
1458
  onDragStopped: function onDragStopped(e) {
1411
1459
  if (apiRef.current) {
1412
- var _apiRef$current5;
1413
- var _columnState = (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.getColumnState();
1460
+ var _apiRef$current6;
1461
+ var _columnState = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.getColumnState();
1414
1462
  setColumnState(_columnState);
1415
1463
 
1416
1464
  // onColumnStateChanged && onColumnStateChanged(columnState)