@nokecy/qc-ui 1.1.11 → 1.1.12
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/array-table/index.js +56 -109
- package/dist/esm/array-table/index.js +57 -110
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -16,9 +16,9 @@ var _arrayAddBtn = _interopRequireDefault(require("./arrayAddBtn"));
|
|
|
16
16
|
var _preview = _interopRequireDefault(require("./preview"));
|
|
17
17
|
var _antd = require("antd");
|
|
18
18
|
var _setting = _interopRequireDefault(require("../ag-grid-plus/setting"));
|
|
19
|
-
var _gridContext = require("../ag-grid-plus/context/gridContext");
|
|
20
19
|
var _columnGroupUtils = require("../ag-grid-plus/setting/columnGroupUtils");
|
|
21
20
|
var _theme = require("../ag-grid-plus/theme");
|
|
21
|
+
var _agGridPlus = require("../ag-grid-plus");
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -77,11 +77,10 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
77
77
|
handleRowDragMove = _useRowDrag.handleRowDragMove;
|
|
78
78
|
|
|
79
79
|
// 直接使用 Context 获取方案管理状态
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
currentSchemes =
|
|
84
|
-
columnSchemes = _ref.columnSchemes;
|
|
80
|
+
var _useGridSchemes = (0, _agGridPlus.useGridSchemes)(),
|
|
81
|
+
columnSchemes = _useGridSchemes.columnSchemes,
|
|
82
|
+
querySchemes = _useGridSchemes.querySchemes,
|
|
83
|
+
currentSchemes = _useGridSchemes.currentSchemes;
|
|
85
84
|
|
|
86
85
|
// 获取当前表格的激活方案
|
|
87
86
|
var currentScheme = (0, _react.useMemo)(function () {
|
|
@@ -95,132 +94,82 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
95
94
|
});
|
|
96
95
|
}, [props.gridKey, currentSchemes, columnSchemes]);
|
|
97
96
|
|
|
98
|
-
// 使用 ref 记录上次应用的方案 ID
|
|
99
|
-
var
|
|
100
|
-
schemeId: null,
|
|
101
|
-
configHash: null
|
|
102
|
-
});
|
|
97
|
+
// 使用 ref 记录上次应用的方案 ID,避免重复应用
|
|
98
|
+
var lastAppliedSchemeIdRef = (0, _react.useRef)(null);
|
|
103
99
|
|
|
104
100
|
/**
|
|
105
|
-
*
|
|
101
|
+
* 方案自动加载
|
|
106
102
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
103
|
+
* 参考 ag-gridPlus 优化方案:
|
|
104
|
+
* 1. 使用 Promise 链确保顺序执行,避免竞态条件
|
|
105
|
+
* 2. 使用双重 RAF 确保渲染完成
|
|
106
|
+
* 3. 完整的错误处理和清理机制
|
|
111
107
|
*/
|
|
112
108
|
(0, _react.useEffect)(function () {
|
|
113
109
|
// 检查必要条件
|
|
114
110
|
if (!props.gridKey || !gridApiState || !currentScheme) return;
|
|
115
111
|
if (!currentScheme.columnConfig || currentScheme.columnConfig.length === 0) return;
|
|
116
112
|
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
width: col.width,
|
|
126
|
-
hide: col.hide,
|
|
127
|
-
pinned: col.pinned
|
|
128
|
-
};
|
|
129
|
-
})
|
|
130
|
-
});
|
|
113
|
+
// 如果是同一个方案,跳过应用(避免重复应用)
|
|
114
|
+
if (currentScheme.id === lastAppliedSchemeIdRef.current) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// 使用 Promise 链确保顺序执行,避免竞态条件
|
|
118
|
+
var cancelled = false;
|
|
119
|
+
Promise.resolve().then(function () {
|
|
120
|
+
if (cancelled || !gridApiState) return;
|
|
131
121
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (currentGridState.length !== currentScheme.columnConfig.length) {
|
|
137
|
-
isGridStateSameAsScheme = false;
|
|
138
|
-
} else {
|
|
139
|
-
// 比较前3列的关键属性
|
|
140
|
-
for (var i = 0; i < Math.min(3, currentGridState.length); i++) {
|
|
141
|
-
var gridCol = currentGridState[i];
|
|
142
|
-
var schemeCol = currentScheme.columnConfig[i];
|
|
143
|
-
if (schemeCol.type !== 'column') continue;
|
|
122
|
+
// 1. 检查是否包含分组配置
|
|
123
|
+
var hasGroups = currentScheme.columnConfig.some(function (item) {
|
|
124
|
+
return item.type === 'group';
|
|
125
|
+
});
|
|
144
126
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
isGridStateSameAsScheme = false;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
127
|
+
// 如果包含分组,先更新 columnDefs
|
|
128
|
+
if (hasGroups) {
|
|
129
|
+
var gridColumnDefs = (0, _columnGroupUtils.flatConfigToGridState)(currentScheme.columnConfig);
|
|
130
|
+
gridApiState.setGridOption('columnDefs', gridColumnDefs);
|
|
152
131
|
}
|
|
153
|
-
}
|
|
154
|
-
// 【关键】跳过应用的条件:
|
|
155
|
-
// 1. Grid 当前状态与方案配置一致(说明已经应用过或刚保存)
|
|
156
|
-
// 2. 方案配置与上次应用的相同(避免重复应用)
|
|
157
|
-
if (isGridStateSameAsScheme || schemeConfigHash === lastAppliedRef.current.configHash) {
|
|
158
|
-
// 更新记录,避免后续误判
|
|
159
|
-
lastAppliedRef.current = {
|
|
160
|
-
schemeId: currentScheme.id,
|
|
161
|
-
configHash: schemeConfigHash
|
|
162
|
-
};
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
132
|
|
|
166
|
-
|
|
167
|
-
var applyColumnStateAndFilter = function applyColumnStateAndFilter() {
|
|
168
|
-
if (!currentScheme || !gridApiState) return;
|
|
133
|
+
// 2. 应用列状态(列顺序、宽度、隐藏、固定等)
|
|
169
134
|
|
|
170
|
-
// 将扁平化的列配置转换为 AG-Grid 列状态
|
|
171
135
|
var columnState = (0, _columnGroupUtils.flatConfigToColumnState)(currentScheme.columnConfig);
|
|
172
|
-
|
|
173
|
-
// 应用列状态(包括列顺序、宽度、隐藏等)
|
|
174
136
|
gridApiState.applyColumnState({
|
|
175
137
|
state: columnState,
|
|
176
|
-
applyOrder: true
|
|
138
|
+
applyOrder: true
|
|
177
139
|
});
|
|
178
|
-
|
|
140
|
+
}).then(function () {
|
|
141
|
+
// 等待 Grid 状态稳定(使用 requestAnimationFrame 而非固定延迟)
|
|
142
|
+
return new Promise(function (resolve) {
|
|
143
|
+
if (cancelled) {
|
|
144
|
+
resolve();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
requestAnimationFrame(function () {
|
|
148
|
+
// 双重 RAF 确保渲染完成
|
|
149
|
+
requestAnimationFrame(function () {
|
|
150
|
+
return resolve();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}).then(function () {
|
|
155
|
+
if (cancelled || !gridApiState) return;
|
|
156
|
+
|
|
157
|
+
// 3. 应用过滤器(在列状态稳定后执行)
|
|
179
158
|
if (currentScheme.filterModel) {
|
|
180
159
|
gridApiState.setFilterModel(currentScheme.filterModel);
|
|
181
160
|
}
|
|
182
161
|
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// 使用 requestAnimationFrame 延迟应用
|
|
191
|
-
var rafId = requestAnimationFrame(function () {
|
|
192
|
-
try {
|
|
193
|
-
// 【关键检测】检查是否包含分组配置
|
|
194
|
-
var hasGroups = currentScheme.columnConfig.some(function (item) {
|
|
195
|
-
return item.type === 'group';
|
|
196
|
-
});
|
|
197
|
-
// 【条件更新】只有在包含分组时才更新 columnDefs
|
|
198
|
-
// 原因:array-table 的列是动态生成的,无分组时不应该覆盖动态列定义
|
|
199
|
-
if (hasGroups) {
|
|
200
|
-
var gridColumnDefs = (0, _columnGroupUtils.flatConfigToGridState)(currentScheme.columnConfig);
|
|
201
|
-
gridApiState.setGridOption('columnDefs', gridColumnDefs);
|
|
202
|
-
|
|
203
|
-
// 等待 columnDefs 更新完成后再应用列状态
|
|
204
|
-
setTimeout(function () {
|
|
205
|
-
try {
|
|
206
|
-
applyColumnStateAndFilter();
|
|
207
|
-
} catch (error) {
|
|
208
|
-
console.error('[ArrayTable] 应用列状态失败:', error);
|
|
209
|
-
}
|
|
210
|
-
}, 100);
|
|
211
|
-
} else {
|
|
212
|
-
// 无分组时,直接应用列状态即可
|
|
213
|
-
|
|
214
|
-
applyColumnStateAndFilter();
|
|
215
|
-
}
|
|
216
|
-
} catch (error) {
|
|
162
|
+
// 记录已应用的方案 ID
|
|
163
|
+
lastAppliedSchemeIdRef.current = currentScheme.id;
|
|
164
|
+
}).catch(function (error) {
|
|
165
|
+
if (!cancelled) {
|
|
217
166
|
console.error('[ArrayTable] 应用方案失败:', error);
|
|
218
167
|
}
|
|
219
168
|
});
|
|
220
169
|
|
|
221
|
-
//
|
|
170
|
+
// 清理函数:取消进行中的操作
|
|
222
171
|
return function () {
|
|
223
|
-
|
|
172
|
+
cancelled = true;
|
|
224
173
|
};
|
|
225
174
|
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id]);
|
|
226
175
|
|
|
@@ -288,8 +237,6 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
288
237
|
params.api.hidePopupMenu();
|
|
289
238
|
apiRef.current = params.api;
|
|
290
239
|
setGridApiState(params.api);
|
|
291
|
-
|
|
292
|
-
// 恢复列状态将由 useEffect 处理(使用方案系统)
|
|
293
240
|
},
|
|
294
241
|
suppressColumnVirtualisation: true,
|
|
295
242
|
gridOptions: {
|
|
@@ -337,8 +284,8 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
337
284
|
' <span data-ref="eSortAsc" class="ag-header-icon ag-sort-ascending-icon"></span>' + ' <span data-ref="eSortDesc" class="ag-header-icon ag-sort-descending-icon"></span>' + ' <span data-ref="eSortNone" class="ag-header-icon ag-sort-none-icon"></span>' + " </div>" + "</div>"
|
|
338
285
|
}
|
|
339
286
|
},
|
|
340
|
-
getRowId: function getRowId(
|
|
341
|
-
var data =
|
|
287
|
+
getRowId: function getRowId(_ref) {
|
|
288
|
+
var data = _ref.data;
|
|
342
289
|
return data._id || data.id;
|
|
343
290
|
}
|
|
344
291
|
// rowDragEntireRow={true}
|
|
@@ -11,7 +11,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
11
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
12
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
import React, { Fragment, useEffect, useRef, useState, useMemo
|
|
14
|
+
import React, { Fragment, useEffect, useRef, useState, useMemo } from "react";
|
|
15
15
|
import { AgGridReact } from "ag-grid-react";
|
|
16
16
|
import { useField, observer, RecursionField } from "@formily/react";
|
|
17
17
|
import { useFieldSchema } from "@formily/react";
|
|
@@ -24,11 +24,11 @@ import ArrayAddBtn from "./arrayAddBtn";
|
|
|
24
24
|
import PreviewArrayTable from "./preview";
|
|
25
25
|
import { Space } from "antd";
|
|
26
26
|
import Setting from "../ag-grid-plus/setting";
|
|
27
|
-
import { GridPlusContext } from "../ag-grid-plus/context/gridContext";
|
|
28
27
|
import { flatConfigToColumnState, flatConfigToGridState } from "../ag-grid-plus/setting/columnGroupUtils";
|
|
29
28
|
|
|
30
29
|
// 导入 AG-Grid v33 主题
|
|
31
30
|
import { agGridTheme } from "../ag-grid-plus/theme";
|
|
31
|
+
import { useGridSchemes } from "../ag-grid-plus";
|
|
32
32
|
|
|
33
33
|
//@ts-ignore
|
|
34
34
|
var ArrayTableInner = observer(function (props) {
|
|
@@ -73,11 +73,10 @@ var ArrayTableInner = observer(function (props) {
|
|
|
73
73
|
handleRowDragMove = _useRowDrag.handleRowDragMove;
|
|
74
74
|
|
|
75
75
|
// 直接使用 Context 获取方案管理状态
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
currentSchemes =
|
|
80
|
-
columnSchemes = _ref.columnSchemes;
|
|
76
|
+
var _useGridSchemes = useGridSchemes(),
|
|
77
|
+
columnSchemes = _useGridSchemes.columnSchemes,
|
|
78
|
+
querySchemes = _useGridSchemes.querySchemes,
|
|
79
|
+
currentSchemes = _useGridSchemes.currentSchemes;
|
|
81
80
|
|
|
82
81
|
// 获取当前表格的激活方案
|
|
83
82
|
var currentScheme = useMemo(function () {
|
|
@@ -91,132 +90,82 @@ var ArrayTableInner = observer(function (props) {
|
|
|
91
90
|
});
|
|
92
91
|
}, [props.gridKey, currentSchemes, columnSchemes]);
|
|
93
92
|
|
|
94
|
-
// 使用 ref 记录上次应用的方案 ID
|
|
95
|
-
var
|
|
96
|
-
schemeId: null,
|
|
97
|
-
configHash: null
|
|
98
|
-
});
|
|
93
|
+
// 使用 ref 记录上次应用的方案 ID,避免重复应用
|
|
94
|
+
var lastAppliedSchemeIdRef = useRef(null);
|
|
99
95
|
|
|
100
96
|
/**
|
|
101
|
-
*
|
|
97
|
+
* 方案自动加载
|
|
102
98
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
99
|
+
* 参考 ag-gridPlus 优化方案:
|
|
100
|
+
* 1. 使用 Promise 链确保顺序执行,避免竞态条件
|
|
101
|
+
* 2. 使用双重 RAF 确保渲染完成
|
|
102
|
+
* 3. 完整的错误处理和清理机制
|
|
107
103
|
*/
|
|
108
104
|
useEffect(function () {
|
|
109
105
|
// 检查必要条件
|
|
110
106
|
if (!props.gridKey || !gridApiState || !currentScheme) return;
|
|
111
107
|
if (!currentScheme.columnConfig || currentScheme.columnConfig.length === 0) return;
|
|
112
108
|
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
width: col.width,
|
|
122
|
-
hide: col.hide,
|
|
123
|
-
pinned: col.pinned
|
|
124
|
-
};
|
|
125
|
-
})
|
|
126
|
-
});
|
|
109
|
+
// 如果是同一个方案,跳过应用(避免重复应用)
|
|
110
|
+
if (currentScheme.id === lastAppliedSchemeIdRef.current) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// 使用 Promise 链确保顺序执行,避免竞态条件
|
|
114
|
+
var cancelled = false;
|
|
115
|
+
Promise.resolve().then(function () {
|
|
116
|
+
if (cancelled || !gridApiState) return;
|
|
127
117
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
|
118
|
+
// 1. 检查是否包含分组配置
|
|
119
|
+
var hasGroups = currentScheme.columnConfig.some(function (item) {
|
|
120
|
+
return item.type === 'group';
|
|
121
|
+
});
|
|
140
122
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
isGridStateSameAsScheme = false;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
123
|
+
// 如果包含分组,先更新 columnDefs
|
|
124
|
+
if (hasGroups) {
|
|
125
|
+
var gridColumnDefs = flatConfigToGridState(currentScheme.columnConfig);
|
|
126
|
+
gridApiState.setGridOption('columnDefs', gridColumnDefs);
|
|
148
127
|
}
|
|
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
|
-
};
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
128
|
|
|
162
|
-
|
|
163
|
-
var applyColumnStateAndFilter = function applyColumnStateAndFilter() {
|
|
164
|
-
if (!currentScheme || !gridApiState) return;
|
|
129
|
+
// 2. 应用列状态(列顺序、宽度、隐藏、固定等)
|
|
165
130
|
|
|
166
|
-
// 将扁平化的列配置转换为 AG-Grid 列状态
|
|
167
131
|
var columnState = flatConfigToColumnState(currentScheme.columnConfig);
|
|
168
|
-
|
|
169
|
-
// 应用列状态(包括列顺序、宽度、隐藏等)
|
|
170
132
|
gridApiState.applyColumnState({
|
|
171
133
|
state: columnState,
|
|
172
|
-
applyOrder: true
|
|
134
|
+
applyOrder: true
|
|
173
135
|
});
|
|
174
|
-
|
|
136
|
+
}).then(function () {
|
|
137
|
+
// 等待 Grid 状态稳定(使用 requestAnimationFrame 而非固定延迟)
|
|
138
|
+
return new Promise(function (resolve) {
|
|
139
|
+
if (cancelled) {
|
|
140
|
+
resolve();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
requestAnimationFrame(function () {
|
|
144
|
+
// 双重 RAF 确保渲染完成
|
|
145
|
+
requestAnimationFrame(function () {
|
|
146
|
+
return resolve();
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}).then(function () {
|
|
151
|
+
if (cancelled || !gridApiState) return;
|
|
152
|
+
|
|
153
|
+
// 3. 应用过滤器(在列状态稳定后执行)
|
|
175
154
|
if (currentScheme.filterModel) {
|
|
176
155
|
gridApiState.setFilterModel(currentScheme.filterModel);
|
|
177
156
|
}
|
|
178
157
|
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
// 使用 requestAnimationFrame 延迟应用
|
|
187
|
-
var rafId = requestAnimationFrame(function () {
|
|
188
|
-
try {
|
|
189
|
-
// 【关键检测】检查是否包含分组配置
|
|
190
|
-
var hasGroups = currentScheme.columnConfig.some(function (item) {
|
|
191
|
-
return item.type === 'group';
|
|
192
|
-
});
|
|
193
|
-
// 【条件更新】只有在包含分组时才更新 columnDefs
|
|
194
|
-
// 原因:array-table 的列是动态生成的,无分组时不应该覆盖动态列定义
|
|
195
|
-
if (hasGroups) {
|
|
196
|
-
var gridColumnDefs = flatConfigToGridState(currentScheme.columnConfig);
|
|
197
|
-
gridApiState.setGridOption('columnDefs', gridColumnDefs);
|
|
198
|
-
|
|
199
|
-
// 等待 columnDefs 更新完成后再应用列状态
|
|
200
|
-
setTimeout(function () {
|
|
201
|
-
try {
|
|
202
|
-
applyColumnStateAndFilter();
|
|
203
|
-
} catch (error) {
|
|
204
|
-
console.error('[ArrayTable] 应用列状态失败:', error);
|
|
205
|
-
}
|
|
206
|
-
}, 100);
|
|
207
|
-
} else {
|
|
208
|
-
// 无分组时,直接应用列状态即可
|
|
209
|
-
|
|
210
|
-
applyColumnStateAndFilter();
|
|
211
|
-
}
|
|
212
|
-
} catch (error) {
|
|
158
|
+
// 记录已应用的方案 ID
|
|
159
|
+
lastAppliedSchemeIdRef.current = currentScheme.id;
|
|
160
|
+
}).catch(function (error) {
|
|
161
|
+
if (!cancelled) {
|
|
213
162
|
console.error('[ArrayTable] 应用方案失败:', error);
|
|
214
163
|
}
|
|
215
164
|
});
|
|
216
165
|
|
|
217
|
-
//
|
|
166
|
+
// 清理函数:取消进行中的操作
|
|
218
167
|
return function () {
|
|
219
|
-
|
|
168
|
+
cancelled = true;
|
|
220
169
|
};
|
|
221
170
|
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id]);
|
|
222
171
|
|
|
@@ -284,8 +233,6 @@ var ArrayTableInner = observer(function (props) {
|
|
|
284
233
|
params.api.hidePopupMenu();
|
|
285
234
|
apiRef.current = params.api;
|
|
286
235
|
setGridApiState(params.api);
|
|
287
|
-
|
|
288
|
-
// 恢复列状态将由 useEffect 处理(使用方案系统)
|
|
289
236
|
},
|
|
290
237
|
suppressColumnVirtualisation: true,
|
|
291
238
|
gridOptions: {
|
|
@@ -333,8 +280,8 @@ var ArrayTableInner = observer(function (props) {
|
|
|
333
280
|
' <span data-ref="eSortAsc" class="ag-header-icon ag-sort-ascending-icon"></span>' + ' <span data-ref="eSortDesc" class="ag-header-icon ag-sort-descending-icon"></span>' + ' <span data-ref="eSortNone" class="ag-header-icon ag-sort-none-icon"></span>' + " </div>" + "</div>"
|
|
334
281
|
}
|
|
335
282
|
},
|
|
336
|
-
getRowId: function getRowId(
|
|
337
|
-
var data =
|
|
283
|
+
getRowId: function getRowId(_ref) {
|
|
284
|
+
var data = _ref.data;
|
|
338
285
|
return data._id || data.id;
|
|
339
286
|
}
|
|
340
287
|
// rowDragEntireRow={true}
|