@nokecy/qc-ui 1.0.65 → 1.0.66

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 (81) hide show
  1. package/dist/cjs/RuleBuilder/LogicSelector.d.ts +23 -0
  2. package/dist/cjs/RuleBuilder/LogicSelector.js +54 -0
  3. package/dist/cjs/RuleBuilder/RuleBuilderContainer.d.ts +20 -0
  4. package/dist/cjs/RuleBuilder/RuleBuilderContainer.js +209 -0
  5. package/dist/cjs/RuleBuilder/RuleCard.d.ts +20 -0
  6. package/dist/cjs/RuleBuilder/RuleCard.js +196 -0
  7. package/dist/cjs/RuleBuilder/RuleGroupEditor.d.ts +25 -0
  8. package/dist/cjs/RuleBuilder/RuleGroupEditor.js +191 -0
  9. package/dist/cjs/RuleBuilder/constants/operators.d.ts +47 -0
  10. package/dist/cjs/RuleBuilder/constants/operators.js +172 -0
  11. package/dist/cjs/RuleBuilder/context/RuleBuilderContext.d.ts +72 -0
  12. package/dist/cjs/RuleBuilder/context/RuleBuilderContext.js +286 -0
  13. package/dist/cjs/RuleBuilder/index.d.ts +25 -0
  14. package/dist/cjs/RuleBuilder/index.js +308 -0
  15. package/dist/cjs/RuleBuilder/inputs/BetweenValueInput.d.ts +23 -0
  16. package/dist/cjs/RuleBuilder/inputs/BetweenValueInput.js +80 -0
  17. package/dist/cjs/RuleBuilder/inputs/MultiValueInput.d.ts +21 -0
  18. package/dist/cjs/RuleBuilder/inputs/MultiValueInput.js +128 -0
  19. package/dist/cjs/RuleBuilder/inputs/SingleValueInput.d.ts +25 -0
  20. package/dist/cjs/RuleBuilder/inputs/SingleValueInput.js +81 -0
  21. package/dist/cjs/RuleBuilder/inputs/ValueInput.d.ts +29 -0
  22. package/dist/cjs/RuleBuilder/inputs/ValueInput.js +80 -0
  23. package/dist/cjs/RuleBuilder/selectors/FieldSelector.d.ts +22 -0
  24. package/dist/cjs/RuleBuilder/selectors/FieldSelector.js +45 -0
  25. package/dist/cjs/RuleBuilder/selectors/OperatorSelector.d.ts +22 -0
  26. package/dist/cjs/RuleBuilder/selectors/OperatorSelector.js +51 -0
  27. package/dist/cjs/RuleBuilder/styles/index.module.less +443 -0
  28. package/dist/cjs/RuleBuilder/styles/index.module.less.d.ts +43 -0
  29. package/dist/cjs/RuleBuilder/types/index.d.ts +232 -0
  30. package/dist/cjs/RuleBuilder/types/index.js +83 -0
  31. package/dist/cjs/RuleBuilder/utils/pathHelpers.d.ts +65 -0
  32. package/dist/cjs/RuleBuilder/utils/pathHelpers.js +241 -0
  33. package/dist/cjs/RuleBuilder/utils/ruleHelpers.d.ts +47 -0
  34. package/dist/cjs/RuleBuilder/utils/ruleHelpers.js +154 -0
  35. package/dist/cjs/RuleBuilder/utils/validation.d.ts +25 -0
  36. package/dist/cjs/RuleBuilder/utils/validation.js +241 -0
  37. package/dist/cjs/index.d.ts +3 -1
  38. package/dist/cjs/index.js +7 -0
  39. package/dist/cjs/standardFormDialog/StandardFormDialog.js +26 -5
  40. package/dist/esm/RuleBuilder/LogicSelector.d.ts +23 -0
  41. package/dist/esm/RuleBuilder/LogicSelector.js +47 -0
  42. package/dist/esm/RuleBuilder/RuleBuilderContainer.d.ts +20 -0
  43. package/dist/esm/RuleBuilder/RuleBuilderContainer.js +203 -0
  44. package/dist/esm/RuleBuilder/RuleCard.d.ts +20 -0
  45. package/dist/esm/RuleBuilder/RuleCard.js +191 -0
  46. package/dist/esm/RuleBuilder/RuleGroupEditor.d.ts +25 -0
  47. package/dist/esm/RuleBuilder/RuleGroupEditor.js +184 -0
  48. package/dist/esm/RuleBuilder/constants/operators.d.ts +47 -0
  49. package/dist/esm/RuleBuilder/constants/operators.js +169 -0
  50. package/dist/esm/RuleBuilder/context/RuleBuilderContext.d.ts +72 -0
  51. package/dist/esm/RuleBuilder/context/RuleBuilderContext.js +271 -0
  52. package/dist/esm/RuleBuilder/index.d.ts +25 -0
  53. package/dist/esm/RuleBuilder/index.js +42 -0
  54. package/dist/esm/RuleBuilder/inputs/BetweenValueInput.d.ts +23 -0
  55. package/dist/esm/RuleBuilder/inputs/BetweenValueInput.js +73 -0
  56. package/dist/esm/RuleBuilder/inputs/MultiValueInput.d.ts +21 -0
  57. package/dist/esm/RuleBuilder/inputs/MultiValueInput.js +121 -0
  58. package/dist/esm/RuleBuilder/inputs/SingleValueInput.d.ts +25 -0
  59. package/dist/esm/RuleBuilder/inputs/SingleValueInput.js +74 -0
  60. package/dist/esm/RuleBuilder/inputs/ValueInput.d.ts +29 -0
  61. package/dist/esm/RuleBuilder/inputs/ValueInput.js +73 -0
  62. package/dist/esm/RuleBuilder/selectors/FieldSelector.d.ts +22 -0
  63. package/dist/esm/RuleBuilder/selectors/FieldSelector.js +38 -0
  64. package/dist/esm/RuleBuilder/selectors/OperatorSelector.d.ts +22 -0
  65. package/dist/esm/RuleBuilder/selectors/OperatorSelector.js +44 -0
  66. package/dist/esm/RuleBuilder/styles/index.module.less +443 -0
  67. package/dist/esm/RuleBuilder/styles/index.module.less.d.ts +43 -0
  68. package/dist/esm/RuleBuilder/types/index.d.ts +232 -0
  69. package/dist/esm/RuleBuilder/types/index.js +91 -0
  70. package/dist/esm/RuleBuilder/utils/pathHelpers.d.ts +65 -0
  71. package/dist/esm/RuleBuilder/utils/pathHelpers.js +228 -0
  72. package/dist/esm/RuleBuilder/utils/ruleHelpers.d.ts +47 -0
  73. package/dist/esm/RuleBuilder/utils/ruleHelpers.js +145 -0
  74. package/dist/esm/RuleBuilder/utils/validation.d.ts +25 -0
  75. package/dist/esm/RuleBuilder/utils/validation.js +236 -0
  76. package/dist/esm/index.d.ts +3 -1
  77. package/dist/esm/index.js +2 -1
  78. package/dist/esm/standardFormDialog/StandardFormDialog.js +26 -5
  79. package/dist/umd/qc-ui.min.css +1 -1
  80. package/dist/umd/qc-ui.min.js +1 -1
  81. package/package.json +1 -1
@@ -0,0 +1,443 @@
1
+ /**
2
+ * 规则构建器样式 - 生产环境紧凑版
3
+ * 适用于需要在一屏显示大量规则的企业生产环境
4
+ */
5
+
6
+ // ===== 紧凑配置 =====
7
+ @compactPadding: 8px;
8
+ @compactMargin: 4px;
9
+ @compactGap: 6px;
10
+ @compactFontSize: 12px;
11
+ @compactHeight: 24px;
12
+
13
+ // ===== 颜色配置 =====
14
+ @groupLevel1: #fafafa;
15
+ @groupLevel2: #f5f5f5;
16
+ @groupLevel3: #f0f0f0;
17
+ @groupLevel4: #ebebeb;
18
+ @groupLevel5: #e6e6e6;
19
+ @andLogic: #1890ff;
20
+ @orLogic: #fa8c16;
21
+ @ruleCardBg: #ffffff;
22
+ @borderColor: #d9d9d9;
23
+ @borderColorLight: #e8e8e8;
24
+ @shadowColor: rgba(0, 0, 0, 0.04);
25
+ @hoverShadowColor: rgba(0, 0, 0, 0.08);
26
+ @text-color: rgba(0, 0, 0, 0.85);
27
+ @text-color-secondary: rgba(0, 0, 0, 0.45);
28
+
29
+ // ===== 规则构建器容器 =====
30
+ .ruleBuilderContainer {
31
+ padding: 0;
32
+ background: transparent;
33
+ border: none;
34
+ font-size: @compactFontSize;
35
+ }
36
+
37
+ // ===== 规则组编辑器 =====
38
+ .ruleGroupEditor {
39
+ padding: @compactPadding;
40
+ margin-bottom: @compactGap;
41
+ border-radius: 4px;
42
+ border: 1px solid @borderColorLight;
43
+ box-shadow: 0 1px 2px @shadowColor;
44
+ transition: box-shadow 0.2s;
45
+
46
+ &:hover {
47
+ box-shadow: 0 2px 4px @hoverShadowColor;
48
+ }
49
+
50
+ // 根据层级设置不同背景色
51
+ &.level0 {
52
+ background: @groupLevel1;
53
+ border-left: 2px solid @andLogic;
54
+ }
55
+
56
+ &.level1 {
57
+ background: @groupLevel2;
58
+ border-left: 2px solid @andLogic;
59
+ }
60
+
61
+ &.level2 {
62
+ background: @groupLevel3;
63
+ border-left: 2px solid @andLogic;
64
+ }
65
+
66
+ &.level3 {
67
+ background: @groupLevel4;
68
+ border-left: 2px solid @andLogic;
69
+ }
70
+
71
+ &.level4 {
72
+ background: @groupLevel5;
73
+ border-left: 2px solid @andLogic;
74
+ }
75
+
76
+ // OR 逻辑使用橙色边框
77
+ &.orLogicGroup {
78
+ border-left-color: @orLogic;
79
+ }
80
+
81
+ // 规则组头部
82
+ .groupHeader {
83
+ display: flex;
84
+ justify-content: space-between;
85
+ align-items: center;
86
+ margin-bottom: @compactGap;
87
+ padding-bottom: 4px;
88
+ border-bottom: 1px solid @borderColorLight;
89
+
90
+ .groupTitle {
91
+ display: flex;
92
+ align-items: center;
93
+ gap: 4px;
94
+ font-weight: 500;
95
+ color: @text-color;
96
+ font-size: @compactFontSize;
97
+ line-height: @compactHeight;
98
+ }
99
+
100
+ .groupActions {
101
+ display: flex;
102
+ gap: 4px;
103
+ }
104
+ }
105
+
106
+ // 规则组内容
107
+ .groupContent {
108
+ display: flex;
109
+ flex-direction: column;
110
+ gap: @compactMargin;
111
+ }
112
+
113
+ // 嵌套规则组
114
+ .nestedGroups {
115
+ margin-top: @compactGap;
116
+ margin-left: @compactPadding;
117
+ padding-left: @compactPadding;
118
+ border-left: 1px dashed @borderColorLight;
119
+ }
120
+ }
121
+
122
+ // ===== 规则卡片 =====
123
+ .ruleCard {
124
+ background: @ruleCardBg;
125
+ padding: 6px @compactPadding;
126
+ border-radius: 4px;
127
+ border: 1px solid @borderColorLight;
128
+ box-shadow: 0 1px 2px @shadowColor;
129
+ transition: all 0.2s;
130
+
131
+ &:hover {
132
+ border-color: @andLogic;
133
+ box-shadow: 0 2px 4px @hoverShadowColor;
134
+ }
135
+
136
+ .ruleContent {
137
+ display: flex;
138
+ align-items: center;
139
+ gap: @compactGap;
140
+ flex-wrap: nowrap;
141
+
142
+ .ruleField {
143
+ min-width: 120px;
144
+ flex: 1;
145
+ }
146
+
147
+ .ruleOperator {
148
+ min-width: 80px;
149
+ flex: 0.6;
150
+ }
151
+
152
+ .ruleValue {
153
+ min-width: 120px;
154
+ flex: 1.2;
155
+ }
156
+
157
+ .ruleValue2 {
158
+ min-width: 100px;
159
+ flex: 0.8;
160
+ }
161
+
162
+ .ruleActions {
163
+ display: flex;
164
+ gap: 2px;
165
+ margin-left: auto;
166
+ flex-shrink: 0;
167
+ }
168
+ }
169
+ }
170
+
171
+ // ===== 逻辑选择器 =====
172
+ .logicSelector {
173
+ display: inline-block;
174
+ margin-bottom: @compactGap;
175
+
176
+ :global(.ant-radio-group) {
177
+ display: flex;
178
+ gap: @compactGap;
179
+ }
180
+
181
+ :global(.ant-radio-button-wrapper) {
182
+ padding: 2px 12px;
183
+ min-width: 70px;
184
+ height: @compactHeight;
185
+ line-height: 20px;
186
+ border-radius: 4px;
187
+ font-size: @compactFontSize;
188
+ transition: all 0.2s;
189
+
190
+ &:hover {
191
+ box-shadow: 0 1px 3px @shadowColor;
192
+ }
193
+ }
194
+
195
+ .logicLabel {
196
+ font-weight: 500;
197
+ font-size: @compactFontSize;
198
+ }
199
+
200
+ .logicDescription {
201
+ display: none; // 紧凑模式隐藏描述
202
+ }
203
+
204
+ // AND 逻辑样式
205
+ .andLogic {
206
+ color: @andLogic;
207
+ }
208
+
209
+ .andLogicActive {
210
+ background: @andLogic;
211
+ border-color: @andLogic;
212
+ color: #ffffff;
213
+ }
214
+
215
+ // OR 逻辑样式
216
+ .orLogic {
217
+ color: @orLogic;
218
+ }
219
+
220
+ .orLogicActive {
221
+ background: @orLogic;
222
+ border-color: @orLogic;
223
+ color: #ffffff;
224
+ }
225
+ }
226
+
227
+ // ===== 添加按钮组 =====
228
+ .addButtonGroup {
229
+ display: flex;
230
+ gap: @compactGap;
231
+ margin-top: @compactGap;
232
+ padding-top: @compactGap;
233
+ border-top: 1px dashed @borderColorLight;
234
+
235
+ :global(.ant-btn) {
236
+ height: @compactHeight;
237
+ padding: 0 8px;
238
+ font-size: @compactFontSize;
239
+ line-height: 22px;
240
+ }
241
+
242
+ :global(.ant-btn-primary) {
243
+ box-shadow: 0 1px 2px rgba(24, 144, 255, 0.2);
244
+
245
+ &:hover {
246
+ box-shadow: 0 2px 4px rgba(24, 144, 255, 0.3);
247
+ }
248
+ }
249
+
250
+ :global(.ant-btn-default) {
251
+ &:hover {
252
+ border-color: @andLogic;
253
+ color: @andLogic;
254
+ }
255
+ }
256
+ }
257
+
258
+ // ===== 空状态 =====
259
+ .emptyState {
260
+ text-align: center;
261
+ padding: 20px 16px;
262
+ color: @text-color-secondary;
263
+ background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
264
+ border-radius: 4px;
265
+ border: 1px dashed @borderColorLight;
266
+
267
+ .emptyIcon {
268
+ font-size: 32px;
269
+ margin-bottom: 8px;
270
+ opacity: 0.6;
271
+ }
272
+
273
+ .emptyText {
274
+ font-size: @compactFontSize;
275
+ margin-bottom: 0;
276
+ line-height: 1.5;
277
+ }
278
+ }
279
+
280
+ // ===== JSON 预览 =====
281
+ .jsonPreview {
282
+ margin-top: 16px;
283
+ padding: @compactPadding;
284
+ background: #fafafa;
285
+ border-radius: 4px;
286
+ border: 1px solid @borderColorLight;
287
+
288
+ .previewTitle {
289
+ font-weight: 500;
290
+ margin-bottom: @compactGap;
291
+ color: @text-color;
292
+ font-size: @compactFontSize;
293
+ }
294
+
295
+ .previewContent {
296
+ max-height: 300px;
297
+ overflow-y: auto;
298
+ background: #ffffff;
299
+ padding: @compactPadding;
300
+ border-radius: 4px;
301
+ border: 1px solid @borderColorLight;
302
+
303
+ pre {
304
+ margin: 0;
305
+ white-space: pre-wrap;
306
+ word-break: break-word;
307
+ font-size: 11px;
308
+ line-height: 1.5;
309
+ }
310
+ }
311
+ }
312
+
313
+ // ===== 验证错误提示 =====
314
+ .validationErrors {
315
+ margin-top: @compactPadding;
316
+ padding: @compactPadding;
317
+ background: #fff2e8;
318
+ border-radius: 4px;
319
+ border: 1px solid #ffbb96;
320
+
321
+ .errorTitle {
322
+ font-weight: 500;
323
+ color: #d4380d;
324
+ margin-bottom: 4px;
325
+ font-size: @compactFontSize;
326
+ }
327
+
328
+ .errorList {
329
+ list-style: none;
330
+ margin: 0;
331
+ padding: 0;
332
+
333
+ .errorItem {
334
+ padding: 2px 0;
335
+ color: #d4380d;
336
+ font-size: 11px;
337
+
338
+ &:before {
339
+ content: '• ';
340
+ margin-right: 4px;
341
+ }
342
+ }
343
+ }
344
+ }
345
+
346
+ // ===== 响应式设计 =====
347
+ @media (max-width: 768px) {
348
+ .ruleCard {
349
+ .ruleContent {
350
+ flex-wrap: wrap;
351
+
352
+ .ruleField,
353
+ .ruleOperator,
354
+ .ruleValue,
355
+ .ruleValue2 {
356
+ min-width: calc(50% - 3px);
357
+ }
358
+
359
+ .ruleActions {
360
+ margin-left: 0;
361
+ width: 100%;
362
+ justify-content: flex-end;
363
+ }
364
+ }
365
+ }
366
+ }
367
+
368
+ // ===== 全局紧凑样式覆盖 =====
369
+ :global {
370
+ .ruleBuilderContainer {
371
+ // 确保所有表单组件使用小尺寸
372
+ .ant-select,
373
+ .ant-input,
374
+ .ant-input-number {
375
+ font-size: @compactFontSize;
376
+
377
+ &-sm {
378
+ height: @compactHeight;
379
+ line-height: @compactHeight;
380
+ }
381
+ }
382
+
383
+ .ant-select-sm {
384
+ .ant-select-selector {
385
+ height: @compactHeight;
386
+ padding: 0 7px;
387
+ font-size: @compactFontSize;
388
+ }
389
+
390
+ .ant-select-selection-item {
391
+ line-height: 22px;
392
+ }
393
+ }
394
+
395
+ .ant-input-sm {
396
+ height: @compactHeight;
397
+ padding: 0 7px;
398
+ font-size: @compactFontSize;
399
+ }
400
+
401
+ .ant-input-number-sm {
402
+ height: @compactHeight;
403
+ font-size: @compactFontSize;
404
+
405
+ .ant-input-number-input {
406
+ height: 22px;
407
+ padding: 0 7px;
408
+ }
409
+ }
410
+
411
+ .ant-btn-sm {
412
+ height: @compactHeight;
413
+ padding: 0 7px;
414
+ font-size: @compactFontSize;
415
+ line-height: 22px;
416
+
417
+ &.ant-btn-icon-only {
418
+ width: @compactHeight;
419
+ padding: 0;
420
+ }
421
+ }
422
+ }
423
+ }
424
+
425
+ // ===== 打印样式 =====
426
+ @media print {
427
+ .ruleBuilderContainer {
428
+ border: none;
429
+ box-shadow: none;
430
+ }
431
+
432
+ .ruleGroupEditor,
433
+ .ruleCard {
434
+ break-inside: avoid;
435
+ box-shadow: none;
436
+ }
437
+
438
+ .groupActions,
439
+ .ruleActions,
440
+ .addButtonGroup {
441
+ display: none;
442
+ }
443
+ }
@@ -0,0 +1,43 @@
1
+ // TypeScript declaration for CSS modules
2
+ declare const styles: {
3
+ readonly ruleBuilderContainer: string;
4
+ readonly ruleGroupEditor: string;
5
+ readonly level0: string;
6
+ readonly level1: string;
7
+ readonly level2: string;
8
+ readonly level3: string;
9
+ readonly level4: string;
10
+ readonly orLogicGroup: string;
11
+ readonly groupHeader: string;
12
+ readonly groupTitle: string;
13
+ readonly groupActions: string;
14
+ readonly groupContent: string;
15
+ readonly nestedGroups: string;
16
+ readonly ruleCard: string;
17
+ readonly ruleContent: string;
18
+ readonly ruleField: string;
19
+ readonly ruleOperator: string;
20
+ readonly ruleValue: string;
21
+ readonly ruleValue2: string;
22
+ readonly ruleActions: string;
23
+ readonly logicSelector: string;
24
+ readonly logicLabel: string;
25
+ readonly logicDescription: string;
26
+ readonly andLogic: string;
27
+ readonly andLogicActive: string;
28
+ readonly orLogic: string;
29
+ readonly orLogicActive: string;
30
+ readonly addButtonGroup: string;
31
+ readonly emptyState: string;
32
+ readonly emptyIcon: string;
33
+ readonly emptyText: string;
34
+ readonly jsonPreview: string;
35
+ readonly previewTitle: string;
36
+ readonly previewContent: string;
37
+ readonly validationErrors: string;
38
+ readonly errorTitle: string;
39
+ readonly errorList: string;
40
+ readonly errorItem: string;
41
+ };
42
+
43
+ export default styles;
@@ -0,0 +1,232 @@
1
+ /**
2
+ * 规则构建器类型定义
3
+ *
4
+ * ⚠️ 重要:与后端定义完全一致
5
+ * - 后端 Domain: Burn.Abp.RuleEngine.Domain.Shared (Rule, RuleGroup)
6
+ * - 后端 DTO: Burn.Abp.LabelManagement.Application.Contracts.RuleEngine (RuleDto, RuleGroupDto)
7
+ *
8
+ * JSON 序列化属性名:
9
+ * - fieldName (不是 FieldName)
10
+ * - operator (不是 Operator)
11
+ * - value, value2
12
+ * - logic, rules, groups
13
+ */
14
+ /**
15
+ * 操作符显示信息
16
+ */
17
+ export interface OperatorInfo {
18
+ value: MatchOperator;
19
+ label: string;
20
+ symbol: string;
21
+ description: string;
22
+ /** 是否需要输入值 */
23
+ requiresValue: boolean;
24
+ /** 是否需要第二个值(Between) */
25
+ requiresValue2: boolean;
26
+ /** 是否需要多个值(In/NotIn) */
27
+ requiresMultiValue: boolean;
28
+ }
29
+ /**
30
+ * 匹配操作符枚举
31
+ *
32
+ * 对应后端: Burn.Abp.RuleEngine.Domain.Shared.MatchOperator
33
+ */
34
+ export declare enum MatchOperator {
35
+ /** 等于 (=) */
36
+ Equals = 0,
37
+ /** 不等于 (!=) */
38
+ NotEquals = 1,
39
+ /** 大于 (>) */
40
+ GreaterThan = 2,
41
+ /** 大于等于 (>=) */
42
+ GreaterThanOrEqual = 3,
43
+ /** 小于 (<) */
44
+ LessThan = 4,
45
+ /** 小于等于 (<=) */
46
+ LessThanOrEqual = 5,
47
+ /** 包含于 (IN) */
48
+ In = 6,
49
+ /** 不包含于 (NOT IN) */
50
+ NotIn = 7,
51
+ /** 区间 (BETWEEN) */
52
+ Between = 8,
53
+ /** 模糊匹配 (LIKE) */
54
+ Like = 9,
55
+ /** 为空 (IS NULL) */
56
+ IsNull = 10,
57
+ /** 不为空 (IS NOT NULL) */
58
+ IsNotNull = 11
59
+ }
60
+ /**
61
+ * 逻辑连接符枚举(与后端保持一致)
62
+ */
63
+ export declare enum MatchLogic {
64
+ /** 逻辑与(所有条件都满足) */
65
+ And = 0,
66
+ /** 逻辑或(任一条件满足) */
67
+ Or = 1
68
+ }
69
+ /**
70
+ * 规则 DTO(与后端保持一致)
71
+ */
72
+ export interface RuleDto {
73
+ /** 字段名称 */
74
+ fieldName: string;
75
+ /** 匹配操作符 */
76
+ operator: MatchOperator;
77
+ /** 匹配值 */
78
+ value?: any;
79
+ /** 第二个值(用于 Between 操作符) */
80
+ value2?: any;
81
+ }
82
+ /**
83
+ * 规则组 DTO(与后端保持一致)
84
+ */
85
+ export interface RuleGroupDto {
86
+ /** 逻辑关系 (And/Or) */
87
+ logic: MatchLogic;
88
+ /** 规则列表 */
89
+ rules: RuleDto[];
90
+ /** 嵌套规则组列表 */
91
+ groups: RuleGroupDto[];
92
+ }
93
+ /**
94
+ * 字段数据类型
95
+ */
96
+ export type FieldDataType = 'string' | 'number' | 'date' | 'boolean';
97
+ /**
98
+ * 字段定义
99
+ */
100
+ export interface FieldDefinition {
101
+ /** 字段名(与后端字段名对应) */
102
+ name: string;
103
+ /** 显示名称(UI 展示) */
104
+ displayName: string;
105
+ /** 数据类型 */
106
+ dataType: FieldDataType;
107
+ /** 字段说明 */
108
+ description?: string;
109
+ /** 允许的操作符(如不指定则根据数据类型自动过滤) */
110
+ allowedOperators?: MatchOperator[];
111
+ }
112
+ /**
113
+ * 验证错误
114
+ */
115
+ export interface ValidationError {
116
+ /** 错误位置路径 */
117
+ path: number[];
118
+ /** 错误信息 */
119
+ message: string;
120
+ /** 相关字段 */
121
+ field?: string;
122
+ }
123
+ /**
124
+ * 验证结果
125
+ */
126
+ export interface ValidationResult {
127
+ /** 是否有效 */
128
+ isValid: boolean;
129
+ /** 错误列表 */
130
+ errors: ValidationError[];
131
+ /** 警告列表 */
132
+ warnings: ValidationError[];
133
+ }
134
+ /**
135
+ * 规则构建器配置
136
+ */
137
+ export interface RuleBuilderConfig {
138
+ /** 静态字段定义 */
139
+ staticFields?: FieldDefinition[];
140
+ /** 动态字段 API 端点 */
141
+ fieldsApiUrl?: string;
142
+ /** 最大嵌套层级(默认 5) */
143
+ maxNestingLevel?: number;
144
+ /** 是否显示 JSON 预览 */
145
+ showJsonPreview?: boolean;
146
+ /** 自定义验证器 */
147
+ validator?: (rule: RuleGroupDto) => ValidationResult;
148
+ }
149
+ /**
150
+ * 规则构建器 Props
151
+ */
152
+ export interface RuleBuilderProps {
153
+ /** 初始规则(编辑模式) */
154
+ value?: RuleGroupDto | null;
155
+ /** 值变更回调 */
156
+ onChange?: (rule: RuleGroupDto | null) => void;
157
+ /** 配置 */
158
+ config?: RuleBuilderConfig;
159
+ /** 是否只读 */
160
+ readonly?: boolean;
161
+ }
162
+ /**
163
+ * 规则路径(用于定位嵌套规则)
164
+ */
165
+ export type RulePath = number[];
166
+ /**
167
+ * 规则构建器内部状态
168
+ */
169
+ export interface RuleBuilderState {
170
+ /** 当前规则组 */
171
+ ruleGroup: RuleGroupDto;
172
+ /** 字段定义列表 */
173
+ fields: FieldDefinition[];
174
+ /** 是否加载中 */
175
+ loading: boolean;
176
+ /** 验证结果 */
177
+ validationResult: ValidationResult;
178
+ /** 是否已修改 */
179
+ isDirty: boolean;
180
+ }
181
+ /**
182
+ * 规则构建器 Action
183
+ */
184
+ export type RuleBuilderAction = {
185
+ type: 'SET_RULE_GROUP';
186
+ payload: RuleGroupDto;
187
+ } | {
188
+ type: 'SET_FIELDS';
189
+ payload: FieldDefinition[];
190
+ } | {
191
+ type: 'SET_LOADING';
192
+ payload: boolean;
193
+ } | {
194
+ type: 'UPDATE_RULE';
195
+ payload: {
196
+ path: RulePath;
197
+ rule: RuleDto;
198
+ };
199
+ } | {
200
+ type: 'DELETE_RULE';
201
+ payload: {
202
+ path: RulePath;
203
+ };
204
+ } | {
205
+ type: 'ADD_RULE';
206
+ payload: {
207
+ path: RulePath;
208
+ rule: RuleDto;
209
+ };
210
+ } | {
211
+ type: 'UPDATE_RULE_GROUP';
212
+ payload: {
213
+ path: RulePath;
214
+ group: RuleGroupDto;
215
+ };
216
+ } | {
217
+ type: 'DELETE_RULE_GROUP';
218
+ payload: {
219
+ path: RulePath;
220
+ };
221
+ } | {
222
+ type: 'ADD_RULE_GROUP';
223
+ payload: {
224
+ path: RulePath;
225
+ group: RuleGroupDto;
226
+ };
227
+ } | {
228
+ type: 'SET_VALIDATION_RESULT';
229
+ payload: ValidationResult;
230
+ } | {
231
+ type: 'RESET';
232
+ };