@steedos/service-plugin-amis 2.3.0-beta.3 → 2.3.0-beta.7

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.
@@ -4,6 +4,18 @@
4
4
  .steedos .creator-content-wrapper .steedos-page .page-header-wrapper{
5
5
  display: none;
6
6
  }
7
+ .ant-modal.absolute .ant-modal-content{
8
+ /*使用绝对定位显示弹出窗口时,内层content最大高度不用限制*/
9
+ max-height: unset;
10
+ }
11
+ .page-form-object_layouts .steedos-amis-form .antd-Collapse .antd-Table-table .antd-Form--normal{
12
+ /*格式内的单元格空白太多*/
13
+ display: block!important;
14
+ }
15
+ .page-form-object_layouts .antd-Table .antd-Field--quickEditable .antd-PlainField{
16
+ /*快速编辑只读状态时编辑按钮不应该换行显示*/
17
+ display: inline;
18
+ }
7
19
  </style>`);
8
20
  $("head").append(styleCss);
9
21
  } catch (error) {
@@ -0,0 +1,886 @@
1
+ {
2
+ "type": "page",
3
+ "body": [
4
+ {
5
+ "type": "form",
6
+ "mode": "normal",
7
+ "persistData": false,
8
+ "promptPageLeave": true,
9
+ "name": "form_edit_${recordId}",
10
+ "title": "",
11
+ "api": {
12
+ "method": "post",
13
+ "url": "${context.rootUrl}/graphql",
14
+ "data": {
15
+ "objectName": "${objectName}",
16
+ "$": "$$",
17
+ "recordId": "${recordId}",
18
+ "modalName": "${modalName}"
19
+ },
20
+ "requestAdaptor": "\n \n const formData = api.data.$;\n for (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n }\n const objectName = api.data.objectName;\n const fieldsName = Object.keys(formData);\n delete formData.created;\n delete formData.created_by;\n delete formData.modified;\n delete formData.modified_by;\n delete formData._display;\n delete formData.sort_order_options;\n delete formData.buttons_options;\n delete formData.fields_options;\n delete formData.field_groups_options;\n delete formData.related_lists_options;\n delete formData.related_object_fields_options;\n\n let query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\n if(formData.recordId){\n query = `mutation{record: ${objectName}__update(id: \"${formData.recordId}\", doc: {__saveData}){_id}}`;\n };\n delete formData._id;\n let __saveData = JSON.stringify(JSON.stringify(formData));\n \n api.data = {query: query.replace('{__saveData}', __saveData)};\n return api;\n ",
21
+ "responseData": {
22
+ "recordId": "${record._id}"
23
+ },
24
+ "adaptor": "\n SteedosUI.getRef(api.body.modalName).close();\n SteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\n return payload;\n "
25
+ },
26
+ "initApi": {
27
+ "method": "post",
28
+ "url": "${context.rootUrl}/graphql",
29
+ "sendOn": "!!this.recordId",
30
+ "cache": 100,
31
+ "adaptor": "var data = payload.data.data[0];\nif(data){\n data.object_name = data.object_name ? data.object_name.name:null;\n \n \n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n};\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n",
32
+ "data": {
33
+ "query": "{data:object_layouts(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,label,object_name:object_name__expand{name,label},profiles,buttons,fields,related_lists,field_groups,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},_display{created,modified}}}"
34
+ }
35
+ },
36
+ "initFetch": true,
37
+ "body": [
38
+ {
39
+ "type": "fieldSet",
40
+ "title": "通用",
41
+ "collapsable": true,
42
+ "body": [
43
+ {
44
+ "name": "name",
45
+ "label": "API 名称",
46
+ "required": true,
47
+ "type": "input-text",
48
+ "className": "col-span-2 m-0",
49
+ "labelClassName": "text-left",
50
+ "id": "u:211102f479e9"
51
+ },
52
+ {
53
+ "name": "label",
54
+ "label": "页面布局名",
55
+ "required": true,
56
+ "type": "input-text",
57
+ "className": "col-span-2 m-0",
58
+ "labelClassName": "text-left",
59
+ "id": "u:1b3e658c6a5e"
60
+ },
61
+ {
62
+ "name": "object_name",
63
+ "label": "对象",
64
+ "required": true,
65
+ "type": "select",
66
+ "joinValues": false,
67
+ "extractValue": true,
68
+ "labelField": "label",
69
+ "valueField": "value",
70
+ "autoComplete": "get:/service/api/amis-metadata-objects/objects/options",
71
+ "className": "m-0",
72
+ "labelClassName": "text-left",
73
+ "en-US": {
74
+ "label": "Object"
75
+ },
76
+ "checkAll": false,
77
+ "searchable": true,
78
+ "id": "u:4e769995f638"
79
+ },
80
+ {
81
+ "name": "profiles",
82
+ "label": "简档",
83
+ "required": true,
84
+ "type": "select",
85
+ "joinValues": false,
86
+ "extractValue": true,
87
+ "labelField": "label",
88
+ "multiple": true,
89
+ "className": "m-0",
90
+ "labelClassName": "text-left",
91
+ "checkAll": true,
92
+ "source": {
93
+ "method": "post",
94
+ "url": "${context.rootUrl}/graphql",
95
+ "data": {
96
+ "query": "{options:permission_set(filters: [\"type\", \"=\", \"profile\"]){name,label}}"
97
+ },
98
+ "requestAdaptor": "",
99
+ "adaptor": ""
100
+ },
101
+ "valueField": "name",
102
+ "searchable": true,
103
+ "id": "u:3c65447a8a6e"
104
+ },
105
+ {
106
+ "type": "service",
107
+ "body": [
108
+ {
109
+ "type": "panel",
110
+ "title": "按钮",
111
+ "body": [
112
+ {
113
+ "name": "buttons",
114
+ "label": "按钮",
115
+ "type": "crud",
116
+ "strictMode": true,
117
+ "affixHeader": false,
118
+ "editable": true,
119
+ "addable": false,
120
+ "removable": true,
121
+ "draggable": false,
122
+ "columns": [
123
+ {
124
+ "name": "index",
125
+ "label": "序号",
126
+ "type": "static",
127
+ "value": "${index + 1}",
128
+ "className": "w-10",
129
+ "id": "u:c59784421c37"
130
+ },
131
+ {
132
+ "name": "button_name_label",
133
+ "label": "名称",
134
+ "type": "tpl",
135
+ "tpl": "${buttons_options|filter:value:equals:button_name|pick:label}",
136
+ "id": "u:302f8fadccd3"
137
+ },
138
+ {
139
+ "name": "visible_on",
140
+ "label": "显示条件",
141
+ "quickEdit": {
142
+ "type": "input-text",
143
+ "className": "m-0",
144
+ "labelClassName": "text-left",
145
+ "onEvent": {
146
+ "change": {
147
+ "actions": [
148
+ {
149
+ "actionType": "setValue",
150
+ "args": {
151
+ "value": "${event.data|quickEidtSaveForButton:visible_on}"
152
+ },
153
+ "componentId": "object-layout-form"
154
+ }
155
+ ]
156
+ }
157
+ },
158
+ "tpl": "<b><%=data.visible_on%></b>"
159
+ },
160
+ "id": "u:3c35211aa1a0"
161
+ }
162
+ ],
163
+ "className": "col-span-2 m-0",
164
+ "labelClassName": "text-left",
165
+ "footable": false,
166
+ "headerToolbar": [
167
+ {
168
+ "type": "action",
169
+ "actionType": "dialog",
170
+ "dialog": {
171
+ "title": "选择按钮",
172
+ "body": [
173
+ {
174
+ "type": "transfer",
175
+ "name": "picked_buttons",
176
+ "sortable": true,
177
+ "source": "${buttons_options}",
178
+ "value": "${buttons|pick:button_name}",
179
+ "searchable": true
180
+ }
181
+ ],
182
+ "onEvent": {
183
+ "confirm": {
184
+ "actions": [
185
+ {
186
+ "actionType": "setValue",
187
+ "args": {
188
+ "value": "${event.data|clearButtons}"
189
+ },
190
+ "componentId": "object-layout-form"
191
+ },
192
+ {
193
+ "actionType": "setValue",
194
+ "args": {
195
+ "value": "${event.data|convertDataForButtons}"
196
+ },
197
+ "componentId": "object-layout-form"
198
+ }
199
+ ]
200
+ }
201
+ }
202
+ },
203
+ "label": "选择按钮",
204
+ "id": "u:1ac8afc8a9bb"
205
+ }
206
+ ],
207
+ "source": "${buttons}",
208
+ "id": "u:a5d43b752494"
209
+ }
210
+ ],
211
+ "id": "u:1c6f542c9215",
212
+ "inline": false,
213
+ "affixFooter": false,
214
+ "className": "m-0",
215
+ "headerClassName": "antd-Panel-heading pl-0",
216
+ "bodyClassName": "antd-Panel-body p-0"
217
+ }
218
+ ],
219
+ "id": "u:bef2e378d96f",
220
+ "messages": {},
221
+ "api": {
222
+ "method": "get",
223
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/actions/options",
224
+ "adaptor": "// 把”选择按钮“弹出窗口中设置的按钮转为主表单buttons字段值格式\namis.registerFilter('convertDataForButtons', function (input) {\n let pickedButtons = input.picked_buttons || [];\n const superButtons = _.keyBy(input.__super.buttons, 'button_name');\n if (typeof pickedButtons === \"string\") {\n pickedButtons = pickedButtons.split(\",\");\n }\n const convertedButtons = pickedButtons.map(function (key) {\n return superButtons[key] || {\n button_name: key\n }\n });\n return {\n buttons: convertedButtons\n }\n});\n\n// 按钮列表每一列数据变量时立即同步值到表单中\namis.registerFilter('quickEidtSaveForButton', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const button_name = rowValue.button_name;\n rowValue[prop_name] = currentPropValue;\n let newButtons = formValue.buttons.map(function (item) {\n if (item.button_name == button_name) {\n return Object.assign({}, item, rowValue);\n }\n else {\n return item;\n }\n });\n return {\n buttons: newButtons\n }\n});\n\n// 清空主表单buttons字段值\namis.registerFilter('clearButtons', function (input) {\n return {\n buttons: []\n }\n});\n\n\n// 新建页面布局时初始化buttons默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\namis.registerFilter('initDefaultButtons', function (input) {\n const superValues = this.data.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n buttons: superValues.buttons,\n }\n});\n\nlet data = payload.data;\ndata.buttons_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
225
+ "sendOn": "!!this.object_name"
226
+ },
227
+ "className": "col-span-2 m-0",
228
+ "affixFooter": false
229
+ },
230
+ {
231
+ "type": "service",
232
+ "body": [
233
+ {
234
+ "type": "panel",
235
+ "title": "字段",
236
+ "body": [
237
+ {
238
+ "name": "fields",
239
+ "required": true,
240
+ "type": "crud",
241
+ "strictMode": true,
242
+ "affixHeader": false,
243
+ "editable": true,
244
+ "addable": false,
245
+ "removable": true,
246
+ "draggable": false,
247
+ "columns": [
248
+ {
249
+ "name": "index",
250
+ "className": "w-10",
251
+ "label": "序号",
252
+ "type": "static",
253
+ "value": "${index + 1}",
254
+ "id": "u:d1c2922699d3"
255
+ },
256
+ {
257
+ "name": "field_name_label",
258
+ "label": "字段",
259
+ "type": "tpl",
260
+ "tpl": "${fields_options|filter:value:equals:field_name|pick:label}",
261
+ "id": "u:b95c69a1cd84"
262
+ },
263
+ {
264
+ "name": "is_readonly",
265
+ "label": "只读",
266
+ "quickEdit": {
267
+ "type": "checkbox",
268
+ "tpl": null,
269
+ "className": "m-0",
270
+ "labelClassName": "text-left",
271
+ "mode": "inline",
272
+ "onEvent": {
273
+ "change": {
274
+ "actions": [
275
+ {
276
+ "actionType": "setValue",
277
+ "args": {
278
+ "value": "${event.data|quickEidtSaveForField:is_readonly}"
279
+ },
280
+ "componentId": "object-layout-form"
281
+ }
282
+ ]
283
+ }
284
+ },
285
+ "id": "u:8cb44f3db16c"
286
+ },
287
+ "id": "u:5081e6e1af55"
288
+ },
289
+ {
290
+ "name": "is_required",
291
+ "label": "必填",
292
+ "quickEdit": {
293
+ "mode": "inline",
294
+ "type": "checkbox",
295
+ "className": "m-0",
296
+ "onEvent": {
297
+ "change": {
298
+ "actions": [
299
+ {
300
+ "actionType": "setValue",
301
+ "args": {
302
+ "value": "${event.data|quickEidtSaveForField:is_required}"
303
+ },
304
+ "componentId": "object-layout-form"
305
+ }
306
+ ]
307
+ }
308
+ },
309
+ "tpl": null,
310
+ "labelClassName": "text-left",
311
+ "id": "u:bbd1c15b6504"
312
+ },
313
+ "id": "u:e54afb5cc05c"
314
+ },
315
+ {
316
+ "name": "group",
317
+ "label": "分组",
318
+ "quickEdit": {
319
+ "type": "select",
320
+ "className": "m-0",
321
+ "source": "${field_groups|pick:group_name}",
322
+ "checkAll": false,
323
+ "selectFirst": false,
324
+ "onEvent": {
325
+ "change": {
326
+ "actions": [
327
+ {
328
+ "actionType": "setValue",
329
+ "args": {
330
+ "value": "${event.data|clearFields}"
331
+ },
332
+ "componentId": "object-layout-form"
333
+ },
334
+ {
335
+ "actionType": "setValue",
336
+ "args": {
337
+ "value": "${event.data|quickEidtSaveForField:group}"
338
+ },
339
+ "componentId": "object-layout-form"
340
+ }
341
+ ]
342
+ }
343
+ },
344
+ "searchable": true,
345
+ "clearable": true
346
+ },
347
+ "id": "u:e532b1949676"
348
+ },
349
+ {
350
+ "name": "visible_on",
351
+ "label": "显示条件",
352
+ "quickEdit": {
353
+ "type": "textarea",
354
+ "tpl": "<b><%=data.visible_on%></b>",
355
+ "className": "m-0",
356
+ "labelClassName": "text-left",
357
+ "onEvent": {
358
+ "change": {
359
+ "actions": [
360
+ {
361
+ "actionType": "setValue",
362
+ "args": {
363
+ "value": "${event.data|quickEidtSaveForField:visible_on}"
364
+ },
365
+ "componentId": "object-layout-form"
366
+ }
367
+ ]
368
+ }
369
+ }
370
+ },
371
+ "breakpoint": "*",
372
+ "id": "u:e3618b8b4c52"
373
+ }
374
+ ],
375
+ "className": "col-span-2 m-0",
376
+ "labelClassName": "text-left",
377
+ "source": "${fields}",
378
+ "footable": false,
379
+ "headerToolbar": [
380
+ {
381
+ "type": "action",
382
+ "actionType": "dialog",
383
+ "dialog": {
384
+ "title": "选择字段",
385
+ "body": [
386
+ {
387
+ "type": "transfer",
388
+ "name": "picked_fields",
389
+ "sortable": true,
390
+ "source": "${fields_options}",
391
+ "value": "${fields|pick:field_name}",
392
+ "searchable": true
393
+ }
394
+ ],
395
+ "onEvent": {
396
+ "confirm": {
397
+ "actions": [
398
+ {
399
+ "actionType": "setValue",
400
+ "args": {
401
+ "value": "${event.data|clearFields}"
402
+ },
403
+ "componentId": "object-layout-form"
404
+ },
405
+ {
406
+ "actionType": "setValue",
407
+ "args": {
408
+ "value": "${event.data|convertDataForFields}"
409
+ },
410
+ "componentId": "object-layout-form"
411
+ }
412
+ ]
413
+ }
414
+ }
415
+ },
416
+ "label": "选择字段",
417
+ "id": "u:853b890ab524"
418
+ },
419
+ {
420
+ "type": "action",
421
+ "actionType": "dialog",
422
+ "dialog": {
423
+ "title": "设置分组",
424
+ "body": [
425
+ {
426
+ "type": "input-table",
427
+ "name": "setting_groups",
428
+ "addable": true,
429
+ "draggable": true,
430
+ "editable": true,
431
+ "columns": [
432
+ {
433
+ "name": "group_name",
434
+ "label": "名称"
435
+ }
436
+ ],
437
+ "value": "${field_groups}",
438
+ "removable": true
439
+ }
440
+ ],
441
+ "onEvent": {
442
+ "confirm": {
443
+ "actions": [
444
+ {
445
+ "actionType": "setValue",
446
+ "args": {
447
+ "value": "${event.data|clearFields}"
448
+ },
449
+ "componentId": "object-layout-form"
450
+ },
451
+ {
452
+ "actionType": "setValue",
453
+ "args": {
454
+ "value": "${event.data|convertDataForGroups}"
455
+ },
456
+ "componentId": "object-layout-form"
457
+ }
458
+ ]
459
+ }
460
+ },
461
+ "type": "dialog"
462
+ },
463
+ "label": "设置分组",
464
+ "id": "u:ec9931ea883c"
465
+ }
466
+ ],
467
+ "id": "u:22121edc42b1"
468
+ }
469
+ ],
470
+ "id": "u:acfaf85221b7",
471
+ "inline": false,
472
+ "affixFooter": false,
473
+ "className": "m-0",
474
+ "headerClassName": "antd-Panel-heading pl-0",
475
+ "bodyClassName": "antd-Panel-body p-0"
476
+ }
477
+ ],
478
+ "id": "u:ac5b7818b88f",
479
+ "affixFooter": false,
480
+ "messages": {},
481
+ "api": {
482
+ "method": "get",
483
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/layout_options",
484
+ "adaptor": "const fieldGroupKey = \"group\";\nconst getFieldsSortFun = function(groupNames){\n return function(m,n){\n var tempM = !!m[fieldGroupKey] ? 1 : 0;\n var tempN = !!n[fieldGroupKey] ? 1 : 0;\n if(!m[fieldGroupKey] || !n[fieldGroupKey]){\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[fieldGroupKey]) - groupNames.indexOf(n[fieldGroupKey]);\n };\n}\n\n// 把”选择字段“弹出窗口中设置的字段转为主表单fields字段值格式\namis.registerFilter('convertDataForFields', function (input) {\n let pickedFields = input.picked_fields || [];\n const superFields = _.keyBy(input.__super.fields, 'field_name');\n if(typeof pickedFields === \"string\"){\n pickedFields = pickedFields.split(\",\");\n }\n const fieldOptions = lodash.keyBy(this.data.__super.__super.__super.__super.__super.fields_options, \"value\");\n const convertedFields = pickedFields.map(function (field_name) {\n const superField = superFields[field_name];\n if (superField) {\n return superField;\n }\n else {\n const fieldOption = fieldOptions[field_name];\n return {\n field_name: field_name,\n is_readonly: fieldOption.readonly,\n is_required: fieldOption.required,\n group: fieldOption.group\n }\n }\n });\n const fieldGroups = this.data.__super.__super.__super.__super.__super.field_groups;\n const groupNames = lodash.compact(lodash.map(fieldGroups,\"group_name\"));\n // fields重新按分组排序\n convertedFields.sort(getFieldsSortFun(groupNames));\n return {\n fields: convertedFields\n }\n});\n\n// 字段列表每一列数据变量时立即同步值到表单中\namis.registerFilter('quickEidtSaveForField', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const field_name = rowValue.field_name;\n rowValue[prop_name] = currentPropValue;\n let newFields = formValue.fields.map(function (item) {\n if (item.field_name == field_name) {\n return Object.assign({}, item, rowValue);\n }\n else { \n return item;\n }\n });\n const fieldGroups = this.data.__super.__super.field_groups;\n const groupNames = lodash.compact(lodash.map(fieldGroups,\"group_name\"));\n // fields重新按分组排序\n newFields.sort(getFieldsSortFun(groupNames));\n return {\n fields: newFields\n }\n});\n\n// 清空主表单fields字段值\namis.registerFilter('clearFields', function (input) {\n return {\n fields: []\n }\n});\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置fields属性的字段先后次序\n// 因为直接设置fields值有bug,即新值老值会串,所以需要先执行上面的clearFields清除原来的值\namis.registerFilter('convertDataForGroups', function (input) {\n const settingGroups = input.setting_groups || [];\n const convertedGroups = lodash.uniqBy(settingGroups.map(function (item) {\n return {\n group_name: item.group_name\n }\n }), \"group_name\");\n\n const groupNames = lodash.compact(lodash.map(convertedGroups,\"group_name\"));\n const fields = this.data.__super.__super.items;\n // fields重新按分组排序\n fields.sort(getFieldsSortFun(groupNames));\n\n return {\n field_groups: convertedGroups, \n fields: fields\n }\n});\n\n// 把字段中配置的group属性加到主表field_groups属性中\namis.registerFilter('mixingGroupsFromFields', function (input) {\n const groupsOptions = input.field_groups_options;\n const groups = this.data.field_groups || [];\n const groupsForMixing = groupsOptions.map(function (item) {\n return {\n group_name: item\n }\n });\n const mixedGroups = lodash.unionBy(groups, groupsForMixing, \"group_name\");\n return {\n field_groups: mixedGroups\n }\n});\n\n// 新建页面布局时初始化fields默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\namis.registerFilter('initDefaultFields', function (input) {\n const superValues = this.data.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n fields: superValues.fields,\n }\n});\n\nlet data = payload.data;\ndata.fields_options = data.options;\ndata.field_groups_options = lodash.uniq(lodash.compact(lodash.map(data.options, \"group\"))) || [];\ndelete data.options\npayload.data = data;\nreturn payload;\n",
485
+ "sendOn": "!!this.object_name",
486
+ "data": null
487
+ },
488
+ "className": "col-span-2 m-0",
489
+ "placeholder": "-",
490
+ "onEvent": {
491
+ "fetchInited": {
492
+ "actions": [
493
+ {
494
+ "actionType": "setValue",
495
+ "args": {
496
+ "value": "${event.data|mixingGroupsFromFields}"
497
+ },
498
+ "componentId": "object-layout-form"
499
+ }
500
+ ]
501
+ }
502
+ }
503
+ },
504
+ {
505
+ "type": "service",
506
+ "body": [
507
+ {
508
+ "type": "panel",
509
+ "title": "子表",
510
+ "body": [
511
+ {
512
+ "name": "related_lists",
513
+ "type": "crud",
514
+ "strictMode": true,
515
+ "affixHeader": false,
516
+ "editable": true,
517
+ "addable": true,
518
+ "removable": true,
519
+ "draggable": false,
520
+ "columns": [
521
+ {
522
+ "name": "index",
523
+ "label": "序号",
524
+ "className": "w-10",
525
+ "type": "static",
526
+ "value": "${index + 1}",
527
+ "id": "u:a2f05dc83cd4"
528
+ },
529
+ {
530
+ "name": "related_field_fullname_label",
531
+ "label": "子表名称",
532
+ "type": "tpl",
533
+ "tpl": "${related_lists_options|filter:value:equals:related_field_fullname|pick:label}",
534
+ "id": "u:5204fc0fbe1c"
535
+ },
536
+ {
537
+ "name": "label",
538
+ "label": "显示标题",
539
+ "quickEdit": {
540
+ "type": "input-text",
541
+ "mode": "inline",
542
+ "onEvent": {
543
+ "change": {
544
+ "actions": [
545
+ {
546
+ "actionType": "setValue",
547
+ "args": {
548
+ "value": "${event.data|quickEidtSaveForRelatedList:label}"
549
+ },
550
+ "componentId": "object-layout-form"
551
+ }
552
+ ]
553
+ }
554
+ },
555
+ "labelRemark": "默认为对象名称",
556
+ "className": "m-0",
557
+ "labelClassName": "text-left",
558
+ "id": "u:5b30f2a71830"
559
+ },
560
+ "id": "u:1267e4351d66"
561
+ },
562
+ {
563
+ "name": "field_names",
564
+ "label": "显示的字段",
565
+ "quickEdit": {
566
+ "type": "transfer-picker",
567
+ "source": {
568
+ "method": "get",
569
+ "url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
570
+ "cache": 60000
571
+ },
572
+ "searchable": true,
573
+ "onEvent": {
574
+ "change": {
575
+ "actions": [
576
+ {
577
+ "actionType": "setValue",
578
+ "args": {
579
+ "value": "${event.data|quickEidtSaveForRelatedList:field_names}"
580
+ },
581
+ "componentId": "object-layout-form"
582
+ }
583
+ ]
584
+ }
585
+ },
586
+ "joinValues": false,
587
+ "extractValue": true
588
+ },
589
+ "type": "tpl",
590
+ "tpl": "<%= data.related_object_fields_options && data.related_object_fields_options[data.related_field_fullname] ? data.related_object_fields_options[data.related_field_fullname].filter(function(item){ return data.field_names && data.field_names.indexOf(item.value) > -1;}).map(function(item){return item.label}) : data.field_names%>",
591
+ "id": "u:ce65d4020107"
592
+ },
593
+ {
594
+ "name": "sort_field_name",
595
+ "label": "排序字段",
596
+ "quickEdit": {
597
+ "type": "transfer-picker",
598
+ "joinValues": false,
599
+ "extractValue": true,
600
+ "onEvent": {
601
+ "change": {
602
+ "actions": [
603
+ {
604
+ "actionType": "setValue",
605
+ "args": {
606
+ "value": "${event.data|quickEidtSaveForRelatedList:sort_field_name}"
607
+ },
608
+ "componentId": "object-layout-form"
609
+ }
610
+ ]
611
+ }
612
+ },
613
+ "source": {
614
+ "method": "get",
615
+ "url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
616
+ "cache": 60000
617
+ },
618
+ "searchable": true
619
+ },
620
+ "tpl": "<%= data.related_object_fields_options && data.related_object_fields_options[data.related_field_fullname] ? data.related_object_fields_options[data.related_field_fullname].filter(function(item){ return data.sort_field_name && data.sort_field_name.indexOf(item.value) > -1;}).map(function(item){return item.label}) : data.sort_field_name%>",
621
+ "id": "u:3dbee6a855c4"
622
+ },
623
+ {
624
+ "name": "sort_order",
625
+ "label": "排序方式",
626
+ "quickEdit": {
627
+ "className": "m-0",
628
+ "labelClassName": "text-left",
629
+ "onEvent": {
630
+ "change": {
631
+ "actions": [
632
+ {
633
+ "actionType": "setValue",
634
+ "args": {
635
+ "value": "${event.data|quickEidtSaveForRelatedList:sort_order}"
636
+ },
637
+ "componentId": "object-layout-form"
638
+ }
639
+ ]
640
+ }
641
+ },
642
+ "joinValues": false,
643
+ "extractValue": true,
644
+ "clearable": true,
645
+ "labelField": "label",
646
+ "valueField": "value",
647
+ "mode_": "inline",
648
+ "source": "${sort_order_options}",
649
+ "type": "select"
650
+ },
651
+ "breakpoint": "*",
652
+ "type": "tpl",
653
+ "tpl": "${sort_order_options|filter:value:equals:sort_order|pick:label}",
654
+ "id": "u:13cb3d304615"
655
+ },
656
+ {
657
+ "name": "filters",
658
+ "label": "过滤规则",
659
+ "quickEdit": {
660
+ "type": "textarea",
661
+ "tpl": "<b><%=data.filters%></b>",
662
+ "className": "col-span-2 m-0",
663
+ "labelClassName": "text-left",
664
+ "onEvent": {
665
+ "change": {
666
+ "actions": [
667
+ {
668
+ "actionType": "setValue",
669
+ "args": {
670
+ "value": "${event.data|quickEidtSaveForRelatedList:filters}"
671
+ },
672
+ "componentId": "object-layout-form"
673
+ }
674
+ ]
675
+ }
676
+ }
677
+ },
678
+ "breakpoint": "*",
679
+ "id": "u:e4c367804b67"
680
+ },
681
+ {
682
+ "name": "visible_on",
683
+ "label": "显示条件",
684
+ "quickEdit": {
685
+ "type": "textarea",
686
+ "className": "m-0",
687
+ "labelClassName": "text-left",
688
+ "onEvent": {
689
+ "change": {
690
+ "actions": [
691
+ {
692
+ "actionType": "setValue",
693
+ "args": {
694
+ "value": "${event.data|quickEidtSaveForRelatedList:visible_on}"
695
+ },
696
+ "componentId": "object-layout-form"
697
+ }
698
+ ]
699
+ }
700
+ },
701
+ "tpl": "<b><%=data.visible_on%></b>"
702
+ },
703
+ "breakpoint": "*",
704
+ "id": "u:1e1dc52d7c33"
705
+ },
706
+ {
707
+ "name": "page_size",
708
+ "label": "每页显示数量",
709
+ "quickEdit": {
710
+ "type": "input-number",
711
+ "precision": 0,
712
+ "className": "m-0",
713
+ "labelClassName": "text-left",
714
+ "onEvent": {
715
+ "change": {
716
+ "actions": [
717
+ {
718
+ "actionType": "setValue",
719
+ "args": {
720
+ "value": "${event.data|quickEidtSaveForRelatedList:page_size}"
721
+ },
722
+ "componentId": "object-layout-form"
723
+ }
724
+ ]
725
+ }
726
+ }
727
+ },
728
+ "breakpoint": "*",
729
+ "id": "u:f9bbd9567bbd"
730
+ }
731
+ ],
732
+ "className": "col-span-2 m-0",
733
+ "labelClassName": "text-left",
734
+ "headerToolbar": [
735
+ {
736
+ "type": "action",
737
+ "actionType": "dialog",
738
+ "dialog": {
739
+ "title": "选择子表",
740
+ "body": [
741
+ {
742
+ "type": "transfer",
743
+ "name": "picked_related_lists",
744
+ "sortable": true,
745
+ "source": "${related_lists_options}",
746
+ "value": "${related_lists|pick:related_field_fullname}",
747
+ "searchable": true
748
+ }
749
+ ],
750
+ "onEvent": {
751
+ "confirm": {
752
+ "actions": [
753
+ {
754
+ "actionType": "setValue",
755
+ "args": {
756
+ "value": "${event.data|clearRelatedLists}"
757
+ },
758
+ "componentId": "object-layout-form"
759
+ },
760
+ {
761
+ "actionType": "setValue",
762
+ "args": {
763
+ "value": "${event.data|convertDataForRelatedLists}"
764
+ },
765
+ "componentId": "object-layout-form"
766
+ }
767
+ ]
768
+ }
769
+ }
770
+ },
771
+ "label": "选择子表",
772
+ "id": "u:b9a5d3b611d7"
773
+ }
774
+ ],
775
+ "source": "${related_lists}",
776
+ "footable": false,
777
+ "columnsTogglable": true,
778
+ "messages": {},
779
+ "tableClassName": "min-w-max",
780
+ "id": "u:95aea10231d3"
781
+ }
782
+ ],
783
+ "id": "u:2d4c3fe14984",
784
+ "inline": false,
785
+ "affixFooter": false,
786
+ "headerClassName": "antd-Panel-heading pl-0",
787
+ "className": "m-0",
788
+ "bodyClassName": "antd-Panel-body p-0"
789
+ }
790
+ ],
791
+ "id": "u:dbadaff47153",
792
+ "messages": {},
793
+ "api": {
794
+ "method": "get",
795
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options",
796
+ "sendOn": "!!this.object_name",
797
+ "adaptor": "// 把”选择子表“弹出窗口中设置的子表转为主表单related_lists字段值格式\namis.registerFilter('convertDataForRelatedLists', function (input) {\n let pickedRelateds = input.picked_related_lists || [];\n const superRelateds = _.keyBy(input.__super.related_lists, 'related_field_fullname');\n if (typeof pickedRelateds === \"string\") {\n pickedRelateds = pickedRelateds.split(\",\");\n }\n const convertedRelateds = pickedRelateds.map(function (key) {\n return superRelateds[key] || {\n related_field_fullname: key,\n sort_order: \"asc\"\n }\n });\n return {\n related_lists: convertedRelateds\n }\n});\n\n// 字段列表每一列数据变量时立即同步值到表单中\namis.registerFilter('quickEidtSaveForRelatedList', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = this.data;\n delete rowValue.event;\n const formValue = rowValue.__super.__super;\n const related_field_fullname = rowValue.related_field_fullname;\n rowValue[prop_name] = currentPropValue;\n let newRelatedLists = formValue.related_lists.map(function (item) {\n if (item.related_field_fullname == related_field_fullname) {\n if (prop_name === \"related_field_fullname\") {\n // 直接在表格上变更子表选项的话,清除其他属性值\n return {\n related_field_fullname: currentPropValue,\n sort_order: \"asc\"\n }\n }\n else {\n return Object.assign({}, item, rowValue);\n }\n }\n else {\n return item;\n }\n });\n const newFormDoc = {\n related_lists: newRelatedLists\n };\n if (prop_name === \"field_names\" || prop_name === \"sort_field_name\") { \n // 修改子表显示字段和排序字段时把变更后的字段值显示为label\n const currentOptions = {};\n currentOptions[related_field_fullname] = input.options;\n newFormDoc.related_object_fields_options = Object.assign({}, formValue.related_object_fields_options, currentOptions);\n }\n return newFormDoc;\n});\n\n// 清空主表单fields字段值\namis.registerFilter('clearRelatedLists', function (input) {\n return {\n related_lists: []\n }\n});\n\n// 新建页面布局时初始化related_lists默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\namis.registerFilter('initDefaultRelatedLists', function (input) {\n const superValues = this.data.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n related_lists: superValues.related_lists,\n }\n});\n\nlet data = payload.data;\ndata.related_lists_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n"
798
+ },
799
+ "className": "col-span-2 m-0",
800
+ "affixFooter": false
801
+ }
802
+ ],
803
+ "id": "u:4b4c1d86aa40"
804
+ }
805
+ ],
806
+ "panelClassName": "m-0",
807
+ "bodyClassName": "p-4",
808
+ "actions": [
809
+ {
810
+ "type": "button",
811
+ "label": "取消",
812
+ "actionType": "",
813
+ "level": "default",
814
+ "block": false,
815
+ "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
816
+ "id": "u:bf2587b53d64"
817
+ },
818
+ {
819
+ "type": "button",
820
+ "label": "保存",
821
+ "actionType": "submit",
822
+ "level": "info",
823
+ "id": "u:08afd6e53cab"
824
+ }
825
+ ],
826
+ "actionsClassName": "p-sm b-t b-light text-center",
827
+ "className": "steedos-amis-form",
828
+ "checkAll": false,
829
+ "id": "object-layout-form",
830
+ "onEvent": {
831
+ "inited": {
832
+ "actions": [
833
+ {
834
+ "actionType": "setValue",
835
+ "args": {
836
+ "value": "${event.data|initDefaultButtons}"
837
+ }
838
+ },
839
+ {
840
+ "actionType": "setValue",
841
+ "args": {
842
+ "value": "${event.data|initDefaultFields}"
843
+ }
844
+ },
845
+ {
846
+ "actionType": "setValue",
847
+ "args": {
848
+ "value": "${event.data|initDefaultRelatedLists}"
849
+ }
850
+ }
851
+ ]
852
+ }
853
+ },
854
+ "data": {
855
+ "sort_order_options": [
856
+ {
857
+ "label": "正序",
858
+ "value": "asc"
859
+ },
860
+ {
861
+ "label": "倒序",
862
+ "value": "desc"
863
+ }
864
+ ]
865
+ }
866
+ }
867
+ ],
868
+ "regions": [
869
+ "body"
870
+ ],
871
+ "data": {
872
+ "objectName": "object_layouts",
873
+ "context": {
874
+ "rootUrl": "http://127.0.0.1:5800",
875
+ "tenantId": "hKdnwE55WcnWveYxS",
876
+ "userId": "62ede4f62161e377e35de58c",
877
+ "authToken": "20ec4d08e58513a09df7a5a5f2f5fb40d52e3e1722de92970a16be9d3db27dc50be21a5c8e9cab1caa7932"
878
+ }
879
+ },
880
+ "bodyClassName": "p-0",
881
+ "name": "page_edit_${recordId}",
882
+ "initApi": null,
883
+ "initFetch": null,
884
+ "className": "page-form-object_layouts",
885
+ "id": "u:3b0de7e88def"
886
+ }
@@ -0,0 +1,12 @@
1
+ name: object_layouts
2
+ is_active: true
3
+ label: 页面布局表单
4
+ object_name: object_layouts
5
+ pageAssignments:
6
+ - desktop: true
7
+ mobile: true
8
+ page: object_layouts
9
+ type: orgDefault
10
+ render_engine: amis
11
+ type: form
12
+ widgets: []
@@ -312,7 +312,10 @@ module.exports = {
312
312
  type: "detail",
313
313
  }
314
314
  */
315
- relatedLists = relatedLists.concat(_.union(object.details, object.lookup_details));
315
+ const relationsInfo = await object.getRelationsInfo();
316
+ const details = relationsInfo && relationsInfo.details;
317
+ const lookupDetails = relationsInfo && relationsInfo.lookup_details;
318
+ relatedLists = relatedLists.concat(_.union(details, lookupDetails));
316
319
 
317
320
  if(objectConfig.enable_tasks){
318
321
  relatedLists.push("tasks.related_to")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.3.0-beta.3",
3
+ "version": "2.3.0-beta.7",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "node .scripts/build.tailwind.js"
@@ -10,5 +10,5 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "gitHead": "bb746c90035f38b361011e4b10f0993a390e8355"
13
+ "gitHead": "5d38049fe2c3d47860b31a73ea850a78049627ea"
14
14
  }