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