@nokecy/qc-ui 1.1.29 → 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.
|
@@ -748,10 +748,9 @@ function AgGridPlus(props) {
|
|
|
748
748
|
var rowData = response.data;
|
|
749
749
|
var rowCount = response.total;
|
|
750
750
|
setRowData(rowData);
|
|
751
|
-
//
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
});
|
|
751
|
+
// 【修复】强制重绘所有行,确保 React cellRenderer 重新渲染
|
|
752
|
+
// refreshCells 对 React 渲染的 cellRenderer 无效,需要使用 redrawRows
|
|
753
|
+
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 || _apiRef$current2.redrawRows();
|
|
755
754
|
setPagination(function (prev) {
|
|
756
755
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
757
756
|
total: rowCount
|
|
@@ -761,6 +760,54 @@ function AgGridPlus(props) {
|
|
|
761
760
|
_logger.logger.info('数据请求成功', {
|
|
762
761
|
rowCount: rowCount
|
|
763
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
|
+
}
|
|
764
811
|
}).catch(function (error) {
|
|
765
812
|
setLoading(false);
|
|
766
813
|
|
|
@@ -1025,8 +1072,8 @@ function AgGridPlus(props) {
|
|
|
1025
1072
|
});
|
|
1026
1073
|
}
|
|
1027
1074
|
if (!allColDefs || displayedData.length === 0) {
|
|
1028
|
-
var _apiRef$
|
|
1029
|
-
(_apiRef$
|
|
1075
|
+
var _apiRef$current4;
|
|
1076
|
+
(_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
|
|
1030
1077
|
return;
|
|
1031
1078
|
}
|
|
1032
1079
|
var calcColFields = allColDefs.filter(function (col) {
|
|
@@ -1040,9 +1087,9 @@ function AgGridPlus(props) {
|
|
|
1040
1087
|
};
|
|
1041
1088
|
});
|
|
1042
1089
|
if (calcColFields.length > 0) {
|
|
1043
|
-
var _apiRef$
|
|
1090
|
+
var _apiRef$current5;
|
|
1044
1091
|
var calculatedValues = calculatefun(calcColFields, displayedData);
|
|
1045
|
-
(_apiRef$
|
|
1092
|
+
(_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
|
|
1046
1093
|
}
|
|
1047
1094
|
}, [allColDefs, calculatefun]);
|
|
1048
1095
|
var onFilterChanged = function onFilterChanged(event) {
|
|
@@ -1418,8 +1465,8 @@ function AgGridPlus(props) {
|
|
|
1418
1465
|
},
|
|
1419
1466
|
onDragStopped: function onDragStopped(e) {
|
|
1420
1467
|
if (apiRef.current) {
|
|
1421
|
-
var _apiRef$
|
|
1422
|
-
var _columnState = (_apiRef$
|
|
1468
|
+
var _apiRef$current6;
|
|
1469
|
+
var _columnState = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.getColumnState();
|
|
1423
1470
|
setColumnState(_columnState);
|
|
1424
1471
|
|
|
1425
1472
|
// onColumnStateChanged && onColumnStateChanged(columnState)
|
|
@@ -740,10 +740,9 @@ function AgGridPlus(props) {
|
|
|
740
740
|
var rowData = response.data;
|
|
741
741
|
var rowCount = response.total;
|
|
742
742
|
setRowData(rowData);
|
|
743
|
-
//
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
});
|
|
743
|
+
// 【修复】强制重绘所有行,确保 React cellRenderer 重新渲染
|
|
744
|
+
// refreshCells 对 React 渲染的 cellRenderer 无效,需要使用 redrawRows
|
|
745
|
+
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 || _apiRef$current2.redrawRows();
|
|
747
746
|
setPagination(function (prev) {
|
|
748
747
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
749
748
|
total: rowCount
|
|
@@ -753,6 +752,54 @@ function AgGridPlus(props) {
|
|
|
753
752
|
logger.info('数据请求成功', {
|
|
754
753
|
rowCount: rowCount
|
|
755
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
|
+
}
|
|
756
803
|
}).catch(function (error) {
|
|
757
804
|
setLoading(false);
|
|
758
805
|
|
|
@@ -1017,8 +1064,8 @@ function AgGridPlus(props) {
|
|
|
1017
1064
|
});
|
|
1018
1065
|
}
|
|
1019
1066
|
if (!allColDefs || displayedData.length === 0) {
|
|
1020
|
-
var _apiRef$
|
|
1021
|
-
(_apiRef$
|
|
1067
|
+
var _apiRef$current4;
|
|
1068
|
+
(_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
|
|
1022
1069
|
return;
|
|
1023
1070
|
}
|
|
1024
1071
|
var calcColFields = allColDefs.filter(function (col) {
|
|
@@ -1032,9 +1079,9 @@ function AgGridPlus(props) {
|
|
|
1032
1079
|
};
|
|
1033
1080
|
});
|
|
1034
1081
|
if (calcColFields.length > 0) {
|
|
1035
|
-
var _apiRef$
|
|
1082
|
+
var _apiRef$current5;
|
|
1036
1083
|
var calculatedValues = calculatefun(calcColFields, displayedData);
|
|
1037
|
-
(_apiRef$
|
|
1084
|
+
(_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
|
|
1038
1085
|
}
|
|
1039
1086
|
}, [allColDefs, calculatefun]);
|
|
1040
1087
|
var onFilterChanged = function onFilterChanged(event) {
|
|
@@ -1410,8 +1457,8 @@ function AgGridPlus(props) {
|
|
|
1410
1457
|
},
|
|
1411
1458
|
onDragStopped: function onDragStopped(e) {
|
|
1412
1459
|
if (apiRef.current) {
|
|
1413
|
-
var _apiRef$
|
|
1414
|
-
var _columnState = (_apiRef$
|
|
1460
|
+
var _apiRef$current6;
|
|
1461
|
+
var _columnState = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.getColumnState();
|
|
1415
1462
|
setColumnState(_columnState);
|
|
1416
1463
|
|
|
1417
1464
|
// onColumnStateChanged && onColumnStateChanged(columnState)
|