@steedos/service-plugin-amis 2.3.0-beta.4 → 2.3.0-beta.5

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.
@@ -0,0 +1,889 @@
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 \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
+ },
51
+ {
52
+ "name": "label",
53
+ "label": "页面布局名",
54
+ "required": true,
55
+ "type": "input-text",
56
+ "className": "col-span-2 m-0",
57
+ "labelClassName": "text-left"
58
+ },
59
+ {
60
+ "name": "object_name",
61
+ "label": "对象",
62
+ "required": true,
63
+ "type": "select",
64
+ "joinValues": false,
65
+ "extractValue": true,
66
+ "labelField": "label",
67
+ "valueField": "value",
68
+ "autoComplete": "get:/service/api/amis-metadata-objects/objects/options",
69
+ "className": "m-0",
70
+ "labelClassName": "text-left",
71
+ "en-US": {
72
+ "label": "Object"
73
+ },
74
+ "checkAll": false,
75
+ "searchable": true
76
+ },
77
+ {
78
+ "name": "profiles",
79
+ "label": "简档",
80
+ "required": true,
81
+ "type": "select",
82
+ "joinValues": false,
83
+ "extractValue": true,
84
+ "labelField": "label",
85
+ "multiple": true,
86
+ "className": "m-0",
87
+ "labelClassName": "text-left",
88
+ "checkAll": true,
89
+ "source": {
90
+ "method": "post",
91
+ "url": "${context.rootUrl}/graphql",
92
+ "data": {
93
+ "query": "{options:permission_set(filters: [\"type\", \"=\", \"profile\"]){name,label}}"
94
+ },
95
+ "requestAdaptor": "",
96
+ "adaptor": ""
97
+ },
98
+ "valueField": "name",
99
+ "searchable": true
100
+ },
101
+ {
102
+ "type": "service",
103
+ "body": [
104
+ {
105
+ "type": "panel",
106
+ "title": "操作",
107
+ "body": [
108
+ {
109
+ "name": "buttons",
110
+ "label": "操作",
111
+ "type": "crud",
112
+ "strictMode": false,
113
+ "affixHeader": false,
114
+ "editable": true,
115
+ "addable": false,
116
+ "removable": true,
117
+ "draggable": false,
118
+ "columns": [
119
+ {
120
+ "name": "button_name",
121
+ "label": "名称",
122
+ "quickEdit": {
123
+ "type": "select",
124
+ "joinValues": false,
125
+ "extractValue": true,
126
+ "labelField": "label",
127
+ "valueField": "value",
128
+ "className": "m-0",
129
+ "labelClassName": "text-left",
130
+ "source": "${buttons_options}",
131
+ "mode": "inline",
132
+ "onEvent": {
133
+ "change": {
134
+ "actions": [
135
+ {
136
+ "actionType": "setValue",
137
+ "args": {
138
+ "value": "${event.data|quickEidtSaveForButton:button_name}"
139
+ },
140
+ "componentId": "object-layout-form"
141
+ }
142
+ ]
143
+ }
144
+ },
145
+ "searchable": true
146
+ },
147
+ "affixFooter": false,
148
+ "placeholder": "-",
149
+ "className": "popOver"
150
+ },
151
+ {
152
+ "name": "visible_on",
153
+ "label": "显示条件",
154
+ "quickEdit": {
155
+ "type": "input-text",
156
+ "className": "m-0",
157
+ "labelClassName": "text-left",
158
+ "mode": "inline",
159
+ "onEvent": {
160
+ "change": {
161
+ "actions": [
162
+ {
163
+ "actionType": "setValue",
164
+ "args": {
165
+ "value": "${event.data|quickEidtSaveForButton:visible_on}"
166
+ },
167
+ "componentId": "object-layout-form"
168
+ }
169
+ ]
170
+ }
171
+ },
172
+ "tpl": "<b><%=data.visible_on%></b>"
173
+ }
174
+ }
175
+ ],
176
+ "className": "col-span-2 m-0",
177
+ "labelClassName": "text-left",
178
+ "footable": false,
179
+ "headerToolbar": [
180
+ {
181
+ "type": "action",
182
+ "actionType": "dialog",
183
+ "dialog": {
184
+ "title": "选择操作",
185
+ "body": [
186
+ {
187
+ "type": "transfer",
188
+ "name": "picked_buttons",
189
+ "sortable": true,
190
+ "source": "${buttons_options}",
191
+ "value": "${buttons|pick:button_name}",
192
+ "searchable": true
193
+ }
194
+ ],
195
+ "onEvent": {
196
+ "confirm": {
197
+ "actions": [
198
+ {
199
+ "actionType": "setValue",
200
+ "args": {
201
+ "value": "${event.data|clearButtons}"
202
+ },
203
+ "componentId": "object-layout-form"
204
+ },
205
+ {
206
+ "actionType": "setValue",
207
+ "args": {
208
+ "value": "${event.data|convertDataForButtons}"
209
+ },
210
+ "componentId": "object-layout-form"
211
+ }
212
+ ]
213
+ }
214
+ }
215
+ },
216
+ "label": "选择操作"
217
+ }
218
+ ],
219
+ "source": "${buttons}"
220
+ }
221
+ ],
222
+ "id": "u:1c6f542c9215",
223
+ "inline": false,
224
+ "affixFooter": false,
225
+ "className": "m-0",
226
+ "headerClassName": "antd-Panel-heading pl-0",
227
+ "bodyClassName": "antd-Panel-body p-0"
228
+ }
229
+ ],
230
+ "id": "u:bef2e378d96f",
231
+ "messages": {},
232
+ "api": {
233
+ "method": "get",
234
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/actions/options",
235
+ "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",
236
+ "sendOn": "!!this.object_name"
237
+ },
238
+ "className": "col-span-2 m-0"
239
+ },
240
+ {
241
+ "type": "service",
242
+ "body": [
243
+ {
244
+ "type": "panel",
245
+ "title": "字段",
246
+ "body": [
247
+ {
248
+ "name": "fields",
249
+ "required": true,
250
+ "type": "crud",
251
+ "strictMode": false,
252
+ "affixHeader": false,
253
+ "editable": true,
254
+ "addable": false,
255
+ "removable": true,
256
+ "draggable": false,
257
+ "columns": [
258
+ {
259
+ "name": "field_name",
260
+ "quickEdit": {
261
+ "type": "select",
262
+ "source": "${fields_options}",
263
+ "mode": "inline",
264
+ "onEvent": {
265
+ "change": {
266
+ "actions": [
267
+ {
268
+ "actionType": "setValue",
269
+ "args": {
270
+ "value": "${event.data|quickEidtSaveForField:field_name}"
271
+ },
272
+ "componentId": "object-layout-form"
273
+ }
274
+ ]
275
+ }
276
+ },
277
+ "searchable": true
278
+ },
279
+ "affixFooter": false,
280
+ "placeholder": "-",
281
+ "className": "popOver",
282
+ "label": "字段"
283
+ },
284
+ {
285
+ "name": "is_readonly",
286
+ "label": "只读",
287
+ "quickEdit": {
288
+ "type": "checkbox",
289
+ "tpl": null,
290
+ "className": "m-0",
291
+ "labelClassName": "text-left",
292
+ "mode": "inline",
293
+ "onEvent": {
294
+ "change": {
295
+ "actions": [
296
+ {
297
+ "actionType": "setValue",
298
+ "args": {
299
+ "value": "${event.data|quickEidtSaveForField:is_readonly}"
300
+ },
301
+ "componentId": "object-layout-form"
302
+ }
303
+ ]
304
+ }
305
+ }
306
+ }
307
+ },
308
+ {
309
+ "name": "is_required",
310
+ "label": "必填",
311
+ "quickEdit": {
312
+ "type": "checkbox",
313
+ "tpl": null,
314
+ "className": "m-0",
315
+ "labelClassName": "text-left",
316
+ "mode": "inline",
317
+ "onEvent": {
318
+ "change": {
319
+ "actions": [
320
+ {
321
+ "actionType": "setValue",
322
+ "args": {
323
+ "value": "${event.data|quickEidtSaveForField:is_required}"
324
+ },
325
+ "componentId": "object-layout-form"
326
+ }
327
+ ]
328
+ }
329
+ }
330
+ }
331
+ },
332
+ {
333
+ "name": "group",
334
+ "label": "分组",
335
+ "quickEdit": {
336
+ "mode": "inline",
337
+ "type": "select",
338
+ "inputClassName": "w-xs",
339
+ "className": "m-0",
340
+ "onEvent": {
341
+ "change": {
342
+ "actions": [
343
+ {
344
+ "actionType": "setValue",
345
+ "args": {
346
+ "value": "${event.data|clearFields}"
347
+ },
348
+ "componentId": "object-layout-form"
349
+ },
350
+ {
351
+ "actionType": "setValue",
352
+ "args": {
353
+ "value": "${event.data|quickEidtSaveForField:group}"
354
+ },
355
+ "componentId": "object-layout-form"
356
+ }
357
+ ]
358
+ }
359
+ },
360
+ "source": "${field_groups|pick:group_name}",
361
+ "checkAll": false,
362
+ "selectFirst": false,
363
+ "searchable": true
364
+ }
365
+ },
366
+ {
367
+ "name": "visible_on",
368
+ "label": "显示条件",
369
+ "quickEdit": {
370
+ "type": "textarea",
371
+ "tpl": "<b><%=data.visible_on%></b>",
372
+ "className": "m-0",
373
+ "labelClassName": "text-left",
374
+ "mode": "inline",
375
+ "onEvent": {
376
+ "change": {
377
+ "actions": [
378
+ {
379
+ "actionType": "setValue",
380
+ "args": {
381
+ "value": "${event.data|quickEidtSaveForField:visible_on}"
382
+ },
383
+ "componentId": "object-layout-form"
384
+ }
385
+ ]
386
+ }
387
+ }
388
+ },
389
+ "breakpoint": "*"
390
+ }
391
+ ],
392
+ "className": "col-span-2 m-0",
393
+ "labelClassName": "text-left",
394
+ "source": "${fields}",
395
+ "footable": true,
396
+ "headerToolbar": [
397
+ {
398
+ "type": "action",
399
+ "actionType": "dialog",
400
+ "dialog": {
401
+ "title": "选择字段",
402
+ "body": [
403
+ {
404
+ "type": "transfer",
405
+ "name": "picked_fields",
406
+ "sortable": true,
407
+ "source": "${fields_options}",
408
+ "value": "${fields|pick:field_name}",
409
+ "searchable": true
410
+ }
411
+ ],
412
+ "onEvent": {
413
+ "confirm": {
414
+ "actions": [
415
+ {
416
+ "actionType": "setValue",
417
+ "args": {
418
+ "value": "${event.data|clearFields}"
419
+ },
420
+ "componentId": "object-layout-form"
421
+ },
422
+ {
423
+ "actionType": "setValue",
424
+ "args": {
425
+ "value": "${event.data|convertDataForFields}"
426
+ },
427
+ "componentId": "object-layout-form"
428
+ }
429
+ ]
430
+ }
431
+ }
432
+ },
433
+ "label": "选择字段"
434
+ },
435
+ {
436
+ "type": "action",
437
+ "actionType": "dialog",
438
+ "dialog": {
439
+ "title": "设置分组",
440
+ "body": [
441
+ {
442
+ "type": "input-table",
443
+ "name": "setting_groups",
444
+ "addable": true,
445
+ "draggable": true,
446
+ "editable": true,
447
+ "columns": [
448
+ {
449
+ "name": "group_name",
450
+ "label": "名称"
451
+ }
452
+ ],
453
+ "value": "${field_groups}",
454
+ "removable": true
455
+ }
456
+ ],
457
+ "onEvent": {
458
+ "confirm": {
459
+ "actions": [
460
+ {
461
+ "actionType": "setValue",
462
+ "args": {
463
+ "value": "${event.data|clearFields}"
464
+ },
465
+ "componentId": "object-layout-form"
466
+ },
467
+ {
468
+ "actionType": "setValue",
469
+ "args": {
470
+ "value": "${event.data|convertDataForGroups}"
471
+ },
472
+ "componentId": "object-layout-form"
473
+ }
474
+ ]
475
+ }
476
+ },
477
+ "type": "dialog"
478
+ },
479
+ "label": "设置分组"
480
+ }
481
+ ]
482
+ }
483
+ ],
484
+ "id": "u:acfaf85221b7",
485
+ "inline": false,
486
+ "affixFooter": false,
487
+ "className": "m-0",
488
+ "headerClassName": "antd-Panel-heading pl-0",
489
+ "bodyClassName": "antd-Panel-body p-0"
490
+ }
491
+ ],
492
+ "id": "u:ac5b7818b88f",
493
+ "affixFooter": false,
494
+ "messages": {},
495
+ "api": {
496
+ "method": "get",
497
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/layout_options",
498
+ "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",
499
+ "sendOn": "!!this.object_name",
500
+ "data": null
501
+ },
502
+ "className": "col-span-2 m-0",
503
+ "placeholder": "-",
504
+ "onEvent": {
505
+ "fetchInited": {
506
+ "actions": [
507
+ {
508
+ "actionType": "setValue",
509
+ "args": {
510
+ "value": "${event.data|mixingGroupsFromFields}"
511
+ },
512
+ "componentId": "object-layout-form"
513
+ }
514
+ ]
515
+ }
516
+ }
517
+ },
518
+ {
519
+ "type": "service",
520
+ "body": [
521
+ {
522
+ "type": "panel",
523
+ "title": "子表",
524
+ "body": [
525
+ {
526
+ "name": "related_lists",
527
+ "type": "crud",
528
+ "strictMode": false,
529
+ "affixHeader": false,
530
+ "editable": true,
531
+ "addable": true,
532
+ "removable": true,
533
+ "draggable": false,
534
+ "columns": [
535
+ {
536
+ "name": "related_field_fullname",
537
+ "label": "子表名称",
538
+ "quickEdit": {
539
+ "type": "select",
540
+ "joinValues": false,
541
+ "extractValue": true,
542
+ "labelField": "label",
543
+ "valueField": "value",
544
+ "className": "m-0",
545
+ "labelClassName": "text-left",
546
+ "checkAll": false,
547
+ "mode": "inline",
548
+ "source": "${related_lists_options}",
549
+ "onEvent": {
550
+ "change": {
551
+ "actions": [
552
+ {
553
+ "actionType": "setValue",
554
+ "args": {
555
+ "value": "${event.data|quickEidtSaveForRelatedList:related_field_fullname}"
556
+ },
557
+ "componentId": "object-layout-form"
558
+ }
559
+ ]
560
+ }
561
+ },
562
+ "searchable": true
563
+ },
564
+ "placeholder": "-",
565
+ "affixFooter": false,
566
+ "className": "popOver"
567
+ },
568
+ {
569
+ "name": "label",
570
+ "label": "显示标题",
571
+ "quickEdit": {
572
+ "labelRemark": "默认为对象名称",
573
+ "type": "input-text",
574
+ "className": "m-0",
575
+ "labelClassName": "text-left",
576
+ "mode": "inline",
577
+ "onEvent": {
578
+ "change": {
579
+ "actions": [
580
+ {
581
+ "actionType": "setValue",
582
+ "args": {
583
+ "value": "${event.data|quickEidtSaveForRelatedList:label}"
584
+ },
585
+ "componentId": "object-layout-form"
586
+ }
587
+ ]
588
+ }
589
+ }
590
+ }
591
+ },
592
+ {
593
+ "name": "field_names",
594
+ "label": "显示的字段",
595
+ "quickEdit": {
596
+ "type": "transfer-picker",
597
+ "mode": "inline",
598
+ "source": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
599
+ "searchable": true,
600
+ "onEvent": {
601
+ "change": {
602
+ "actions": [
603
+ {
604
+ "actionType": "setValue",
605
+ "args": {
606
+ "value": "${event.data|quickEidtSaveForRelatedList:field_names}"
607
+ },
608
+ "componentId": "object-layout-form"
609
+ }
610
+ ]
611
+ }
612
+ },
613
+ "joinValues": false,
614
+ "extractValue": true
615
+ }
616
+ },
617
+ {
618
+ "name": "sort_field_name",
619
+ "label": "排序字段",
620
+ "quickEdit": {
621
+ "type": "transfer-picker",
622
+ "source": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
623
+ "mode": "inline",
624
+ "searchable": true,
625
+ "onEvent": {
626
+ "change": {
627
+ "actions": [
628
+ {
629
+ "actionType": "setValue",
630
+ "args": {
631
+ "value": "${event.data|quickEidtSaveForRelatedList:sort_field_name}"
632
+ },
633
+ "componentId": "object-layout-form"
634
+ }
635
+ ]
636
+ }
637
+ },
638
+ "joinValues": false,
639
+ "extractValue": true
640
+ },
641
+ "breakpoint": "*"
642
+ },
643
+ {
644
+ "name": "sort_order",
645
+ "label": "排序方式",
646
+ "quickEdit": {
647
+ "type": "select",
648
+ "joinValues": false,
649
+ "options": [
650
+ {
651
+ "label": "正序",
652
+ "value": "asc"
653
+ },
654
+ {
655
+ "label": "倒序",
656
+ "value": "desc"
657
+ }
658
+ ],
659
+ "extractValue": true,
660
+ "clearable": true,
661
+ "labelField": "label",
662
+ "valueField": "value",
663
+ "tpl": null,
664
+ "value": "\"asc\"",
665
+ "className": "m-0",
666
+ "labelClassName": "text-left",
667
+ "mode": "inline",
668
+ "onEvent": {
669
+ "change": {
670
+ "actions": [
671
+ {
672
+ "actionType": "setValue",
673
+ "args": {
674
+ "value": "${event.data|quickEidtSaveForRelatedList:sort_order}"
675
+ },
676
+ "componentId": "object-layout-form"
677
+ }
678
+ ]
679
+ }
680
+ }
681
+ },
682
+ "breakpoint": "*"
683
+ },
684
+ {
685
+ "name": "filters",
686
+ "label": "过滤规则",
687
+ "quickEdit": {
688
+ "type": "textarea",
689
+ "tpl": "<b><%=data.filters%></b>",
690
+ "className": "col-span-2 m-0",
691
+ "labelClassName": "text-left",
692
+ "mode": "inline",
693
+ "onEvent": {
694
+ "change": {
695
+ "actions": [
696
+ {
697
+ "actionType": "setValue",
698
+ "args": {
699
+ "value": "${event.data|quickEidtSaveForRelatedList:filters}"
700
+ },
701
+ "componentId": "object-layout-form"
702
+ }
703
+ ]
704
+ }
705
+ }
706
+ },
707
+ "breakpoint": "*"
708
+ },
709
+ {
710
+ "name": "visible_on",
711
+ "label": "显示条件",
712
+ "quickEdit": {
713
+ "type": "textarea",
714
+ "tpl": "<b><%=data.visible_on%></b>",
715
+ "className": "m-0",
716
+ "labelClassName": "text-left",
717
+ "mode": "inline",
718
+ "onEvent": {
719
+ "change": {
720
+ "actions": [
721
+ {
722
+ "actionType": "setValue",
723
+ "args": {
724
+ "value": "${event.data|quickEidtSaveForRelatedList:visible_on}"
725
+ },
726
+ "componentId": "object-layout-form"
727
+ }
728
+ ]
729
+ }
730
+ }
731
+ },
732
+ "breakpoint": "*"
733
+ },
734
+ {
735
+ "name": "page_size",
736
+ "label": "每页显示数量",
737
+ "quickEdit": {
738
+ "type": "input-number",
739
+ "precision": 0,
740
+ "className": "m-0",
741
+ "labelClassName": "text-left",
742
+ "mode": "inline",
743
+ "onEvent": {
744
+ "change": {
745
+ "actions": [
746
+ {
747
+ "actionType": "setValue",
748
+ "args": {
749
+ "value": "${event.data|quickEidtSaveForRelatedList:page_size}"
750
+ },
751
+ "componentId": "object-layout-form"
752
+ }
753
+ ]
754
+ }
755
+ }
756
+ },
757
+ "breakpoint": "*"
758
+ }
759
+ ],
760
+ "className": "col-span-2 m-0",
761
+ "labelClassName": "text-left",
762
+ "headerToolbar": [
763
+ {
764
+ "type": "action",
765
+ "actionType": "dialog",
766
+ "dialog": {
767
+ "title": "选择子表",
768
+ "body": [
769
+ {
770
+ "type": "transfer",
771
+ "name": "picked_related_lists",
772
+ "sortable": true,
773
+ "source": "${related_lists_options}",
774
+ "value": "${related_lists|pick:related_field_fullname}",
775
+ "searchable": true
776
+ }
777
+ ],
778
+ "onEvent": {
779
+ "confirm": {
780
+ "actions": [
781
+ {
782
+ "actionType": "setValue",
783
+ "args": {
784
+ "value": "${event.data|clearRelatedLists}"
785
+ },
786
+ "componentId": "object-layout-form"
787
+ },
788
+ {
789
+ "actionType": "setValue",
790
+ "args": {
791
+ "value": "${event.data|convertDataForRelatedLists}"
792
+ },
793
+ "componentId": "object-layout-form"
794
+ }
795
+ ]
796
+ }
797
+ }
798
+ },
799
+ "label": "选择子表"
800
+ }
801
+ ],
802
+ "source": "${related_lists}",
803
+ "footable": true,
804
+ "columnsTogglable": false
805
+ }
806
+ ],
807
+ "id": "u:2d4c3fe14984",
808
+ "inline": false,
809
+ "affixFooter": false,
810
+ "headerClassName": "antd-Panel-heading pl-0",
811
+ "className": "m-0",
812
+ "bodyClassName": "antd-Panel-body p-0"
813
+ }
814
+ ],
815
+ "id": "u:dbadaff47153",
816
+ "messages": {},
817
+ "api": {
818
+ "method": "get",
819
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options",
820
+ "sendOn": "!!this.object_name",
821
+ "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 return {\n related_lists: newRelatedLists\n }\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"
822
+ },
823
+ "className": "col-span-2 m-0"
824
+ }
825
+ ]
826
+ }
827
+ ],
828
+ "panelClassName": "m-0",
829
+ "bodyClassName": "p-4",
830
+ "actions": [
831
+ {
832
+ "type": "button",
833
+ "label": "取消",
834
+ "actionType": "",
835
+ "level": "default",
836
+ "block": false,
837
+ "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();"
838
+ },
839
+ {
840
+ "type": "button",
841
+ "label": "保存",
842
+ "actionType": "submit",
843
+ "level": "info"
844
+ }
845
+ ],
846
+ "actionsClassName": "p-sm b-t b-light text-center",
847
+ "className": "steedos-amis-form",
848
+ "checkAll": false,
849
+ "id": "object-layout-form",
850
+ "onEvent": {
851
+ "inited": {
852
+ "actions": [
853
+ {
854
+ "actionType": "setValue",
855
+ "args": {
856
+ "value": "${event.data|initDefaultButtons}"
857
+ }
858
+ },
859
+ {
860
+ "actionType": "setValue",
861
+ "args": {
862
+ "value": "${event.data|initDefaultFields}"
863
+ }
864
+ },
865
+ {
866
+ "actionType": "setValue",
867
+ "args": {
868
+ "value": "${event.data|initDefaultRelatedLists}"
869
+ }
870
+ }
871
+ ]
872
+ }
873
+ }
874
+ }
875
+ ],
876
+ "regions": [
877
+ "body"
878
+ ],
879
+ "data": {
880
+ "objectName": "object_layouts",
881
+ "context": {
882
+ "rootUrl": "http://127.0.0.1:5800"
883
+ }
884
+ },
885
+ "bodyClassName": "p-0",
886
+ "name": "page_edit_${recordId}",
887
+ "initApi": null,
888
+ "initFetch": null
889
+ }
@@ -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: []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.3.0-beta.4",
3
+ "version": "2.3.0-beta.5",
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": "04dec60fc62988742fcf63181d26f584f5995196"
13
+ "gitHead": "36b9f5a9327378379ed8f1ca3d790f08c35625a9"
14
14
  }