@steedos/service-plugin-amis 2.6.1-beta.6 → 2.6.2-beta.2
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.
- package/main/default/client/amis.render.client.js +67 -16
- package/main/default/client/creator.function.client.js +4 -4
- package/main/default/pages/{action_field_updates.page.amis.json → action_field_updates_form.page.amis.json} +12 -12
- package/main/default/pages/{action_field_updates.page.yml → action_field_updates_form.page.yml} +1 -1
- package/main/default/pages/apps_form.page.amis.json +295 -567
- package/main/default/pages/listview_form.page.amis.json +179 -552
- package/main/default/pages/object_layouts_form.page.amis.json +100 -0
- package/main/default/pages/{object_layouts.page.yml → object_layouts_form.page.yml} +1 -1
- package/main/default/services/amis-design.service.js +39 -12
- package/main/default/services/metadata/objects.service.js +38 -13
- package/main/default/services/utils/page-schema.js +5 -8
- package/main/default/translations/en.translation.yml +28 -0
- package/main/default/translations/zh-CN.translation.yml +28 -0
- package/package.json +2 -2
- package/package.service.js +62 -4
- package/public/tailwind/tailwind-steedos.css +115 -44
- package/main/default/pages/object_layouts.page.amis.json +0 -913
|
@@ -1,913 +0,0 @@
|
|
|
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
|
-
"resetAfterSubmit": true,
|
|
11
|
-
"title": "",
|
|
12
|
-
"api": {
|
|
13
|
-
"method": "post",
|
|
14
|
-
"url": "${context.rootUrl}/graphql",
|
|
15
|
-
"data": {
|
|
16
|
-
"objectName": "${objectName}",
|
|
17
|
-
"$": "$$",
|
|
18
|
-
"recordId": "${recordId}",
|
|
19
|
-
"modalName": "${modalName}"
|
|
20
|
-
},
|
|
21
|
-
"requestAdaptor": "\n \n const formData = api.data.$;\n for (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n }\n const objectName = api.data.objectName;\n const fieldsName = Object.keys(formData);\n delete formData.created;\n delete formData.created_by;\n delete formData.modified;\n delete formData.modified_by;\n delete formData._display;\n delete formData.sort_order_options;\n delete formData.buttons_options;\n delete formData.fields_options;\n delete formData.field_groups_options;\n delete formData.related_lists_options;\n delete formData.related_object_fields_options;\n delete formData.isLookup;\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 ",
|
|
22
|
-
"adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;\n}\nreturn payload;",
|
|
23
|
-
"responseData": {
|
|
24
|
-
"recordId": "${record._id}"
|
|
25
|
-
},
|
|
26
|
-
"headers": {
|
|
27
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"initApi": {
|
|
31
|
-
"method": "post",
|
|
32
|
-
"url": "${context.rootUrl}/graphql",
|
|
33
|
-
"cache": 100,
|
|
34
|
-
"adaptor": "\n\nconst recordId = api.body.recordId;\nlet initialValues = {};\nif (recordId && payload.data.data) {\n var data = payload.data.data[0];\n const dataKeys = _.keys(data);\n const uiSchema = api.body.uiSchema;\n const fieldKeys = uiSchema && _.keys(uiSchema.fields);\n if (data) {\n _.each(dataKeys, function (key) {\n if (fieldKeys.indexOf(key) < 0) {\n delete data[key];\n }\n })\n\n //初始化接口返回的字段移除字段值为null的字段\n for (key in data) {\n if (data[key] === null) {\n delete data[key];\n }\n }\n };\n initialValues = data;\n}\nelse {\n var uiSchema = api.body.uiSchema;\n var defaultData = api.body.defaultData;\n var defaultValues = {};\n _.each(uiSchema?.fields, function (field) {\n var value = SteedosUI.getFieldDefaultValue(field, api.body.global);\n if (value) {\n defaultValues[field.name] = value;\n }\n });\n if (defaultData && _.isObject(defaultData) && !_.isArray(defaultData)) {\n defaultValues = Object.assign({}, defaultValues, defaultData)\n }\n if (uiSchema.form) {\n try {\n var objectFormConfig = JSON.parse(uiSchema.form);\n initialValues = objectFormConfig.initialValues;\n if (initialValues) {\n initialValues = new Function(\"return \" + initialValues)();\n }\n if (typeof initialValues === \"function\") {\n initialValues = initialValues.apply({ doc: defaultValues || {} })\n }\n }\n catch (ex) {\n console.warn(ex);\n }\n }\n if (_.isObject(initialValues)) {\n // uiSchema.form.initialValues为函数且执行后为json,则优先取initialValues中的默认值\n initialValues = Object.assign({}, defaultValues, initialValues);\n }\n else {\n initialValues = defaultValues;\n }\n}\n\npayload.data = initialValues;\ndelete payload.extensions;\nreturn payload;\n",
|
|
35
|
-
"data": {
|
|
36
|
-
"recordId": "${recordId}",
|
|
37
|
-
"defaultData": "${defaultData}",
|
|
38
|
-
"query": "{data:object_layouts(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,label,object_name,profiles,buttons,fields,related_lists,field_groups,is_system,created,created_by,modified,modified_by,instances,instance_state,_display:_ui{object_name,profiles,buttons,fields,related_lists,is_system,created,created_by,modified,modified_by,instances,instance_state}}}",
|
|
39
|
-
"uiSchema": "${uiSchema}",
|
|
40
|
-
"objectName": "${objectName}"
|
|
41
|
-
},
|
|
42
|
-
"headers": {
|
|
43
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
44
|
-
},
|
|
45
|
-
"requestAdaptor": "\n// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去\nvar { recordId, objectName, uiSchema, global, context, ...data } = api.data;\nif (!recordId) {\n // 新建则不请求任何数据\n data.query = \"{data:\" + objectName + \"(filters: \" + JSON.stringify([\"_id\", \"=\", null]) + \", top: 1){_id}}\";\n}\napi.data = data;\nreturn api;"
|
|
46
|
-
},
|
|
47
|
-
"initFetch": true,
|
|
48
|
-
"body": [
|
|
49
|
-
{
|
|
50
|
-
"type": "tabs",
|
|
51
|
-
"tabs": [
|
|
52
|
-
{
|
|
53
|
-
"title": "基本信息",
|
|
54
|
-
"body": [
|
|
55
|
-
{
|
|
56
|
-
"type": "wrapper",
|
|
57
|
-
"className": "form-content",
|
|
58
|
-
"body": [
|
|
59
|
-
{
|
|
60
|
-
"name": "name",
|
|
61
|
-
"label": "API 名称",
|
|
62
|
-
"required": true,
|
|
63
|
-
"type": "input-text",
|
|
64
|
-
"className": "col-span-2 m-0",
|
|
65
|
-
"labelClassName": "text-left",
|
|
66
|
-
"id": "u:211102f479e9"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"name": "label",
|
|
70
|
-
"label": "页面布局名",
|
|
71
|
-
"required": true,
|
|
72
|
-
"type": "input-text",
|
|
73
|
-
"className": "col-span-2 m-0",
|
|
74
|
-
"labelClassName": "text-left",
|
|
75
|
-
"id": "u:1b3e658c6a5e"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
"name": "object_name",
|
|
79
|
-
"label": "对象",
|
|
80
|
-
"required": true,
|
|
81
|
-
"type": "select",
|
|
82
|
-
"joinValues": false,
|
|
83
|
-
"extractValue": true,
|
|
84
|
-
"labelField": "label",
|
|
85
|
-
"valueField": "value",
|
|
86
|
-
"className": "m-0",
|
|
87
|
-
"labelClassName": "text-left",
|
|
88
|
-
"en-US": {
|
|
89
|
-
"label": "Object"
|
|
90
|
-
},
|
|
91
|
-
"checkAll": false,
|
|
92
|
-
"searchable": true,
|
|
93
|
-
"id": "u:4e769995f638",
|
|
94
|
-
"source": {
|
|
95
|
-
"method": "get",
|
|
96
|
-
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
|
|
97
|
-
"headers": {
|
|
98
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"multiple": false
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"name": "profiles",
|
|
105
|
-
"label": "简档",
|
|
106
|
-
"required": true,
|
|
107
|
-
"type": "select",
|
|
108
|
-
"joinValues": false,
|
|
109
|
-
"extractValue": true,
|
|
110
|
-
"labelField": "label",
|
|
111
|
-
"multiple": true,
|
|
112
|
-
"className": "m-0",
|
|
113
|
-
"labelClassName": "text-left",
|
|
114
|
-
"checkAll": true,
|
|
115
|
-
"source": {
|
|
116
|
-
"method": "post",
|
|
117
|
-
"url": "${context.rootUrl}/graphql",
|
|
118
|
-
"data": {
|
|
119
|
-
"query": "{options:permission_set(filters: [\"type\", \"=\", \"profile\"]){name,label}}"
|
|
120
|
-
},
|
|
121
|
-
"requestAdaptor": "",
|
|
122
|
-
"adaptor": "",
|
|
123
|
-
"headers": {
|
|
124
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
"valueField": "name",
|
|
128
|
-
"searchable": true,
|
|
129
|
-
"id": "u:3c65447a8a6e",
|
|
130
|
-
"defaultCheckAll": false,
|
|
131
|
-
"checkAllLabel": "全选"
|
|
132
|
-
}
|
|
133
|
-
],
|
|
134
|
-
"size": "none",
|
|
135
|
-
"id": "u:ce73f365fafa"
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
"id": "u:c7b26b220195"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"title": "按钮",
|
|
142
|
-
"body": [
|
|
143
|
-
{
|
|
144
|
-
"type": "wrapper",
|
|
145
|
-
"body": [
|
|
146
|
-
{
|
|
147
|
-
"type": "service",
|
|
148
|
-
"body": [
|
|
149
|
-
{
|
|
150
|
-
"name": "buttons",
|
|
151
|
-
"label": "按钮",
|
|
152
|
-
"type": "crud",
|
|
153
|
-
"strictMode": true,
|
|
154
|
-
"affixHeader": false,
|
|
155
|
-
"editable": true,
|
|
156
|
-
"addable": false,
|
|
157
|
-
"removable": true,
|
|
158
|
-
"draggable": false,
|
|
159
|
-
"columns": [
|
|
160
|
-
{
|
|
161
|
-
"name": "index",
|
|
162
|
-
"label": "序号",
|
|
163
|
-
"type": "static",
|
|
164
|
-
"value": "${index + 1}",
|
|
165
|
-
"className": "w-10",
|
|
166
|
-
"id": "u:c59784421c37"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
"name": "button_name_label",
|
|
170
|
-
"label": "名称",
|
|
171
|
-
"type": "tpl",
|
|
172
|
-
"tpl": "${buttons_options|filter:value:equals:button_name|pick:label}",
|
|
173
|
-
"id": "u:302f8fadccd3"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"name": "visible_on",
|
|
177
|
-
"label": "显示条件",
|
|
178
|
-
"className": "w-6/12",
|
|
179
|
-
"quickEdit": {
|
|
180
|
-
"type": "input-text",
|
|
181
|
-
"className": "m-0",
|
|
182
|
-
"labelClassName": "text-left",
|
|
183
|
-
"onEvent": {
|
|
184
|
-
"change": {
|
|
185
|
-
"actions": [
|
|
186
|
-
{
|
|
187
|
-
"actionType": "custom",
|
|
188
|
-
"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"
|
|
189
|
-
}
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
"tpl": "<b><%=data.visible_on%></b>",
|
|
194
|
-
"name": "visible_on",
|
|
195
|
-
"id": "u:daa771bd34b9",
|
|
196
|
-
"mode": "popOver"
|
|
197
|
-
},
|
|
198
|
-
"id": "u:3c35211aa1a0",
|
|
199
|
-
"placeholder": "-"
|
|
200
|
-
}
|
|
201
|
-
],
|
|
202
|
-
"className": "col-span-2 m-0",
|
|
203
|
-
"labelClassName": "text-left",
|
|
204
|
-
"footable": false,
|
|
205
|
-
"headerToolbar": [
|
|
206
|
-
{
|
|
207
|
-
"type": "button",
|
|
208
|
-
"actionType": "dialog",
|
|
209
|
-
"dialog": {
|
|
210
|
-
"title": "设置按钮",
|
|
211
|
-
"body": [
|
|
212
|
-
{
|
|
213
|
-
"type": "transfer",
|
|
214
|
-
"name": "picked_buttons",
|
|
215
|
-
"sortable": true,
|
|
216
|
-
"source": "${buttons_options}",
|
|
217
|
-
"value": "${buttons|pick:button_name}",
|
|
218
|
-
"searchable": true,
|
|
219
|
-
"id": "u:d6e067c40e83"
|
|
220
|
-
}
|
|
221
|
-
],
|
|
222
|
-
"onEvent": {
|
|
223
|
-
"confirm": {
|
|
224
|
-
"actions": [
|
|
225
|
-
{
|
|
226
|
-
"actionType": "custom",
|
|
227
|
-
"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"
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
"type": "dialog",
|
|
233
|
-
"id": "u:a0027ac6f8c1",
|
|
234
|
-
"closeOnEsc": false,
|
|
235
|
-
"closeOnOutside": false,
|
|
236
|
-
"showCloseButton": true,
|
|
237
|
-
"size": "md"
|
|
238
|
-
},
|
|
239
|
-
"label": "设置按钮",
|
|
240
|
-
"id": "u:1ac8afc8a9bb"
|
|
241
|
-
}
|
|
242
|
-
],
|
|
243
|
-
"headerToolbarClassName": "px-1 py-3",
|
|
244
|
-
"source": "${buttons}",
|
|
245
|
-
"id": "u:a5d43b752494"
|
|
246
|
-
}
|
|
247
|
-
],
|
|
248
|
-
"id": "u:bef2e378d96f",
|
|
249
|
-
"api": {
|
|
250
|
-
"method": "get",
|
|
251
|
-
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/actions/options",
|
|
252
|
-
"adaptor": "let data = payload.data;\ndata.buttons_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
|
|
253
|
-
"sendOn": "!!this.object_name",
|
|
254
|
-
"headers": {
|
|
255
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
"className": "col-span-2 m-0",
|
|
259
|
-
"affixFooter": false,
|
|
260
|
-
"messages": {}
|
|
261
|
-
}
|
|
262
|
-
],
|
|
263
|
-
"size": "none",
|
|
264
|
-
"id": "u:100edb4c59d0"
|
|
265
|
-
}
|
|
266
|
-
],
|
|
267
|
-
"id": "u:2a10c03c2218"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
"title": "字段",
|
|
271
|
-
"body": [
|
|
272
|
-
{
|
|
273
|
-
"type": "wrapper",
|
|
274
|
-
"body": [
|
|
275
|
-
{
|
|
276
|
-
"type": "service",
|
|
277
|
-
"body": [
|
|
278
|
-
{
|
|
279
|
-
"name": "fields",
|
|
280
|
-
"required": true,
|
|
281
|
-
"type": "crud",
|
|
282
|
-
"strictMode": true,
|
|
283
|
-
"affixHeader": false,
|
|
284
|
-
"editable": true,
|
|
285
|
-
"addable": false,
|
|
286
|
-
"removable": true,
|
|
287
|
-
"draggable": false,
|
|
288
|
-
"columns": [
|
|
289
|
-
{
|
|
290
|
-
"name": "index",
|
|
291
|
-
"className": "w-10",
|
|
292
|
-
"label": "序号",
|
|
293
|
-
"type": "static",
|
|
294
|
-
"value": "${index + 1}",
|
|
295
|
-
"id": "u:d1c2922699d3"
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
"name": "field_name_label",
|
|
299
|
-
"label": "字段",
|
|
300
|
-
"type": "tpl",
|
|
301
|
-
"tpl": "${fields_options|filter:value:equals:field_name|pick:label}",
|
|
302
|
-
"id": "u:b95c69a1cd84"
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
"name": "is_readonly",
|
|
306
|
-
"label": "只读",
|
|
307
|
-
"quickEdit": {
|
|
308
|
-
"type": "checkbox",
|
|
309
|
-
"tpl": null,
|
|
310
|
-
"className": "m-0",
|
|
311
|
-
"labelClassName": "text-left",
|
|
312
|
-
"mode": "inline",
|
|
313
|
-
"onEvent": {
|
|
314
|
-
"change": {
|
|
315
|
-
"actions": [
|
|
316
|
-
{
|
|
317
|
-
"actionType": "custom",
|
|
318
|
-
"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"
|
|
319
|
-
}
|
|
320
|
-
]
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
"id": "u:8cb44f3db16c",
|
|
324
|
-
"name": "is_readonly"
|
|
325
|
-
},
|
|
326
|
-
"id": "u:5081e6e1af55",
|
|
327
|
-
"placeholder": "-"
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
"name": "is_required",
|
|
331
|
-
"label": "必填",
|
|
332
|
-
"quickEdit": {
|
|
333
|
-
"mode": "inline",
|
|
334
|
-
"type": "checkbox",
|
|
335
|
-
"className": "m-0",
|
|
336
|
-
"onEvent": {
|
|
337
|
-
"change": {
|
|
338
|
-
"actions": [
|
|
339
|
-
{
|
|
340
|
-
"actionType": "custom",
|
|
341
|
-
"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"
|
|
342
|
-
}
|
|
343
|
-
]
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
"tpl": null,
|
|
347
|
-
"labelClassName": "text-left",
|
|
348
|
-
"id": "u:bbd1c15b6504",
|
|
349
|
-
"name": "is_required"
|
|
350
|
-
},
|
|
351
|
-
"id": "u:e54afb5cc05c",
|
|
352
|
-
"placeholder": "-"
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
"name": "group",
|
|
356
|
-
"label": "分组",
|
|
357
|
-
"quickEdit": {
|
|
358
|
-
"type": "select",
|
|
359
|
-
"className": "m-0",
|
|
360
|
-
"source": "${field_groups|pick:group_name}",
|
|
361
|
-
"checkAll": false,
|
|
362
|
-
"selectFirst": false,
|
|
363
|
-
"onEvent": {
|
|
364
|
-
"change": {
|
|
365
|
-
"actions": [
|
|
366
|
-
{
|
|
367
|
-
"actionType": "custom",
|
|
368
|
-
"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"
|
|
369
|
-
}
|
|
370
|
-
]
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
"searchable": true,
|
|
374
|
-
"clearable": true,
|
|
375
|
-
"name": "group",
|
|
376
|
-
"id": "u:f75ddc45d296",
|
|
377
|
-
"multiple": false,
|
|
378
|
-
"mode": "popOver"
|
|
379
|
-
},
|
|
380
|
-
"id": "u:e532b1949676",
|
|
381
|
-
"placeholder": "-"
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
"name": "visible_on",
|
|
385
|
-
"label": "显示条件",
|
|
386
|
-
"quickEdit": {
|
|
387
|
-
"type": "input-text",
|
|
388
|
-
"tpl": "<b><%=data.visible_on%></b>",
|
|
389
|
-
"className": "m-0",
|
|
390
|
-
"labelClassName": "text-left",
|
|
391
|
-
"onEvent": {
|
|
392
|
-
"change": {
|
|
393
|
-
"actions": [
|
|
394
|
-
{
|
|
395
|
-
"actionType": "custom",
|
|
396
|
-
"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"
|
|
397
|
-
}
|
|
398
|
-
]
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
"name": "visible_on",
|
|
402
|
-
"id": "u:624913811ecc",
|
|
403
|
-
"minRows": 3,
|
|
404
|
-
"maxRows": 20,
|
|
405
|
-
"mode": "popOver"
|
|
406
|
-
},
|
|
407
|
-
"breakpoint": "*",
|
|
408
|
-
"id": "u:e3618b8b4c52",
|
|
409
|
-
"placeholder": "-"
|
|
410
|
-
}
|
|
411
|
-
],
|
|
412
|
-
"className": "col-span-2 m-0",
|
|
413
|
-
"labelClassName": "text-left",
|
|
414
|
-
"source": "${fields}",
|
|
415
|
-
"footable": false,
|
|
416
|
-
"headerToolbar": [
|
|
417
|
-
{
|
|
418
|
-
"type": "button",
|
|
419
|
-
"actionType": "dialog",
|
|
420
|
-
"dialog": {
|
|
421
|
-
"title": "设置字段",
|
|
422
|
-
"body": [
|
|
423
|
-
{
|
|
424
|
-
"type": "transfer",
|
|
425
|
-
"name": "picked_fields",
|
|
426
|
-
"sortable": true,
|
|
427
|
-
"source": "${fields_options}",
|
|
428
|
-
"value": "${fields|pick:field_name}",
|
|
429
|
-
"searchable": true,
|
|
430
|
-
"id": "u:502c4ecd81b6"
|
|
431
|
-
}
|
|
432
|
-
],
|
|
433
|
-
"onEvent": {
|
|
434
|
-
"confirm": {
|
|
435
|
-
"actions": [
|
|
436
|
-
{
|
|
437
|
-
"actionType": "custom",
|
|
438
|
-
"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"
|
|
439
|
-
}
|
|
440
|
-
]
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
"type": "dialog",
|
|
444
|
-
"size": "md",
|
|
445
|
-
"id": "u:c405734543e0",
|
|
446
|
-
"closeOnEsc": false,
|
|
447
|
-
"closeOnOutside": false,
|
|
448
|
-
"showCloseButton": true
|
|
449
|
-
},
|
|
450
|
-
"label": "设置字段",
|
|
451
|
-
"id": "u:853b890ab524"
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
"type": "button",
|
|
455
|
-
"actionType": "dialog",
|
|
456
|
-
"dialog": {
|
|
457
|
-
"title": "设置分组",
|
|
458
|
-
"body": [
|
|
459
|
-
{
|
|
460
|
-
"type": "input-table",
|
|
461
|
-
"name": "setting_groups",
|
|
462
|
-
"addable": true,
|
|
463
|
-
"draggable": true,
|
|
464
|
-
"editable": true,
|
|
465
|
-
"columns": [
|
|
466
|
-
{
|
|
467
|
-
"name": "group_name",
|
|
468
|
-
"label": "名称",
|
|
469
|
-
"id": "u:ee2fb813a3e7"
|
|
470
|
-
}
|
|
471
|
-
],
|
|
472
|
-
"value": "${field_groups}",
|
|
473
|
-
"removable": true,
|
|
474
|
-
"id": "u:e9f43ef94d08"
|
|
475
|
-
}
|
|
476
|
-
],
|
|
477
|
-
"onEvent": {
|
|
478
|
-
"confirm": {
|
|
479
|
-
"actions": [
|
|
480
|
-
{
|
|
481
|
-
"actionType": "custom",
|
|
482
|
-
"args": {},
|
|
483
|
-
"componentId": "",
|
|
484
|
-
"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"
|
|
485
|
-
}
|
|
486
|
-
]
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
"type": "dialog",
|
|
490
|
-
"id": "u:e02c8f59216e",
|
|
491
|
-
"closeOnEsc": false,
|
|
492
|
-
"closeOnOutside": false,
|
|
493
|
-
"showCloseButton": true
|
|
494
|
-
},
|
|
495
|
-
"label": "设置分组",
|
|
496
|
-
"id": "u:ec9931ea883c"
|
|
497
|
-
}
|
|
498
|
-
],
|
|
499
|
-
"headerToolbarClassName": "px-1 py-3",
|
|
500
|
-
"id": "u:22121edc42b1"
|
|
501
|
-
}
|
|
502
|
-
],
|
|
503
|
-
"id": "u:ac5b7818b88f",
|
|
504
|
-
"affixFooter": false,
|
|
505
|
-
"api": {
|
|
506
|
-
"method": "get",
|
|
507
|
-
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/layout_options",
|
|
508
|
-
"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",
|
|
509
|
-
"sendOn": "!!this.object_name",
|
|
510
|
-
"data": null,
|
|
511
|
-
"headers": {
|
|
512
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
"className": "col-span-2 m-0",
|
|
516
|
-
"placeholder": "-",
|
|
517
|
-
"onEvent": {
|
|
518
|
-
"fetchInited": {
|
|
519
|
-
"actions": [
|
|
520
|
-
{
|
|
521
|
-
"actionType": "custom",
|
|
522
|
-
"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"
|
|
523
|
-
}
|
|
524
|
-
]
|
|
525
|
-
}
|
|
526
|
-
},
|
|
527
|
-
"messages": {}
|
|
528
|
-
}
|
|
529
|
-
],
|
|
530
|
-
"size": "none",
|
|
531
|
-
"id": "u:100edb4c59d0"
|
|
532
|
-
}
|
|
533
|
-
],
|
|
534
|
-
"id": "u:8b579617d2da"
|
|
535
|
-
},
|
|
536
|
-
{
|
|
537
|
-
"title": "子表",
|
|
538
|
-
"body": [
|
|
539
|
-
{
|
|
540
|
-
"type": "wrapper",
|
|
541
|
-
"body": [
|
|
542
|
-
{
|
|
543
|
-
"type": "service",
|
|
544
|
-
"id": "u:dbadaff47153",
|
|
545
|
-
"api": {
|
|
546
|
-
"method": "get",
|
|
547
|
-
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options",
|
|
548
|
-
"sendOn": "!!this.object_name",
|
|
549
|
-
"adaptor": "let data = payload.data;\ndata.related_lists_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
|
|
550
|
-
"headers": {
|
|
551
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
"className": "col-span-2 m-0",
|
|
555
|
-
"affixFooter": false,
|
|
556
|
-
"body": [
|
|
557
|
-
{
|
|
558
|
-
"name": "related_lists",
|
|
559
|
-
"type": "crud",
|
|
560
|
-
"strictMode": true,
|
|
561
|
-
"affixHeader": false,
|
|
562
|
-
"editable": true,
|
|
563
|
-
"addable": true,
|
|
564
|
-
"removable": true,
|
|
565
|
-
"draggable": false,
|
|
566
|
-
"columns": [
|
|
567
|
-
{
|
|
568
|
-
"name": "index",
|
|
569
|
-
"label": "序号",
|
|
570
|
-
"className": "w-10",
|
|
571
|
-
"type": "static",
|
|
572
|
-
"value": "${index + 1}",
|
|
573
|
-
"id": "u:a2f05dc83cd4"
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
"name": "related_field_fullname_label",
|
|
577
|
-
"label": "子表名称",
|
|
578
|
-
"type": "tpl",
|
|
579
|
-
"tpl": "${related_lists_options|filter:value:equals:related_field_fullname|pick:label}",
|
|
580
|
-
"id": "u:5204fc0fbe1c"
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
"name": "label",
|
|
584
|
-
"label": "显示标题",
|
|
585
|
-
"quickEdit": {
|
|
586
|
-
"type": "input-text",
|
|
587
|
-
"onEvent": {
|
|
588
|
-
"change": {
|
|
589
|
-
"actions": [
|
|
590
|
-
{
|
|
591
|
-
"actionType": "custom",
|
|
592
|
-
"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"
|
|
593
|
-
}
|
|
594
|
-
]
|
|
595
|
-
}
|
|
596
|
-
},
|
|
597
|
-
"labelRemark": "默认为对象名称",
|
|
598
|
-
"className": "m-0",
|
|
599
|
-
"labelClassName": "text-left",
|
|
600
|
-
"id": "u:5b30f2a71830",
|
|
601
|
-
"name": "label"
|
|
602
|
-
},
|
|
603
|
-
"id": "u:1267e4351d66",
|
|
604
|
-
"placeholder": "-"
|
|
605
|
-
},
|
|
606
|
-
{
|
|
607
|
-
"name": "field_names",
|
|
608
|
-
"label": "显示的字段",
|
|
609
|
-
"quickEdit": {
|
|
610
|
-
"type": "transfer-picker",
|
|
611
|
-
"source": {
|
|
612
|
-
"method": "get",
|
|
613
|
-
"url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
|
|
614
|
-
"cache": 60000,
|
|
615
|
-
"headers": {
|
|
616
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
"searchable": true,
|
|
620
|
-
"onEvent": {
|
|
621
|
-
"change": {
|
|
622
|
-
"actions": [
|
|
623
|
-
{
|
|
624
|
-
"actionType": "custom",
|
|
625
|
-
"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"
|
|
626
|
-
}
|
|
627
|
-
]
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
"joinValues": false,
|
|
631
|
-
"extractValue": true,
|
|
632
|
-
"mode": "inline",
|
|
633
|
-
"id": "u:a85f62af394f",
|
|
634
|
-
"name": "field_names"
|
|
635
|
-
},
|
|
636
|
-
"type": "tpl",
|
|
637
|
-
"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%>",
|
|
638
|
-
"id": "u:ce65d4020107",
|
|
639
|
-
"placeholder": "-"
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
"name": "sort_field_name",
|
|
643
|
-
"label": "排序字段",
|
|
644
|
-
"quickEdit": {
|
|
645
|
-
"type": "transfer-picker",
|
|
646
|
-
"joinValues": false,
|
|
647
|
-
"extractValue": true,
|
|
648
|
-
"onEvent": {
|
|
649
|
-
"change": {
|
|
650
|
-
"actions": [
|
|
651
|
-
{
|
|
652
|
-
"actionType": "custom",
|
|
653
|
-
"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"
|
|
654
|
-
}
|
|
655
|
-
]
|
|
656
|
-
}
|
|
657
|
-
},
|
|
658
|
-
"source": {
|
|
659
|
-
"method": "get",
|
|
660
|
-
"url": "/service/api/amis-metadata-objects/objects/${related_field_fullname|split:.|first}/fields/options",
|
|
661
|
-
"cache": 60000,
|
|
662
|
-
"headers": {
|
|
663
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
664
|
-
}
|
|
665
|
-
},
|
|
666
|
-
"searchable": true,
|
|
667
|
-
"name": "sort_field_name",
|
|
668
|
-
"id": "u:c1e3daddf92c",
|
|
669
|
-
"mode": "inline"
|
|
670
|
-
},
|
|
671
|
-
"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%>",
|
|
672
|
-
"id": "u:3dbee6a855c4"
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
"name": "sort_order",
|
|
676
|
-
"label": "排序方式",
|
|
677
|
-
"quickEdit": {
|
|
678
|
-
"className": "m-0",
|
|
679
|
-
"labelClassName": "text-left",
|
|
680
|
-
"onEvent": {
|
|
681
|
-
"change": {
|
|
682
|
-
"actions": [
|
|
683
|
-
{
|
|
684
|
-
"actionType": "custom",
|
|
685
|
-
"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"
|
|
686
|
-
}
|
|
687
|
-
]
|
|
688
|
-
}
|
|
689
|
-
},
|
|
690
|
-
"joinValues": false,
|
|
691
|
-
"extractValue": true,
|
|
692
|
-
"clearable": true,
|
|
693
|
-
"labelField": "label",
|
|
694
|
-
"valueField": "value",
|
|
695
|
-
"mode_": "inline",
|
|
696
|
-
"source": "${sort_order_options}",
|
|
697
|
-
"type": "select",
|
|
698
|
-
"name": "sort_order",
|
|
699
|
-
"id": "u:951e05ace916",
|
|
700
|
-
"multiple": false
|
|
701
|
-
},
|
|
702
|
-
"breakpoint": "*",
|
|
703
|
-
"type": "tpl",
|
|
704
|
-
"tpl": "${sort_order_options|filter:value:equals:sort_order|pick:label}",
|
|
705
|
-
"id": "u:13cb3d304615"
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
"name": "filters",
|
|
709
|
-
"label": "过滤规则",
|
|
710
|
-
"quickEdit": {
|
|
711
|
-
"type": "editor",
|
|
712
|
-
"language": "javascript",
|
|
713
|
-
"description": "函数签名:(filters, data) => 自定义过滤条件, 数据在 data 中,修改后返回 自定义过滤条件",
|
|
714
|
-
"tpl": "<b><%=data.filters%></b>",
|
|
715
|
-
"className": "col-span-2 m-0",
|
|
716
|
-
"labelClassName": "text-left",
|
|
717
|
-
"onEvent": {
|
|
718
|
-
"change": {
|
|
719
|
-
"actions": [
|
|
720
|
-
{
|
|
721
|
-
"actionType": "custom",
|
|
722
|
-
"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"
|
|
723
|
-
}
|
|
724
|
-
]
|
|
725
|
-
}
|
|
726
|
-
},
|
|
727
|
-
"name": "filters",
|
|
728
|
-
"id": "u:0436e626f06a",
|
|
729
|
-
"minRows": 3,
|
|
730
|
-
"maxRows": 20
|
|
731
|
-
},
|
|
732
|
-
"breakpoint": "*",
|
|
733
|
-
"id": "u:e4c367804b67"
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
"name": "visible_on",
|
|
737
|
-
"label": "显示条件",
|
|
738
|
-
"quickEdit": {
|
|
739
|
-
"type": "input-text",
|
|
740
|
-
"className": "m-0",
|
|
741
|
-
"labelClassName": "text-left",
|
|
742
|
-
"onEvent": {
|
|
743
|
-
"change": {
|
|
744
|
-
"actions": [
|
|
745
|
-
{
|
|
746
|
-
"actionType": "custom",
|
|
747
|
-
"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"
|
|
748
|
-
}
|
|
749
|
-
]
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
"tpl": "<b><%=data.visible_on%></b>",
|
|
753
|
-
"name": "visible_on",
|
|
754
|
-
"id": "u:3106cc0f9cc7",
|
|
755
|
-
"minRows": 3,
|
|
756
|
-
"maxRows": 20
|
|
757
|
-
},
|
|
758
|
-
"breakpoint": "*",
|
|
759
|
-
"id": "u:1e1dc52d7c33"
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
"name": "page_size",
|
|
763
|
-
"label": "每页显示数量",
|
|
764
|
-
"quickEdit": {
|
|
765
|
-
"type": "input-number",
|
|
766
|
-
"precision": 0,
|
|
767
|
-
"className": "m-0",
|
|
768
|
-
"labelClassName": "text-number",
|
|
769
|
-
"onEvent": {
|
|
770
|
-
"change": {
|
|
771
|
-
"actions": [
|
|
772
|
-
{
|
|
773
|
-
"actionType": "custom",
|
|
774
|
-
"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"
|
|
775
|
-
}
|
|
776
|
-
]
|
|
777
|
-
}
|
|
778
|
-
},
|
|
779
|
-
"name": "page_size",
|
|
780
|
-
"id": "u:0e261f265511"
|
|
781
|
-
},
|
|
782
|
-
"breakpoint": "*",
|
|
783
|
-
"id": "u:f9bbd9567bbd"
|
|
784
|
-
}
|
|
785
|
-
],
|
|
786
|
-
"className": "col-span-2 m-0",
|
|
787
|
-
"labelClassName": "text-left",
|
|
788
|
-
"headerToolbar": [
|
|
789
|
-
{
|
|
790
|
-
"type": "button",
|
|
791
|
-
"actionType": "dialog",
|
|
792
|
-
"dialog": {
|
|
793
|
-
"title": "设置子表",
|
|
794
|
-
"body": [
|
|
795
|
-
{
|
|
796
|
-
"type": "transfer",
|
|
797
|
-
"name": "picked_related_lists",
|
|
798
|
-
"sortable": true,
|
|
799
|
-
"source": "${related_lists_options}",
|
|
800
|
-
"value": "${related_lists|pick:related_field_fullname}",
|
|
801
|
-
"searchable": true,
|
|
802
|
-
"id": "u:ab6a6c9c8677"
|
|
803
|
-
}
|
|
804
|
-
],
|
|
805
|
-
"onEvent": {
|
|
806
|
-
"confirm": {
|
|
807
|
-
"actions": [
|
|
808
|
-
{
|
|
809
|
-
"actionType": "custom",
|
|
810
|
-
"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"
|
|
811
|
-
}
|
|
812
|
-
]
|
|
813
|
-
}
|
|
814
|
-
},
|
|
815
|
-
"type": "dialog",
|
|
816
|
-
"size": "md",
|
|
817
|
-
"id": "u:3663990f226a",
|
|
818
|
-
"closeOnEsc": false,
|
|
819
|
-
"closeOnOutside": false,
|
|
820
|
-
"showCloseButton": true
|
|
821
|
-
},
|
|
822
|
-
"label": "设置子表",
|
|
823
|
-
"id": "u:b9a5d3b611d7"
|
|
824
|
-
}
|
|
825
|
-
],
|
|
826
|
-
"headerToolbarClassName": "px-1 py-3",
|
|
827
|
-
"source": "${related_lists}",
|
|
828
|
-
"footable": false,
|
|
829
|
-
"columnsTogglable": true,
|
|
830
|
-
"messages": {},
|
|
831
|
-
"tableClassName": "min-w-max",
|
|
832
|
-
"id": "u:95aea10231d3"
|
|
833
|
-
}
|
|
834
|
-
],
|
|
835
|
-
"messages": {}
|
|
836
|
-
}
|
|
837
|
-
],
|
|
838
|
-
"size": "none",
|
|
839
|
-
"id": "u:100edb4c59d0"
|
|
840
|
-
}
|
|
841
|
-
],
|
|
842
|
-
"id": "u:e09b5c1a4751"
|
|
843
|
-
}
|
|
844
|
-
],
|
|
845
|
-
"id": "u:33778a88db62"
|
|
846
|
-
}
|
|
847
|
-
],
|
|
848
|
-
"panelClassName": "m-0 -mt-3",
|
|
849
|
-
"bodyClassName": "p-4",
|
|
850
|
-
"actions": [],
|
|
851
|
-
"actionsClassName": "p-sm b-t b-light text-center",
|
|
852
|
-
"className": "steedos-amis-form",
|
|
853
|
-
"checkAll": false,
|
|
854
|
-
"id": "object-layout-form",
|
|
855
|
-
"onEvent": {
|
|
856
|
-
"inited": {
|
|
857
|
-
"actions": [
|
|
858
|
-
{
|
|
859
|
-
"actionType": "custom",
|
|
860
|
-
"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: input.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"
|
|
861
|
-
},
|
|
862
|
-
{
|
|
863
|
-
"actionType": "custom",
|
|
864
|
-
"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: input.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"
|
|
865
|
-
},
|
|
866
|
-
{
|
|
867
|
-
"actionType": "custom",
|
|
868
|
-
"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: input.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"
|
|
869
|
-
}
|
|
870
|
-
]
|
|
871
|
-
},
|
|
872
|
-
"submitSucc": {
|
|
873
|
-
"weight": 0,
|
|
874
|
-
"actions": [
|
|
875
|
-
{
|
|
876
|
-
"actionType": "broadcast",
|
|
877
|
-
"args": {
|
|
878
|
-
"eventName": "@data.changed.object_layouts"
|
|
879
|
-
},
|
|
880
|
-
"data": {
|
|
881
|
-
"objectName": "object_layouts"
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
]
|
|
885
|
-
}
|
|
886
|
-
},
|
|
887
|
-
"data": {
|
|
888
|
-
"sort_order_options": [
|
|
889
|
-
{
|
|
890
|
-
"label": "正序",
|
|
891
|
-
"value": "asc"
|
|
892
|
-
},
|
|
893
|
-
{
|
|
894
|
-
"label": "倒序",
|
|
895
|
-
"value": "desc"
|
|
896
|
-
}
|
|
897
|
-
]
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
],
|
|
901
|
-
"regions": [
|
|
902
|
-
"body"
|
|
903
|
-
],
|
|
904
|
-
"data": {
|
|
905
|
-
"objectName": "object_layouts"
|
|
906
|
-
},
|
|
907
|
-
"bodyClassName": "p-0",
|
|
908
|
-
"name": "page_edit_${recordId}",
|
|
909
|
-
"initApi": null,
|
|
910
|
-
"initFetch": null,
|
|
911
|
-
"className": "page-form-object_layouts",
|
|
912
|
-
"id": "u:3b0de7e88def"
|
|
913
|
-
}
|