@baishuyun/chat-sdk 0.0.9 → 0.0.10

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 (51) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/chat-sdk.js +13923 -13642
  3. package/dist/chat-sdk.js.map +1 -1
  4. package/dist/chat-sdk.umd.cjs +159 -159
  5. package/dist/chat-sdk.umd.cjs.map +1 -1
  6. package/dist/index.css +1 -1
  7. package/package.json +4 -4
  8. package/src/chat.tsx +9 -0
  9. package/src/components/biz-comp/FakeBotMsg.tsx +6 -1
  10. package/src/components/biz-comp/chat-client.tsx +1 -0
  11. package/src/components/biz-comp/conversation.tsx +24 -45
  12. package/src/components/biz-comp/dash-widget-icon.tsx +17 -0
  13. package/src/components/biz-comp/field-icon.tsx +7 -2
  14. package/src/components/biz-comp/highlight-msg.tsx +3 -0
  15. package/src/components/biz-comp/messages.tsx +5 -4
  16. package/src/components/biz-comp/multi-modal-input/clear-btn.tsx +1 -0
  17. package/src/components/biz-comp/multi-modal-input/index.tsx +7 -3
  18. package/src/components/biz-comp/suggestions.tsx +5 -5
  19. package/src/components/bs-ui/border-color-animation.tsx +4 -1
  20. package/src/components/bs-ui/bs-icons.tsx +70 -0
  21. package/src/components/bs-ui/card.tsx +8 -10
  22. package/src/components/bs-ui/chat-area-header.tsx +5 -3
  23. package/src/components/bs-ui/collapsible-txt-msg.tsx +21 -6
  24. package/src/components/bs-ui/fields-generating-indicator.tsx +76 -31
  25. package/src/components/bs-ui/fields-previewer.tsx +4 -0
  26. package/src/components/bs-ui/form-info-editor.tsx +21 -7
  27. package/src/components/bs-ui/icon-btn.tsx +7 -2
  28. package/src/components/bs-ui/primary-confirm-btn.tsx +14 -7
  29. package/src/components/bs-ui/primary-entry-btn.tsx +14 -4
  30. package/src/components/bs-ui/scroll-to-bottom-btn.tsx +28 -0
  31. package/src/const/index.ts +26 -2
  32. package/src/hooks/use-frame-mode.ts +1 -0
  33. package/src/hooks/use-scroll-to-bottom.ts +127 -0
  34. package/src/plugins/mcp-form-builder-plugin/components/create-form-confirm.tsx +1 -1
  35. package/src/plugins/mcp-form-builder-plugin/index.ts +1 -0
  36. package/src/plugins/report-query-plugin/components/query-msg-part.tsx +30 -3
  37. package/src/plugins/report-query-plugin/components/result-cards/DataTableCard.tsx +12 -3
  38. package/src/plugins/report-query-plugin/components/result-cards/DataTableFields.tsx +1 -1
  39. package/src/plugins/report-query-plugin/components/result-cards/FilterCondition.tsx +11 -11
  40. package/src/plugins/report-query-plugin/index.ts +4 -0
  41. package/src/plugins/report-query-plugin/utils/field-enhance.ts +39 -0
  42. package/src/plugins/report-query-plugin/utils/get-field-group.ts +691 -0
  43. package/src/plugins/report-query-plugin/utils/get-field-icon.ts +26 -0
  44. package/src/plugins/report-query-plugin/utils/get-group-rule.ts +21 -0
  45. package/src/plugins/report-query-plugin/utils.tsx +40 -50
  46. package/src/stories/DashWidgetIcon.stories.tsx +132 -0
  47. package/src/stories/IconBtn.stories.tsx +14 -8
  48. package/src/stories/{PrimaryConfirmBtn.stories.ts → PrimaryConfirmBtn.stories.tsx} +16 -0
  49. package/src/stories/ScrollToBottom.stories.tsx +24 -0
  50. package/src/stories/SplitLine.stories.tsx +4 -4
  51. package/src/stories/fields-generating.stories.tsx +19 -0
@@ -0,0 +1,691 @@
1
+ /**
2
+ * 字段分组工具函数 - 基于 FX.LimitFields 配置
3
+ * 用于确定字段在仪表盘/图表中的分组归属
4
+ */
5
+
6
+ import { IDashWidgetType, IQueryResultXField } from '@baishuyun/types';
7
+
8
+ // ==================== 全局类型扩展 ====================
9
+
10
+ declare global {
11
+ interface Window {
12
+ FX?: {
13
+ LimitFields: LimitFieldsConfig;
14
+ [key: string]: unknown;
15
+ };
16
+ }
17
+ }
18
+
19
+ // ==================== 类型定义 ====================
20
+
21
+ /** 字段原始类型 */
22
+ type RawFieldType =
23
+ | '_id'
24
+ | 'text'
25
+ | 'textarea'
26
+ | 'number'
27
+ | 'datetime'
28
+ | 'radiogroup'
29
+ | 'checkboxgroup'
30
+ | 'combo'
31
+ | 'combocheck'
32
+ | 'address'
33
+ | 'location'
34
+ | 'user'
35
+ | 'usergroup'
36
+ | 'dept'
37
+ | 'deptgroup'
38
+ | 'image'
39
+ | 'upload'
40
+ | 'signature'
41
+ | 'subform'
42
+ | 'linkdata'
43
+ | 'linkquery'
44
+ | 'linkfield'
45
+ | 'sn'
46
+ | 'phone'
47
+ | 'button'
48
+ | 'dataload'
49
+ | 'separator'
50
+ | 'formula'
51
+ | 'formula_rank'
52
+ | 'formula_cumulative'
53
+ | 'flowState'
54
+ | 'flowstate'
55
+ | 'flowdecision'
56
+ | 'flownode'
57
+ | 'chargers'
58
+ | 'ext'
59
+ | 'creator'
60
+ | 'createTime'
61
+ | 'updateTime'
62
+ | 'flow_chargers'
63
+ | 'flow_signature'
64
+ | 'flow_comment'
65
+ | 'innerlink_qr'
66
+ | 'publiclink_qr'
67
+ | 'qrcode'
68
+ | 'print_operator'
69
+ | 'print_time'
70
+ | 'form_publink_qr'
71
+ | 'assist_flowid'
72
+ | 'assist_prostatus'
73
+ | 'tabs'
74
+ | 'flow'
75
+ | 'string'
76
+ | 'id'
77
+ | 'region'
78
+ | 'currency'
79
+ | 'percentage'
80
+ | 'text_filter'
81
+ | 'textarea_filter'
82
+ | 'combocheck_filter'
83
+ | 'user_filter'
84
+ | 'usergroup_filter'
85
+ | 'number_filter'
86
+ | 'address_filter'
87
+ | 'date_filter'
88
+ | 'datetime_filter'
89
+ | 'datemonth_filter'
90
+ | 'dateyear_filter'
91
+ | 'dept_filter'
92
+ | 'deptgroup_filter'
93
+ | 'flowstate_filter'
94
+ | 'flowdecision_filter'
95
+ | 'phone_filter'
96
+ | 'filelist_filter'
97
+ | 'address_city_filter'
98
+ | 'address_district_filter'
99
+ | 'address_province_filter'
100
+ | 'assist_prostatus_filter'
101
+ | 'assist_flowid_filter'
102
+ | 'metric_table'
103
+ | 'newMap'
104
+ | 'card'
105
+ | 'webPage'
106
+ | 'gauge_chart'
107
+ | 'data_table'
108
+ | 'rili'
109
+ | 'pivot_table'
110
+ | 'line_chart'
111
+ | 'column_chart'
112
+ | 'bar_chart'
113
+ | 'funnel_chart'
114
+ | 'area_chart'
115
+ | 'pie_chart'
116
+ | 'radar_chart'
117
+ | 'calendar_manage'
118
+ | 'data_manage'
119
+ | 'multi_axes_chart'
120
+ | 'map_chart'
121
+ | 'description'
122
+ | 'real_time'
123
+ | 'filte_quick'
124
+ | 'embedded_iframe'
125
+ | 'base_layout_container'
126
+ | 'background_table'
127
+ | 'gantt'
128
+ | 'gauge_imageMore';
129
+
130
+ /** 字段值类型(由业务逻辑计算得出) */
131
+ type FieldValueType = RawFieldType | string;
132
+
133
+ /** 字段对象 */
134
+ interface Field {
135
+ type: RawFieldType;
136
+ name: string;
137
+ [key: string]: unknown;
138
+ }
139
+
140
+ /** 限制字段配置(FX.LimitFields 的完整类型) */
141
+ interface LimitFieldsConfig {
142
+ // 基础限制
143
+ noSingleDataRepeat: RawFieldType[];
144
+ noSaveValue: RawFieldType[];
145
+ subform: RawFieldType[];
146
+ systemFields: RawFieldType[];
147
+ dataManage: RawFieldType[];
148
+
149
+ // 排序和查询
150
+ dashCustomSort: RawFieldType[];
151
+ queryFilter: RawFieldType[];
152
+ sort: RawFieldType[];
153
+ flowQueryPaneFilter: RawFieldType[];
154
+ parameter: RawFieldType[];
155
+
156
+ // 筛选器相关
157
+ filter: RawFieldType[];
158
+ Notifyfilter: RawFieldType[];
159
+ Notifyfield: RawFieldType[];
160
+ FlowNotifyfield: RawFieldType[];
161
+
162
+ // 列表和分组
163
+ list: RawFieldType[];
164
+ listJoin: RawFieldType[];
165
+ group: RawFieldType[];
166
+ subGroup: RawFieldType[];
167
+ dataLabel: RawFieldType[];
168
+ groupJoin: RawFieldType[];
169
+ subGroupJoin: RawFieldType[];
170
+
171
+ // 验证和依赖
172
+ validate: RawFieldType[];
173
+ rely: RawFieldType[];
174
+ link: RawFieldType[];
175
+ brief: RawFieldType[];
176
+ import: RawFieldType[];
177
+ combodata: RawFieldType[];
178
+ linkData: RawFieldType[];
179
+ linkKey: RawFieldType[];
180
+ subLinkData: RawFieldType[];
181
+ aggregate: RawFieldType[];
182
+ batchEdit: RawFieldType[];
183
+
184
+ // 文件和导出
185
+ fileExport: RawFieldType[];
186
+ itemLink: RawFieldType[];
187
+ fieldQrcode: RawFieldType[];
188
+ printTemplate: RawFieldType[];
189
+ printTemplateCellEditField: RawFieldType[];
190
+ excelExport: RawFieldType[];
191
+ noCache: RawFieldType[];
192
+
193
+ // 扩展字段
194
+ ext: RawFieldType[];
195
+ userDept: RawFieldType[];
196
+ triggerWrite: RawFieldType[];
197
+
198
+ // ETL 相关
199
+ etlInput: RawFieldType[];
200
+ etlMapFormula: RawFieldType[];
201
+ etlDimension: RawFieldType[];
202
+ etlQuota: RawFieldType[];
203
+ etlPivot: RawFieldType[];
204
+
205
+ // 仪表盘公式和排序
206
+ dashTableFormula: RawFieldType[];
207
+ dashSort: RawFieldType[];
208
+
209
+ // 仪表盘显示
210
+ dashWatermark: RawFieldType[];
211
+ dashTextAlignment: RawFieldType[];
212
+
213
+ // 核心:维度相关
214
+ dashDimension: RawFieldType[];
215
+ dashDimensions: RawFieldType[];
216
+ dashDimensionTime: RawFieldType[];
217
+ dashDimensionLAL: RawFieldType[];
218
+
219
+ // 核心:指标相关
220
+ dashQuota: RawFieldType[];
221
+
222
+ // 核心:筛选器相关
223
+ dashFilter: RawFieldType[];
224
+ dashFilters: RawFieldType[];
225
+
226
+ // 核心:字段相关
227
+ dashField: RawFieldType[];
228
+ dashGanttField: RawFieldType[];
229
+ dashFields: RawFieldType[];
230
+ datahelperFields: RawFieldType[];
231
+ dashTableField: RawFieldType[];
232
+
233
+ // 多选字段
234
+ multipleField: RawFieldType[];
235
+ multipleFields: RawFieldType[];
236
+
237
+ // 卡片相关
238
+ dashCardShowField: RawFieldType[];
239
+ dashCardTitleField: RawFieldType[];
240
+ dashTableFilter: RawFieldType[];
241
+
242
+ // 触发器
243
+ triggerQuery: RawFieldType[];
244
+ triggerCond: RawFieldType[];
245
+ datahelpnews: RawFieldType[];
246
+ disable: RawFieldType[];
247
+
248
+ // 组件和图表类型
249
+ dashCompFilter: string[];
250
+ dashCompChart: string[];
251
+ dashRowOrderChart: string[];
252
+ dashTopDataChart: string[];
253
+ dashCustomAxisLabelChart: string[];
254
+ dashCustomAxisRangeChart: string[];
255
+ dashAxisChart: string[];
256
+ dashThresholds: string[];
257
+ dashGuideline: string[];
258
+ dashColors: string[];
259
+ dashChartLabel: string[];
260
+ dashLegend: string[];
261
+ dashChangedColors: string[];
262
+ dashMobileLayout: string[];
263
+
264
+ // 可见性
265
+ invisibleFieldFilter: RawFieldType[];
266
+ fieldVisibleFilter: RawFieldType[];
267
+ }
268
+
269
+ /** 图表类型 */
270
+ type ChartType =
271
+ | 'newMap'
272
+ | 'gantt'
273
+ | 'table'
274
+ | 'metric_table'
275
+ | 'gauge_chart'
276
+ | 'data_table'
277
+ | 'pivot_table'
278
+ | 'line_chart'
279
+ | 'column_chart'
280
+ | 'bar_chart'
281
+ | 'funnel_chart'
282
+ | 'area_chart'
283
+ | 'pie_chart'
284
+ | 'radar_chart'
285
+ | 'multi_axes_chart'
286
+ | 'map_chart'
287
+ | 'card'
288
+ | 'webPage'
289
+ | 'rili'
290
+ | string;
291
+
292
+ /** 字段分组标签 */
293
+ type FieldGroup =
294
+ | 'dimension' // 普通维度
295
+ | 'quota' // 指标/度量
296
+ | 'LALDimension' // LAL维度(地理位置/文本/地址)
297
+ | '$dimension' // 表格维度
298
+ | 'filter' // 筛选器
299
+ | 'ganttshowfield' // 甘特图显示字段
300
+ | 'n-dimension' // 数字维度(甘特图)
301
+ | 't-dimension'; // 时间维度(甘特图)
302
+
303
+ /** 函数选项 */
304
+ interface GetFieldGroupOptions {
305
+ /** 图表类型 */
306
+ chartType: ChartType;
307
+ /** FX.LimitFields 配置 */
308
+ limitFields: LimitFieldsConfig;
309
+ /**
310
+ * 是否为隐藏模式(控制 quota、LALDimension、$dimension 的添加)
311
+ * @default false
312
+ */
313
+ isHidden?: boolean;
314
+ }
315
+
316
+ /** 获取字段值类型的函数 */
317
+ type GetFieldValueType = (field: Field) => FieldValueType;
318
+
319
+ // ==================== 常量定义 ====================
320
+
321
+ /**
322
+ * 甘特图中不适合做维度的字段类型黑名单
323
+ * 这些类型会被移除 dimension 和 $dimension 分组
324
+ */
325
+ const GANTT_DIMENSION_BLACKLIST: Set<RawFieldType> = new Set([
326
+ 'textarea',
327
+ 'subform',
328
+ 'checkboxgroup',
329
+ 'combocheck',
330
+ 'address',
331
+ 'user',
332
+ 'usergroup',
333
+ 'deptgroup',
334
+ 'location',
335
+ 'linkdata',
336
+ 'image',
337
+ 'upload',
338
+ 'signature',
339
+ 'chargers',
340
+ 'button',
341
+ 'dataload',
342
+ 'separator',
343
+ 'linkquery',
344
+ ]);
345
+
346
+ // ==================== 核心函数 ====================
347
+
348
+ /**
349
+ * 获取字段所属的分组标签列表
350
+ *
351
+ * 基于 FX.LimitFields 配置和图表类型,确定字段在仪表盘中的分组归属
352
+ *
353
+ * @param field - 字段对象,包含 type 和 name
354
+ * @param getValueType - 获取字段值类型的函数(对应原 _getFieldValueType)
355
+ * @param options - 配置选项,包含 chartType、limitFields 和 isHidden
356
+ * @returns 分组标签数组,表示该字段可用于哪些功能区域
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * // 基础用法
361
+ * const groups = getFieldGroup(
362
+ * { type: 'number', name: 'sales_amount' },
363
+ * (f) => f.type, // 简化示例,实际可能更复杂
364
+ * {
365
+ * chartType: 'gantt',
366
+ * limitFields: fxLimitFields,
367
+ * isHidden: false
368
+ * }
369
+ * );
370
+ * // 返回: ['dimension', '$dimension', 'quota', 'filter', 'ganttshowfield', 'n-dimension']
371
+ *
372
+ * // newMap 模式
373
+ * const mapGroups = getFieldGroup(
374
+ * { type: 'text', name: 'province' },
375
+ * (f) => f.type,
376
+ * { chartType: 'newMap', limitFields: fxLimitFields, isHidden: false }
377
+ * );
378
+ * // 返回: ['dimension', 'filter'](注意 newMap 使用 dashTableField 判断 dimension)
379
+ * ```
380
+ */
381
+ export function getFieldGroup(
382
+ field: Field,
383
+ getValueType: GetFieldValueType,
384
+ options: GetFieldGroupOptions
385
+ ): FieldGroup[] {
386
+ const { chartType, limitFields, isHidden = false } = options;
387
+ const groups: FieldGroup[] = [];
388
+
389
+ const valueType = getValueType(field);
390
+ const rawType = field.type;
391
+
392
+ // 1. 维度判断(核心逻辑,区分 newMap 和其他图表)
393
+ addDimensionGroups(groups, chartType, valueType, isHidden, limitFields);
394
+
395
+ // 2. 指标判断(需要 !isHidden)
396
+ if (!isHidden && limitFields.dashQuota.includes(valueType as RawFieldType)) {
397
+ groups.push('quota');
398
+ }
399
+
400
+ // 3. LAL维度判断(需要 !isHidden 且排除 _id 字段)
401
+ if (
402
+ !isHidden &&
403
+ limitFields.dashDimensionLAL.includes(valueType as RawFieldType) &&
404
+ field.name !== '_id'
405
+ ) {
406
+ groups.push('LALDimension');
407
+ }
408
+
409
+ // 4. 表格维度判断(需要 !isHidden)
410
+ if (!isHidden && limitFields.dashTableField.includes(valueType as RawFieldType)) {
411
+ groups.push('$dimension');
412
+ }
413
+
414
+ // 5. 筛选器判断(不依赖 isHidden,使用 rawType)
415
+ addFilterGroup(groups, chartType, rawType, limitFields);
416
+
417
+ // 6. 甘特图特殊处理
418
+ if (chartType === 'gantt') {
419
+ return processGanttSpecific(rawType, groups);
420
+ }
421
+
422
+ return groups;
423
+ }
424
+
425
+ // ==================== 辅助函数 ====================
426
+
427
+ /**
428
+ * 添加维度分组标签
429
+ *
430
+ * 规则:
431
+ * - newMap 图表:使用 dashTableField 判断,且需要 !isHidden
432
+ * - 其他图表:使用 dashDimension 判断,不需要检查 isHidden
433
+ */
434
+ function addDimensionGroups(
435
+ groups: FieldGroup[],
436
+ chartType: ChartType,
437
+ valueType: FieldValueType,
438
+ isHidden: boolean,
439
+ limitFields: LimitFieldsConfig
440
+ ): void {
441
+ if (chartType === 'newMap') {
442
+ // newMap 特殊逻辑:使用 dashTableField 作为维度依据,且受 isHidden 控制
443
+ if (!isHidden && limitFields.dashTableField.includes(valueType as RawFieldType)) {
444
+ groups.push('dimension');
445
+ }
446
+ } else {
447
+ // 标准逻辑:使用 dashDimension,不受 isHidden 影响
448
+ if (limitFields.dashDimension.includes(valueType as RawFieldType)) {
449
+ groups.push('dimension');
450
+ }
451
+ }
452
+ }
453
+
454
+ /**
455
+ * 添加筛选器分组标签
456
+ *
457
+ * 规则:
458
+ * - newMap 图表:使用 dashFilters(复数)
459
+ * - 其他图表:使用 dashFilter(单数)
460
+ * - 注意:筛选器判断不依赖 isHidden,使用 rawType 而非 valueType
461
+ */
462
+ function addFilterGroup(
463
+ groups: FieldGroup[],
464
+ chartType: ChartType,
465
+ rawType: RawFieldType,
466
+ limitFields: LimitFieldsConfig
467
+ ): void {
468
+ const filterList = chartType === 'newMap' ? limitFields.dashFilters : limitFields.dashFilter;
469
+
470
+ if (filterList.includes(rawType)) {
471
+ groups.push('filter');
472
+ }
473
+ }
474
+
475
+ /**
476
+ * 处理甘特图特定的分组逻辑
477
+ *
478
+ * 特殊处理:
479
+ * 1. 所有字段添加 'ganttshowfield'
480
+ * 2. number 类型添加 'n-dimension'
481
+ * 3. datetime 类型添加 't-dimension'
482
+ * 4. 黑名单类型移除 'dimension' 和 '$dimension'
483
+ */
484
+ function processGanttSpecific(rawType: RawFieldType, currentGroups: FieldGroup[]): FieldGroup[] {
485
+ const groups = [...currentGroups];
486
+
487
+ // 所有甘特图字段默认可显示
488
+ groups.push('ganttshowfield');
489
+
490
+ // 根据原始类型添加特定维度标签
491
+ if (rawType === 'number') {
492
+ groups.push('n-dimension');
493
+ } else if (rawType === 'datetime') {
494
+ groups.push('t-dimension');
495
+ }
496
+
497
+ // 黑名单类型:移除不适合做维度的标签
498
+ if (GANTT_DIMENSION_BLACKLIST.has(rawType)) {
499
+ return groups.filter((group) => group !== 'dimension' && group !== '$dimension');
500
+ }
501
+
502
+ return groups;
503
+ }
504
+
505
+ // ==================== 工厂函数 ====================
506
+
507
+ /**
508
+ * 创建预配置的字段分组获取器
509
+ *
510
+ * 适用于在特定业务场景下复用相同的配置
511
+ *
512
+ * @param getValueType - 获取字段值类型的函数
513
+ * @param limitFields - FX.LimitFields 配置对象
514
+ * @param defaultChartType - 默认图表类型
515
+ * @returns 预配置的 getFieldGroup 函数
516
+ *
517
+ * @example
518
+ * ```typescript
519
+ * // 创建专用于甘特图的分组器
520
+ * const ganttFieldGrouper = createFieldGroupGetter(
521
+ * getFieldValueType,
522
+ * fxLimitFields,
523
+ * 'gantt'
524
+ * );
525
+ *
526
+ * // 使用(无需重复传入 chartType)
527
+ * const groups1 = ganttFieldGrouper({ type: 'number', name: 'progress' });
528
+ * const groups2 = ganttFieldGrouper({ type: 'datetime', name: 'start_date' });
529
+ *
530
+ * // 临时切换图表类型
531
+ * const tableGroups = ganttFieldGrouper(
532
+ * { type: 'combo', name: 'status' },
533
+ * 'table',
534
+ * false
535
+ * );
536
+ * ```
537
+ */
538
+ export function createFieldGroupGetter(
539
+ getValueType: GetFieldValueType,
540
+ limitFields: LimitFieldsConfig,
541
+ defaultChartType: ChartType = 'table'
542
+ ) {
543
+ return (
544
+ field: Field,
545
+ chartType: ChartType = defaultChartType,
546
+ isHidden?: boolean
547
+ ): FieldGroup[] => {
548
+ return getFieldGroup(field, getValueType, {
549
+ chartType,
550
+ limitFields,
551
+ isHidden,
552
+ });
553
+ };
554
+ }
555
+
556
+ // ==================== 类型守卫 ====================
557
+
558
+ /**
559
+ * 检查是否为有效的字段类型
560
+ */
561
+ export function isValidFieldType(type: string): type is RawFieldType {
562
+ // 基础类型检查,实际项目中可能需要更完整的列表
563
+ const validTypes: string[] = [
564
+ '_id',
565
+ 'text',
566
+ 'textarea',
567
+ 'number',
568
+ 'datetime',
569
+ 'radiogroup',
570
+ 'checkboxgroup',
571
+ 'combo',
572
+ 'combocheck',
573
+ 'address',
574
+ 'location',
575
+ 'user',
576
+ 'usergroup',
577
+ 'dept',
578
+ 'deptgroup',
579
+ 'image',
580
+ 'upload',
581
+ 'signature',
582
+ 'subform',
583
+ 'linkdata',
584
+ 'linkquery',
585
+ 'sn',
586
+ 'phone',
587
+ 'button',
588
+ 'dataload',
589
+ 'separator',
590
+ 'formula',
591
+ ];
592
+ return validTypes.includes(type);
593
+ }
594
+
595
+ /**
596
+ * 检查字段是否在指定分组中
597
+ */
598
+ export function fieldHasGroup(groups: FieldGroup[], targetGroup: FieldGroup): boolean {
599
+ return groups.includes(targetGroup);
600
+ }
601
+
602
+ // ==================== 使用示例 ====================
603
+
604
+ // 示例:模拟 FX.LimitFields 的部分配置
605
+ const exampleLimitFields: Partial<LimitFieldsConfig> = {
606
+ dashDimension: [
607
+ '_id',
608
+ 'text',
609
+ 'radiogroup',
610
+ 'combo',
611
+ 'datetime',
612
+ 'address',
613
+ 'user',
614
+ 'dept',
615
+ 'sn',
616
+ ],
617
+ dashTableField: [
618
+ '_id',
619
+ 'text',
620
+ 'textarea',
621
+ 'number',
622
+ 'combo',
623
+ 'datetime',
624
+ 'address',
625
+ 'user',
626
+ 'dept',
627
+ ],
628
+ dashQuota: ['_id', 'text', 'combo', 'number', 'sn', 'formula'],
629
+ dashDimensionLAL: ['location', 'text', 'address'],
630
+ dashFilter: [
631
+ '_id',
632
+ 'text',
633
+ 'radiogroup',
634
+ 'combo',
635
+ 'datetime',
636
+ 'address',
637
+ 'user',
638
+ 'dept',
639
+ 'number',
640
+ ],
641
+ dashFilters: [
642
+ '_id',
643
+ 'text',
644
+ 'textarea',
645
+ 'radiogroup',
646
+ 'combo',
647
+ 'datetime',
648
+ 'address',
649
+ 'user',
650
+ 'dept',
651
+ 'number',
652
+ ],
653
+ };
654
+
655
+ // // 示例字段值类型获取函数
656
+ // const exampleGetValueType: GetFieldValueType = (field) => {
657
+ // // 实际业务中可能更复杂,例如根据字段配置映射到标准类型
658
+ // return field.type;
659
+ // };
660
+
661
+ // 使用示例
662
+ // const exampleField: Field = { type: 'number', name: 'amount' };
663
+ // const groups = getFieldGroup(exampleField, exampleGetValueType, {
664
+ // chartType: 'gantt',
665
+ // limitFields: exampleLimitFields as LimitFieldsConfig,
666
+ // isHidden: false,
667
+ // });
668
+
669
+ export const GetXFieldGroupStr = (
670
+ chartType: IDashWidgetType,
671
+ field: {
672
+ type: string;
673
+ name: string;
674
+ }
675
+ ) => {
676
+ return getFieldGroup(
677
+ {
678
+ type: field.type as RawFieldType,
679
+ name: field.name,
680
+ },
681
+ (f) => f.type,
682
+ {
683
+ chartType,
684
+ limitFields: window.FX?.LimitFields as LimitFieldsConfig,
685
+ isHidden: false,
686
+ }
687
+ ).join(',');
688
+ };
689
+
690
+ // console.log('Field groups:', groups);
691
+ // 预期输出: ['dimension', '$dimension', 'quota', 'filter', 'ganttshowfield', 'n-dimension']
@@ -0,0 +1,26 @@
1
+ import { FieldType } from '@baishuyun/types';
2
+
3
+ /** 获取字段图标 */
4
+ export const getFieldIcon = (type: FieldType): string => {
5
+ const iconMap: Record<string, string> = {
6
+ text: 'icon-widget-text',
7
+ textarea: 'icon-widget-textarea',
8
+ number: 'icon-widget-number',
9
+ datetime: 'icon-widget-datetime',
10
+ date: 'icon-widget-date',
11
+ time: 'icon-widget-time',
12
+ radiogroup: 'icon-widget-radiogroup',
13
+ checkboxgroup: 'icon-widget-checkboxgroup',
14
+ user: 'icon-widget-user',
15
+ usergroup: 'icon-widget-usergroup',
16
+ dept: 'icon-widget-dept',
17
+ deptgroup: 'icon-widget-deptgroup',
18
+ upload: 'icon-widget-upload',
19
+ image: 'icon-widget-image',
20
+ location: 'icon-widget-location',
21
+ select: 'icon-widget-select',
22
+ combo: 'icon-widget-combo',
23
+ signature: 'icon-widget-signature',
24
+ };
25
+ return iconMap[type] || 'icon-widget-text';
26
+ };