@steedos/service-plugin-amis 2.4.0-beta.4 → 2.4.0-beta.41
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 +65 -33
- package/main/default/pages/action_field_updates.page.amis.json +266 -0
- package/main/default/pages/action_field_updates.page.yml +12 -0
- package/main/default/pages/apps_form.page.amis.json +22 -3
- package/main/default/pages/apps_form.page.yml +0 -2
- package/main/default/pages/generate_object_tabs.page.amis.json +3 -2
- package/main/default/pages/listview_form.page.amis.json +38 -4
- package/main/default/pages/object_layouts.page.amis.json +14 -27
- package/main/default/services/metadata/objects.service.js +2 -1
- package/package.json +6 -3
- package/public/amis/amis.css +0 -18
- package/public/tailwind/tailwind-steedos.css +154 -111
- package/public/translations/amis/zh-CN.json +2 -2
- package/tailwind.config.js +1 -1
- package/main/default/client/load.assets.client.js +0 -26
- package/main/default/client/style.client.js +0 -24
- package/main/default/client/tailwind.client.js +0 -35
- package/main/default/objects/pages/fields/render_engine.field.yml +0 -11
- package/main/default/objects/pages/pages.object.yml +0 -2
|
@@ -6,23 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
; (function () {
|
|
8
8
|
|
|
9
|
-
const loadCss = (href)=>{
|
|
10
|
-
try {
|
|
11
|
-
// 加载Amis css
|
|
12
|
-
let amisStyle = document.createElement("link");
|
|
13
|
-
amisStyle.setAttribute("rel", "stylesheet");
|
|
14
|
-
amisStyle.setAttribute("type", "text/css");
|
|
15
|
-
amisStyle.setAttribute("href", href);
|
|
16
|
-
document.getElementsByTagName("head")[0].appendChild(amisStyle);
|
|
17
|
-
} catch (error) {
|
|
18
|
-
console.error(error)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
// loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/sdk.css"))
|
|
22
|
-
loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/helper.css"))
|
|
23
|
-
loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/iconfont.css"))
|
|
24
|
-
loadCss(Steedos.absoluteUrl("/amis/amis.css"))
|
|
25
|
-
|
|
26
9
|
try {
|
|
27
10
|
window['attrAccept'] = function (file, acceptedFiles) {
|
|
28
11
|
if (file && acceptedFiles) {
|
|
@@ -48,9 +31,9 @@
|
|
|
48
31
|
}
|
|
49
32
|
|
|
50
33
|
// 加载Amis SDK: 如果直接放到body中会导致 meteor 编译后的 cordova.js 加载报错
|
|
51
|
-
let amisSDKScript = document.createElement("script");
|
|
52
|
-
amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com/amis/sdk/sdk.js'));
|
|
53
|
-
document.getElementsByTagName("head")[0].appendChild(amisSDKScript);
|
|
34
|
+
// let amisSDKScript = document.createElement("script");
|
|
35
|
+
// amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com/amis/sdk/sdk.js'));
|
|
36
|
+
// document.getElementsByTagName("head")[0].appendChild(amisSDKScript);
|
|
54
37
|
} catch (error) {
|
|
55
38
|
console.error(error)
|
|
56
39
|
};
|
|
@@ -94,7 +77,7 @@
|
|
|
94
77
|
if(comp.componentType === 'amisSchema'){
|
|
95
78
|
let amisReact = amisRequire('react');
|
|
96
79
|
AmisWrapper = function(props){
|
|
97
|
-
const { body, render } = props
|
|
80
|
+
const { $schema, body, render } = props
|
|
98
81
|
const [schema, setSchema] = amisReact.useState(null);
|
|
99
82
|
amisReact.useEffect(()=>{
|
|
100
83
|
const result = Component.class(props);
|
|
@@ -105,7 +88,7 @@
|
|
|
105
88
|
}else{
|
|
106
89
|
setSchema(result)
|
|
107
90
|
}
|
|
108
|
-
}, [])
|
|
91
|
+
}, [JSON.stringify($schema)])
|
|
109
92
|
return amisReact.createElement(amisReact.Fragment, null, amisReact.createElement(amisReact.Fragment, null, schema && render ? render('body', schema) : ''), amisReact.createElement(amisReact.Fragment, null, render ? render('body', body) : ''));
|
|
110
93
|
}
|
|
111
94
|
}
|
|
@@ -203,7 +186,7 @@
|
|
|
203
186
|
console.error(`error`, error)
|
|
204
187
|
}
|
|
205
188
|
}
|
|
206
|
-
|
|
189
|
+
AmisEnv = {
|
|
207
190
|
// getModalContainer: (props)=>{
|
|
208
191
|
// let div = document.querySelector("#amisModalContainer");
|
|
209
192
|
// if(!div){
|
|
@@ -223,7 +206,7 @@
|
|
|
223
206
|
to = normalizeLink(to);
|
|
224
207
|
|
|
225
208
|
if (action && action.actionType === 'url') {
|
|
226
|
-
action.blank ===
|
|
209
|
+
action.blank === true ? window.open(to): (window.location.href = to);
|
|
227
210
|
return;
|
|
228
211
|
}
|
|
229
212
|
|
|
@@ -248,10 +231,13 @@
|
|
|
248
231
|
const schema = props.schema;
|
|
249
232
|
const data = props.data;
|
|
250
233
|
const name = props.name;
|
|
251
|
-
|
|
252
|
-
if(SteedosUI.refs[
|
|
253
|
-
if(SteedosUI.refs[
|
|
254
|
-
|
|
234
|
+
const refName = schema.name || schema.id;
|
|
235
|
+
if(SteedosUI.refs[refName]){
|
|
236
|
+
if(SteedosUI.refs[refName].unmount){
|
|
237
|
+
try {
|
|
238
|
+
SteedosUI.refs[refName].unmount()
|
|
239
|
+
} catch (Exception) {
|
|
240
|
+
}
|
|
255
241
|
}else{
|
|
256
242
|
console.log(`not find amis scope unmount`)
|
|
257
243
|
}
|
|
@@ -279,19 +265,65 @@
|
|
|
279
265
|
return scoped = ref
|
|
280
266
|
}
|
|
281
267
|
|
|
282
|
-
|
|
268
|
+
|
|
269
|
+
let amisReact = amisRequire('react');
|
|
270
|
+
|
|
271
|
+
amisReact.useEffect(()=>{
|
|
283
272
|
const amisScope = amisRequire('amis/embed').embed(`.steedos-amis-render-scope-${name}`,schema, {data, name, locale: getAmisLng()}, Object.assign({}, AmisEnv, env))
|
|
284
|
-
|
|
285
|
-
|
|
273
|
+
const refName = schema.name || schema.id;
|
|
274
|
+
if(window.SteedosUI && refName){
|
|
275
|
+
SteedosUI.refs[refName] = amisScope;
|
|
286
276
|
}
|
|
287
277
|
}, [])
|
|
288
|
-
return
|
|
278
|
+
return amisReact.createElement("div", {
|
|
289
279
|
className: "amis-scope"
|
|
290
|
-
},
|
|
280
|
+
}, amisReact.createElement("div", {
|
|
291
281
|
className: `steedos-amis-render-scope-${name}`
|
|
292
282
|
}));
|
|
293
283
|
};
|
|
294
284
|
|
|
285
|
+
window.renderAmis = function (root, schema, data, env) {
|
|
286
|
+
const refName = schema.name || schema.id;
|
|
287
|
+
if(SteedosUI.refs[refName]){
|
|
288
|
+
if(SteedosUI.refs[refName].unmount){
|
|
289
|
+
try {
|
|
290
|
+
SteedosUI.refs[refName].unmount()
|
|
291
|
+
} catch (Exception) {
|
|
292
|
+
}
|
|
293
|
+
}else{
|
|
294
|
+
console.log(`not find amis scope unmount`)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// if(props.pageType === 'form'){
|
|
299
|
+
// env = Object.assign({
|
|
300
|
+
// getModalContainer: ()=>{
|
|
301
|
+
// return document.querySelector('.amis-scope');
|
|
302
|
+
// }
|
|
303
|
+
// }, env);
|
|
304
|
+
// }
|
|
305
|
+
schema.scopeRef = (ref) => {
|
|
306
|
+
try {
|
|
307
|
+
if(!window.amisScopes){
|
|
308
|
+
window.amisScopes = {};
|
|
309
|
+
}
|
|
310
|
+
if(name){
|
|
311
|
+
window.amisScopes[name] = ref;
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
console.error('error', error)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return scoped = ref
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
const amisScope = amisRequire('amis/embed').embed(root, schema, {data, name, locale: getAmisLng()}, Object.assign({}, AmisEnv, env))
|
|
322
|
+
if(window.SteedosUI && refName){
|
|
323
|
+
SteedosUI.refs[refName] = amisScope;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
295
327
|
const initMonaco = ()=>{
|
|
296
328
|
|
|
297
329
|
// const { detect } = require('detect-browser');
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "page",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "service",
|
|
6
|
+
"className": "p-0",
|
|
7
|
+
"name": "page_edit_${recordId}",
|
|
8
|
+
"api": {
|
|
9
|
+
"method": "post",
|
|
10
|
+
"url": "${context.rootUrl}/graphql",
|
|
11
|
+
"adaptor": "\n if(payload.data.data){\n var data = payload.data.data[0];\n if(data){\n \n \n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n };\n payload.data = data;\n delete payload.extensions;\n }\n return payload;\n ",
|
|
12
|
+
"data": {
|
|
13
|
+
"query": "{data:action_field_updates(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,label,object_name,target_object,field_name,operation,formula,literal_value,description,reevaluate_on_change,undirect,created,created_by,modified,modified_by,_display:_ui{object_name,target_object,field_name,operation,reevaluate_on_change,undirect,created,created_by,modified,modified_by}, \n recordPermissions: _permissions{\n allowCreate,\n allowCreateFiles,\n allowDelete,\n allowDeleteFiles,\n allowEdit,\n allowEditFiles,\n allowRead,\n allowReadFiles,\n disabled_actions,\n disabled_list_views,\n field_permissions,\n modifyAllFiles,\n modifyAllRecords,\n modifyAssignCompanysRecords,\n modifyCompanyRecords,\n uneditable_fields,\n unreadable_fields,\n unrelated_objects,\n viewAllFiles,\n viewAllRecords,\n viewAssignCompanysRecords,\n viewCompanyRecords,\n }\n }}"
|
|
14
|
+
},
|
|
15
|
+
"headers": {
|
|
16
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
17
|
+
},
|
|
18
|
+
"sendOn": "!!this.recordId",
|
|
19
|
+
"cache": 100
|
|
20
|
+
},
|
|
21
|
+
"initFetch": null,
|
|
22
|
+
"body": [
|
|
23
|
+
{
|
|
24
|
+
"type": "form",
|
|
25
|
+
"title": "",
|
|
26
|
+
"body": [
|
|
27
|
+
{
|
|
28
|
+
"type": "fieldSet",
|
|
29
|
+
"id": "u:3ce1d050bcac",
|
|
30
|
+
"title": "通用",
|
|
31
|
+
"collapsable": true,
|
|
32
|
+
"body": [
|
|
33
|
+
{
|
|
34
|
+
"name": "name",
|
|
35
|
+
"label": "API 名称",
|
|
36
|
+
"required": true,
|
|
37
|
+
"type": "input-text",
|
|
38
|
+
"className": "m-1",
|
|
39
|
+
"labelClassName": "text-left",
|
|
40
|
+
"clearValueOnHidden": true,
|
|
41
|
+
"fieldName": "name",
|
|
42
|
+
"id": "u:8ebca359c714"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "label",
|
|
46
|
+
"label": "显示名称",
|
|
47
|
+
"required": true,
|
|
48
|
+
"type": "input-text",
|
|
49
|
+
"className": "m-1",
|
|
50
|
+
"labelClassName": "text-left",
|
|
51
|
+
"clearValueOnHidden": true,
|
|
52
|
+
"fieldName": "label",
|
|
53
|
+
"id": "u:124c34a09c5c"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "object_name",
|
|
57
|
+
"label": "对象",
|
|
58
|
+
"required": false,
|
|
59
|
+
"type": "select",
|
|
60
|
+
"joinValues": false,
|
|
61
|
+
"extractValue": true,
|
|
62
|
+
"searchable": true,
|
|
63
|
+
"source": {
|
|
64
|
+
"method": "post",
|
|
65
|
+
"url": "${context.rootUrl}/graphql",
|
|
66
|
+
"data": {
|
|
67
|
+
"orderBy": "${orderBy}",
|
|
68
|
+
"orderDir": "${orderDir}",
|
|
69
|
+
"pageNo": "${page}",
|
|
70
|
+
"pageSize": "${perPage}",
|
|
71
|
+
"query": "{options:objects(filters: {__filters}, top: {__top}, sort: \"{__sort}\"){_id label:label value:name},count:objects__count(filters:{__filters}),defaultValueOptions:objects(filters:{__options_filters}){_id label:label value:name}}",
|
|
72
|
+
"$term": "$term",
|
|
73
|
+
"$value": "$object_name",
|
|
74
|
+
"$": "$$",
|
|
75
|
+
"rfield": "${object_name}"
|
|
76
|
+
},
|
|
77
|
+
"headers": {
|
|
78
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
79
|
+
},
|
|
80
|
+
"adaptor": "\n const data = payload.data;\n var defaultValueOptions = data.defaultValueOptions;\n // 字段值下拉选项合并到options中\n data.options = _.unionWith(defaultValueOptions, data.options, function(a,b){\n return a[\"value\"]=== b[\"value\"];\n });\n delete data.defaultValueOptions;\n payload.data.options = data.options;\n return payload;\n ",
|
|
81
|
+
"requestAdaptor": "\n var filters = [];\n var top = 10;\n if(api.data.$term){\n filters = [[\"label\", \"contains\", api.data.$term]];\n }\n // else if(api.data.$value){\n // filters = [[\"_id\", \"=\", api.data.$value]];\n // }\n\n var fieldFilters = undefined;\n if(fieldFilters && fieldFilters.length){\n filters.push(fieldFilters);\n }\n\n const filtersFunction = undefined;\n\n if(filtersFunction){\n const _filters = filtersFunction(filters, api.data.$);\n if(_filters && _filters.length > 0){\n filters.push(_filters);\n }\n }\n var sort = \"\";\n api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', top).replace('{__sort}', sort.trim());\n\n var defaultValue = api.data.$value;\n var optionsFiltersOp = \"=\";\n var optionsFilters = [[\"name\", optionsFiltersOp, []]];\n if (defaultValue && !api.data.$term) { \n // 字段值单独请求,没值的时候在请求中返回空\n optionsFilters = [[\"name\", optionsFiltersOp, defaultValue]];\n }\n api.data.query = api.data.query.replace(/{__options_filters}/g, JSON.stringify(optionsFilters));\n return api;\n "
|
|
82
|
+
},
|
|
83
|
+
"className": "m-1",
|
|
84
|
+
"labelClassName": "text-left",
|
|
85
|
+
"clearValueOnHidden": true,
|
|
86
|
+
"fieldName": "object_name",
|
|
87
|
+
"id": "u:0f2e40f882e2"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "target_object",
|
|
91
|
+
"label": "要更新的对象",
|
|
92
|
+
"required": false,
|
|
93
|
+
"type": "select",
|
|
94
|
+
"joinValues": false,
|
|
95
|
+
"extractValue": true,
|
|
96
|
+
"searchable": true,
|
|
97
|
+
"source": {
|
|
98
|
+
"method": "get",
|
|
99
|
+
"url": "${context.rootUrl}/service/api/action_field_updates/target_object/options?objectName=${object_name}"
|
|
100
|
+
},
|
|
101
|
+
"className": "m-1",
|
|
102
|
+
"labelClassName": "text-left",
|
|
103
|
+
"clearValueOnHidden": true,
|
|
104
|
+
"fieldName": "target_object",
|
|
105
|
+
"id": "u:dd1c95753238"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "field_name",
|
|
109
|
+
"label": "要更新的字段",
|
|
110
|
+
"required": false,
|
|
111
|
+
"type": "select",
|
|
112
|
+
"joinValues": false,
|
|
113
|
+
"extractValue": true,
|
|
114
|
+
"searchable": true,
|
|
115
|
+
"source": {
|
|
116
|
+
"method": "get",
|
|
117
|
+
"url": "${context.rootUrl}/service/api/action_field_updates/field_name/options?objectName=${object_name}&targetObject=${target_object}"
|
|
118
|
+
},
|
|
119
|
+
"className": "m-1",
|
|
120
|
+
"labelClassName": "text-left",
|
|
121
|
+
"clearValueOnHidden": true,
|
|
122
|
+
"fieldName": "field_name",
|
|
123
|
+
"id": "u:204fadb7cef0"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "operation",
|
|
127
|
+
"label": "新字段值类型",
|
|
128
|
+
"required": false,
|
|
129
|
+
"type": "select",
|
|
130
|
+
"joinValues": false,
|
|
131
|
+
"extractValue": true,
|
|
132
|
+
"source": {
|
|
133
|
+
"method": "get",
|
|
134
|
+
"url": "${context.rootUrl}/service/api/action_field_updates/operation/options?objectName=${object_name}&targetObject=${target_object}&fieldName=${field_name}"
|
|
135
|
+
},
|
|
136
|
+
"className": "m-1",
|
|
137
|
+
"labelClassName": "text-left",
|
|
138
|
+
"clearValueOnHidden": true,
|
|
139
|
+
"fieldName": "operation",
|
|
140
|
+
"id": "u:627e520855b5",
|
|
141
|
+
"multiple": false
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "formula",
|
|
145
|
+
"label": "公式",
|
|
146
|
+
"required": false,
|
|
147
|
+
"type": "textarea",
|
|
148
|
+
"tpl": "<b><%=data.formula%></b>",
|
|
149
|
+
"className": "col-span-2 m-1",
|
|
150
|
+
"labelClassName": "text-left",
|
|
151
|
+
"clearValueOnHidden": true,
|
|
152
|
+
"fieldName": "formula",
|
|
153
|
+
"id": "u:20766a86a9f4",
|
|
154
|
+
"hiddenOn": "this.operation != 'formula'"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": "service",
|
|
158
|
+
"id": "u:d201a629c160",
|
|
159
|
+
"body": [],
|
|
160
|
+
"messages": {},
|
|
161
|
+
"schemaApi": {
|
|
162
|
+
"method": "get",
|
|
163
|
+
"url": "${context.rootUrl}/service/api/action_field_updates/literal_value/options?objectName=${object_name}&targetObject=${target_object}&fieldName=${field_name}&operation=${operation}",
|
|
164
|
+
"data": {
|
|
165
|
+
"&": "$$"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "description",
|
|
171
|
+
"label": "描述",
|
|
172
|
+
"required": false,
|
|
173
|
+
"type": "textarea",
|
|
174
|
+
"tpl": "<b><%=data.description%></b>",
|
|
175
|
+
"className": "col-span-2 m-1",
|
|
176
|
+
"labelClassName": "text-left",
|
|
177
|
+
"clearValueOnHidden": true,
|
|
178
|
+
"fieldName": "description",
|
|
179
|
+
"id": "u:16a7ebd835a6"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "reevaluate_on_change",
|
|
183
|
+
"label": "字段更改后重新评估工作流规则",
|
|
184
|
+
"required": false,
|
|
185
|
+
"type": "checkbox",
|
|
186
|
+
"tpl": null,
|
|
187
|
+
"className": "m-1",
|
|
188
|
+
"labelClassName": "text-left",
|
|
189
|
+
"clearValueOnHidden": true,
|
|
190
|
+
"fieldName": "reevaluate_on_change",
|
|
191
|
+
"id": "u:b9baf683b6b0"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "undirect",
|
|
195
|
+
"label": "触发对象触发器、工作流规则、字段验证规则",
|
|
196
|
+
"required": false,
|
|
197
|
+
"type": "checkbox",
|
|
198
|
+
"tpl": null,
|
|
199
|
+
"className": "m-1",
|
|
200
|
+
"labelClassName": "text-left",
|
|
201
|
+
"clearValueOnHidden": true,
|
|
202
|
+
"fieldName": "undirect",
|
|
203
|
+
"id": "u:b86f699bbe4f"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"id": "u:f57077c2a95f",
|
|
209
|
+
"mode": "horizontal",
|
|
210
|
+
"persistData": false,
|
|
211
|
+
"promptPageLeave": true,
|
|
212
|
+
"name": "form_edit_${recordId}",
|
|
213
|
+
"debug": false,
|
|
214
|
+
"submitText": "",
|
|
215
|
+
"api": {
|
|
216
|
+
"method": "post",
|
|
217
|
+
"url": "${context.rootUrl}/graphql",
|
|
218
|
+
"data": {
|
|
219
|
+
"objectName": "${objectName}",
|
|
220
|
+
"$": "$$",
|
|
221
|
+
"recordId": "${recordId}",
|
|
222
|
+
"modalName": "${modalName}"
|
|
223
|
+
},
|
|
224
|
+
"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.created;\r\ndelete formData.created_by;\r\ndelete formData.modified;\r\ndelete formData.modified_by;\n \n \n let query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\n if(formData.recordId && formData.recordId !='new'){\n query = `mutation{record: ${objectName}__update(id: \"${formData._id}\", 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 ",
|
|
225
|
+
"responseData": {
|
|
226
|
+
"recordId": "${record._id}"
|
|
227
|
+
},
|
|
228
|
+
"adaptor": "\n if(payload.errors){\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n }\n return payload;\n ",
|
|
229
|
+
"headers": {
|
|
230
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"initFetch": true,
|
|
234
|
+
"panelClassName": "m-0 sm:rounded-lg shadow-none",
|
|
235
|
+
"bodyClassName": "p-0",
|
|
236
|
+
"className": "steedos-amis-form",
|
|
237
|
+
"onEvent": {
|
|
238
|
+
"submitSucc": {
|
|
239
|
+
"weight": 0,
|
|
240
|
+
"actions": [
|
|
241
|
+
{
|
|
242
|
+
"componentId": "listview_action_field_updates",
|
|
243
|
+
"actionType": "reload",
|
|
244
|
+
"expression": "!!listViewId"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"actionType": "custom",
|
|
248
|
+
"script": "\n const { recordId, listViewId } = context.props.data;\n const data = event.data;\n const appId = data.appId;\n const objectName = data.objectName;\n // 在记录详细界面时isRecordDetail为true\n // TODO: isRecordDetail这个判断需要优化\n const isRecordDetail = data._isRelated;\n if(recordId){\n // 编辑记录时,刷新主表单\n doAction({\n componentId: `detail_${recordId}`,\n actionType: \"reload\",\n expression: `!${listViewId}`\n });\n }\n else if(!isRecordDetail){\n // 在列表视图界面新建记录时跳转到详细页面\n const jumpTo = event.context.env && event.context.env.jumpTo;\n if(jumpTo){\n const newRecordId = data.result.data?.recordId;\n jumpTo(\"/app/\" + appId + \"/\" + objectName + \"/view/\" + newRecordId);\n }\n }\n "
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
"initApi": null
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
"data": {
|
|
259
|
+
"objectName": "action_field_updates",
|
|
260
|
+
"context": {}
|
|
261
|
+
},
|
|
262
|
+
"regions": [
|
|
263
|
+
"body"
|
|
264
|
+
],
|
|
265
|
+
"bodyClassName": ""
|
|
266
|
+
}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"sendOn": "!!this.recordId",
|
|
34
34
|
"adaptor": "var data = payload.data.data[0];\nif(data){\n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n};\nif (data.tab_items && !_.isArray(data.tab_items)) {\n // 数据库中存储的是对象格式而不是数组,转换为数组用于界面显示\n let arrTabItems = [];\n _.each(data.tab_items, function (n, k) {\n n.tab_name = k;\n delete n.index;\n arrTabItems.push(n);\n });\n data.tab_items = arrTabItems;\n}\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
|
|
35
35
|
"data": {
|
|
36
|
-
"query": "{data:apps(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,code,icon_slds,visible,description,tabs,tab_items,tab_groups,objects,mobile_objects,is_creator,mobile,sort,url,is_use_ie,is_use_iframe,is_new_window,on_click,auth_name,secret,is_system,from_code_id,instance_state,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},_display{visible,is_creator,mobile,is_use_ie,is_use_iframe,is_new_window,is_system,instance_state,created,modified}}}"
|
|
36
|
+
"query": "{data:apps(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,code,icon_slds,visible, showSidebar, description,tabs,tab_items,tab_groups,objects,mobile_objects,is_creator,mobile,sort,url,is_use_ie,is_use_iframe,is_new_window,on_click,auth_name,secret,is_system,from_code_id,instance_state,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},_display{visible,is_creator,mobile,is_use_ie,is_use_iframe,is_new_window,is_system,instance_state,created,modified}}}"
|
|
37
37
|
},
|
|
38
38
|
"headers": {
|
|
39
39
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -157,6 +157,15 @@
|
|
|
157
157
|
"labelClassName": "text-left",
|
|
158
158
|
"id": "u:07a8a4c5f875"
|
|
159
159
|
},
|
|
160
|
+
{
|
|
161
|
+
"name": "showSidebar",
|
|
162
|
+
"label": "菜单显示在左侧",
|
|
163
|
+
"type": "checkbox",
|
|
164
|
+
"tpl": null,
|
|
165
|
+
"className": "m-0",
|
|
166
|
+
"labelClassName": "text-left",
|
|
167
|
+
"id": "u:07a8a4c5f877"
|
|
168
|
+
},
|
|
160
169
|
{
|
|
161
170
|
"name": "description",
|
|
162
171
|
"label": "描述",
|
|
@@ -356,6 +365,7 @@
|
|
|
356
365
|
}
|
|
357
366
|
}
|
|
358
367
|
],
|
|
368
|
+
"headerToolbarClassName": "px-1 py-3",
|
|
359
369
|
"id": "crud_tab_items",
|
|
360
370
|
"perPageAvailable": [
|
|
361
371
|
10
|
|
@@ -381,7 +391,7 @@
|
|
|
381
391
|
{
|
|
382
392
|
"name": "url",
|
|
383
393
|
"label": "外部链接",
|
|
384
|
-
"type": "input-
|
|
394
|
+
"type": "input-text",
|
|
385
395
|
"className": "m-0",
|
|
386
396
|
"labelClassName": "text-left",
|
|
387
397
|
"id": "u:d7116a113670"
|
|
@@ -524,7 +534,16 @@
|
|
|
524
534
|
"script": "const data = context.props.data;\nif (!data._id) { \n return;\n}\nif (data.tab_items) {\n return;\n}\n\nconst tabOptions = data.tabs_options || [];\nconst tabItems = [];\n// 把应用中原来tabs属性值添加到新的tab_items属性的默认值中\nif (data.tabs && data.tabs.length) {\n data.tabs.forEach(function (item) {\n tabItems.push({ tab_name: item });\n });\n}\nconst pushObjectsToTabItems = function (objects) {\n objects.forEach(function (item) {\n // 已经有绑定到指定对象的选项卡就不添加\n let existObjectItem = !!tabItems.find(function (tabItem) {\n return !!tabOptions.find(function (option) {\n return tabItem.tab_name === tabItem.value && option.object === item;\n });\n });\n if (existObjectItem) {\n return;\n }\n // 找到指向指定对象的选项卡\n let tempOption = tabOptions.find(function (option) {\n return option.type === \"object\" && option.object === item;\n });\n if (!tempOption) {\n return;\n }\n // 选项卡名称如果重复了就不添加\n let existTabItem = !!tabItems.find(function (tabItem) {\n return tabItem.tab_name === tempOption.value;\n });\n if (existTabItem) {\n return;\n }\n if (tempOption) {\n tabItems.push({ tab_name: tempOption.value });\n }\n });\n}\n// 把应用中原来objects属性值添加到新的tab_items属性的默认值中\nif (data.objects && data.objects.length) {\n pushObjectsToTabItems(data.objects);\n}\n// 把应用中原来mobile_objects属性值添加到新的tab_items属性的默认值中\nif (data.mobile_objects && data.mobile_objects.length) {\n pushObjectsToTabItems(data.mobile_objects);\n}\n\ndoAction({\n actionType: 'setValue',\n args: {\n \"value\": { tab_items: tabItems }\n }\n});"
|
|
525
535
|
}
|
|
526
536
|
]
|
|
527
|
-
}
|
|
537
|
+
},
|
|
538
|
+
"submitSucc": {
|
|
539
|
+
"weight": 0,
|
|
540
|
+
"actions": [
|
|
541
|
+
{
|
|
542
|
+
"componentId": "listview_apps",
|
|
543
|
+
"actionType": "reload"
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
}
|
|
528
547
|
},
|
|
529
548
|
"id": "apps-form"
|
|
530
549
|
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"requestAdaptor": "const formData = api.data.$;\napi.data = { objects: formData.objects };\nreturn api;",
|
|
22
22
|
"responseData": null,
|
|
23
|
-
"adaptor": "\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n
|
|
23
|
+
"adaptor": "\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n}\nreturn payload;\n ",
|
|
24
24
|
"headers": {
|
|
25
25
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
26
26
|
}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"actions": [
|
|
64
64
|
{
|
|
65
65
|
"actionType": "custom",
|
|
66
|
-
"script": "const result = event.data.result;\nconst doneCount = result.data && result.data.doneCount || 0;\nconst myMsg = '已成功生成' + doneCount.toString() + \"条选项卡!\";\ndoAction({\n actionType: 'toast',\n args: {\n msg: myMsg,\n msgType: \"success\"\n }\n});\nconst errors = result.data && result.data.errors || [];\nif (errors && errors.length) { \n console.warn(\"以下对象未能生成选项卡:\");\n console.warn(JSON.stringify(errors));\n}\nconst
|
|
66
|
+
"script": "const result = event.data.result;\nconst doneCount = result.data && result.data.doneCount || 0;\nconst myMsg = '已成功生成' + doneCount.toString() + \"条选项卡!\";\ndoAction({\n actionType: 'toast',\n args: {\n msg: myMsg,\n msgType: \"success\"\n }\n});\nconst errors = result.data && result.data.errors || [];\nif (errors && errors.length) { \n console.warn(\"以下对象未能生成选项卡:\");\n console.warn(JSON.stringify(errors));\n}\nconst objectName = event.data.objectName;\nif (objectName === \"apps\") {\n // 在应用表单中生成选项卡后需要触发选项卡列表组件reload重新刷新列表\n doAction({\n actionType: 'reload',\n componentId: \"tabs-options-service\"\n });\n}\nelse {\n // 刷新主列表\n doAction({\n actionType: 'reload',\n componentId: `listview_${objectName}`\n });\n}"
|
|
67
67
|
}
|
|
68
68
|
]
|
|
69
69
|
}
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
],
|
|
76
76
|
"data": {
|
|
77
77
|
"context": {
|
|
78
|
+
"rootUrl": "http://127.0.0.1:5800"
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
81
|
"id": "u:3b0de7e88def",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"method": "post",
|
|
32
32
|
"url": "${context.rootUrl}/graphql?rf=1653731141728",
|
|
33
33
|
"cache": 100,
|
|
34
|
-
"adaptor": "
|
|
34
|
+
"adaptor": "const recordId = api.body.recordId;\nvar data;\nif (recordId) {\n console.log('recordId==>', recordId)\n data = payload.data.data[0] || { _filters_type_controller: 'conditions' };\n //数据格式转换\n if (data) {\n data.columns = lodash.map(data.columns, 'field');\n data.sort = lodash.map(data.sort, (item) => {\n return `${item.field_name}:${item.order || 'asc'}`\n });\n data.mobile_columns = lodash.map(data.mobile_columns, 'field');\n data.searchable_fields = lodash.map(data.searchable_fields, 'field');\n\n if (data.filters && lodash.isString(data.filters)) {\n try {\n data.filters = JSON.parse(data.filters);\n } catch (e) { }\n }\n\n if (data.filters && lodash.isString(data.filters)) {\n data._filters_type_controller = 'function';\n } else {\n data._filters_type_controller = 'conditions'\n }\n\n if (data._filters_type_controller === 'conditions') {\n data._filters_conditions = window.amisConvert.filtersToConditions(data.filters || []);\n } else {\n data._filters_function = data.filters;\n }\n }\n} else {\n const defaultData = api.body.defaultData;\n let defaultValues = {};\n // TODO:字段默认值后期添加\n if(defaultData && _.isObject(defaultData) && !_.isArray(defaultData)){\n data = Object.assign({}, defaultValues, defaultData)\n }\n}\nfor (key in data) {\n if (data[key] === null) {\n delete data[key];\n }\n}\npayload.data = data;\ndelete payload.extensions;\nreturn payload;",
|
|
35
35
|
"data": {
|
|
36
|
-
"
|
|
36
|
+
"recordId": "${recordId}",
|
|
37
|
+
"defaultData": "${defaultData}",
|
|
38
|
+
"query": "{data:object_listviews(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,label,name,object_name,requestAdaptor,adaptor,filter_scope,shared,show_count,columns,filter_fields,sort,filters,filter_logic,mobile_columns,searchable_fields,sort_no,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},enable_amis_schema,amis_schema,_display{shared,show_count,created,modified}}}"
|
|
37
39
|
},
|
|
38
|
-
"sendOn": "!!this.recordId",
|
|
39
40
|
"replaceData": false,
|
|
40
41
|
"responseData": {
|
|
41
42
|
"&": "$$"
|
|
@@ -298,7 +299,7 @@
|
|
|
298
299
|
"label": "js脚本",
|
|
299
300
|
"name": "_filters_function",
|
|
300
301
|
"id": "u:84714ec9abba",
|
|
301
|
-
"visibleOn": "!!this.object_name && _filters_type_controller == 'function'",
|
|
302
|
+
"visibleOn": "!!this.object_name && !!this._filters_type_controller && _filters_type_controller== 'function'",
|
|
302
303
|
"className": "col-span-2 m-0",
|
|
303
304
|
"labelClassName": "hidden"
|
|
304
305
|
}
|
|
@@ -442,6 +443,39 @@
|
|
|
442
443
|
"title": "searchable"
|
|
443
444
|
}
|
|
444
445
|
},
|
|
446
|
+
{
|
|
447
|
+
"type": "fieldSet",
|
|
448
|
+
"title": "数据接口",
|
|
449
|
+
"description": "获取列表数据的 api",
|
|
450
|
+
"collapsable": true,
|
|
451
|
+
"body": [
|
|
452
|
+
{
|
|
453
|
+
"type": "editor",
|
|
454
|
+
"name": "requestAdaptor",
|
|
455
|
+
"label": "发送适配器",
|
|
456
|
+
"required": false,
|
|
457
|
+
"language": "javascript",
|
|
458
|
+
"description": "函数签名:(api) => api, 数据在 api.data 中,修改后返回 api 对象。",
|
|
459
|
+
"className": "col-span-2 m-1",
|
|
460
|
+
"labelClassName": "text-left"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"type": "editor",
|
|
464
|
+
"name": "adaptor",
|
|
465
|
+
"label": "接收适配器",
|
|
466
|
+
"required": false,
|
|
467
|
+
"language": "javascript",
|
|
468
|
+
"description": "函数签名: (payload, response, api) => payload",
|
|
469
|
+
"className": "col-span-2 m-1",
|
|
470
|
+
"labelClassName": "text-left"
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
"collapsed": true,
|
|
474
|
+
"visibleOn": "!!this.object_name",
|
|
475
|
+
"en-US": {
|
|
476
|
+
"title": "API"
|
|
477
|
+
}
|
|
478
|
+
},
|
|
445
479
|
{
|
|
446
480
|
"type": "fieldSet",
|
|
447
481
|
"title": "高级",
|