cloud-web-corejs 1.0.54-dev.688 → 1.0.54-dev.689

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 (24) hide show
  1. package/package.json +1 -1
  2. package/src/components/fileLibrary/index.vue +113 -33
  3. package/src/components/xform/docs//345/220/216/345/217/260/345/255/227/346/256/265/357/274/210/345/212/250/346/200/201/347/224/237/346/210/220/357/274/211JSON /350/257/264/346/230/216.md" +210 -305
  4. package/src/components/xform/docs//346/225/260/346/215/256/350/241/250/346/240/274/345/212/250/346/200/201/345/210/227 JSON /350/257/264/346/230/216.md" +657 -0
  5. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +80 -14
  6. package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +18 -13
  7. package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +11 -8
  8. package/src/components/xform/form-designer/form-widget/field-widget/script-input-widget.vue +143 -0
  9. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +87 -25
  10. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +5 -0
  11. package/src/components/xform/form-designer/setting-panel/property-editor/container-table/table-dynamicField-editor.vue +80 -34
  12. package/src/components/xform/form-designer/setting-panel/property-editor/field-script-input/script-input-editor.vue +54 -0
  13. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
  14. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +56 -1
  15. package/src/components/xform/form-render/container-item/data-table-mixin.js +296 -118
  16. package/src/components/xform/form-render/container-item/dynamicFieldMixin.js +25 -37
  17. package/src/components/xform/form-render/container-item/list-h5-item.vue +5 -1
  18. package/src/components/xform/form-render/indexMixin.js +175 -6
  19. package/src/components/xform/lang/en-US.js +1 -0
  20. package/src/components/xform/lang/zh-CN.js +1 -0
  21. package/src/components/xform/utils/dynamicSchemaUtil.js +312 -0
  22. package/src/components/xform/utils/tableCellValidateUtil.js +148 -0
  23. package/src/components/xform/utils/tableColumnHelper.js +21 -1
  24. package/src/components/xform/utils/util.js +126 -0
@@ -1,8 +1,14 @@
1
1
  # 后台字段(动态生成)JSON 说明
2
2
 
3
- > 适用场景:表格布局容器(`table`)启用 **后台字段(动态生成)**(`dynamicSchemaEnabled`)后,后台脚本返回字段定义,前端运行时生成并渲染表单控件。
3
+ > 适用场景:
4
+ > - 表格布局容器(`table`)启用 **后台字段(动态生成)**(`dynamicSchemaEnabled`)
5
+ > - 数据表格(`data-table`)启用 **接口动态列**(`dynamicColumnSourceType: api`)
4
6
  >
5
- > 相关代码:`form-render/container-item/dynamicFieldMixin.js`
7
+ > 二者共用同一套请求/响应与字段定义 JSON 格式(见 `utils/dynamicSchemaUtil.js`)。
8
+ >
9
+ > **文档分工:** 本文维护控件类型与 options(**唯一维护点**);数据表格差异(width、formatS、操作列等)见 [`数据表格动态列 JSON 说明.md`](./数据表格动态列%20JSON%20说明.md)。
10
+ >
11
+ > 相关代码:`form-render/container-item/dynamicFieldMixin.js`、`data-table-mixin.js`
6
12
 
7
13
  ---
8
14
 
@@ -14,6 +20,7 @@
14
20
  → 解析响应为「字段定义数组」
15
21
  → 按生成模式(append/replace/anchor)插入行布局
16
22
  → 各字段控件初始化(下拉/状态等可能再次请求选项数据)
23
+ → (业务需要时)脚本调用 loadDynamicSchema() 重新加载,见 §1.5
17
24
  ```
18
25
 
19
26
  ### 1.1 请求参数(前端 → 后台字段脚本)
@@ -37,7 +44,7 @@
37
44
 
38
45
  ```json
39
46
  {
40
- "success": true,
47
+ "type": "success",
41
48
  "message": "ok",
42
49
  "objx": []
43
50
  }
@@ -45,57 +52,121 @@
45
52
 
46
53
  ### 1.3 objx 解析规则(未配置转换脚本时)
47
54
 
48
- 按以下优先级取字段定义数组:
55
+ 按以下优先级取字段/列定义数组:
56
+
57
+ | 优先级 | 结构 | 场景 |
58
+ |--------|------|------|
59
+ | 1 | `objx` 为数组 | 通用 |
60
+ | 2 | `objx.fields` 为数组 | 表头后台字段 |
61
+ | 3 | `objx.columns` 为数组 | 数据表格动态列 |
62
+
63
+ 配置了 **转换脚本** `dynamicSchemaConvert` 时,入参为完整 `res`,需返回数组或 `{ fields: [...] }` / `{ columns: [...] }`。
64
+
65
+ ### 1.4 数据表格接口动态列
66
+
67
+ 数据表格请求时会额外携带 `formCode`、`formVersion`、`taBm`、`dataId`,内层 `data` 仍为 `{ formData, ...extra }`。
68
+
69
+ 后台可返回与表头字段相同的 `type` + `keyName` 定义,前端自动映射为列 `formatS`(如 `input` → `editInput`)。展示列使用 `keyName` + `formatS`。
70
+
71
+ **数据表格专用文档(含各列类型完整示例):** [`数据表格动态列 JSON 说明.md`](./数据表格动态列%20JSON%20说明.md)
72
+
73
+ ### 1.5 脚本重新加载(表头后台字段)
74
+
75
+ 首次加载在 `table` 容器 `mounted` 时自动执行。主表数据或业务条件变化后,需在脚本里**手动**调用以重新请求后台并刷新字段。
76
+
77
+ **任意字段 / 按钮脚本(写法相同):**
78
+
79
+ ```javascript
80
+ this.getWidgetRef("headerTable").loadDynamicSchema();
81
+ ```
82
+
83
+ > 字段与容器共用表单级 `refList`,**无需** `getParentTarget().getWidgetRef(...)`。
84
+ > `getParentTarget()` 仅用于操作列等场景直接调用**父级 data-table** 的方法(如 `deleteRow`),见本文数据表格文档操作列示例。
85
+
86
+ **等待加载完成:**
87
+
88
+ ```javascript
89
+ this.getWidgetRef("headerTable").loadDynamicSchema().then(() => {
90
+ // 动态行已重新生成,formModel 已补全新字段默认值
91
+ });
92
+ ```
93
+
94
+ | 项目 | 说明 |
95
+ |------|------|
96
+ | 方法 | `loadDynamicSchema()` |
97
+ | 挂载组件 | `table-item`(`dynamicFieldMixin.js`) |
98
+ | 行为 | 删除上次动态生成的行 → 用当前 `formModel` +「脚本返回对应的参数值」重新请求 → 按 `dynamicSchemaMode` 插入 |
99
+ | 默认 loading | 不显示全屏 loading |
100
+ | 前提 | `dynamicSchemaEnabled: true` 且已配置 `dynamicSchemaScriptCode` |
49
101
 
50
- | 优先级 | 结构 |
51
- |--------|------|
52
- | 1 | `objx` 本身为数组 |
53
- | 2 | `objx.fields` 为数组 |
54
- | 3 | `objx.columns` 为数组 |
102
+ 典型场景:主表 `billType` 变更、保存/加载单据后、点击「刷新表头」按钮。
55
103
 
56
- 配置了 **转换脚本** 时,入参为完整 `res`,需返回数组或 `{ fields: [...] }`。
104
+ 数据表格动态列重新加载见 [`数据表格动态列 JSON 说明.md`](./数据表格动态列%20JSON%20说明.md) **§1.4**。
57
105
 
58
106
  ---
59
107
 
60
108
  ## 2. 通用字段定义 Schema
61
109
 
62
- 每条字段定义会被转成 xform 控件 schema:
110
+ ### 2.0 最小字段集(维护约定)
111
+
112
+ **新脚本只维护以下顶层字段;`required` 等字段级属性写顶层,`options` 只放控件扩展配置:**
113
+
114
+ | 字段 | 必填 | 说明 |
115
+ |------|------|------|
116
+ | `keyName` | **是** | 字段绑定名 |
117
+ | `type` | 否 | 控件类型,默认 `input` |
118
+ | `label` | 推荐 | 显示标签 |
119
+ | `optionItems` | 否 | 静态选项(select / radio / checkbox) |
120
+ | `required` / `readonly` / `disabled` / `hidden` | 否 | 字段级属性,**写顶层** |
121
+ | `defaultValue` / `placeholder` | 否 | 默认值 / 占位符,**写顶层** |
122
+ | `options` | 否 | 控件扩展配置(`formScriptCode`、`min`、`searchDialogConfig`、`onClick` 等) |
123
+
124
+ **表头额外:** `colspan`(默认 `1`,单列时可不写)
125
+
126
+ **数据表格额外:** `width`、`formatS`(展示列)→ 见 [`数据表格动态列 JSON 说明.md`](./数据表格动态列%20JSON%20说明.md) §2
127
+
128
+ **操作列(仅数据表格):** 无 `keyName`,`label` 写顶层;`onClick` 写 `options`;dropdown 的 `dropdownItems` 写顶层。
129
+
130
+ **默认值(与控件设计器一致,一般无需写入 JSON / Java):**
131
+
132
+ | 场景 | 无需维护 |
133
+ |------|----------|
134
+ | 表头布局 | `colspan: 1` |
135
+ | 静态选项 | `formScriptEnabled`、`commonAttributeEnabled`(默认均为 false) |
136
+ | 脚本选项 | `labelKey` / `valueKey`(默认 `label` / `value`;返回自定义字段名时除外) |
137
+ | 系统词汇 | `labelKey` / `valueKey`(前端固定 `value` / `sn`) |
138
+ | radio / checkbox | `displayStyle: inline`、`buttonStyle`、`border` |
139
+ | select | `clearable: true`、`multiple: false`;`filterable` 默认 false,需搜索时再设 |
140
+ | input | `options.type: text`、`clearable: true`、`maxLength: null` |
141
+ | date | `format` / `valueFormat` 默认 `yyyy-MM-dd` |
142
+ | textarea | `rows: 3`、`maxLength: null`、`showWordLimit: false` |
143
+ | 空值占位 | 无业务要求时不写 `defaultValue: ""`、`placeholder` 等 |
144
+
145
+ **推荐模板:**
63
146
 
64
147
  ```json
65
148
  {
66
149
  "type": "input",
67
150
  "keyName": "contractNo",
68
151
  "label": "合同编号",
69
- "required": true,
70
- "readonly": false,
71
- "disabled": false,
72
- "hidden": false,
73
- "defaultValue": "",
74
- "placeholder": "请输入",
75
- "colspan": 1,
76
- "optionItems": [],
77
- "options": {}
152
+ "required": true
78
153
  }
79
154
  ```
80
155
 
81
156
  ### 2.1 顶层公共属性
82
157
 
83
- | 属性 | 必填 | 类型 | 说明 |
84
- |------|------|------|------|
85
- | `type` | | string | 控件类型,默认 `input` |
86
- | `keyName` | **是*** | string | 字段绑定名(写入 formModel)。也可用 `field` / `name`,优先级:`keyName` > `field` > `name` |
87
- | `label` | 否 | string | 显示标签 |
88
- | `required` | | boolean | 是否必填 |
89
- | `readonly` | | boolean | 是否只读 |
90
- | `disabled` | | boolean | 是否禁用 |
91
- | `hidden` | | boolean | 是否隐藏 |
92
- | `defaultValue` | | any | 默认值 |
93
- | `placeholder` | 否 | string | 占位符(控件支持时生效) |
94
- | `colspan` | 否 | number | 占列数,默认 `1` |
95
- | `optionItems` | 否 | array | 静态选项(select/radio/checkbox 等) |
96
- | `options` | 否 | object | 控件扩展配置,合并进 `widget.options` |
97
-
98
- > *`keyName` / `field` / `name` 至少提供一个,否则该条定义会被忽略。
158
+ | 属性 | 说明 |
159
+ |------|------|
160
+ | `keyName` | 字段绑定名,**必填** |
161
+ | `type` | 控件类型 |
162
+ | `label` | 显示标签 |
163
+ | `colspan` | 表头占列数,默认 `1` |
164
+ | `optionItems` | 静态选项 |
165
+ | `required` / `readonly` / `disabled` / `hidden` | 字段级属性(**顶层**) |
166
+ | `defaultValue` / `placeholder` | 默认值 / 占位符(**顶层**) |
167
+ | `options` | 控件扩展配置(**不含** `required` 等字段级属性) |
168
+
169
+ > 未提供 `keyName` 的字段定义会被忽略(操作列除外,见数据表格文档)。
99
170
 
100
171
  ### 2.2 选项类控件三种数据来源
101
172
 
@@ -109,29 +180,15 @@
109
180
 
110
181
  **互斥规则:** `formScriptEnabled` 与 `commonAttributeEnabled` 不能同时为 `true`。
111
182
 
112
- **词汇下拉/状态 labelKey/valueKey:**
113
-
114
- ```json
115
- {
116
- "labelKey": "value",
117
- "valueKey": "sn"
118
- }
119
- ```
120
-
121
- **脚本下拉 labelKey/valueKey(默认):**
183
+ **系统词汇:** 只需 `commonAttributeEnabled` + `commonAttributeCode`,**无需**配置 `labelKey` / `valueKey`(前端固定:显示字段 `value`,关联字段 `sn`)。
122
184
 
123
- ```json
124
- {
125
- "labelKey": "label",
126
- "valueKey": "value"
127
- }
128
- ```
185
+ **脚本选项:** 返回字段默认为 `label` / `value`,一般无需配置 `labelKey` / `valueKey`(脚本返回自定义字段名时除外)。
129
186
 
130
187
  **选项脚本返回格式:**
131
188
 
132
189
  ```json
133
190
  {
134
- "success": true,
191
+ "type": "success",
135
192
  "objx": {
136
193
  "records": [
137
194
  { "label": "选项A", "value": "A" }
@@ -144,7 +201,7 @@
144
201
 
145
202
  ```json
146
203
  {
147
- "success": true,
204
+ "type": "success",
148
205
  "objx": [
149
206
  { "label": "选项A", "value": "A" }
150
207
  ]
@@ -171,25 +228,12 @@
171
228
  "type": "input",
172
229
  "keyName": "contractNo",
173
230
  "label": "合同编号",
174
- "required": true,
175
- "placeholder": "请输入合同编号",
176
- "defaultValue": "",
177
- "colspan": 1,
178
- "options": {
179
- "type": "text",
180
- "clearable": true,
181
- "showPassword": false,
182
- "minLength": null,
183
- "maxLength": 50,
184
- "showWordLimit": true,
185
- "prefixIcon": "",
186
- "suffixIcon": "",
187
- "validation": "",
188
- "validationHint": ""
189
- }
231
+ "required": true
190
232
  }
191
233
  ```
192
234
 
235
+ > `maxLength` 默认 `null`(不限制);需限长或字数统计时再设 `maxLength` / `showWordLimit`。
236
+
193
237
  | options 字段 | 类型 | 默认值 | 说明 |
194
238
  |-------------|------|--------|------|
195
239
  | `type` | string | `text` | 输入类型:`text` / `password` 等 |
@@ -212,18 +256,12 @@
212
256
  "type": "textarea",
213
257
  "keyName": "remark",
214
258
  "label": "备注",
215
- "placeholder": "请输入备注",
216
- "defaultValue": "",
217
- "colspan": 2,
218
- "options": {
219
- "rows": 3,
220
- "minLength": null,
221
- "maxLength": 500,
222
- "showWordLimit": true
223
- }
259
+ "colspan": 2
224
260
  }
225
261
  ```
226
262
 
263
+ > `rows` 默认 `3`;`maxLength` 默认不限制。
264
+
227
265
  | options 字段 | 类型 | 默认值 | 说明 |
228
266
  |-------------|------|--------|------|
229
267
  | `rows` | number | 3 | 可见行数 |
@@ -242,15 +280,10 @@
242
280
  "label": "数量",
243
281
  "required": true,
244
282
  "defaultValue": 0,
245
- "colspan": 1,
246
283
  "options": {
247
284
  "min": 0,
248
285
  "max": 999999,
249
- "precision": 0,
250
- "step": 1,
251
- "controlsPosition": "right",
252
- "formulaEnabled": false,
253
- "formula": ""
286
+ "precision": 0
254
287
  }
255
288
  }
256
289
  ```
@@ -277,18 +310,10 @@
277
310
  "keyName": "urgentFlag",
278
311
  "label": "是否加急",
279
312
  "defaultValue": "0",
280
- "colspan": 1,
281
313
  "optionItems": [
282
- { "label": "否", "value": "0", "disabled": false },
283
- { "label": "是", "value": "1", "disabled": false }
284
- ],
285
- "options": {
286
- "formScriptEnabled": false,
287
- "commonAttributeEnabled": false,
288
- "displayStyle": "inline",
289
- "buttonStyle": false,
290
- "border": false
291
- }
314
+ { "label": "否", "value": "0" },
315
+ { "label": "是", "value": "1" }
316
+ ]
292
317
  }
293
318
  ```
294
319
 
@@ -301,12 +326,8 @@
301
326
  "label": "付款方式",
302
327
  "options": {
303
328
  "formScriptEnabled": true,
304
- "commonAttributeEnabled": false,
305
329
  "formScriptCode": "payTypeList",
306
- "labelKey": "label",
307
- "valueKey": "value",
308
- "formScriptParam": "return { parentCode: this.formModel.billType }",
309
- "displayStyle": "inline"
330
+ "formScriptParam": "return { parentCode: this.formModel.billType }"
310
331
  }
311
332
  }
312
333
  ```
@@ -320,11 +341,8 @@
320
341
  "label": "是否",
321
342
  "defaultValue": "1",
322
343
  "options": {
323
- "formScriptEnabled": false,
324
344
  "commonAttributeEnabled": true,
325
- "commonAttributeCode": "YES_NO",
326
- "labelKey": "value",
327
- "valueKey": "sn"
345
+ "commonAttributeCode": "YES_NO"
328
346
  }
329
347
  }
330
348
  ```
@@ -352,18 +370,13 @@
352
370
  { "label": "短信", "value": "SMS" },
353
371
  { "label": "邮件", "value": "EMAIL" },
354
372
  { "label": "站内信", "value": "MSG" }
355
- ],
356
- "options": {
357
- "formScriptEnabled": false,
358
- "commonAttributeEnabled": false,
359
- "displayStyle": "inline"
360
- }
373
+ ]
361
374
  }
362
375
  ```
363
376
 
364
377
  #### 后台脚本 / 系统词汇
365
378
 
366
- 配置方式与 `radio`、`select` 相同,将 `formScriptEnabled` `commonAttributeEnabled` 放入 `options` 即可。
379
+ 配置方式与 `radio`、`select` 相同:脚本模式写 `formScriptEnabled` + `formScriptCode`;词汇模式写 `commonAttributeEnabled` + `commonAttributeCode`。
367
380
 
368
381
  ---
369
382
 
@@ -376,21 +389,14 @@
376
389
  "type": "select",
377
390
  "keyName": "payType",
378
391
  "label": "付款方式",
379
- "required": true,
380
392
  "defaultValue": "CASH",
381
- "placeholder": "请选择",
382
- "colspan": 1,
383
393
  "optionItems": [
384
- { "label": "现金", "value": "CASH", "disabled": false },
385
- { "label": "转账", "value": "TRANSFER", "disabled": false }
394
+ { "label": "现金", "value": "CASH" },
395
+ { "label": "转账", "value": "TRANSFER" }
386
396
  ],
397
+ "required": true,
387
398
  "options": {
388
- "formScriptEnabled": false,
389
- "commonAttributeEnabled": false,
390
- "clearable": true,
391
- "filterable": true,
392
- "multiple": false,
393
- "multipleLimit": 0
399
+ "filterable": true
394
400
  }
395
401
  }
396
402
  ```
@@ -404,12 +410,8 @@
404
410
  "label": "子付款方式",
405
411
  "options": {
406
412
  "formScriptEnabled": true,
407
- "commonAttributeEnabled": false,
408
413
  "formScriptCode": "subPayTypeList",
409
- "labelKey": "label",
410
- "valueKey": "value",
411
414
  "formScriptParam": "return { parentPayType: this.formModel.payType }",
412
- "clearable": true,
413
415
  "filterable": true
414
416
  }
415
417
  }
@@ -437,12 +439,8 @@
437
439
  "label": "订单状态",
438
440
  "defaultValue": "1",
439
441
  "options": {
440
- "formScriptEnabled": false,
441
442
  "commonAttributeEnabled": true,
442
443
  "commonAttributeCode": "ORDER_STATUS",
443
- "labelKey": "value",
444
- "valueKey": "sn",
445
- "clearable": true,
446
444
  "filterable": true
447
445
  }
448
446
  }
@@ -468,7 +466,7 @@
468
466
 
469
467
  ```json
470
468
  {
471
- "success": true,
469
+ "type": "success",
472
470
  "objx": {
473
471
  "records": [
474
472
  { "deptName": "采购部", "deptCode": "D001" },
@@ -497,24 +495,12 @@
497
495
  "type": "date",
498
496
  "keyName": "orderDate",
499
497
  "label": "订单日期",
500
- "required": true,
501
- "defaultValue": null,
502
- "placeholder": "请选择日期",
503
- "colspan": 1,
504
- "options": {
505
- "type": "date",
506
- "format": "yyyy-MM-dd",
507
- "valueFormat": "yyyy-MM-dd",
508
- "clearable": true,
509
- "editable": false,
510
- "readonly": false,
511
- "minDate": null,
512
- "maxDate": null,
513
- "utcTransformEnabled": false
514
- }
498
+ "required": true
515
499
  }
516
500
  ```
517
501
 
502
+ > `format` / `valueFormat` 默认均为 `yyyy-MM-dd`,非特殊格式无需配置。
503
+
518
504
  | options.type | 说明 |
519
505
  |-------------|------|
520
506
  | `date` | 日期 |
@@ -539,17 +525,7 @@
539
525
  {
540
526
  "type": "text",
541
527
  "keyName": "createByName",
542
- "label": "创建人",
543
- "defaultValue": "",
544
- "colspan": 1,
545
- "options": {
546
- "colorClass": "",
547
- "formatType": null,
548
- "renderHandle": null,
549
- "autoValueEnabled": false,
550
- "autoValueHanlde": null,
551
- "utcTransformEnabled": false
552
- }
528
+ "label": "创建人"
553
529
  }
554
530
  ```
555
531
 
@@ -563,41 +539,44 @@
563
539
 
564
540
  ---
565
541
 
566
- ### 3.9 凭证(type: `vabUpload`)
542
+ ### 3.9 凭证(type: `vabUpload` / `baseAttachment`)
543
+
544
+ 附件上传控件,绑定值为**文件数组**。`baseAttachment` 与 `vabUpload` 的 `keyName` 规则相同。
545
+
546
+ **`keyName` 格式(必填遵守):**
547
+
548
+ ```
549
+ attachments_<唯一后缀>
550
+ ```
551
+
552
+ | 部分 | 说明 |
553
+ |------|------|
554
+ | 固定前缀 | `attachments_`(与设计器 `keyNamePrefixMap` 一致,**不可省略**) |
555
+ | 唯一后缀 | 同表单内唯一,设计器拖入时默认生成 UUID;后台脚本自行指定时也须保证不重复 |
556
+ | 完整示例 | `attachments_a1b2c3d4e5f6789012345678abcdef` |
567
557
 
568
- 附件上传控件,绑定值为文件数组。
558
+ > 同一张表单若有多个附件字段,每个字段使用不同的后缀;`formModel`、保存接口、`getList` 的 `taBm` 均使用**完整** `keyName`(含前缀)。
559
+ > 勿使用 `attachments` 等无前缀或无前缀+后缀的写法。
569
560
 
570
561
  ```json
571
562
  {
572
563
  "type": "vabUpload",
573
- "keyName": "attachments",
564
+ "keyName": "attachments_a1b2c3d4e5f6789012345678abcdef",
574
565
  "label": "附件",
575
- "required": false,
576
566
  "colspan": 2,
577
567
  "options": {
578
- "limit": 10,
579
- "hideRemoveButton": false,
580
- "entityTableCode": "PO_ORDER",
581
- "entityTableDesc": "采购订单",
582
- "hiddenFileInfo": false,
583
- "hiddenFileName": false,
584
- "showFileSize": true,
585
- "showFileCreateBy": false,
586
- "showFileCreateDate": false,
587
- "widgetSize": 2,
588
- "formScriptEnabled": true,
589
- "formScriptCode": "getList",
590
- "formScriptParam": "return { id: dataId }"
568
+ "limit": 10
591
569
  }
592
570
  }
593
571
  ```
594
572
 
573
+ > `formScriptCode` 加载历史附件默认 `getList`,一般无需配置。
574
+ > **无需**维护 `entityTableCode` / `entityTableDesc`(设计器「实体表」配置已废弃;凭证按 `formCode` + 字段 `keyName`(`taBm`)+ 单据 `dataId` 加载)。
575
+
595
576
  | options 字段 | 类型 | 说明 |
596
577
  |-------------|------|------|
597
578
  | `limit` | number | 最大文件数,`1` 为单文件 |
598
579
  | `hideRemoveButton` | boolean | 隐藏删除按钮 |
599
- | `entityTableCode` | string | 业务表编码(附件关联) |
600
- | `entityTableDesc` | string | 业务表描述 |
601
580
  | `hiddenFileInfo` | boolean | 隐藏文件信息区 |
602
581
  | `hiddenFileName` | boolean | 隐藏文件名 |
603
582
  | `showFileSize` | boolean | 显示文件大小 |
@@ -612,7 +591,7 @@
612
591
  {
613
592
  "formCode": "PO_ORDER_FORM",
614
593
  "formVersion": "1.0",
615
- "taBm": "attachments",
594
+ "taBm": "attachments_a1b2c3d4e5f6789012345678abcdef",
616
595
  "data": {
617
596
  "id": "10001"
618
597
  }
@@ -623,7 +602,7 @@
623
602
 
624
603
  ```json
625
604
  {
626
- "success": true,
605
+ "type": "success",
627
606
  "objx": [
628
607
  {
629
608
  "id": "file001",
@@ -651,18 +630,27 @@
651
630
  "keyName": "supplierCode",
652
631
  "label": "供应商",
653
632
  "required": true,
654
- "colspan": 1,
655
633
  "options": {
656
634
  "vabSearchName": "supplierName",
657
- "readonly": true,
658
- "multipleChoices": false,
659
- "dialogModel": "1",
635
+ "searchDialogConfig": {
636
+ "formCode": "SUPPLIER_LIST",
637
+ "valueSourceField": "supplierCode",
638
+ "labelSourceField": "supplierName"
639
+ }
640
+ }
641
+ }
642
+ ```
643
+
644
+ 扩展配置(按需)示例:
645
+
646
+ ```json
647
+ {
648
+ "options": {
660
649
  "searchDialogConfig": {
661
650
  "formCode": "SUPPLIER_LIST",
662
651
  "formName": "供应商列表",
663
652
  "valueSourceField": "supplierCode",
664
653
  "labelSourceField": "supplierName",
665
- "multipleChoices": false,
666
654
  "tableEnabled": true,
667
655
  "dialogQueryParam": "return { status: '1' }",
668
656
  "dialogCustomParam": "return { title: '选择供应商' }"
@@ -736,13 +724,7 @@
736
724
  "keyName": "orderStatus",
737
725
  "label": "订单状态",
738
726
  "defaultValue": "1",
739
- "colspan": 1,
740
727
  "options": {
741
- "formScriptEnabled": false,
742
- "commonAttributeEnabled": false,
743
- "optionItemValueType": 0,
744
- "labelKey": "label",
745
- "valueKey": "value",
746
728
  "statusParam": [
747
729
  { "label": "草稿", "value": "1", "type": "info" },
748
730
  { "label": "已提交", "value": "2", "type": "warning" },
@@ -797,10 +779,7 @@
797
779
  "label": "流程状态",
798
780
  "options": {
799
781
  "formScriptEnabled": true,
800
- "commonAttributeEnabled": false,
801
782
  "formScriptCode": "wfStatusList",
802
- "labelKey": "label",
803
- "valueKey": "value",
804
783
  "formScriptParam": "return { processId: this.formModel.processId }"
805
784
  }
806
785
  }
@@ -816,11 +795,8 @@
816
795
  "keyName": "billStatus",
817
796
  "label": "单据状态",
818
797
  "options": {
819
- "formScriptEnabled": false,
820
798
  "commonAttributeEnabled": true,
821
- "commonAttributeCode": "BILL_STATUS",
822
- "labelKey": "value",
823
- "valueKey": "sn"
799
+ "commonAttributeCode": "BILL_STATUS"
824
800
  }
825
801
  }
826
802
  ```
@@ -833,29 +809,26 @@
833
809
 
834
810
  ```json
835
811
  {
836
- "success": true,
812
+ "type": "success",
837
813
  "message": "ok",
838
814
  "objx": [
839
815
  {
840
816
  "type": "input",
841
817
  "keyName": "contractNo",
842
818
  "label": "合同编号",
843
- "required": true,
844
- "colspan": 1
819
+ "required": true
845
820
  },
846
821
  {
847
822
  "type": "textarea",
848
823
  "keyName": "remark",
849
824
  "label": "备注",
850
- "colspan": 2,
851
- "options": { "rows": 3, "maxLength": 500, "showWordLimit": true }
825
+ "colspan": 2
852
826
  },
853
827
  {
854
828
  "type": "number",
855
829
  "keyName": "totalQty",
856
830
  "label": "数量",
857
831
  "defaultValue": 1,
858
- "colspan": 1,
859
832
  "options": { "min": 0, "precision": 0 }
860
833
  },
861
834
  {
@@ -866,19 +839,18 @@
866
839
  "optionItems": [
867
840
  { "label": "否", "value": "0" },
868
841
  { "label": "是", "value": "1" }
869
- ],
870
- "colspan": 1
842
+ ]
871
843
  },
872
844
  {
873
845
  "type": "checkbox",
874
846
  "keyName": "notifyTypes",
875
847
  "label": "通知方式",
876
848
  "defaultValue": [],
849
+ "colspan": 2,
877
850
  "optionItems": [
878
851
  { "label": "短信", "value": "SMS" },
879
852
  { "label": "邮件", "value": "EMAIL" }
880
- ],
881
- "colspan": 2
853
+ ]
882
854
  },
883
855
  {
884
856
  "type": "select",
@@ -886,37 +858,26 @@
886
858
  "label": "付款方式",
887
859
  "options": {
888
860
  "formScriptEnabled": true,
889
- "formScriptCode": "payTypeList",
890
- "labelKey": "label",
891
- "valueKey": "value"
892
- },
893
- "colspan": 1
861
+ "formScriptCode": "payTypeList"
862
+ }
894
863
  },
895
864
  {
896
865
  "type": "date",
897
866
  "keyName": "orderDate",
898
- "label": "订单日期",
899
- "colspan": 1,
900
- "options": {
901
- "format": "yyyy-MM-dd",
902
- "valueFormat": "yyyy-MM-dd"
903
- }
867
+ "label": "订单日期"
904
868
  },
905
869
  {
906
870
  "type": "text",
907
871
  "keyName": "createByName",
908
- "label": "创建人",
909
- "colspan": 1
872
+ "label": "创建人"
910
873
  },
911
874
  {
912
875
  "type": "vabUpload",
913
- "keyName": "attachments",
876
+ "keyName": "attachments_a1b2c3d4e5f6789012345678abcdef",
914
877
  "label": "附件",
915
878
  "colspan": 2,
916
879
  "options": {
917
- "limit": 10,
918
- "entityTableCode": "PO_ORDER",
919
- "formScriptCode": "getList"
880
+ "limit": 10
920
881
  }
921
882
  },
922
883
  {
@@ -924,14 +885,12 @@
924
885
  "keyName": "supplierCode",
925
886
  "label": "供应商",
926
887
  "required": true,
927
- "colspan": 1,
928
888
  "options": {
929
889
  "vabSearchName": "supplierName",
930
890
  "searchDialogConfig": {
931
891
  "formCode": "SUPPLIER_LIST",
932
892
  "valueSourceField": "supplierCode",
933
- "labelSourceField": "supplierName",
934
- "multipleChoices": false
893
+ "labelSourceField": "supplierName"
935
894
  }
936
895
  }
937
896
  },
@@ -940,7 +899,6 @@
940
899
  "keyName": "orderStatus",
941
900
  "label": "订单状态",
942
901
  "defaultValue": "1",
943
- "colspan": 1,
944
902
  "options": {
945
903
  "statusParam": [
946
904
  { "label": "草稿", "value": "1", "type": "info" },
@@ -966,18 +924,21 @@
966
924
  |------|------|
967
925
  | 返回类型 | `List<Map<String, Object>>`,每个 Map 为一条字段定义 |
968
926
  | 嵌套配置 | 控件扩展属性放在 `options`(`Map`)中 |
927
+ | 默认值 | 与控件设计器默认相同的属性**无需写入**,见 **§2.0** |
969
928
  | 静态选项 | `select` / `radio` / `checkbox` 可直接 `put("optionItems", list)` |
970
- | 请求入参 | 前端请求体含 `formData`(当前表单数据)及容器「脚本返回对应的参数值」 |
929
+ | 请求入参 | Java 脚本通过 `this.getBinding().getVariables()` 获取;表头脚本直接读 `formData`,见下方示例 |
971
930
  | 二次请求 | 下拉/状态等 `formScriptCode`、凭证 `getList` 需**单独维护**选项脚本 |
972
931
 
973
- 读取表单数据示例(变量名以平台脚本引擎为准):
932
+ 读取表单数据示例(表头后台字段脚本):
974
933
 
975
934
  ```java
976
- // Map data = ...; // 平台注入的请求体
977
- Map<String, Object> formData = (Map<String, Object>) data.get("formData");
978
- String billType = formData != null ? String.valueOf(formData.get("billType")) : null;
935
+ Map<String, Object> variables = this.getBinding().getVariables();
936
+ Map<String, Object> formModel = (Map<String, Object>) variables.get("formData");
937
+ String billType = formModel.get("billType").toString();
979
938
  ```
980
939
 
940
+ 数据表格动态列脚本读内层 `data`,见 [`数据表格动态列 JSON 说明.md`](./数据表格动态列%20JSON%20说明.md) §0.2 / §1.1。
941
+
981
942
  ### 5.2 主脚本:返回全部字段定义
982
943
 
983
944
  ```java
@@ -994,14 +955,6 @@ f1.put("type", "input");
994
955
  f1.put("keyName", "contractNo");
995
956
  f1.put("label", "合同编号");
996
957
  f1.put("required", true);
997
- f1.put("placeholder", "请输入合同编号");
998
- f1.put("colspan", 1);
999
- Map<String, Object> f1Opt = new HashMap<>();
1000
- f1Opt.put("type", "text");
1001
- f1Opt.put("clearable", true);
1002
- f1Opt.put("maxLength", 50);
1003
- f1Opt.put("showWordLimit", true);
1004
- f1.put("options", f1Opt);
1005
958
  fields.add(f1);
1006
959
 
1007
960
  // ========== 2. 多行输入 textarea ==========
@@ -1010,11 +963,6 @@ f2.put("type", "textarea");
1010
963
  f2.put("keyName", "remark");
1011
964
  f2.put("label", "备注");
1012
965
  f2.put("colspan", 2);
1013
- Map<String, Object> f2Opt = new HashMap<>();
1014
- f2Opt.put("rows", 3);
1015
- f2Opt.put("maxLength", 500);
1016
- f2Opt.put("showWordLimit", true);
1017
- f2.put("options", f2Opt);
1018
966
  fields.add(f2);
1019
967
 
1020
968
  // ========== 3. 计数器 number ==========
@@ -1023,12 +971,9 @@ f3.put("type", "number");
1023
971
  f3.put("keyName", "totalQty");
1024
972
  f3.put("label", "数量");
1025
973
  f3.put("defaultValue", 1);
1026
- f3.put("colspan", 1);
1027
974
  Map<String, Object> f3Opt = new HashMap<>();
1028
975
  f3Opt.put("min", 0);
1029
- f3Opt.put("max", 999999);
1030
976
  f3Opt.put("precision", 0);
1031
- f3Opt.put("step", 1);
1032
977
  f3.put("options", f3Opt);
1033
978
  fields.add(f3);
1034
979
 
@@ -1038,7 +983,6 @@ f4.put("type", "radio");
1038
983
  f4.put("keyName", "urgentFlag");
1039
984
  f4.put("label", "是否加急");
1040
985
  f4.put("defaultValue", "0");
1041
- f4.put("colspan", 1);
1042
986
  List<Map<String, Object>> f4Items = new ArrayList<>();
1043
987
  Map<String, Object> f4Item1 = new HashMap<>();
1044
988
  f4Item1.put("label", "否");
@@ -1049,11 +993,6 @@ f4Item2.put("label", "是");
1049
993
  f4Item2.put("value", "1");
1050
994
  f4Items.add(f4Item2);
1051
995
  f4.put("optionItems", f4Items);
1052
- Map<String, Object> f4Opt = new HashMap<>();
1053
- f4Opt.put("formScriptEnabled", false);
1054
- f4Opt.put("commonAttributeEnabled", false);
1055
- f4Opt.put("displayStyle", "inline");
1056
- f4.put("options", f4Opt);
1057
996
  fields.add(f4);
1058
997
 
1059
998
  // ========== 5. 多选项 checkbox(静态 optionItems) ==========
@@ -1081,17 +1020,11 @@ f6.put("type", "select");
1081
1020
  f6.put("keyName", "payType");
1082
1021
  f6.put("label", "付款方式");
1083
1022
  f6.put("required", true);
1084
- f6.put("colspan", 1);
1085
1023
  Map<String, Object> f6Opt = new HashMap<>();
1086
1024
  f6Opt.put("formScriptEnabled", true);
1087
- f6Opt.put("commonAttributeEnabled", false);
1088
1025
  f6Opt.put("formScriptCode", "payTypeList");
1089
- f6Opt.put("labelKey", "label");
1090
- f6Opt.put("valueKey", "value");
1091
1026
  // formScriptParam 为前端 JS 脚本字符串,非 Java
1092
1027
  f6Opt.put("formScriptParam", "return { billType: this.formModel.billType }");
1093
- f6Opt.put("clearable", true);
1094
- f6Opt.put("filterable", true);
1095
1028
  f6.put("options", f6Opt);
1096
1029
  fields.add(f6);
1097
1030
 
@@ -1101,13 +1034,9 @@ f6b.put("type", "select");
1101
1034
  f6b.put("keyName", "orderStatus");
1102
1035
  f6b.put("label", "订单状态");
1103
1036
  f6b.put("defaultValue", "1");
1104
- f6b.put("colspan", 1);
1105
1037
  Map<String, Object> f6bOpt = new HashMap<>();
1106
- f6bOpt.put("formScriptEnabled", false);
1107
1038
  f6bOpt.put("commonAttributeEnabled", true);
1108
1039
  f6bOpt.put("commonAttributeCode", "ORDER_STATUS");
1109
- f6bOpt.put("labelKey", "value");
1110
- f6bOpt.put("valueKey", "sn");
1111
1040
  f6b.put("options", f6bOpt);
1112
1041
  fields.add(f6b);
1113
1042
 
@@ -1116,13 +1045,6 @@ Map<String, Object> f7 = new HashMap<>();
1116
1045
  f7.put("type", "date");
1117
1046
  f7.put("keyName", "orderDate");
1118
1047
  f7.put("label", "订单日期");
1119
- f7.put("colspan", 1);
1120
- Map<String, Object> f7Opt = new HashMap<>();
1121
- f7Opt.put("type", "date");
1122
- f7Opt.put("format", "yyyy-MM-dd");
1123
- f7Opt.put("valueFormat", "yyyy-MM-dd");
1124
- f7Opt.put("clearable", true);
1125
- f7.put("options", f7Opt);
1126
1048
  fields.add(f7);
1127
1049
 
1128
1050
  // ========== 8. 文本 text(只读展示) ==========
@@ -1130,26 +1052,16 @@ Map<String, Object> f8 = new HashMap<>();
1130
1052
  f8.put("type", "text");
1131
1053
  f8.put("keyName", "createByName");
1132
1054
  f8.put("label", "创建人");
1133
- f8.put("colspan", 1);
1134
- Map<String, Object> f8Opt = new HashMap<>();
1135
- f8Opt.put("colorClass", "");
1136
- f8.put("utcTransformEnabled", false);
1137
- f8.put("options", f8Opt);
1138
1055
  fields.add(f8);
1139
1056
 
1140
1057
  // ========== 9. 凭证 vabUpload ==========
1141
1058
  Map<String, Object> f9 = new HashMap<>();
1142
1059
  f9.put("type", "vabUpload");
1143
- f9.put("keyName", "attachments");
1060
+ f9.put("keyName", "attachments_a1b2c3d4e5f6789012345678abcdef");
1144
1061
  f9.put("label", "附件");
1145
1062
  f9.put("colspan", 2);
1146
1063
  Map<String, Object> f9Opt = new HashMap<>();
1147
1064
  f9Opt.put("limit", 10);
1148
- f9Opt.put("entityTableCode", "PO_ORDER");
1149
- f9Opt.put("entityTableDesc", "采购订单");
1150
- f9Opt.put("hideRemoveButton", false);
1151
- f9Opt.put("showFileSize", true);
1152
- f9Opt.put("formScriptCode", "getList");
1153
1065
  f9.put("options", f9Opt);
1154
1066
  fields.add(f9);
1155
1067
 
@@ -1159,16 +1071,12 @@ f10.put("type", "vabsearch");
1159
1071
  f10.put("keyName", "supplierCode");
1160
1072
  f10.put("label", "供应商");
1161
1073
  f10.put("required", true);
1162
- f10.put("colspan", 1);
1163
1074
  Map<String, Object> f10Opt = new HashMap<>();
1164
1075
  f10Opt.put("vabSearchName", "supplierName");
1165
- f10Opt.put("readonly", true);
1166
- f10Opt.put("multipleChoices", false);
1167
1076
  Map<String, Object> f10Dialog = new HashMap<>();
1168
1077
  f10Dialog.put("formCode", "SUPPLIER_LIST");
1169
1078
  f10Dialog.put("valueSourceField", "supplierCode");
1170
1079
  f10Dialog.put("labelSourceField", "supplierName");
1171
- f10Dialog.put("multipleChoices", false);
1172
1080
  f10Opt.put("searchDialogConfig", f10Dialog);
1173
1081
  f10.put("options", f10Opt);
1174
1082
  fields.add(f10);
@@ -1179,13 +1087,7 @@ f11.put("type", "status");
1179
1087
  f11.put("keyName", "wfStatus");
1180
1088
  f11.put("label", "流程状态");
1181
1089
  f11.put("defaultValue", "1");
1182
- f11.put("colspan", 1);
1183
1090
  Map<String, Object> f11Opt = new HashMap<>();
1184
- f11Opt.put("formScriptEnabled", false);
1185
- f11Opt.put("commonAttributeEnabled", false);
1186
- f11Opt.put("optionItemValueType", 0);
1187
- f11Opt.put("labelKey", "label");
1188
- f11Opt.put("valueKey", "value");
1189
1091
  List<Map<String, Object>> f11Status = new ArrayList<>();
1190
1092
  Map<String, Object> s1 = new HashMap<>();
1191
1093
  s1.put("label", "草稿");
@@ -1242,7 +1144,7 @@ return list;
1242
1144
 
1243
1145
  ### 5.4 附属脚本:凭证 getList
1244
1146
 
1245
- 字段 `attachments` 在编辑态(有 dataId)时,通过 `formScriptCode: "getList"` 加载历史附件。
1147
+ 字段 `attachments_<唯一后缀>` 在编辑态(有 dataId)时,通过 `formScriptCode: "getList"` 加载历史附件;`taBm` 与 `keyName` 一致。
1246
1148
 
1247
1149
  ```java
1248
1150
  import java.util.ArrayList;
@@ -1275,8 +1177,9 @@ import java.util.Map;
1275
1177
 
1276
1178
  List<Map<String, Object>> fields = new ArrayList<>();
1277
1179
 
1278
- Map<String, Object> formData = (Map<String, Object>) data.get("formData");
1279
- String billType = formData != null ? String.valueOf(formData.get("billType")) : "";
1180
+ Map<String, Object> variables = this.getBinding().getVariables();
1181
+ Map<String, Object> formModel = (Map<String, Object>) variables.get("formData");
1182
+ String billType = formModel.get("billType").toString();
1280
1183
 
1281
1184
  // 所有单据都有合同编号
1282
1185
  Map<String, Object> contractNo = new HashMap<>();
@@ -1316,7 +1219,6 @@ return fields;
1316
1219
  | `payTypeList` | 下拉选项二次请求脚本 |
1317
1220
  | `ORDER_STATUS` | 系统词汇编码 |
1318
1221
  | `SUPPLIER_LIST` | 搜索弹框表单编码 |
1319
- | `PO_ORDER` | 凭证 entityTableCode |
1320
1222
  | 各字段 `keyName` | 与 formModel / 保存接口字段一致 |
1321
1223
 
1322
1224
  联调建议:先返回 `input` + `select`(静态 optionItems) 两列验证通路,再逐步放开其余类型。
@@ -1339,10 +1241,11 @@ return fields;
1339
1241
 
1340
1242
  1. **type 必须已注册**:未在设计器字段库中注册的 type 会被跳过。
1341
1243
  2. **keyName 唯一**:不要与表单已有字段重复。
1342
- 3. **动态规则分离**:运行时显隐/必填/只读等规则在「表单设置 动态字段规则」配置,不在本 JSON 中动态下发(初始 `hidden/required` 等仍可在定义里设置)。
1343
- 4. **formScriptParam / dialogQueryParam 等**:均为 JS 脚本字符串,不是 JSON 对象。
1344
- 5. **选项脚本与词汇互斥**:同一控件只能启用一种选项来源。
1345
- 6. **凭证仅编辑态加载**:无 `dataId` 时不请求历史附件。
1244
+ 3. **只写差异属性**:与控件设计器默认值相同的属性无需维护,见 **§2.0 默认值**。
1245
+ 4. **动态规则分离**:运行时显隐/必填/只读等规则在「表单设置 动态字段规则」配置,不在本 JSON 中动态下发(初始 `hidden/required` 等仍可在定义里设置)。
1246
+ 5. **formScriptParam / dialogQueryParam 等**:均为 JS 脚本字符串,不是 JSON 对象。
1247
+ 6. **选项脚本与词汇互斥**:同一控件只能启用一种选项来源。
1248
+ 7. **凭证仅编辑态加载**:无 `dataId` 时不请求历史附件。
1346
1249
 
1347
1250
  ---
1348
1251
 
@@ -1350,7 +1253,9 @@ return fields;
1350
1253
 
1351
1254
  | 文件 | 说明 |
1352
1255
  |------|------|
1353
- | `form-render/container-item/dynamicFieldMixin.js` | 运行时解析与生成 |
1354
- | `form-designer/setting-panel/property-editor/container-table/table-dynamicField-editor.vue` | 设计器配置面板 |
1355
- | `form-designer/widget-panel/widgetsConfig.js` | 各控件默认 schema |
1356
- | `src/docs/表格动态列后台脚本示例.md` | 同平台 bd_api 脚本写法参考(列定义版) |
1256
+ | `utils/dynamicSchemaUtil.js` | 协议常量(`DYNAMIC_SCHEMA_CORE_KEYS` 等)与规范化 |
1257
+ | `form-render/container-item/dynamicFieldMixin.js` | 表头后台字段运行时 |
1258
+ | `form-render/container-item/data-table-mixin.js` | 数据表格动态列运行时 |
1259
+ | `form-designer/.../table-dynamicField-editor.vue` | 表头设计器配置 |
1260
+ | `form-designer/.../data-table-editor.vue` | 数据表格设计器配置 |
1261
+ | [`数据表格动态列 JSON 说明.md`](./数据表格动态列%20JSON%20说明.md) | 数据表格差异说明 |