@steedos-widgets/amis-object 1.2.35-beta.1 → 1.2.35-beta.2

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.
@@ -3766,9 +3766,10 @@ async function getFieldTpl (field, options){
3766
3766
  }
3767
3767
  }
3768
3768
 
3769
- async function getFieldsTemplate(fields, expand){
3770
- if(expand != false){
3771
- expand = true;
3769
+ async function getFieldsTemplate(fields, display){
3770
+ let expandFields = [];
3771
+ if(display != false){
3772
+ display = true;
3772
3773
  }
3773
3774
  let fieldsName = ['_id'];
3774
3775
  let displayFields = [];
@@ -3780,33 +3781,43 @@ async function getFieldsTemplate(fields, expand){
3780
3781
  }
3781
3782
  for (const field of fieldsArr) {
3782
3783
  //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
3783
- if(field.name.indexOf('.') < 0){
3784
- if(expand && (field.type == 'lookup' || field.type == 'master_detail')){
3785
- fieldsName.push(`${field.name}`);
3786
- displayFields.push(`${field.name}`);
3784
+ if(field.expand){
3785
+ expandFields.push(field);
3786
+ }else {
3787
+ if(field.name.indexOf('.') < 0){
3788
+ if(display && (field.type == 'lookup' || field.type == 'master_detail')){
3789
+ fieldsName.push(`${field.name}`);
3790
+ displayFields.push(`${field.name}`);
3791
+ }else {
3792
+ fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
3793
+ }
3794
+ if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
3795
+ fieldsName.push(`${field.name}`);
3796
+ }
3797
+ if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3798
+ displayFields.push(`${field.name}`);
3799
+ }
3787
3800
  }else {
3788
- fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
3789
- }
3790
- if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
3791
- fieldsName.push(`${field.name}`);
3792
- }
3793
- if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3794
- displayFields.push(`${field.name}`);
3801
+ objectFieldName = field.name.split('.')[0];
3802
+ fieldsName.push(objectFieldName);
3803
+ displayFields.push(objectFieldName);
3795
3804
  }
3796
- }else {
3797
- objectFieldName = field.name.split('.')[0];
3798
- fieldsName.push(objectFieldName);
3799
- displayFields.push(objectFieldName);
3800
3805
  }
3801
3806
  }
3802
3807
 
3803
3808
  displayFields = ___default.uniq(displayFields);
3804
3809
  fieldsName = ___default.uniq(fieldsName);
3810
+ let expandFieldsQuery = "";
3811
+ if(expandFields.length > 0){
3812
+ ___default.each(expandFields, function(field){
3813
+ expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
3814
+ });
3815
+ }
3805
3816
 
3806
3817
  if(displayFields.length > 0){
3807
- return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
3818
+ return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
3808
3819
  }
3809
- return `${fieldsName.join(' ')}`
3820
+ return `${fieldsName.join(' ')},${expandFieldsQuery}`
3810
3821
  }
3811
3822
 
3812
3823
  function getRecordPermissionsTemplate(){
@@ -13502,8 +13513,8 @@ async function getRelatedListSchema(
13502
13513
  /*
13503
13514
  * @Author: baozhoutao@steedos.com
13504
13515
  * @Date: 2022-07-05 15:55:39
13505
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13506
- * @LastEditTime: 2023-06-04 17:36:49
13516
+ * @LastEditors: baozhoutao@steedos.com
13517
+ * @LastEditTime: 2023-07-29 13:58:07
13507
13518
  * @Description:
13508
13519
  */
13509
13520
 
@@ -13837,6 +13848,7 @@ async function getListSchema(
13837
13848
  "filterVisible": ctx.filterVisible,
13838
13849
  "rowClassNameExpr": ctx.rowClassNameExpr
13839
13850
  };
13851
+ // console.log(`getListSchema===>`,amisSchema)
13840
13852
  return {
13841
13853
  uiSchema,
13842
13854
  amisSchema,
@@ -13850,7 +13862,7 @@ async function getTableSchema(
13850
13862
  columns,
13851
13863
  ctx = {}
13852
13864
  ) {
13853
- // console.time('getTableSchema');
13865
+ // console.time('getTableSchema', columns);
13854
13866
  const uiSchema = await getUISchema(objectName);
13855
13867
 
13856
13868
  let sort = ctx.sort;
@@ -13864,19 +13876,52 @@ async function getTableSchema(
13864
13876
  }
13865
13877
 
13866
13878
  let fields = [];
13867
- each(columns, function (column) {
13868
- if (isString(column) && uiSchema.fields[column]) {
13869
- fields.push(uiSchema.fields[column]);
13870
- } else if (isObject$1(column) && uiSchema.fields[column.field]) {
13871
- fields.push(
13872
- Object.assign({}, uiSchema.fields[column.field], {
13873
- width: column.width,
13874
- wrap: column.wrap, // wrap = true 是没效果的
13875
- amis: column.amis
13876
- })
13877
- );
13879
+ for(const column of columns){
13880
+ if (isString(column)) {
13881
+ if(column.indexOf('.') > 0){
13882
+ const fieldName = column.split('.')[0];
13883
+ const displayName = column.split('.')[1];
13884
+ const filedInfo = uiSchema.fields[fieldName];
13885
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
13886
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
13887
+ const rfFieldInfo = rfUiSchema.fields[displayName];
13888
+ fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
13889
+ }
13890
+ }else {
13891
+ if(uiSchema.fields[column]){
13892
+ fields.push(uiSchema.fields[column]);
13893
+ }
13894
+ }
13895
+ } else if (isObject$1(column)) {
13896
+ if(column.field.indexOf('.') > 0){
13897
+ const fieldName = column.field.split('.')[0];
13898
+ const displayName = column.field.split('.')[1];
13899
+ const filedInfo = uiSchema.fields[fieldName];
13900
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
13901
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
13902
+ const rfFieldInfo = rfUiSchema.fields[displayName];
13903
+ fields.push(Object.assign({}, rfFieldInfo,
13904
+ {name: column.field, expand: true, expandInfo: {fieldName, displayName}},
13905
+ {
13906
+ width: column.width,
13907
+ wrap: column.wrap, // wrap = true 是没效果的
13908
+ amis: column.amis
13909
+ }
13910
+ ));
13911
+ }
13912
+ }else {
13913
+ if(uiSchema.fields[column.field]){
13914
+ fields.push(
13915
+ Object.assign({}, uiSchema.fields[column.field], {
13916
+ width: column.width,
13917
+ wrap: column.wrap, // wrap = true 是没效果的
13918
+ amis: column.amis
13919
+ })
13920
+ );
13921
+ }
13922
+ }
13878
13923
  }
13879
- });
13924
+ }
13880
13925
 
13881
13926
  const extraColumns = ctx.extraColumns;
13882
13927