@steedos/service-plugin-amis 2.2.55 → 2.3.0-beta.3
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.
|
@@ -150,6 +150,7 @@ const getFieldOperators = (type, lng)=>{
|
|
|
150
150
|
switch (type) {
|
|
151
151
|
case 'text':
|
|
152
152
|
return ['equal', 'not_equal', 'like', 'not_like', 'starts_with', 'ends_with']
|
|
153
|
+
case 'currency':
|
|
153
154
|
case 'number':
|
|
154
155
|
return [ 'equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between']
|
|
155
156
|
case 'date':
|
|
@@ -246,12 +247,13 @@ module.exports = {
|
|
|
246
247
|
operators: getFieldOperators(field.type, lng)
|
|
247
248
|
});
|
|
248
249
|
break;
|
|
250
|
+
case 'currency':
|
|
249
251
|
case 'number':
|
|
250
252
|
fields.push({
|
|
251
253
|
label: field.label,
|
|
252
|
-
type:
|
|
254
|
+
type: 'number',
|
|
253
255
|
name: field.name,
|
|
254
|
-
operators: getFieldOperators(
|
|
256
|
+
operators: getFieldOperators('number', lng)
|
|
255
257
|
});
|
|
256
258
|
break;
|
|
257
259
|
// 以下date 、datetime、time 不能作为amis 表单项的格式 . filters 对此格式做个特殊兼容,
|
|
@@ -291,7 +293,15 @@ module.exports = {
|
|
|
291
293
|
label: field.label,
|
|
292
294
|
type: 'select',
|
|
293
295
|
name: field.name,
|
|
294
|
-
source:
|
|
296
|
+
source: {
|
|
297
|
+
"method": "get",
|
|
298
|
+
"url": "${context.rootUrl}" + `/service/api/amis-metadata-listviews/getSelectFieldOptions?objectName=${objectName}&fieldName=${field.name}`,
|
|
299
|
+
"dataType": "json",
|
|
300
|
+
"headers": {
|
|
301
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
,
|
|
295
305
|
searchable: true,
|
|
296
306
|
operators: getFieldOperators(field.type, lng)
|
|
297
307
|
});
|
|
@@ -59,6 +59,46 @@ module.exports = {
|
|
|
59
59
|
return { status: 0, data: { options } }
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
+
getObjectFieldsLayoutOptions: {
|
|
63
|
+
rest: {
|
|
64
|
+
method: "GET",
|
|
65
|
+
path: "/objects/:objectName/fields/layout_options"
|
|
66
|
+
},
|
|
67
|
+
async handler(ctx) {
|
|
68
|
+
const options = await this.getObjectFieldsLayoutOptions(ctx);
|
|
69
|
+
return { status: 0, data: { options } }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
getObjectFieldsGroups: {
|
|
73
|
+
rest: {
|
|
74
|
+
method: "GET",
|
|
75
|
+
path: "/objects/:objectName/fields/groups"
|
|
76
|
+
},
|
|
77
|
+
async handler(ctx) {
|
|
78
|
+
const options = await this.getObjectFieldsGroups(ctx);
|
|
79
|
+
return { status: 0, data: { options } }
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
getObjectActionsOptions: {
|
|
83
|
+
rest: {
|
|
84
|
+
method: "GET",
|
|
85
|
+
path: "/objects/:objectName/actions/options"
|
|
86
|
+
},
|
|
87
|
+
async handler(ctx) {
|
|
88
|
+
const options = await this.getObjectActionsOptions(ctx);
|
|
89
|
+
return { status: 0, data: { options } }
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
getObjectRelatedListsOptions: {
|
|
93
|
+
rest: {
|
|
94
|
+
method: "GET",
|
|
95
|
+
path: "/objects/:objectName/relatedLists/options"
|
|
96
|
+
},
|
|
97
|
+
async handler(ctx) {
|
|
98
|
+
const options = await this.getObjectRelatedListsOptions(ctx);
|
|
99
|
+
return { status: 0, data: { options } }
|
|
100
|
+
}
|
|
101
|
+
},
|
|
62
102
|
getObjectSortFieldsOptions: {
|
|
63
103
|
rest: {
|
|
64
104
|
method: "GET",
|
|
@@ -163,6 +203,157 @@ module.exports = {
|
|
|
163
203
|
}
|
|
164
204
|
})));
|
|
165
205
|
}
|
|
206
|
+
},
|
|
207
|
+
getObjectFieldsLayoutOptions: {
|
|
208
|
+
async handler(ctx) {
|
|
209
|
+
const userSession = ctx.meta.user;
|
|
210
|
+
const lng = userSession.language || 'zh-CN';
|
|
211
|
+
const objectName = ctx.params.objectName;
|
|
212
|
+
const objectConfig = await objectql.getSteedosSchema().getObject(objectName).toConfig();
|
|
213
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
214
|
+
|
|
215
|
+
if(objectConfig.enable_workflow){
|
|
216
|
+
try {
|
|
217
|
+
objectConfig.fields.instance_state.hidden = false;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
console.log("error", error)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const fieldsArr = [];
|
|
224
|
+
_.each(objectConfig.fields , (field, field_name)=>{
|
|
225
|
+
if(!_.has(field, "name")){
|
|
226
|
+
field.name = field_name
|
|
227
|
+
}
|
|
228
|
+
fieldsArr.push(field)
|
|
229
|
+
})
|
|
230
|
+
return _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field)=>{
|
|
231
|
+
return {
|
|
232
|
+
value: field.name,
|
|
233
|
+
label: field.label || field.name,
|
|
234
|
+
group: field.group,
|
|
235
|
+
readonly: field.readonly,
|
|
236
|
+
required: field.required
|
|
237
|
+
}
|
|
238
|
+
})));
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
getObjectFieldsGroups: {
|
|
242
|
+
async handler(ctx) {
|
|
243
|
+
const userSession = ctx.meta.user;
|
|
244
|
+
const lng = userSession.language || 'zh-CN';
|
|
245
|
+
const objectName = ctx.params.objectName;
|
|
246
|
+
const objectConfig = await objectql.getSteedosSchema().getObject(objectName).toConfig();
|
|
247
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
248
|
+
|
|
249
|
+
if(objectConfig.enable_workflow){
|
|
250
|
+
try {
|
|
251
|
+
objectConfig.fields.instance_state.hidden = false;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.log("error", error)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const fieldsArr = [];
|
|
258
|
+
_.each(objectConfig.fields , (field, field_name)=>{
|
|
259
|
+
if(!_.has(field, "name")){
|
|
260
|
+
field.name = field_name
|
|
261
|
+
}
|
|
262
|
+
fieldsArr.push(field)
|
|
263
|
+
})
|
|
264
|
+
return _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field)=>{
|
|
265
|
+
return field.group
|
|
266
|
+
})));
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
getObjectActionsOptions: {
|
|
270
|
+
async handler(ctx) {
|
|
271
|
+
const userSession = ctx.meta.user;
|
|
272
|
+
const lng = userSession.language || 'zh-CN';
|
|
273
|
+
const objectName = ctx.params.objectName;
|
|
274
|
+
const objectConfig = await objectql.getSteedosSchema().getObject(objectName).toConfig();
|
|
275
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
276
|
+
|
|
277
|
+
const actionsArr = [];
|
|
278
|
+
_.each(objectConfig.actions , (action, action_name)=>{
|
|
279
|
+
if(!_.has(action, "name")){
|
|
280
|
+
action.name = action_name
|
|
281
|
+
}
|
|
282
|
+
actionsArr.push(action)
|
|
283
|
+
})
|
|
284
|
+
return _.uniq(_.compact(_.map(_.sortBy(actionsArr, "sort"), (action)=>{
|
|
285
|
+
return {
|
|
286
|
+
value: action.name,
|
|
287
|
+
label: action.label || action.name
|
|
288
|
+
}
|
|
289
|
+
})));
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
getObjectRelatedListsOptions: {
|
|
293
|
+
async handler(ctx) {
|
|
294
|
+
const userSession = ctx.meta.user;
|
|
295
|
+
const lng = userSession.language || 'zh-CN';
|
|
296
|
+
const objectName = ctx.params.objectName;
|
|
297
|
+
const object = await objectql.getSteedosSchema().getObject(objectName);
|
|
298
|
+
const objectConfig = object.toConfig();
|
|
299
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
300
|
+
|
|
301
|
+
const options = [];
|
|
302
|
+
let relatedLists = []
|
|
303
|
+
if(objectConfig.enable_files){
|
|
304
|
+
relatedLists.push("cms_files.parent")
|
|
305
|
+
}
|
|
306
|
+
/*
|
|
307
|
+
object.details是一个字符串,形如:testb__c.testa__c
|
|
308
|
+
object.lookup_details是一个对象,格式如下:
|
|
309
|
+
{
|
|
310
|
+
key: "testd__c.testa__c",
|
|
311
|
+
objectName: "testa__c",
|
|
312
|
+
type: "detail",
|
|
313
|
+
}
|
|
314
|
+
*/
|
|
315
|
+
relatedLists = relatedLists.concat(_.union(object.details, object.lookup_details));
|
|
316
|
+
|
|
317
|
+
if(objectConfig.enable_tasks){
|
|
318
|
+
relatedLists.push("tasks.related_to")
|
|
319
|
+
}
|
|
320
|
+
if(objectConfig.enable_notes){
|
|
321
|
+
relatedLists.push("notes.related_to")
|
|
322
|
+
}
|
|
323
|
+
if(objectConfig.enable_events){
|
|
324
|
+
relatedLists.push("events.related_to")
|
|
325
|
+
}
|
|
326
|
+
if(objectConfig.enable_instances){
|
|
327
|
+
relatedLists.push("instances.record_ids")
|
|
328
|
+
}
|
|
329
|
+
if(objectConfig.enable_approvals){
|
|
330
|
+
relatedLists.push("approvals.related_to")
|
|
331
|
+
}
|
|
332
|
+
if(objectConfig.enable_process){
|
|
333
|
+
relatedLists.push("process_instance_history.target_object")
|
|
334
|
+
}
|
|
335
|
+
if(objectConfig.enable_audit){
|
|
336
|
+
relatedLists.push("audit_records.related_to")
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
_.each(relatedLists, async function(related){
|
|
340
|
+
if (!related) return;
|
|
341
|
+
/*related可能是一个lookup_details,它是对象而不是字符串,从中取出key值*/
|
|
342
|
+
if(typeof related !== "string"){
|
|
343
|
+
related = related.key;
|
|
344
|
+
}
|
|
345
|
+
if (!related) return;
|
|
346
|
+
let foo = related.split('.');
|
|
347
|
+
let rObjectName = foo[0];
|
|
348
|
+
let rFieldName = foo[1];
|
|
349
|
+
const rObjectConfig = await objectql.getSteedosSchema().getObject(rObjectName).toConfig();
|
|
350
|
+
steedosI18n.translationObject(lng, rObjectConfig.name, rObjectConfig);
|
|
351
|
+
let rObjectLable = rObjectConfig.label;
|
|
352
|
+
let rObjectFieldLable = (_.find(rObjectConfig.fields, function(field){return field.name === rFieldName}) || {}).label;
|
|
353
|
+
options.push({label: `${rObjectLable}.${rObjectFieldLable}`, value: related})
|
|
354
|
+
})
|
|
355
|
+
return options;
|
|
356
|
+
}
|
|
166
357
|
}
|
|
167
358
|
}
|
|
168
359
|
};
|
|
@@ -11,7 +11,8 @@ function getFieldsTemplate(fields, expand){
|
|
|
11
11
|
if(field.name.indexOf('.') < 0){
|
|
12
12
|
if(expand && (field.type == 'lookup' || field.type == 'master_detail') && field.reference_to){
|
|
13
13
|
const NAME_FIELD_KEY = objectql.getObject(field.reference_to).NAME_FIELD_KEY;
|
|
14
|
-
|
|
14
|
+
const referenceToField = field.reference_to_field || "_id";
|
|
15
|
+
fieldsName.push(`${field.name}:${field.name}__expand{${referenceToField},${NAME_FIELD_KEY}}`)
|
|
15
16
|
}else{
|
|
16
17
|
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name)
|
|
17
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-plugin-amis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-beta.3",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node .scripts/build.tailwind.js"
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "bb746c90035f38b361011e4b10f0993a390e8355"
|
|
14
14
|
}
|