@nokecy/qc-ui 1.1.30 → 1.1.32

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.
Files changed (27) hide show
  1. package/dist/cjs/ag-grid-plus/ag-gridPlus.js +68 -9
  2. package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +22 -0
  3. package/dist/cjs/ag-grid-plus/context/useSchemeManager.d.ts +3 -0
  4. package/dist/cjs/ag-grid-plus/context/useSchemeManager.js +160 -1
  5. package/dist/cjs/ag-grid-plus/index.d.ts +1 -0
  6. package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +192 -50
  7. package/dist/cjs/ag-grid-plus/shared/permissions/globalConfigPermissions.d.ts +22 -0
  8. package/dist/cjs/ag-grid-plus/shared/permissions/globalConfigPermissions.js +5 -0
  9. package/dist/cjs/ag-grid-plus/shared/storage/localStorageAdapter.d.ts +18 -0
  10. package/dist/cjs/ag-grid-plus/shared/storage/localStorageAdapter.js +114 -0
  11. package/dist/cjs/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +25 -0
  12. package/dist/cjs/index.d.ts +1 -1
  13. package/dist/esm/ag-grid-plus/ag-gridPlus.js +68 -9
  14. package/dist/esm/ag-grid-plus/context/gridContext.d.ts +22 -0
  15. package/dist/esm/ag-grid-plus/context/useSchemeManager.d.ts +3 -0
  16. package/dist/esm/ag-grid-plus/context/useSchemeManager.js +160 -1
  17. package/dist/esm/ag-grid-plus/index.d.ts +1 -0
  18. package/dist/esm/ag-grid-plus/index.js +2 -0
  19. package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +195 -51
  20. package/dist/esm/ag-grid-plus/shared/permissions/globalConfigPermissions.d.ts +22 -0
  21. package/dist/esm/ag-grid-plus/shared/permissions/globalConfigPermissions.js +1 -0
  22. package/dist/esm/ag-grid-plus/shared/storage/localStorageAdapter.d.ts +18 -0
  23. package/dist/esm/ag-grid-plus/shared/storage/localStorageAdapter.js +114 -0
  24. package/dist/esm/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +25 -0
  25. package/dist/esm/index.d.ts +1 -1
  26. package/dist/umd/qc-ui.min.js +1 -1
  27. package/package.json +1 -1
@@ -92,7 +92,11 @@ function AgGridPlus(props) {
92
92
  extensibleColumns = _useGridPlusColumnSta.extensibleColumns,
93
93
  applyToGlobal = _useGridPlusColumnSta.applyToGlobal,
94
94
  resetCurrent = _useGridPlusColumnSta.resetCurrent,
95
- resetAll = _useGridPlusColumnSta.resetAll;
95
+ resetAll = _useGridPlusColumnSta.resetAll,
96
+ globalConfigPermissions = _useGridPlusColumnSta.globalConfigPermissions,
97
+ applySchemeToGlobal = _useGridPlusColumnSta.applySchemeToGlobal,
98
+ resetToGlobal = _useGridPlusColumnSta.resetToGlobal,
99
+ resetAllUsers = _useGridPlusColumnSta.resetAllUsers;
96
100
  var gridRef = useRef();
97
101
  var apiRef = useRef();
98
102
  var allColDefsRef = useRef([]);
@@ -752,6 +756,54 @@ function AgGridPlus(props) {
752
756
  logger.info('数据请求成功', {
753
757
  rowCount: rowCount
754
758
  });
759
+
760
+ // 【新增】数据刷新后同步更新选中行数据
761
+ // 场景:用户执行操作(如审核)后刷新列表,选中行的数据已变化
762
+ // 需要从新数据中找到对应的行,同步更新业务层的选中状态
763
+ // 支持两种回调方式:onSelectedRowsChange 和 onSelectionChanged
764
+ if (apiRef.current) {
765
+ // 使用 requestAnimationFrame 确保 AG-Grid 数据更新完成
766
+ requestAnimationFrame(function () {
767
+ if (!apiRef.current) return;
768
+ var selectedNodes = apiRef.current.getSelectedNodes();
769
+ if (selectedNodes.length > 0) {
770
+ // 获取行ID的方法
771
+ var getRowIdMethod = props.getRowId || function (params) {
772
+ return generateUniqueRowId(params.data);
773
+ };
774
+
775
+ // 获取当前选中的行ID列表
776
+ var selectedIds = selectedNodes.filter(function (node) {
777
+ return node.data;
778
+ }).map(function (node) {
779
+ return getRowIdMethod({
780
+ data: node.data,
781
+ level: node.level || 0,
782
+ api: apiRef.current,
783
+ context: null
784
+ });
785
+ });
786
+
787
+ // 【关键】重新选中行以触发 onSelectionChanged
788
+ // 先取消所有选中,再重新选中,这样可以触发选中变化事件
789
+ // 并且新选中的行数据是刷新后的最新数据
790
+ apiRef.current.deselectAll();
791
+
792
+ // 从新数据中找到对应的行并重新选中
793
+ selectedIds.forEach(function (id) {
794
+ var _apiRef$current3;
795
+ var rowNode = (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 ? void 0 : _apiRef$current3.getRowNode(id);
796
+ if (rowNode) {
797
+ rowNode.setSelected(true, false, 'api');
798
+ }
799
+ });
800
+ logger.debug('数据刷新后重新选中行', {
801
+ selectedIds: selectedIds,
802
+ reselectedCount: selectedIds.length
803
+ });
804
+ }
805
+ });
806
+ }
755
807
  }).catch(function (error) {
756
808
  setLoading(false);
757
809
 
@@ -1016,8 +1068,8 @@ function AgGridPlus(props) {
1016
1068
  });
1017
1069
  }
1018
1070
  if (!allColDefs || displayedData.length === 0) {
1019
- var _apiRef$current3;
1020
- (_apiRef$current3 = apiRef.current) === null || _apiRef$current3 === void 0 || _apiRef$current3.setGridOption('pinnedBottomRowData', undefined);
1071
+ var _apiRef$current4;
1072
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
1021
1073
  return;
1022
1074
  }
1023
1075
  var calcColFields = allColDefs.filter(function (col) {
@@ -1031,9 +1083,9 @@ function AgGridPlus(props) {
1031
1083
  };
1032
1084
  });
1033
1085
  if (calcColFields.length > 0) {
1034
- var _apiRef$current4;
1086
+ var _apiRef$current5;
1035
1087
  var calculatedValues = calculatefun(calcColFields, displayedData);
1036
- (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', calculatedValues);
1088
+ (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
1037
1089
  }
1038
1090
  }, [allColDefs, calculatefun]);
1039
1091
  var onFilterChanged = function onFilterChanged(event) {
@@ -1197,7 +1249,12 @@ function AgGridPlus(props) {
1197
1249
  refreshSchemes: refreshSchemes,
1198
1250
  getColumnSchemes: getColumnSchemes,
1199
1251
  getQuerySchemes: getQuerySchemes,
1200
- getCurrentScheme: getCurrentScheme
1252
+ getCurrentScheme: getCurrentScheme,
1253
+ // ========== 全局配置 API(透传给子组件) ==========
1254
+ globalConfigPermissions: globalConfigPermissions,
1255
+ applySchemeToGlobal: applySchemeToGlobal,
1256
+ resetToGlobal: resetToGlobal,
1257
+ resetAllUsers: resetAllUsers
1201
1258
  };
1202
1259
  }, [extensibleColumns, gridPlusColumnState, allColDefsRef.current,
1203
1260
  // 【修复】添加到依赖数组
@@ -1205,7 +1262,9 @@ function AgGridPlus(props) {
1205
1262
  // 【新增】添加初始列定义到依赖数组
1206
1263
  onSaveColumnState, applyToGlobal, resetCurrent, resetAll, currentQueryScheme, queryItemsOrder, queryFormItems,
1207
1264
  // 方案管理依赖
1208
- columnSchemes, querySchemes, currentSchemes, schemesLoading, lastSyncTime, saveColumnScheme, deleteColumnScheme, saveQueryScheme, deleteQueryScheme, setCurrentColumnScheme, setCurrentQueryScheme, refreshSchemes, getColumnSchemes, getQuerySchemes, getCurrentScheme]);
1265
+ columnSchemes, querySchemes, currentSchemes, schemesLoading, lastSyncTime, saveColumnScheme, deleteColumnScheme, saveQueryScheme, deleteQueryScheme, setCurrentColumnScheme, setCurrentQueryScheme, refreshSchemes, getColumnSchemes, getQuerySchemes, getCurrentScheme,
1266
+ // 全局配置依赖
1267
+ globalConfigPermissions, applySchemeToGlobal, resetToGlobal, resetAllUsers]);
1209
1268
  return /*#__PURE__*/React.createElement(GridPlusContext.Provider, {
1210
1269
  value: gridPlusContextValue
1211
1270
  }, /*#__PURE__*/React.createElement(Spin, {
@@ -1409,8 +1468,8 @@ function AgGridPlus(props) {
1409
1468
  },
1410
1469
  onDragStopped: function onDragStopped(e) {
1411
1470
  if (apiRef.current) {
1412
- var _apiRef$current5;
1413
- var _columnState = (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.getColumnState();
1471
+ var _apiRef$current6;
1472
+ var _columnState = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.getColumnState();
1414
1473
  setColumnState(_columnState);
1415
1474
 
1416
1475
  // onColumnStateChanged && onColumnStateChanged(columnState)
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import type { ColumnScheme, QueryScheme, CurrentSchemeDto } from "../shared/storage/schemeStorageAdapter";
3
+ import type { GlobalConfigPermissions } from '../shared/permissions/globalConfigPermissions';
3
4
  /**
4
5
  * 方案管理 API 接口
5
6
  *
@@ -144,5 +145,26 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
144
145
  * 此字段由 useSchemeManager 自动管理,无需手动设置
145
146
  */
146
147
  currentUserId?: string | null;
148
+ /**
149
+ * 将当前列配置应用为全局默认(管理员操作)
150
+ * @param gridId 表格标识
151
+ * @param schemeId 源方案ID(可选,不传则使用当前激活的方案)
152
+ */
153
+ applySchemeToGlobal?: (gridId: string, schemeId?: string) => Promise<void>;
154
+ /**
155
+ * 重置当前用户配置,回退到全局配置
156
+ * @param gridId 表格标识
157
+ */
158
+ resetToGlobal?: (gridId: string) => Promise<void>;
159
+ /**
160
+ * 重置所有用户配置(管理员操作)
161
+ * @param gridId 表格标识
162
+ */
163
+ resetAllUsers?: (gridId: string) => Promise<void>;
164
+ /**
165
+ * 全局配置权限信息
166
+ * 由使用端(业务应用)传入,用于前端根据权限动态显示/隐藏操作按钮
167
+ */
168
+ globalConfigPermissions?: GlobalConfigPermissions;
147
169
  }
148
170
  export declare const GridPlusContext: React.Context<GridPlusContextValue>;
@@ -51,6 +51,9 @@ export declare function useSchemeManager(config: UseSchemeManagerConfig): {
51
51
  getColumnSchemes: (gridId: string) => ColumnScheme[];
52
52
  getQuerySchemes: (gridId: string) => QueryScheme[];
53
53
  getCurrentScheme: (gridId: string) => CurrentSchemeDto | null;
54
+ applySchemeToGlobal: (gridId: string, schemeId?: string) => Promise<string>;
55
+ resetToGlobal: (gridId: string) => Promise<void>;
56
+ resetAllUsers: (gridId: string) => Promise<void>;
54
57
  };
55
58
  /**
56
59
  * 在组件中使用集中式方案管理
@@ -430,6 +430,161 @@ export function useSchemeManager(config) {
430
430
  }
431
431
  }, _callee8);
432
432
  })), [loadAllSchemes]);
433
+
434
+ // ========== 全局配置操作 ==========
435
+
436
+ /**
437
+ * 处理全局配置操作的错误
438
+ * @author nokecy
439
+ */
440
+ var handleGlobalConfigError = useCallback(function (error, defaultMessage) {
441
+ var _error$response;
442
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 403) {
443
+ message.error('没有权限执行此操作');
444
+ } else {
445
+ message.error(error.message || defaultMessage);
446
+ }
447
+ }, []);
448
+
449
+ /**
450
+ * 将方案应用到全局(管理员操作)
451
+ * @author nokecy
452
+ */
453
+ var applySchemeToGlobal = useCallback( /*#__PURE__*/function () {
454
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(gridId, schemeId) {
455
+ var _currentSchemes$gridI3;
456
+ var targetSchemeId, globalSchemeId;
457
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
458
+ while (1) switch (_context9.prev = _context9.next) {
459
+ case 0:
460
+ targetSchemeId = schemeId || ((_currentSchemes$gridI3 = currentSchemes[gridId]) === null || _currentSchemes$gridI3 === void 0 ? void 0 : _currentSchemes$gridI3.columnSchemeId);
461
+ if (targetSchemeId) {
462
+ _context9.next = 3;
463
+ break;
464
+ }
465
+ throw new Error('没有可应用的方案');
466
+ case 3:
467
+ if (adapter.applyToGlobal) {
468
+ _context9.next = 5;
469
+ break;
470
+ }
471
+ throw new Error('当前存储适配器不支持全局配置功能');
472
+ case 5:
473
+ _context9.prev = 5;
474
+ _context9.next = 8;
475
+ return adapter.applyToGlobal(gridId, targetSchemeId);
476
+ case 8:
477
+ globalSchemeId = _context9.sent;
478
+ message.success('已应用到全局配置');
479
+ _context9.next = 12;
480
+ return refreshSchemes();
481
+ case 12:
482
+ return _context9.abrupt("return", globalSchemeId);
483
+ case 15:
484
+ _context9.prev = 15;
485
+ _context9.t0 = _context9["catch"](5);
486
+ console.error('[useSchemeManager] 应用到全局失败:', _context9.t0);
487
+ handleGlobalConfigError(_context9.t0, '应用到全局失败');
488
+ throw _context9.t0;
489
+ case 20:
490
+ case "end":
491
+ return _context9.stop();
492
+ }
493
+ }, _callee9, null, [[5, 15]]);
494
+ }));
495
+ return function (_x13, _x14) {
496
+ return _ref9.apply(this, arguments);
497
+ };
498
+ }(), [adapter, currentSchemes, refreshSchemes, handleGlobalConfigError]);
499
+
500
+ /**
501
+ * 重置当前用户配置,回退到全局配置
502
+ * @author nokecy
503
+ */
504
+ var resetToGlobal = useCallback( /*#__PURE__*/function () {
505
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(gridId) {
506
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
507
+ while (1) switch (_context10.prev = _context10.next) {
508
+ case 0:
509
+ if (adapter.resetToGlobal) {
510
+ _context10.next = 2;
511
+ break;
512
+ }
513
+ throw new Error('当前存储适配器不支持全局配置功能');
514
+ case 2:
515
+ _context10.prev = 2;
516
+ _context10.next = 5;
517
+ return adapter.resetToGlobal(gridId);
518
+ case 5:
519
+ setCurrentSchemes(function (prev) {
520
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, gridId, _objectSpread(_objectSpread({}, prev[gridId]), {}, {
521
+ columnSchemeId: null
522
+ })));
523
+ });
524
+ _context10.next = 8;
525
+ return refreshSchemes();
526
+ case 8:
527
+ message.success('已重置为全局配置');
528
+ _context10.next = 16;
529
+ break;
530
+ case 11:
531
+ _context10.prev = 11;
532
+ _context10.t0 = _context10["catch"](2);
533
+ console.error('[useSchemeManager] 重置为全局配置失败:', _context10.t0);
534
+ handleGlobalConfigError(_context10.t0, '重置失败');
535
+ throw _context10.t0;
536
+ case 16:
537
+ case "end":
538
+ return _context10.stop();
539
+ }
540
+ }, _callee10, null, [[2, 11]]);
541
+ }));
542
+ return function (_x15) {
543
+ return _ref10.apply(this, arguments);
544
+ };
545
+ }(), [adapter, refreshSchemes, handleGlobalConfigError]);
546
+
547
+ /**
548
+ * 重置所有用户配置(管理员操作)
549
+ * @author nokecy
550
+ */
551
+ var resetAllUsers = useCallback( /*#__PURE__*/function () {
552
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(gridId) {
553
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
554
+ while (1) switch (_context11.prev = _context11.next) {
555
+ case 0:
556
+ if (adapter.resetAllUsers) {
557
+ _context11.next = 2;
558
+ break;
559
+ }
560
+ throw new Error('当前存储适配器不支持全局配置功能');
561
+ case 2:
562
+ _context11.prev = 2;
563
+ _context11.next = 5;
564
+ return adapter.resetAllUsers(gridId);
565
+ case 5:
566
+ _context11.next = 7;
567
+ return refreshSchemes();
568
+ case 7:
569
+ message.success('已重置所有用户配置');
570
+ _context11.next = 15;
571
+ break;
572
+ case 10:
573
+ _context11.prev = 10;
574
+ _context11.t0 = _context11["catch"](2);
575
+ console.error('[useSchemeManager] 重置所有用户配置失败:', _context11.t0);
576
+ handleGlobalConfigError(_context11.t0, '重置失败');
577
+ throw _context11.t0;
578
+ case 15:
579
+ case "end":
580
+ return _context11.stop();
581
+ }
582
+ }, _callee11, null, [[2, 10]]);
583
+ }));
584
+ return function (_x16) {
585
+ return _ref11.apply(this, arguments);
586
+ };
587
+ }(), [adapter, refreshSchemes, handleGlobalConfigError]);
433
588
  var getColumnSchemes = useCallback(function (gridId) {
434
589
  return columnSchemes[gridId] || [];
435
590
  }, [columnSchemes]);
@@ -461,7 +616,11 @@ export function useSchemeManager(config) {
461
616
  refreshSchemes: refreshSchemes,
462
617
  getColumnSchemes: getColumnSchemes,
463
618
  getQuerySchemes: getQuerySchemes,
464
- getCurrentScheme: getCurrentScheme
619
+ getCurrentScheme: getCurrentScheme,
620
+ // 全局配置操作
621
+ applySchemeToGlobal: applySchemeToGlobal,
622
+ resetToGlobal: resetToGlobal,
623
+ resetAllUsers: resetAllUsers
465
624
  };
466
625
  }
467
626
 
@@ -12,3 +12,4 @@ export type { SchemeStorageAdapter, SchemeSyncDataDto, CurrentSchemeDto, SchemeS
12
12
  export type { UseSchemeManagerConfig } from "./context/useSchemeManager";
13
13
  export type { BackendApiAdapterConfig } from "./shared/storage/backendApiAdapter";
14
14
  export type { LocalStorageAdapterConfig } from "./shared/storage/localStorageAdapter";
15
+ export type { GlobalConfigPermissions } from "./shared/permissions/globalConfigPermissions";
@@ -13,5 +13,7 @@ export { useSchemeManager, useGridSchemes } from "./context/useSchemeManager";
13
13
  export { LocalStorageSchemeAdapter } from "./shared/storage/localStorageAdapter";
14
14
  export { BackendApiSchemeAdapter } from "./shared/storage/backendApiAdapter";
15
15
 
16
+ // 权限相关类型
17
+
16
18
  // 注意: 旧的查询方案管理功能已废弃
17
19
  // 相关导出已移除,请使用集中式方案管理 API (useSchemeManager/useGridSchemes)