@nokecy/qc-ui 1.1.35 → 1.1.36

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,34 @@ function AgGridPlus(props) {
617
620
  cellRenderer: cellRenderer
618
621
  });
619
622
  });
623
+
624
+ // 【新增】基于 entityType 自动注入扩展列 @author nokecy
625
+ // 从 context 的 hostEntityExtensions 获取对应实体的扩展字段并转换为列定义
626
+ if (entityType && hostEntityExtensions) {
627
+ var extensionCols = (0, _entityExtensionColumns.getEntityExtensionColumns)(entityType, hostEntityExtensions);
628
+ if (extensionCols.length > 0) {
629
+ // 查找操作列位置(pinned='right' 或 field='action')
630
+ var actionIndex = columnDefs.findIndex(function (col) {
631
+ return col.field === 'action' || col.pinned === 'right';
632
+ });
633
+ if (actionIndex === -1) {
634
+ var _columnDefs;
635
+ // 没有操作列,直接追加到末尾
636
+ (_columnDefs = columnDefs).push.apply(_columnDefs, _toConsumableArray(extensionCols));
637
+ } else {
638
+ var _columnDefs2;
639
+ // 插入到操作列之前
640
+ (_columnDefs2 = columnDefs).splice.apply(_columnDefs2, [actionIndex, 0].concat(_toConsumableArray(extensionCols)));
641
+ }
642
+ _logger.logger.debug('[AgGridPlus] 已注入实体扩展列', {
643
+ entityType: entityType,
644
+ extensionColsCount: extensionCols.length,
645
+ extensionCols: extensionCols.map(function (c) {
646
+ return c.field;
647
+ })
648
+ });
649
+ }
650
+ }
620
651
  return columnDefs;
621
652
  };
622
653
 
@@ -643,7 +674,7 @@ function AgGridPlus(props) {
643
674
  });
644
675
  }
645
676
  return cols;
646
- }, [_react.default.Children.count(children), props.columnDefs, extensibleColumns, gridKey]);
677
+ }, [_react.default.Children.count(children), props.columnDefs, extensibleColumns, gridKey, entityType, hostEntityExtensions]);
647
678
 
648
679
  // 稳定化 gridParams 和 sortColumn 的引用
649
680
  var stableGridParams = (0, _react.useMemo)(function () {
@@ -1267,7 +1298,9 @@ function AgGridPlus(props) {
1267
1298
  resetAllUsers: resetAllUsers,
1268
1299
  // ========== 全局方案回退状态 @author nokecy ==========
1269
1300
  isUsingGlobalFallback: isUsingGlobalFallback,
1270
- isUsingGlobalQueryFallback: isUsingGlobalQueryFallback
1301
+ isUsingGlobalQueryFallback: isUsingGlobalQueryFallback,
1302
+ // ========== 实体扩展字段配置 @author nokecy ==========
1303
+ hostEntityExtensions: hostEntityExtensions
1271
1304
  };
1272
1305
  }, [extensibleColumns, gridPlusColumnState, allColDefsRef.current,
1273
1306
  // 【修复】添加到依赖数组
@@ -1279,7 +1312,9 @@ function AgGridPlus(props) {
1279
1312
  // 全局配置依赖
1280
1313
  globalConfigPermissions, applySchemeToGlobal, resetToGlobal, resetAllUsers,
1281
1314
  // 全局方案回退状态依赖 @author nokecy
1282
- isUsingGlobalFallback, isUsingGlobalQueryFallback]);
1315
+ isUsingGlobalFallback, isUsingGlobalQueryFallback,
1316
+ // 实体扩展字段配置依赖 @author nokecy
1317
+ hostEntityExtensions]);
1283
1318
  return /*#__PURE__*/_react.default.createElement(_gridContext.GridPlusContext.Provider, {
1284
1319
  value: gridPlusContextValue
1285
1320
  }, /*#__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,14 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
175
176
  * 是否使用全局查询方案作为回退
176
177
  */
177
178
  isUsingGlobalQueryFallback?: boolean;
179
+ /**
180
+ * 实体扩展字段配置映射
181
+ * key: 实体类型全名 (如 "Burn.Product.Domain.Product")
182
+ * value: 该实体的扩展配置(包含字段定义数组)
183
+ *
184
+ * 来自后端 ABP 配置的 extraProperties.hostEntityExtensions
185
+ * 用于 AgGridPlus 根据 entityType 属性自动注入扩展列
186
+ */
187
+ hostEntityExtensions?: HostEntityExtensions;
178
188
  }
179
189
  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,56 @@ export type RowDataArray<T = any> = T[];
310
310
  * 查询表单项数组类型
311
311
  */
312
312
  export type QueryFormItems = QueryFormItem[];
313
+ /**
314
+ * 扩展字段定义
315
+ * 来自后端 ABP 配置的 hostEntityExtensions
316
+ */
317
+ export interface EntityExtensionField {
318
+ /** 字段名称 */
319
+ name: string;
320
+ /** 显示名称 */
321
+ displayName: string;
322
+ /** 描述信息 */
323
+ description?: string | null;
324
+ /** 数据类型: String, Int, Long, Decimal, Double, Float, Boolean, DateTime, Date, Guid, Enum, Text */
325
+ dataType: string;
326
+ /** 最大长度(字符串类型) */
327
+ maxLength?: number | null;
328
+ /** 精度(数值类型) */
329
+ precision?: number | null;
330
+ /** 小数位数(数值类型) */
331
+ scale?: number | null;
332
+ /** 是否必填 */
333
+ isRequired?: boolean;
334
+ /** 排序顺序 */
335
+ sortOrder?: number;
336
+ /** UI 组件类型 */
337
+ uiComponent?: string | null;
338
+ /** 占位符文本 */
339
+ placeholder?: string | null;
340
+ /** 默认值 */
341
+ defaultValue?: any;
342
+ /** 组件属性(JSON 字符串) */
343
+ componentProps?: string | null;
344
+ /** 验证规则(JSON 字符串) */
345
+ validationRules?: string | null;
346
+ }
347
+ /**
348
+ * 单个实体的扩展配置
349
+ */
350
+ export interface EntityExtensionConfig {
351
+ /** 实体类型全名 (如 "Burn.Product.Domain.Product") */
352
+ entityType: string;
353
+ /** 实体显示名称 */
354
+ displayName: string;
355
+ /** 模块名称 */
356
+ moduleName: string;
357
+ /** 扩展字段列表 */
358
+ fields: EntityExtensionField[];
359
+ }
360
+ /**
361
+ * 所有实体扩展配置映射
362
+ * key: 实体类型全名
363
+ * value: 该实体的扩展配置
364
+ */
365
+ export type HostEntityExtensions = Record<string, EntityExtensionConfig>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 实体扩展字段列转换工具
3
+ * 将后端 ABP 配置的扩展字段转换为 AG-Grid 列定义
4
+ *
5
+ * @author nokecy
6
+ */
7
+ import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
8
+ /**
9
+ * 将单个扩展字段转换为列定义
10
+ *
11
+ * @param field 扩展字段定义
12
+ * @returns AG-Grid 列定义
13
+ */
14
+ export declare function fieldToColumnDef(field: EntityExtensionField): ExtendedColDef;
15
+ /**
16
+ * 获取指定实体的扩展列定义
17
+ *
18
+ * @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
19
+ * @param extensions 实体扩展配置映射
20
+ * @returns 扩展列定义数组,按 sortOrder 排序
21
+ */
22
+ export declare function getEntityExtensionColumns(entityType: string | undefined, extensions?: HostEntityExtensions): ExtendedColDef[];
@@ -0,0 +1,138 @@
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
+ *
97
+ * @param field 扩展字段定义
98
+ * @returns AG-Grid 列定义
99
+ */
100
+ function fieldToColumnDef(field) {
101
+ var config = dataTypeColumnConfig[field.dataType] || {
102
+ width: 150,
103
+ hideInSearch: false
104
+ };
105
+ var colDef = _objectSpread(_objectSpread({
106
+ field: field.name,
107
+ headerName: field.displayName,
108
+ width: config.width,
109
+ hideInSearch: config.hideInSearch
110
+ }, config.type && {
111
+ type: config.type
112
+ }), field.description && {
113
+ headerTooltip: field.description
114
+ });
115
+ return colDef;
116
+ }
117
+
118
+ /**
119
+ * 获取指定实体的扩展列定义
120
+ *
121
+ * @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
122
+ * @param extensions 实体扩展配置映射
123
+ * @returns 扩展列定义数组,按 sortOrder 排序
124
+ */
125
+ function getEntityExtensionColumns(entityType, extensions) {
126
+ // 边界情况处理:无效输入直接返回空数组
127
+ var entityConfig = entityType ? extensions === null || extensions === void 0 ? void 0 : extensions[entityType] : undefined;
128
+ var fields = entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.fields;
129
+ if (!fields || !Array.isArray(fields)) {
130
+ return [];
131
+ }
132
+
133
+ // 按 sortOrder 排序后转换为列定义
134
+ return _toConsumableArray(fields).sort(function (a, b) {
135
+ var _a$sortOrder, _b$sortOrder;
136
+ 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);
137
+ }).map(fieldToColumnDef);
138
+ }
@@ -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,34 @@ function AgGridPlus(props) {
609
612
  cellRenderer: cellRenderer
610
613
  });
611
614
  });
615
+
616
+ // 【新增】基于 entityType 自动注入扩展列 @author nokecy
617
+ // 从 context 的 hostEntityExtensions 获取对应实体的扩展字段并转换为列定义
618
+ if (entityType && hostEntityExtensions) {
619
+ var extensionCols = getEntityExtensionColumns(entityType, hostEntityExtensions);
620
+ if (extensionCols.length > 0) {
621
+ // 查找操作列位置(pinned='right' 或 field='action')
622
+ var actionIndex = columnDefs.findIndex(function (col) {
623
+ return col.field === 'action' || col.pinned === 'right';
624
+ });
625
+ if (actionIndex === -1) {
626
+ var _columnDefs;
627
+ // 没有操作列,直接追加到末尾
628
+ (_columnDefs = columnDefs).push.apply(_columnDefs, _toConsumableArray(extensionCols));
629
+ } else {
630
+ var _columnDefs2;
631
+ // 插入到操作列之前
632
+ (_columnDefs2 = columnDefs).splice.apply(_columnDefs2, [actionIndex, 0].concat(_toConsumableArray(extensionCols)));
633
+ }
634
+ logger.debug('[AgGridPlus] 已注入实体扩展列', {
635
+ entityType: entityType,
636
+ extensionColsCount: extensionCols.length,
637
+ extensionCols: extensionCols.map(function (c) {
638
+ return c.field;
639
+ })
640
+ });
641
+ }
642
+ }
612
643
  return columnDefs;
613
644
  };
614
645
 
@@ -635,7 +666,7 @@ function AgGridPlus(props) {
635
666
  });
636
667
  }
637
668
  return cols;
638
- }, [React.Children.count(children), props.columnDefs, extensibleColumns, gridKey]);
669
+ }, [React.Children.count(children), props.columnDefs, extensibleColumns, gridKey, entityType, hostEntityExtensions]);
639
670
 
640
671
  // 稳定化 gridParams 和 sortColumn 的引用
641
672
  var stableGridParams = useMemo(function () {
@@ -1259,7 +1290,9 @@ function AgGridPlus(props) {
1259
1290
  resetAllUsers: resetAllUsers,
1260
1291
  // ========== 全局方案回退状态 @author nokecy ==========
1261
1292
  isUsingGlobalFallback: isUsingGlobalFallback,
1262
- isUsingGlobalQueryFallback: isUsingGlobalQueryFallback
1293
+ isUsingGlobalQueryFallback: isUsingGlobalQueryFallback,
1294
+ // ========== 实体扩展字段配置 @author nokecy ==========
1295
+ hostEntityExtensions: hostEntityExtensions
1263
1296
  };
1264
1297
  }, [extensibleColumns, gridPlusColumnState, allColDefsRef.current,
1265
1298
  // 【修复】添加到依赖数组
@@ -1271,7 +1304,9 @@ function AgGridPlus(props) {
1271
1304
  // 全局配置依赖
1272
1305
  globalConfigPermissions, applySchemeToGlobal, resetToGlobal, resetAllUsers,
1273
1306
  // 全局方案回退状态依赖 @author nokecy
1274
- isUsingGlobalFallback, isUsingGlobalQueryFallback]);
1307
+ isUsingGlobalFallback, isUsingGlobalQueryFallback,
1308
+ // 实体扩展字段配置依赖 @author nokecy
1309
+ hostEntityExtensions]);
1275
1310
  return /*#__PURE__*/React.createElement(GridPlusContext.Provider, {
1276
1311
  value: gridPlusContextValue
1277
1312
  }, /*#__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,14 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
175
176
  * 是否使用全局查询方案作为回退
176
177
  */
177
178
  isUsingGlobalQueryFallback?: boolean;
179
+ /**
180
+ * 实体扩展字段配置映射
181
+ * key: 实体类型全名 (如 "Burn.Product.Domain.Product")
182
+ * value: 该实体的扩展配置(包含字段定义数组)
183
+ *
184
+ * 来自后端 ABP 配置的 extraProperties.hostEntityExtensions
185
+ * 用于 AgGridPlus 根据 entityType 属性自动注入扩展列
186
+ */
187
+ hostEntityExtensions?: HostEntityExtensions;
178
188
  }
179
189
  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,56 @@ export type RowDataArray<T = any> = T[];
310
310
  * 查询表单项数组类型
311
311
  */
312
312
  export type QueryFormItems = QueryFormItem[];
313
+ /**
314
+ * 扩展字段定义
315
+ * 来自后端 ABP 配置的 hostEntityExtensions
316
+ */
317
+ export interface EntityExtensionField {
318
+ /** 字段名称 */
319
+ name: string;
320
+ /** 显示名称 */
321
+ displayName: string;
322
+ /** 描述信息 */
323
+ description?: string | null;
324
+ /** 数据类型: String, Int, Long, Decimal, Double, Float, Boolean, DateTime, Date, Guid, Enum, Text */
325
+ dataType: string;
326
+ /** 最大长度(字符串类型) */
327
+ maxLength?: number | null;
328
+ /** 精度(数值类型) */
329
+ precision?: number | null;
330
+ /** 小数位数(数值类型) */
331
+ scale?: number | null;
332
+ /** 是否必填 */
333
+ isRequired?: boolean;
334
+ /** 排序顺序 */
335
+ sortOrder?: number;
336
+ /** UI 组件类型 */
337
+ uiComponent?: string | null;
338
+ /** 占位符文本 */
339
+ placeholder?: string | null;
340
+ /** 默认值 */
341
+ defaultValue?: any;
342
+ /** 组件属性(JSON 字符串) */
343
+ componentProps?: string | null;
344
+ /** 验证规则(JSON 字符串) */
345
+ validationRules?: string | null;
346
+ }
347
+ /**
348
+ * 单个实体的扩展配置
349
+ */
350
+ export interface EntityExtensionConfig {
351
+ /** 实体类型全名 (如 "Burn.Product.Domain.Product") */
352
+ entityType: string;
353
+ /** 实体显示名称 */
354
+ displayName: string;
355
+ /** 模块名称 */
356
+ moduleName: string;
357
+ /** 扩展字段列表 */
358
+ fields: EntityExtensionField[];
359
+ }
360
+ /**
361
+ * 所有实体扩展配置映射
362
+ * key: 实体类型全名
363
+ * value: 该实体的扩展配置
364
+ */
365
+ export type HostEntityExtensions = Record<string, EntityExtensionConfig>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 实体扩展字段列转换工具
3
+ * 将后端 ABP 配置的扩展字段转换为 AG-Grid 列定义
4
+ *
5
+ * @author nokecy
6
+ */
7
+ import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
8
+ /**
9
+ * 将单个扩展字段转换为列定义
10
+ *
11
+ * @param field 扩展字段定义
12
+ * @returns AG-Grid 列定义
13
+ */
14
+ export declare function fieldToColumnDef(field: EntityExtensionField): ExtendedColDef;
15
+ /**
16
+ * 获取指定实体的扩展列定义
17
+ *
18
+ * @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
19
+ * @param extensions 实体扩展配置映射
20
+ * @returns 扩展列定义数组,按 sortOrder 排序
21
+ */
22
+ export declare function getEntityExtensionColumns(entityType: string | undefined, extensions?: HostEntityExtensions): ExtendedColDef[];