@steedos/service-plugin-amis 2.4.3 → 2.4.4

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.
@@ -88,7 +88,7 @@
88
88
  }else{
89
89
  setSchema(result)
90
90
  }
91
- }, [JSON.stringify($schema)])
91
+ }, [JSON.stringify($schema)]) //, JSON.stringify(props.data)
92
92
 
93
93
  if (!schema)
94
94
  return render('body', {
@@ -206,9 +206,14 @@ module.exports = {
206
206
  const userSession = ctx.meta.user;
207
207
  const lng = userSession.language || 'zh-CN';
208
208
  const objectName = ctx.params.objectName;
209
- const objectConfig = await objectql.getSteedosSchema().getObject(objectName).toConfig();
209
+ const object = await objectql.getSteedosSchema().getObject(objectName);
210
+ const objectConfig = object.toConfig();
210
211
  steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
211
212
 
213
+ const include_deep = ctx.params.include_deep === "true";
214
+ const include_hide = ctx.params.include_hide === "true";
215
+ const include_related = ctx.params.include_related === "true";
216
+
212
217
  if(objectConfig.enable_workflow){
213
218
  try {
214
219
  objectConfig.fields.instance_state.hidden = false;
@@ -216,22 +221,151 @@ module.exports = {
216
221
  console.log("error", error)
217
222
  }
218
223
  }
219
-
220
- const fieldsArr = [];
224
+
225
+ // 设置主表
226
+ let fieldsArr = [];
221
227
  _.each(objectConfig.fields , (field, field_name)=>{
222
228
  if(!_.has(field, "name")){
223
229
  field.name = field_name
224
230
  }
225
231
  fieldsArr.push(field)
226
232
  })
227
- return _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field)=>{
228
- if(!field.hidden && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown", "html"], field.type)){
233
+
234
+ let output = [];
235
+ output = _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field)=>{
236
+ if((include_hide || !field.hidden) && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown", "html"], field.type)){
237
+ // 隐藏的字段 和 字段类型 判断
229
238
  return {
230
239
  value: field.name,
231
240
  label: field.label || field.name
232
241
  }
233
242
  }
234
243
  })));
244
+
245
+ if(include_deep) {
246
+ for( let i = 0; i < fieldsArr.length; i ++ ) {
247
+ if(!include_hide && fieldsArr[i].hidden) continue;
248
+ if((fieldsArr[i].type == 'lookup' || fieldsArr[i].type == 'master_detail') && fieldsArr[i].reference_to && _.isString(fieldsArr[i].reference_to)) {
249
+ const r_object = await objectql.getSteedosSchema().getObject(fieldsArr[i].reference_to).toConfig();
250
+ steedosI18n.translationObject(lng, r_object.name, r_object);
251
+ if (r_object){
252
+ _.forEach(r_object.fields, (f2, k2)=>{
253
+ if(!include_hide && f2.hidden) return;
254
+ output.push({
255
+ 'value': fieldsArr[i].name + '.' + k2,
256
+ 'label': (fieldsArr[i].label || fieldsArr[i].name) + '=>' + (f2.label || k2)
257
+ });
258
+ });
259
+ }
260
+ }
261
+ }
262
+ }
263
+
264
+ if(include_related){
265
+ const relationsInfo = await object.getRelationsInfo();
266
+ const lookupDetails = relationsInfo && relationsInfo.lookup_details;
267
+ let details = relationsInfo && relationsInfo.details;
268
+
269
+ details = _.uniq(details.concat(lookupDetails));
270
+
271
+ let relatedListObjects = [];
272
+ _.each(details, (related)=>{
273
+ let foo = related.split('.');
274
+ let rObjectName = foo[0];
275
+ let foreign_key = foo[1];
276
+ relatedListObjects.push({object_name: rObjectName, foreign_key: foreign_key});
277
+ });
278
+
279
+ if(objectConfig.enable_files){
280
+ relatedListObjects.push({
281
+ object_name: 'cms_files',
282
+ foreign_key: 'parent'
283
+ })
284
+ }
285
+ if(objectConfig.enable_tasks){
286
+ relatedListObjects.push({
287
+ object_name: 'tasks',
288
+ foreign_key: 'related_to'
289
+ })
290
+ }
291
+ if(objectConfig.enable_notes){
292
+ relatedListObjects.push({
293
+ object_name: 'notes',
294
+ foreign_key: 'related_to'
295
+ })
296
+ }
297
+ if(objectConfig.enable_events){
298
+ relatedListObjects.push({
299
+ object_name: 'events',
300
+ foreign_key: 'related_to'
301
+ })
302
+ }
303
+ if(objectConfig.enable_instances){
304
+ relatedListObjects.push({
305
+ object_name: 'instances',
306
+ foreign_key: 'record_ids'
307
+ })
308
+ }
309
+ if(objectConfig.enable_approvals){
310
+ relatedListObjects.push({
311
+ object_name: 'approvals',
312
+ foreign_key: 'related_to'
313
+ })
314
+ }
315
+ if(objectConfig.enable_process){
316
+ relatedListObjects.push({
317
+ object_name: 'process_instance_history',
318
+ foreign_key: 'target_object'
319
+ })
320
+ }
321
+ if(objectConfig.enable_audit){
322
+ relatedListObjects.push({
323
+ object_name: 'audit_records',
324
+ foreign_key: 'related_to'
325
+ })
326
+ }
327
+
328
+ for( let i = 0; i < relatedListObjects.length; i ++ ) {
329
+ // 获得相关对象的字段
330
+ const fieldsArr = [];
331
+ _.each(objectConfig.fields, (field, field_name) => {
332
+ if (!_.has(field, "name")) {
333
+ field.name = field_name;
334
+ }
335
+ fieldsArr.push(field);
336
+ })
337
+ let relatedOptions = [];
338
+ relatedOptions = _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field) => {
339
+ if ((!field.hidden) && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown", "html"], field.type)) {
340
+ return {
341
+ 'value': field.name,
342
+ 'label': field.label || field.name
343
+ }
344
+ }
345
+ })));
346
+
347
+ let relatedObject = await objectql.getSteedosSchema().getObject(relatedListObjects[i].object_name);
348
+ _.each(relatedOptions, (relatedOption)=>{
349
+ if (relatedListObjects[i].foreign_key != relatedOption.value){
350
+ output.push({
351
+ 'value': relatedObject.name + '.' + relatedOption.value,
352
+ 'label': (relatedObject.label || relatedObject.name) + '=>' + relatedOption.label
353
+ })
354
+ }
355
+ })
356
+ }
357
+ }
358
+ // 根据用户关键字进行过滤
359
+ if( ctx.params.term ) {
360
+ let form_fields = output;
361
+ output = [];
362
+ form_fields.forEach((item) => {
363
+ if(item.label.toLowerCase().indexOf(ctx.params.term.toLowerCase()) !== -1)
364
+ output.push(item);
365
+ })
366
+ }
367
+ output = _.uniqWith(_.compact(output), _.isEqual);
368
+ return output;
235
369
  }
236
370
  },
237
371
  getObjectFieldsLayoutOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "yarn build:tailwind-base && yarn build:tailwind",
@@ -13,7 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "gitHead": "802cae87c7da664458bf1d2321d65808ed1d243a",
16
+ "gitHead": "04caa0eb2226278f96c01825dd2828170c1f9789",
17
17
  "devDependencies": {
18
18
  "tailwindcss": "3.2.4"
19
19
  }
@@ -332,8 +332,8 @@
332
332
  padding-top: 1rem
333
333
  }
334
334
 
335
- .pb-16 {
336
- padding-bottom: 4rem
335
+ .pb-24 {
336
+ padding-bottom: 6rem
337
337
  }
338
338
 
339
339
  .pb-4 {