@steedos-labs/plugin-workflow 3.0.0-beta.6 → 3.0.0-beta.8
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/pages/flowdetail.page.amis.json +1 -1
- package/main/default/routes/am.router.js +1 -1
- package/main/default/routes/api_workflow_relocate.router.js +1 -1
- package/main/default/routes/flow_form_design.ejs +593 -331
- package/main/default/services/flows.service.js +1 -1
- package/main/default/utils/designerManager.js +1 -0
- package/package.json +1 -1
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
"cache": 100,
|
|
560
560
|
"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 ",
|
|
561
561
|
"data": {
|
|
562
|
-
"query": "{data:flows(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,company_id,name,api_name,form,category,state,is_valid,current_no,description,help_text,created_by,modified_by,current,perms,object_name,instance_fields,instance_table_fields,
|
|
562
|
+
"query": "{data:flows(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,company_id,name,api_name,form,category,state,is_valid,current_no,description,help_text,created_by,modified_by,current,perms,object_name,instance_fields,instance_table_fields,field_map,auto_remind,sort_no,timeout_auto_submit,allow_select_step,created,modified,instance_state,_display:_ui{company_id,form,category,state,is_valid,current_no,created_by,modified_by,object_name,auto_remind,sort_no,timeout_auto_submit,allow_select_step,created,modified,instance_state}, \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 }}"
|
|
563
563
|
},
|
|
564
564
|
"headers": {
|
|
565
565
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -102,7 +102,7 @@ router.post('/am/forms', async function (req, res) {
|
|
|
102
102
|
if (objectName) {
|
|
103
103
|
instanceFields = await designerManager.getBusinessFields(objectName)
|
|
104
104
|
const objFields = await objectql.getObject(objectName).getFields();
|
|
105
|
-
const transformObjectFields = await designerManager.transformObjectFields(
|
|
105
|
+
const transformObjectFields = await designerManager.transformObjectFields(_.sortBy(instanceFields, 'sort_no'), objFields);
|
|
106
106
|
formFields = await designerManager.transformObjectFieldsToFormFields(transformObjectFields);
|
|
107
107
|
}
|
|
108
108
|
const tables = await designerManager.transformObjectDetailFieldsToFormTableFields(instance_table_fields)
|
|
@@ -10,7 +10,7 @@ const router = express.Router();
|
|
|
10
10
|
const { requireAuthentication } = require("@steedos/auth");
|
|
11
11
|
const objectql = require('@steedos/objectql');
|
|
12
12
|
const { excuteTriggers } = require('../utils/trigger');
|
|
13
|
-
const { getStep } = require('../
|
|
13
|
+
const { getStep } = require('../uuFlowManager');
|
|
14
14
|
const UUFlowManager = require('../manager/uuflow_manager');
|
|
15
15
|
/**
|
|
16
16
|
* 重定位申请单
|
|
@@ -1,112 +1,119 @@
|
|
|
1
1
|
<html>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<script src="/unpkg.com/@steedos-builder/fiddle@0.0.5/dist/builder-fiddle.umd.js"></script>
|
|
5
|
+
<script src="/unpkg.com/axios@0.26.1/dist/axios.min.js"></script>
|
|
6
|
+
<script src="/unpkg.com/flowbite@2.3.0/dist/flowbite.min.js"></script>
|
|
7
|
+
<script src="/unpkg.com/lodash@4.17.21/lodash.min.js"></script>
|
|
8
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
9
|
+
<link href="/toast/toastr.min.css" rel="stylesheet" />
|
|
10
|
+
<script src="/jquery.min.js"></script>
|
|
11
|
+
<script src="/toast/toastr.min.js"></script>
|
|
12
|
+
<style>
|
|
13
|
+
#toast-container.toast-bottom-center>div,
|
|
14
|
+
#toast-container.toast-top-center>div {
|
|
15
|
+
width: 450px;
|
|
16
|
+
opacity: 1;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
|
|
21
|
+
<body>
|
|
22
|
+
<!-- Main modal -->
|
|
23
|
+
<div id="fieldLayoutModal" tabindex="-1" aria-hidden="true"
|
|
24
|
+
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
|
25
|
+
<div class="relative p-4 w-full max-w-2xl max-h-full">
|
|
26
|
+
<!-- Modal content -->
|
|
27
|
+
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
|
|
28
|
+
<!-- Modal header -->
|
|
29
|
+
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
|
|
30
|
+
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
|
31
|
+
字段保存结果
|
|
32
|
+
</h3>
|
|
33
|
+
<button type="button"
|
|
34
|
+
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white"
|
|
35
|
+
data-modal-hide="fieldLayoutModal">
|
|
36
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
|
37
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
38
|
+
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
|
|
39
|
+
</svg>
|
|
40
|
+
<span class="sr-only">Close modal</span>
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
<!-- Modal body -->
|
|
44
|
+
<div class="p-4 md:p-5 space-y-4">
|
|
45
|
+
<ul class="space-y-4 text-gray-500 list-disc list-inside dark:text-gray-400" id="fieldLayoutList">
|
|
46
|
+
</ul>
|
|
47
|
+
</div>
|
|
42
48
|
</div>
|
|
43
49
|
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
</div>
|
|
51
|
+
<builder-fiddle host="<%=builderHost%>"></builder-fiddle>
|
|
52
|
+
<script>
|
|
53
|
+
const useOpenAPI = <%=(useOpenAPI === "true" || useOpenAPI === true) %>;
|
|
54
|
+
const settings = {
|
|
55
|
+
assetUrls: "<%=assetUrls%>",
|
|
56
|
+
rootUrl: "<%=rootUrl%>",
|
|
57
|
+
userId: "<%=userId%>",
|
|
58
|
+
tenantId: "<%=tenantId%>",
|
|
59
|
+
authToken: "<%=authToken%>",
|
|
60
|
+
messageOnly: true,
|
|
61
|
+
useOpenAPI: useOpenAPI,
|
|
62
|
+
id: "<%=id%>",
|
|
63
|
+
pageId: "<%=id%>",
|
|
64
|
+
hiddenDeploy: true
|
|
65
|
+
};
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
let comp = document.querySelector("builder-fiddle");
|
|
68
|
+
|
|
69
|
+
// set the modal menu element
|
|
70
|
+
const $targetEl = document.getElementById('fieldLayoutModal');
|
|
71
|
+
// options with default values
|
|
72
|
+
const options = {
|
|
73
|
+
placement: 'top-center',
|
|
74
|
+
backdrop: 'dynamic',
|
|
75
|
+
backdropClasses:
|
|
76
|
+
'bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-40',
|
|
77
|
+
closable: true,
|
|
78
|
+
onHide: () => {
|
|
79
|
+
console.log('modal is hidden');
|
|
80
|
+
},
|
|
81
|
+
onShow: () => {
|
|
82
|
+
console.log('modal is shown');
|
|
83
|
+
},
|
|
84
|
+
onToggle: () => {
|
|
85
|
+
console.log('modal has been toggled');
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
// instance options object
|
|
89
|
+
const instanceOptions = {
|
|
90
|
+
id: 'fieldLayoutModal',
|
|
91
|
+
override: true
|
|
92
|
+
};
|
|
93
|
+
const modal = new Flowbite.default.Modal($targetEl, options, instanceOptions);
|
|
94
|
+
|
|
95
|
+
const loadPage = async () => {
|
|
96
|
+
const { assetUrls, rootUrl, userId, tenantId, authToken, id } = settings;
|
|
97
|
+
|
|
98
|
+
// 如果传入 steedos rooturl
|
|
99
|
+
if (rootUrl && !authToken) return;
|
|
100
|
+
|
|
101
|
+
const initialContent = {
|
|
102
|
+
type: "page",
|
|
103
|
+
title: "Welcome to Steedos",
|
|
104
|
+
body: [],
|
|
105
|
+
regions: ["body"],
|
|
106
|
+
data: {
|
|
107
|
+
context: {
|
|
108
|
+
rootUrl,
|
|
109
|
+
userId,
|
|
110
|
+
tenantId,
|
|
111
|
+
authToken,
|
|
79
112
|
},
|
|
113
|
+
},
|
|
80
114
|
};
|
|
81
|
-
// instance options object
|
|
82
|
-
const instanceOptions = {
|
|
83
|
-
id: 'fieldLayoutModal',
|
|
84
|
-
override: true
|
|
85
|
-
};
|
|
86
|
-
const modal = new Flowbite.default.Modal($targetEl, options, instanceOptions);
|
|
87
|
-
|
|
88
|
-
const loadPage = async () => {
|
|
89
|
-
const { assetUrls, rootUrl, userId, tenantId, authToken, id } = settings;
|
|
90
|
-
|
|
91
|
-
// 如果传入 steedos rooturl
|
|
92
|
-
if (rootUrl && !authToken) return;
|
|
93
|
-
|
|
94
|
-
const initialContent = {
|
|
95
|
-
type: "page",
|
|
96
|
-
title: "Welcome to Steedos",
|
|
97
|
-
body: [],
|
|
98
|
-
regions: ["body"],
|
|
99
|
-
data: {
|
|
100
|
-
context: {
|
|
101
|
-
rootUrl,
|
|
102
|
-
userId,
|
|
103
|
-
tenantId,
|
|
104
|
-
authToken,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
if (id) {
|
|
110
117
|
const result = await axios.post(
|
|
111
118
|
`${rootUrl}/graphql`,
|
|
112
119
|
{
|
|
@@ -141,7 +148,7 @@
|
|
|
141
148
|
"actions": [],
|
|
142
149
|
"wrapWithPanel": false
|
|
143
150
|
}
|
|
144
|
-
if(result.data.data.record.current.fields){
|
|
151
|
+
if (result.data.data.record.current.fields) {
|
|
145
152
|
for (let i = 0; i < result.data.data.record.current.fields.length; i++) {
|
|
146
153
|
const temp = await getFieldEditTpl(result.data.data.record.current.fields[i]);
|
|
147
154
|
if (temp) {
|
|
@@ -183,66 +190,319 @@
|
|
|
183
190
|
} else {
|
|
184
191
|
return initialContent
|
|
185
192
|
}
|
|
186
|
-
|
|
193
|
+
};
|
|
194
|
+
|
|
187
195
|
|
|
188
|
-
const savePage = async (data) => {
|
|
189
|
-
const { rootUrl, userId, tenantId, authToken, id } = settings;
|
|
190
196
|
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
const getSelectOptions = (field) => {
|
|
198
|
+
const options = [];
|
|
199
|
+
// each(field.options.split("\n"), (item) => {
|
|
200
|
+
// var foo = item.split(":");
|
|
201
|
+
// if (foo.length == 2) {
|
|
202
|
+
// options.push({ label: foo[0], value: foo[1] });
|
|
203
|
+
// } else {
|
|
204
|
+
// options.push({ label: item, value: item });
|
|
205
|
+
// }
|
|
206
|
+
// });
|
|
207
|
+
|
|
208
|
+
const splitItem = field.options.split("\n");
|
|
209
|
+
splitItem.forEach(item => {
|
|
210
|
+
var foo = item.split(":");
|
|
211
|
+
if (foo.length == 2) {
|
|
212
|
+
options.push({ label: foo[0], value: foo[1] });
|
|
213
|
+
} else {
|
|
214
|
+
options.push({ label: item, value: item });
|
|
193
215
|
}
|
|
216
|
+
});
|
|
194
217
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
218
|
+
return options;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const startsWith = (url, str) => {
|
|
222
|
+
|
|
223
|
+
let flag = false
|
|
224
|
+
if (url.substr(0, 4) === str) {
|
|
225
|
+
flag = true
|
|
226
|
+
} else {
|
|
227
|
+
flag = false
|
|
228
|
+
}
|
|
229
|
+
return flag
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
//将原数据字段转换为amis字段
|
|
234
|
+
const getFieldEditTpl = async (field) => {
|
|
235
|
+
|
|
236
|
+
if(field.steedos_field){
|
|
237
|
+
return {
|
|
238
|
+
type: `sfield-${_.toLower(_.camelCase(field.steedos_field.type))}`,
|
|
239
|
+
config: field.steedos_field
|
|
201
240
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const tpl = {
|
|
244
|
+
label: field.name,
|
|
245
|
+
name: field.code,
|
|
246
|
+
required: field.is_required,
|
|
247
|
+
multiple: field.is_multiselect,
|
|
248
|
+
className: (field.is_wide ? 'is_wide' : '') +
|
|
249
|
+
(field.is_list_display ? ' is_list_display' : '') +
|
|
250
|
+
(field.is_searchable ? ' is_searchable' : '')
|
|
251
|
+
};
|
|
252
|
+
switch (field.type) {
|
|
253
|
+
case "input":
|
|
254
|
+
if (field.is_textarea) {
|
|
255
|
+
tpl.type = "textarea";
|
|
256
|
+
} else {
|
|
257
|
+
tpl.type = "input-text";
|
|
258
|
+
}
|
|
259
|
+
break;
|
|
260
|
+
case "number":
|
|
261
|
+
tpl.type = "input-number";
|
|
262
|
+
break;
|
|
263
|
+
case "date":
|
|
264
|
+
tpl.type = "input-date";
|
|
265
|
+
tpl.inputFormat = "YYYY-MM-DD";
|
|
266
|
+
tpl.format = 'YYYY-MM-DDT00:00:00.000[Z]';
|
|
267
|
+
break;
|
|
268
|
+
case "dateTime":
|
|
269
|
+
tpl.type = "input-datetime";
|
|
270
|
+
tpl.inputFormat = "YYYY-MM-DD HH:mm";
|
|
271
|
+
tpl.format = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
|
|
272
|
+
break;
|
|
273
|
+
case "checkbox":
|
|
274
|
+
tpl.type = "checkbox";
|
|
275
|
+
break;
|
|
276
|
+
|
|
277
|
+
case "email":
|
|
278
|
+
tpl.type = "input-email";
|
|
279
|
+
tpl.validations = {
|
|
280
|
+
isEmail: true,
|
|
281
|
+
};
|
|
282
|
+
break;
|
|
283
|
+
case "url":
|
|
284
|
+
tpl.type = "input-url";
|
|
285
|
+
tpl.validations = {
|
|
286
|
+
isUrl: true,
|
|
287
|
+
};
|
|
288
|
+
break;
|
|
289
|
+
case "password":
|
|
290
|
+
tpl.type = "input-password";
|
|
291
|
+
tpl.showCounter = true;
|
|
292
|
+
break;
|
|
293
|
+
case "select":
|
|
294
|
+
tpl.type = "select";
|
|
295
|
+
tpl.options = getSelectOptions(field);
|
|
296
|
+
break;
|
|
297
|
+
|
|
298
|
+
case "user":
|
|
299
|
+
const useTpl = {
|
|
300
|
+
"type": "steedos-field",
|
|
301
|
+
"id": "u:9f4486c22f52",
|
|
302
|
+
"field": JSON.stringify({
|
|
303
|
+
name: field.code,
|
|
304
|
+
label: field.name,
|
|
305
|
+
reference_to: "space_users",
|
|
306
|
+
reference_to_field: 'user',
|
|
307
|
+
multiple: field.is_multiselect,
|
|
308
|
+
type: "lookup"
|
|
309
|
+
}),
|
|
310
|
+
}
|
|
311
|
+
// const useTpl = await lookupToAmis(
|
|
312
|
+
// {
|
|
313
|
+
// name: field.code,
|
|
314
|
+
// label: field.name,
|
|
315
|
+
// reference_to: "space_users",
|
|
316
|
+
// reference_to_field: 'user',
|
|
317
|
+
// multiple: field.is_multiselect,
|
|
318
|
+
// },
|
|
319
|
+
// false,
|
|
320
|
+
// {}
|
|
321
|
+
// );
|
|
322
|
+
Object.assign(tpl, useTpl);
|
|
323
|
+
break;
|
|
324
|
+
|
|
325
|
+
case "group":
|
|
326
|
+
const orgTpl = {
|
|
327
|
+
"type": "steedos-field",
|
|
328
|
+
"id": "u:9f4486c22f52",
|
|
329
|
+
"field": JSON.stringify({
|
|
330
|
+
name: field.code,
|
|
331
|
+
label: field.name,
|
|
332
|
+
reference_to: "organizations",
|
|
333
|
+
multiple: field.is_multiselect,
|
|
334
|
+
type: "lookup"
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// const orgTpl = await lookupToAmis(
|
|
339
|
+
// {
|
|
340
|
+
// name: field.code,
|
|
341
|
+
// label: field.name,
|
|
342
|
+
// reference_to: "organizations",
|
|
343
|
+
// multiple: field.is_multiselect,
|
|
344
|
+
// },
|
|
345
|
+
// false,
|
|
346
|
+
// {}
|
|
347
|
+
// );
|
|
348
|
+
Object.assign(tpl, orgTpl);
|
|
349
|
+
break;
|
|
350
|
+
case "radio":
|
|
351
|
+
tpl.type = "radios";
|
|
352
|
+
tpl.options = getSelectOptions(field);
|
|
353
|
+
break;
|
|
354
|
+
case "multiSelect":
|
|
355
|
+
tpl.type = "checkboxes";
|
|
356
|
+
tpl.options = getSelectOptions(field);
|
|
357
|
+
break;
|
|
358
|
+
case "odata":
|
|
359
|
+
console.log('field', field);
|
|
360
|
+
var labelField = field.formula.substr(1, field.formula.length - 2);
|
|
361
|
+
labelField = labelField.substr(labelField.indexOf(".") + 1);
|
|
362
|
+
// 加入odata标签以示区别 把field-老表单设计器的元素加入
|
|
363
|
+
tpl.type = "select";
|
|
364
|
+
tpl.description = field.description
|
|
365
|
+
tpl.detail_url = field.detail_url
|
|
366
|
+
tpl.filters = field.filters
|
|
367
|
+
tpl.formula = field.formula
|
|
368
|
+
tpl.is_list_display = field.is_list_display
|
|
369
|
+
tpl.is_multiselect = field.is_multiselect
|
|
370
|
+
tpl.is_required = field.is_required
|
|
371
|
+
tpl.is_searchable = field.is_searchable
|
|
372
|
+
tpl.is_wide = field.is_wide
|
|
373
|
+
tpl.search_field = field.search_field
|
|
374
|
+
tpl._id = field._id
|
|
375
|
+
// tpl.labelField = labelField;
|
|
376
|
+
// tpl.valueField = "_value";
|
|
377
|
+
tpl.source = {
|
|
378
|
+
//判断该field.url是否为http开头
|
|
379
|
+
url: startsWith(field.url, "http")
|
|
380
|
+
? field.url
|
|
381
|
+
: `\${context.rootUrl}${field.url}`,
|
|
382
|
+
method: "get",
|
|
383
|
+
dataType: "json",
|
|
384
|
+
headers: {
|
|
385
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}",
|
|
386
|
+
},
|
|
387
|
+
adaptor: `
|
|
388
|
+
payload.data = {
|
|
389
|
+
options: _.map(payload.value, (item)=>{
|
|
390
|
+
const value = item;
|
|
391
|
+
item["@label"] = item["${labelField}"]
|
|
392
|
+
delete item['@odata.editLink'];
|
|
393
|
+
delete item['@odata.etag'];
|
|
394
|
+
delete item['@odata.id'];
|
|
395
|
+
return {
|
|
396
|
+
label: item["@label"],
|
|
397
|
+
value: value
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
return payload;
|
|
402
|
+
`
|
|
403
|
+
};
|
|
404
|
+
break;
|
|
405
|
+
case "html":
|
|
406
|
+
if (tpl.disabled) {
|
|
407
|
+
tpl.type = 'html';
|
|
408
|
+
} else {
|
|
409
|
+
tpl.type = "input-rich-text";
|
|
410
|
+
}
|
|
411
|
+
break;
|
|
412
|
+
case "table":
|
|
413
|
+
tpl.type = "input-table";
|
|
414
|
+
tpl.addable = field.permission === "editable";
|
|
415
|
+
tpl.editable = tpl.addable;
|
|
416
|
+
tpl.copyable = tpl.addable;
|
|
417
|
+
tpl.columns = [];
|
|
418
|
+
for (const sField of field.fields) {
|
|
419
|
+
if (sField.type != "hidden") {
|
|
420
|
+
sField.permission = field.permission
|
|
421
|
+
const column = await getFieldEditTpl(sField, true);
|
|
422
|
+
tpl.columns.push(column);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
break;
|
|
426
|
+
case "section":
|
|
427
|
+
tpl.type = "fieldset";
|
|
428
|
+
tpl.title = field.name;
|
|
429
|
+
tpl.collapsable = true;
|
|
430
|
+
tpl.body = []
|
|
431
|
+
if (field.fields) {
|
|
432
|
+
for (let i = 0; i < field.fields.length; i++) {
|
|
433
|
+
let fieldsItem = await getFieldEditTpl(field.fields[i], true)
|
|
434
|
+
tpl.body.push(fieldsItem)
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
break;
|
|
438
|
+
default:
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
return tpl
|
|
442
|
+
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
const savePage = async (data) => {
|
|
448
|
+
const { rootUrl, userId, tenantId, authToken, id } = settings;
|
|
449
|
+
|
|
450
|
+
if (!id) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// 保存schema时,清理context下的认证信息
|
|
455
|
+
const schema = JSON.parse(
|
|
456
|
+
JSON.stringify(data.data.AmisSchema, null, 4)
|
|
457
|
+
);
|
|
458
|
+
if (schema.data && typeof schema.data.context === 'object') {
|
|
459
|
+
delete schema.data.context
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return await axios.post(
|
|
463
|
+
`${rootUrl}/graphql`,
|
|
464
|
+
{
|
|
465
|
+
query: `
|
|
207
466
|
mutation{
|
|
208
467
|
forms__update(id: "${id}", doc: {amis_schema: ${JSON.stringify(JSON.stringify(schema, null, 4))}}){_id}
|
|
209
468
|
}
|
|
210
469
|
`,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
withCredentials: true,
|
|
473
|
+
headers: { Authorization: `Bearer ${tenantId},${authToken}` },
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
.catch(function (error) {
|
|
477
|
+
// handle error
|
|
478
|
+
console.log(error);
|
|
479
|
+
});
|
|
221
480
|
|
|
222
481
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
482
|
+
return result;
|
|
483
|
+
};
|
|
484
|
+
window.addEventListener('message', function (event) {
|
|
485
|
+
const { data } = event;
|
|
486
|
+
if (data) {
|
|
487
|
+
if (data.type === 'builder.loaded') {
|
|
488
|
+
comp.messageFrame('builder.EditorPropsChanged', {
|
|
489
|
+
editorProps: JSON.stringify({
|
|
490
|
+
onChange: function (value) {
|
|
491
|
+
|
|
492
|
+
},
|
|
493
|
+
onDndAccept: function (event) {
|
|
494
|
+
return true;
|
|
495
|
+
},
|
|
496
|
+
beforeDelete: function (event) {
|
|
497
|
+
|
|
498
|
+
},
|
|
499
|
+
onInit: function () {
|
|
500
|
+
// 创建一个新的 style 元素
|
|
501
|
+
var style = document.createElement('style');
|
|
502
|
+
style.type = "text/css";
|
|
503
|
+
style.media = "screen";
|
|
504
|
+
// 将 CSS 样式写入 style 元素
|
|
505
|
+
style.innerHTML = `
|
|
246
506
|
.ae-RendererList-groupWrap .ae-RendererList-group:nth-child(n+3) {
|
|
247
507
|
display: none;
|
|
248
508
|
}
|
|
@@ -257,185 +517,187 @@
|
|
|
257
517
|
}
|
|
258
518
|
`;
|
|
259
519
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
return false
|
|
418
|
-
}
|
|
419
|
-
}, (key, value) => {
|
|
420
|
-
if (typeof value === 'function') {
|
|
421
|
-
return value.toString();
|
|
520
|
+
// 将 style 元素插入到 head 中
|
|
521
|
+
document.head.appendChild(style);
|
|
522
|
+
},
|
|
523
|
+
disableBultinPlugin: false,
|
|
524
|
+
disablePluginList2: function (id, plugin) {
|
|
525
|
+
if (lodash.includes([
|
|
526
|
+
"FlexPlugin",
|
|
527
|
+
"GridPlugin",
|
|
528
|
+
"ContainerPlugin",
|
|
529
|
+
"Layout_free_container",
|
|
530
|
+
"Layout_fixed_top",
|
|
531
|
+
"Layout_fixed",
|
|
532
|
+
"CollapseGroupPlugin",
|
|
533
|
+
"PanelPlugin",
|
|
534
|
+
"TabsPlugin",
|
|
535
|
+
"SwitchContainerPlugin",
|
|
536
|
+
"CRUDPlugin",
|
|
537
|
+
"Table2Plugin",
|
|
538
|
+
"TableCRUDPlugin",
|
|
539
|
+
"FormPlugin",
|
|
540
|
+
"ServicePlugin",
|
|
541
|
+
// "TextControlPlugin",
|
|
542
|
+
// "TextareaControlPlugin",
|
|
543
|
+
// "NumberControlPlugin",
|
|
544
|
+
// "SelectControlPlugin",
|
|
545
|
+
// "NestedSelectControlPlugin",
|
|
546
|
+
// "ChainedSelectControlPlugin",
|
|
547
|
+
// "DropDownButtonPlugin",
|
|
548
|
+
// "CheckboxesControlPlugin",
|
|
549
|
+
// "RadiosControlPlugin",
|
|
550
|
+
// "CheckboxControlPlugin",
|
|
551
|
+
// "DateControlPlugin",
|
|
552
|
+
// "DateRangeControlPlugin",
|
|
553
|
+
// "FileControlPlugin",
|
|
554
|
+
// "ImageControlPlugin",
|
|
555
|
+
// "ExcelControlPlugin",
|
|
556
|
+
// "TreeControlPlugin",
|
|
557
|
+
// "TagControlPlugin",
|
|
558
|
+
// "ListControlPlugin",
|
|
559
|
+
// "ButtonGroupControlPlugin",
|
|
560
|
+
// "ButtonToolbarControlPlugin",
|
|
561
|
+
// "PickerControlPlugin",
|
|
562
|
+
// "SwitchControlPlugin",
|
|
563
|
+
// "RangeControlPlugin",
|
|
564
|
+
// "RateControlPlugin",
|
|
565
|
+
// "CityControlPlugin",
|
|
566
|
+
// "TransferPlugin",
|
|
567
|
+
// "TabsTransferPlugin",
|
|
568
|
+
// "ColorControlPlugin",
|
|
569
|
+
// "ConditionBilderPlugin",
|
|
570
|
+
// "FieldSetControlPlugin",
|
|
571
|
+
// "ComboControlPlugin",
|
|
572
|
+
// "InputGroupControlPlugin",
|
|
573
|
+
// "TableControlPlugin",
|
|
574
|
+
// "MatrixControlPlugin",
|
|
575
|
+
// "RichTextControlPlugin",
|
|
576
|
+
// "DiffEditorControlPlugin",
|
|
577
|
+
// "CodeEditorControlPlugin",
|
|
578
|
+
// "SearchBoxPlugin",
|
|
579
|
+
// "KVControlPlugin",
|
|
580
|
+
// "RepeatControlPlugin",
|
|
581
|
+
// "UUIDControlPlugin",
|
|
582
|
+
// "LocationControlPlugin",
|
|
583
|
+
// "SubFormControlPlugin",
|
|
584
|
+
// "HiddenControlPlugin",
|
|
585
|
+
// "SignaturePlugin",
|
|
586
|
+
// "StaticControlPlugin",
|
|
587
|
+
"ButtonPlugin",
|
|
588
|
+
"ButtonGroupPlugin",
|
|
589
|
+
"NavPlugin",
|
|
590
|
+
"AnchorNavPlugin",
|
|
591
|
+
"TooltipWrapperPlugin",
|
|
592
|
+
"AlertPlugin",
|
|
593
|
+
"WizardPlugin",
|
|
594
|
+
"TableViewPlugin",
|
|
595
|
+
"WebComponentPlugin",
|
|
596
|
+
"AudioPlugin",
|
|
597
|
+
"VideoPlugin",
|
|
598
|
+
"CustomPlugin",
|
|
599
|
+
"TasksPlugin",
|
|
600
|
+
"EachPlugin",
|
|
601
|
+
"PropertyPlugin",
|
|
602
|
+
"IFramePlugin",
|
|
603
|
+
"QRCodePlugin",
|
|
604
|
+
"TplPlugin",
|
|
605
|
+
"IconPlugin",
|
|
606
|
+
"LinkPlugin",
|
|
607
|
+
"ListPlugin",
|
|
608
|
+
"List2Plugin",
|
|
609
|
+
"MappingPlugin",
|
|
610
|
+
"AvatarPlugin",
|
|
611
|
+
"CardPlugin",
|
|
612
|
+
"Card2Plugin",
|
|
613
|
+
"CardsPlugin",
|
|
614
|
+
"TablePlugin",
|
|
615
|
+
"TableCell2Plugin",
|
|
616
|
+
"ChartPlugin",
|
|
617
|
+
"SparklinePlugin",
|
|
618
|
+
"CarouselPlugin",
|
|
619
|
+
"ImagePlugin",
|
|
620
|
+
"ImagesPlugin",
|
|
621
|
+
"DatePlugin",
|
|
622
|
+
"TimePlugin",
|
|
623
|
+
"DatetimePlugin",
|
|
624
|
+
"CalendarPlugin",
|
|
625
|
+
"TagPlugin",
|
|
626
|
+
"JsonPlugin",
|
|
627
|
+
"ProgressPlugin",
|
|
628
|
+
"StatusPlugin",
|
|
629
|
+
"StepsPlugin",
|
|
630
|
+
"TimelinePlugin",
|
|
631
|
+
// "DividerPlugin",
|
|
632
|
+
// "CodeViewPlugin",
|
|
633
|
+
// "MarkdownPlugin",
|
|
634
|
+
// "CollapsePlugin",
|
|
635
|
+
"OfficeViewerPlugin",
|
|
636
|
+
"PdfViewerPlugin",
|
|
637
|
+
"LogPlugin",
|
|
638
|
+
"ActionPlugin",
|
|
639
|
+
"TableCellPlugin",
|
|
640
|
+
"ArrayControlPlugin",
|
|
641
|
+
"ControlPlugin",
|
|
642
|
+
"DateTimeControlPlugin",
|
|
643
|
+
"DateTimeRangeControlPlugin",
|
|
644
|
+
"EmailControlPlugin",
|
|
645
|
+
"FormulaControlPlugin",
|
|
646
|
+
"GroupControlPlugin",
|
|
647
|
+
"ItemPlugin",
|
|
648
|
+
"MonthControlPlugin",
|
|
649
|
+
"MonthRangeControlPlugin",
|
|
650
|
+
"PasswordControlPlugin",
|
|
651
|
+
"InputQuarterPlugin",
|
|
652
|
+
"QuarterRangePlugin",
|
|
653
|
+
"TimeControlPlugin",
|
|
654
|
+
"TimeRangeControlPlugin",
|
|
655
|
+
"TreeSelectControlPlugin",
|
|
656
|
+
"URLControlPlugin",
|
|
657
|
+
"YearControlPlugin",
|
|
658
|
+
"YearRangeControlPlugin",
|
|
659
|
+
"BreadcrumbPlugin",
|
|
660
|
+
"CustomRegionPlugin",
|
|
661
|
+
"DialogPlugin",
|
|
662
|
+
"DrawerPlugin",
|
|
663
|
+
"HBoxPlugin",
|
|
664
|
+
"ListItemPlugin",
|
|
665
|
+
"OperationPlugin",
|
|
666
|
+
// "PagePlugin",
|
|
667
|
+
"PaginationPlugin",
|
|
668
|
+
"PlainPlugin",
|
|
669
|
+
"ResetPlugin",
|
|
670
|
+
"SubmitPlugin",
|
|
671
|
+
"WrapperPlugin",
|
|
672
|
+
"ColumnToggler"
|
|
673
|
+
]
|
|
674
|
+
, id)) {
|
|
675
|
+
return true;
|
|
422
676
|
}
|
|
423
|
-
return
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
if (data.type === 'builder.saveContent') {
|
|
432
|
-
savePage(data.data).then(()=>{
|
|
433
|
-
comp.messageFrame('builder.contentSaved')
|
|
677
|
+
return false
|
|
678
|
+
}
|
|
679
|
+
}, (key, value) => {
|
|
680
|
+
if (typeof value === 'function') {
|
|
681
|
+
return value.toString();
|
|
682
|
+
}
|
|
683
|
+
return value;
|
|
434
684
|
})
|
|
435
|
-
}
|
|
685
|
+
})
|
|
436
686
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
687
|
+
if (data.type === 'builder.loadContent') {
|
|
688
|
+
loadPage().then((content) => {
|
|
689
|
+
comp.messageFrame('builder.contentChanged', { AmisSchema: content })
|
|
690
|
+
})
|
|
691
|
+
}
|
|
692
|
+
if (data.type === 'builder.saveContent') {
|
|
693
|
+
savePage(data.data).then(() => {
|
|
694
|
+
comp.messageFrame('builder.contentSaved')
|
|
695
|
+
})
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
})
|
|
699
|
+
comp.settings = settings;
|
|
700
|
+
</script>
|
|
701
|
+
</body>
|
|
702
|
+
|
|
703
|
+
</html>
|