openyida 0.1.2 → 1.0.0-beta.0

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 (61) hide show
  1. package/README.md +68 -38
  2. package/bin/yida.js +164 -761
  3. package/lib/babel-transform/index.js +244 -0
  4. package/lib/babel-transform/jsx-utils.js +89 -0
  5. package/lib/check-update.js +72 -0
  6. package/lib/copy.js +258 -0
  7. package/lib/create-app.js +174 -0
  8. package/lib/create-form.js +2244 -0
  9. package/lib/create-page.js +89 -0
  10. package/lib/env.js +164 -0
  11. package/lib/get-page-config.js +102 -0
  12. package/lib/get-schema.js +76 -0
  13. package/lib/login.js +323 -0
  14. package/lib/publish.js +610 -0
  15. package/lib/save-share-config.js +268 -0
  16. package/lib/update-form-config.js +237 -0
  17. package/lib/utils.js +443 -0
  18. package/lib/verify-short-url.js +279 -0
  19. package/package.json +20 -7
  20. package/project/.cache/demo-schema.json +2353 -0
  21. package/project/pages/src/demo-birthday-game.js +833 -0
  22. package/project/pages/src/demo-future-vision-2026.js +1102 -0
  23. package/project/pages/src/demo-salary-calculator.js +904 -0
  24. package/project/prd/demo-birthday-game.md +39 -0
  25. package/project/prd/demo-future-vision-2026.md +78 -0
  26. package/project/prd/demo-salary-calculator.md +101 -0
  27. package/scripts/postinstall.js +114 -0
  28. package/yida-skills/SKILL.md +273 -0
  29. package/yida-skills/reference/association-form-field.md +469 -0
  30. package/yida-skills/reference/employee-field.md +17 -0
  31. package/yida-skills/reference/model-api.md +73 -0
  32. package/yida-skills/reference/serial-number-field.md +132 -0
  33. package/yida-skills/reference/yida-api.md +1208 -0
  34. package/yida-skills/skills/yida-app/SKILL.md +394 -0
  35. package/yida-skills/skills/yida-create-app/SKILL.md +158 -0
  36. package/yida-skills/skills/yida-create-form-page/SKILL.md +598 -0
  37. package/yida-skills/skills/yida-create-page/SKILL.md +103 -0
  38. package/yida-skills/skills/yida-custom-page/SKILL.md +533 -0
  39. package/yida-skills/skills/yida-get-schema/SKILL.md +90 -0
  40. package/yida-skills/skills/yida-login/SKILL.md +200 -0
  41. package/yida-skills/skills/yida-logout/SKILL.md +58 -0
  42. package/yida-skills/skills/yida-page-config/SKILL.md +261 -0
  43. package/yida-skills/skills/yida-publish-page/SKILL.md +113 -0
  44. package/.eslintrc.json +0 -25
  45. package/.github/workflows/ci.yml +0 -123
  46. package/.github/workflows/publish.yml +0 -105
  47. package/.github/workflows/update-contributors.yml +0 -151
  48. package/.openclaw/skills/yida-issue/SKILL.md +0 -27
  49. package/.openclaw/skills/yida-issue/scripts/create-issue.js +0 -317
  50. package/CLAUDE.md +0 -168
  51. package/CONTRIBUTING.md +0 -59
  52. package/install-skills.ps1 +0 -162
  53. package/install-skills.sh +0 -175
  54. package/pages/dist/.gitkeep +0 -0
  55. package/pages/src/.gitkeep +0 -0
  56. package/prd/salary-calculator.md +0 -15
  57. package/tests/cli.test.js +0 -930
  58. package/tests/install.test.js +0 -277
  59. package/tests/yida-issue.test.js +0 -314
  60. /package/{config.json → project/config.json} +0 -0
  61. /package/{.cache → project/pages/dist}/.gitkeep +0 -0
@@ -0,0 +1,469 @@
1
+ # 关联表单字段完整使用指南
2
+
3
+ 关联表单字段(`AssociationFormField`)用于在当前表单中选择另一个表单的数据记录,并支持数据过滤和自动填充功能。
4
+
5
+ ## 核心配置说明
6
+
7
+ **1. 基础配置**
8
+
9
+ ```json
10
+ {
11
+ "type": "AssociationFormField",
12
+ "label": "关联字段名",
13
+ "required": true,
14
+ "multiple": false,
15
+ "hasClear": true,
16
+ "isShowSearchBar": true,
17
+ "associationForm": {
18
+ "formUuid": "FORM-XXX",
19
+ "appType": "APP_xxx",
20
+ "appName": "应用名称",
21
+ "formTitle": "表单名称",
22
+ "mainFieldId": "textField_xxx", // 主要信息
23
+ "subFieldId": "selectField_mhokb6fa", // 次要信息组件 FieldId
24
+ "subComponentName": "SelectField", // 次要信息组件类型
25
+ "mainFieldLabel": "主显示字段标签",
26
+ "mainComponentName": "TextField",
27
+ "tableShowType": "custom",
28
+ "customTableFields": ["textField_xxx", "numberField_xxx"]
29
+ }
30
+ }
31
+ ```
32
+
33
+ **2. 数据过滤规则(dataFilterRules)**
34
+
35
+ 用于限制关联表单选择器中展示的数据范围,支持多条件组合筛选:
36
+
37
+ ```json
38
+ {
39
+ "dataFilterRules": {
40
+ "condition": "AND",
41
+ "rules": [
42
+ {
43
+ "id": "目标表单字段 fieldId",
44
+ "name": "字段标签",
45
+ "componentType": "TextField",
46
+ "type": "TextField",
47
+ "op": "contains",
48
+ "filterType": "bizField",
49
+ "extValue": "field",
50
+ "ruleValue": "当前表单字段 fieldId",
51
+ "value": "当前表单字段 fieldId",
52
+ "valueType": "value",
53
+ "ruleType": "rule_text",
54
+ "ruleId": "item-唯一 ID"
55
+ }
56
+ ],
57
+ "ruleId": "group-唯一 ID",
58
+ "instanceFieldId": "",
59
+ "version": "v2"
60
+ }
61
+ }
62
+
63
+ ```
64
+
65
+ **常用操作符(op)**:
66
+ - `eq` - 等于
67
+ - `is_not` - 不等于
68
+ - `contains` - 包含
69
+ - `not_contains` - 不包含
70
+
71
+ **extValue 说明**:
72
+ - `"field"` - 筛选值来源于当前表单的某个字段(`ruleValue` 填写当前表单的 fieldId)
73
+ - `"value"` - 筛选值为固定值(`ruleValue` 填写具体值)
74
+
75
+ **3. 数据回填规则(dataFillingRules)**
76
+
77
+ 用于在选中关联表单记录后,自动将目标表单的字段值填充到当前表单的字段中:
78
+
79
+ ```json
80
+ {
81
+ "dataFillingRules": {
82
+ "mainRules": [
83
+ {
84
+ "source": "目标表单字段 fieldId(数据来源)",
85
+ "sourceType": "TextField",
86
+ "target": "当前表单字段 fieldId(填充目标)",
87
+ "targetType": "TextField"
88
+ }
89
+ ],
90
+ "tableRules": [],
91
+ "version": "v2"
92
+ }
93
+ }
94
+ ```
95
+
96
+ > ⚠️ **脚本内部实际生成的完整格式**(6 个字段,缺少任意一个回填不生效):
97
+ >
98
+ > | 字段 | 说明 |
99
+ > |------|------|
100
+ > | `sourceFieldId` | 源字段 ID(与 `source` 相同,兼容旧格式) |
101
+ > | `targetFieldId` | 目标字段 ID(与 `target` 相同,兼容旧格式) |
102
+ > | `source` | 同 `sourceFieldId` |
103
+ > | `sourceType` | 源字段组件类型,如 `SerialNumberField`、`TextField` |
104
+ > | `target` | 同 `targetFieldId` |
105
+ > | `targetType` | 目标字段组件类型,如 `TextField`、`NumberField` |
106
+ >
107
+ > 配置时只需填写 `source/sourceType/target/targetType` 四个字段,脚本的 `normalizeFillingRules` 函数会自动补全 `sourceFieldId` 和 `targetFieldId`,并根据 fieldId 前缀自动推断组件类型(如 `serialNumberField_xxx` → `SerialNumberField`)。
108
+
109
+ **重要说明**:
110
+ - `mainRules` 用于主表字段之间的回填(最常用)
111
+ - `tableRules` 用于**子表填充子表**的回填(将关联表单的子表数据填充到当前表单的子表中)
112
+ - `source` 和 `target` 必须填写**字段 ID(fieldId)**,而非字段标签;支持 `@label:字段标签` 语法,脚本会自动解析为真实 fieldId
113
+ - `sourceType` 和 `targetType` 必须与目标字段的组件类型一致;如果不填,脚本会根据 fieldId 前缀自动推断
114
+ - 脚本会**自动推断**`supportDataFilling` 的值:当 `mainRules` 或 `tableRules` 非空时自动设为 `true`,否则为 `false`
115
+ - 如果配置了回填规则但实际不生效,请检查:
116
+ 1. `source` 和 `target` 的 fieldId 是否正确(可通过 get-schema 技能查看)
117
+ 2. `sourceType` 和 `targetType` 是否与字段类型一致
118
+ 3. `dataFillingRules` 是否被正确设置到 `props.dataFillingRules`(而非只写在 `associationForm` 对象内)
119
+ 4. 关联表单字段的 Schema 节点**顶层**是否有 `fieldId` 属性(宜搭回填引擎依赖顶层 `fieldId` 识别字段,仅在 `props` 内有 `fieldId` 不生效)
120
+
121
+ **子表填充子表(tableRules)格式**:
122
+
123
+ ```json
124
+ {
125
+ "dataFillingRules": {
126
+ "mainRules": [
127
+ {
128
+ "source": "目标表单主表字段 fieldId",
129
+ "sourceType": "TextField",
130
+ "target": "@label:当前表单主表字段标签",
131
+ "targetType": "TextField"
132
+ }
133
+ ],
134
+ "tableRules": [
135
+ {
136
+ "tableId": "被关联表单(源表)的子表字段 fieldId",
137
+ "rules": [
138
+ {
139
+ "source": "目标表单子表字段 fieldId",
140
+ "sourceType": "TextareaField",
141
+ "target": "@label:当前表单子表内字段标签",
142
+ "targetType": "TextField"
143
+ }
144
+ ],
145
+ "filters": ""
146
+ }
147
+ ],
148
+ "version": "v2"
149
+ }
150
+ }
151
+ ```
152
+
153
+ **tableRules 字段说明**:
154
+
155
+ | 字段 | 类型 | 必填 | 说明 |
156
+ | --- | --- | --- | --- |
157
+ | `tableId` | String | 是 | ⚠️ **被关联表单(源表)的子表字段 fieldId**,不是当前表单的子表 fieldId |
158
+ | `rules` | Array | 是 | 子表内的字段映射规则数组 |
159
+ | `rules[].source` | String | 是 | 关联表单子表中的源字段 fieldId |
160
+ | `rules[].target` | String | 是 | 当前表单子表中的目标字段 fieldId,支持 `@label:字段标签` 语法 |
161
+ | `rules[].sourceType` | String | 是 | 源字段类型,如 `TextareaField`、`NumberField` 等 |
162
+ | `rules[].targetType` | String | 是 | 目标字段类型,需与目标字段实际类型一致 |
163
+ | `filters` | String | 否 | 过滤条件,通常为空字符串 |
164
+
165
+ **注意事项**:
166
+ - `tableRules` 用于实现"选择关联表单记录后,将其子表数据自动填充到当前表单的子表中"
167
+ - **`tableId` 必须填写被关联表单(源表)的子表 fieldId**,宜搭通过它在源表 Schema 中定位子表数据;填写当前表单的子表 fieldId 会导致 `getInstMultiSubTableDatas` 接口报 500 错误
168
+ - 每个 `tableRule` 对应源表的一个子表,可以配置多个子表的回填规则
169
+ - 子表内的 `target` 同样支持 `@label:字段标签` 语法,脚本会自动解析为 fieldId
170
+ - 确保 `rules[].source` 是源表子表内的字段 fieldId,`rules[].target` 是当前表单子表内的字段 fieldId
171
+
172
+ #### 完整使用示例
173
+
174
+ **场景**:创建任务表,关联人员信息表,选择人员后自动填充年龄
175
+
176
+ **步骤 1:创建人员信息表**
177
+
178
+ ```json
179
+ [
180
+ {
181
+ "type": "TextField",
182
+ "label": "姓名",
183
+ "required": true,
184
+ "placeholder": "请输入姓名"
185
+ },
186
+ {
187
+ "type": "NumberField",
188
+ "label": "年龄",
189
+ "required": true,
190
+ "placeholder": "请输入年龄"
191
+ }
192
+ ]
193
+ ```
194
+
195
+ 执行创建后,记录返回的 `formUuid` 和各字段 `fieldId`:
196
+ - formUuid: `FORM-XXX`
197
+ - 姓名 fieldId: `textField_xxx`
198
+ - 年龄 fieldId: `numberField_xxx`
199
+
200
+ **步骤 2:创建任务表(带关联表单和自动填充)**
201
+
202
+ ```json
203
+ [
204
+ {
205
+ "type": "TextField",
206
+ "label": "任务名称",
207
+ "required": true,
208
+ "placeholder": "请输入任务名称"
209
+ },
210
+ {
211
+ "type": "AssociationFormField",
212
+ "label": "选择人员",
213
+ "required": true,
214
+ "multiple": false,
215
+ "hasClear": true,
216
+ "isShowSearchBar": true,
217
+ "associationForm": {
218
+ "formUuid": "FORM-XXX",
219
+ "appType": "APP_xxx",
220
+ "appName": "测试应用",
221
+ "formTitle": "人员信息表",
222
+ "mainFieldId": "textField_xxx",
223
+ "mainFieldLabel": "姓名",
224
+ "mainComponentName": "TextField",
225
+ "tableShowType": "custom",
226
+ "customTableFields": ["textField_xxx", "numberField_xxx"],
227
+ "dataFillingRules": {
228
+ "mainRules": [
229
+ {
230
+ "source": "numberField_xxx",
231
+ "sourceType": "NumberField",
232
+ "target": "@label:年龄",
233
+ "targetType": "NumberField"
234
+ }
235
+ ],
236
+ "tableRules": [],
237
+ "version": "v2"
238
+ }
239
+ }
240
+ },
241
+ {
242
+ "type": "NumberField",
243
+ "label": "年龄",
244
+ "required": true,
245
+ "placeholder": "选择人员后自动填充"
246
+ }
247
+ ]
248
+ ```
249
+
250
+ **注意事项**:
251
+ 1. 必须先创建被关联的表单(人员信息表),获取其 `formUuid` 和字段 `fieldId`(通过 `get-schema` 技能查看)
252
+ 2. `dataFillingRules` 中的 `target` 使用 `@label:年龄` 语法,脚本会自动将其解析为当前表单中「年龄」字段的真实 fieldId,**无需手动查找**
253
+ 3. `source` 填写被关联表单(人员信息表)中年龄字段的真实 fieldId
254
+ 4. 脚本会自动设置 `supportDataFilling: true`,无需手动配置
255
+
256
+ #### 子表填充子表示例
257
+
258
+ **场景**:创建订单表,关联商品表,选择商品后将商品明细(子表)自动填充到订单明细(子表)
259
+
260
+ **步骤 1:创建商品表(含商品明细子表)**
261
+
262
+ ```json
263
+ [
264
+ {
265
+ "type": "TextField",
266
+ "label": "商品名称",
267
+ "required": true
268
+ },
269
+ {
270
+ "type": "NumberField",
271
+ "label": "商品单价",
272
+ "required": true
273
+ },
274
+ {
275
+ "type": "TableField",
276
+ "label": "规格明细",
277
+ "children": [
278
+ { "type": "TextField", "label": "规格名称" },
279
+ { "type": "NumberField", "label": "规格价格" },
280
+ { "type": "NumberField", "label": "库存数量" }
281
+ ]
282
+ }
283
+ ]
284
+ ```
285
+
286
+ 执行创建后,记录返回的 `formUuid` 和各字段 `fieldId`:
287
+ - formUuid: `FORM-XXX`
288
+ - 商品名称 fieldId: `textField_xxx`
289
+ - 商品单价 fieldId: `numberField_xxx`
290
+ - 规格明细(子表)fieldId: `tableField_xxx`
291
+ - 规格名称(子表内)fieldId: `textField_xxx`
292
+ - 规格价格(子表内)fieldId: `numberField_xxx`
293
+ - 库存数量(子表内)fieldId: `numberField_xxx`
294
+
295
+ **步骤 2:创建订单表(带子表和关联表单)**
296
+
297
+ ```json
298
+ [
299
+ {
300
+ "type": "TextField",
301
+ "label": "订单编号",
302
+ "required": true
303
+ },
304
+ {
305
+ "type": "AssociationFormField",
306
+ "label": "选择商品",
307
+ "required": true,
308
+ "associationForm": {
309
+ "formUuid": "FORM-XXX",
310
+ "appType": "APP_xxx",
311
+ "appName": "商品管理",
312
+ "formTitle": "商品信息表",
313
+ "mainFieldId": "textField_xxx",
314
+ "mainFieldLabel": "商品名称",
315
+ "mainComponentName": "TextField",
316
+ "tableShowType": "custom",
317
+ "customTableFields": ["textField_xxx", "numberField_xxx"],
318
+ "dataFillingRules": {
319
+ "mainRules": [
320
+ {
321
+ "source": "numberField_xxx",
322
+ "sourceType": "NumberField",
323
+ "target": "@label:商品单价",
324
+ "targetType": "NumberField"
325
+ }
326
+ ],
327
+ "tableRules": [
328
+ {
329
+ "tableId": "@label:订单明细",
330
+ "rules": [
331
+ {
332
+ "source": "textField_xxx",
333
+ "sourceType": "TextField",
334
+ "target": "@label:规格",
335
+ "targetType": "TextField"
336
+ },
337
+ {
338
+ "source": "numberField_xxx",
339
+ "sourceType": "NumberField",
340
+ "target": "@label:单价",
341
+ "targetType": "NumberField"
342
+ },
343
+ {
344
+ "source": "numberField_xxx",
345
+ "sourceType": "NumberField",
346
+ "target": "@label:数量",
347
+ "targetType": "NumberField"
348
+ }
349
+ ],
350
+ "filters": ""
351
+ }
352
+ ],
353
+ "version": "v2"
354
+ }
355
+ }
356
+ },
357
+ {
358
+ "type": "NumberField",
359
+ "label": "商品单价",
360
+ "required": true
361
+ },
362
+ {
363
+ "type": "TableField",
364
+ "label": "订单明细",
365
+ "children": [
366
+ { "type": "TextField", "label": "规格" },
367
+ { "type": "NumberField", "label": "单价" },
368
+ { "type": "NumberField", "label": "数量" }
369
+ ]
370
+ }
371
+ ]
372
+ ```
373
+
374
+ **关键点说明**:
375
+ 1. `tableRules` 中的 `tableId` 填写的是**被关联表单(商品表)的子表 fieldId**(即「规格明细」子表的 fieldId),而非当前表单(订单表)的子表 fieldId。宜搭通过此 fieldId 在源表 Schema 中定位子表数据,填错会导致 `getInstMultiSubTableDatas` 接口报 500 错误
376
+ 2. `tableRules` 中的每个 `rule.target` 支持 `@label:字段标签` 语法,用于定位当前表单子表内的字段
377
+ 3. 选择商品后,商品表的「规格明细」子表数据会自动填充到订单表的「订单明细」子表中
378
+ 4. 可以配置多个 `tableRule` 来实现多子表的数据回填
379
+
380
+ #### 常见问题排查
381
+
382
+ **问题 1:关联表单选择后没有自动填充**
383
+ - 检查 `dataFillingRules.mainRules` 是否非空
384
+ - 检查 `source` 和 `target` 的 fieldId 是否正确(可通过 get-schema 技能查看)
385
+ - 检查 `sourceType` 和 `targetType` 是否与字段类型一致
386
+ - 确认 `props.supportDataFilling` 是否为 `true`
387
+ - 确认每条规则同时包含 `sourceFieldId/targetFieldId/source/sourceType/target/targetType` 6 个字段(缺少任意一个不生效)
388
+ - 确认关联表单字段的 Schema 节点**顶层**有 `fieldId` 属性(宜搭回填引擎依赖顶层 `fieldId`,仅在 `props` 内有 `fieldId` 不生效)
389
+
390
+ **问题 2:子表填充子表不生效**
391
+ - 检查 `tableRules` 是否为数组且非空
392
+ - 检查 `tableId` 是否正确(⚠️ 应为**被关联表单(源表)的子表 fieldId**,不是当前表单的子表 fieldId)
393
+ - 检查 `tableRules[].rules` 是否为数组且非空
394
+ - 检查子表内的 `source` 和 `target` fieldId 是否正确
395
+ - 确认 `tableId` 对应的子表字段在被关联表单中存在
396
+ - 查看控制台输出是否有 `📋 处理子表回填规则` 的日志
397
+
398
+ **问题 3:关联表单选择器中显示的数据不对**
399
+ - 检查 `dataFilterRules` 配置是否正确
400
+ - 检查 `ruleValue` 指向的当前表单字段是否有值
401
+ - 检查 `op` 操作符是否合适
402
+
403
+ **问题 4:关联表单选择器中显示的字段不对**
404
+ - 检查 `mainFieldId` 是否为主显示字段的 fieldId
405
+ - 检查 `customTableFields` 是否包含需要展示的字段 fieldId
406
+ - 检查 `tableShowType` 是否为 `"custom"`(如需自定义展示)
407
+ #### 完整使用示例
408
+
409
+ ```json
410
+ {
411
+ "type": "AssociationFormField",
412
+ "label": "选择门店人员",
413
+ "required": true,
414
+ "multiple": false,
415
+ "associationForm": {
416
+ "formUuid": "FORM-447E4C1A330B4D8E975A49D6B8514DBFCLT5",
417
+ "appType": "APP_U4PQPSBLV0DI311TCFY7",
418
+ "appName": "一群",
419
+ "formTitle": "导购信息",
420
+ "mainFieldId": "textField_mi2zgd95",
421
+ "mainFieldLabel": "姓名",
422
+ "mainComponentName": "TextField",
423
+ "tableShowType": "custom",
424
+ "customTableFields": [
425
+ "textField_mi2zgd95",
426
+ "selectField_mhvrw9zj",
427
+ "employeeField_mii8l25k"
428
+ ],
429
+ "subFieldId": "selectField_mhokb6fa",
430
+ "subComponentName": "SelectField",
431
+ "dataFilterRules": {
432
+ "condition": "AND",
433
+ "rules": [
434
+ {
435
+ "id": "textField_mhvrw9zt",
436
+ "name": "门店编码",
437
+ "componentType": "TextField",
438
+ "type": "TextField",
439
+ "op": "contains",
440
+ "filterType": "bizField",
441
+ "extValue": "field",
442
+ "ruleValue": "multiSelectField_mksf6jwb",
443
+ "value": "multiSelectField_mksf6jwb",
444
+ "valueType": "value",
445
+ "ruleType": "rule_text",
446
+ "ruleId": "item-唯一ID"
447
+ }
448
+ ],
449
+ "ruleId": "group-唯一ID",
450
+ "instanceFieldId": "",
451
+ "version": "v2"
452
+ },
453
+ "dataFillingRules": {
454
+ "mainRules": [
455
+ {
456
+ "source": "employeeField_mhok3twl",
457
+ "sourceType": "EmployeeField",
458
+ "target": "employeeField_mff5ro7o",
459
+ "targetType": "EmployeeField"
460
+ }
461
+ ],
462
+ "tableRules": [],
463
+ "version": "v2"
464
+ },
465
+ "orderConfig": [
466
+ { "fieldId": "textField_mhvrw9zt", "order": "desc" }
467
+ ]
468
+ }
469
+ }
@@ -0,0 +1,17 @@
1
+ ## EmployeeField 设置默认值为当前登录人
2
+
3
+ 宜搭 EmployeeField 设置默认值为当前登录人,需要添加以下三个属性:
4
+
5
+ ```json
6
+ {
7
+ "valueType": "variable",
8
+ "complexValue": {
9
+ "complexType": "formula",
10
+ "formula": "USER()",
11
+ "value": []
12
+ },
13
+ "variable": {
14
+ "type": "user"
15
+ }
16
+ }
17
+ ```
@@ -0,0 +1,73 @@
1
+ # 大模型 AI 接口
2
+
3
+ ## txtFromAI
4
+
5
+ **描述**:输入提示词,调用大模型接口返回文本
6
+
7
+ **接口地址**:`/query/intelligent/txtFromAI.json`
8
+
9
+ **请求方式**:POST
10
+
11
+ **Content-Type**:`application/x-www-form-urlencoded`
12
+
13
+ ### 请求参数
14
+
15
+ | 参数名 | 类型 | 是否必填 | 描述 | 示例 |
16
+ | --- | --- | --- | --- | --- |
17
+ | _csrf_token | String | 是 | CSRF 令牌,从 `window.g_config._csrf_token` 获取 | `06109173-62b8-461a-89b8-a9baca5d9c86` |
18
+ | prompt | String | 是 | 提示词内容 | `请生成一段描述` |
19
+ | maxTokens | String | 否 | 最大返回 token 数 | `3000` |
20
+ | skill | String | 是 | 技能类型 | `ToText` |
21
+
22
+ ### 返回值
23
+
24
+ | 字段 | 类型 | 描述 |
25
+ | --- | --- | --- |
26
+ | success | Boolean | 请求是否成功 |
27
+ | errorCode | String | 错误码 |
28
+ | errorMsg | String | 错误信息 |
29
+ | content | Object | 返回内容对象 |
30
+ | content.content | String | 大模型生成的文本内容 |
31
+ | content.damo_requestId | String | 请求唯一标识 |
32
+ | content.usage | Object | token 用量统计 |
33
+ | content.usage.input_tokens | Number | 输入 token 数 |
34
+ | content.usage.onput_tokens | Number | 输出 token 数 |
35
+
36
+ ### 请求示例
37
+
38
+ ```javascript
39
+ fetch('/query/intelligent/txtFromAI.json', {
40
+ method: 'POST',
41
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
42
+ body: new URLSearchParams({
43
+ _csrf_token: window.g_config._csrf_token,
44
+ prompt: '提示词内容',
45
+ maxTokens: '3000',
46
+ skill: 'ToText',
47
+ }).toString(),
48
+ }).then((res) => res.json())
49
+ .then((data) => {
50
+ console.log('AI返回内容', data.content.content);
51
+ });
52
+ ```
53
+
54
+ ### 返回值示例
55
+
56
+ ```json
57
+ {
58
+ "content": {
59
+ "usage": {
60
+ "onput_tokens": 11,
61
+ "input_tokens": 91
62
+ },
63
+ "damo_requestId": "chatcmpl-26a868b5-e3e1-9ddb-a310-d1336299f9b9",
64
+ "content": "大模型生成的文本内容"
65
+ },
66
+ "errorCode": "",
67
+ "errorExtInfo": null,
68
+ "errorLevel": "",
69
+ "errorMsg": "",
70
+ "success": true,
71
+ "throwable": ""
72
+ }
73
+ ```
@@ -0,0 +1,132 @@
1
+ ## SerialNumberField 流水号规则详解
2
+
3
+ ### 默认场景(无自定义需求)
4
+
5
+ 只有一条 `autoCount` 规则,4 位自增,从 1 开始,不重置:
6
+
7
+ ```json
8
+ {
9
+ "serialNumberRule": [
10
+ {
11
+ "resetPeriod": "noClean",
12
+ "dateFormat": "yyyyMMdd",
13
+ "ruleType": "autoCount",
14
+ "timeZone": "+8",
15
+ "__sid": "item_auto_count",
16
+ "__hide_delete__": true,
17
+ "__sid__": "serial_auto_count",
18
+ "digitCount": "4",
19
+ "isFixed": true,
20
+ "initialValue": 1,
21
+ "content": "",
22
+ "formField": ""
23
+ }
24
+ ],
25
+ "serialNumPreview": "0001"
26
+ }
27
+ ```
28
+
29
+ > ⚠️ 注意:默认场景的 `autoCount` 规则 `__hide_delete__` 必须为 `true`(不可删除),`digitCount` 为字符串 `"4"`。
30
+
31
+ ### 自定义场景(多规则组合)
32
+
33
+ 支持以下 4 种规则类型,可任意组合排列:
34
+
35
+ | `ruleType` | 说明 | 关键字段 |
36
+ | --- | --- | --- |
37
+ | `autoCount` | 自动计数(自增数字) | `digitCount`(位数,字符串)、`initialValue`(起始值)、`resetPeriod`(重置周期) |
38
+ | `character` | 固定字符 | `content`(固定字符串内容) |
39
+ | `date` | 提交日期 | `dateFormat`(日期格式,如 `"yy"`、`"yyyyMMdd"`) |
40
+ | `form` | 取表单字段值 | `formField`(字段 fieldId) |
41
+
42
+ **自定义规则通用结构**:
43
+
44
+ ```json
45
+ {
46
+ "resetPeriod": "noClean",
47
+ "dateFormat": "yyyyMMdd",
48
+ "ruleType": "<类型>",
49
+ "timeZone": "+8",
50
+ "__sid": "item_<唯一id>",
51
+ "__hide_delete__": false,
52
+ "__sid__": "serial_<唯一id>",
53
+ "digitCount": 4,
54
+ "isFixed": true,
55
+ "initialValue": 1,
56
+ "content": "<固定字符,仅 character 类型填写>",
57
+ "formField": "<字段fieldId,仅 form 类型填写>",
58
+ "isFixedTips": "",
59
+ "resetPeriodTips": ""
60
+ }
61
+ ```
62
+
63
+ > ⚠️ 注意:自定义规则中 `digitCount` 为**数字**类型(不是字符串),`__hide_delete__` 为 `false`;而默认 `autoCount` 规则的 `digitCount` 是**字符串** `"4"`,`__hide_delete__` 为 `true`。
64
+
65
+ **`resetPeriod` 重置周期可选值**:
66
+
67
+ | 值 | 说明 |
68
+ | --- | --- |
69
+ | `"noClean"` | 不重置(永久自增) |
70
+ | `"day"` | 每天重置 |
71
+ | `"month"` | 每月重置 |
72
+ | `"year"` | 每年重置 |
73
+
74
+ **`dateFormat` 日期格式可选值**(`date` 类型规则):
75
+
76
+ | 值 | 示例 |
77
+ | --- | --- |
78
+ | `"yy"` | `26`(年份后两位) |
79
+ | `"yyyy"` | `2026` |
80
+ | `"yyyyMM"` | `202603` |
81
+ | `"yyyyMMdd"` | `20260311` |
82
+
83
+ **示例:`YY-提交日期-自动计数4位` 的规则配置**:
84
+
85
+ ```json
86
+ {
87
+ "serialNumberRule": [
88
+ {
89
+ "ruleType": "character",
90
+ "content": "YY",
91
+ "dateFormat": "yyyyMMdd", "timeZone": "+8",
92
+ "resetPeriod": "noClean", "digitCount": 4,
93
+ "isFixed": true, "initialValue": 1,
94
+ "isFixedTips": "", "resetPeriodTips": "",
95
+ "formField": "",
96
+ "__sid": "item_char_yy", "__sid__": "serial_char_yy", "__hide_delete__": false
97
+ },
98
+ {
99
+ "ruleType": "date",
100
+ "content": "",
101
+ "dateFormat": "yy", "timeZone": "+8",
102
+ "resetPeriod": "noClean", "digitCount": 4,
103
+ "isFixed": true, "initialValue": 1,
104
+ "isFixedTips": "", "resetPeriodTips": "",
105
+ "formField": "",
106
+ "__sid": "item_date_yy", "__sid__": "serial_date_yy", "__hide_delete__": false
107
+ },
108
+ {
109
+ "ruleType": "autoCount",
110
+ "content": "",
111
+ "dateFormat": "yyyyMMdd", "timeZone": "+8",
112
+ "resetPeriod": "noClean", "digitCount": 4,
113
+ "isFixed": true, "initialValue": 1,
114
+ "isFixedTips": "", "resetPeriodTips": "",
115
+ "formField": "",
116
+ "__sid": "item_auto", "__sid__": "serial_auto", "__hide_delete__": true
117
+ }
118
+ ],
119
+ "serialNumPreview": "YY260001"
120
+ }
121
+ ```
122
+
123
+ ### formula 构建规则
124
+
125
+ `formula` 必须是**对象格式**(不是字符串),`expression` 的最后一个参数是 `{ "type": "custom", "value": <serialNumberRule数组> }` 的 JSON 字符串,需对双引号转义:
126
+
127
+ ```javascript
128
+ var ruleJson = JSON.stringify({ type: 'custom', value: serialNumberRule });
129
+ var escapedRuleJson = ruleJson.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
130
+ var expression = 'SERIALNUMBER("' + corpId + '", "' + appType + '", "' + formUuid + '", "' + fieldId + '", "' + escapedRuleJson + '")';
131
+ obj.formula = { expression: expression };
132
+ ```