@steedos-widgets/amis-lib 1.1.12-beta.1 → 1.1.12

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/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, keys, sortBy, compact, toArray, mergeWith, isBoolean, omitBy, isNil, isString, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, has, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, keys, sortBy, compact, toArray, mergeWith, isBoolean, omitBy, isNil, isString, union, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, has, filter, startsWith } from 'lodash';
3
3
  import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
4
4
  import isPlainObject from 'lodash/isPlainObject';
5
5
 
@@ -5463,12 +5463,12 @@ async function getEditFormInitApi(object, recordId, fields, options){
5463
5463
  if(uiSchema.form){
5464
5464
  try{
5465
5465
  var objectFormConfig = JSON.parse(uiSchema.form);
5466
- initialValues = objectFormConfig.initialValues;
5467
- if(initialValues){
5468
- initialValues = new Function("return " + initialValues)();
5466
+ var formInitialValuesFun = objectFormConfig.initialValues;
5467
+ if(formInitialValuesFun){
5468
+ formInitialValuesFun = new Function("return " + formInitialValuesFun)();
5469
5469
  }
5470
- if(typeof initialValues === "function"){
5471
- initialValues = initialValues.apply({doc: defaultValues || {} })
5470
+ if(typeof formInitialValuesFun === "function"){
5471
+ initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
5472
5472
  }
5473
5473
  }
5474
5474
  catch(ex){
@@ -5485,12 +5485,15 @@ async function getEditFormInitApi(object, recordId, fields, options){
5485
5485
  }
5486
5486
  // data下的变量需要在保存接口(getSaveApi)中被删除。
5487
5487
  payload.data = {
5488
- initialValues,
5489
- editFormInited: true
5488
+ ...initialValues
5490
5489
  }
5491
5490
  ${options.initApiAdaptor || ''}
5492
5491
  return payload;
5493
5492
  `,
5493
+ responseData: {
5494
+ initialValues: "$$",
5495
+ editFormInited: true
5496
+ },
5494
5497
  data: data,
5495
5498
  headers: {
5496
5499
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -6617,28 +6620,8 @@ async function getTableApi(mainObject, fields, options){
6617
6620
 
6618
6621
  if(enable_tree){
6619
6622
  const records = payload.data.rows;
6620
- const treeRecords = [];
6621
- const getChildren = (records, childrenIds)=>{
6622
- if(!childrenIds){
6623
- return;
6624
- }
6625
- const children = _.filter(records, (record)=>{
6626
- return _.includes(childrenIds, record._id)
6627
- });
6628
- _.each(children, (item)=>{
6629
- if(item.children){
6630
- item.children = getChildren(records, item.children)
6631
- }
6632
- })
6633
- return children;
6634
- }
6635
-
6636
- _.each(records, (record)=>{
6637
- if(!record.parent){
6638
- treeRecords.push(Object.assign({}, record, {children: getChildren(records, record.children)}));
6639
- }
6640
- });
6641
- payload.data.rows = treeRecords;
6623
+ const getTreeOptions = SteedosUI.getTreeOptions
6624
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
6642
6625
  }
6643
6626
 
6644
6627
 
@@ -7331,7 +7314,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
7331
7314
  * @Author: baozhoutao@steedos.com
7332
7315
  * @Date: 2022-07-05 15:55:39
7333
7316
  * @LastEditors: Please set LastEditors
7334
- * @LastEditTime: 2023-04-13 09:20:21
7317
+ * @LastEditTime: 2023-04-18 19:13:30
7335
7318
  * @Description:
7336
7319
  */
7337
7320
 
@@ -7428,7 +7411,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
7428
7411
  mainRelated[arr[0]] = arr[1];
7429
7412
  }
7430
7413
  }else {
7431
- const details = mainObjectUiSchema.details || [];
7414
+ const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
7432
7415
  for (const detail of details) {
7433
7416
  const arr = detail.split(".");
7434
7417
  mainRelated[arr[0]] = arr[1];