@nokecy/qc-ui 1.1.35 → 1.1.37

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.
@@ -35,7 +35,8 @@ var _schemeDataMigration = require("./shared/utils/schemeDataMigration");
35
35
  var _sanitize = require("./utils/sanitize");
36
36
  var _errors = require("./errors");
37
37
  var _logger = require("./utils/logger");
38
- var _excluded = ["style", "loading", "params", "request", "dataSource", "treeKeyName", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "children", "defaultSearchExpand", "overlayNoRowsTemplateText", "queryDefaultRows", "onSelectedRowsChange", "enableClickSelection", "rowSelection", "useNativeTreeFilter"];
38
+ var _entityExtensionColumns = require("./utils/entityExtensionColumns");
39
+ var _excluded = ["style", "loading", "params", "request", "dataSource", "treeKeyName", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "children", "defaultSearchExpand", "overlayNoRowsTemplateText", "queryDefaultRows", "onSelectedRowsChange", "enableClickSelection", "rowSelection", "useNativeTreeFilter", "entityType"];
39
40
  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); }
40
41
  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; }
41
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -93,6 +94,7 @@ function AgGridPlus(props) {
93
94
  propsRowSelection = props.rowSelection,
94
95
  _props$useNativeTreeF = props.useNativeTreeFilter,
95
96
  useNativeTreeFilter = _props$useNativeTreeF === void 0 ? false : _props$useNativeTreeF,
97
+ entityType = props.entityType,
96
98
  rest = _objectWithoutProperties(props, _excluded);
97
99
  var _useGridPlusColumnSta = (0, _.useGridPlusColumnState)(),
98
100
  onSaveColumnState = _useGridPlusColumnSta.onSaveColumnState,
@@ -104,7 +106,8 @@ function AgGridPlus(props) {
104
106
  globalConfigPermissions = _useGridPlusColumnSta.globalConfigPermissions,
105
107
  applySchemeToGlobal = _useGridPlusColumnSta.applySchemeToGlobal,
106
108
  resetToGlobal = _useGridPlusColumnSta.resetToGlobal,
107
- resetAllUsers = _useGridPlusColumnSta.resetAllUsers;
109
+ resetAllUsers = _useGridPlusColumnSta.resetAllUsers,
110
+ hostEntityExtensions = _useGridPlusColumnSta.hostEntityExtensions;
108
111
  var gridRef = (0, _react.useRef)();
109
112
  var apiRef = (0, _react.useRef)();
110
113
  var allColDefsRef = (0, _react.useRef)([]);
@@ -617,6 +620,30 @@ function AgGridPlus(props) {
617
620
  cellRenderer: cellRenderer
618
621
  });
619
622
  });
623
+
624
+ // 基于 entityType 自动注入扩展列 @author nokecy
625
+ // 从 context 的 hostEntityExtensions 获取对应实体的扩展字段并转换为列定义
626
+ var extensionCols = (0, _entityExtensionColumns.getEntityExtensionColumns)(entityType, hostEntityExtensions);
627
+ if (extensionCols.length > 0) {
628
+ // 查找操作列位置(pinned='right' 或 field='action'),插入到其之前
629
+ var actionIndex = columnDefs.findIndex(function (col) {
630
+ return col.field === 'action' || col.pinned === 'right';
631
+ });
632
+ if (actionIndex === -1) {
633
+ var _columnDefs;
634
+ (_columnDefs = columnDefs).push.apply(_columnDefs, _toConsumableArray(extensionCols));
635
+ } else {
636
+ var _columnDefs2;
637
+ (_columnDefs2 = columnDefs).splice.apply(_columnDefs2, [actionIndex, 0].concat(_toConsumableArray(extensionCols)));
638
+ }
639
+ _logger.logger.debug('[AgGridPlus] 已注入实体扩展列', {
640
+ entityType: entityType,
641
+ extensionColsCount: extensionCols.length,
642
+ extensionCols: extensionCols.map(function (c) {
643
+ return c.field;
644
+ })
645
+ });
646
+ }
620
647
  return columnDefs;
621
648
  };
622
649
 
@@ -643,7 +670,7 @@ function AgGridPlus(props) {
643
670
  });
644
671
  }
645
672
  return cols;
646
- }, [_react.default.Children.count(children), props.columnDefs, extensibleColumns, gridKey]);
673
+ }, [_react.default.Children.count(children), props.columnDefs, extensibleColumns, gridKey, entityType, hostEntityExtensions]);
647
674
 
648
675
  // 稳定化 gridParams 和 sortColumn 的引用
649
676
  var stableGridParams = (0, _react.useMemo)(function () {
@@ -1267,7 +1294,9 @@ function AgGridPlus(props) {
1267
1294
  resetAllUsers: resetAllUsers,
1268
1295
  // ========== 全局方案回退状态 @author nokecy ==========
1269
1296
  isUsingGlobalFallback: isUsingGlobalFallback,
1270
- isUsingGlobalQueryFallback: isUsingGlobalQueryFallback
1297
+ isUsingGlobalQueryFallback: isUsingGlobalQueryFallback,
1298
+ // ========== 实体扩展字段配置 @author nokecy ==========
1299
+ hostEntityExtensions: hostEntityExtensions
1271
1300
  };
1272
1301
  }, [extensibleColumns, gridPlusColumnState, allColDefsRef.current,
1273
1302
  // 【修复】添加到依赖数组
@@ -1279,7 +1308,9 @@ function AgGridPlus(props) {
1279
1308
  // 全局配置依赖
1280
1309
  globalConfigPermissions, applySchemeToGlobal, resetToGlobal, resetAllUsers,
1281
1310
  // 全局方案回退状态依赖 @author nokecy
1282
- isUsingGlobalFallback, isUsingGlobalQueryFallback]);
1311
+ isUsingGlobalFallback, isUsingGlobalQueryFallback,
1312
+ // 实体扩展字段配置依赖 @author nokecy
1313
+ hostEntityExtensions]);
1283
1314
  return /*#__PURE__*/_react.default.createElement(_gridContext.GridPlusContext.Provider, {
1284
1315
  value: gridPlusContextValue
1285
1316
  }, /*#__PURE__*/_react.default.createElement(_antd.Spin, {
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import type { ColumnScheme, QueryScheme, CurrentSchemeDto } from "../shared/storage/schemeStorageAdapter";
3
3
  import type { GlobalConfigPermissions } from '../shared/permissions/globalConfigPermissions';
4
+ import type { HostEntityExtensions } from '../types';
4
5
  /**
5
6
  * 方案管理 API 接口
6
7
  *
@@ -175,5 +176,10 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
175
176
  * 是否使用全局查询方案作为回退
176
177
  */
177
178
  isUsingGlobalQueryFallback?: boolean;
179
+ /**
180
+ * 实体扩展字段配置映射
181
+ * 来自后端 ABP 配置,用于 AgGridPlus 根据 entityType 自动注入扩展列
182
+ */
183
+ hostEntityExtensions?: HostEntityExtensions;
178
184
  }
179
185
  export declare const GridPlusContext: React.Context<GridPlusContextValue>;
@@ -13,3 +13,5 @@ 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
15
  export type { GlobalConfigPermissions } from "./shared/permissions/globalConfigPermissions";
16
+ export type { EntityExtensionField, EntityExtensionConfig, HostEntityExtensions } from "./types";
17
+ export { fieldToColumnDef, getEntityExtensionColumns } from "./utils/entityExtensionColumns";
@@ -57,6 +57,12 @@ Object.defineProperty(exports, "dateValueFormatter", {
57
57
  return _utils.dateValueFormatter;
58
58
  }
59
59
  });
60
+ Object.defineProperty(exports, "fieldToColumnDef", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _entityExtensionColumns.fieldToColumnDef;
64
+ }
65
+ });
60
66
  Object.defineProperty(exports, "flatten", {
61
67
  enumerable: true,
62
68
  get: function get() {
@@ -69,6 +75,12 @@ Object.defineProperty(exports, "flattenTreeDeep", {
69
75
  return _utils.flattenTreeDeep;
70
76
  }
71
77
  });
78
+ Object.defineProperty(exports, "getEntityExtensionColumns", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _entityExtensionColumns.getEntityExtensionColumns;
82
+ }
83
+ });
72
84
  Object.defineProperty(exports, "toTree", {
73
85
  enumerable: true,
74
86
  get: function get() {
@@ -101,4 +113,5 @@ var _utils = require("./utils");
101
113
  var _useSchemeManager = require("./context/useSchemeManager");
102
114
  var _localStorageAdapter = require("./shared/storage/localStorageAdapter");
103
115
  var _backendApiAdapter = require("./shared/storage/backendApiAdapter");
116
+ var _entityExtensionColumns = require("./utils/entityExtensionColumns");
104
117
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -95,6 +95,15 @@ interface GridProps extends AgGridReactProps {
95
95
  * @default false
96
96
  */
97
97
  useNativeTreeFilter?: boolean;
98
+ /**
99
+ * 实体类型全名,用于自动注入扩展字段列
100
+ * 当配置此属性时,组件会自动从 context 的 hostEntityExtensions
101
+ * 获取对应实体的扩展字段并转换为列定义
102
+ *
103
+ * @example "Burn.Product.Domain.Product"
104
+ * @author nokecy
105
+ */
106
+ entityType?: string;
98
107
  }
99
108
  interface AgGridColumnPropsClone extends ColDef {
100
109
  /**
@@ -310,3 +310,36 @@ export type RowDataArray<T = any> = T[];
310
310
  * 查询表单项数组类型
311
311
  */
312
312
  export type QueryFormItems = QueryFormItem[];
313
+ /**
314
+ * 扩展字段定义(来自后端 ABP 配置)
315
+ */
316
+ export interface EntityExtensionField {
317
+ name: string;
318
+ displayName: string;
319
+ description?: string | null;
320
+ /** 数据类型: String, Int, Long, Decimal, Double, Float, Boolean, DateTime, Date, Guid, Enum, Text */
321
+ dataType: string;
322
+ maxLength?: number | null;
323
+ precision?: number | null;
324
+ scale?: number | null;
325
+ isRequired?: boolean;
326
+ sortOrder?: number;
327
+ uiComponent?: string | null;
328
+ placeholder?: string | null;
329
+ defaultValue?: any;
330
+ componentProps?: string | null;
331
+ validationRules?: string | null;
332
+ }
333
+ /**
334
+ * 单个实体的扩展配置
335
+ */
336
+ export interface EntityExtensionConfig {
337
+ entityType: string;
338
+ displayName: string;
339
+ moduleName: string;
340
+ fields: EntityExtensionField[];
341
+ }
342
+ /**
343
+ * 实体扩展配置映射(key: 实体类型全名)
344
+ */
345
+ export type HostEntityExtensions = Record<string, EntityExtensionConfig>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 实体扩展字段列转换工具
3
+ * 将后端 ABP 配置的扩展字段转换为 AG-Grid 列定义
4
+ *
5
+ * @author nokecy
6
+ */
7
+ import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
8
+ /**
9
+ * 将单个扩展字段转换为列定义
10
+ * 使用 extraProperties.xxx 嵌套路径访问数据
11
+ *
12
+ * @param field 扩展字段定义
13
+ * @returns AG-Grid 列定义
14
+ */
15
+ export declare function fieldToColumnDef(field: EntityExtensionField): ExtendedColDef;
16
+ /**
17
+ * 获取指定实体的扩展列定义
18
+ *
19
+ * @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
20
+ * @param extensions 实体扩展配置映射
21
+ * @returns 扩展列定义数组,按 sortOrder 排序
22
+ */
23
+ export declare function getEntityExtensionColumns(entityType: string | undefined, extensions?: HostEntityExtensions): ExtendedColDef[];
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fieldToColumnDef = fieldToColumnDef;
7
+ exports.getEntityExtensionColumns = getEntityExtensionColumns;
8
+ 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); }
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+ 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."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+ 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; }
15
+ 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; }
16
+ 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; }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
+ 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); }
20
+ /**
21
+ * 实体扩展字段列转换工具
22
+ * 将后端 ABP 配置的扩展字段转换为 AG-Grid 列定义
23
+ *
24
+ * @author nokecy
25
+ */
26
+
27
+ /**
28
+ * 数据类型到列配置的映射
29
+ * 根据字段的数据类型自动配置列宽度、是否可搜索、列类型等
30
+ */
31
+ var dataTypeColumnConfig = {
32
+ // 字符串类型
33
+ String: {
34
+ width: 150,
35
+ hideInSearch: false
36
+ },
37
+ Text: {
38
+ width: 200,
39
+ hideInSearch: true
40
+ },
41
+ // 数值类型
42
+ Int: {
43
+ width: 100,
44
+ hideInSearch: true,
45
+ type: 'numberColumn'
46
+ },
47
+ Long: {
48
+ width: 100,
49
+ hideInSearch: true,
50
+ type: 'numberColumn'
51
+ },
52
+ Decimal: {
53
+ width: 120,
54
+ hideInSearch: true,
55
+ type: 'numberColumn'
56
+ },
57
+ Double: {
58
+ width: 120,
59
+ hideInSearch: true,
60
+ type: 'numberColumn'
61
+ },
62
+ Float: {
63
+ width: 120,
64
+ hideInSearch: true,
65
+ type: 'numberColumn'
66
+ },
67
+ // 布尔类型
68
+ Boolean: {
69
+ width: 80,
70
+ hideInSearch: false
71
+ },
72
+ // 日期时间类型
73
+ DateTime: {
74
+ width: 160,
75
+ hideInSearch: true,
76
+ type: 'dateTimeColumn'
77
+ },
78
+ Date: {
79
+ width: 120,
80
+ hideInSearch: true,
81
+ type: 'dateColumn'
82
+ },
83
+ // 其他类型
84
+ Guid: {
85
+ width: 280,
86
+ hideInSearch: false
87
+ },
88
+ Enum: {
89
+ width: 100,
90
+ hideInSearch: false
91
+ }
92
+ };
93
+
94
+ /**
95
+ * 将单个扩展字段转换为列定义
96
+ * 使用 extraProperties.xxx 嵌套路径访问数据
97
+ *
98
+ * @param field 扩展字段定义
99
+ * @returns AG-Grid 列定义
100
+ */
101
+ function fieldToColumnDef(field) {
102
+ var config = dataTypeColumnConfig[field.dataType] || {
103
+ width: 150,
104
+ hideInSearch: false
105
+ };
106
+ var colDef = _objectSpread(_objectSpread({
107
+ // 使用嵌套路径访问 extraProperties 中的数据 @author nokecy
108
+ field: "extraProperties.".concat(field.name),
109
+ headerName: field.displayName,
110
+ width: config.width,
111
+ hideInSearch: config.hideInSearch
112
+ }, config.type && {
113
+ type: config.type
114
+ }), field.description && {
115
+ headerTooltip: field.description
116
+ });
117
+ return colDef;
118
+ }
119
+
120
+ /**
121
+ * 获取指定实体的扩展列定义
122
+ *
123
+ * @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
124
+ * @param extensions 实体扩展配置映射
125
+ * @returns 扩展列定义数组,按 sortOrder 排序
126
+ */
127
+ function getEntityExtensionColumns(entityType, extensions) {
128
+ // 边界情况处理:无效输入直接返回空数组
129
+ var entityConfig = entityType ? extensions === null || extensions === void 0 ? void 0 : extensions[entityType] : undefined;
130
+ var fields = entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.fields;
131
+ if (!fields || !Array.isArray(fields)) {
132
+ return [];
133
+ }
134
+
135
+ // 按 sortOrder 排序后转换为列定义
136
+ return _toConsumableArray(fields).sort(function (a, b) {
137
+ var _a$sortOrder, _b$sortOrder;
138
+ return ((_a$sortOrder = a.sortOrder) !== null && _a$sortOrder !== void 0 ? _a$sortOrder : 0) - ((_b$sortOrder = b.sortOrder) !== null && _b$sortOrder !== void 0 ? _b$sortOrder : 0);
139
+ }).map(fieldToColumnDef);
140
+ }
@@ -1,7 +1,7 @@
1
1
  import _sumBy from "lodash/sumBy";
2
2
  import _uniqueId from "lodash/uniqueId";
3
3
  import _isArray from "lodash/isArray";
4
- var _excluded = ["style", "loading", "params", "request", "dataSource", "treeKeyName", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "children", "defaultSearchExpand", "overlayNoRowsTemplateText", "queryDefaultRows", "onSelectedRowsChange", "enableClickSelection", "rowSelection", "useNativeTreeFilter"];
4
+ var _excluded = ["style", "loading", "params", "request", "dataSource", "treeKeyName", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "children", "defaultSearchExpand", "overlayNoRowsTemplateText", "queryDefaultRows", "onSelectedRowsChange", "enableClickSelection", "rowSelection", "useNativeTreeFilter", "entityType"];
5
5
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
7
  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."); }
@@ -54,6 +54,7 @@ import { extractItemsOrder, extractHiddenFields } from "./shared/utils/schemeDat
54
54
  import { createSafeHtmlTemplate } from "./utils/sanitize";
55
55
  import { GridPlusError, ErrorType, ErrorSeverity } from "./errors";
56
56
  import { logger } from "./utils/logger";
57
+ import { getEntityExtensionColumns } from "./utils/entityExtensionColumns";
57
58
  import { message } from 'antd';
58
59
  var Text = Typography.Text;
59
60
  var getSort = function getSort(columnState) {
@@ -85,6 +86,7 @@ function AgGridPlus(props) {
85
86
  propsRowSelection = props.rowSelection,
86
87
  _props$useNativeTreeF = props.useNativeTreeFilter,
87
88
  useNativeTreeFilter = _props$useNativeTreeF === void 0 ? false : _props$useNativeTreeF,
89
+ entityType = props.entityType,
88
90
  rest = _objectWithoutProperties(props, _excluded);
89
91
  var _useGridPlusColumnSta = useGridPlusColumnState(),
90
92
  onSaveColumnState = _useGridPlusColumnSta.onSaveColumnState,
@@ -96,7 +98,8 @@ function AgGridPlus(props) {
96
98
  globalConfigPermissions = _useGridPlusColumnSta.globalConfigPermissions,
97
99
  applySchemeToGlobal = _useGridPlusColumnSta.applySchemeToGlobal,
98
100
  resetToGlobal = _useGridPlusColumnSta.resetToGlobal,
99
- resetAllUsers = _useGridPlusColumnSta.resetAllUsers;
101
+ resetAllUsers = _useGridPlusColumnSta.resetAllUsers,
102
+ hostEntityExtensions = _useGridPlusColumnSta.hostEntityExtensions;
100
103
  var gridRef = useRef();
101
104
  var apiRef = useRef();
102
105
  var allColDefsRef = useRef([]);
@@ -609,6 +612,30 @@ function AgGridPlus(props) {
609
612
  cellRenderer: cellRenderer
610
613
  });
611
614
  });
615
+
616
+ // 基于 entityType 自动注入扩展列 @author nokecy
617
+ // 从 context 的 hostEntityExtensions 获取对应实体的扩展字段并转换为列定义
618
+ var extensionCols = getEntityExtensionColumns(entityType, hostEntityExtensions);
619
+ if (extensionCols.length > 0) {
620
+ // 查找操作列位置(pinned='right' 或 field='action'),插入到其之前
621
+ var actionIndex = columnDefs.findIndex(function (col) {
622
+ return col.field === 'action' || col.pinned === 'right';
623
+ });
624
+ if (actionIndex === -1) {
625
+ var _columnDefs;
626
+ (_columnDefs = columnDefs).push.apply(_columnDefs, _toConsumableArray(extensionCols));
627
+ } else {
628
+ var _columnDefs2;
629
+ (_columnDefs2 = columnDefs).splice.apply(_columnDefs2, [actionIndex, 0].concat(_toConsumableArray(extensionCols)));
630
+ }
631
+ logger.debug('[AgGridPlus] 已注入实体扩展列', {
632
+ entityType: entityType,
633
+ extensionColsCount: extensionCols.length,
634
+ extensionCols: extensionCols.map(function (c) {
635
+ return c.field;
636
+ })
637
+ });
638
+ }
612
639
  return columnDefs;
613
640
  };
614
641
 
@@ -635,7 +662,7 @@ function AgGridPlus(props) {
635
662
  });
636
663
  }
637
664
  return cols;
638
- }, [React.Children.count(children), props.columnDefs, extensibleColumns, gridKey]);
665
+ }, [React.Children.count(children), props.columnDefs, extensibleColumns, gridKey, entityType, hostEntityExtensions]);
639
666
 
640
667
  // 稳定化 gridParams 和 sortColumn 的引用
641
668
  var stableGridParams = useMemo(function () {
@@ -1259,7 +1286,9 @@ function AgGridPlus(props) {
1259
1286
  resetAllUsers: resetAllUsers,
1260
1287
  // ========== 全局方案回退状态 @author nokecy ==========
1261
1288
  isUsingGlobalFallback: isUsingGlobalFallback,
1262
- isUsingGlobalQueryFallback: isUsingGlobalQueryFallback
1289
+ isUsingGlobalQueryFallback: isUsingGlobalQueryFallback,
1290
+ // ========== 实体扩展字段配置 @author nokecy ==========
1291
+ hostEntityExtensions: hostEntityExtensions
1263
1292
  };
1264
1293
  }, [extensibleColumns, gridPlusColumnState, allColDefsRef.current,
1265
1294
  // 【修复】添加到依赖数组
@@ -1271,7 +1300,9 @@ function AgGridPlus(props) {
1271
1300
  // 全局配置依赖
1272
1301
  globalConfigPermissions, applySchemeToGlobal, resetToGlobal, resetAllUsers,
1273
1302
  // 全局方案回退状态依赖 @author nokecy
1274
- isUsingGlobalFallback, isUsingGlobalQueryFallback]);
1303
+ isUsingGlobalFallback, isUsingGlobalQueryFallback,
1304
+ // 实体扩展字段配置依赖 @author nokecy
1305
+ hostEntityExtensions]);
1275
1306
  return /*#__PURE__*/React.createElement(GridPlusContext.Provider, {
1276
1307
  value: gridPlusContextValue
1277
1308
  }, /*#__PURE__*/React.createElement(Spin, {
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import type { ColumnScheme, QueryScheme, CurrentSchemeDto } from "../shared/storage/schemeStorageAdapter";
3
3
  import type { GlobalConfigPermissions } from '../shared/permissions/globalConfigPermissions';
4
+ import type { HostEntityExtensions } from '../types';
4
5
  /**
5
6
  * 方案管理 API 接口
6
7
  *
@@ -175,5 +176,10 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
175
176
  * 是否使用全局查询方案作为回退
176
177
  */
177
178
  isUsingGlobalQueryFallback?: boolean;
179
+ /**
180
+ * 实体扩展字段配置映射
181
+ * 来自后端 ABP 配置,用于 AgGridPlus 根据 entityType 自动注入扩展列
182
+ */
183
+ hostEntityExtensions?: HostEntityExtensions;
178
184
  }
179
185
  export declare const GridPlusContext: React.Context<GridPlusContextValue>;
@@ -13,3 +13,5 @@ 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
15
  export type { GlobalConfigPermissions } from "./shared/permissions/globalConfigPermissions";
16
+ export type { EntityExtensionField, EntityExtensionConfig, HostEntityExtensions } from "./types";
17
+ export { fieldToColumnDef, getEntityExtensionColumns } from "./utils/entityExtensionColumns";
@@ -15,5 +15,10 @@ export { BackendApiSchemeAdapter } from "./shared/storage/backendApiAdapter";
15
15
 
16
16
  // 权限相关类型
17
17
 
18
+ // 实体扩展字段类型 @author nokecy
19
+
20
+ // 实体扩展列工具函数 @author nokecy
21
+ export { fieldToColumnDef, getEntityExtensionColumns } from "./utils/entityExtensionColumns";
22
+
18
23
  // 注意: 旧的查询方案管理功能已废弃
19
24
  // 相关导出已移除,请使用集中式方案管理 API (useSchemeManager/useGridSchemes)
@@ -95,6 +95,15 @@ interface GridProps extends AgGridReactProps {
95
95
  * @default false
96
96
  */
97
97
  useNativeTreeFilter?: boolean;
98
+ /**
99
+ * 实体类型全名,用于自动注入扩展字段列
100
+ * 当配置此属性时,组件会自动从 context 的 hostEntityExtensions
101
+ * 获取对应实体的扩展字段并转换为列定义
102
+ *
103
+ * @example "Burn.Product.Domain.Product"
104
+ * @author nokecy
105
+ */
106
+ entityType?: string;
98
107
  }
99
108
  interface AgGridColumnPropsClone extends ColDef {
100
109
  /**
@@ -310,3 +310,36 @@ export type RowDataArray<T = any> = T[];
310
310
  * 查询表单项数组类型
311
311
  */
312
312
  export type QueryFormItems = QueryFormItem[];
313
+ /**
314
+ * 扩展字段定义(来自后端 ABP 配置)
315
+ */
316
+ export interface EntityExtensionField {
317
+ name: string;
318
+ displayName: string;
319
+ description?: string | null;
320
+ /** 数据类型: String, Int, Long, Decimal, Double, Float, Boolean, DateTime, Date, Guid, Enum, Text */
321
+ dataType: string;
322
+ maxLength?: number | null;
323
+ precision?: number | null;
324
+ scale?: number | null;
325
+ isRequired?: boolean;
326
+ sortOrder?: number;
327
+ uiComponent?: string | null;
328
+ placeholder?: string | null;
329
+ defaultValue?: any;
330
+ componentProps?: string | null;
331
+ validationRules?: string | null;
332
+ }
333
+ /**
334
+ * 单个实体的扩展配置
335
+ */
336
+ export interface EntityExtensionConfig {
337
+ entityType: string;
338
+ displayName: string;
339
+ moduleName: string;
340
+ fields: EntityExtensionField[];
341
+ }
342
+ /**
343
+ * 实体扩展配置映射(key: 实体类型全名)
344
+ */
345
+ export type HostEntityExtensions = Record<string, EntityExtensionConfig>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 实体扩展字段列转换工具
3
+ * 将后端 ABP 配置的扩展字段转换为 AG-Grid 列定义
4
+ *
5
+ * @author nokecy
6
+ */
7
+ import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
8
+ /**
9
+ * 将单个扩展字段转换为列定义
10
+ * 使用 extraProperties.xxx 嵌套路径访问数据
11
+ *
12
+ * @param field 扩展字段定义
13
+ * @returns AG-Grid 列定义
14
+ */
15
+ export declare function fieldToColumnDef(field: EntityExtensionField): ExtendedColDef;
16
+ /**
17
+ * 获取指定实体的扩展列定义
18
+ *
19
+ * @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
20
+ * @param extensions 实体扩展配置映射
21
+ * @returns 扩展列定义数组,按 sortOrder 排序
22
+ */
23
+ export declare function getEntityExtensionColumns(entityType: string | undefined, extensions?: HostEntityExtensions): ExtendedColDef[];