@nokecy/qc-ui 1.1.36 → 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.
@@ -621,32 +621,28 @@ function AgGridPlus(props) {
621
621
  });
622
622
  });
623
623
 
624
- // 【新增】基于 entityType 自动注入扩展列 @author nokecy
624
+ // 基于 entityType 自动注入扩展列 @author nokecy
625
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
- });
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)));
649
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
+ });
650
646
  }
651
647
  return columnDefs;
652
648
  };
@@ -178,11 +178,7 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
178
178
  isUsingGlobalQueryFallback?: boolean;
179
179
  /**
180
180
  * 实体扩展字段配置映射
181
- * key: 实体类型全名 (如 "Burn.Product.Domain.Product")
182
- * value: 该实体的扩展配置(包含字段定义数组)
183
- *
184
- * 来自后端 ABP 配置的 extraProperties.hostEntityExtensions
185
- * 用于 AgGridPlus 根据 entityType 属性自动注入扩展列
181
+ * 来自后端 ABP 配置,用于 AgGridPlus 根据 entityType 自动注入扩展列
186
182
  */
187
183
  hostEntityExtensions?: HostEntityExtensions;
188
184
  }
@@ -311,55 +311,35 @@ export type RowDataArray<T = any> = T[];
311
311
  */
312
312
  export type QueryFormItems = QueryFormItem[];
313
313
  /**
314
- * 扩展字段定义
315
- * 来自后端 ABP 配置的 hostEntityExtensions
314
+ * 扩展字段定义(来自后端 ABP 配置)
316
315
  */
317
316
  export interface EntityExtensionField {
318
- /** 字段名称 */
319
317
  name: string;
320
- /** 显示名称 */
321
318
  displayName: string;
322
- /** 描述信息 */
323
319
  description?: string | null;
324
320
  /** 数据类型: String, Int, Long, Decimal, Double, Float, Boolean, DateTime, Date, Guid, Enum, Text */
325
321
  dataType: string;
326
- /** 最大长度(字符串类型) */
327
322
  maxLength?: number | null;
328
- /** 精度(数值类型) */
329
323
  precision?: number | null;
330
- /** 小数位数(数值类型) */
331
324
  scale?: number | null;
332
- /** 是否必填 */
333
325
  isRequired?: boolean;
334
- /** 排序顺序 */
335
326
  sortOrder?: number;
336
- /** UI 组件类型 */
337
327
  uiComponent?: string | null;
338
- /** 占位符文本 */
339
328
  placeholder?: string | null;
340
- /** 默认值 */
341
329
  defaultValue?: any;
342
- /** 组件属性(JSON 字符串) */
343
330
  componentProps?: string | null;
344
- /** 验证规则(JSON 字符串) */
345
331
  validationRules?: string | null;
346
332
  }
347
333
  /**
348
334
  * 单个实体的扩展配置
349
335
  */
350
336
  export interface EntityExtensionConfig {
351
- /** 实体类型全名 (如 "Burn.Product.Domain.Product") */
352
337
  entityType: string;
353
- /** 实体显示名称 */
354
338
  displayName: string;
355
- /** 模块名称 */
356
339
  moduleName: string;
357
- /** 扩展字段列表 */
358
340
  fields: EntityExtensionField[];
359
341
  }
360
342
  /**
361
- * 所有实体扩展配置映射
362
- * key: 实体类型全名
363
- * value: 该实体的扩展配置
343
+ * 实体扩展配置映射(key: 实体类型全名)
364
344
  */
365
345
  export type HostEntityExtensions = Record<string, EntityExtensionConfig>;
@@ -7,6 +7,7 @@
7
7
  import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
8
8
  /**
9
9
  * 将单个扩展字段转换为列定义
10
+ * 使用 extraProperties.xxx 嵌套路径访问数据
10
11
  *
11
12
  * @param field 扩展字段定义
12
13
  * @returns AG-Grid 列定义
@@ -93,6 +93,7 @@ var dataTypeColumnConfig = {
93
93
 
94
94
  /**
95
95
  * 将单个扩展字段转换为列定义
96
+ * 使用 extraProperties.xxx 嵌套路径访问数据
96
97
  *
97
98
  * @param field 扩展字段定义
98
99
  * @returns AG-Grid 列定义
@@ -103,7 +104,8 @@ function fieldToColumnDef(field) {
103
104
  hideInSearch: false
104
105
  };
105
106
  var colDef = _objectSpread(_objectSpread({
106
- field: field.name,
107
+ // 使用嵌套路径访问 extraProperties 中的数据 @author nokecy
108
+ field: "extraProperties.".concat(field.name),
107
109
  headerName: field.displayName,
108
110
  width: config.width,
109
111
  hideInSearch: config.hideInSearch
@@ -613,32 +613,28 @@ function AgGridPlus(props) {
613
613
  });
614
614
  });
615
615
 
616
- // 【新增】基于 entityType 自动注入扩展列 @author nokecy
616
+ // 基于 entityType 自动注入扩展列 @author nokecy
617
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
- });
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)));
641
630
  }
631
+ logger.debug('[AgGridPlus] 已注入实体扩展列', {
632
+ entityType: entityType,
633
+ extensionColsCount: extensionCols.length,
634
+ extensionCols: extensionCols.map(function (c) {
635
+ return c.field;
636
+ })
637
+ });
642
638
  }
643
639
  return columnDefs;
644
640
  };
@@ -178,11 +178,7 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
178
178
  isUsingGlobalQueryFallback?: boolean;
179
179
  /**
180
180
  * 实体扩展字段配置映射
181
- * key: 实体类型全名 (如 "Burn.Product.Domain.Product")
182
- * value: 该实体的扩展配置(包含字段定义数组)
183
- *
184
- * 来自后端 ABP 配置的 extraProperties.hostEntityExtensions
185
- * 用于 AgGridPlus 根据 entityType 属性自动注入扩展列
181
+ * 来自后端 ABP 配置,用于 AgGridPlus 根据 entityType 自动注入扩展列
186
182
  */
187
183
  hostEntityExtensions?: HostEntityExtensions;
188
184
  }
@@ -311,55 +311,35 @@ export type RowDataArray<T = any> = T[];
311
311
  */
312
312
  export type QueryFormItems = QueryFormItem[];
313
313
  /**
314
- * 扩展字段定义
315
- * 来自后端 ABP 配置的 hostEntityExtensions
314
+ * 扩展字段定义(来自后端 ABP 配置)
316
315
  */
317
316
  export interface EntityExtensionField {
318
- /** 字段名称 */
319
317
  name: string;
320
- /** 显示名称 */
321
318
  displayName: string;
322
- /** 描述信息 */
323
319
  description?: string | null;
324
320
  /** 数据类型: String, Int, Long, Decimal, Double, Float, Boolean, DateTime, Date, Guid, Enum, Text */
325
321
  dataType: string;
326
- /** 最大长度(字符串类型) */
327
322
  maxLength?: number | null;
328
- /** 精度(数值类型) */
329
323
  precision?: number | null;
330
- /** 小数位数(数值类型) */
331
324
  scale?: number | null;
332
- /** 是否必填 */
333
325
  isRequired?: boolean;
334
- /** 排序顺序 */
335
326
  sortOrder?: number;
336
- /** UI 组件类型 */
337
327
  uiComponent?: string | null;
338
- /** 占位符文本 */
339
328
  placeholder?: string | null;
340
- /** 默认值 */
341
329
  defaultValue?: any;
342
- /** 组件属性(JSON 字符串) */
343
330
  componentProps?: string | null;
344
- /** 验证规则(JSON 字符串) */
345
331
  validationRules?: string | null;
346
332
  }
347
333
  /**
348
334
  * 单个实体的扩展配置
349
335
  */
350
336
  export interface EntityExtensionConfig {
351
- /** 实体类型全名 (如 "Burn.Product.Domain.Product") */
352
337
  entityType: string;
353
- /** 实体显示名称 */
354
338
  displayName: string;
355
- /** 模块名称 */
356
339
  moduleName: string;
357
- /** 扩展字段列表 */
358
340
  fields: EntityExtensionField[];
359
341
  }
360
342
  /**
361
- * 所有实体扩展配置映射
362
- * key: 实体类型全名
363
- * value: 该实体的扩展配置
343
+ * 实体扩展配置映射(key: 实体类型全名)
364
344
  */
365
345
  export type HostEntityExtensions = Record<string, EntityExtensionConfig>;
@@ -7,6 +7,7 @@
7
7
  import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
8
8
  /**
9
9
  * 将单个扩展字段转换为列定义
10
+ * 使用 extraProperties.xxx 嵌套路径访问数据
10
11
  *
11
12
  * @param field 扩展字段定义
12
13
  * @returns AG-Grid 列定义
@@ -86,6 +86,7 @@ var dataTypeColumnConfig = {
86
86
 
87
87
  /**
88
88
  * 将单个扩展字段转换为列定义
89
+ * 使用 extraProperties.xxx 嵌套路径访问数据
89
90
  *
90
91
  * @param field 扩展字段定义
91
92
  * @returns AG-Grid 列定义
@@ -96,7 +97,8 @@ export function fieldToColumnDef(field) {
96
97
  hideInSearch: false
97
98
  };
98
99
  var colDef = _objectSpread(_objectSpread({
99
- field: field.name,
100
+ // 使用嵌套路径访问 extraProperties 中的数据 @author nokecy
101
+ field: "extraProperties.".concat(field.name),
100
102
  headerName: field.displayName,
101
103
  width: config.width,
102
104
  hideInSearch: config.hideInSearch
@@ -116,23 +118,16 @@ export function fieldToColumnDef(field) {
116
118
  * @returns 扩展列定义数组,按 sortOrder 排序
117
119
  */
118
120
  export function getEntityExtensionColumns(entityType, extensions) {
119
- // 边界情况处理
120
- if (!entityType || !extensions || !extensions[entityType]) {
121
+ // 边界情况处理:无效输入直接返回空数组
122
+ var entityConfig = entityType ? extensions === null || extensions === void 0 ? void 0 : extensions[entityType] : undefined;
123
+ var fields = entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.fields;
124
+ if (!fields || !Array.isArray(fields)) {
121
125
  return [];
122
126
  }
123
- var entityConfig = extensions[entityType];
124
127
 
125
- // 验证字段数组
126
- if (!entityConfig.fields || !Array.isArray(entityConfig.fields)) {
127
- return [];
128
- }
129
-
130
- // 按 sortOrder 排序字段
131
- var sortedFields = _toConsumableArray(entityConfig.fields).sort(function (a, b) {
128
+ // 按 sortOrder 排序后转换为列定义
129
+ return _toConsumableArray(fields).sort(function (a, b) {
132
130
  var _a$sortOrder, _b$sortOrder;
133
131
  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);
134
- });
135
-
136
- // 转换为列定义
137
- return sortedFields.map(fieldToColumnDef);
132
+ }).map(fieldToColumnDef);
138
133
  }