@steedos/service-plugin-amis 2.3.0-beta.9 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,10 @@
21
21
  "responseData": {
22
22
  "recordId": "${record._id}"
23
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 "
24
+ "adaptor": "var modal = SteedosUI.getRef(api.body.modalName);\nmodal && modal.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
+ "headers": {
26
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
27
+ }
25
28
  },
26
29
  "initApi": {
27
30
  "method": "post",
@@ -31,779 +34,804 @@
31
34
  "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
35
  "data": {
33
36
  "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}}}"
37
+ },
38
+ "headers": {
39
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
34
40
  }
35
41
  },
36
42
  "initFetch": true,
37
43
  "body": [
38
44
  {
39
- "type": "fieldSet",
40
- "title": "通用",
41
- "collapsable": true,
42
- "body": [
45
+ "type": "tabs",
46
+ "tabs": [
43
47
  {
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"
48
+ "title": "基本信息",
49
+ "body": [
50
+ {
51
+ "type": "wrapper",
52
+ "className": "form-content",
53
+ "body": [
54
+ {
55
+ "name": "name",
56
+ "label": "API 名称",
57
+ "required": true,
58
+ "type": "input-text",
59
+ "className": "col-span-2 m-0",
60
+ "labelClassName": "text-left",
61
+ "id": "u:211102f479e9"
62
+ },
63
+ {
64
+ "name": "label",
65
+ "label": "页面布局名",
66
+ "required": true,
67
+ "type": "input-text",
68
+ "className": "col-span-2 m-0",
69
+ "labelClassName": "text-left",
70
+ "id": "u:1b3e658c6a5e"
71
+ },
72
+ {
73
+ "name": "object_name",
74
+ "label": "对象",
75
+ "required": true,
76
+ "type": "select",
77
+ "joinValues": false,
78
+ "extractValue": true,
79
+ "labelField": "label",
80
+ "valueField": "value",
81
+ "className": "m-0",
82
+ "labelClassName": "text-left",
83
+ "en-US": {
84
+ "label": "Object"
85
+ },
86
+ "checkAll": false,
87
+ "searchable": true,
88
+ "id": "u:4e769995f638",
89
+ "source": {
90
+ "method": "get",
91
+ "url": "/service/api/amis-metadata-objects/objects/options",
92
+ "headers": {
93
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
94
+ }
95
+ },
96
+ "multiple": false
97
+ },
98
+ {
99
+ "name": "profiles",
100
+ "label": "简档",
101
+ "required": true,
102
+ "type": "select",
103
+ "joinValues": false,
104
+ "extractValue": true,
105
+ "labelField": "label",
106
+ "multiple": true,
107
+ "className": "m-0",
108
+ "labelClassName": "text-left",
109
+ "checkAll": true,
110
+ "source": {
111
+ "method": "post",
112
+ "url": "${context.rootUrl}/graphql",
113
+ "data": {
114
+ "query": "{options:permission_set(filters: [\"type\", \"=\", \"profile\"]){name,label}}"
115
+ },
116
+ "requestAdaptor": "",
117
+ "adaptor": "",
118
+ "headers": {
119
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
120
+ }
121
+ },
122
+ "valueField": "name",
123
+ "searchable": true,
124
+ "id": "u:3c65447a8a6e",
125
+ "defaultCheckAll": false,
126
+ "checkAllLabel": "全选"
127
+ }
128
+ ],
129
+ "size": "none",
130
+ "id": "u:ce73f365fafa"
131
+ }
132
+ ],
133
+ "id": "u:c7b26b220195"
104
134
  },
105
135
  {
106
- "type": "service",
136
+ "title": "按钮",
107
137
  "body": [
108
138
  {
109
- "type": "panel",
110
- "title": "按钮",
139
+ "type": "wrapper",
111
140
  "body": [
112
141
  {
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": [
142
+ "type": "service",
143
+ "body": [
123
144
  {
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
- }
145
+ "name": "buttons",
146
+ "label": "按钮",
147
+ "type": "crud",
148
+ "strictMode": true,
149
+ "affixHeader": false,
150
+ "editable": true,
151
+ "addable": false,
152
+ "removable": true,
153
+ "draggable": false,
154
+ "columns": [
155
+ {
156
+ "name": "index",
157
+ "label": "序号",
158
+ "type": "static",
159
+ "value": "${index + 1}",
160
+ "className": "w-10",
161
+ "id": "u:c59784421c37"
157
162
  },
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
- },
163
+ {
164
+ "name": "button_name_label",
165
+ "label": "名称",
166
+ "type": "tpl",
167
+ "tpl": "${buttons_options|filter:value:equals:button_name|pick:label}",
168
+ "id": "u:302f8fadccd3"
169
+ },
170
+ {
171
+ "name": "visible_on",
172
+ "label": "显示条件",
173
+ "quickEdit": {
174
+ "type": "input-text",
175
+ "className": "m-0",
176
+ "labelClassName": "text-left",
177
+ "onEvent": {
178
+ "change": {
179
+ "actions": [
180
+ {
181
+ "actionType": "custom",
182
+ "script": "// 按钮列表每一列数据变量时立即同步值到表单中\nconst 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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForButton(eventData, \"visible_on\")\n }\n});\n"
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ "tpl": "<b><%=data.visible_on%></b>",
188
+ "name": "visible_on",
189
+ "id": "u:daa771bd34b9",
190
+ "mode": "popOver"
191
+ },
192
+ "id": "u:3c35211aa1a0",
193
+ "placeholder": "-"
194
+ }
195
+ ],
196
+ "className": "col-span-2 m-0",
197
+ "labelClassName": "text-left",
198
+ "footable": false,
199
+ "headerToolbar": [
200
+ {
201
+ "type": "button",
202
+ "actionType": "dialog",
203
+ "dialog": {
204
+ "title": "设置按钮",
205
+ "body": [
192
206
  {
193
- "actionType": "setValue",
194
- "args": {
195
- "value": "${event.data|convertDataForButtons}"
196
- },
197
- "componentId": "object-layout-form"
207
+ "type": "transfer",
208
+ "name": "picked_buttons",
209
+ "sortable": true,
210
+ "source": "${buttons_options}",
211
+ "value": "${buttons|pick:button_name}",
212
+ "searchable": true,
213
+ "id": "u:d6e067c40e83"
214
+ }
215
+ ],
216
+ "onEvent": {
217
+ "confirm": {
218
+ "actions": [
219
+ {
220
+ "actionType": "custom",
221
+ "script": "// 清空主表单buttons字段值\nconst clearButtons = function (input) {\n return {\n buttons: []\n }\n}\n\n// 把”设置按钮“弹出窗口中设置的按钮转为主表单buttons字段值格式\nconst 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\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: clearButtons()\n }\n});\n\nsetTimeout(function () {\n doAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: convertDataForButtons(eventData)\n }\n });\n}, 300);\n"
222
+ }
223
+ ]
198
224
  }
199
- ]
200
- }
225
+ },
226
+ "type": "dialog",
227
+ "id": "u:a0027ac6f8c1",
228
+ "closeOnEsc": false,
229
+ "closeOnOutside": false,
230
+ "showCloseButton": true
231
+ },
232
+ "label": "设置按钮",
233
+ "id": "u:1ac8afc8a9bb"
201
234
  }
202
- },
203
- "label": "选择按钮",
204
- "id": "u:1ac8afc8a9bb"
235
+ ],
236
+ "source": "${buttons}",
237
+ "id": "u:a5d43b752494"
205
238
  }
206
239
  ],
207
- "source": "${buttons}",
208
- "id": "u:a5d43b752494"
240
+ "id": "u:bef2e378d96f",
241
+ "api": {
242
+ "method": "get",
243
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/actions/options",
244
+ "adaptor": "let data = payload.data;\ndata.buttons_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
245
+ "sendOn": "!!this.object_name",
246
+ "headers": {
247
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
248
+ }
249
+ },
250
+ "className": "col-span-2 m-0",
251
+ "affixFooter": false,
252
+ "messages": {}
209
253
  }
210
254
  ],
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"
255
+ "size": "none",
256
+ "id": "u:100edb4c59d0"
217
257
  }
218
258
  ],
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
259
+ "id": "u:2a10c03c2218"
229
260
  },
230
261
  {
231
- "type": "service",
262
+ "title": "字段",
232
263
  "body": [
233
264
  {
234
- "type": "panel",
235
- "title": "字段",
265
+ "type": "wrapper",
236
266
  "body": [
237
267
  {
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
- },
268
+ "type": "service",
269
+ "body": [
256
270
  {
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"
271
+ "name": "fields",
272
+ "required": true,
273
+ "type": "crud",
274
+ "strictMode": true,
275
+ "affixHeader": false,
276
+ "editable": true,
277
+ "addable": false,
278
+ "removable": true,
279
+ "draggable": false,
280
+ "columns": [
281
+ {
282
+ "name": "index",
283
+ "className": "w-10",
284
+ "label": "序号",
285
+ "type": "static",
286
+ "value": "${index + 1}",
287
+ "id": "u:d1c2922699d3"
288
+ },
289
+ {
290
+ "name": "field_name_label",
291
+ "label": "字段",
292
+ "type": "tpl",
293
+ "tpl": "${fields_options|filter:value:equals:field_name|pick:label}",
294
+ "id": "u:b95c69a1cd84"
295
+ },
296
+ {
297
+ "name": "is_readonly",
298
+ "label": "只读",
299
+ "quickEdit": {
300
+ "type": "checkbox",
301
+ "tpl": null,
302
+ "className": "m-0",
303
+ "labelClassName": "text-left",
304
+ "mode": "inline",
305
+ "onEvent": {
306
+ "change": {
307
+ "actions": [
308
+ {
309
+ "actionType": "custom",
310
+ "script": "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// 字段列表每一列数据变量时立即同步值到表单中\nconst 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 = input.__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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForField(eventData, \"is_readonly\")\n }\n});\n"
311
+ }
312
+ ]
281
313
  }
282
- ]
283
- }
314
+ },
315
+ "id": "u:8cb44f3db16c",
316
+ "name": "is_readonly"
317
+ },
318
+ "id": "u:5081e6e1af55",
319
+ "placeholder": "-"
284
320
  },
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"
321
+ {
322
+ "name": "is_required",
323
+ "label": "必填",
324
+ "quickEdit": {
325
+ "mode": "inline",
326
+ "type": "checkbox",
327
+ "className": "m-0",
328
+ "onEvent": {
329
+ "change": {
330
+ "actions": [
331
+ {
332
+ "actionType": "custom",
333
+ "script": "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// 字段列表每一列数据变量时立即同步值到表单中\nconst 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 = input.__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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForField(eventData, \"is_required\")\n }\n});\n"
334
+ }
335
+ ]
305
336
  }
306
- ]
307
- }
337
+ },
338
+ "tpl": null,
339
+ "labelClassName": "text-left",
340
+ "id": "u:bbd1c15b6504",
341
+ "name": "is_required"
342
+ },
343
+ "id": "u:e54afb5cc05c",
344
+ "placeholder": "-"
308
345
  },
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"
346
+ {
347
+ "name": "group",
348
+ "label": "分组",
349
+ "quickEdit": {
350
+ "type": "select",
351
+ "className": "m-0",
352
+ "source": "${field_groups|pick:group_name}",
353
+ "checkAll": false,
354
+ "selectFirst": false,
355
+ "onEvent": {
356
+ "change": {
357
+ "actions": [
358
+ {
359
+ "actionType": "custom",
360
+ "script": "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// 字段列表每一列数据变量时立即同步值到表单中\nconst 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 = input.__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\nconst eventData = event.data;\n\n// 清空主表单fields字段值\nconst clearFields = function (input) {\n return {\n fields: []\n }\n}\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: clearFields()\n }\n});\nsetTimeout(function () {\n doAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForField(eventData, \"group\")\n }\n });\n}, 300);\n"
361
+ }
362
+ ]
340
363
  }
341
- ]
342
- }
364
+ },
365
+ "searchable": true,
366
+ "clearable": true,
367
+ "name": "group",
368
+ "id": "u:f75ddc45d296",
369
+ "multiple": false,
370
+ "mode": "popOver"
371
+ },
372
+ "id": "u:e532b1949676",
373
+ "placeholder": "-"
343
374
  },
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"
375
+ {
376
+ "name": "visible_on",
377
+ "label": "显示条件",
378
+ "quickEdit": {
379
+ "type": "input-text",
380
+ "tpl": "<b><%=data.visible_on%></b>",
381
+ "className": "m-0",
382
+ "labelClassName": "text-left",
383
+ "onEvent": {
384
+ "change": {
385
+ "actions": [
386
+ {
387
+ "actionType": "custom",
388
+ "script": "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// 字段列表每一列数据变量时立即同步值到表单中\nconst 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 = input.__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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForField(eventData, \"visible_on\")\n }\n});\n"
389
+ }
390
+ ]
366
391
  }
367
- ]
368
- }
392
+ },
393
+ "name": "visible_on",
394
+ "id": "u:624913811ecc",
395
+ "minRows": 3,
396
+ "maxRows": 20,
397
+ "mode": "popOver"
398
+ },
399
+ "breakpoint": "*",
400
+ "id": "u:e3618b8b4c52",
401
+ "placeholder": "-"
369
402
  }
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
- },
403
+ ],
404
+ "className": "col-span-2 m-0",
405
+ "labelClassName": "text-left",
406
+ "source": "${fields}",
407
+ "footable": false,
408
+ "headerToolbar": [
409
+ {
410
+ "type": "button",
411
+ "actionType": "dialog",
412
+ "dialog": {
413
+ "title": "设置字段",
414
+ "body": [
405
415
  {
406
- "actionType": "setValue",
407
- "args": {
408
- "value": "${event.data|convertDataForFields}"
409
- },
410
- "componentId": "object-layout-form"
416
+ "type": "transfer",
417
+ "name": "picked_fields",
418
+ "sortable": true,
419
+ "source": "${fields_options}",
420
+ "value": "${fields|pick:field_name}",
421
+ "searchable": true,
422
+ "id": "u:502c4ecd81b6"
411
423
  }
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": [
424
+ ],
425
+ "onEvent": {
426
+ "confirm": {
427
+ "actions": [
428
+ {
429
+ "actionType": "custom",
430
+ "script": "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字段值\nconst clearFields = function (input) { \n return {\n fields: []\n }\n}\n\n// 把”设置字段“弹出窗口中设置的字段转为主表单fields字段值格式\nconst 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(input.__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 = input.__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\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: clearFields()\n }\n});\n\nsetTimeout(function () {\n doAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: convertDataForFields(eventData)\n }\n });\n}, 300);\n\n"
431
+ }
432
+ ]
433
+ }
434
+ },
435
+ "type": "dialog",
436
+ "id": "u:c405734543e0",
437
+ "closeOnEsc": false,
438
+ "closeOnOutside": false,
439
+ "showCloseButton": true
440
+ },
441
+ "label": "设置字段",
442
+ "id": "u:853b890ab524"
443
+ },
444
+ {
445
+ "type": "button",
446
+ "actionType": "dialog",
447
+ "dialog": {
448
+ "title": "设置分组",
449
+ "body": [
432
450
  {
433
- "name": "group_name",
434
- "label": "名称"
451
+ "type": "input-table",
452
+ "name": "setting_groups",
453
+ "addable": true,
454
+ "draggable": true,
455
+ "editable": true,
456
+ "columns": [
457
+ {
458
+ "name": "group_name",
459
+ "label": "名称",
460
+ "id": "u:ee2fb813a3e7"
461
+ }
462
+ ],
463
+ "value": "${field_groups}",
464
+ "removable": true,
465
+ "id": "u:e9f43ef94d08"
435
466
  }
436
467
  ],
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"
468
+ "onEvent": {
469
+ "confirm": {
470
+ "actions": [
471
+ {
472
+ "actionType": "custom",
473
+ "args": {},
474
+ "componentId": "",
475
+ "script": "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字段值\nconst clearFields = function (input) {\n return {\n fields: []\n }\n}\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置fields属性的字段先后次序\n// 因为直接设置fields值有bug,即新值老值会串,所以需要先执行上面的clearFields清除原来的值\nconst 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 = input.__super.__super.items;\n // fields重新按分组排序\n fields.sort(getFieldsSortFun(groupNames));\n\n return {\n field_groups: convertedGroups,\n fields: fields\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: clearFields()\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: convertDataForGroups(eventData)\n }\n});\n\n"
476
+ }
477
+ ]
457
478
  }
458
- ]
459
- }
460
- },
461
- "type": "dialog"
462
- },
463
- "label": "设置分组",
464
- "id": "u:ec9931ea883c"
479
+ },
480
+ "type": "dialog",
481
+ "id": "u:e02c8f59216e",
482
+ "closeOnEsc": false,
483
+ "closeOnOutside": false,
484
+ "showCloseButton": true
485
+ },
486
+ "label": "设置分组",
487
+ "id": "u:ec9931ea883c"
488
+ }
489
+ ],
490
+ "id": "u:22121edc42b1"
465
491
  }
466
492
  ],
467
- "id": "u:22121edc42b1"
493
+ "id": "u:ac5b7818b88f",
494
+ "affixFooter": false,
495
+ "api": {
496
+ "method": "get",
497
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/layout_options",
498
+ "adaptor": "let 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
+ "headers": {
502
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
503
+ }
504
+ },
505
+ "className": "col-span-2 m-0",
506
+ "placeholder": "-",
507
+ "onEvent": {
508
+ "fetchInited": {
509
+ "actions": [
510
+ {
511
+ "actionType": "custom",
512
+ "script": "// 把字段中配置的group属性加到主表field_groups属性中\nconst mixingGroupsFromFields = function (input, formData) {\n const groupsOptions = input.field_groups_options;\n const groups = formData.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\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: mixingGroupsFromFields(eventData, context.props.data)\n }\n});\n\n"
513
+ }
514
+ ]
515
+ }
516
+ },
517
+ "messages": {}
468
518
  }
469
519
  ],
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"
520
+ "size": "none",
521
+ "id": "u:100edb4c59d0"
476
522
  }
477
523
  ],
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
- }
524
+ "id": "u:8b579617d2da"
503
525
  },
504
526
  {
505
- "type": "service",
527
+ "title": "子表",
506
528
  "body": [
507
529
  {
508
- "type": "panel",
509
- "title": "子表",
530
+ "type": "wrapper",
510
531
  "body": [
511
532
  {
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
- },
533
+ "type": "service",
534
+ "id": "u:dbadaff47153",
535
+ "api": {
536
+ "method": "get",
537
+ "url": "/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options",
538
+ "sendOn": "!!this.object_name",
539
+ "adaptor": "let data = payload.data;\ndata.related_lists_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
540
+ "headers": {
541
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
542
+ }
543
+ },
544
+ "className": "col-span-2 m-0",
545
+ "affixFooter": false,
546
+ "body": [
536
547
  {
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
- }
548
+ "name": "related_lists",
549
+ "type": "crud",
550
+ "strictMode": true,
551
+ "affixHeader": false,
552
+ "editable": true,
553
+ "addable": true,
554
+ "removable": true,
555
+ "draggable": false,
556
+ "columns": [
557
+ {
558
+ "name": "index",
559
+ "label": "序号",
560
+ "className": "w-10",
561
+ "type": "static",
562
+ "value": "${index + 1}",
563
+ "id": "u:a2f05dc83cd4"
554
564
  },
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
565
+ {
566
+ "name": "related_field_fullname_label",
567
+ "label": "子表名称",
568
+ "type": "tpl",
569
+ "tpl": "${related_lists_options|filter:value:equals:related_field_fullname|pick:label}",
570
+ "id": "u:5204fc0fbe1c"
571
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"
572
+ {
573
+ "name": "label",
574
+ "label": "显示标题",
575
+ "quickEdit": {
576
+ "type": "input-text",
577
+ "onEvent": {
578
+ "change": {
579
+ "actions": [
580
+ {
581
+ "actionType": "custom",
582
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, \"label\")\n }\n});\n"
583
+ }
584
+ ]
582
585
  }
583
- ]
584
- }
586
+ },
587
+ "labelRemark": "默认为对象名称",
588
+ "className": "m-0",
589
+ "labelClassName": "text-left",
590
+ "id": "u:5b30f2a71830",
591
+ "name": "label"
592
+ },
593
+ "id": "u:1267e4351d66",
594
+ "placeholder": "-"
585
595
  },
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"
596
+ {
597
+ "name": "field_names",
598
+ "label": "显示的字段",
599
+ "quickEdit": {
600
+ "type": "transfer-picker",
601
+ "source": {
602
+ "method": "get",
603
+ "url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
604
+ "cache": 60000,
605
+ "headers": {
606
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
609
607
  }
610
- ]
611
- }
608
+ },
609
+ "searchable": true,
610
+ "onEvent": {
611
+ "change": {
612
+ "actions": [
613
+ {
614
+ "actionType": "custom",
615
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, rowValue, prop_name) {\n debugger;\n const currentPropValue = input.value;\n // const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, context.props.data, \"field_names\")\n }\n});\n"
616
+ }
617
+ ]
618
+ }
619
+ },
620
+ "joinValues": false,
621
+ "extractValue": true,
622
+ "mode": "inline",
623
+ "id": "u:a85f62af394f",
624
+ "name": "field_names"
625
+ },
626
+ "type": "tpl",
627
+ "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%>",
628
+ "id": "u:ce65d4020107",
629
+ "placeholder": "-"
612
630
  },
613
- "source": {
614
- "method": "get",
615
- "url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
616
- "cache": 60000
631
+ {
632
+ "name": "sort_field_name",
633
+ "label": "排序字段",
634
+ "quickEdit": {
635
+ "type": "transfer-picker",
636
+ "joinValues": false,
637
+ "extractValue": true,
638
+ "onEvent": {
639
+ "change": {
640
+ "actions": [
641
+ {
642
+ "actionType": "custom",
643
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, rowValue, prop_name) {\n debugger;\n const currentPropValue = input.value;\n // const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, context.props.data, \"sort_field_name\")\n }\n});\n"
644
+ }
645
+ ]
646
+ }
647
+ },
648
+ "source": {
649
+ "method": "get",
650
+ "url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
651
+ "cache": 60000,
652
+ "headers": {
653
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
654
+ }
655
+ },
656
+ "searchable": true,
657
+ "name": "sort_field_name",
658
+ "id": "u:c1e3daddf92c",
659
+ "mode": "inline"
660
+ },
661
+ "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%>",
662
+ "id": "u:3dbee6a855c4"
617
663
  },
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"
664
+ {
665
+ "name": "sort_order",
666
+ "label": "排序方式",
667
+ "quickEdit": {
668
+ "className": "m-0",
669
+ "labelClassName": "text-left",
670
+ "onEvent": {
671
+ "change": {
672
+ "actions": [
673
+ {
674
+ "actionType": "custom",
675
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, rowValue, prop_name) {\n debugger;\n const currentPropValue = input.value;\n // const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, context.props.data, \"sort_order\")\n }\n});\n"
676
+ }
677
+ ]
638
678
  }
639
- ]
640
- }
679
+ },
680
+ "joinValues": false,
681
+ "extractValue": true,
682
+ "clearable": true,
683
+ "labelField": "label",
684
+ "valueField": "value",
685
+ "mode_": "inline",
686
+ "source": "${sort_order_options}",
687
+ "type": "select",
688
+ "name": "sort_order",
689
+ "id": "u:951e05ace916",
690
+ "multiple": false
691
+ },
692
+ "breakpoint": "*",
693
+ "type": "tpl",
694
+ "tpl": "${sort_order_options|filter:value:equals:sort_order|pick:label}",
695
+ "id": "u:13cb3d304615"
641
696
  },
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"
697
+ {
698
+ "name": "filters",
699
+ "label": "过滤规则",
700
+ "quickEdit": {
701
+ "type": "input-text",
702
+ "tpl": "<b><%=data.filters%></b>",
703
+ "className": "col-span-2 m-0",
704
+ "labelClassName": "text-left",
705
+ "onEvent": {
706
+ "change": {
707
+ "actions": [
708
+ {
709
+ "actionType": "custom",
710
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, rowValue, prop_name) {\n debugger;\n const currentPropValue = input.value;\n // const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, context.props.data, \"filters\")\n }\n});\n"
711
+ }
712
+ ]
673
713
  }
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"
714
+ },
715
+ "name": "filters",
716
+ "id": "u:0436e626f06a",
717
+ "minRows": 3,
718
+ "maxRows": 20
719
+ },
720
+ "breakpoint": "*",
721
+ "id": "u:e4c367804b67"
722
+ },
723
+ {
724
+ "name": "visible_on",
725
+ "label": "显示条件",
726
+ "quickEdit": {
727
+ "type": "input-text",
728
+ "className": "m-0",
729
+ "labelClassName": "text-left",
730
+ "onEvent": {
731
+ "change": {
732
+ "actions": [
733
+ {
734
+ "actionType": "custom",
735
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, rowValue, prop_name) {\n debugger;\n const currentPropValue = input.value;\n // const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, context.props.data, \"visible_on\")\n }\n});\n"
736
+ }
737
+ ]
697
738
  }
698
- ]
699
- }
739
+ },
740
+ "tpl": "<b><%=data.visible_on%></b>",
741
+ "name": "visible_on",
742
+ "id": "u:3106cc0f9cc7",
743
+ "minRows": 3,
744
+ "maxRows": 20
745
+ },
746
+ "breakpoint": "*",
747
+ "id": "u:1e1dc52d7c33"
700
748
  },
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"
749
+ {
750
+ "name": "page_size",
751
+ "label": "每页显示数量",
752
+ "quickEdit": {
753
+ "type": "input-number",
754
+ "precision": 0,
755
+ "className": "m-0",
756
+ "labelClassName": "text-number",
757
+ "onEvent": {
758
+ "change": {
759
+ "actions": [
760
+ {
761
+ "actionType": "custom",
762
+ "script": "// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForRelatedList = function (input, rowValue, prop_name) {\n debugger;\n const currentPropValue = input.value;\n // const rowValue = input;\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\nconst eventData = event.data;\n\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: quickEidtSaveForRelatedList(eventData, context.props.data, \"page_size\")\n }\n});\n"
763
+ }
764
+ ]
723
765
  }
724
- ]
725
- }
766
+ },
767
+ "name": "page_size",
768
+ "id": "u:0e261f265511"
769
+ },
770
+ "breakpoint": "*",
771
+ "id": "u:f9bbd9567bbd"
726
772
  }
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
- },
773
+ ],
774
+ "className": "col-span-2 m-0",
775
+ "labelClassName": "text-left",
776
+ "headerToolbar": [
777
+ {
778
+ "type": "button",
779
+ "actionType": "dialog",
780
+ "dialog": {
781
+ "title": "设置子表",
782
+ "body": [
760
783
  {
761
- "actionType": "setValue",
762
- "args": {
763
- "value": "${event.data|convertDataForRelatedLists}"
764
- },
765
- "componentId": "object-layout-form"
784
+ "type": "transfer",
785
+ "name": "picked_related_lists",
786
+ "sortable": true,
787
+ "source": "${related_lists_options}",
788
+ "value": "${related_lists|pick:related_field_fullname}",
789
+ "searchable": true,
790
+ "id": "u:ab6a6c9c8677"
791
+ }
792
+ ],
793
+ "onEvent": {
794
+ "confirm": {
795
+ "actions": [
796
+ {
797
+ "actionType": "custom",
798
+ "script": "// 清空主表单related_lists字段值\nconst clearRelatedLists = function (input) {\n return {\n related_lists: []\n }\n}\n\n// 把”设置子表“弹出窗口中设置的子表转为主表单related_lists字段值格式\nconst 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\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: clearRelatedLists()\n }\n});\n\nsetTimeout(function () {\n doAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: convertDataForRelatedLists(eventData)\n }\n });\n}, 300);\n"
799
+ }
800
+ ]
766
801
  }
767
- ]
768
- }
802
+ },
803
+ "type": "dialog",
804
+ "id": "u:3663990f226a",
805
+ "closeOnEsc": false,
806
+ "closeOnOutside": false,
807
+ "showCloseButton": true
808
+ },
809
+ "label": "设置子表",
810
+ "id": "u:b9a5d3b611d7"
769
811
  }
770
- },
771
- "label": "选择子表",
772
- "id": "u:b9a5d3b611d7"
812
+ ],
813
+ "source": "${related_lists}",
814
+ "footable": false,
815
+ "columnsTogglable": true,
816
+ "messages": {},
817
+ "tableClassName": "min-w-max",
818
+ "id": "u:95aea10231d3"
773
819
  }
774
820
  ],
775
- "source": "${related_lists}",
776
- "footable": false,
777
- "columnsTogglable": true,
778
- "messages": {},
779
- "tableClassName": "min-w-max",
780
- "id": "u:95aea10231d3"
821
+ "messages": {}
781
822
  }
782
823
  ],
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"
824
+ "size": "none",
825
+ "id": "u:100edb4c59d0"
789
826
  }
790
827
  ],
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
828
+ "id": "u:e09b5c1a4751"
801
829
  }
802
830
  ],
803
- "id": "u:4b4c1d86aa40"
831
+ "id": "u:33778a88db62"
804
832
  }
805
833
  ],
806
- "panelClassName": "m-0",
834
+ "panelClassName": "m-0 -mt-3",
807
835
  "bodyClassName": "p-4",
808
836
  "actions": [
809
837
  {
@@ -831,22 +859,18 @@
831
859
  "inited": {
832
860
  "actions": [
833
861
  {
834
- "actionType": "setValue",
835
- "args": {
836
- "value": "${event.data|initDefaultButtons}"
837
- }
862
+ "actionType": "custom",
863
+ "script": "// 新建页面布局时初始化buttons默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\nconst initDefaultButtons = function (input) {\n const superValues = input.__super.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n buttons: superValues.buttons,\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: initDefaultButtons(eventData)\n }\n});\n"
838
864
  },
839
865
  {
840
- "actionType": "setValue",
841
- "args": {
842
- "value": "${event.data|initDefaultFields}"
843
- }
866
+ "actionType": "custom",
867
+ "script": "// 新建页面布局时初始化fields默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\nconst initDefaultFields = function (input) {\n const superValues = input.__super.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n fields: superValues.fields,\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: initDefaultFields(eventData)\n }\n});\n",
868
+ "componentId": "",
869
+ "args": {}
844
870
  },
845
871
  {
846
- "actionType": "setValue",
847
- "args": {
848
- "value": "${event.data|initDefaultRelatedLists}"
849
- }
872
+ "actionType": "custom",
873
+ "script": "// 新建页面布局时初始化related_lists默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\nconst initDefaultRelatedLists = function (input, rowValue, prop_name) {\n const superValues = input.__super.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n related_lists: superValues.related_lists,\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"object-layout-form\",\n args: {\n value: initDefaultRelatedLists(eventData)\n }\n});\n"
850
874
  }
851
875
  ]
852
876
  }
@@ -871,10 +895,7 @@
871
895
  "data": {
872
896
  "objectName": "object_layouts",
873
897
  "context": {
874
- "rootUrl": "http://127.0.0.1:5800",
875
- "tenantId": "hKdnwE55WcnWveYxS",
876
- "userId": "62ede4f62161e377e35de58c",
877
- "authToken": "20ec4d08e58513a09df7a5a5f2f5fb40d52e3e1722de92970a16be9d3db27dc50be21a5c8e9cab1caa7932"
898
+ "rootUrl": "http://127.0.0.1:5800"
878
899
  }
879
900
  },
880
901
  "bodyClassName": "p-0",