@nokecy/qc-ui 1.1.13 → 1.1.17
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/setting/ColumnSetting.js +85 -43
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +12 -14
- package/dist/cjs/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +8 -8
- package/dist/cjs/array-table/index.js +41 -13
- package/dist/cjs/array-table/utils.js +25 -9
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +85 -43
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +12 -14
- package/dist/esm/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +8 -8
- package/dist/esm/array-table/index.js +41 -13
- package/dist/esm/array-table/utils.js +24 -8
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -297,10 +297,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
297
297
|
|
|
298
298
|
/**
|
|
299
299
|
* 保存列配置
|
|
300
|
-
*
|
|
300
|
+
* 优化逻辑:先保存配置到存储,再直接应用到 Grid,不依赖 handleLoadScheme
|
|
301
301
|
*/
|
|
302
302
|
var handleSaveColumns = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
303
|
-
var values, flatConfig, configToSave, invalidColumns, filterModel,
|
|
303
|
+
var values, flatConfig, configToSave, invalidColumns, filterModel, savedScheme, defaultScheme, hasGroups, gridColumnDefs, columnState;
|
|
304
304
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
305
305
|
while (1) switch (_context2.prev = _context2.next) {
|
|
306
306
|
case 0:
|
|
@@ -335,16 +335,17 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
335
335
|
_context2.next = 17;
|
|
336
336
|
break;
|
|
337
337
|
}
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
// 如果有激活的方案,更新该方案
|
|
339
|
+
savedScheme = _objectSpread(_objectSpread({}, currentScheme), {}, {
|
|
340
340
|
columnConfig: configToSave,
|
|
341
|
-
filterModel: filterModel
|
|
342
|
-
updatedAt
|
|
343
|
-
})
|
|
344
|
-
|
|
345
|
-
|
|
341
|
+
filterModel: filterModel
|
|
342
|
+
// updatedAt 由存储适配器自动生成
|
|
343
|
+
});
|
|
344
|
+
_context2.next = 14;
|
|
345
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, savedScheme);
|
|
346
|
+
case 14:
|
|
346
347
|
_antd.message.success('列配置已保存到方案');
|
|
347
|
-
_context2.next =
|
|
348
|
+
_context2.next = 29;
|
|
348
349
|
break;
|
|
349
350
|
case 17:
|
|
350
351
|
// 如果没有激活的方案,自动创建或更新默认方案
|
|
@@ -355,52 +356,96 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
355
356
|
_context2.next = 25;
|
|
356
357
|
break;
|
|
357
358
|
}
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
// 更新默认方案
|
|
360
|
+
savedScheme = _objectSpread(_objectSpread({}, defaultScheme), {}, {
|
|
360
361
|
columnConfig: configToSave,
|
|
361
|
-
filterModel: filterModel
|
|
362
|
-
updatedAt
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
|
|
362
|
+
filterModel: filterModel
|
|
363
|
+
// updatedAt 由存储适配器自动生成
|
|
364
|
+
});
|
|
365
|
+
_context2.next = 22;
|
|
366
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, savedScheme);
|
|
367
|
+
case 22:
|
|
366
368
|
_antd.message.success('列配置已保存到默认方案');
|
|
367
|
-
_context2.next =
|
|
369
|
+
_context2.next = 29;
|
|
368
370
|
break;
|
|
369
371
|
case 25:
|
|
370
372
|
// 创建新的默认方案
|
|
371
|
-
|
|
373
|
+
savedScheme = {
|
|
372
374
|
id: (0, _uuid.v4)(),
|
|
373
375
|
name: '默认配置',
|
|
374
376
|
description: '自动创建的默认列配置',
|
|
375
377
|
columnConfig: configToSave,
|
|
376
378
|
filterModel: filterModel,
|
|
377
379
|
isDefault: true,
|
|
378
|
-
isSystem: false
|
|
379
|
-
createdAt
|
|
380
|
-
updatedAt: Date.now()
|
|
380
|
+
isSystem: false
|
|
381
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
381
382
|
};
|
|
382
383
|
_context2.next = 28;
|
|
383
|
-
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey,
|
|
384
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, savedScheme);
|
|
384
385
|
case 28:
|
|
385
|
-
schemeIdToLoad = newScheme.id;
|
|
386
386
|
_antd.message.success('已创建并保存到默认方案');
|
|
387
|
-
case
|
|
388
|
-
_context2.next =
|
|
389
|
-
return
|
|
390
|
-
|
|
391
|
-
|
|
387
|
+
case 29:
|
|
388
|
+
_context2.next = 31;
|
|
389
|
+
return new Promise(function (resolve) {
|
|
390
|
+
return setTimeout(resolve, 100);
|
|
391
|
+
});
|
|
392
|
+
case 31:
|
|
393
|
+
// 1. 检查是否包含分组配置
|
|
394
|
+
hasGroups = savedScheme.columnConfig.some(function (item) {
|
|
395
|
+
return item.type === 'group';
|
|
396
|
+
}); // 如果包含分组,先更新 columnDefs
|
|
397
|
+
if (!hasGroups) {
|
|
398
|
+
_context2.next = 37;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
gridColumnDefs = (0, _columnGroupUtils.flatConfigToGridState)(savedScheme.columnConfig, originalColumnDefs);
|
|
402
|
+
gridApi.setGridOption('columnDefs', gridColumnDefs);
|
|
403
|
+
|
|
404
|
+
// 等待 columnDefs 更新完成
|
|
405
|
+
_context2.next = 37;
|
|
406
|
+
return new Promise(function (resolve) {
|
|
407
|
+
return setTimeout(resolve, 100);
|
|
408
|
+
});
|
|
409
|
+
case 37:
|
|
410
|
+
columnState = (0, _columnGroupUtils.flatConfigToColumnState)(savedScheme.columnConfig);
|
|
411
|
+
gridApi.applyColumnState({
|
|
412
|
+
state: columnState,
|
|
413
|
+
applyOrder: true
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
// 3. 应用过滤器
|
|
417
|
+
if (savedScheme.filterModel) {
|
|
418
|
+
gridApi.setFilterModel(savedScheme.filterModel);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// 4. 设置为当前方案(如果不是当前方案)
|
|
422
|
+
if (!(!currentScheme || savedScheme.id !== currentScheme.id)) {
|
|
423
|
+
_context2.next = 43;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
_context2.next = 43;
|
|
427
|
+
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, savedScheme.id);
|
|
428
|
+
case 43:
|
|
429
|
+
_context2.next = 45;
|
|
430
|
+
return new Promise(function (resolve) {
|
|
431
|
+
return setTimeout(resolve, 50);
|
|
432
|
+
});
|
|
433
|
+
case 45:
|
|
434
|
+
// 5. 关闭弹窗
|
|
435
|
+
onClose();
|
|
436
|
+
_context2.next = 52;
|
|
392
437
|
break;
|
|
393
|
-
case
|
|
394
|
-
_context2.prev =
|
|
438
|
+
case 48:
|
|
439
|
+
_context2.prev = 48;
|
|
395
440
|
_context2.t0 = _context2["catch"](8);
|
|
396
441
|
console.error('保存列配置到方案失败:', _context2.t0);
|
|
397
442
|
_antd.message.error('保存列配置失败');
|
|
398
|
-
case
|
|
443
|
+
case 52:
|
|
399
444
|
case "end":
|
|
400
445
|
return _context2.stop();
|
|
401
446
|
}
|
|
402
|
-
}, _callee2, null, [[8,
|
|
403
|
-
})), [form, gridApi, saveColumnScheme, setCurrentColumnScheme, currentScheme, schemes, gridKey,
|
|
447
|
+
}, _callee2, null, [[8, 48]]);
|
|
448
|
+
})), [form, gridApi, saveColumnScheme, setCurrentColumnScheme, currentScheme, schemes, gridKey, originalColumnDefs, onClose]);
|
|
404
449
|
|
|
405
450
|
// 保存为新方案
|
|
406
451
|
var handleSaveScheme = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
@@ -461,9 +506,8 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
461
506
|
columnConfig: columnConfigToSave,
|
|
462
507
|
filterModel: filterModel,
|
|
463
508
|
isDefault: false,
|
|
464
|
-
isSystem: false
|
|
465
|
-
createdAt
|
|
466
|
-
updatedAt: Date.now()
|
|
509
|
+
isSystem: false
|
|
510
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
467
511
|
};
|
|
468
512
|
_context3.next = 23;
|
|
469
513
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, newScheme);
|
|
@@ -519,8 +563,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
519
563
|
}
|
|
520
564
|
_context4.next = 11;
|
|
521
565
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, s), {}, {
|
|
522
|
-
isDefault: false
|
|
523
|
-
updatedAt: Date.now()
|
|
566
|
+
isDefault: false
|
|
524
567
|
}));
|
|
525
568
|
case 11:
|
|
526
569
|
_context4.next = 6;
|
|
@@ -539,8 +582,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
539
582
|
case 21:
|
|
540
583
|
_context4.next = 23;
|
|
541
584
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, scheme), {}, {
|
|
542
|
-
isDefault: true
|
|
543
|
-
updatedAt: Date.now()
|
|
585
|
+
isDefault: true
|
|
544
586
|
}));
|
|
545
587
|
case 23:
|
|
546
588
|
_antd.message.success('已设置为默认方案');
|
|
@@ -633,8 +675,8 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
633
675
|
_context6.next = 7;
|
|
634
676
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, scheme), {}, {
|
|
635
677
|
name: editingName.trim(),
|
|
636
|
-
description: editingDescription.trim() || undefined
|
|
637
|
-
updatedAt
|
|
678
|
+
description: editingDescription.trim() || undefined
|
|
679
|
+
// updatedAt 由存储适配器自动生成
|
|
638
680
|
}));
|
|
639
681
|
case 7:
|
|
640
682
|
_antd.message.success('更新成功');
|
|
@@ -213,8 +213,8 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
213
213
|
}
|
|
214
214
|
_context.next = 7;
|
|
215
215
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, currentScheme), {}, {
|
|
216
|
-
queryConfig: queryConfig
|
|
217
|
-
updatedAt
|
|
216
|
+
queryConfig: queryConfig
|
|
217
|
+
// updatedAt 由存储适配器自动生成
|
|
218
218
|
}));
|
|
219
219
|
case 7:
|
|
220
220
|
_antd.message.success('已应用新配置');
|
|
@@ -228,9 +228,8 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
228
228
|
description: '自动创建的默认查询方案',
|
|
229
229
|
queryConfig: queryConfig,
|
|
230
230
|
isDefault: true,
|
|
231
|
-
isSystem: false
|
|
232
|
-
createdAt
|
|
233
|
-
updatedAt: Date.now()
|
|
231
|
+
isSystem: false
|
|
232
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
234
233
|
};
|
|
235
234
|
_context.next = 13;
|
|
236
235
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, newScheme);
|
|
@@ -287,9 +286,8 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
287
286
|
description: '',
|
|
288
287
|
queryConfig: queryConfig,
|
|
289
288
|
isDefault: false,
|
|
290
|
-
isSystem: false
|
|
291
|
-
createdAt
|
|
292
|
-
updatedAt: Date.now()
|
|
289
|
+
isSystem: false
|
|
290
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
293
291
|
};
|
|
294
292
|
_context2.next = 10;
|
|
295
293
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, newScheme);
|
|
@@ -345,8 +343,8 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
345
343
|
_context3.next = 8;
|
|
346
344
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, scheme), {}, {
|
|
347
345
|
name: editingName.trim(),
|
|
348
|
-
description: editingDescription.trim() || undefined
|
|
349
|
-
updatedAt
|
|
346
|
+
description: editingDescription.trim() || undefined
|
|
347
|
+
// updatedAt 由存储适配器自动生成
|
|
350
348
|
}));
|
|
351
349
|
case 8:
|
|
352
350
|
_antd.message.success('更新成功');
|
|
@@ -429,8 +427,8 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
429
427
|
}
|
|
430
428
|
_context5.next = 9;
|
|
431
429
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, _scheme), {}, {
|
|
432
|
-
isDefault: false
|
|
433
|
-
updatedAt
|
|
430
|
+
isDefault: false
|
|
431
|
+
// updatedAt 由存储适配器自动生成
|
|
434
432
|
}));
|
|
435
433
|
case 9:
|
|
436
434
|
_context5.next = 4;
|
|
@@ -457,8 +455,8 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
457
455
|
}
|
|
458
456
|
_context5.next = 23;
|
|
459
457
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, scheme), {}, {
|
|
460
|
-
isDefault: true
|
|
461
|
-
updatedAt
|
|
458
|
+
isDefault: true
|
|
459
|
+
// updatedAt 由存储适配器自动生成
|
|
462
460
|
}));
|
|
463
461
|
case 23:
|
|
464
462
|
_antd.message.success("\u5DF2\u5C06\"".concat(schemeName, "\"\u8BBE\u4E3A\u9ED8\u8BA4\u65B9\u6848"));
|
|
@@ -33,10 +33,10 @@ export interface QueryScheme {
|
|
|
33
33
|
isDefault: boolean;
|
|
34
34
|
/** 是否为系统方案(不可删除) */
|
|
35
35
|
isSystem: boolean;
|
|
36
|
-
/**
|
|
37
|
-
createdAt
|
|
38
|
-
/**
|
|
39
|
-
updatedAt
|
|
36
|
+
/** 创建时间戳(由存储适配器自动生成) */
|
|
37
|
+
createdAt?: number;
|
|
38
|
+
/** 最后更新时间戳(由存储适配器自动生成) */
|
|
39
|
+
updatedAt?: number;
|
|
40
40
|
/** 创建用户ID(可选) */
|
|
41
41
|
createdBy?: string;
|
|
42
42
|
}
|
|
@@ -59,10 +59,10 @@ export interface ColumnScheme {
|
|
|
59
59
|
isDefault: boolean;
|
|
60
60
|
/** 是否为系统方案(不可删除) */
|
|
61
61
|
isSystem: boolean;
|
|
62
|
-
/**
|
|
63
|
-
createdAt
|
|
64
|
-
/**
|
|
65
|
-
updatedAt
|
|
62
|
+
/** 创建时间戳(由存储适配器自动生成) */
|
|
63
|
+
createdAt?: number;
|
|
64
|
+
/** 最后更新时间戳(由存储适配器自动生成) */
|
|
65
|
+
updatedAt?: number;
|
|
66
66
|
/** 创建用户ID(可选) */
|
|
67
67
|
createdBy?: string;
|
|
68
68
|
}
|
|
@@ -56,10 +56,26 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
56
56
|
gridApiState = _useState4[0],
|
|
57
57
|
setGridApiState = _useState4[1];
|
|
58
58
|
var dataSource = Array.isArray(field.value) ? field.value.slice() : [];
|
|
59
|
-
var sources = (0, _utils.useArrayTableSources)();
|
|
60
|
-
var actions = (0, _utils.useArrayTableActions)();
|
|
61
|
-
var columns = (0, _utils.useArrayTableColumns)(dataSource, field, sources);
|
|
62
59
|
var schema = (0, _react2.useFieldSchema)();
|
|
60
|
+
|
|
61
|
+
// 获取 sources(每次渲染都会重新计算,返回新的数组引用)
|
|
62
|
+
var rawSources = (0, _utils.useArrayTableSources)();
|
|
63
|
+
var actions = (0, _utils.useArrayTableActions)();
|
|
64
|
+
|
|
65
|
+
// 【关键修复】使用 useMemo 基于内容稳定 sources 引用
|
|
66
|
+
// 通过 JSON.stringify 比较内容,只有内容真正变化时才返回新引用
|
|
67
|
+
var sourcesKey = (0, _react.useMemo)(function () {
|
|
68
|
+
return JSON.stringify(rawSources.map(function (s) {
|
|
69
|
+
return {
|
|
70
|
+
name: s.name,
|
|
71
|
+
display: s.display
|
|
72
|
+
// 只提取稳定的标识信息
|
|
73
|
+
};
|
|
74
|
+
}));
|
|
75
|
+
}, [rawSources]);
|
|
76
|
+
var sources = (0, _react.useMemo)(function () {
|
|
77
|
+
return rawSources;
|
|
78
|
+
}, [sourcesKey]);
|
|
63
79
|
//@ts-ignore
|
|
64
80
|
var onAdd = props.onAdd,
|
|
65
81
|
onCopy = props.onCopy,
|
|
@@ -97,9 +113,25 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
97
113
|
// 使用 ref 记录上次应用的方案状态,避免重复应用
|
|
98
114
|
var lastAppliedSchemeRef = (0, _react.useRef)({
|
|
99
115
|
id: null,
|
|
100
|
-
updatedAt:
|
|
116
|
+
updatedAt: undefined
|
|
101
117
|
});
|
|
102
118
|
|
|
119
|
+
/**
|
|
120
|
+
* 【关键优化】使用 useMemo 稳定 columnDefs 引用
|
|
121
|
+
* 只在基础列定义(sources)变化时更新,避免数据变化导致列重置
|
|
122
|
+
* 列的状态(宽度、顺序、隐藏等)由方案通过 applyColumnState 控制,不需要通过 columnDefs 传递
|
|
123
|
+
*/
|
|
124
|
+
var stableColumnDefs = (0, _react.useMemo)(function () {
|
|
125
|
+
// 只依赖 sources,不依赖 dataSource 和 field.value
|
|
126
|
+
var cols = (0, _utils.useArrayTableColumns)([], field, sources);
|
|
127
|
+
//@ts-ignore
|
|
128
|
+
if (cols.length > 0 && props.onRowDrag) {
|
|
129
|
+
//@ts-ignore
|
|
130
|
+
cols[0].rowDrag = true;
|
|
131
|
+
}
|
|
132
|
+
return cols;
|
|
133
|
+
}, [sources, props.onRowDrag]); // 移除 field 依赖,避免数据变化时重新计算
|
|
134
|
+
|
|
103
135
|
/**
|
|
104
136
|
* 方案自动加载
|
|
105
137
|
*
|
|
@@ -182,12 +214,6 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
182
214
|
cancelled = true;
|
|
183
215
|
};
|
|
184
216
|
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.updatedAt]);
|
|
185
|
-
|
|
186
|
-
//@ts-ignore
|
|
187
|
-
if (columns.length > 0) {
|
|
188
|
-
//@ts-ignore
|
|
189
|
-
columns[0].rowDrag = props.onRowDrag ? true : false;
|
|
190
|
-
}
|
|
191
217
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
192
218
|
ref: ref,
|
|
193
219
|
style: {
|
|
@@ -234,7 +260,7 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
234
260
|
gridKey: props.gridKey,
|
|
235
261
|
gridApi: apiRef.current,
|
|
236
262
|
gridApiState: gridApiState,
|
|
237
|
-
allColDefs:
|
|
263
|
+
allColDefs: stableColumnDefs,
|
|
238
264
|
showQueryScheme: false
|
|
239
265
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
240
266
|
style: {
|
|
@@ -256,7 +282,9 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
256
282
|
suppressCopySingleCellRanges: true,
|
|
257
283
|
enterNavigatesVertically: true,
|
|
258
284
|
enterNavigatesVerticallyAfterEdit: true,
|
|
259
|
-
columnHoverHighlight: true
|
|
285
|
+
columnHoverHighlight: true,
|
|
286
|
+
// 【关键修复】保持用户设置的列顺序
|
|
287
|
+
maintainColumnOrder: true
|
|
260
288
|
},
|
|
261
289
|
onCellKeyDown: handleCellKeyDown,
|
|
262
290
|
onCellClicked: function onCellClicked(event) {
|
|
@@ -313,7 +341,7 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
313
341
|
,
|
|
314
342
|
rowHeight: 38,
|
|
315
343
|
pagination: false,
|
|
316
|
-
columnDefs:
|
|
344
|
+
columnDefs: stableColumnDefs,
|
|
317
345
|
rowData: dataSource
|
|
318
346
|
})), sources.map(function (column, key) {
|
|
319
347
|
//专门用来承接对Column的状态管理
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -8,13 +9,15 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
9
|
var _react2 = require("@formily/react");
|
|
9
10
|
var _shared = require("@formily/shared");
|
|
10
11
|
var _arrayBase = _interopRequireDefault(require("./arrayBase"));
|
|
12
|
+
var _excluded = ["pinned", "width", "hide", "sort", "sortIndex"];
|
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
21
|
var isColumnComponent = exports.isColumnComponent = function isColumnComponent(schema) {
|
|
19
22
|
var _schema$xComponent;
|
|
20
23
|
return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : _schema$xComponent.indexOf('Column')) > -1;
|
|
@@ -106,12 +109,16 @@ var useArrayTableActions = exports.useArrayTableActions = function useArrayTable
|
|
|
106
109
|
return schema.properties ? parseSources(schema.properties['actions'] || {}) : [];
|
|
107
110
|
};
|
|
108
111
|
var AgField = function AgField(_ref) {
|
|
112
|
+
var _ref2, _node$rowIndex;
|
|
109
113
|
var value = _ref.value,
|
|
110
114
|
record = _ref.data,
|
|
111
115
|
dataSource = _ref.dataSource,
|
|
112
116
|
schema = _ref.schema,
|
|
113
|
-
field = _ref.field
|
|
114
|
-
|
|
117
|
+
field = _ref.field,
|
|
118
|
+
node = _ref.node;
|
|
119
|
+
// 【修复】优先使用 AG-Grid 的 node.rowIndex,避免依赖 dataSource
|
|
120
|
+
// 这样即使 columnDefs 中的 dataSource 是空数组,也能正确获取索引
|
|
121
|
+
var index = (_ref2 = (_node$rowIndex = node === null || node === void 0 ? void 0 : node.rowIndex) !== null && _node$rowIndex !== void 0 ? _node$rowIndex : dataSource === null || dataSource === void 0 ? void 0 : dataSource.indexOf(record)) !== null && _ref2 !== void 0 ? _ref2 : -1;
|
|
115
122
|
var children =
|
|
116
123
|
/*#__PURE__*/
|
|
117
124
|
//@ts-ignore
|
|
@@ -131,14 +138,23 @@ var AgField = function AgField(_ref) {
|
|
|
131
138
|
return children;
|
|
132
139
|
};
|
|
133
140
|
var useArrayTableColumns = exports.useArrayTableColumns = function useArrayTableColumns(dataSource, field, sources) {
|
|
134
|
-
return sources.reduce(function (buf,
|
|
135
|
-
var name =
|
|
136
|
-
columnProps =
|
|
137
|
-
schema =
|
|
138
|
-
display =
|
|
141
|
+
return sources.reduce(function (buf, _ref3, key) {
|
|
142
|
+
var name = _ref3.name,
|
|
143
|
+
columnProps = _ref3.columnProps,
|
|
144
|
+
schema = _ref3.schema,
|
|
145
|
+
display = _ref3.display;
|
|
139
146
|
if (display && display !== 'visible') return buf;
|
|
140
147
|
if (!isColumnComponent(schema)) return buf;
|
|
141
|
-
|
|
148
|
+
|
|
149
|
+
// 【关键修复】移除可能干扰用户列状态的属性
|
|
150
|
+
// 这些属性应该由用户通过列配置(applyColumnState)控制,而不是从 columnDefs 继承
|
|
151
|
+
var pinned = columnProps.pinned,
|
|
152
|
+
width = columnProps.width,
|
|
153
|
+
hide = columnProps.hide,
|
|
154
|
+
sort = columnProps.sort,
|
|
155
|
+
sortIndex = columnProps.sortIndex,
|
|
156
|
+
safeColumnProps = _objectWithoutProperties(columnProps, _excluded);
|
|
157
|
+
return buf.concat(_objectSpread(_objectSpread({}, safeColumnProps), {}, {
|
|
142
158
|
//@ts-ignore
|
|
143
159
|
headerName: columnProps.headerName || columnProps.title,
|
|
144
160
|
field: name,
|