@nokecy/qc-ui 1.1.2 → 1.1.3

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.
@@ -225,7 +225,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
225
225
  * 将扁平化配置转换回 Grid State 并应用到 AG-Grid
226
226
  */
227
227
  var handleSaveColumns = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
228
- var values, flatConfig, configToSave, gridColumnDefs, columnState;
228
+ var values, flatConfig, configToSave, invalidColumns, gridColumnDefs, columnState;
229
229
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
230
230
  while (1) switch (_context2.prev = _context2.next) {
231
231
  case 0:
@@ -243,16 +243,28 @@ var ColumnSetting = function ColumnSetting(_ref) {
243
243
  _antd.message.info('检测到旧版本配置,已自动迁移到新格式');
244
244
  }
245
245
 
246
+ // 【修复】验证数据完整性,过滤掉无效的列配置
247
+ invalidColumns = configToSave.filter(function (item) {
248
+ return item.type === 'column' && !item.field;
249
+ });
250
+ if (invalidColumns.length > 0) {
251
+ _antd.message.warning("\u68C0\u6D4B\u5230 ".concat(invalidColumns.length, " \u4E2A\u5217\u7F3A\u5C11 field \u5B57\u6BB5\uFF0C\u5DF2\u81EA\u52A8\u8FC7\u6EE4"));
252
+ console.warn('[ColumnSetting] 无效的列配置:', invalidColumns);
253
+ configToSave = configToSave.filter(function (item) {
254
+ return item.type === 'group' || item.type === 'column' && item.field;
255
+ });
256
+ }
257
+
246
258
  // 【修复】转换为 AG-Grid 的列定义,传入原始列定义以保留自定义属性
247
259
  gridColumnDefs = (0, _columnGroupUtils.flatConfigToGridState)(configToSave, originalColumnDefs); // 【关键修复】先更新 columnDefs(处理分组结构变化)
248
260
  gridApi.setGridOption('columnDefs', gridColumnDefs);
249
261
 
250
262
  // 等待 columnDefs 更新完成
251
- _context2.next = 10;
263
+ _context2.next = 12;
252
264
  return new Promise(function (resolve) {
253
265
  return setTimeout(resolve, 100);
254
266
  });
255
- case 10:
267
+ case 12:
256
268
  // 【修复】然后应用列状态(宽度、隐藏、顺序等)
257
269
  columnState = (0, _columnGroupUtils.flatConfigToColumnState)(configToSave);
258
270
  gridApi.applyColumnState({
@@ -344,7 +356,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
344
356
 
345
357
  // message.success 已经在上面的逻辑中处理了
346
358
  onClose();
347
- case 15:
359
+ case 17:
348
360
  case "end":
349
361
  return _context2.stop();
350
362
  }
@@ -322,6 +322,9 @@ function flatConfigToColumnState(flatConfig) {
322
322
  return flatConfig.filter(function (item) {
323
323
  return item.type === 'column';
324
324
  }) // 只处理列节点,分组不在 columnState 中
325
+ .filter(function (item) {
326
+ return item.field;
327
+ }) // 【修复】过滤掉没有 field 的列,防止 colId 为 undefined
325
328
  .sort(function (a, b) {
326
329
  return a.order - b.order;
327
330
  }) // 按 order 字段排序
@@ -42,7 +42,6 @@ var DraggableModal = function DraggableModal(props) {
42
42
  bounds = _useState4[0],
43
43
  setBounds = _useState4[1];
44
44
  var draggleRef = (0, _react.useRef)(null);
45
- var modalContentRef = (0, _react.useRef)(null);
46
45
 
47
46
  // 调整大小相关状态
48
47
  var _useState5 = (0, _react.useState)(false),
@@ -216,7 +216,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
216
216
  * 将扁平化配置转换回 Grid State 并应用到 AG-Grid
217
217
  */
218
218
  var handleSaveColumns = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
219
- var values, flatConfig, configToSave, gridColumnDefs, columnState;
219
+ var values, flatConfig, configToSave, invalidColumns, gridColumnDefs, columnState;
220
220
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
221
221
  while (1) switch (_context2.prev = _context2.next) {
222
222
  case 0:
@@ -234,16 +234,28 @@ var ColumnSetting = function ColumnSetting(_ref) {
234
234
  message.info('检测到旧版本配置,已自动迁移到新格式');
235
235
  }
236
236
 
237
+ // 【修复】验证数据完整性,过滤掉无效的列配置
238
+ invalidColumns = configToSave.filter(function (item) {
239
+ return item.type === 'column' && !item.field;
240
+ });
241
+ if (invalidColumns.length > 0) {
242
+ message.warning("\u68C0\u6D4B\u5230 ".concat(invalidColumns.length, " \u4E2A\u5217\u7F3A\u5C11 field \u5B57\u6BB5\uFF0C\u5DF2\u81EA\u52A8\u8FC7\u6EE4"));
243
+ console.warn('[ColumnSetting] 无效的列配置:', invalidColumns);
244
+ configToSave = configToSave.filter(function (item) {
245
+ return item.type === 'group' || item.type === 'column' && item.field;
246
+ });
247
+ }
248
+
237
249
  // 【修复】转换为 AG-Grid 的列定义,传入原始列定义以保留自定义属性
238
250
  gridColumnDefs = flatConfigToGridState(configToSave, originalColumnDefs); // 【关键修复】先更新 columnDefs(处理分组结构变化)
239
251
  gridApi.setGridOption('columnDefs', gridColumnDefs);
240
252
 
241
253
  // 等待 columnDefs 更新完成
242
- _context2.next = 10;
254
+ _context2.next = 12;
243
255
  return new Promise(function (resolve) {
244
256
  return setTimeout(resolve, 100);
245
257
  });
246
- case 10:
258
+ case 12:
247
259
  // 【修复】然后应用列状态(宽度、隐藏、顺序等)
248
260
  columnState = flatConfigToColumnState(configToSave);
249
261
  gridApi.applyColumnState({
@@ -335,7 +347,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
335
347
 
336
348
  // message.success 已经在上面的逻辑中处理了
337
349
  onClose();
338
- case 15:
350
+ case 17:
339
351
  case "end":
340
352
  return _context2.stop();
341
353
  }
@@ -306,6 +306,9 @@ export function flatConfigToColumnState(flatConfig) {
306
306
  return flatConfig.filter(function (item) {
307
307
  return item.type === 'column';
308
308
  }) // 只处理列节点,分组不在 columnState 中
309
+ .filter(function (item) {
310
+ return item.field;
311
+ }) // 【修复】过滤掉没有 field 的列,防止 colId 为 undefined
309
312
  .sort(function (a, b) {
310
313
  return a.order - b.order;
311
314
  }) // 按 order 字段排序
@@ -33,7 +33,6 @@ var DraggableModal = function DraggableModal(props) {
33
33
  bounds = _useState4[0],
34
34
  setBounds = _useState4[1];
35
35
  var draggleRef = useRef(null);
36
- var modalContentRef = useRef(null);
37
36
 
38
37
  // 调整大小相关状态
39
38
  var _useState5 = useState(false),