@nokecy/qc-ui 1.1.8 → 1.1.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.
- package/dist/cjs/ag-grid-plus/ag-gridPlus.js +5 -6
- package/dist/cjs/ag-grid-plus/context/useSchemeManager.js +26 -5
- package/dist/cjs/ag-grid-plus/interface.d.ts +15 -6
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +194 -184
- package/dist/cjs/array-table/index.js +46 -10
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +5 -6
- package/dist/esm/ag-grid-plus/context/useSchemeManager.js +26 -5
- package/dist/esm/ag-grid-plus/interface.d.ts +15 -6
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +194 -184
- package/dist/esm/array-table/index.js +46 -10
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -103,23 +103,59 @@ var ArrayTableInner = observer(function (props) {
|
|
|
103
103
|
* 监听 currentScheme 和 gridApiState 的变化,当方案和 Grid API 都准备好时,
|
|
104
104
|
* 自动应用方案中保存的列状态(列顺序、宽度、隐藏等)
|
|
105
105
|
*
|
|
106
|
-
*
|
|
106
|
+
* 关键优化:比较 Grid 当前状态和方案配置,只在真正不一致时才应用
|
|
107
107
|
*/
|
|
108
108
|
useEffect(function () {
|
|
109
|
-
var _currentScheme$column;
|
|
110
109
|
// 检查必要条件
|
|
111
110
|
if (!props.gridKey || !gridApiState || !currentScheme) return;
|
|
112
111
|
if (!currentScheme.columnConfig || currentScheme.columnConfig.length === 0) return;
|
|
113
112
|
|
|
114
|
-
//
|
|
115
|
-
var
|
|
113
|
+
// 【修复】计算方案配置的哈希
|
|
114
|
+
var schemeConfigHash = JSON.stringify({
|
|
116
115
|
id: currentScheme.id,
|
|
117
116
|
columnCount: currentScheme.columnConfig.length,
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
// 使用前3列的完整配置作为哈希的一部分(包含顺序、宽度、隐藏等)
|
|
118
|
+
firstCols: currentScheme.columnConfig.slice(0, 3).map(function (col) {
|
|
119
|
+
return {
|
|
120
|
+
field: col.field,
|
|
121
|
+
width: col.width,
|
|
122
|
+
hide: col.hide,
|
|
123
|
+
pinned: col.pinned
|
|
124
|
+
};
|
|
125
|
+
})
|
|
120
126
|
});
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
|
|
128
|
+
// 【关键修复】比较方案配置和 Grid 当前状态
|
|
129
|
+
// 检查前3列的关键属性是否一致(跳过字段名差异)
|
|
130
|
+
var currentGridState = gridApiState.getColumnState();
|
|
131
|
+
var isGridStateSameAsScheme = true;
|
|
132
|
+
if (currentGridState.length !== currentScheme.columnConfig.length) {
|
|
133
|
+
isGridStateSameAsScheme = false;
|
|
134
|
+
} else {
|
|
135
|
+
// 比较前3列的关键属性
|
|
136
|
+
for (var i = 0; i < Math.min(3, currentGridState.length); i++) {
|
|
137
|
+
var gridCol = currentGridState[i];
|
|
138
|
+
var schemeCol = currentScheme.columnConfig[i];
|
|
139
|
+
if (schemeCol.type !== 'column') continue;
|
|
140
|
+
|
|
141
|
+
// 比较关键属性(field/colId, width, hide, pinned)
|
|
142
|
+
if (gridCol.colId !== schemeCol.field || Math.abs((gridCol.width || 0) - (schemeCol.width || 0)) > 5 ||
|
|
143
|
+
// 允许5px误差
|
|
144
|
+
gridCol.hide !== schemeCol.hide || gridCol.pinned !== schemeCol.pinned) {
|
|
145
|
+
isGridStateSameAsScheme = false;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// 【关键】跳过应用的条件:
|
|
151
|
+
// 1. Grid 当前状态与方案配置一致(说明已经应用过或刚保存)
|
|
152
|
+
// 2. 方案配置与上次应用的相同(避免重复应用)
|
|
153
|
+
if (isGridStateSameAsScheme || schemeConfigHash === lastAppliedRef.current.configHash) {
|
|
154
|
+
// 更新记录,避免后续误判
|
|
155
|
+
lastAppliedRef.current = {
|
|
156
|
+
schemeId: currentScheme.id,
|
|
157
|
+
configHash: schemeConfigHash
|
|
158
|
+
};
|
|
123
159
|
return;
|
|
124
160
|
}
|
|
125
161
|
|
|
@@ -143,7 +179,7 @@ var ArrayTableInner = observer(function (props) {
|
|
|
143
179
|
// 记录本次应用的配置哈希
|
|
144
180
|
lastAppliedRef.current = {
|
|
145
181
|
schemeId: currentScheme.id,
|
|
146
|
-
configHash:
|
|
182
|
+
configHash: schemeConfigHash
|
|
147
183
|
};
|
|
148
184
|
};
|
|
149
185
|
|
|
@@ -182,7 +218,7 @@ var ArrayTableInner = observer(function (props) {
|
|
|
182
218
|
return function () {
|
|
183
219
|
cancelAnimationFrame(rafId);
|
|
184
220
|
};
|
|
185
|
-
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id
|
|
221
|
+
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id]);
|
|
186
222
|
|
|
187
223
|
//@ts-ignore
|
|
188
224
|
if (columns.length > 0) {
|