@nokecy/qc-ui 1.0.88 → 1.0.89
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/_utils/processColumnGroups.js +3 -1
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +43 -14
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +3 -1
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +12 -16
- package/dist/esm/ag-grid-plus/_utils/processColumnGroups.js +3 -1
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +43 -14
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +3 -1
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +12 -16
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -43,8 +43,10 @@ var processColumnGroups = function processColumnGroups(columns) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// 检查是否是新格式(FlatColumnItem)
|
|
46
|
+
// 注意:不能用 col.type 判断,因为 AG-Grid 列定义也有 type 字段(如 type: 'dateTimeColumn')
|
|
47
|
+
// FlatColumnItem 的特征是:有 id, parentId, level, order 等字段,且 type 的值是 'group' 或 'column'
|
|
46
48
|
var isNewFormat = columns.some(function (col) {
|
|
47
|
-
return col.
|
|
49
|
+
return col.id !== undefined && col.level !== undefined && col.order !== undefined && (col.type === 'group' || col.type === 'column');
|
|
48
50
|
});
|
|
49
51
|
if (isNewFormat) {
|
|
50
52
|
// 新格式:使用 flatConfigToGridState 转换
|
|
@@ -10,10 +10,13 @@ var _uuid = require("uuid");
|
|
|
10
10
|
var _localStorageAdapter = require("../storage/localStorageAdapter");
|
|
11
11
|
var _validator = require("../utils/validator");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
+
var _excluded = ["activate"];
|
|
13
14
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
15
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
16
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
17
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
17
20
|
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; }
|
|
18
21
|
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; }
|
|
19
22
|
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; }
|
|
@@ -336,7 +339,7 @@ function useColumnSchemes(config) {
|
|
|
336
339
|
*/
|
|
337
340
|
var createScheme = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
338
341
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(name, columnConfig, options) {
|
|
339
|
-
var nameValidation, uniqueName, newScheme, updatedSchemes;
|
|
342
|
+
var nameValidation, uniqueName, _ref6, activate, schemeOptions, newScheme, updatedSchemes;
|
|
340
343
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
341
344
|
while (1) switch (_context5.prev = _context5.next) {
|
|
342
345
|
case 0:
|
|
@@ -355,14 +358,15 @@ function useColumnSchemes(config) {
|
|
|
355
358
|
throw new Error("\u65B9\u6848\u6570\u91CF\u5DF2\u8FBE\u4E0A\u9650\uFF08".concat(_constants.MAX_SCHEMES_PER_GRID, "\u4E2A\uFF09\uFF0C\u8BF7\u5220\u9664\u4E00\u4E9B\u65B9\u6848\u540E\u518D\u8BD5"));
|
|
356
359
|
case 5:
|
|
357
360
|
// 处理重名情况
|
|
358
|
-
uniqueName = (0, _validator.checkDuplicateName)(name, schemes) ? (0, _validator.generateUniqueName)(name, schemes) : name;
|
|
361
|
+
uniqueName = (0, _validator.checkDuplicateName)(name, schemes) ? (0, _validator.generateUniqueName)(name, schemes) : name; // 提取 activate 选项
|
|
362
|
+
_ref6 = options || {}, activate = _ref6.activate, schemeOptions = _objectWithoutProperties(_ref6, _excluded);
|
|
359
363
|
newScheme = _objectSpread({
|
|
360
364
|
id: (0, _uuid.v4)(),
|
|
361
365
|
name: uniqueName,
|
|
362
366
|
createdAt: Date.now(),
|
|
363
367
|
updatedAt: Date.now(),
|
|
364
368
|
columnConfig: columnConfig
|
|
365
|
-
},
|
|
369
|
+
}, schemeOptions); // 如果设置为默认方案,取消其他方案的默认标记
|
|
366
370
|
updatedSchemes = schemes;
|
|
367
371
|
if (newScheme.isDefault) {
|
|
368
372
|
updatedSchemes = schemes.map(function (s) {
|
|
@@ -372,27 +376,52 @@ function useColumnSchemes(config) {
|
|
|
372
376
|
});
|
|
373
377
|
}
|
|
374
378
|
updatedSchemes = [].concat(_toConsumableArray(updatedSchemes), [newScheme]);
|
|
375
|
-
_context5.next =
|
|
379
|
+
_context5.next = 13;
|
|
376
380
|
return saveSchemesToStorage(updatedSchemes);
|
|
377
|
-
case
|
|
381
|
+
case 13:
|
|
382
|
+
if (!activate) {
|
|
383
|
+
_context5.next = 26;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
setCurrentScheme(newScheme);
|
|
387
|
+
setIsDirty(false);
|
|
388
|
+
|
|
389
|
+
// 保存当前方案ID
|
|
390
|
+
if (!storageAdapter.saveCurrentSchemeId) {
|
|
391
|
+
_context5.next = 25;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
_context5.prev = 17;
|
|
395
|
+
_context5.next = 20;
|
|
396
|
+
return storageAdapter.saveCurrentSchemeId(gridId, newScheme.id);
|
|
397
|
+
case 20:
|
|
398
|
+
_context5.next = 25;
|
|
399
|
+
break;
|
|
400
|
+
case 22:
|
|
401
|
+
_context5.prev = 22;
|
|
402
|
+
_context5.t0 = _context5["catch"](17);
|
|
403
|
+
console.error('[useColumnSchemes] 保存当前方案ID失败:', _context5.t0);
|
|
404
|
+
case 25:
|
|
405
|
+
onSchemeChange === null || onSchemeChange === void 0 || onSchemeChange(newScheme);
|
|
406
|
+
case 26:
|
|
378
407
|
onSchemeSave === null || onSchemeSave === void 0 || onSchemeSave(newScheme);
|
|
379
408
|
return _context5.abrupt("return", newScheme);
|
|
380
|
-
case
|
|
409
|
+
case 28:
|
|
381
410
|
case "end":
|
|
382
411
|
return _context5.stop();
|
|
383
412
|
}
|
|
384
|
-
}, _callee5);
|
|
413
|
+
}, _callee5, null, [[17, 22]]);
|
|
385
414
|
}));
|
|
386
415
|
return function (_x4, _x5, _x6) {
|
|
387
416
|
return _ref5.apply(this, arguments);
|
|
388
417
|
};
|
|
389
|
-
}(), [schemes, saveSchemesToStorage, onSchemeSave]);
|
|
418
|
+
}(), [schemes, gridId, storageAdapter, saveSchemesToStorage, onSchemeChange, onSchemeSave]);
|
|
390
419
|
|
|
391
420
|
/**
|
|
392
421
|
* 更新方案信息(不影响 columnState)
|
|
393
422
|
*/
|
|
394
423
|
var updateScheme = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
395
|
-
var
|
|
424
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schemeId, updates) {
|
|
396
425
|
var scheme, nameValidation, updatedScheme, updatedSchemes;
|
|
397
426
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
398
427
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -456,7 +485,7 @@ function useColumnSchemes(config) {
|
|
|
456
485
|
}, _callee6);
|
|
457
486
|
}));
|
|
458
487
|
return function (_x7, _x8) {
|
|
459
|
-
return
|
|
488
|
+
return _ref7.apply(this, arguments);
|
|
460
489
|
};
|
|
461
490
|
}(), [schemes, currentScheme, saveSchemesToStorage]);
|
|
462
491
|
|
|
@@ -464,7 +493,7 @@ function useColumnSchemes(config) {
|
|
|
464
493
|
* 删除方案
|
|
465
494
|
*/
|
|
466
495
|
var deleteScheme = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
467
|
-
var
|
|
496
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schemeId) {
|
|
468
497
|
var scheme, updatedSchemes;
|
|
469
498
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
470
499
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -523,7 +552,7 @@ function useColumnSchemes(config) {
|
|
|
523
552
|
}, _callee7, null, [[12, 17]]);
|
|
524
553
|
}));
|
|
525
554
|
return function (_x9) {
|
|
526
|
-
return
|
|
555
|
+
return _ref8.apply(this, arguments);
|
|
527
556
|
};
|
|
528
557
|
}(), [schemes, currentScheme, gridId, storageAdapter, saveSchemesToStorage, onSchemeChange, onSchemeDelete]);
|
|
529
558
|
|
|
@@ -542,7 +571,7 @@ function useColumnSchemes(config) {
|
|
|
542
571
|
* 设置默认方案
|
|
543
572
|
*/
|
|
544
573
|
var setDefaultScheme = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
545
|
-
var
|
|
574
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(schemeId) {
|
|
546
575
|
var updatedSchemes;
|
|
547
576
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
548
577
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -561,7 +590,7 @@ function useColumnSchemes(config) {
|
|
|
561
590
|
}, _callee8);
|
|
562
591
|
}));
|
|
563
592
|
return function (_x10) {
|
|
564
|
-
return
|
|
593
|
+
return _ref9.apply(this, arguments);
|
|
565
594
|
};
|
|
566
595
|
}(), [schemes, saveSchemesToStorage]);
|
|
567
596
|
|
|
@@ -109,7 +109,9 @@ export interface UseColumnSchemesReturn {
|
|
|
109
109
|
/** 保存当前方案(更新现有方案) */
|
|
110
110
|
saveScheme: (updates?: Partial<ColumnScheme>) => Promise<void>;
|
|
111
111
|
/** 创建新方案 */
|
|
112
|
-
createScheme: (name: string, columnConfig: FlatColumnItem[], options?: Partial<ColumnScheme>
|
|
112
|
+
createScheme: (name: string, columnConfig: FlatColumnItem[], options?: Partial<ColumnScheme> & {
|
|
113
|
+
activate?: boolean;
|
|
114
|
+
}) => Promise<ColumnScheme>;
|
|
113
115
|
/** 更新方案信息(不影响 columnConfig) */
|
|
114
116
|
updateScheme: (schemeId: string, updates: Partial<Omit<ColumnScheme, 'id' | 'columnConfig'>>) => Promise<void>;
|
|
115
117
|
/** 删除方案 */
|
|
@@ -254,7 +254,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
254
254
|
while (1) switch (_context.prev = _context.next) {
|
|
255
255
|
case 0:
|
|
256
256
|
if (!(schemeManager && gridKey)) {
|
|
257
|
-
_context.next =
|
|
257
|
+
_context.next = 27;
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
260
|
_context.prev = 1;
|
|
@@ -287,7 +287,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
287
287
|
filterModel: filterModel
|
|
288
288
|
});
|
|
289
289
|
case 8:
|
|
290
|
-
_context.next =
|
|
290
|
+
_context.next = 22;
|
|
291
291
|
break;
|
|
292
292
|
case 10:
|
|
293
293
|
// 如果没有激活的方案,查找或创建"默认配置"方案
|
|
@@ -308,7 +308,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
308
308
|
filterModel: filterModel
|
|
309
309
|
});
|
|
310
310
|
case 16:
|
|
311
|
-
_context.next =
|
|
311
|
+
_context.next = 22;
|
|
312
312
|
break;
|
|
313
313
|
case 18:
|
|
314
314
|
_context.next = 20;
|
|
@@ -317,33 +317,29 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
317
317
|
{
|
|
318
318
|
isDefault: true,
|
|
319
319
|
description: '自动保存的默认列配置',
|
|
320
|
-
filterModel: filterModel
|
|
320
|
+
filterModel: filterModel,
|
|
321
|
+
activate: true // 立即激活该方案
|
|
321
322
|
});
|
|
322
323
|
case 20:
|
|
323
324
|
newScheme = _context.sent;
|
|
324
|
-
console.log('[ColumnSetting]
|
|
325
|
+
console.log('[ColumnSetting] 创建默认方案成功并已激活:', {
|
|
325
326
|
schemeId: newScheme.id,
|
|
326
327
|
schemeName: newScheme.name,
|
|
327
328
|
hasColumnConfig: !!newScheme.columnConfig,
|
|
328
329
|
columnConfigLength: ((_newScheme$columnConf = newScheme.columnConfig) === null || _newScheme$columnConf === void 0 ? void 0 : _newScheme$columnConf.length) || 0
|
|
329
330
|
});
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
// loadScheme 会设置 currentScheme 并触发 onSchemeChange
|
|
333
|
-
_context.next = 24;
|
|
334
|
-
return schemeManager.loadScheme(newScheme.id);
|
|
335
|
-
case 24:
|
|
336
|
-
_context.next = 29;
|
|
331
|
+
case 22:
|
|
332
|
+
_context.next = 27;
|
|
337
333
|
break;
|
|
338
|
-
case
|
|
339
|
-
_context.prev =
|
|
334
|
+
case 24:
|
|
335
|
+
_context.prev = 24;
|
|
340
336
|
_context.t0 = _context["catch"](1);
|
|
341
337
|
console.error('[ColumnSetting] 保存列配置到方案失败:', _context.t0);
|
|
342
|
-
case
|
|
338
|
+
case 27:
|
|
343
339
|
case "end":
|
|
344
340
|
return _context.stop();
|
|
345
341
|
}
|
|
346
|
-
}, _callee, null, [[1,
|
|
342
|
+
}, _callee, null, [[1, 24]]);
|
|
347
343
|
})), 50);
|
|
348
344
|
|
|
349
345
|
// 保存成功后清除备份
|
|
@@ -38,8 +38,10 @@ var processColumnGroups = function processColumnGroups(columns) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// 检查是否是新格式(FlatColumnItem)
|
|
41
|
+
// 注意:不能用 col.type 判断,因为 AG-Grid 列定义也有 type 字段(如 type: 'dateTimeColumn')
|
|
42
|
+
// FlatColumnItem 的特征是:有 id, parentId, level, order 等字段,且 type 的值是 'group' 或 'column'
|
|
41
43
|
var isNewFormat = columns.some(function (col) {
|
|
42
|
-
return col.
|
|
44
|
+
return col.id !== undefined && col.level !== undefined && col.order !== undefined && (col.type === 'group' || col.type === 'column');
|
|
43
45
|
});
|
|
44
46
|
if (isNewFormat) {
|
|
45
47
|
// 新格式:使用 flatConfigToGridState 转换
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
var _excluded = ["activate"];
|
|
2
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
6
9
|
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; }
|
|
7
10
|
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; }
|
|
8
11
|
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; }
|
|
@@ -331,7 +334,7 @@ export function useColumnSchemes(config) {
|
|
|
331
334
|
*/
|
|
332
335
|
var createScheme = useCallback( /*#__PURE__*/function () {
|
|
333
336
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(name, columnConfig, options) {
|
|
334
|
-
var nameValidation, uniqueName, newScheme, updatedSchemes;
|
|
337
|
+
var nameValidation, uniqueName, _ref6, activate, schemeOptions, newScheme, updatedSchemes;
|
|
335
338
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
336
339
|
while (1) switch (_context5.prev = _context5.next) {
|
|
337
340
|
case 0:
|
|
@@ -350,14 +353,15 @@ export function useColumnSchemes(config) {
|
|
|
350
353
|
throw new Error("\u65B9\u6848\u6570\u91CF\u5DF2\u8FBE\u4E0A\u9650\uFF08".concat(MAX_SCHEMES_PER_GRID, "\u4E2A\uFF09\uFF0C\u8BF7\u5220\u9664\u4E00\u4E9B\u65B9\u6848\u540E\u518D\u8BD5"));
|
|
351
354
|
case 5:
|
|
352
355
|
// 处理重名情况
|
|
353
|
-
uniqueName = checkDuplicateName(name, schemes) ? generateUniqueName(name, schemes) : name;
|
|
356
|
+
uniqueName = checkDuplicateName(name, schemes) ? generateUniqueName(name, schemes) : name; // 提取 activate 选项
|
|
357
|
+
_ref6 = options || {}, activate = _ref6.activate, schemeOptions = _objectWithoutProperties(_ref6, _excluded);
|
|
354
358
|
newScheme = _objectSpread({
|
|
355
359
|
id: uuidv4(),
|
|
356
360
|
name: uniqueName,
|
|
357
361
|
createdAt: Date.now(),
|
|
358
362
|
updatedAt: Date.now(),
|
|
359
363
|
columnConfig: columnConfig
|
|
360
|
-
},
|
|
364
|
+
}, schemeOptions); // 如果设置为默认方案,取消其他方案的默认标记
|
|
361
365
|
updatedSchemes = schemes;
|
|
362
366
|
if (newScheme.isDefault) {
|
|
363
367
|
updatedSchemes = schemes.map(function (s) {
|
|
@@ -367,27 +371,52 @@ export function useColumnSchemes(config) {
|
|
|
367
371
|
});
|
|
368
372
|
}
|
|
369
373
|
updatedSchemes = [].concat(_toConsumableArray(updatedSchemes), [newScheme]);
|
|
370
|
-
_context5.next =
|
|
374
|
+
_context5.next = 13;
|
|
371
375
|
return saveSchemesToStorage(updatedSchemes);
|
|
372
|
-
case
|
|
376
|
+
case 13:
|
|
377
|
+
if (!activate) {
|
|
378
|
+
_context5.next = 26;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
setCurrentScheme(newScheme);
|
|
382
|
+
setIsDirty(false);
|
|
383
|
+
|
|
384
|
+
// 保存当前方案ID
|
|
385
|
+
if (!storageAdapter.saveCurrentSchemeId) {
|
|
386
|
+
_context5.next = 25;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
_context5.prev = 17;
|
|
390
|
+
_context5.next = 20;
|
|
391
|
+
return storageAdapter.saveCurrentSchemeId(gridId, newScheme.id);
|
|
392
|
+
case 20:
|
|
393
|
+
_context5.next = 25;
|
|
394
|
+
break;
|
|
395
|
+
case 22:
|
|
396
|
+
_context5.prev = 22;
|
|
397
|
+
_context5.t0 = _context5["catch"](17);
|
|
398
|
+
console.error('[useColumnSchemes] 保存当前方案ID失败:', _context5.t0);
|
|
399
|
+
case 25:
|
|
400
|
+
onSchemeChange === null || onSchemeChange === void 0 || onSchemeChange(newScheme);
|
|
401
|
+
case 26:
|
|
373
402
|
onSchemeSave === null || onSchemeSave === void 0 || onSchemeSave(newScheme);
|
|
374
403
|
return _context5.abrupt("return", newScheme);
|
|
375
|
-
case
|
|
404
|
+
case 28:
|
|
376
405
|
case "end":
|
|
377
406
|
return _context5.stop();
|
|
378
407
|
}
|
|
379
|
-
}, _callee5);
|
|
408
|
+
}, _callee5, null, [[17, 22]]);
|
|
380
409
|
}));
|
|
381
410
|
return function (_x4, _x5, _x6) {
|
|
382
411
|
return _ref5.apply(this, arguments);
|
|
383
412
|
};
|
|
384
|
-
}(), [schemes, saveSchemesToStorage, onSchemeSave]);
|
|
413
|
+
}(), [schemes, gridId, storageAdapter, saveSchemesToStorage, onSchemeChange, onSchemeSave]);
|
|
385
414
|
|
|
386
415
|
/**
|
|
387
416
|
* 更新方案信息(不影响 columnState)
|
|
388
417
|
*/
|
|
389
418
|
var updateScheme = useCallback( /*#__PURE__*/function () {
|
|
390
|
-
var
|
|
419
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schemeId, updates) {
|
|
391
420
|
var scheme, nameValidation, updatedScheme, updatedSchemes;
|
|
392
421
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
393
422
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -451,7 +480,7 @@ export function useColumnSchemes(config) {
|
|
|
451
480
|
}, _callee6);
|
|
452
481
|
}));
|
|
453
482
|
return function (_x7, _x8) {
|
|
454
|
-
return
|
|
483
|
+
return _ref7.apply(this, arguments);
|
|
455
484
|
};
|
|
456
485
|
}(), [schemes, currentScheme, saveSchemesToStorage]);
|
|
457
486
|
|
|
@@ -459,7 +488,7 @@ export function useColumnSchemes(config) {
|
|
|
459
488
|
* 删除方案
|
|
460
489
|
*/
|
|
461
490
|
var deleteScheme = useCallback( /*#__PURE__*/function () {
|
|
462
|
-
var
|
|
491
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schemeId) {
|
|
463
492
|
var scheme, updatedSchemes;
|
|
464
493
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
465
494
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -518,7 +547,7 @@ export function useColumnSchemes(config) {
|
|
|
518
547
|
}, _callee7, null, [[12, 17]]);
|
|
519
548
|
}));
|
|
520
549
|
return function (_x9) {
|
|
521
|
-
return
|
|
550
|
+
return _ref8.apply(this, arguments);
|
|
522
551
|
};
|
|
523
552
|
}(), [schemes, currentScheme, gridId, storageAdapter, saveSchemesToStorage, onSchemeChange, onSchemeDelete]);
|
|
524
553
|
|
|
@@ -537,7 +566,7 @@ export function useColumnSchemes(config) {
|
|
|
537
566
|
* 设置默认方案
|
|
538
567
|
*/
|
|
539
568
|
var setDefaultScheme = useCallback( /*#__PURE__*/function () {
|
|
540
|
-
var
|
|
569
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(schemeId) {
|
|
541
570
|
var updatedSchemes;
|
|
542
571
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
543
572
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -556,7 +585,7 @@ export function useColumnSchemes(config) {
|
|
|
556
585
|
}, _callee8);
|
|
557
586
|
}));
|
|
558
587
|
return function (_x10) {
|
|
559
|
-
return
|
|
588
|
+
return _ref9.apply(this, arguments);
|
|
560
589
|
};
|
|
561
590
|
}(), [schemes, saveSchemesToStorage]);
|
|
562
591
|
|
|
@@ -109,7 +109,9 @@ export interface UseColumnSchemesReturn {
|
|
|
109
109
|
/** 保存当前方案(更新现有方案) */
|
|
110
110
|
saveScheme: (updates?: Partial<ColumnScheme>) => Promise<void>;
|
|
111
111
|
/** 创建新方案 */
|
|
112
|
-
createScheme: (name: string, columnConfig: FlatColumnItem[], options?: Partial<ColumnScheme>
|
|
112
|
+
createScheme: (name: string, columnConfig: FlatColumnItem[], options?: Partial<ColumnScheme> & {
|
|
113
|
+
activate?: boolean;
|
|
114
|
+
}) => Promise<ColumnScheme>;
|
|
113
115
|
/** 更新方案信息(不影响 columnConfig) */
|
|
114
116
|
updateScheme: (schemeId: string, updates: Partial<Omit<ColumnScheme, 'id' | 'columnConfig'>>) => Promise<void>;
|
|
115
117
|
/** 删除方案 */
|
|
@@ -245,7 +245,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
245
245
|
while (1) switch (_context.prev = _context.next) {
|
|
246
246
|
case 0:
|
|
247
247
|
if (!(schemeManager && gridKey)) {
|
|
248
|
-
_context.next =
|
|
248
|
+
_context.next = 27;
|
|
249
249
|
break;
|
|
250
250
|
}
|
|
251
251
|
_context.prev = 1;
|
|
@@ -278,7 +278,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
278
278
|
filterModel: filterModel
|
|
279
279
|
});
|
|
280
280
|
case 8:
|
|
281
|
-
_context.next =
|
|
281
|
+
_context.next = 22;
|
|
282
282
|
break;
|
|
283
283
|
case 10:
|
|
284
284
|
// 如果没有激活的方案,查找或创建"默认配置"方案
|
|
@@ -299,7 +299,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
299
299
|
filterModel: filterModel
|
|
300
300
|
});
|
|
301
301
|
case 16:
|
|
302
|
-
_context.next =
|
|
302
|
+
_context.next = 22;
|
|
303
303
|
break;
|
|
304
304
|
case 18:
|
|
305
305
|
_context.next = 20;
|
|
@@ -308,33 +308,29 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
308
308
|
{
|
|
309
309
|
isDefault: true,
|
|
310
310
|
description: '自动保存的默认列配置',
|
|
311
|
-
filterModel: filterModel
|
|
311
|
+
filterModel: filterModel,
|
|
312
|
+
activate: true // 立即激活该方案
|
|
312
313
|
});
|
|
313
314
|
case 20:
|
|
314
315
|
newScheme = _context.sent;
|
|
315
|
-
console.log('[ColumnSetting]
|
|
316
|
+
console.log('[ColumnSetting] 创建默认方案成功并已激活:', {
|
|
316
317
|
schemeId: newScheme.id,
|
|
317
318
|
schemeName: newScheme.name,
|
|
318
319
|
hasColumnConfig: !!newScheme.columnConfig,
|
|
319
320
|
columnConfigLength: ((_newScheme$columnConf = newScheme.columnConfig) === null || _newScheme$columnConf === void 0 ? void 0 : _newScheme$columnConf.length) || 0
|
|
320
321
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
// loadScheme 会设置 currentScheme 并触发 onSchemeChange
|
|
324
|
-
_context.next = 24;
|
|
325
|
-
return schemeManager.loadScheme(newScheme.id);
|
|
326
|
-
case 24:
|
|
327
|
-
_context.next = 29;
|
|
322
|
+
case 22:
|
|
323
|
+
_context.next = 27;
|
|
328
324
|
break;
|
|
329
|
-
case
|
|
330
|
-
_context.prev =
|
|
325
|
+
case 24:
|
|
326
|
+
_context.prev = 24;
|
|
331
327
|
_context.t0 = _context["catch"](1);
|
|
332
328
|
console.error('[ColumnSetting] 保存列配置到方案失败:', _context.t0);
|
|
333
|
-
case
|
|
329
|
+
case 27:
|
|
334
330
|
case "end":
|
|
335
331
|
return _context.stop();
|
|
336
332
|
}
|
|
337
|
-
}, _callee, null, [[1,
|
|
333
|
+
}, _callee, null, [[1, 24]]);
|
|
338
334
|
})), 50);
|
|
339
335
|
|
|
340
336
|
// 保存成功后清除备份
|
|
@@ -173,7 +173,7 @@ export declare const createSelectField: (title: string, options: {
|
|
|
173
173
|
export declare const createCascaderField: (title: string, options: any[], config?: {
|
|
174
174
|
required?: boolean | undefined;
|
|
175
175
|
changeOnSelect?: boolean | undefined;
|
|
176
|
-
expandTrigger?: "
|
|
176
|
+
expandTrigger?: "hover" | "click" | undefined;
|
|
177
177
|
placeholder?: string | undefined;
|
|
178
178
|
}) => {
|
|
179
179
|
type: string;
|
|
@@ -187,7 +187,7 @@ export declare const createCascaderField: (title: string, options: any[], config
|
|
|
187
187
|
};
|
|
188
188
|
options: any[];
|
|
189
189
|
changeOnSelect: boolean;
|
|
190
|
-
expandTrigger: "
|
|
190
|
+
expandTrigger: "hover" | "click";
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
193
|
export default withStandardForm;
|